diff --git a/src/buskill.kv b/src/buskill.kv index 066e09b0..c1ac8a29 100644 --- a/src/buskill.kv +++ b/src/buskill.kv @@ -7,7 +7,7 @@ # Updated: 2023-06-14 # Version: 0.3 ################################################################################ - +#:import BusKillNavigationDrawer buskill_gui : @@ -64,7 +64,7 @@ title: '[font=RobotoMedium][size=20] BusKill[/size][/font]' on_release: root.toggle_menu() - NavigationDrawer: + BusKillNavigationDrawer: id: nav_drawer anim_type: 'slide_above_simple' side_panel_width: min( dp(300), 0.8*self.width ) diff --git a/src/buskill_gui.py b/src/buskill_gui.py index f934004f..161f4ffb 100755 --- a/src/buskill_gui.py +++ b/src/buskill_gui.py @@ -89,6 +89,41 @@ def get_screen_manager(obj): return None +class BusKillNavigationDrawer(NavigationDrawer): + """Fixes issue #43: nav drawer swipe gesture works on all screens. + + Root cause: Kivy dispatches on_touch_down to children first. Child + screens (Settings, DebugLog, etc.) consume the touch before the + NavigationDrawer can detect the left-edge swipe gesture. + + Fix: grab left-edge touches before dispatching to children. + """ + + def on_touch_down(self, touch): + if not self.collide_point(*touch.pos): + return super().on_touch_down(touch) + + if self._anim_progress < 0.001: + if touch.x <= self.touch_accept_width: + self._touch = touch + touch.grab(self) + self._start_touch_x = touch.x + self._start_time = touch.time_start + super().on_touch_down(touch) + return True + + return super().on_touch_down(touch) + + def on_touch_move(self, touch): + if touch.grab_current is self: + return super().on_touch_move(touch) + return super().on_touch_move(touch) + + def on_touch_up(self, touch): + if touch.grab_current is self: + return super().on_touch_up(touch) + return super().on_touch_up(touch) + class MainWindow(Screen): toggle_btn = ObjectProperty(None) diff --git a/src/packages/garden/navigationdrawer/__init__.py b/src/packages/garden/navigationdrawer/__init__.py index 5bf75fd7..1bfdfa22 100644 --- a/src/packages/garden/navigationdrawer/__init__.py +++ b/src/packages/garden/navigationdrawer/__init__.py @@ -515,7 +515,8 @@ def on_touch_down(self, touch): touch.x <= (self.x + self.touch_accept_width)) if not valid_region: - self._main_panel.on_touch_down(touch) + if col_main: + self._main_panel.on_touch_down(touch) return False else: if col_side and not self._main_above: