comparison cagou/plugins/plugin_wid_widget_selector.py @ 365:9c6fe392d623

core (widgets_handler): use a StencilView + BoxLayout instead of ScrollView as wrapper: The default wrapping when no Carousel or ScreenManager was used was a ScrollView. This was causing bugs as the touch event is not propagated correctly when a ScrollView is in children of ScrollView (notably causing trouble with ModernMenu on ContactList and FileSharing widgets). To avoid that, a simple StencilView with BoxLayout is now used instead. If a ScrollView is needed, it can be added inside the widget (this is the case for WidgetSelector).
author Goffi <goffi@goffi.org>
date Mon, 27 Jan 2020 21:17:08 +0100
parents 4d3a0c4f2430
children 4d660b252487
comparison
equal deleted inserted replaced
364:a1f3af7c0b67 365:9c6fe392d623
43 item = properties.ObjectProperty() 43 item = properties.ObjectProperty()
44 44
45 def on_release(self, *args): 45 def on_release(self, *args):
46 log.debug("widget selection: {}".format(self.plugin_info["name"])) 46 log.debug("widget selection: {}".format(self.plugin_info["name"]))
47 factory = self.plugin_info["factory"] 47 factory = self.plugin_info["factory"]
48 G.host.switchWidget(self, factory(self.plugin_info, None, profiles=iter(G.host.profiles))) 48 G.host.switchWidget(
49 self, factory(self.plugin_info, None, profiles=iter(G.host.profiles)))
49 50
50 51
51 class WidgetSelector(cagou_widget.CagouWidget): 52 class WidgetSelector(cagou_widget.CagouWidget):
52 # TODO: should inherit from QuickWidget 53 container = properties.ObjectProperty()
53 54
54 def __init__(self): 55 def __init__(self):
55 super(WidgetSelector, self).__init__() 56 super(WidgetSelector, self).__init__()
56 self.items = [] 57 self.items = []
57 for plugin_info in G.host.getPluggedWidgets(except_cls=self.__class__): 58 for plugin_info in G.host.getPluggedWidgets(except_cls=self.__class__):
58 item = WidgetSelItem(plugin_info=plugin_info) 59 item = WidgetSelItem(plugin_info=plugin_info)
59 self.items.append(item.item) 60 self.items.append(item.item)
60 item.item.bind(minimum_width=self.adjust_width) 61 item.item.bind(minimum_width=self.adjust_width)
61 self.add_widget(item) 62 self.container.add_widget(item)
62 self.add_widget(Widget()) 63 self.container.add_widget(Widget())
63 64
64 def adjust_width(self, label, texture_size): 65 def adjust_width(self, label, texture_size):
65 width = max([i.minimum_width for i in self.items]) 66 width = max([i.minimum_width for i in self.items])
66 for i in self.items: 67 for i in self.items:
67 i.width = width 68 i.width = width