init Files

This commit is contained in:
2024-12-09 19:47:18 +01:00
parent b55a8cd2bc
commit 528e862838
3471 changed files with 1105029 additions and 0 deletions

View File

@@ -0,0 +1,14 @@
Simple Message box
------------------
.. lv_example:: widgets/msgbox/lv_example_msgbox_1
:language: c
Scrolling and styled Message box
--------------------------------
.. lv_example:: widgets/msgbox/lv_example_msgbox_2
:language: c

View File

@@ -0,0 +1,29 @@
#include "../../lv_examples.h"
#if LV_USE_MSGBOX && LV_BUILD_EXAMPLES
static void event_cb(lv_event_t * e)
{
lv_obj_t * btn = lv_event_get_target(e);
lv_obj_t * label = lv_obj_get_child(btn, 0);
LV_UNUSED(label);
LV_LOG_USER("Button %s clicked", lv_label_get_text(label));
}
void lv_example_msgbox_1(void)
{
lv_obj_t * mbox1 = lv_msgbox_create(NULL);
lv_msgbox_add_title(mbox1, "Hello");
lv_msgbox_add_text(mbox1, "This is a message box with two buttons.");
lv_msgbox_add_close_button(mbox1);
lv_obj_t * btn;
btn = lv_msgbox_add_footer_button(mbox1, "Apply");
lv_obj_add_event_cb(btn, event_cb, LV_EVENT_CLICKED, NULL);
btn = lv_msgbox_add_footer_button(mbox1, "Cancel");
lv_obj_add_event_cb(btn, event_cb, LV_EVENT_CLICKED, NULL);
return;
}
#endif

View File

@@ -0,0 +1,63 @@
#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