Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit71ab5d1

Browse files
Fix top swipe gesture
1 parenta2af392 commit71ab5d1

File tree

2 files changed

+63
-39
lines changed

2 files changed

+63
-39
lines changed

‎internal_filesystem/lib/mpos/ui/__init__.py‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
screen_stack
55
)
66
from .widgetimporthandle_back_swipe,handle_top_swipe
7-
from .topmenuimportopen_bar,close_bar,open_drawer,drawer_open
7+
from .topmenuimportopen_bar,close_bar,open_drawer,drawer_open,NOTIFICATION_BAR_HEIGHT
88
from .focusimportsave_and_clear_current_focusgroup
99
from .displayimport (
1010
get_display_width,get_display_height,
@@ -18,7 +18,7 @@
1818
__all__= [
1919
"setContentView","back_screen","empty_screen_stack",
2020
"handle_back_swipe","handle_top_swipe",
21-
"open_bar","close_bar","open_drawer","drawer_open",
21+
"open_bar","close_bar","open_drawer","drawer_open","NOTIFICATION_BAR_HEIGHT",
2222
"save_and_clear_current_focusgroup",
2323
"get_display_width","get_display_height",
2424
"pct_of_display_width","pct_of_display_height",

‎internal_filesystem/lib/mpos/ui/widget.py‎

Lines changed: 61 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -2,107 +2,131 @@
22
importlvglaslv
33
from .animimportsmooth_show,smooth_hide
44
from .viewimportback_screen
5-
from .topmenuimportopen_drawer,drawer_open
5+
from .topmenuimportopen_drawer,drawer_open,NOTIFICATION_BAR_HEIGHT
66
from .displayimportget_display_width,get_display_height
77

88
downbutton=None
99
backbutton=None
1010
down_start_x=0
1111
back_start_y=0
1212

13+
14+
# Would be better to somehow save other events, like clicks, and pass them down to the layers below if released with x < 60
1315
def_back_swipe_cb(event):
1416
ifdrawer_open:
17+
print("ignoring back gesture because drawer is open")
1518
return
16-
globalback_start_y,backbutton
17-
code=event.get_code()
19+
20+
globalbackbutton,back_start_y
21+
event_code=event.get_code()
1822
indev=lv.indev_active()
1923
ifnotindev:
2024
return
2125
point=lv.point_t()
2226
indev.get_point(point)
23-
x,y=point.x,point.y
24-
25-
ifcode==lv.EVENT.PRESSED:
27+
x=point.x
28+
y=point.y
29+
#print(f"visual_back_swipe_cb event_code={event_code} and event_name={name} and pos: {x}, {y}")
30+
ifevent_code==lv.EVENT.PRESSED:
2631
smooth_show(backbutton)
2732
back_start_y=y
28-
elifcode==lv.EVENT.PRESSING:
33+
elifevent_code==lv.EVENT.PRESSING:
2934
magnetic_x=round(x/10)
30-
backbutton.set_pos(magnetic_x,back_start_y)
31-
elifcode==lv.EVENT.RELEASED:
35+
backbutton.set_pos(magnetic_x,back_start_y)
36+
elifevent_code==lv.EVENT.RELEASED:
3237
smooth_hide(backbutton)
3338
ifx>min(100,get_display_width()/3):
3439
back_screen()
3540

41+
42+
# Would be better to somehow save other events, like clicks, and pass them down to the layers below if released with x < 60
3643
def_top_swipe_cb(event):
3744
ifdrawer_open:
45+
print("ignoring top swipe gesture because drawer is open")
3846
return
39-
globaldown_start_x,downbutton
40-
code=event.get_code()
47+
48+
globaldownbutton,down_start_x
49+
event_code=event.get_code()
4150
indev=lv.indev_active()
4251
ifnotindev:
4352
return
4453
point=lv.point_t()
4554
indev.get_point(point)
46-
x,y=point.x,point.y
47-
48-
ifcode==lv.EVENT.PRESSED:
55+
x=point.x
56+
y=point.y
57+
#print(f"visual_back_swipe_cb event_code={event_code} and event_name={name} and pos: {x}, {y}")
58+
ifevent_code==lv.EVENT.PRESSED:
4959
smooth_show(downbutton)
5060
down_start_x=x
51-
elifcode==lv.EVENT.PRESSING:
52-
magnetic_y=round(y/10)
53-
downbutton.set_pos(down_start_x,magnetic_y)
54-
elifcode==lv.EVENT.RELEASED:
61+
elifevent_code==lv.EVENT.PRESSING:
62+
magnetic_y=round(y/10)
63+
downbutton.set_pos(down_start_x,magnetic_y)
64+
elifevent_code==lv.EVENT.RELEASED:
5565
smooth_hide(downbutton)
5666
ify>min(80,get_display_height()/3):
5767
open_drawer()
5868

69+
5970
defhandle_back_swipe():
6071
globalbackbutton
6172
rect=lv.obj(lv.layer_top())
62-
rect.set_size(round(60),lv.layer_top().get_height()-80)
63-
rect.set_pos(0,80)
73+
rect.set_size(round(NOTIFICATION_BAR_HEIGHT/2),lv.layer_top().get_height()-NOTIFICATION_BAR_HEIGHT)# narrow because it overlaps buttons
6474
rect.set_scrollbar_mode(lv.SCROLLBAR_MODE.OFF)
65-
75+
rect.set_scroll_dir(lv.DIR.NONE)
76+
rect.set_pos(0,NOTIFICATION_BAR_HEIGHT)
6677
style=lv.style_t()
6778
style.init()
6879
style.set_bg_opa(lv.OPA.TRANSP)
6980
style.set_border_width(0)
81+
style.set_radius(0)
82+
ifFalse:# debug the back swipe zone with a red border
83+
style.set_bg_opa(15)
84+
style.set_border_width(4)
85+
style.set_border_color(lv.color_hex(0xFF0000))# Red border for visibility
86+
style.set_border_opa(lv.OPA._50)# 50% opacity for the border
7087
rect.add_style(style,0)
71-
88+
#rect.add_flag(lv.obj.FLAG.CLICKABLE) # Make the object clickable
89+
#rect.add_flag(lv.obj.FLAG.GESTURE_BUBBLE) # Allow dragging
7290
rect.add_event_cb(_back_swipe_cb,lv.EVENT.PRESSED,None)
7391
rect.add_event_cb(_back_swipe_cb,lv.EVENT.PRESSING,None)
7492
rect.add_event_cb(_back_swipe_cb,lv.EVENT.RELEASED,None)
75-
93+
#rect.add_event_cb(back_swipe_cb, lv.EVENT.ALL, None)
94+
# button with label that shows up during the dragging:
7695
backbutton=lv.button(lv.layer_top())
77-
backbutton.set_pos(0,200)
96+
backbutton.set_pos(0,round(lv.layer_top().get_height()/2))
7897
backbutton.add_flag(lv.obj.FLAG.HIDDEN)
7998
backbutton.add_state(lv.STATE.DISABLED)
80-
lbl=lv.label(backbutton)
81-
lbl.set_text(lv.SYMBOL.LEFT)
82-
lbl.set_style_text_font(lv.font_montserrat_18,0)
83-
lbl.center()
99+
backlabel=lv.label(backbutton)
100+
backlabel.set_text(lv.SYMBOL.LEFT)
101+
backlabel.set_style_text_font(lv.font_montserrat_18,0)
102+
backlabel.center()
84103

85104
defhandle_top_swipe():
86105
globaldownbutton
87106
rect=lv.obj(lv.layer_top())
88-
rect.set_size(lv.pct(100),60)
107+
rect.set_size(lv.pct(100),round(NOTIFICATION_BAR_HEIGHT*2/3))
89108
rect.set_pos(0,0)
90109
rect.set_scrollbar_mode(lv.SCROLLBAR_MODE.OFF)
91-
92110
style=lv.style_t()
93111
style.init()
94112
style.set_bg_opa(lv.OPA.TRANSP)
113+
#style.set_bg_opa(15)
114+
style.set_border_width(0)
115+
style.set_radius(0)
116+
#style.set_border_color(lv.color_hex(0xFF0000)) # White border for visibility
117+
#style.set_border_opa(lv.OPA._50) # 50% opacity for the border
95118
rect.add_style(style,0)
96-
119+
#rect.add_flag(lv.obj.FLAG.CLICKABLE) # Make the object clickable
120+
#rect.add_flag(lv.obj.FLAG.GESTURE_BUBBLE) # Allow dragging
97121
rect.add_event_cb(_top_swipe_cb,lv.EVENT.PRESSED,None)
98122
rect.add_event_cb(_top_swipe_cb,lv.EVENT.PRESSING,None)
99123
rect.add_event_cb(_top_swipe_cb,lv.EVENT.RELEASED,None)
100-
124+
# button with label that shows up during the dragging:
101125
downbutton=lv.button(lv.layer_top())
102-
downbutton.set_pos(100,0)
126+
downbutton.set_pos(0,round(lv.layer_top().get_height()/2))
103127
downbutton.add_flag(lv.obj.FLAG.HIDDEN)
104128
downbutton.add_state(lv.STATE.DISABLED)
105-
lbl=lv.label(downbutton)
106-
lbl.set_text(lv.SYMBOL.DOWN)
107-
lbl.set_style_text_font(lv.font_montserrat_18,0)
108-
lbl.center()
129+
downlabel=lv.label(downbutton)
130+
downlabel.set_text(lv.SYMBOL.DOWN)
131+
downlabel.set_style_text_font(lv.font_montserrat_18,0)
132+
downlabel.center()

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp