diff cagou/core/cagou_main.py @ 154:a5e8833184c6

widget handler: refactoring: - replaced proof of concept implementation with cleaner one based on custom layout - removed proof of concept big bars in favor of thin line to separate widgets, with a 3 dots area in the center where user can touch/click more easily - when in delete zone, the line + half circle become red, so user knows that she's about to delete a widget - carousel is now created in kv - ignore perpendicular swipes. This was not working before but is know working well, and the swipe is far more easy to do on desktop or mobile - each new widget of the handler has an id (its creation number), which is displayed in debug logs on touch - handler's widgets keep track of which widgets are on sides (left, top, right, bottom)
author Goffi <goffi@goffi.org>
date Fri, 27 Apr 2018 16:45:09 +0200
parents b9fd83292fc4
children e6ec8ff62d87
line wrap: on
line diff
--- a/cagou/core/cagou_main.py	Fri Apr 27 16:37:15 2018 +0200
+++ b/cagou/core/cagou_main.py	Fri Apr 27 16:45:09 2018 +0200
@@ -46,7 +46,6 @@
 from kivy import properties
 import xmlui
 from profile_manager import ProfileManager
-from widgets_handler import WidgetsHandler
 from kivy.clock import Clock
 from kivy.uix.label import Label
 from kivy.uix.boxlayout import BoxLayout
@@ -571,16 +570,6 @@
         if isinstance(widget, quick_chat.QuickChat) and widget.type == C.CHAT_GROUP:
             self.addNote(u"", _(u"room {} has been joined").format(widget.target))
 
-    def getParentHandler(self, widget):
-        """Return handler holding this widget
-
-        @return (WidgetsHandler): handler
-        """
-        w_handler = widget.parent
-        while w_handler and not(isinstance(w_handler, widgets_handler.WidgetsHandler)):
-            w_handler = w_handler.parent
-        return w_handler
-
     def switchWidget(self, old, new):
         """Replace old widget by new one
 
@@ -598,8 +587,15 @@
 
         if to_change is None:
             raise exceptions.InternalError(u"no CagouWidget found when trying to switch widget")
-        handler = self.getParentHandler(to_change)
-        handler.changeWidget(new)
+
+        wrapper = to_change.parent
+        while wrapper is not None and not(isinstance(wrapper, widgets_handler.WHWrapper)):
+            wrapper = wrapper.parent
+
+        if wrapper is None:
+            raise exceptions.InternalError(u"no wrapper found")
+
+        wrapper.changeWidget(new)
 
     def addVisibleWidget(self, widget):
         """declare a widget visible
@@ -658,7 +654,7 @@
     ## misc ##
 
     def plugging_profiles(self):
-        self.app.root.changeWidget(WidgetsHandler())
+        self.app.root.changeWidget(widgets_handler.WidgetsHandler())
         self.bridge.menusGet("", C.NO_SECURITY_LIMIT, callback=self._menusGetCb)
 
     def setPresenceStatus(self, show='', status=None, profile=C.PROF_KEY_NONE):