From bb20b9a6bce6dbf8b4c581ffc30a47cfda139e74 Mon Sep 17 00:00:00 2001 From: Gabor Kiss-Vamosi Date: Thu, 19 Dec 2024 14:23:38 +0100 Subject: [PATCH] update gen files --- .../components/buttons/button_default_gen.c | 15 ++++++------ .../components/buttons/button_error_gen.c | 15 ++++++------ .../components/buttons/button_warning_gen.c | 14 +++++------ examples/components/headings/h1_gen.c | 16 ++++++------- examples/components/headings/h1_gen.h | 2 +- examples/components/headings/h2_gen.c | 16 ++++++------- examples/components/headings/h2_gen.h | 2 +- examples/components/headings/h3_gen.c | 16 ++++++------- examples/components/headings/h3_gen.h | 2 +- examples/components/home_gen.c | 23 +++++++++++++------ examples/components/scratchpad_gen.c | 13 ++++++----- examples/example_gen.c | 8 ++++--- examples/example_gen.h | 8 ++++--- examples/ui.c | 3 ++- .../widgets/dark_slider/dark_slider_gen.c | 4 ++++ examples/widgets/slider_box/slider_box.c | 5 ++-- examples/widgets/slider_box/slider_box_gen.c | 5 ++-- 17 files changed, 95 insertions(+), 72 deletions(-) diff --git a/examples/components/buttons/button_default_gen.c b/examples/components/buttons/button_default_gen.c index d7c143a..e41a1e3 100644 --- a/examples/components/buttons/button_default_gen.c +++ b/examples/components/buttons/button_default_gen.c @@ -10,11 +10,11 @@ lv_obj_t * button_default_create(lv_obj_t * parent, const char * button_label) static lv_style_t style_pr; - static bool style_main_inited = false; + static bool style_inited = false; + + if(!style_inited) { - if(!style_main_inited) { - lv_style_init(&style_main); lv_style_set_bg_color(&style_main, lv_color_hex(0x222222)); @@ -39,14 +39,15 @@ lv_obj_t * button_default_create(lv_obj_t * parent, const char * button_label) lv_style_set_shadow_opa(&style_pr, 40); - style_main_inited = true; + style_inited = true; } lv_obj_t * obj = lv_button_create(parent); - lv_obj_add_style(obj, &style_main, LV_STATE_DEFAULT);lv_obj_add_style(obj, &style_pr, LV_STATE_PRESSED); - lv_obj_add_style(obj, &style_main, LV_PART_MAIN | LV_STATE_DEFAULT); - lv_obj_t * h3 = h3_create(obj, "$button_label"); + + lv_obj_add_style(obj, &style_main, LV_PART_MAIN | LV_STATE_DEFAULT); + lv_obj_add_style(obj, &style_pr, LV_PART_MAIN | LV_STATE_PRESSED); + lv_obj_t * h3 = h3_create(obj, button_label); lv_obj_set_align(h3, LV_ALIGN_CENTER); diff --git a/examples/components/buttons/button_error_gen.c b/examples/components/buttons/button_error_gen.c index 853b89e..de2e974 100644 --- a/examples/components/buttons/button_error_gen.c +++ b/examples/components/buttons/button_error_gen.c @@ -10,11 +10,11 @@ lv_obj_t * button_error_create(lv_obj_t * parent, const char * button_label) static lv_style_t style_pr; - static bool style_main_inited = false; + static bool style_inited = false; + + if(!style_inited) { - if(!style_main_inited) { - lv_style_init(&style_main); lv_style_set_bg_color(&style_main, lv_color_hex(0xf03c0f)); @@ -39,14 +39,15 @@ lv_obj_t * button_error_create(lv_obj_t * parent, const char * button_label) lv_style_set_shadow_opa(&style_pr, 40); - style_main_inited = true; + style_inited = true; } lv_obj_t * obj = lv_button_create(parent); - lv_obj_add_style(obj, &style_main, LV_STATE_DEFAULT);lv_obj_add_style(obj, &style_pr, LV_STATE_PRESSED); - lv_obj_add_style(obj, &style_main, LV_PART_MAIN | LV_STATE_DEFAULT); - lv_obj_t * h3 = h3_create(obj, "$button_label"); + + lv_obj_add_style(obj, &style_main, LV_PART_MAIN | LV_STATE_DEFAULT); + lv_obj_add_style(obj, &style_pr, LV_PART_MAIN | LV_STATE_PRESSED); + lv_obj_t * h3 = h3_create(obj, button_label); lv_obj_set_align(h3, LV_ALIGN_CENTER); diff --git a/examples/components/buttons/button_warning_gen.c b/examples/components/buttons/button_warning_gen.c index 97b3b3d..eb3e66f 100644 --- a/examples/components/buttons/button_warning_gen.c +++ b/examples/components/buttons/button_warning_gen.c @@ -10,11 +10,11 @@ lv_obj_t * button_warning_create(lv_obj_t * parent, const char * button_label) static lv_style_t style_pr; - static bool style_main_inited = false; + static bool style_inited = false; + + if(!style_inited) { - if(!style_main_inited) { - lv_style_init(&style_main); lv_style_set_bg_color(&style_main, lv_color_hex(0xf0b005)); @@ -41,14 +41,14 @@ lv_obj_t * button_warning_create(lv_obj_t * parent, const char * button_label) lv_style_set_shadow_opa(&style_pr, 40); - style_main_inited = true; + style_inited = true; } lv_obj_t * obj = lv_button_create(parent); - lv_obj_add_style(obj, &style_main, LV_STATE_DEFAULT); - lv_obj_add_style(obj, &style_main, LV_PART_MAIN | LV_STATE_DEFAULT); - lv_obj_t * h3 = h3_create(obj, "$button_label"); + + lv_obj_add_style(obj, &style_main, LV_PART_MAIN | LV_STATE_DEFAULT); + lv_obj_t * h3 = h3_create(obj, button_label); lv_obj_set_align(h3, LV_ALIGN_CENTER); diff --git a/examples/components/headings/h1_gen.c b/examples/components/headings/h1_gen.c index 50e2f70..7b96cc4 100644 --- a/examples/components/headings/h1_gen.c +++ b/examples/components/headings/h1_gen.c @@ -2,7 +2,7 @@ #include "h1_gen.h" #include "ui.h" -lv_obj_t * h1_create(lv_obj_t * parent, const char * text) +lv_obj_t * h1_create(lv_obj_t * parent, const char * heading_text) { LV_TRACE_OBJ_CREATE("begin"); @@ -10,23 +10,23 @@ lv_obj_t * h1_create(lv_obj_t * parent, const char * text) - static bool style_main_inited = false; + static bool style_inited = false; + + if(!style_inited) { - if(!style_main_inited) { - lv_style_init(&style_main); lv_style_set_text_font(&style_main, inter_xl); - style_main_inited = true; + style_inited = true; } lv_obj_t * obj = lv_label_create(parent); - lv_obj_add_style(obj, &style_main, LV_STATE_DEFAULT); - lv_obj_add_style(obj, &style_main, LV_PART_MAIN | LV_STATE_DEFAULT); - lv_label_set_text(obj, "text"); + + lv_obj_add_style(obj, &style_main, LV_PART_MAIN | LV_STATE_DEFAULT); + lv_label_set_text(obj, "heading_text"); LV_TRACE_OBJ_CREATE("finished"); diff --git a/examples/components/headings/h1_gen.h b/examples/components/headings/h1_gen.h index 84a6015..facd9c6 100644 --- a/examples/components/headings/h1_gen.h +++ b/examples/components/headings/h1_gen.h @@ -6,6 +6,6 @@ -lv_obj_t * h1_create(lv_obj_t * parent, const char * text); +lv_obj_t * h1_create(lv_obj_t * parent, const char * heading_text); #endif /*H1_H*/ \ No newline at end of file diff --git a/examples/components/headings/h2_gen.c b/examples/components/headings/h2_gen.c index 37595d7..d3c735c 100644 --- a/examples/components/headings/h2_gen.c +++ b/examples/components/headings/h2_gen.c @@ -2,7 +2,7 @@ #include "h2_gen.h" #include "ui.h" -lv_obj_t * h2_create(lv_obj_t * parent, const char * text) +lv_obj_t * h2_create(lv_obj_t * parent, const char * heading_text) { LV_TRACE_OBJ_CREATE("begin"); @@ -10,23 +10,23 @@ lv_obj_t * h2_create(lv_obj_t * parent, const char * text) - static bool style_main_inited = false; + static bool style_inited = false; + + if(!style_inited) { - if(!style_main_inited) { - lv_style_init(&style_main); lv_style_set_text_font(&style_main, inter_md); - style_main_inited = true; + style_inited = true; } lv_obj_t * obj = lv_label_create(parent); - lv_obj_add_style(obj, &style_main, LV_STATE_DEFAULT); - lv_obj_add_style(obj, &style_main, LV_PART_MAIN | LV_STATE_DEFAULT); - lv_label_set_text(obj, "text"); + + lv_obj_add_style(obj, &style_main, LV_PART_MAIN | LV_STATE_DEFAULT); + lv_label_set_text(obj, "heading_text"); LV_TRACE_OBJ_CREATE("finished"); diff --git a/examples/components/headings/h2_gen.h b/examples/components/headings/h2_gen.h index 501b56e..c8d0a78 100644 --- a/examples/components/headings/h2_gen.h +++ b/examples/components/headings/h2_gen.h @@ -6,6 +6,6 @@ -lv_obj_t * h2_create(lv_obj_t * parent, const char * text); +lv_obj_t * h2_create(lv_obj_t * parent, const char * heading_text); #endif /*H2_H*/ \ No newline at end of file diff --git a/examples/components/headings/h3_gen.c b/examples/components/headings/h3_gen.c index 2a6b946..7879006 100644 --- a/examples/components/headings/h3_gen.c +++ b/examples/components/headings/h3_gen.c @@ -2,7 +2,7 @@ #include "h3_gen.h" #include "ui.h" -lv_obj_t * h3_create(lv_obj_t * parent, const char * text) +lv_obj_t * h3_create(lv_obj_t * parent, const char * heading_text) { LV_TRACE_OBJ_CREATE("begin"); @@ -10,23 +10,23 @@ lv_obj_t * h3_create(lv_obj_t * parent, const char * text) - static bool style_main_inited = false; + static bool style_inited = false; + + if(!style_inited) { - if(!style_main_inited) { - lv_style_init(&style_main); lv_style_set_text_font(&style_main, inter_sm); - style_main_inited = true; + style_inited = true; } lv_obj_t * obj = lv_label_create(parent); - lv_obj_add_style(obj, &style_main, LV_STATE_DEFAULT); - lv_obj_add_style(obj, &style_main, LV_PART_MAIN | LV_STATE_DEFAULT); - lv_label_set_text(obj, "text"); + + lv_obj_add_style(obj, &style_main, LV_PART_MAIN | LV_STATE_DEFAULT); + lv_label_set_text(obj, "heading_text"); LV_TRACE_OBJ_CREATE("finished"); diff --git a/examples/components/headings/h3_gen.h b/examples/components/headings/h3_gen.h index ec1bd6c..21853c7 100644 --- a/examples/components/headings/h3_gen.h +++ b/examples/components/headings/h3_gen.h @@ -6,6 +6,6 @@ -lv_obj_t * h3_create(lv_obj_t * parent, const char * text); +lv_obj_t * h3_create(lv_obj_t * parent, const char * heading_text); #endif /*H3_H*/ \ No newline at end of file diff --git a/examples/components/home_gen.c b/examples/components/home_gen.c index 22ec492..e6fde85 100644 --- a/examples/components/home_gen.c +++ b/examples/components/home_gen.c @@ -12,11 +12,11 @@ lv_obj_t * home_create(lv_obj_t * parent) static lv_style_t style_left_cont; static lv_style_t style_right_cont; - static bool style_main_inited = false; + static bool style_inited = false; + + if(!style_inited) { - if(!style_main_inited) { - lv_style_init(&style_main); lv_style_set_bg_color(&style_main, lv_color_hex(0x111111)); @@ -32,6 +32,8 @@ static lv_style_t style_right_cont; lv_style_set_height(&style_main, lv_pct(100)); + lv_style_set_pad_all(&style_main, 0); + lv_style_set_pad_column(&style_main, 0); @@ -46,6 +48,8 @@ static lv_style_t style_right_cont; lv_style_set_radius(&style_cont, 0); + lv_style_set_pad_all(&style_cont, 0); + lv_style_set_pad_row(&style_cont, 16); @@ -54,6 +58,8 @@ static lv_style_t style_right_cont; lv_style_set_border_width(&style_left_cont, 0); + lv_style_set_pad_all(&style_left_cont, 16); + lv_style_init(&style_right_cont); lv_style_set_layout(&style_right_cont, LV_LAYOUT_FLEX); @@ -68,14 +74,16 @@ static lv_style_t style_right_cont; lv_style_set_flex_cross_place(&style_right_cont, LV_FLEX_ALIGN_CENTER); + lv_style_set_pad_all(&style_right_cont, 16); + - style_main_inited = true; + style_inited = true; } lv_obj_t * obj = lv_obj_create(parent); - lv_obj_add_style(obj, &style_main, LV_STATE_DEFAULT); - lv_obj_add_style(obj, &style_main, LV_PART_MAIN | LV_STATE_DEFAULT); + + lv_obj_add_style(obj, &style_main, LV_PART_MAIN | LV_STATE_DEFAULT); lv_obj_t * lv_obj = lv_obj_create(obj); lv_obj_add_style(lv_obj, &style_cont, LV_PART_MAIN | LV_STATE_DEFAULT); lv_obj_add_style(lv_obj, &style_left_cont, LV_PART_MAIN | LV_STATE_DEFAULT); @@ -97,12 +105,13 @@ static lv_style_t style_right_cont; lv_obj_t * lv_obj_2 = lv_obj_create(obj); lv_obj_add_style(lv_obj_2, &style_cont, LV_PART_MAIN | LV_STATE_DEFAULT); lv_obj_add_style(lv_obj_2, &style_right_cont, LV_PART_MAIN | LV_STATE_DEFAULT); + lv_obj_set_flex_grow(lv_obj_2, 1); lv_obj_t * button_default = button_default_create(lv_obj_2, "Ok"); lv_obj_t * button_default_2 = button_default_create(lv_obj_2, "Cancel"); lv_obj_t * dark_slider = dark_slider_create(lv_obj_2); lv_obj_set_width(dark_slider, lv_pct(100)); dark_slider_set_color(dark_slider, lv_color_hex(0xf03c0f)); - lv_obj_set_send_draw_task_events(dark_slider, true); + lv_obj_update_flag(dark_slider, LV_OBJ_FLAG_SEND_DRAW_TASK_EVENTS, true); lv_obj_t * button_warning = button_warning_create(lv_obj_2, "Alert 1"); lv_obj_t * button_warning_2 = button_warning_create(lv_obj_2, "Alert 2"); lv_obj_t * button_error = button_error_create(lv_obj_2, "Error 1"); diff --git a/examples/components/scratchpad_gen.c b/examples/components/scratchpad_gen.c index 2a90367..b0d7a5f 100644 --- a/examples/components/scratchpad_gen.c +++ b/examples/components/scratchpad_gen.c @@ -10,20 +10,21 @@ lv_obj_t * scratchpad_create(lv_obj_t * parent) - static bool style_main_inited = false; + static bool style_inited = false; + + if(!style_inited) { - if(!style_main_inited) { - - style_main_inited = true; + style_inited = true; } lv_obj_t * obj = lv_obj_create(parent); - - lv_obj_set_width(obj, lv_pct(100)); + + lv_obj_set_width(obj, lv_pct(100)); lv_obj_set_height(obj, lv_pct(100)); + lv_obj_set_flex_flow(obj, LV_FLEX_FLOW_COLUMN); lv_obj_t * button_default = button_default_create(obj, "Button"); lv_obj_set_width(button_default, 250); lv_obj_t * button_default_2 = button_default_create(obj, "Button"); diff --git a/examples/example_gen.c b/examples/example_gen.c index 4a4a1a6..8a06b3e 100644 --- a/examples/example_gen.c +++ b/examples/example_gen.c @@ -6,6 +6,7 @@ /********************* * INCLUDES *********************/ + #include "example_gen.h" /********************* * DEFINES @@ -28,9 +29,9 @@ **********************/ /*Fonts*/ -lv_font_t inter_sm; -lv_font_t inter_md; -lv_font_t inter_xl; +lv_font_t * inter_sm; +lv_font_t * inter_md; +lv_font_t * inter_xl; /********************** * MACROS @@ -43,6 +44,7 @@ lv_font_t inter_xl; void example_init_gen(void) { inter_sm = lv_tiny_ttf_create_file("A:/fonts/Inter-SemiBold.ttf", 14); + LV_LOG_USER("inter_sm: %d\n", inter_sm); inter_md = lv_tiny_ttf_create_file("A:/fonts/Inter-SemiBold.ttf", 18); inter_xl = lv_tiny_ttf_create_file("A:/fonts/Inter-SemiBold.ttf", 22); } diff --git a/examples/example_gen.h b/examples/example_gen.h index 0d3268c..be3918f 100644 --- a/examples/example_gen.h +++ b/examples/example_gen.h @@ -14,6 +14,8 @@ extern "C" { * INCLUDES *********************/ +#include "lvgl/lvgl.h" + /*Include all the widget and components of this library*/ #include "widgets/dark_slider/dark_slider.h" #include "widgets/slider_box/slider_box.h" @@ -39,9 +41,9 @@ extern "C" { **********************/ /*Fonts*/ -extern lv_font_t inter_sm; -extern lv_font_t inter_md; -extern lv_font_t inter_xl; +extern lv_font_t * inter_sm; +extern lv_font_t * inter_md; +extern lv_font_t * inter_xl; /********************** * GLOBAL PROTOTYPES diff --git a/examples/ui.c b/examples/ui.c index 82ef626..f1cfee8 100644 --- a/examples/ui.c +++ b/examples/ui.c @@ -33,7 +33,8 @@ **********************/ void ui_init(void) -{ +{ + LV_LOG_USER("ui_init()\n"); example_init(); } diff --git a/examples/widgets/dark_slider/dark_slider_gen.c b/examples/widgets/dark_slider/dark_slider_gen.c index 00b05ef..99ee48a 100644 --- a/examples/widgets/dark_slider/dark_slider_gen.c +++ b/examples/widgets/dark_slider/dark_slider_gen.c @@ -92,6 +92,8 @@ static lv_style_t style_blue_indicator; lv_style_set_height(&style_main, 10); + lv_style_set_pad_all(&style_main, 0); + lv_style_init(&style_light_knob); @@ -107,6 +109,8 @@ static lv_style_t style_blue_indicator; lv_style_set_radius(&style_light_knob, 100); + lv_style_set_pad_all(&style_light_knob, 5); + lv_style_init(&style_blue_indicator); diff --git a/examples/widgets/slider_box/slider_box.c b/examples/widgets/slider_box/slider_box.c index dc67256..00e671f 100644 --- a/examples/widgets/slider_box/slider_box.c +++ b/examples/widgets/slider_box/slider_box.c @@ -37,6 +37,7 @@ void slider_box_constructor_hook(lv_obj_t * obj) { + LV_LOG_USER("Create a slider box\n"); slider_box_t * slider_box = (slider_box_t *)obj; lv_obj_add_event_cb(slider_box->lv_button, decerease_event_cb, LV_EVENT_CLICKED, slider_box->dark_slider); @@ -62,13 +63,13 @@ void slider_box_set_title(lv_obj_t * obj, const char * title) { slider_box_t * slider_box = (slider_box_t *)obj; slider_box->title = title; - lv_label_set_text(slider_box->lv_label, title); + lv_label_set_text(slider_box->lv_label2, title); } const char * slider_box_get_title(lv_obj_t * obj) { slider_box_t * slider_box = (slider_box_t *)obj; - return lv_label_get_text(slider_box->lv_label); + return lv_label_get_text(slider_box->lv_label2); } /********************** diff --git a/examples/widgets/slider_box/slider_box_gen.c b/examples/widgets/slider_box/slider_box_gen.c index ee6902b..704c9a4 100644 --- a/examples/widgets/slider_box/slider_box_gen.c +++ b/examples/widgets/slider_box/slider_box_gen.c @@ -78,8 +78,6 @@ static void slider_box_constructor(const lv_obj_class_t * class_p, lv_obj_t * ob if(!style_main_inited) { - - lv_style_init(&style_main); lv_style_set_bg_color(&style_main, lv_color_hex(0x666666)); @@ -103,6 +101,8 @@ static void slider_box_constructor(const lv_obj_class_t * class_p, lv_obj_t * ob lv_style_set_pad_column(&style_main, 4); + lv_style_set_pad_all(&style_main, 16); + lv_style_set_text_font(&style_main, inter_sm); lv_style_set_text_color(&style_main, lv_color_hex(0xffffff)); @@ -139,6 +139,7 @@ static void slider_box_constructor(const lv_obj_class_t * class_p, lv_obj_t * ob slider_box->lv_label2 = lv_label_create(obj); lv_obj_set_align(slider_box->lv_label2, LV_ALIGN_TOP_MID); lv_label_set_text(slider_box->lv_label2, "Title"); + lv_obj_set_flex_grow(slider_box->lv_label2, 1); lv_obj_set_style_text_align(slider_box->lv_label2, LV_TEXT_ALIGN_CENTER, LV_PART_MAIN | LV_STATE_DEFAULT); lv_obj_set_width(slider_box->lv_label2, LV_SIZE_CONTENT); lv_label_set_long_mode(slider_box->lv_label2, LV_LABEL_LONG_MODE_SCROLL);