Skip to content

Commit

Permalink
minor fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
kisvegabor committed Dec 11, 2024
1 parent 4a4feb8 commit 060aadf
Show file tree
Hide file tree
Showing 4 changed files with 61 additions and 124 deletions.
17 changes: 6 additions & 11 deletions examples/components/home.xml
Original file line number Diff line number Diff line change
Expand Up @@ -36,17 +36,12 @@

<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"/>
<slider_box width="190"/>
<slider_box width="190"/>
<slider_box width="190"/>
<slider_box width="190"/>
<slider_box width="190"/>
<slider_box width="190"/>
</lv_obj>

<lv_obj styles="cont right_cont" flex_grow="1">
Expand Down
2 changes: 1 addition & 1 deletion examples/widgets/dark_slider/dark_slider.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<style name="main"
bg_color="0x333333" bg_opa="255"
border_width="2" border_color="0xaaaaaa"
radius="100"
radius="10"
width="120"
height="16"
pad_all="4"/>
Expand Down
58 changes: 19 additions & 39 deletions examples/widgets/dark_slider/dark_slider_gen.c
Original file line number Diff line number Diff line change
Expand Up @@ -73,60 +73,40 @@ static void dark_slider_constructor(const lv_obj_class_t * class_p, lv_obj_t * o
static lv_style_t style_main;

static lv_style_t style_light_knob;
static lv_style_t style_blue_indicator;
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_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_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_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_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);

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_main, LV_PART_MAIN | LV_STATE_DEFAULT);
lv_obj_add_style(obj, &style_light_knob, LV_PART_KNOB | LV_STATE_DEFAULT);
lv_obj_add_style(obj, &style_blue_indicator, LV_PART_INDICATOR | LV_STATE_DEFAULT);
lv_obj_add_flag(obj, LV_OBJ_FLAG_SEND_DRAW_TASK_EVENTS);




dark_slider_t * dark_slider = (dark_slider_t *)obj;


Expand Down
108 changes: 35 additions & 73 deletions examples/widgets/slider_box/slider_box_gen.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
*********************/
#include "slider_box_private_gen.h"
#include "lvgl/src/core/lv_obj_class_private.h"
#include "ui.h"
#include "../../ui.h"


/*********************
* DEFINES
Expand Down Expand Up @@ -71,99 +72,59 @@ static void slider_box_constructor(const lv_obj_class_t * class_p, lv_obj_t * ob
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 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, 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_style_init(&style_transp_cont);
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_style_init(&style_button);
lv_style_set_radius(&style_button, 100);


style_main_inited = true;
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, 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_ROW_WRAP);
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_style_set_pad_all(&style_main, 10);

lv_style_init(&style_button);
lv_style_set_radius(&style_button, 100);
style_main_inited = true;
}

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);
slider_box->lv_button = lv_button_create(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_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_flex_grow(slider_box->lv_label, 1);
lv_label_set_long_mode(slider_box->lv_label, LV_LABEL_LONG_MODE_SCROLL);
lv_obj_set_style_text_align(slider_box->lv_label, LV_TEXT_ALIGN_CENTER, 0);

slider_box->lv_button2 = lv_button_create(slider_box->lv_obj);
slider_box->lv_button2 = lv_button_create(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->dark_slider = dark_slider_create(obj);
lv_obj_set_width(slider_box->dark_slider, lv_pct(100));

slider_box_constructor_hook(obj);

Expand All @@ -188,4 +149,5 @@ static void slider_box_event(const lv_obj_class_t * class_p, lv_event_t * e)
if(res != LV_RESULT_OK) return;

slider_box_event_hook(e);
}
}

0 comments on commit 060aadf

Please sign in to comment.