Mercurial > libervia-desktop-kivy
comparison cagou/core/cagou_main.py @ 423:f8ba934ea462
core: new showHeadWidget method to show/hide notifications header.
author | Goffi <goffi@goffi.org> |
---|---|
date | Wed, 26 Feb 2020 16:42:22 +0100 |
parents | 83d184393fe1 |
children | 58d3ea442f9c |
comparison
equal
deleted
inserted
replaced
422:efee0e0afb78 | 423:f8ba934ea462 |
---|---|
339 return local_platform.on_resume() | 339 return local_platform.on_resume() |
340 | 340 |
341 def on_stop(self): | 341 def on_stop(self): |
342 return local_platform.on_stop() | 342 return local_platform.on_stop() |
343 | 343 |
344 def showHeadWidget(self, show=None, animation=True): | |
345 """Show/Hide the head widget | |
346 | |
347 @param show(bool, None): True to show, False to hide, None to switch | |
348 @param animation(bool): animate the show/hide if True | |
349 """ | |
350 head = self.root.head_widget | |
351 if bool(self.root.head_widget.height) == show: | |
352 return | |
353 if head.height: | |
354 if animation: | |
355 Animation(height=0, opacity=0, duration=0.3).start(head) | |
356 else: | |
357 head.height = head.opacity = 0 | |
358 else: | |
359 if animation: | |
360 Animation(height=head.HEIGHT, opacity=1, duration=0.3).start(head) | |
361 else: | |
362 head.height = head.HEIGHT | |
363 head.opacity = 1 | |
364 | |
344 def key_input(self, window, key, scancode, codepoint, modifier): | 365 def key_input(self, window, key, scancode, codepoint, modifier): |
345 | 366 |
346 # we first check if selected widget handles the key | 367 # we first check if selected widget handles the key |
347 if ((self.host.selected_widget is not None | 368 if ((self.host.selected_widget is not None |
348 and hasattr(self.host.selected_widget, 'key_input') | 369 and hasattr(self.host.selected_widget, 'key_input') |
365 else: | 386 else: |
366 Window.fullscreen = False | 387 Window.fullscreen = False |
367 return True | 388 return True |
368 elif key == 110 and 'alt' in modifier: | 389 elif key == 110 and 'alt' in modifier: |
369 # M-n we hide/show notifications | 390 # M-n we hide/show notifications |
370 head = self.root.head_widget | 391 self.showHeadWidget() |
371 if head.height: | |
372 Animation(height=0, opacity=0, duration=0.3).start(head) | |
373 else: | |
374 Animation(height=head.HEIGHT, opacity=1, duration=0.3).start(head) | |
375 return True | 392 return True |
376 else: | 393 else: |
377 return False | 394 return False |
378 | 395 |
379 def on_dropfile(self, __, file_path): | 396 def on_dropfile(self, __, file_path): |