Skip to content

Commit de35a9d

Browse files
Camera app: tweak layout
1 parent b0592f8 commit de35a9d

File tree

2 files changed

+12
-5
lines changed

2 files changed

+12
-5
lines changed

internal_filesystem/apps/com.micropythonos.camera/assets/camera_app.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -103,8 +103,12 @@ def onCreate(self):
103103
self.qr_label.set_text(lv.SYMBOL.EYE_OPEN)
104104
self.qr_label.center()
105105
self.status_label_cont = lv.obj(self.main_screen)
106-
self.status_label_cont.set_size(lv.pct(66),lv.pct(60))
107-
self.status_label_cont.align(lv.ALIGN.LEFT_MID, lv.pct(5), 0)
106+
width = mpos.ui.pct_of_display_width(70)
107+
height = mpos.ui.pct_of_display_width(60)
108+
self.status_label_cont.set_size(width,height)
109+
center_w = round((mpos.ui.pct_of_display_width(100) - self.button_width - 5 - width)/2)
110+
center_h = round((mpos.ui.pct_of_display_height(100) - height)/2)
111+
self.status_label_cont.set_pos(center_w,center_h)
108112
self.status_label_cont.set_style_bg_color(lv.color_white(), 0)
109113
self.status_label_cont.set_style_bg_opa(66, 0)
110114
self.status_label_cont.set_style_border_width(0, 0)
@@ -116,7 +120,6 @@ def onCreate(self):
116120
self.setContentView(self.main_screen)
117121

118122
def onResume(self, screen):
119-
self.create_preview_image()
120123
self.cam = init_internal_cam(self.width, self.height)
121124
if not self.cam:
122125
# try again because the manual i2c poweroff leaves it in a bad state
@@ -279,8 +282,8 @@ def qr_button_click(self, e):
279282
self.stop_qr_decoding()
280283

281284
def open_settings(self):
282-
#self.main_screen.clean()
283-
self.image.delete()
285+
self.image_dsc.data = None
286+
self.current_cam_buffer = None
284287
"""Launch the camera settings activity."""
285288
intent = Intent(activity_class=CameraSettingsActivity)
286289
self.startActivityForResult(intent, self.handle_settings_result)

internal_filesystem/lib/mpos/ui/display.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,13 @@ def get_pointer_xy():
2424
return -1, -1
2525

2626
def pct_of_display_width(pct):
27+
if pct == 100:
28+
return _horizontal_resolution
2729
return round(_horizontal_resolution * pct / 100)
2830

2931
def pct_of_display_height(pct):
32+
if pct == 100:
33+
return _vertical_resolution
3034
return round(_vertical_resolution * pct / 100)
3135

3236
def min_resolution():

0 commit comments

Comments
 (0)