Mercurial > libervia-desktop-kivy
diff 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 |
line wrap: on
line diff
--- a/cagou/core/cagou_main.py Wed Feb 26 16:41:27 2020 +0100 +++ b/cagou/core/cagou_main.py Wed Feb 26 16:42:22 2020 +0100 @@ -341,6 +341,27 @@ def on_stop(self): return local_platform.on_stop() + def showHeadWidget(self, show=None, animation=True): + """Show/Hide the head widget + + @param show(bool, None): True to show, False to hide, None to switch + @param animation(bool): animate the show/hide if True + """ + head = self.root.head_widget + if bool(self.root.head_widget.height) == show: + return + if head.height: + if animation: + Animation(height=0, opacity=0, duration=0.3).start(head) + else: + head.height = head.opacity = 0 + else: + if animation: + Animation(height=head.HEIGHT, opacity=1, duration=0.3).start(head) + else: + head.height = head.HEIGHT + head.opacity = 1 + def key_input(self, window, key, scancode, codepoint, modifier): # we first check if selected widget handles the key @@ -367,11 +388,7 @@ return True elif key == 110 and 'alt' in modifier: # M-n we hide/show notifications - head = self.root.head_widget - if head.height: - Animation(height=0, opacity=0, duration=0.3).start(head) - else: - Animation(height=head.HEIGHT, opacity=1, duration=0.3).start(head) + self.showHeadWidget() return True else: return False