diff --git a/internal_filesystem/lib/mpos/ui/__init__.py b/internal_filesystem/lib/mpos/ui/__init__.py index 1bd35865..b1b160ab 100644 --- a/internal_filesystem/lib/mpos/ui/__init__.py +++ b/internal_filesystem/lib/mpos/ui/__init__.py @@ -34,8 +34,6 @@ notification_bar = None foreground_app_name=None -animator = WidgetAnimator() - def get_pointer_xy(): indev = lv.indev_active() if indev: @@ -80,16 +78,16 @@ def open_drawer(): if not drawer_open: open_bar() drawer_open=True - animator.show_widget(drawer, anim_type="slide_down", duration=1000, delay=0) + WidgetAnimator.show_widget(drawer, anim_type="slide_down", duration=1000, delay=0) def close_drawer(to_launcher=False): global drawer_open, drawer, foreground_app_name if drawer_open: drawer_open=False - animator.hide_widget(drawer, anim_type="slide_up", duration=1000, delay=0) if not to_launcher and not mpos.apps.is_launcher(foreground_app_name): print(f"close_drawer: also closing bar because to_launcher is {to_launcher} and foreground_app_name is {foreground_app_name}") close_bar() + WidgetAnimator.hide_widget(drawer, anim_type="slide_up", duration=1000, delay=0) def open_bar(): print("opening bar...") diff --git a/internal_filesystem/lib/mpos/ui/anim.py b/internal_filesystem/lib/mpos/ui/anim.py index 787d6e7e..fb4800ca 100644 --- a/internal_filesystem/lib/mpos/ui/anim.py +++ b/internal_filesystem/lib/mpos/ui/anim.py @@ -95,7 +95,7 @@ class WidgetAnimator: anim.set_custom_exec_cb(lambda anim, value: widget.set_y(value)) anim.set_path_cb(lv.anim_t.path_ease_in_out) # Set HIDDEN flag after animation - anim.set_completed_cb(lambda *args: WidgetAnimator.hide_complete_cb(widget)) + anim.set_completed_cb(lambda *args: WidgetAnimator.hide_complete_cb(widget, original_y)) elif anim_type == "slide_up": print("hide with slide_up") # Create slide-up animation (y from original y to -height) @@ -110,18 +110,18 @@ class WidgetAnimator: anim.set_custom_exec_cb(lambda anim, value: widget.set_y(value)) anim.set_path_cb(lv.anim_t.path_ease_in_out) # Set HIDDEN flag after animation - anim.set_completed_cb(lambda *args: WidgetAnimator.hide_complete_cb(widget)) + anim.set_completed_cb(lambda *args: WidgetAnimator.hide_complete_cb(widget, original_y)) # Store and start animation #self.animations[widget] = anim anim.start() @staticmethod - def hide_complete_cb(widget): + def hide_complete_cb(widget, original_y=None): #print("hide_complete_cb") widget.add_flag(lv.obj.FLAG.HIDDEN) - #if original_y: - # widget.set_y(original_y) # in case it shifted slightly due to rounding etc + if original_y: + widget.set_y(original_y) # in case it shifted slightly due to rounding etc def smooth_show(widget):