Skip to content

Commit 68b6ff3

Browse files
Cleanup WidgetAnimator framework
1 parent 86d9c38 commit 68b6ff3

File tree

11 files changed

+262
-217
lines changed

11 files changed

+262
-217
lines changed

internal_filesystem/lib/mpos/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
from .ui.focus import save_and_clear_current_focusgroup
4040
from .ui.gesture_navigation import handle_back_swipe, handle_top_swipe
4141
from .ui.util import shutdown, set_foreground_app, get_foreground_app
42-
from .ui.anim import smooth_show, smooth_hide
42+
from .ui.widget_animator import WidgetAnimator
4343
from .ui import focus_direction
4444

4545
# Utility modules
@@ -78,7 +78,7 @@
7878
"save_and_clear_current_focusgroup",
7979
"handle_back_swipe", "handle_top_swipe",
8080
"shutdown", "set_foreground_app", "get_foreground_app",
81-
"smooth_show", "smooth_hide",
81+
"WidgetAnimator",
8282
"focus_direction",
8383
# Testing utilities
8484
"wait_for_render", "capture_screenshot", "simulate_click", "get_widget_coords",

internal_filesystem/lib/mpos/ui/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
from .util import shutdown, set_foreground_app, get_foreground_app
1212
from .setting_activity import SettingActivity
1313
from .settings_activity import SettingsActivity
14-
from .anim import smooth_show, smooth_hide
14+
from .widget_animator import WidgetAnimator
1515
from . import focus_direction
1616

1717
# main_display is assigned by board-specific initialization code
@@ -28,6 +28,6 @@
2828
"shutdown", "set_foreground_app", "get_foreground_app",
2929
"SettingActivity",
3030
"SettingsActivity",
31-
"smooth_show", "smooth_hide",
31+
"WidgetAnimator",
3232
"focus_direction"
3333
]

internal_filesystem/lib/mpos/ui/anim.py

Lines changed: 0 additions & 181 deletions
This file was deleted.

internal_filesystem/lib/mpos/ui/camera_settings.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
from ..config import SharedPreferences
44
from ..app.activity import Activity
55
from .display import DisplayMetrics
6-
from . import anim
6+
from .widget_animator import WidgetAnimator
77

88
class CameraSettingsActivity(Activity):
99

@@ -354,11 +354,11 @@ def create_advanced_tab(self, tab, prefs):
354354
def exposure_ctrl_changed(e=None):
355355
is_auto = aec_checkbox.get_state() & lv.STATE.CHECKED
356356
if is_auto:
357-
anim.smooth_hide(me_cont, duration=1000)
358-
anim.smooth_show(ae_cont, delay=1000)
357+
WidgetAnimator.smooth_hide(me_cont, duration=1000)
358+
WidgetAnimator.smooth_show(ae_cont, delay=1000)
359359
else:
360-
anim.smooth_hide(ae_cont, duration=1000)
361-
anim.smooth_show(me_cont, delay=1000)
360+
WidgetAnimator.smooth_hide(ae_cont, duration=1000)
361+
WidgetAnimator.smooth_show(me_cont, delay=1000)
362362

363363
aec_checkbox.add_event_cb(exposure_ctrl_changed, lv.EVENT.VALUE_CHANGED, None)
364364
exposure_ctrl_changed()
@@ -382,9 +382,9 @@ def gain_ctrl_changed(e=None):
382382
is_auto = agc_checkbox.get_state() & lv.STATE.CHECKED
383383
gain_slider = self.ui_controls["agc_gain"]
384384
if is_auto:
385-
anim.smooth_hide(agc_cont, duration=1000)
385+
WidgetAnimator.smooth_hide(agc_cont, duration=1000)
386386
else:
387-
anim.smooth_show(agc_cont, duration=1000)
387+
WidgetAnimator.smooth_show(agc_cont, duration=1000)
388388

389389
agc_checkbox.add_event_cb(gain_ctrl_changed, lv.EVENT.VALUE_CHANGED, None)
390390
gain_ctrl_changed()
@@ -414,9 +414,9 @@ def gain_ctrl_changed(e=None):
414414
def whitebal_changed(e=None):
415415
is_auto = wbcheckbox.get_state() & lv.STATE.CHECKED
416416
if is_auto:
417-
anim.smooth_hide(wb_cont, duration=1000)
417+
WidgetAnimator.smooth_hide(wb_cont, duration=1000)
418418
else:
419-
anim.smooth_show(wb_cont, duration=1000)
419+
WidgetAnimator.smooth_show(wb_cont, duration=1000)
420420
wbcheckbox.add_event_cb(whitebal_changed, lv.EVENT.VALUE_CHANGED, None)
421421
whitebal_changed()
422422

internal_filesystem/lib/mpos/ui/gesture_navigation.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import lvgl as lv
22
from lvgl import LvReferenceError
3-
from .anim import smooth_show, smooth_hide
3+
from .widget_animator import WidgetAnimator
44
from .view import back_screen
55
from mpos.ui import topmenu as topmenu
66
from .display import DisplayMetrics
@@ -50,12 +50,12 @@ def _back_swipe_cb(event):
5050
should_show = not is_short_movement(dx, dy)
5151
if should_show != backbutton_visible:
5252
backbutton_visible = should_show
53-
smooth_show(backbutton) if should_show else smooth_hide(backbutton)
53+
WidgetAnimator.smooth_show(backbutton) if should_show else WidgetAnimator.smooth_hide(backbutton)
5454
backbutton.set_pos(round(x / 10), back_start_y)
5555
elif event_code == lv.EVENT.RELEASED:
5656
if backbutton_visible:
5757
backbutton_visible = False
58-
smooth_hide(backbutton)
58+
WidgetAnimator.smooth_hide(backbutton)
5959
if x > DisplayMetrics.width() / 5:
6060
if topmenu.drawer_open :
6161
topmenu.close_drawer()
@@ -89,12 +89,12 @@ def _top_swipe_cb(event):
8989
should_show = not is_short_movement(dx, dy)
9090
if should_show != downbutton_visible:
9191
downbutton_visible = should_show
92-
smooth_show(downbutton) if should_show else smooth_hide(downbutton)
92+
WidgetAnimator.smooth_show(downbutton) if should_show else WidgetAnimator.smooth_hide(downbutton)
9393
downbutton.set_pos(down_start_x, round(y / 10))
9494
elif event_code == lv.EVENT.RELEASED:
9595
if downbutton_visible:
9696
downbutton_visible = False
97-
smooth_hide(downbutton)
97+
WidgetAnimator.smooth_hide(downbutton)
9898
dx = abs(x - down_start_x)
9999
dy = abs(y - down_start_y)
100100
if y > DisplayMetrics.height() / 5:

internal_filesystem/lib/mpos/ui/keyboard.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717

1818
import lvgl as lv
1919
import mpos.ui.theme
20+
from .widget_animator import WidgetAnimator
2021

2122
class MposKeyboard:
2223
"""
@@ -247,7 +248,7 @@ def scroll_back_after_hide(self, timer):
247248

248249
def show_keyboard(self):
249250
self._saved_scroll_y = self._parent.get_scroll_y()
250-
mpos.ui.anim.smooth_show(self._keyboard, duration=500)
251+
WidgetAnimator.smooth_show(self._keyboard, duration=500)
251252
# Scroll to view on a timer because it will be hidden initially
252253
lv.timer_create(self.scroll_after_show, 250, None).set_repeat_count(1)
253254
# When this is done from a timer, focus styling is not applied so the user doesn't see which button is selected.
@@ -259,7 +260,7 @@ def show_keyboard(self):
259260
self.focus_on_keyboard()
260261

261262
def hide_keyboard(self):
262-
mpos.ui.anim.smooth_hide(self._keyboard, duration=500)
263+
WidgetAnimator.smooth_hide(self._keyboard, duration=500)
263264
# Do this after the hide so the scrollbars disappear automatically if not needed
264265
scroll_timer = lv.timer_create(self.scroll_back_after_hide,550,None).set_repeat_count(1)
265266

internal_filesystem/lib/mpos/ui/setting_activity.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
from ..app.activity import Activity
44
from .camera_activity import CameraActivity
55
from .display import DisplayMetrics
6-
from . import anim
6+
from .widget_animator import WidgetAnimator
77
from ..camera_manager import CameraManager
88

99
"""
@@ -134,7 +134,7 @@ def onCreate(self):
134134

135135
def onStop(self, screen):
136136
if self.keyboard:
137-
anim.smooth_hide(self.keyboard)
137+
WidgetAnimator.smooth_hide(self.keyboard)
138138

139139
def radio_event_handler(self, event):
140140
print("radio_event_handler called")

internal_filesystem/lib/mpos/ui/topmenu.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
from .display_metrics import DisplayMetrics
66
from .util import (get_foreground_app)
77
from . import focus_direction
8-
from .anim import WidgetAnimator
8+
from .widget_animator import WidgetAnimator
99

1010
NOTIFICATION_BAR_HEIGHT=24
1111

0 commit comments

Comments
 (0)