comparison 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
comparison
equal deleted inserted replaced
165:e6ec8ff62d87 166:37220459e93d
50 from kivy.uix.label import Label 50 from kivy.uix.label import Label
51 from kivy.uix.boxlayout import BoxLayout 51 from kivy.uix.boxlayout import BoxLayout
52 from kivy.uix.floatlayout import FloatLayout 52 from kivy.uix.floatlayout import FloatLayout
53 from kivy.uix.screenmanager import ScreenManager, Screen, FallOutTransition, RiseInTransition 53 from kivy.uix.screenmanager import ScreenManager, Screen, FallOutTransition, RiseInTransition
54 from kivy.uix.dropdown import DropDown 54 from kivy.uix.dropdown import DropDown
55 from kivy.core.window import Window
56 from kivy.animation import Animation
57 from kivy.metrics import dp
55 from cagou_widget import CagouWidget 58 from cagou_widget import CagouWidget
56 from . import widgets_handler 59 from . import widgets_handler
57 from .common import IconButton 60 from .common import IconButton
58 from . import menu 61 from . import menu
59 from importlib import import_module 62 from importlib import import_module
61 import glob 64 import glob
62 import cagou.plugins 65 import cagou.plugins
63 import cagou.kv 66 import cagou.kv
64 from kivy import utils as kivy_utils 67 from kivy import utils as kivy_utils
65 import sys 68 import sys
66 from kivy.core.window import Window
67 69
68 # we want white background by default 70 # we want white background by default
69 Window.clearcolor = (1, 1, 1, 1) 71 Window.clearcolor = (1, 1, 1, 1)
70 72
71 73
156 screen.add_widget(note) 158 screen.add_widget(note)
157 self.manager.switch_to(screen) 159 self.manager.switch_to(screen)
158 160
159 161
160 class RootMenus(menu.MenusWidget): 162 class RootMenus(menu.MenusWidget):
161 pass 163 HEIGHT = dp(30)
162 164
163 165
164 class RootBody(BoxLayout): 166 class RootBody(BoxLayout):
165 pass 167 pass
166 168
230 # a settings screen when pressing F1 or platform specific key 232 # a settings screen when pressing F1 or platform specific key
231 return 233 return
232 234
233 def build(self): 235 def build(self):
234 Window.bind(on_keyboard=self.key_input) 236 Window.bind(on_keyboard=self.key_input)
235 return CagouRootWidget(Label(text=u"Loading please wait")) 237 wid = CagouRootWidget(Label(text=u"Loading please wait"))
238 if sys.platform == 'android':
239 # we don't want menu on Android
240 wid.root_menus.height = 0
241 return wid
236 242
237 def showWidget(self): 243 def showWidget(self):
238 self._profile_manager = ProfileManager() 244 self._profile_manager = ProfileManager()
239 self.root.changeWidget(self._profile_manager) 245 self.root.changeWidget(self._profile_manager)
240 246
276 self.cagou_status[0] = 'S' 282 self.cagou_status[0] = 'S'
277 self.cagou_status.flush() 283 self.cagou_status.flush()
278 self.cagou_status_fd.close() 284 self.cagou_status_fd.close()
279 285
280 def key_input(self, window, key, scancode, codepoint, modifier): 286 def key_input(self, window, key, scancode, codepoint, modifier):
281 # we disable [esc] handling, because default action is to quit app
282 if key == 27: 287 if key == 27:
288 # we disable [esc] handling, because default action is to quit app
283 return True 289 return True
284 elif key == 292: 290 elif key == 292:
291 # F11: full screen
285 if not Window.fullscreen: 292 if not Window.fullscreen:
286 window.fullscreen = 'auto' 293 window.fullscreen = 'auto'
287 else: 294 else:
288 window.fullscreen = False 295 window.fullscreen = False
296 return True
297 elif key == 109 and modifier == ['alt']:
298 # M-m we hide/show menu
299 menu = self.root.root_menus
300 if menu.height:
301 Animation(height=0, duration=0.3).start(menu)
302 else:
303 Animation(height=menu.HEIGHT, duration=0.3).start(menu)
289 return True 304 return True
290 else: 305 else:
291 return False 306 return False
292 307
293 308