Mercurial > libervia-desktop-kivy
diff cagou/core/xmlui.py @ 241:661b9cf7b4e4
xmlui: scroll/size fixes:
- VerticalContainer and TabsPanelContainer are now put in ScrollView
- the height hack in TabsContainer has been removed has it is not needed anymore (minimum_height is now available)
- remove the empty widget which was added at the end of main panel, it's better to have the UI taking the whole container height
- fixed height for TextWidget,LabelWidget and JidWidget
- better scrollbar for VerticalContainer and TabsPanelContainer
author | Goffi <goffi@goffi.org> |
---|---|
date | Thu, 03 Jan 2019 10:42:43 +0100 |
parents | ca86954b3788 |
children | 50f7c000b4ae |
line wrap: on
line diff
--- a/cagou/core/xmlui.py Sat Oct 06 09:48:52 2018 +0200 +++ b/cagou/core/xmlui.py Thu Jan 03 10:42:43 2019 +0100 @@ -22,6 +22,7 @@ from sat.core.log import getLogger log = getLogger(__name__) from sat_frontends.tools import xmlui +from kivy.uix.scrollview import ScrollView from kivy.uix.boxlayout import BoxLayout from kivy.uix.gridlayout import GridLayout from kivy.uix.tabbedpanel import TabbedPanel, TabbedPanelItem @@ -278,14 +279,15 @@ ## Containers ## -class VerticalContainer(xmlui.VerticalContainer, BoxLayout): +class VerticalContainer(xmlui.VerticalContainer, ScrollView): + layout = properties.ObjectProperty(None) def __init__(self, xmlui_parent): self.xmlui_parent = xmlui_parent - BoxLayout.__init__(self, orientation="vertical") + ScrollView.__init__(self) def _xmluiAppend(self, widget): - self.add_widget(widget) + self.layout.add_widget(widget) class PairsContainer(xmlui.PairsContainer, GridLayout): @@ -303,19 +305,16 @@ class TabsPanelContainer(TabbedPanelItem): + layout = properties.ObjectProperty(None) def _xmluiAppend(self, widget): - self.add_widget(widget) + self.layout.add_widget(widget) class TabsContainer(xmlui.TabsContainer, TabbedPanel): def __init__(self, xmlui_parent): self.xmlui_parent = xmlui_parent - xmlui_panel = xmlui_parent - while not isinstance(xmlui_panel, XMLUIPanel): - xmlui_panel = xmlui_panel.xmlui_parent - xmlui_panel.addPostTreat(self._postTreat) TabbedPanel.__init__(self, do_default_tab=False) def _xmluiAddTab(self, label, selected): @@ -323,17 +322,6 @@ self.add_widget(tab) return tab - def _postTreat(self): - """bind minimum height of tabs' content so self.height is adapted""" - # we need to do this in postTreat because contents exists after UI construction - for t in self.tab_list: - t.content.bind(minimum_height=self._updateHeight) - - def _updateHeight(self, instance, height): - """Called after UI is constructed (so height can be calculated)""" - # needed because TabbedPanel doesn't have a minimum_height property - self.height = max([t.content.minimum_height for t in self.tab_list]) + self.tab_height + 5 - class AdvancedListRow(GridLayout): global_index = 0 @@ -514,7 +502,7 @@ widget_factory = WidgetFactory() def __init__(self, host, parsed_xml, title=None, flags=None, callback=None, ignore=None, whitelist=None, profile=C.PROF_KEY_NONE): - BoxLayout.__init__(self, orientation="vertical") + BoxLayout.__init__(self) self.close_cb = None self._post_treats = [] # list of callback to call after UI is constructed xmlui.XMLUIPanel.__init__(self, @@ -569,7 +557,6 @@ self.save_btn = FormButton(text=_(u"Save"), disabled=True) self.save_btn.bind(on_press=self._saveButtonCb) self.add_widget(self.save_btn) - self.add_widget(Widget()) # to have elements on the top def show(self, *args, **kwargs): if not self.user_action and not kwargs.get("force", False):