# HG changeset patch # User Goffi # Date 1524922828 -7200 # Node ID 37220459e93d04f28e3c30e7c6a1eef971851ac0 # Parent e6ec8ff62d87611adb1bae0936af73ecbdc9bec7 core: hide/show menu on M-m + disable menu on Android diff -r e6ec8ff62d87 -r 37220459e93d cagou/core/cagou_main.py --- 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 diff -r e6ec8ff62d87 -r 37220459e93d cagou/kv/menu.kv --- a/cagou/kv/menu.kv Sat Apr 28 12:46:50 2018 +0200 +++ b/cagou/kv/menu.kv Sat Apr 28 15:40:28 2018 +0200 @@ -31,7 +31,7 @@ size_hint: 1, None : - height: self.children[0].height if self.children else 30 + height: 30 : cancel_handler_widget: self.parent diff -r e6ec8ff62d87 -r 37220459e93d cagou/kv/root_widget.kv --- a/cagou/kv/root_widget.kv Sat Apr 28 12:46:50 2018 +0200 +++ b/cagou/kv/root_widget.kv Sat Apr 28 15:40:28 2018 +0200 @@ -95,3 +95,4 @@ # need to be added at the end so it's drawed above other widgets RootMenus: id: root_menus + height: self.HEIGHT