You've already forked MicroPythonOS
mirror of
https://github.com/m5stack/MicroPythonOS.git
synced 2026-05-20 11:51:27 -07:00
Fix drawer hide/show issue
This commit is contained in:
@@ -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...")
|
||||
|
||||
@@ -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):
|
||||
|
||||
Reference in New Issue
Block a user