# HG changeset patch # User Goffi # Date 1548530688 -3600 # Node ID 1f579baf787ac3f8ecd5ddde9dc2936b24ed5bf9 # Parent ff1efdeff53f355cdb91193028ac024c948e79d3 xmlui: some design improvments + use ScrollView + BoxLayout instead of DropDown for ListWidget: there are some trouble with the ScrollView inside the ScrollView which need to be addressed diff -r ff1efdeff53f -r 1f579baf787a cagou/core/xmlui.py --- a/cagou/core/xmlui.py Sat Jan 26 20:24:48 2019 +0100 +++ b/cagou/core/xmlui.py Sat Jan 26 20:24:48 2019 +0100 @@ -31,7 +31,6 @@ from kivy.uix.button import Button from kivy.uix.togglebutton import ToggleButton from kivy.uix.widget import Widget -from kivy.uix.dropdown import DropDown from kivy.uix.switch import Switch from kivy import properties from cagou import G @@ -131,13 +130,13 @@ value = properties.StringProperty() def on_release(self): - super(ListWidgetItem, self).on_release() parent = self.parent - while parent is not None and not isinstance(parent, DropDown): + while parent is not None and not isinstance(parent, ListWidget): parent = parent.parent - if parent is not None and parent.attach_to is not None: + if parent is not None: parent.select(self) + return super(ListWidgetItem, self).on_release() @property def selected(self): @@ -148,16 +147,12 @@ self.state = 'down' if value else 'normal' -class ListWidget(xmlui.ListWidget, Button): +class ListWidget(xmlui.ListWidget, ScrollView): + layout = properties.ObjectProperty() def __init__(self, _xmlui_parent, options, selected, flags): - Button.__init__(self) - self.text = _(u"open list") - self._dropdown = DropDown() - self._dropdown.auto_dismiss = False - self._dropdown.bind(on_select = self.on_select) + ScrollView.__init__(self) self.multi = 'single' not in flags - self._dropdown.dismiss_on_select = not self.multi self._values = [] for option in options: self.addValue(option) @@ -166,26 +161,9 @@ @property def items(self): - return self._dropdown.children[0].children + return self.layout.children - def on_touch_down(self, touch): - # we simulate auto-dismiss ourself because dropdown - # will dismiss even if attached button is touched - # resulting in a dismiss just before a toggle in on_release - # so the dropbox would always be opened, we don't want that! - if super(ListWidget, self).on_touch_down(touch): - return True - if self._dropdown.parent: - self._dropdown.dismiss() - - def on_release(self): - if self._dropdown.parent is not None: - # we want to close a list already opened - self._dropdown.dismiss() - else: - self._dropdown.open(self) - - def on_select(self, drop_down, item): + def select(self, item): if not self.multi: self._xmluiSelectValues([item.value]) if self._on_change is not None: @@ -200,7 +178,7 @@ item = ListWidgetItem() item.value, item.text = option item.selected = selected - self._dropdown.add_widget(item) + self.layout.add_widget(item) def _xmluiSelectValue(self, value): self._xmluiSelectValues([value]) diff -r ff1efdeff53f -r 1f579baf787a cagou/kv/xmlui.kv --- a/cagou/kv/xmlui.kv Sat Jan 26 20:24:48 2019 +0100 +++ b/cagou/kv/xmlui.kv Sat Jan 26 20:24:48 2019 +0100 @@ -27,9 +27,9 @@ : - size_hint: 1, None + size_hint: 1, 1 + size_hint_min_y: max(dp(common_height), self.texture_size[1]) text_size: self.width, None - height: max(dp(common_height), self.texture_size[1]) color: 1, 1, 1, 1 @@ -70,7 +70,17 @@ : size_hint: 1, None - height: dp(button_height) + layout: layout + height: min(layout.minimum_height, dp(250)) + do_scroll_x: False + scroll_type: ['bars', 'content'] + bar_width: dp(6) + BoxLayout: + id: layout + size_hint: 1, None + height: self.minimum_height + orientation: "vertical" + padding: dp(10) : @@ -114,6 +124,7 @@ cols: 2 size_hint: 1, None height: self.minimum_height + padding: dp(10) :