1
0
mirror of https://github.com/lvgl/lvgl.git synced 2025-01-28 07:03:00 +08:00
lvgl/examples/widgets/msgbox/lv_example_msgbox_2.c

64 lines
2.6 KiB
C
Raw Normal View History

#include "../../lv_examples.h"
#if LV_USE_MSGBOX && LV_BUILD_EXAMPLES
static void minimize_button_event_cb(lv_event_t * e)
{
lv_obj_t * mbox = (lv_obj_t *) lv_event_get_user_data(e);
lv_obj_add_flag(mbox, LV_OBJ_FLAG_HIDDEN);
}
void lv_example_msgbox_2(void)
{
lv_obj_t * setting = lv_msgbox_create(lv_screen_active());
lv_obj_set_style_clip_corner(setting, true, 0);
/* setting fixed size */
lv_obj_set_size(setting, 300, 200);
/* setting's titlebar/header */
lv_msgbox_add_title(setting, "Setting");
lv_obj_t * minimize_button = lv_msgbox_add_header_button(setting, LV_SYMBOL_MINUS);
lv_obj_add_event_cb(minimize_button, minimize_button_event_cb, LV_EVENT_CLICKED, setting);
lv_msgbox_add_close_button(setting);
/* setting's content*/
lv_obj_t * content = lv_msgbox_get_content(setting);
lv_obj_set_flex_flow(content, LV_FLEX_FLOW_COLUMN);
lv_obj_set_flex_align(content, LV_FLEX_ALIGN_START, LV_FLEX_ALIGN_CENTER, LV_FLEX_ALIGN_CENTER);
lv_obj_set_style_pad_right(content, -1, LV_PART_SCROLLBAR);
lv_obj_t * cont_brightness = lv_obj_create(content);
lv_obj_set_size(cont_brightness, lv_pct(100), LV_SIZE_CONTENT);
lv_obj_set_flex_flow(cont_brightness, LV_FLEX_FLOW_COLUMN);
lv_obj_set_flex_align(cont_brightness, LV_FLEX_ALIGN_CENTER, LV_FLEX_ALIGN_START, LV_FLEX_ALIGN_CENTER);
lv_obj_t * lb_brightness = lv_label_create(cont_brightness);
lv_label_set_text(lb_brightness, "Brightness : ");
lv_obj_t * slider_brightness = lv_slider_create(cont_brightness);
lv_obj_set_width(slider_brightness, lv_pct(100));
lv_slider_set_value(slider_brightness, 50, LV_ANIM_OFF);
lv_obj_t * cont_speed = lv_obj_create(content);
lv_obj_set_size(cont_speed, lv_pct(100), LV_SIZE_CONTENT);
lv_obj_set_flex_flow(cont_speed, LV_FLEX_FLOW_COLUMN);
lv_obj_set_flex_align(cont_speed, LV_FLEX_ALIGN_CENTER, LV_FLEX_ALIGN_START, LV_FLEX_ALIGN_CENTER);
lv_obj_t * lb_speed = lv_label_create(cont_speed);
lv_label_set_text(lb_speed, "Speed : ");
lv_obj_t * slider_speed = lv_slider_create(cont_speed);
lv_obj_set_width(slider_speed, lv_pct(100));
lv_slider_set_value(slider_speed, 80, LV_ANIM_OFF);
/* footer */
lv_obj_t * apply_button = lv_msgbox_add_footer_button(setting, "Apply");
lv_obj_set_flex_grow(apply_button, 1);
lv_obj_t * cancel_button = lv_msgbox_add_footer_button(setting, "Cancel");
lv_obj_set_flex_grow(cancel_button, 1);
lv_obj_t * footer = lv_msgbox_get_footer(setting);
lv_obj_set_style_bg_color(footer, lv_palette_main(LV_PALETTE_INDIGO), 0);
lv_obj_set_style_bg_opa(footer, LV_OPA_100, 0);
}
#endif