Mercurial > libervia-desktop-kivy
changeset 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 | a1f3af7c0b67 |
children | 58e395c0777e |
files | cagou/core/menu.py cagou/core/widgets_handler.py cagou/plugins/plugin_wid_contact_list.py cagou/plugins/plugin_wid_widget_selector.kv cagou/plugins/plugin_wid_widget_selector.py |
diffstat | 5 files changed, 30 insertions(+), 19 deletions(-) [+] |
line wrap: on
line diff
--- a/cagou/core/menu.py Mon Jan 27 21:17:08 2020 +0100 +++ b/cagou/core/menu.py Mon Jan 27 21:17:08 2020 +0100 @@ -448,8 +448,8 @@ if not choices: return self.menu = TouchMenu(choices=choices, - center=pos, - size_hint=(None, None)) + center=pos, + size_hint=(None, None)) self.float_layout.add_widget(self.menu) self.menu.start_display(touch) self.menu_item = item
--- a/cagou/core/widgets_handler.py Mon Jan 27 21:17:08 2020 +0100 +++ b/cagou/core/widgets_handler.py Mon Jan 27 21:17:08 2020 +0100 @@ -26,7 +26,6 @@ from kivy.uix.stencilview import StencilView from kivy.uix.carousel import Carousel from kivy.uix.screenmanager import ScreenManager, Screen -from kivy.uix.scrollview import ScrollView from kivy.metrics import dp from kivy import properties from cagou import G @@ -40,6 +39,10 @@ MIN_WIDTH = MIN_HEIGHT = dp(70) +class BoxStencil(BoxLayout, StencilView): + pass + + class WHWrapper(BoxLayout): main_container = properties.ObjectProperty(None) screen_manager = properties.ObjectProperty(None, allownone=True) @@ -371,7 +374,7 @@ if wid.collection_carousel or wid.global_screen_manager: self.main_container = self else: - self.main_container = ScrollView() + self.main_container = BoxStencil() self.add_widget(self.main_container) if self.carousel is not None:
--- a/cagou/plugins/plugin_wid_contact_list.py Mon Jan 27 21:17:08 2020 +0100 +++ b/cagou/plugins/plugin_wid_contact_list.py Mon Jan 27 21:17:08 2020 +0100 @@ -18,21 +18,23 @@ # along with this program. If not, see <http://www.gnu.org/licenses/>. +from functools import partial +import bisect +import re from sat.core import log as logging -log = logging.getLogger(__name__) -from cagou.core.constants import Const as C -from ..core.common import ContactItem from sat.core.i18n import _ from sat_frontends.quick_frontend.quick_contact_list import QuickContactList from sat_frontends.tools import jid -from cagou.core.utils import FilterBehavior -from cagou.core.menu import SideMenu, TouchMenuBehaviour, TouchMenuItemBehaviour from kivy import properties -from cagou.core import cagou_widget from cagou import G -from functools import partial -import bisect -import re +from ..core import cagou_widget +from ..core.constants import Const as C +from ..core.common import ContactItem +from ..core.utils import FilterBehavior +from ..core.menu import SideMenu, TouchMenuBehaviour, TouchMenuItemBehaviour + + +log = logging.getLogger(__name__) PLUGIN_INFO = {
--- a/cagou/plugins/plugin_wid_widget_selector.kv Mon Jan 27 21:17:08 2020 +0100 +++ b/cagou/plugins/plugin_wid_widget_selector.kv Mon Jan 27 21:17:08 2020 +0100 @@ -39,5 +39,10 @@ <WidgetSelector>: spacing: dp(10) - size_hint: 1, None - height: self.minimum_height + container: container + ScrollView: + BoxLayout: + orientation: "vertical" + size_hint: 1, None + height: self.minimum_height + id: container
--- a/cagou/plugins/plugin_wid_widget_selector.py Mon Jan 27 21:17:08 2020 +0100 +++ b/cagou/plugins/plugin_wid_widget_selector.py Mon Jan 27 21:17:08 2020 +0100 @@ -45,11 +45,12 @@ def on_release(self, *args): log.debug("widget selection: {}".format(self.plugin_info["name"])) factory = self.plugin_info["factory"] - G.host.switchWidget(self, factory(self.plugin_info, None, profiles=iter(G.host.profiles))) + G.host.switchWidget( + self, factory(self.plugin_info, None, profiles=iter(G.host.profiles))) class WidgetSelector(cagou_widget.CagouWidget): - # TODO: should inherit from QuickWidget + container = properties.ObjectProperty() def __init__(self): super(WidgetSelector, self).__init__() @@ -58,8 +59,8 @@ item = WidgetSelItem(plugin_info=plugin_info) self.items.append(item.item) item.item.bind(minimum_width=self.adjust_width) - self.add_widget(item) - self.add_widget(Widget()) + self.container.add_widget(item) + self.container.add_widget(Widget()) def adjust_width(self, label, texture_size): width = max([i.minimum_width for i in self.items])