Skip to content

Commit

Permalink
minor updates
Browse files Browse the repository at this point in the history
  • Loading branch information
kisvegabor committed Dec 10, 2024
1 parent 90299a6 commit 4a4feb8
Show file tree
Hide file tree
Showing 8 changed files with 123 additions and 70 deletions.
2 changes: 1 addition & 1 deletion examples/components/buttons/button_default.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
</consts>

<styles>
<style name="main" bg_color="#dark_color" border_width="2" border_color="0x555555" radius="100"/>
<style name="main" bg_color="#dark_color" border_width="2" radius="100"/>
</styles>

<view extends="lv_button" styles="main">
Expand Down
2 changes: 1 addition & 1 deletion examples/components/buttons/button_warning.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
</api>

<styles>
<style name="main" bg_color="0xffbb44" border_width="2" border_color="0x555555" radius="100"/>
<style name="main" bg_color="0xff9900" border_width="2" radius="100"/>
</styles>

<view extends="lv_button" styles="main">
Expand Down
20 changes: 15 additions & 5 deletions examples/components/home.xml
Original file line number Diff line number Diff line change
Expand Up @@ -37,16 +37,26 @@
<view extends="lv_obj" styles="main">
<lv_obj styles="cont left_cont">
<slider_box width="150"/>
<slider_box width="150"/>
<slider_box width="150"/>
<slider_box width="150"/>
<slider_box width="150"/>
<slider_box width="150"/>
<slider_box width="150"/>
<slider_box width="150"/>
<slider_box width="150"/>
<slider_box width="150"/>
<slider_box width="150"/>
</lv_obj>

<lv_obj styles="cont right_cont" flex_grow="1">
<button_default text="First button"/>
<button_default text="Second button"/>
<dark_slider width="100" height="15" color="0xff0000"/>
<button_warning text="Third button"/>
<button_warning text="Forth button"/>
<button_error text="Fifth button"/>
<button_error text="Sixth button"/>
<dark_slider width="100" height="15" color="0xff0000" send_draw_task_events="true"/>
<button_warning text="First button"/>
<button_warning text="Second button"/>
<button_error text="First button"/>
<button_error text="Second button"/>
</lv_obj>
</view>
</component>
1 change: 1 addition & 0 deletions examples/widgets/dark_slider/dark_slider.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
bg_color="0x0000ff" bg_opa="255"
radius="100"/>
</styles>

<view extends="lv_slider"
styles="main light_knob:knob blue_indicator:indicator"
align="center" value="30" range="20 40" send_draw_task_events="true">
Expand Down
75 changes: 42 additions & 33 deletions examples/widgets/dark_slider/dark_slider_gen.c
Original file line number Diff line number Diff line change
Expand Up @@ -70,53 +70,62 @@ static void dark_slider_constructor(const lv_obj_class_t * class_p, lv_obj_t * o
LV_UNUSED(class_p);
LV_TRACE_OBJ_CREATE("begin");


static lv_style_t style_main;

static lv_style_t style_light_knob;
static lv_style_t style_blue_indicator;

static bool style_main_inited = false;

if(!style_main_inited) {



lv_style_init(&style_main);
lv_style_set_bg_color(&style_main, lv_color_hex(0x333333));
lv_style_set_bg_opa(&style_main, 255);
lv_style_set_border_width(&style_main, 2);
lv_style_set_border_color(&style_main, lv_color_hex(0xaaaaaa));
lv_style_set_radius(&style_main, 100);
lv_style_set_width(&style_main, 120);
lv_style_set_height(&style_main, 16);
lv_style_set_pad_all(&style_main, 4);
style_main_inited = true;
}
lv_style_set_bg_color(&style_main, lv_color_hex(0x333333));

lv_style_set_bg_opa(&style_main, 255);

lv_style_set_border_width(&style_main, 2);

lv_style_set_border_color(&style_main, lv_color_hex(0xaaaaaa));

lv_style_set_radius(&style_main, 100);

lv_style_set_width(&style_main, 120);

lv_style_set_height(&style_main, 16);

lv_obj_add_style(obj, &style_main, LV_PART_MAIN | LV_STATE_DEFAULT);

static lv_style_t style_light_knob;
static bool style_light_knob_inited = false;

if(!style_light_knob_inited) {
lv_style_init(&style_light_knob);
lv_style_set_bg_color(&style_light_knob, lv_color_hex(0xeeeeee));
lv_style_set_bg_opa(&style_light_knob, 255);
lv_style_set_border_width(&style_light_knob, 2);
lv_style_set_radius(&style_light_knob, 100);
lv_style_set_border_color(&style_light_knob, lv_color_hex(0xaaaaaa));
lv_style_set_pad_all(&style_light_knob, 5);
style_light_knob_inited = true;
}
lv_style_set_bg_color(&style_light_knob, lv_color_hex(0xeeeeee));

lv_style_set_bg_opa(&style_light_knob, 255);

lv_style_set_border_width(&style_light_knob, 2);

lv_style_set_radius(&style_light_knob, 100);

lv_style_set_border_color(&style_light_knob, lv_color_hex(0xaaaaaa));

lv_obj_add_style(obj, &style_light_knob, LV_PART_KNOB | LV_STATE_DEFAULT);

static lv_style_t style_blue_indicator;
static bool style_blue_indicator_inited = false;

if(!style_blue_indicator_inited) {
lv_style_init(&style_blue_indicator);
lv_style_set_bg_color(&style_blue_indicator, lv_color_hex(0x0000ff));
lv_style_set_bg_opa(&style_blue_indicator, 255);
lv_style_set_radius(&style_blue_indicator, 100);
style_blue_indicator_inited = true;
lv_style_set_bg_color(&style_blue_indicator, lv_color_hex(0x0000ff));

lv_style_set_bg_opa(&style_blue_indicator, 255);

lv_style_set_radius(&style_blue_indicator, 100);


style_main_inited = true;
}

lv_obj_add_style(obj, &style_blue_indicator, LV_PART_INDICATOR| LV_STATE_DEFAULT);
lv_obj_add_style(obj, &style_main, LV_PART_MAIN | LV_STATE_DEFAULT);




dark_slider_t * dark_slider = (dark_slider_t *)obj;

Expand Down Expand Up @@ -144,4 +153,4 @@ static void dark_slider_event(const lv_obj_class_t * class_p, lv_event_t * e)
if(res != LV_RESULT_OK) return;

dark_slider_event_hook(e);
}
}
4 changes: 2 additions & 2 deletions examples/widgets/dark_slider/dark_slider_private_gen.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ extern "C" {
/*********************
* INCLUDES
*********************/
#include "lvgl/src/widgets/slider/lv_slider_private.h"
#include "lvgl/src/widgets/slider/lv_slider_private.h" /*The ancestor of dark_slider*/
#include "dark_slider.h"

/*********************
Expand Down Expand Up @@ -41,4 +41,4 @@ typedef struct {
} /*extern "C"*/
#endif

#endif /*DARK_SLIDER_PRIVATE_H*/
#endif /*DARK_SLIDER_PRIVATE_H*/
5 changes: 3 additions & 2 deletions examples/widgets/slider_box/slider_box.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
radius="20"
width="180" height="content"
layout="flex"
flex_flow="column" flex_cross_place="center" flex_track_place="center"
flex_flow="column"
flex_cross_place="center" flex_track_place="center"
pad_row="10"
pad_all="10"/>

Expand All @@ -32,7 +33,7 @@
<lv_button width="30" height="30" styles="button">
<lv_label text="-"/>
</lv_button>
<dark_slider flex_grow="1"/>
<dark_slider flex_grow="1" color="0xff00ff"/>
<lv_button styles="button">
<lv_label text="+"/>
</lv_button>
Expand Down
84 changes: 58 additions & 26 deletions examples/widgets/slider_box/slider_box_gen.c
Original file line number Diff line number Diff line change
Expand Up @@ -70,67 +70,99 @@ static void slider_box_constructor(const lv_obj_class_t * class_p, lv_obj_t * ob
LV_UNUSED(class_p);
LV_TRACE_OBJ_CREATE("begin");


static lv_style_t style_main;

static lv_style_t style_transp_cont;
static lv_style_t style_button;

static bool style_main_inited = false;

if(!style_main_inited) {



lv_style_init(&style_main);
lv_style_set_bg_color(&style_main, lv_color_hex(0x666666));
lv_style_set_bg_opa(&style_main, 255);
lv_style_set_border_width(&style_main, 2);
lv_style_set_border_color(&style_main, lv_color_hex(0xaaaaaa));
lv_style_set_radius(&style_main, 20);
lv_style_set_width(&style_main, 250);
lv_style_set_height(&style_main, 100);
lv_style_set_pad_all(&style_main, 10);
style_main_inited = true;
}
lv_style_set_bg_color(&style_main, lv_color_hex(0x666666));

lv_style_set_bg_opa(&style_main, 255);

lv_style_set_border_width(&style_main, 2);

lv_style_set_border_color(&style_main, lv_color_hex(0xaaaaaa));

lv_style_set_radius(&style_main, 20);

lv_style_set_width(&style_main, 180);

lv_style_set_height(&style_main, LV_SIZE_CONTENT);

lv_style_set_layout(&style_main, LV_LAYOUT_FLEX);

lv_style_set_flex_flow(&style_main, LV_FLEX_FLOW_COLUMN);

lv_style_set_flex_cross_place(&style_main, LV_FLEX_ALIGN_CENTER);

lv_style_set_flex_track_place(&style_main, LV_FLEX_ALIGN_CENTER);

lv_style_set_pad_row(&style_main, 10);

lv_obj_add_style(obj, &style_main, LV_PART_MAIN | LV_STATE_DEFAULT);

static lv_style_t style_transp_cont;
static bool style_transp_cont_inited = false;

if(!style_transp_cont_inited) {
lv_style_init(&style_transp_cont);
lv_style_set_bg_opa(&style_transp_cont, 0);
lv_style_set_border_width(&style_transp_cont, 2);
style_transp_cont_inited = true;
}
lv_style_set_bg_opa(&style_transp_cont, 0);

lv_style_set_border_width(&style_transp_cont, 1);

lv_style_set_layout(&style_transp_cont, LV_LAYOUT_FLEX);

lv_style_set_flex_flow(&style_transp_cont, LV_FLEX_FLOW_ROW);

lv_style_set_flex_cross_place(&style_transp_cont, LV_FLEX_ALIGN_CENTER);

lv_style_set_pad_column(&style_transp_cont, 15);

lv_obj_add_style(obj, &style_transp_cont, LV_PART_MAIN | LV_STATE_DEFAULT);

static lv_style_t style_button;
static bool style_button_inited = false;

if(!style_button_inited) {
lv_style_init(&style_button);
lv_style_set_radius(&style_button, 100);
style_button_inited = true;
lv_style_set_radius(&style_button, 100);


style_main_inited = true;
}

lv_obj_add_style(obj, &style_button, LV_PART_MAIN | LV_STATE_DEFAULT);
lv_obj_add_style(obj, &style_main, LV_PART_MAIN | LV_STATE_DEFAULT);


slider_box_t * slider_box = (slider_box_t *)obj;

slider_box->lv_label = lv_label_create(obj);
lv_obj_set_align(slider_box->lv_label, LV_ALIGN_TOP_MID);
lv_label_set_text(slider_box->lv_label, "$title");
lv_obj_set_style_text_color(slider_box->lv_label, lv_color_hex(0x000000), LV_PART_MAIN | LV_STATE_DEFAULT);
lv_obj_set_width(slider_box->lv_label, LV_SIZE_CONTENT);
lv_label_set_long_mode(slider_box->lv_label, LV_LABEL_LONG_MODE_SCROLL);

slider_box->lv_obj = lv_obj_create(obj);
lv_obj_add_style(slider_box->lv_obj, &style_transp_cont, LV_PART_MAIN | LV_STATE_DEFAULT);
lv_obj_set_width(slider_box->lv_obj, lv_pct(100));
lv_obj_set_height(slider_box->lv_obj, LV_SIZE_CONTENT);

slider_box->lv_button = lv_button_create(slider_box->lv_obj);
lv_obj_add_style(slider_box->lv_button, &style_button, LV_PART_MAIN | LV_STATE_DEFAULT);
lv_obj_set_width(slider_box->lv_button, 30);
lv_obj_set_height(slider_box->lv_button, 30);

slider_box->lv_label2 = lv_label_create(slider_box->lv_button);
lv_label_set_text(slider_box->lv_label2, "-");

slider_box->lv_button2 = lv_button_create(slider_box->lv_obj);
lv_obj_add_style(slider_box->lv_button2, &style_button, LV_PART_MAIN | LV_STATE_DEFAULT);

slider_box->lv_label3 = lv_label_create(slider_box->lv_button2);
lv_label_set_text(slider_box->lv_label3, "+");

slider_box->dark_slider = dark_slider_create(slider_box->lv_obj);
dark_slider_set_color(slider_box->dark_slider, lv_color_hex(0xff00ff));


slider_box_constructor_hook(obj);
Expand Down

0 comments on commit 4a4feb8

Please sign in to comment.