|
55 | 55 | def open_drawer(): |
56 | 56 | global drawer_open |
57 | 57 | if not drawer_open: |
| 58 | + show_bar_animation.start() |
58 | 59 | drawer_open=True |
59 | | - notification_bar.set_pos(0,0) |
60 | | - notification_bar.remove_flag(lv.obj.FLAG.HIDDEN) |
61 | 60 | drawer.remove_flag(lv.obj.FLAG.HIDDEN) |
62 | 61 |
|
63 | | -def close_drawer(): |
| 62 | +def close_drawer(to_launcher=False): |
64 | 63 | global drawer_open |
65 | 64 | if drawer_open: |
66 | 65 | drawer_open=False |
67 | 66 | drawer.add_flag(lv.obj.FLAG.HIDDEN) |
68 | | - animation.start() |
| 67 | + if not to_launcher: |
| 68 | + hide_bar_animation.start() |
69 | 69 |
|
70 | | -def toggle_drawer(event): |
71 | | - global drawer_open |
72 | | - if drawer_open: |
73 | | - close_drawer() |
74 | | - else: |
75 | | - open_drawer() |
76 | 70 |
|
77 | | - |
78 | | -# Create notification bar object |
| 71 | +# Create notification bar |
79 | 72 | notification_bar = lv.obj(lv.layer_top()) |
80 | 73 | notification_bar.set_style_bg_color(COLOR_NOTIF_BAR_BG, 0) |
81 | 74 | notification_bar.set_size(TFT_HOR_RES, NOTIFICATION_BAR_HEIGHT) |
82 | 75 | notification_bar.set_pos(0, 0) |
83 | | -notification_bar.add_flag(lv.obj.FLAG.HIDDEN) |
84 | 76 | notification_bar.set_scrollbar_mode(lv.SCROLLBAR_MODE.OFF) |
85 | 77 | notification_bar.set_scroll_dir(lv.DIR.VER) |
86 | 78 | notification_bar.set_style_border_width(0, 0) |
@@ -155,12 +147,20 @@ def update_memfree(timer): |
155 | 147 | #notification_bar.add_event_cb(toggle_drawer, lv.EVENT.CLICKED, None) |
156 | 148 |
|
157 | 149 | # hide bar animation |
158 | | -animation = lv.anim_t() |
159 | | -animation.init() |
160 | | -animation.set_var(notification_bar) |
161 | | -animation.set_values(0, -NOTIFICATION_BAR_HEIGHT) |
162 | | -animation.set_time(2000) |
163 | | -animation.set_custom_exec_cb(lambda not_used, value : notification_bar.set_y(value)) |
| 150 | +hide_bar_animation = lv.anim_t() |
| 151 | +hide_bar_animation.init() |
| 152 | +hide_bar_animation.set_var(notification_bar) |
| 153 | +hide_bar_animation.set_values(0, -NOTIFICATION_BAR_HEIGHT) |
| 154 | +hide_bar_animation.set_time(2000) |
| 155 | +hide_bar_animation.set_custom_exec_cb(lambda not_used, value : notification_bar.set_y(value)) |
| 156 | + |
| 157 | +# show bar animation |
| 158 | +show_bar_animation = lv.anim_t() |
| 159 | +show_bar_animation.init() |
| 160 | +show_bar_animation.set_var(notification_bar) |
| 161 | +show_bar_animation.set_values(-NOTIFICATION_BAR_HEIGHT, 0) |
| 162 | +show_bar_animation.set_time(1000) |
| 163 | +show_bar_animation.set_custom_exec_cb(lambda not_used, value : notification_bar.set_y(value)) |
164 | 164 |
|
165 | 165 |
|
166 | 166 | drawer=lv.obj(lv.layer_top()) |
@@ -229,7 +229,7 @@ def wifi_event(e): |
229 | 229 | def launcher_event(e): |
230 | 230 | print("Launcher button pressed!") |
231 | 231 | global drawer_open,rootscreen |
232 | | - close_drawer() |
| 232 | + close_drawer(True) |
233 | 233 | lv.screen_load(rootscreen) |
234 | 234 |
|
235 | 235 | launcher_btn.add_event_cb(launcher_event,lv.EVENT.CLICKED,None) |
@@ -357,10 +357,11 @@ def start_app(app_dir, is_launcher=False): |
357 | 357 | app_name, start_script = parse_manifest(manifest_path) |
358 | 358 | start_script_fullpath = f"{app_dir}/{start_script}" |
359 | 359 | execute_script_new_thread(start_script_fullpath, True, is_launcher, True) |
360 | | - # Show notification bar, then start animation to hide it |
361 | | - notification_bar.set_pos(0,0) |
362 | | - notification_bar.remove_flag(lv.obj.FLAG.HIDDEN) |
363 | | - animation.start() |
| 360 | + # Launchers have the bar, other apps don't have it |
| 361 | + if is_launcher: |
| 362 | + show_bar_animation.start() |
| 363 | + else: |
| 364 | + hide_bar_animation.start() |
364 | 365 |
|
365 | 366 | def restart_launcher(): |
366 | 367 | # The launcher might have been updated from the builtin one, so check that: |
|
0 commit comments