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

Commit697b8fc

Browse files
focus_direction.py: improve output
1 parent731568c commit697b8fc

File tree

1 file changed

+11
-9
lines changed

1 file changed

+11
-9
lines changed

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

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
importlvglaslv
33
importmpos.util
44

5-
importmath
65

76
defget_object_center(obj):
87
"""Calculate the center (x, y) of an object based on its position and size."""
@@ -33,8 +32,8 @@ def compute_angle_to_object(from_obj, to_obj):
3332
return (angle_deg+360)%360# Normalize to [0, 360)
3433

3534
defis_object_in_focus_group(focus_group,obj):
36-
"""Check if an object is in the focus group."""
37-
ifobjisNone:
35+
"""Check if an object is in the focus group and not hidden."""
36+
ifobjisNoneorobj.has_flag(lv.obj.FLAG.HIDDEN):
3837
returnFalse
3938
forobjnrinrange(focus_group.get_obj_count()):
4039
iffocus_group.get_obj_by_index(objnr)isobj:
@@ -79,7 +78,7 @@ def get_closest_edge_point_and_distance(from_x, from_y, obj, direction_degrees,
7978
angle_diff=min((angle_deg-direction_degrees)%360, (direction_degrees-angle_deg)%360)
8079
ifangle_diff>45:
8180
ifdebug:
82-
print(f"{obj} at ({x},{y}) size ({width}x{height}): closest point ({closest_x:.1f},{closest_y:.1f}), angle{angle_deg:.1f}°, diff{angle_diff:.1f}° > 45°, skipped")
81+
print(f"{obj} at ({x},{y}) size ({width}x{height}): closest point ({closest_x:.1f},{closest_y:.1f}), angle{angle_deg:.1f}°, diff{angle_diff:.1f}° > 45, skipped")
8382
returnNone
8483

8584
ifdebug:
@@ -90,8 +89,8 @@ def get_closest_edge_point_and_distance(from_x, from_y, obj, direction_degrees,
9089
deffind_closest_obj_in_direction(focus_group,current_focused,direction_degrees,debug=False):
9190
"""
9291
Find the closest object in the specified direction from the current focused object.
93-
Only considers objects that are in the focus_group (including children of any object).
9492
Uses closest edge point for distance to handle object sizes intuitively.
93+
Only considers objects that are in the focus_group and not hidden (including children).
9594
Direction is in degrees: 0° = UP, 90° = RIGHT, 180° = DOWN, 270° = LEFT (clockwise).
9695
Returns the closest object or None.
9796
"""
@@ -100,7 +99,8 @@ def find_closest_obj_in_direction(focus_group, current_focused, direction_degree
10099
returnNone
101100

102101
ifdebug:
103-
print(f"Current focused object:{current_focused}")
102+
print("Current focused object:")
103+
mpos.util.print_lvgl_widget(current_focused)
104104
print(f"Default focus group has{focus_group.get_obj_count()} items")
105105

106106
closest_obj=None
@@ -114,7 +114,7 @@ def process_object(obj, depth=0):
114114
ifobjisNoneorobjiscurrent_focused:
115115
return
116116

117-
# Check if the object is in the focus group and evaluate it
117+
# Check if the object is in the focus group andnot hidden, thenevaluate it
118118
ifis_object_in_focus_group(focus_group,obj):
119119
result=get_closest_edge_point_and_distance(current_x,current_y,obj,direction_degrees,debug)
120120
ifresult:
@@ -123,7 +123,8 @@ def process_object(obj, depth=0):
123123
min_distance=distance
124124
closest_obj=obj
125125
ifdebug:
126-
print(f" Updated closest:{obj}, distance{distance:.1f}, angle{angle_deg:.1f}°")
126+
print(f" Updated closest (distance{distance:.1f}, angle{angle_deg:.1f}°):")
127+
mpos.util.print_lvgl_widget(obj,depth=depth)
127128

128129
# Process children regardless of parent's focus group membership
129130
forchildnrinrange(obj.get_child_count()):
@@ -137,7 +138,8 @@ def process_object(obj, depth=0):
137138

138139
# Result
139140
ifclosest_obj:
140-
print(f"Closest object in direction{direction_degrees}°:{closest_obj}")
141+
print(f"Closest object in direction{direction_degrees}°:")
142+
mpos.util.print_lvgl_widget(closest_obj)
141143
else:
142144
print(f"No object found in direction{direction_degrees}°")
143145

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp