refactor(btn, img): rename btn to button and img to image
This commit is contained in:
@@ -113,7 +113,7 @@ void lv_example_file_explorer_2(void)
|
||||
/*Quick access status control button*/
|
||||
lv_obj_t * fe_quick_access_obj = lv_file_explorer_get_quick_access_area(file_explorer);
|
||||
lv_obj_t * fe_header_obj = lv_file_explorer_get_header(file_explorer);
|
||||
lv_obj_t * btn = lv_btn_create(fe_header_obj);
|
||||
lv_obj_t * btn = lv_button_create(fe_header_obj);
|
||||
lv_obj_set_style_radius(btn, 2, 0);
|
||||
lv_obj_set_style_pad_all(btn, 4, 0);
|
||||
lv_obj_align(btn, LV_ALIGN_LEFT_MID, 0, 0);
|
||||
|
||||
@@ -14,14 +14,14 @@ def file_explorer_event_handler(e):
|
||||
sel_fn = obj.explorer_get_selected_file_name()
|
||||
print(str(cur_path) + str(sel_fn))
|
||||
|
||||
def btn_event_handler(e,fe_quick_access_obj):
|
||||
def button_event_handler(e,fe_quick_access_obj):
|
||||
|
||||
code = e.get_code()
|
||||
btn = e.get_target_obj()
|
||||
button = e.get_target_obj()
|
||||
# lv_obj_t * file_explorer = lv_event_get_user_data(e);
|
||||
|
||||
if code == lv.EVENT.VALUE_CHANGED :
|
||||
if btn.has_state(lv.STATE.CHECKED) :
|
||||
if button.has_state(lv.STATE.CHECKED) :
|
||||
fe_quick_access_obj.add_flag(lv.obj.FLAG.HIDDEN)
|
||||
else :
|
||||
fe_quick_access_obj.clear_flag(lv.obj.FLAG.HIDDEN)
|
||||
@@ -73,18 +73,18 @@ file_explorer.add_event(file_explorer_event_handler, lv.EVENT.ALL, None)
|
||||
# Quick access status control button
|
||||
fe_quick_access_obj = file_explorer.explorer_get_quick_access_area()
|
||||
fe_header_obj = file_explorer.explorer_get_header()
|
||||
btn = lv.btn(fe_header_obj)
|
||||
btn.set_style_radius(2, 0)
|
||||
btn.set_style_pad_all(4, 0)
|
||||
btn.align(lv.ALIGN.LEFT_MID, 0, 0)
|
||||
btn.add_flag(lv.obj.FLAG.CHECKABLE)
|
||||
button = lv.button(fe_header_obj)
|
||||
button.set_style_radius(2, 0)
|
||||
button.set_style_pad_all(4, 0)
|
||||
button.align(lv.ALIGN.LEFT_MID, 0, 0)
|
||||
button.add_flag(lv.obj.FLAG.CHECKABLE)
|
||||
|
||||
label = lv.label(btn)
|
||||
label = lv.label(button)
|
||||
label.set_text(lv.SYMBOL.LIST)
|
||||
label.center()
|
||||
|
||||
btn.add_event(lambda evt: btn_event_handler(evt,fe_quick_access_obj), lv.EVENT.VALUE_CHANGED, None)
|
||||
#btn.add_event(lambda evt: btn_event_handler(evt,file_explorer), lv.EVENT.VALUE_CHANGED, None)
|
||||
button.add_event(lambda evt: button_event_handler(evt,fe_quick_access_obj), lv.EVENT.VALUE_CHANGED, None)
|
||||
#button.add_event(lambda evt: button_event_handler(evt,file_explorer), lv.EVENT.VALUE_CHANGED, None)
|
||||
|
||||
# Sort control
|
||||
opts = "NONE\nKIND"
|
||||
@@ -95,7 +95,7 @@ dd.set_style_pad_all(0, 0)
|
||||
dd.set_size(lv.pct(30), lv.SIZE_CONTENT)
|
||||
dd.set_options_static(opts)
|
||||
dd.align(lv.ALIGN.RIGHT_MID, 0, 0)
|
||||
# lv_obj_align_to(dd, btn, LV_ALIGN_OUT_RIGHT_MID, 0, 0);
|
||||
# lv_obj_align_to(dd, button, LV_ALIGN_OUT_RIGHT_MID, 0, 0);
|
||||
|
||||
dd.add_event(lambda evt: dd_event_handler(evt,file_explorer), lv.EVENT.VALUE_CHANGED, None)
|
||||
#dd.add_event(lambda evt: dd_event_handler(evt,fe_quick_access_obj), lv.EVENT.VALUE_CHANGED, None)
|
||||
|
||||
@@ -45,11 +45,11 @@ void lv_example_fragment_2(void)
|
||||
lv_obj_remove_style_all(container);
|
||||
lv_obj_set_grid_cell(container, LV_GRID_ALIGN_STRETCH, 0, 2, LV_GRID_ALIGN_STRETCH, 0, 1);
|
||||
|
||||
lv_obj_t * push_btn = lv_btn_create(root);
|
||||
lv_obj_t * push_btn = lv_button_create(root);
|
||||
lv_obj_t * push_label = lv_label_create(push_btn);
|
||||
lv_label_set_text(push_label, "Push");
|
||||
|
||||
lv_obj_t * pop_btn = lv_btn_create(root);
|
||||
lv_obj_t * pop_btn = lv_button_create(root);
|
||||
lv_obj_t * pop_label = lv_label_create(pop_btn);
|
||||
lv_label_set_text(pop_label, "Pop");
|
||||
lv_obj_set_grid_cell(push_btn, LV_GRID_ALIGN_START, 0, 1, LV_GRID_ALIGN_CENTER, 1, 1);
|
||||
@@ -89,7 +89,7 @@ static lv_obj_t * sample_fragment_create_obj(lv_fragment_t * self, lv_obj_t * pa
|
||||
fragment->label = label;
|
||||
lv_label_set_text_fmt(label, "The button has been pressed %d times", fragment->counter);
|
||||
|
||||
lv_obj_t * inc_btn = lv_btn_create(content);
|
||||
lv_obj_t * inc_btn = lv_button_create(content);
|
||||
lv_obj_t * inc_label = lv_label_create(inc_btn);
|
||||
lv_label_set_text(inc_label, "+1");
|
||||
lv_obj_add_event(inc_btn, sample_fragment_inc_click, LV_EVENT_CLICKED, fragment);
|
||||
|
||||
@@ -25,7 +25,7 @@ void lv_example_gridnav_1(void)
|
||||
|
||||
uint32_t i;
|
||||
for(i = 0; i < 10; i++) {
|
||||
lv_obj_t * obj = lv_btn_create(cont1);
|
||||
lv_obj_t * obj = lv_button_create(cont1);
|
||||
lv_obj_set_size(obj, 70, LV_SIZE_CONTENT);
|
||||
lv_obj_add_flag(obj, LV_OBJ_FLAG_CHECKABLE);
|
||||
lv_group_remove_obj(obj); /*Not needed, we use the gridnav instead*/
|
||||
|
||||
@@ -19,7 +19,7 @@ label = lv.label(cont1)
|
||||
label.set_text("No rollover")
|
||||
|
||||
for i in range(10):
|
||||
obj = lv.btn(cont1)
|
||||
obj = lv.button(cont1)
|
||||
obj.set_size(70, lv.SIZE_CONTENT)
|
||||
obj.add_flag(lv.obj.FLAG.CHECKABLE)
|
||||
lv.group_remove_obj(obj) # Not needed, we use the gridnav instead
|
||||
|
||||
@@ -21,7 +21,7 @@ void lv_example_gridnav_2(void)
|
||||
uint32_t i;
|
||||
for(i = 0; i < 15; i++) {
|
||||
lv_snprintf(buf, sizeof(buf), "File %d", i + 1);
|
||||
lv_obj_t * item = lv_list_add_btn(list1, LV_SYMBOL_FILE, buf);
|
||||
lv_obj_t * item = lv_list_add_button(list1, LV_SYMBOL_FILE, buf);
|
||||
lv_obj_set_style_bg_opa(item, 0, 0);
|
||||
lv_group_remove_obj(item); /*Not needed, we use the gridnav instead*/
|
||||
}
|
||||
@@ -35,7 +35,7 @@ void lv_example_gridnav_2(void)
|
||||
|
||||
for(i = 0; i < 15; i++) {
|
||||
lv_snprintf(buf, sizeof(buf), "Folder %d", i + 1);
|
||||
lv_obj_t * item = lv_list_add_btn(list2, LV_SYMBOL_DIRECTORY, buf);
|
||||
lv_obj_t * item = lv_list_add_button(list2, LV_SYMBOL_DIRECTORY, buf);
|
||||
lv_obj_set_style_bg_opa(item, 0, 0);
|
||||
lv_group_remove_obj(item);
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@ lv.group_get_default().add_obj(list1)
|
||||
|
||||
for i in range(15):
|
||||
item_text = "File {:d}".format(i)
|
||||
item = list1.add_btn(lv.SYMBOL.FILE, item_text)
|
||||
item = list1.add_button(lv.SYMBOL.FILE, item_text)
|
||||
item.set_style_bg_opa(0, 0)
|
||||
lv.group_remove_obj(item) # Not needed, we use the gridnav instead
|
||||
|
||||
@@ -26,7 +26,7 @@ lv.group_get_default().add_obj(list2)
|
||||
|
||||
for i in range(15):
|
||||
item_text = "Folder {:d}".format(i)
|
||||
item = list2.add_btn(lv.SYMBOL.DIRECTORY, item_text)
|
||||
item = list2.add_button(lv.SYMBOL.DIRECTORY, item_text)
|
||||
item.set_style_bg_opa(0, 0)
|
||||
lv.group_remove_obj(item)
|
||||
|
||||
|
||||
@@ -36,12 +36,12 @@ void lv_example_gridnav_3(void)
|
||||
lv_obj_t * btn;
|
||||
lv_obj_t * label;
|
||||
|
||||
btn = lv_btn_create(cont_main);
|
||||
btn = lv_button_create(cont_main);
|
||||
lv_group_remove_obj(btn);
|
||||
label = lv_label_create(btn);
|
||||
lv_label_set_text(label, "Button 1");
|
||||
|
||||
btn = lv_btn_create(cont_main);
|
||||
btn = lv_button_create(cont_main);
|
||||
lv_group_remove_obj(btn);
|
||||
label = lv_label_create(btn);
|
||||
lv_label_set_text(label, "Button 2");
|
||||
@@ -83,12 +83,12 @@ void lv_example_gridnav_3(void)
|
||||
lv_label_set_text(label, "Use ENTER/ESC to focus/defocus this container");
|
||||
lv_obj_set_width(label, lv_pct(100));
|
||||
|
||||
btn = lv_btn_create(cont_sub2);
|
||||
btn = lv_button_create(cont_sub2);
|
||||
lv_group_remove_obj(btn);
|
||||
label = lv_label_create(btn);
|
||||
lv_label_set_text(label, "Button 3");
|
||||
|
||||
btn = lv_btn_create(cont_sub2);
|
||||
btn = lv_button_create(cont_sub2);
|
||||
lv_group_remove_obj(btn);
|
||||
label = lv_label_create(btn);
|
||||
lv_label_set_text(label, "Button 4");
|
||||
|
||||
@@ -24,14 +24,14 @@ cont_main.set_flex_flow(lv.FLEX_FLOW.ROW_WRAP)
|
||||
cont_main.set_style_bg_color(lv.palette_lighten(lv.PALETTE.BLUE, 5), lv.STATE.FOCUSED)
|
||||
cont_main.set_size(lv.pct(80), lv.SIZE_CONTENT)
|
||||
|
||||
btn = lv.btn(cont_main)
|
||||
lv.group_remove_obj(btn)
|
||||
label = lv.label(btn)
|
||||
button = lv.button(cont_main)
|
||||
lv.group_remove_obj(button)
|
||||
label = lv.label(button)
|
||||
label.set_text("Button 1")
|
||||
|
||||
btn = lv.btn(cont_main)
|
||||
lv.group_remove_obj(btn)
|
||||
label = lv.label(btn)
|
||||
button = lv.button(cont_main)
|
||||
lv.group_remove_obj(button)
|
||||
label = lv.label(button)
|
||||
label.set_text("Button 2");
|
||||
|
||||
|
||||
@@ -72,13 +72,13 @@ label = lv.label(cont_sub2)
|
||||
label.set_text("Use ENTER/ESC to focus/defocus this container")
|
||||
label.set_width(lv.pct(100))
|
||||
|
||||
btn = lv.btn(cont_sub2)
|
||||
lv.group_remove_obj(btn)
|
||||
label = lv.label(btn)
|
||||
button = lv.button(cont_sub2)
|
||||
lv.group_remove_obj(button)
|
||||
label = lv.label(button)
|
||||
label.set_text("Button 3")
|
||||
|
||||
btn = lv.btn(cont_sub2)
|
||||
lv.group_remove_obj(btn)
|
||||
label = lv.label(btn)
|
||||
button = lv.button(cont_sub2)
|
||||
lv.group_remove_obj(button)
|
||||
label = lv.label(button)
|
||||
label.set_text("Button 4")
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ static void event_handler(lv_event_t * e)
|
||||
{
|
||||
lv_obj_t * obj = lv_event_get_target(e);
|
||||
lv_obj_t * list = lv_obj_get_parent(obj);
|
||||
LV_LOG_USER("Clicked: %s", lv_list_get_btn_text(list, obj));
|
||||
LV_LOG_USER("Clicked: %s", lv_list_get_button_text(list, obj));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -33,12 +33,12 @@ void lv_example_gridnav_4(void)
|
||||
}
|
||||
|
||||
lv_snprintf(buf, sizeof(buf), "File %d", i + 1);
|
||||
lv_obj_t * item = lv_list_add_btn(list, LV_SYMBOL_FILE, buf);
|
||||
lv_obj_t * item = lv_list_add_button(list, LV_SYMBOL_FILE, buf);
|
||||
lv_obj_add_event(item, event_handler, LV_EVENT_CLICKED, NULL);
|
||||
lv_group_remove_obj(item); /*The default group adds it automatically*/
|
||||
}
|
||||
|
||||
lv_obj_t * btn = lv_btn_create(lv_scr_act());
|
||||
lv_obj_t * btn = lv_button_create(lv_scr_act());
|
||||
lv_obj_align(btn, LV_ALIGN_RIGHT_MID, -10, 0);
|
||||
lv_obj_t * label = lv_label_create(btn);
|
||||
lv_label_set_text(label, "Button");
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
def event_handler(e):
|
||||
obj = e.get_target_obj()
|
||||
list = obj.get_parent()
|
||||
print("Clicked: " + list.get_btn_text(obj))
|
||||
print("Clicked: " + list.get_button_text(obj))
|
||||
|
||||
|
||||
#
|
||||
@@ -25,12 +25,12 @@ for i in range(20):
|
||||
|
||||
txt = "File {:d}".format(i + 1)
|
||||
#lv_snprintf(buf, sizeof(buf), "File %d", i + 1);
|
||||
item = list.add_btn(lv.SYMBOL.FILE, txt)
|
||||
item = list.add_button(lv.SYMBOL.FILE, txt)
|
||||
item.add_event(event_handler, lv.EVENT.CLICKED, None)
|
||||
lv.group_remove_obj(item) # The default group adds it automatically
|
||||
|
||||
btn = lv.btn(lv.scr_act())
|
||||
btn.align(lv.ALIGN.RIGHT_MID, 0, -10)
|
||||
label = lv.label(btn)
|
||||
button = lv.button(lv.scr_act())
|
||||
button.align(lv.ALIGN.RIGHT_MID, 0, -10)
|
||||
label = lv.label(button)
|
||||
label.set_text("Button")
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
#if LV_BUILD_EXAMPLES
|
||||
#if LV_USE_IMGFONT
|
||||
|
||||
LV_IMG_DECLARE(emoji_F617)
|
||||
LV_IMAGE_DECLARE(emoji_F617)
|
||||
char path_buf[128];
|
||||
static const void * get_imgfont_path(const lv_font_t * font, uint32_t unicode, uint32_t unicode_next,
|
||||
lv_coord_t * offset_y, void * user_data)
|
||||
|
||||
@@ -40,7 +40,7 @@ void lv_example_msg_2(void)
|
||||
lv_obj_t * label;
|
||||
|
||||
/*Create a log out button which will be active only when logged in*/
|
||||
btn = lv_btn_create(lv_scr_act());
|
||||
btn = lv_button_create(lv_scr_act());
|
||||
lv_obj_set_pos(btn, 240, 10);
|
||||
lv_obj_add_event(btn, log_out_event_cb, LV_EVENT_ALL, NULL);
|
||||
lv_msg_subscribe_obj(MSG_LOGIN_OK, btn, NULL);
|
||||
@@ -59,7 +59,7 @@ void lv_example_msg_2(void)
|
||||
lv_msg_subscribe_obj(MSG_LOG_OUT, label, NULL);
|
||||
|
||||
/*Create button which will be active only when logged in*/
|
||||
btn = lv_btn_create(lv_scr_act());
|
||||
btn = lv_button_create(lv_scr_act());
|
||||
lv_obj_set_pos(btn, 10, 80);
|
||||
lv_obj_add_event(btn, start_engine_msg_event_cb, LV_EVENT_MSG_RECEIVED, NULL);
|
||||
lv_obj_add_flag(btn, LV_OBJ_FLAG_CHECKABLE);
|
||||
|
||||
@@ -51,22 +51,22 @@ def log_out_event_cb(e):
|
||||
lv.msg_send(MSG_LOG_OUT, None)
|
||||
elif code == lv.EVENT.MSG_RECEIVED:
|
||||
m = e.get_msg()
|
||||
btn = e.get_target_obj()
|
||||
button = e.get_target_obj()
|
||||
id = m.get_id()
|
||||
if id == MSG_LOGIN_OK:
|
||||
btn.clear_state(lv.STATE.DISABLED)
|
||||
button.clear_state(lv.STATE.DISABLED)
|
||||
elif id == MSG_LOG_OUT:
|
||||
btn.add_state(lv.STATE.DISABLED)
|
||||
button.add_state(lv.STATE.DISABLED)
|
||||
|
||||
def start_engine_msg_event_cb(e):
|
||||
|
||||
m = e.get_msg()
|
||||
btn = e.get_target_obj()
|
||||
button = e.get_target_obj()
|
||||
id = m.get_id()
|
||||
if id == MSG_LOGIN_OK:
|
||||
btn.clear_state(lv.STATE.DISABLED)
|
||||
button.clear_state(lv.STATE.DISABLED)
|
||||
elif id == MSG_LOG_OUT:
|
||||
btn.add_state(lv.STATE.DISABLED)
|
||||
button.add_state(lv.STATE.DISABLED)
|
||||
|
||||
|
||||
def info_label_msg_event_cb(e):
|
||||
@@ -109,13 +109,13 @@ kb = lv.keyboard(lv.scr_act())
|
||||
kb.set_textarea(ta)
|
||||
|
||||
# Create a log out button which will be active only when logged in
|
||||
btn = lv.btn(lv.scr_act())
|
||||
btn.set_pos(240, 10)
|
||||
btn.add_event(log_out_event_cb, lv.EVENT.ALL, None)
|
||||
lv.msg_subscribe_obj(MSG_LOGIN_OK, btn, None)
|
||||
lv.msg_subscribe_obj(MSG_LOG_OUT, btn, None)
|
||||
button = lv.button(lv.scr_act())
|
||||
button.set_pos(240, 10)
|
||||
button.add_event(log_out_event_cb, lv.EVENT.ALL, None)
|
||||
lv.msg_subscribe_obj(MSG_LOGIN_OK, button, None)
|
||||
lv.msg_subscribe_obj(MSG_LOG_OUT, button, None)
|
||||
|
||||
label = lv.label(btn);
|
||||
label = lv.label(button);
|
||||
label.set_text("LOG OUT")
|
||||
|
||||
# Create a label to show info
|
||||
@@ -128,14 +128,14 @@ lv.msg_subscribe_obj(MSG_LOGIN_OK, label, None)
|
||||
lv.msg_subscribe_obj(MSG_LOG_OUT, label, None)
|
||||
|
||||
#Create button which will be active only when logged in
|
||||
btn = lv.btn(lv.scr_act())
|
||||
btn.set_pos(10, 80)
|
||||
btn.add_event(start_engine_msg_event_cb, lv.EVENT.MSG_RECEIVED, None)
|
||||
btn.add_flag(lv.obj.FLAG.CHECKABLE)
|
||||
lv.msg_subscribe_obj(MSG_LOGIN_OK, btn, None)
|
||||
lv.msg_subscribe_obj(MSG_LOG_OUT, btn, None)
|
||||
button = lv.button(lv.scr_act())
|
||||
button.set_pos(10, 80)
|
||||
button.add_event(start_engine_msg_event_cb, lv.EVENT.MSG_RECEIVED, None)
|
||||
button.add_flag(lv.obj.FLAG.CHECKABLE)
|
||||
lv.msg_subscribe_obj(MSG_LOGIN_OK, button, None)
|
||||
lv.msg_subscribe_obj(MSG_LOG_OUT, button, None)
|
||||
|
||||
label = lv.label(btn)
|
||||
label = lv.label(button)
|
||||
label.set_text("START ENGINE")
|
||||
|
||||
lv.msg_send(MSG_LOG_OUT, None)
|
||||
|
||||
@@ -27,7 +27,7 @@ void lv_example_msg_3(void)
|
||||
lv_obj_t * label;
|
||||
|
||||
/*Up button*/
|
||||
btn = lv_btn_create(panel);
|
||||
btn = lv_button_create(panel);
|
||||
lv_obj_set_flex_grow(btn, 1);
|
||||
lv_obj_add_event(btn, btn_event_cb, LV_EVENT_ALL, NULL);
|
||||
label = lv_label_create(btn);
|
||||
@@ -43,7 +43,7 @@ void lv_example_msg_3(void)
|
||||
lv_obj_add_event(label, label_event_cb, LV_EVENT_MSG_RECEIVED, NULL);
|
||||
|
||||
/*Down button*/
|
||||
btn = lv_btn_create(panel);
|
||||
btn = lv_button_create(panel);
|
||||
lv_obj_set_flex_grow(btn, 1);
|
||||
lv_obj_add_event(btn, btn_event_cb, LV_EVENT_ALL, NULL);
|
||||
label = lv_label_create(btn);
|
||||
|
||||
@@ -28,10 +28,10 @@ class LV_Example_Msg_2:
|
||||
panel.set_flex_align(lv.FLEX_ALIGN.SPACE_BETWEEN, lv.FLEX_ALIGN.CENTER, lv.FLEX_ALIGN.START)
|
||||
|
||||
# Up button
|
||||
btn = lv.btn(panel)
|
||||
btn.set_flex_grow(1)
|
||||
btn.add_event(self.btn_event_cb, lv.EVENT.ALL, None)
|
||||
label = lv.label(btn)
|
||||
button = lv.button(panel)
|
||||
button.set_flex_grow(1)
|
||||
button.add_event(self.button_event_cb, lv.EVENT.ALL, None)
|
||||
label = lv.label(button)
|
||||
label.set_text(lv.SYMBOL.LEFT)
|
||||
label.center()
|
||||
|
||||
@@ -44,10 +44,10 @@ class LV_Example_Msg_2:
|
||||
label.add_event(self.label_event_cb, lv.EVENT.MSG_RECEIVED, None)
|
||||
|
||||
# Down button
|
||||
btn = lv.btn(panel)
|
||||
btn.set_flex_grow(1)
|
||||
btn.add_event(self.btn_event_cb, lv.EVENT.ALL, None)
|
||||
label = lv.label(btn)
|
||||
button = lv.button(panel)
|
||||
button.set_flex_grow(1)
|
||||
button.add_event(self.button_event_cb, lv.EVENT.ALL, None)
|
||||
label = lv.label(button)
|
||||
label.set_text(lv.SYMBOL.RIGHT)
|
||||
label.center()
|
||||
|
||||
@@ -83,11 +83,11 @@ class LV_Example_Msg_2:
|
||||
if self.value != old_value:
|
||||
lv.msg_send(MSG_UPDATE, NewValue(self.value));
|
||||
|
||||
def btn_event_cb(self,e):
|
||||
btn = e.get_target_obj()
|
||||
def button_event_cb(self,e):
|
||||
button = e.get_target_obj()
|
||||
code = e.get_code()
|
||||
if code == lv.EVENT.CLICKED or code == lv.EVENT.LONG_PRESSED_REPEAT:
|
||||
if btn.get_index() == 0: # rst object is the dec. button
|
||||
if button.get_index() == 0: # rst object is the dec. button
|
||||
lv.msg_send(MSG_DEC, None)
|
||||
else :
|
||||
lv.msg_send(MSG_INC, None)
|
||||
|
||||
@@ -7,7 +7,7 @@ static void event_cb(lv_event_t * e)
|
||||
lv_obj_t * img = lv_event_get_target(e);
|
||||
|
||||
if(snapshot_obj) {
|
||||
lv_img_dsc_t * snapshot = (void *)lv_img_get_src(snapshot_obj);
|
||||
lv_image_dsc_t * snapshot = (void *)lv_image_get_src(snapshot_obj);
|
||||
if(snapshot) {
|
||||
lv_snapshot_free(snapshot);
|
||||
}
|
||||
@@ -16,22 +16,22 @@ static void event_cb(lv_event_t * e)
|
||||
snapshot = lv_snapshot_take(img->parent, LV_COLOR_FORMAT_ARGB8888);
|
||||
if(snapshot == NULL)
|
||||
return;
|
||||
lv_img_set_src(snapshot_obj, snapshot);
|
||||
lv_image_set_src(snapshot_obj, snapshot);
|
||||
}
|
||||
}
|
||||
|
||||
void lv_example_snapshot_1(void)
|
||||
{
|
||||
LV_IMG_DECLARE(img_star);
|
||||
LV_IMAGE_DECLARE(img_star);
|
||||
lv_obj_t * root = lv_scr_act();
|
||||
lv_obj_set_style_bg_color(root, lv_palette_main(LV_PALETTE_LIGHT_BLUE), 0);
|
||||
|
||||
/*Create an image object to show snapshot*/
|
||||
lv_obj_t * snapshot_obj = lv_img_create(root);
|
||||
lv_obj_t * snapshot_obj = lv_image_create(root);
|
||||
lv_obj_set_style_bg_color(snapshot_obj, lv_palette_main(LV_PALETTE_PURPLE), 0);
|
||||
lv_obj_set_style_bg_opa(snapshot_obj, LV_OPA_100, 0);
|
||||
lv_img_set_zoom(snapshot_obj, 128);
|
||||
lv_img_set_angle(snapshot_obj, 300);
|
||||
lv_image_set_zoom(snapshot_obj, 128);
|
||||
lv_image_set_angle(snapshot_obj, 300);
|
||||
|
||||
/*Create the container and its children*/
|
||||
lv_obj_t * container = lv_obj_create(root);
|
||||
@@ -44,8 +44,8 @@ void lv_example_snapshot_1(void)
|
||||
lv_obj_t * img;
|
||||
int i;
|
||||
for(i = 0; i < 4; i++) {
|
||||
img = lv_img_create(container);
|
||||
lv_img_set_src(img, &img_star);
|
||||
img = lv_image_create(container);
|
||||
lv_image_set_src(img, &img_star);
|
||||
lv_obj_set_style_bg_color(img, lv_color_black(), 0);
|
||||
lv_obj_set_style_bg_opa(img, LV_OPA_COVER, 0);
|
||||
// lv_obj_set_style_transform_zoom(img, 400, LV_STATE_PRESSED);
|
||||
|
||||
@@ -18,19 +18,19 @@ except:
|
||||
print("Could not find star.png")
|
||||
sys.exit()
|
||||
|
||||
img_star = lv.img_dsc_t({
|
||||
image_star = lv.image_dsc_t({
|
||||
'data_size': len(png_data),
|
||||
'data': png_data
|
||||
})
|
||||
|
||||
def event_cb(e, snapshot_obj):
|
||||
img = e.get_target_obj()
|
||||
image = e.get_target_obj()
|
||||
|
||||
if snapshot_obj:
|
||||
# no need to free the old source for snapshot_obj, gc will free it for us.
|
||||
|
||||
# take a new snapshot, overwrite the old one
|
||||
dsc = lv.snapshot_take(img.get_parent(), lv.COLOR_FORMAT.NATIVE_ALPHA)
|
||||
dsc = lv.snapshot_take(image.get_parent(), lv.COLOR_FORMAT.NATIVE_ALPHA)
|
||||
snapshot_obj.set_src(dsc)
|
||||
|
||||
gc.collect()
|
||||
@@ -41,7 +41,7 @@ root = lv.scr_act()
|
||||
root.set_style_bg_color(lv.palette_main(lv.PALETTE.LIGHT_BLUE), 0)
|
||||
|
||||
# Create an image object to show snapshot
|
||||
snapshot_obj = lv.img(root)
|
||||
snapshot_obj = lv.image(root)
|
||||
snapshot_obj.set_style_bg_color(lv.palette_main(lv.PALETTE.PURPLE), 0)
|
||||
snapshot_obj.set_style_bg_opa(lv.OPA.COVER, 0)
|
||||
snapshot_obj.set_zoom(128)
|
||||
@@ -55,11 +55,11 @@ container.set_flex_align(lv.FLEX_ALIGN.SPACE_EVENLY, lv.FLEX_ALIGN.CENTER, lv.FL
|
||||
container.set_style_radius(50, 0)
|
||||
|
||||
for i in range(4):
|
||||
img = lv.img(container)
|
||||
img.set_src(img_star)
|
||||
img.set_style_bg_color(lv.palette_main(lv.PALETTE.GREY), 0)
|
||||
img.set_style_bg_opa(lv.OPA.COVER, 0)
|
||||
img.set_style_transform_zoom(400, lv.STATE.PRESSED)
|
||||
img.add_flag(img.FLAG.CLICKABLE)
|
||||
img.add_event(lambda e: event_cb(e, snapshot_obj), lv.EVENT.PRESSED, None)
|
||||
img.add_event(lambda e: event_cb(e, snapshot_obj), lv.EVENT.RELEASED, None)
|
||||
image = lv.image(container)
|
||||
image.set_src(image_star)
|
||||
image.set_style_bg_color(lv.palette_main(lv.PALETTE.GREY), 0)
|
||||
image.set_style_bg_opa(lv.OPA.COVER, 0)
|
||||
image.set_style_transform_zoom(400, lv.STATE.PRESSED)
|
||||
image.add_flag(image.FLAG.CLICKABLE)
|
||||
image.add_event(lambda e: event_cb(e, snapshot_obj), lv.EVENT.PRESSED, None)
|
||||
image.add_event(lambda e: event_cb(e, snapshot_obj), lv.EVENT.RELEASED, None)
|
||||
|
||||
Reference in New Issue
Block a user