diff cagou/core/cagou_main.py @ 166:37220459e93d

core: hide/show menu on M-m + disable menu on Android
author Goffi <goffi@goffi.org>
date Sat, 28 Apr 2018 15:40:28 +0200
parents e6ec8ff62d87
children 7103655647aa
line wrap: on
line diff
--- a/cagou/core/cagou_main.py	Sat Apr 28 12:46:50 2018 +0200
+++ b/cagou/core/cagou_main.py	Sat Apr 28 15:40:28 2018 +0200
@@ -52,6 +52,9 @@
 from kivy.uix.floatlayout import FloatLayout
 from kivy.uix.screenmanager import ScreenManager, Screen, FallOutTransition, RiseInTransition
 from kivy.uix.dropdown import DropDown
+from kivy.core.window import Window
+from kivy.animation import Animation
+from kivy.metrics import dp
 from cagou_widget import CagouWidget
 from . import widgets_handler
 from .common import IconButton
@@ -63,7 +66,6 @@
 import cagou.kv
 from kivy import utils as kivy_utils
 import sys
-from kivy.core.window import Window
 
 # we want white background by default
 Window.clearcolor = (1, 1, 1, 1)
@@ -158,7 +160,7 @@
 
 
 class RootMenus(menu.MenusWidget):
-    pass
+    HEIGHT = dp(30)
 
 
 class RootBody(BoxLayout):
@@ -232,7 +234,11 @@
 
     def build(self):
         Window.bind(on_keyboard=self.key_input)
-        return CagouRootWidget(Label(text=u"Loading please wait"))
+        wid = CagouRootWidget(Label(text=u"Loading please wait"))
+        if sys.platform == 'android':
+            # we don't want menu on Android
+            wid.root_menus.height = 0
+        return wid
 
     def showWidget(self):
         self._profile_manager = ProfileManager()
@@ -278,15 +284,24 @@
             self.cagou_status_fd.close()
 
     def key_input(self, window, key, scancode, codepoint, modifier):
-        # we disable [esc] handling, because default action is to quit app
         if key == 27:
+            # we disable [esc] handling, because default action is to quit app
             return True
         elif key == 292:
+            # F11: full screen
             if not Window.fullscreen:
                 window.fullscreen = 'auto'
             else:
                 window.fullscreen = False
             return True
+        elif key == 109 and modifier == ['alt']:
+            # M-m we hide/show menu
+            menu = self.root.root_menus
+            if menu.height:
+                Animation(height=0, duration=0.3).start(menu)
+            else:
+                Animation(height=menu.HEIGHT, duration=0.3).start(menu)
+            return True
         else:
             return False