mirror of
https://github.com/lvgl/lvgl.git
synced 2026-05-23 07:46:36 +08:00
Merge branch 'master' of https://github.com/littlevgl/lvgl
This commit is contained in:
@@ -5,6 +5,7 @@ on:
|
||||
- master
|
||||
jobs:
|
||||
build-and-deploy:
|
||||
if: github.repository == 'lvgl/lvgl'
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout
|
||||
@@ -23,6 +24,8 @@ jobs:
|
||||
pip install --upgrade --upgrade-strategy eager sphinx recommonmark commonmark breathe sphinx-rtd-theme sphinx-markdown-tables sphinx-sitemap
|
||||
- name: Build docs
|
||||
run: docs/build.py
|
||||
- name: Remove .doctrees
|
||||
run: rm -rf out_html/.doctrees
|
||||
- name: Retrieve version
|
||||
run: |
|
||||
echo "::set-output name=VERSION_NAME::$(scripts/find_version.sh)"
|
||||
@@ -37,3 +40,4 @@ jobs:
|
||||
FOLDER: out_html # The folder the action should deploy.
|
||||
TARGET_FOLDER: ${{ steps.version.outputs.VERSION_NAME }}
|
||||
PRESERVE: true
|
||||
SINGLE_COMMIT: true
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
# Changelog
|
||||
|
||||
## v7.11.0 (Planned for 19.02.2021)
|
||||
## v7.11.0
|
||||
|
||||
### New features
|
||||
- Add better screen orientation management with software rotation support
|
||||
|
||||
@@ -37,10 +37,13 @@ void lv_example_get_started_2(void)
|
||||
lv_style_set_bg_grad_color(&style_btn_pressed, lv_palette_darken(LV_PALETTE_RED, 3));
|
||||
|
||||
/*Create a button and use the new styles*/
|
||||
lv_obj_t * btn = lv_btn_create(lv_scr_act()); /*Add a button the current screen*/
|
||||
lv_obj_t * btn = lv_btn_create(lv_scr_act()); /*Add a button the current screen*/
|
||||
/* Remove the styles coming from the theme
|
||||
* Note that size and position are also stored as style properties
|
||||
* so lv_obj_remove_style_all will remove the set size and position too */
|
||||
lv_obj_remove_style_all(btn);
|
||||
lv_obj_set_pos(btn, 10, 10); /*Set its position*/
|
||||
lv_obj_set_size(btn, 120, 50); /*Set its size*/
|
||||
lv_obj_remove_style_all(btn); /*Remove the styles coming from the theme*/
|
||||
lv_obj_add_style(btn, &style_btn, 0);
|
||||
lv_obj_add_style(btn, &style_btn_pressed, LV_STATE_PRESSED);
|
||||
|
||||
@@ -50,9 +53,9 @@ void lv_example_get_started_2(void)
|
||||
|
||||
/*Create an other button and use the red style too*/
|
||||
lv_obj_t * btn2 = lv_btn_create(lv_scr_act());
|
||||
lv_obj_remove_style_all(btn2); /*Remove the styles coming from the theme*/
|
||||
lv_obj_set_pos(btn2, 10, 80);
|
||||
lv_obj_set_size(btn2, 120, 50); /*Set its size*/
|
||||
lv_obj_remove_style_all(btn2); /*Remove the styles coming from the theme*/
|
||||
lv_obj_add_style(btn2, &style_btn, 0);
|
||||
lv_obj_add_style(btn2, &style_btn_red, 0);
|
||||
lv_obj_add_style(btn2, &style_btn_pressed, LV_STATE_PRESSED);
|
||||
|
||||
@@ -15,6 +15,7 @@ void lv_example_meter_1(void)
|
||||
{
|
||||
meter = lv_meter_create(lv_scr_act());
|
||||
lv_obj_center(meter);
|
||||
lv_obj_set_size(meter, 200, 200);
|
||||
|
||||
/*Add a scale first*/
|
||||
lv_meter_scale_t * scale = lv_meter_add_scale(meter);
|
||||
|
||||
@@ -16,6 +16,7 @@ void lv_example_meter_2(void)
|
||||
{
|
||||
meter = lv_meter_create(lv_scr_act());
|
||||
lv_obj_center(meter);
|
||||
lv_obj_set_size(meter, 200, 200);
|
||||
|
||||
/*Remove the circle from the middle*/
|
||||
lv_obj_remove_style(meter, NULL, LV_PART_INDICATOR);
|
||||
|
||||
@@ -8,13 +8,13 @@ static void set_value(void * indic, int32_t v)
|
||||
lv_meter_set_indicator_end_value(meter, indic, v);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* A clock from a meter
|
||||
*/
|
||||
void lv_example_meter_3(void)
|
||||
{
|
||||
meter = lv_meter_create(lv_scr_act());
|
||||
lv_obj_set_size(meter, 220, 220);
|
||||
lv_obj_center(meter);
|
||||
|
||||
/*Create a scale for the minutes*/
|
||||
|
||||
@@ -7,12 +7,14 @@
|
||||
void lv_example_meter_4(void)
|
||||
{
|
||||
lv_obj_t * meter = lv_meter_create(lv_scr_act());
|
||||
lv_obj_center(meter);
|
||||
|
||||
/*Remove the background and the circle from the middle*/
|
||||
lv_obj_remove_style(meter, NULL, LV_PART_MAIN);
|
||||
lv_obj_remove_style(meter, NULL, LV_PART_INDICATOR);
|
||||
|
||||
lv_obj_set_size(meter, 200, 200);
|
||||
lv_obj_center(meter);
|
||||
|
||||
/*Add a scale first with no ticks.*/
|
||||
lv_meter_scale_t * scale = lv_meter_add_scale(meter);
|
||||
lv_meter_set_scale_ticks(meter, scale, 0, 0, 0, lv_color_black());
|
||||
|
||||
+2
-2
@@ -463,8 +463,8 @@ e.g. "stm32f769xx.h" or "stm32f429xx.h"*/
|
||||
#define LV_USE_THEME_DEFAULT 1
|
||||
#if LV_USE_THEME_DEFAULT
|
||||
|
||||
/*1: Light mode; 0: Dark mode*/
|
||||
# define LV_THEME_DEFAULT_PALETTE_LIGHT 1
|
||||
/*0: Light mode; 1: Dark mode*/
|
||||
# define LV_THEME_DEFAULT_DARK 0
|
||||
|
||||
/*1: Enable grow on press*/
|
||||
# define LV_THEME_DEFAULT_GROW 1
|
||||
|
||||
+1
-1
@@ -285,7 +285,7 @@ static bool event_is_bubbled(lv_event_code_t e)
|
||||
case LV_EVENT_CHILD_CHANGED:
|
||||
case LV_EVENT_SIZE_CHANGED:
|
||||
case LV_EVENT_STYLE_CHANGED:
|
||||
case LV_EVENT_GET_SELF_SIZE:
|
||||
case LV_EVENT_REFR_SELF_SIZE:
|
||||
return false;
|
||||
default:
|
||||
return true;
|
||||
|
||||
+1
-1
@@ -76,7 +76,7 @@ typedef enum {
|
||||
LV_EVENT_SIZE_CHANGED, /**< Object coordinates/size have changed*/
|
||||
LV_EVENT_STYLE_CHANGED, /**< Object's style has changed*/
|
||||
LV_EVENT_BASE_DIR_CHANGED, /**< The base dir has changed*/
|
||||
LV_EVENT_GET_SELF_SIZE, /**< Get the internal size of a widget*/
|
||||
LV_EVENT_REFR_SELF_SIZE, /**< Get the internal size of a widget*/
|
||||
|
||||
_LV_EVENT_LAST /** Number of default events*/
|
||||
}lv_event_code_t;
|
||||
|
||||
@@ -164,6 +164,7 @@ typedef struct _lv_obj_t {
|
||||
void * user_data;
|
||||
#endif
|
||||
lv_area_t coords;
|
||||
lv_point_t self_size;
|
||||
lv_obj_flag_t flags;
|
||||
lv_state_t state;
|
||||
uint16_t layout_inv :1;
|
||||
|
||||
@@ -95,6 +95,7 @@ lv_obj_t * lv_obj_create_from_class(const lv_obj_class_t * class_p, lv_obj_t * p
|
||||
}
|
||||
|
||||
|
||||
lv_obj_mark_layout_as_dirty(obj);
|
||||
lv_theme_apply(obj);
|
||||
lv_obj_construct(obj);
|
||||
lv_group_t * def_group = lv_group_get_default();
|
||||
|
||||
+7
-10
@@ -592,23 +592,20 @@ void lv_obj_get_content_coords(const lv_obj_t * obj, lv_area_t * area)
|
||||
|
||||
lv_coord_t lv_obj_get_self_width(struct _lv_obj_t * obj)
|
||||
{
|
||||
lv_point_t p = {0, LV_COORD_MIN};
|
||||
lv_event_send((lv_obj_t * )obj, LV_EVENT_GET_SELF_SIZE, &p);
|
||||
return p.x;
|
||||
return obj->self_size.x;
|
||||
}
|
||||
|
||||
lv_coord_t lv_obj_get_self_height(struct _lv_obj_t * obj)
|
||||
{
|
||||
lv_point_t p = {LV_COORD_MIN, 0};
|
||||
lv_event_send((lv_obj_t * )obj, LV_EVENT_GET_SELF_SIZE, &p);
|
||||
return p.y;
|
||||
return obj->self_size.y;
|
||||
}
|
||||
|
||||
bool lv_obj_handle_self_size_chg(struct _lv_obj_t * obj)
|
||||
bool lv_obj_refresh_self_size(struct _lv_obj_t * obj)
|
||||
{
|
||||
lv_coord_t w_set = lv_obj_get_style_width(obj, LV_PART_MAIN);
|
||||
lv_coord_t h_set = lv_obj_get_style_height(obj, LV_PART_MAIN);
|
||||
if(w_set != LV_SIZE_CONTENT && h_set != LV_SIZE_CONTENT) return false;
|
||||
lv_obj_update_layout(obj);
|
||||
obj->self_size.x = 0;
|
||||
obj->self_size.y = 0;
|
||||
lv_event_send(obj, LV_EVENT_REFR_SELF_SIZE, &obj->self_size);
|
||||
|
||||
lv_obj_refr_size(obj);
|
||||
return true;
|
||||
|
||||
@@ -293,7 +293,7 @@ lv_coord_t lv_obj_get_self_height(struct _lv_obj_t * obj);
|
||||
* @param obj pointer to an object
|
||||
* @return false: nothing happened; true: refresh happened
|
||||
*/
|
||||
bool lv_obj_handle_self_size_chg(struct _lv_obj_t * obj);
|
||||
bool lv_obj_refresh_self_size(struct _lv_obj_t * obj);
|
||||
|
||||
void lv_obj_refr_pos(struct _lv_obj_t * obj);
|
||||
|
||||
|
||||
@@ -299,10 +299,12 @@ void lv_obj_scroll_to_x(lv_obj_t * obj, lv_coord_t x, lv_anim_enable_t anim_en)
|
||||
|
||||
/*Don't let scroll more then naturally possible by the size of the content*/
|
||||
if(x < 0) x = 0;
|
||||
lv_coord_t scroll_max = lv_obj_get_scroll_left(obj) + lv_obj_get_scroll_right(obj);
|
||||
if(scroll_max < 0) scroll_max = 0;
|
||||
if(x > 0) {
|
||||
lv_coord_t scroll_max = lv_obj_get_scroll_left(obj) + lv_obj_get_scroll_right(obj);
|
||||
if(scroll_max < 0) scroll_max = 0;
|
||||
|
||||
if(x > scroll_max) x = scroll_max;
|
||||
if(x > scroll_max) x = scroll_max;
|
||||
}
|
||||
|
||||
lv_coord_t scroll_x = lv_obj_get_scroll_x(obj);
|
||||
lv_coord_t diff = -x + scroll_x;
|
||||
@@ -316,9 +318,11 @@ void lv_obj_scroll_to_y(lv_obj_t * obj, lv_coord_t y, lv_anim_enable_t anim_en)
|
||||
|
||||
/*Don't let scroll more then naturally possible by the size of the content*/
|
||||
if(y < 0) y = 0;
|
||||
lv_coord_t scroll_max = lv_obj_get_scroll_top(obj) + lv_obj_get_scroll_bottom(obj);
|
||||
if(scroll_max < 0) scroll_max = 0;
|
||||
if(y > scroll_max) y = scroll_max;
|
||||
if(y > 0) {
|
||||
lv_coord_t scroll_max = lv_obj_get_scroll_top(obj) + lv_obj_get_scroll_bottom(obj);
|
||||
if(scroll_max < 0) scroll_max = 0;
|
||||
if(y > scroll_max) y = scroll_max;
|
||||
}
|
||||
|
||||
lv_coord_t scroll_y = lv_obj_get_scroll_y(obj);
|
||||
lv_coord_t diff = -y + scroll_y;
|
||||
|
||||
@@ -95,18 +95,6 @@ const lv_font_t * lv_theme_get_font_large(lv_obj_t * obj)
|
||||
return th ? th->font_large : LV_FONT_DEFAULT;
|
||||
}
|
||||
|
||||
lv_palette_t lv_theme_get_palette_primary(lv_obj_t * obj)
|
||||
{
|
||||
lv_theme_t * th = lv_theme_get_from_obj(obj);
|
||||
return th ? th->palette_primary : LV_PALETTE_BLUE_GREY;
|
||||
}
|
||||
|
||||
lv_palette_t lv_theme_get_palette_secondary(lv_obj_t * obj)
|
||||
{
|
||||
lv_theme_t * th = lv_theme_get_from_obj(obj);
|
||||
return th ? th->palette_secondary : LV_PALETTE_BLUE;
|
||||
}
|
||||
|
||||
lv_color_t lv_theme_get_color_primary(lv_obj_t * obj)
|
||||
{
|
||||
lv_theme_t * th = lv_theme_get_from_obj(obj);
|
||||
|
||||
@@ -33,8 +33,6 @@ typedef struct _lv_theme_t {
|
||||
struct _lv_theme_t * parent; /**< Apply the current theme's style on top of this theme.*/
|
||||
void * user_data;
|
||||
struct _lv_disp_t * disp;
|
||||
lv_palette_t palette_primary;
|
||||
lv_palette_t palette_secondary;
|
||||
lv_color_t color_primary;
|
||||
lv_color_t color_secondary;
|
||||
const lv_font_t * font_small;
|
||||
@@ -94,10 +92,6 @@ const lv_font_t * lv_theme_get_font_normal(lv_obj_t * obj);
|
||||
*/
|
||||
const lv_font_t * lv_theme_get_font_large(lv_obj_t * obj);
|
||||
|
||||
lv_palette_t lv_theme_get_palette_primary(lv_obj_t * obj);
|
||||
|
||||
lv_palette_t lv_theme_get_palette_secondary(lv_obj_t * obj);
|
||||
|
||||
/**
|
||||
* Get the primary color of the theme
|
||||
* @return the color
|
||||
|
||||
@@ -61,7 +61,6 @@ void lv_draw_img_dsc_init(lv_draw_img_dsc_t * dsc)
|
||||
dsc->opa = LV_OPA_COVER;
|
||||
dsc->zoom = LV_IMG_ZOOM_NONE;
|
||||
dsc->antialias = LV_COLOR_DEPTH > 8 ? 1 : 0;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -158,8 +158,6 @@ lv_theme_t * lv_theme_basic_init(lv_disp_t * disp)
|
||||
}
|
||||
|
||||
theme.disp = disp;
|
||||
theme.palette_primary = LV_PALETTE_NONE;
|
||||
theme.palette_secondary = LV_PALETTE_NONE;
|
||||
theme.font_small = LV_FONT_DEFAULT;
|
||||
theme.font_normal = LV_FONT_DEFAULT;
|
||||
theme.font_large = LV_FONT_DEFAULT;
|
||||
|
||||
@@ -33,8 +33,8 @@
|
||||
#define BORDER_WIDTH LV_DPX(2)
|
||||
#define OUTLINE_WIDTH LV_DPX(3)
|
||||
|
||||
#define PAD_DEF (disp_size == DISP_LARGE ? LV_DPX(24) : disp_size == DISP_MEDIUM ? LV_DPX(20) : LV_DPX(20))
|
||||
#define PAD_SMALL (disp_size == DISP_LARGE ? LV_DPX(14) : disp_size == DISP_MEDIUM ? LV_DPX(12) : LV_DPX(12))
|
||||
#define PAD_DEF (disp_size == DISP_LARGE ? LV_DPX(24) : disp_size == DISP_MEDIUM ? LV_DPX(20) : LV_DPX(16))
|
||||
#define PAD_SMALL (disp_size == DISP_LARGE ? LV_DPX(14) : disp_size == DISP_MEDIUM ? LV_DPX(12) : LV_DPX(10))
|
||||
#define PAD_TINY (disp_size == DISP_LARGE ? LV_DPX(8) : disp_size == DISP_MEDIUM ? LV_DPX(6) : LV_DPX(2))
|
||||
|
||||
/**********************
|
||||
@@ -165,8 +165,6 @@ static my_theme_styles_t * styles;
|
||||
static lv_theme_t theme;
|
||||
static disp_size_t disp_size;
|
||||
static bool inited;
|
||||
static lv_color_t color_primary;
|
||||
static lv_color_t color_secondary;
|
||||
static lv_color_t color_scr;
|
||||
static lv_color_t color_text;
|
||||
static lv_color_t color_card;
|
||||
@@ -206,17 +204,11 @@ static void style_init(void)
|
||||
0
|
||||
};
|
||||
|
||||
color_primary = lv_palette_main(theme.palette_primary);
|
||||
color_secondary = lv_palette_main(theme.palette_secondary);
|
||||
|
||||
color_scr = theme.flags & MODE_DARK ? DARK_COLOR_SCR : LIGHT_COLOR_SCR;
|
||||
color_text = theme.flags & MODE_DARK ? DARK_COLOR_TEXT : LIGHT_COLOR_TEXT;
|
||||
color_card = theme.flags & MODE_DARK ? DARK_COLOR_CARD : LIGHT_COLOR_CARD;
|
||||
color_grey = theme.flags & MODE_DARK ? DARK_COLOR_GREY : LIGHT_COLOR_GREY;
|
||||
|
||||
theme.color_primary = color_primary;
|
||||
theme.color_secondary = color_secondary;
|
||||
|
||||
static lv_style_transition_dsc_t trans_delayed;
|
||||
lv_style_transition_dsc_init(&trans_delayed, trans_props, lv_anim_path_linear, TRANSITION_TIME, 70);
|
||||
|
||||
@@ -263,13 +255,13 @@ static void style_init(void)
|
||||
lv_style_set_line_width(&styles->card, LV_DPX(1));
|
||||
|
||||
style_init_reset(&styles->outline_primary);
|
||||
lv_style_set_outline_color(&styles->outline_primary, color_primary);
|
||||
lv_style_set_outline_color(&styles->outline_primary, theme.color_primary);
|
||||
lv_style_set_outline_width(&styles->outline_primary, OUTLINE_WIDTH);
|
||||
lv_style_set_outline_pad(&styles->outline_primary, OUTLINE_WIDTH);
|
||||
lv_style_set_outline_opa(&styles->outline_primary, LV_OPA_50);
|
||||
|
||||
style_init_reset(&styles->outline_secondary);
|
||||
lv_style_set_outline_color(&styles->outline_secondary, color_secondary);
|
||||
lv_style_set_outline_color(&styles->outline_secondary, theme.color_secondary);
|
||||
lv_style_set_outline_width(&styles->outline_secondary, OUTLINE_WIDTH);
|
||||
lv_style_set_outline_opa(&styles->outline_secondary, LV_OPA_50);
|
||||
|
||||
@@ -338,23 +330,23 @@ static void style_init(void)
|
||||
lv_style_set_pad_column(&styles->pad_tiny, PAD_TINY);
|
||||
|
||||
style_init_reset(&styles->bg_color_primary);
|
||||
lv_style_set_bg_color(&styles->bg_color_primary, color_primary);
|
||||
lv_style_set_bg_color(&styles->bg_color_primary, theme.color_primary);
|
||||
lv_style_set_text_color(&styles->bg_color_primary, lv_color_white());
|
||||
lv_style_set_bg_opa(&styles->bg_color_primary, LV_OPA_COVER);
|
||||
|
||||
style_init_reset(&styles->bg_color_primary_muted);
|
||||
lv_style_set_bg_color(&styles->bg_color_primary_muted, color_primary);
|
||||
lv_style_set_text_color(&styles->bg_color_primary_muted, color_primary);
|
||||
lv_style_set_bg_color(&styles->bg_color_primary_muted, theme.color_primary);
|
||||
lv_style_set_text_color(&styles->bg_color_primary_muted, theme.color_primary);
|
||||
lv_style_set_bg_opa(&styles->bg_color_primary_muted, LV_OPA_20);
|
||||
|
||||
style_init_reset(&styles->bg_color_secondary);
|
||||
lv_style_set_bg_color(&styles->bg_color_secondary, color_secondary);
|
||||
lv_style_set_bg_color(&styles->bg_color_secondary, theme.color_secondary);
|
||||
lv_style_set_text_color(&styles->bg_color_secondary, lv_color_white());
|
||||
lv_style_set_bg_opa(&styles->bg_color_secondary, LV_OPA_COVER);
|
||||
|
||||
style_init_reset(&styles->bg_color_secondary_muted);
|
||||
lv_style_set_bg_color(&styles->bg_color_secondary_muted, color_secondary);
|
||||
lv_style_set_text_color(&styles->bg_color_secondary_muted, color_secondary);
|
||||
lv_style_set_bg_color(&styles->bg_color_secondary_muted, theme.color_secondary);
|
||||
lv_style_set_text_color(&styles->bg_color_secondary_muted, theme.color_secondary);
|
||||
lv_style_set_bg_opa(&styles->bg_color_secondary_muted, LV_OPA_20);
|
||||
|
||||
style_init_reset(&styles->bg_color_grey);
|
||||
@@ -380,7 +372,7 @@ static void style_init(void)
|
||||
#endif
|
||||
|
||||
style_init_reset(&styles->knob);
|
||||
lv_style_set_bg_color(&styles->knob, color_primary);
|
||||
lv_style_set_bg_color(&styles->knob, theme.color_primary);
|
||||
lv_style_set_bg_opa(&styles->knob, LV_OPA_COVER);
|
||||
lv_style_set_pad_all(&styles->knob, LV_DPX(6));
|
||||
lv_style_set_radius(&styles->knob, LV_RADIUS_CIRCLE);
|
||||
@@ -395,14 +387,14 @@ static void style_init(void)
|
||||
lv_style_set_arc_rounded(&styles->arc_indic, true);
|
||||
|
||||
style_init_reset(&styles->arc_indic_primary);
|
||||
lv_style_set_arc_color(&styles->arc_indic_primary, color_primary);
|
||||
lv_style_set_arc_color(&styles->arc_indic_primary, theme.color_primary);
|
||||
#endif
|
||||
|
||||
#if LV_USE_CHECKBOX
|
||||
style_init_reset(&styles->cb_marker);
|
||||
lv_style_set_pad_all(&styles->cb_marker, LV_DPX(3));
|
||||
lv_style_set_border_width(&styles->cb_marker, BORDER_WIDTH);
|
||||
lv_style_set_border_color(&styles->cb_marker, color_primary);
|
||||
lv_style_set_border_color(&styles->cb_marker, theme.color_primary);
|
||||
lv_style_set_bg_color(&styles->cb_marker, color_card);
|
||||
lv_style_set_bg_opa(&styles->cb_marker, LV_OPA_COVER);
|
||||
lv_style_set_radius(&styles->cb_marker, RADIUS_DEFAULT / 2);
|
||||
@@ -514,7 +506,7 @@ static void style_init(void)
|
||||
|
||||
#if LV_USE_TABVIEW
|
||||
style_init_reset(&styles->tab_btn);
|
||||
lv_style_set_border_color(&styles->tab_btn, color_primary);
|
||||
lv_style_set_border_color(&styles->tab_btn, theme.color_primary);
|
||||
lv_style_set_border_width(&styles->tab_btn, BORDER_WIDTH * 2);
|
||||
lv_style_set_border_side(&styles->tab_btn, LV_BORDER_SIDE_BOTTOM);
|
||||
#endif
|
||||
@@ -557,8 +549,7 @@ static void style_init(void)
|
||||
* GLOBAL FUNCTIONS
|
||||
**********************/
|
||||
|
||||
lv_theme_t * lv_theme_default_init(lv_disp_t * disp, lv_palette_t palette_primary, lv_palette_t palette_secondary, bool dark,
|
||||
const lv_font_t * font_small, const lv_font_t * font_normal, const lv_font_t * font_large)
|
||||
lv_theme_t * lv_theme_default_init(lv_disp_t * disp, lv_color_t color_primary, lv_color_t color_secondary, bool dark, const lv_font_t * font)
|
||||
{
|
||||
|
||||
/*This trick is required only to avoid the garbage collection of
|
||||
@@ -574,11 +565,11 @@ lv_theme_t * lv_theme_default_init(lv_disp_t * disp, lv_palette_t palette_primar
|
||||
else disp_size = DISP_LARGE;
|
||||
|
||||
theme.disp = disp;
|
||||
theme.palette_primary = palette_primary;
|
||||
theme.palette_secondary = palette_secondary;
|
||||
theme.font_small = font_small;
|
||||
theme.font_normal = font_normal;
|
||||
theme.font_large = font_large;
|
||||
theme.color_primary = color_primary;
|
||||
theme.color_secondary = color_secondary;
|
||||
theme.font_small = font;
|
||||
theme.font_normal = font;
|
||||
theme.font_large = font;
|
||||
theme.apply_cb = theme_apply;
|
||||
theme.flags = dark ? MODE_DARK : 0;
|
||||
|
||||
@@ -883,7 +874,8 @@ static void theme_apply(lv_theme_t * th, lv_obj_t * obj)
|
||||
lv_obj_add_style(obj, &styles->keyboard_btn_bg, LV_PART_ITEMS);
|
||||
lv_obj_add_style(obj, &styles->pressed, LV_PART_ITEMS | LV_STATE_PRESSED);
|
||||
lv_obj_add_style(obj, &styles->bg_color_grey, LV_PART_ITEMS | LV_STATE_CHECKED);
|
||||
lv_obj_add_style(obj, &styles->outline_primary, LV_PART_ITEMS | LV_STATE_FOCUSED);
|
||||
lv_obj_add_style(obj, &styles->outline_primary, LV_PART_ITEMS | LV_STATE_FOCUS_KEY);
|
||||
lv_obj_add_style(obj, &styles->outline_secondary, LV_PART_ITEMS | LV_STATE_EDITED);
|
||||
}
|
||||
#endif
|
||||
#if LV_USE_LIST
|
||||
@@ -938,6 +930,7 @@ static void theme_apply(lv_theme_t * th, lv_obj_t * obj)
|
||||
#if LV_USE_TABVIEW
|
||||
if(lv_obj_check_type(obj, &lv_tabview_class)) {
|
||||
lv_obj_add_style(obj, &styles->scr, 0);
|
||||
lv_obj_add_style(obj, &styles->pad_zero, 0);
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -36,8 +36,7 @@ extern "C" {
|
||||
* @param font pointer to a font to use.
|
||||
* @return a pointer to reference this theme later
|
||||
*/
|
||||
lv_theme_t * lv_theme_default_init(lv_disp_t * disp, lv_palette_t palette_primary, lv_palette_t palette_secondary,
|
||||
bool dark, const lv_font_t * font_small, const lv_font_t * font_normal, const lv_font_t * font_large);
|
||||
lv_theme_t * lv_theme_default_init(lv_disp_t * disp, lv_color_t color_primary, lv_color_t color_secondary, bool dark, const lv_font_t * font);
|
||||
|
||||
|
||||
bool lv_theme_default_is_inited(void);
|
||||
|
||||
@@ -132,7 +132,7 @@ lv_disp_t * lv_disp_drv_register(lv_disp_drv_t * driver)
|
||||
|
||||
#if LV_USE_THEME_DEFAULT
|
||||
if(lv_theme_default_is_inited() == false) {
|
||||
disp->theme = lv_theme_default_init(disp, LV_PALETTE_BLUE, LV_PALETTE_CYAN, false, LV_FONT_DEFAULT, LV_FONT_DEFAULT, LV_FONT_DEFAULT);
|
||||
disp->theme = lv_theme_default_init(disp, lv_palette_main(LV_PALETTE_BLUE), lv_palette_main(LV_PALETTE_RED), LV_THEME_DEFAULT_DARK, LV_FONT_DEFAULT);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
@@ -1398,12 +1398,12 @@ e.g. "stm32f769xx.h" or "stm32f429xx.h"*/
|
||||
#endif
|
||||
#if LV_USE_THEME_DEFAULT
|
||||
|
||||
/*1: Light mode; 0: Dark mode*/
|
||||
#ifndef LV_THEME_DEFAULT_PALETTE_LIGHT
|
||||
# ifdef CONFIG_LV_THEME_DEFAULT_PALETTE_LIGHT
|
||||
# define LV_THEME_DEFAULT_PALETTE_LIGHT CONFIG_LV_THEME_DEFAULT_PALETTE_LIGHT
|
||||
/*0: Light mode; 1: Dark mode*/
|
||||
#ifndef LV_THEME_DEFAULT_DARK
|
||||
# ifdef CONFIG_LV_THEME_DEFAULT_DARK
|
||||
# define LV_THEME_DEFAULT_DARK CONFIG_LV_THEME_DEFAULT_DARK
|
||||
# else
|
||||
# define LV_THEME_DEFAULT_PALETTE_LIGHT 1
|
||||
# define LV_THEME_DEFAULT_DARK 0
|
||||
# endif
|
||||
#endif
|
||||
|
||||
|
||||
+4
-4
@@ -247,10 +247,10 @@ void _lv_area_align(const lv_area_t * base, const lv_area_t * to_align, lv_align
|
||||
#define LV_COORD_SET_SPEC(x) ((x) | _LV_COORD_TYPE_SPEC)
|
||||
|
||||
/*Special coordinates*/
|
||||
#define LV_PCT(x) LV_COORD_SET_SPEC(x)
|
||||
#define LV_COORD_IS_PCT(x) ((LV_COORD_IS_SPEC(x) && _LV_COORD_PLAIN(x) <= 1000) ? true : false)
|
||||
#define LV_COORD_GET_PCT(x) _LV_COORD_PLAIN(x)
|
||||
#define LV_SIZE_CONTENT LV_COORD_SET_SPEC(1001)
|
||||
#define LV_PCT(x) (x < 0 ? LV_COORD_SET_SPEC(1000 - (x)) : LV_COORD_SET_SPEC(x))
|
||||
#define LV_COORD_IS_PCT(x) ((LV_COORD_IS_SPEC(x) && _LV_COORD_PLAIN(x) <= 2000) ? true : false)
|
||||
#define LV_COORD_GET_PCT(x) (_LV_COORD_PLAIN(x) > 1000 ? 1000 - _LV_COORD_PLAIN(x) : _LV_COORD_PLAIN(x))
|
||||
#define LV_SIZE_CONTENT LV_COORD_SET_SPEC(2001)
|
||||
|
||||
LV_EXPORT_CONST_INT(LV_SIZE_CONTENT);
|
||||
|
||||
|
||||
+15
-7
@@ -70,11 +70,10 @@ void _lv_log_add(lv_log_level_t level, const char * file, int line, const char *
|
||||
if(level >= LV_LOG_LEVEL) {
|
||||
va_list args;
|
||||
va_start(args, format);
|
||||
char buf[256];
|
||||
lv_vsnprintf(buf, sizeof(buf), format, args);
|
||||
char msg[256];
|
||||
lv_vsnprintf(msg, sizeof(msg), format, args);
|
||||
va_end(args);
|
||||
|
||||
#if LV_LOG_PRINTF
|
||||
/*Use only the file name not the path*/
|
||||
size_t p;
|
||||
for(p = strlen(file); p > 0; p--) {
|
||||
@@ -84,15 +83,24 @@ void _lv_log_add(lv_log_level_t level, const char * file, int line, const char *
|
||||
}
|
||||
}
|
||||
|
||||
char buf[512];
|
||||
uint32_t t = lv_tick_get();
|
||||
static const char * lvl_prefix[] = {"Trace", "Info", "Warn", "Error", "User"};
|
||||
printf("[%s]\t(%d.%03d)\t %s: %s \t(in %s line #%d)\n", lvl_prefix[level], t / 1000, t % 1000, func, buf, &file[p], line);
|
||||
#else
|
||||
if(custom_print_cb) custom_print_cb(level, file, line, func, buf);
|
||||
#endif
|
||||
lv_snprintf(buf, sizeof(buf), "[%s]\t(%d.%03d)\t %s: %s \t(in %s line #%d)\n", lvl_prefix[level], t / 1000, t % 1000, func, msg, &file[p], line);
|
||||
|
||||
lv_log(buf);
|
||||
}
|
||||
}
|
||||
|
||||
void lv_log(const char * buf)
|
||||
{
|
||||
#if LV_LOG_PRINTF
|
||||
printf("%s", buf);
|
||||
#endif
|
||||
if(custom_print_cb) custom_print_cb(buf);
|
||||
|
||||
}
|
||||
|
||||
/**********************
|
||||
* STATIC FUNCTIONS
|
||||
**********************/
|
||||
|
||||
+16
-9
@@ -45,9 +45,9 @@ typedef int8_t lv_log_level_t;
|
||||
**********************/
|
||||
|
||||
/**
|
||||
* Log print function. Receives "Log Level", "File path", "Line number", "Function name" and "Description".
|
||||
* Log print function. Receives a string buffer to print".
|
||||
*/
|
||||
typedef void (*lv_log_print_g_cb_t)(lv_log_level_t level, const char *, uint32_t, const char *, const char *);
|
||||
typedef void (*lv_log_print_g_cb_t)(const char *buf);
|
||||
|
||||
/**********************
|
||||
* GLOBAL PROTOTYPES
|
||||
@@ -57,18 +57,25 @@ typedef void (*lv_log_print_g_cb_t)(lv_log_level_t level, const char *, uint32_t
|
||||
* Register custom print/write function to call when a log is added.
|
||||
* It can format its "File path", "Line number" and "Description" as required
|
||||
* and send the formatted log message to a console or serial port.
|
||||
* @param print_cb a function pointer to print a log
|
||||
* @param print_cb a function pointer to print a log
|
||||
*/
|
||||
void lv_log_register_print_cb(lv_log_print_g_cb_t print_cb);
|
||||
|
||||
/**
|
||||
* Print a log message via `printf` if enabled with `LV_LOG_PRINTF` in `lv_conf.h`
|
||||
* and/or a print callback if registered with `lv_log_register_print_cb`
|
||||
* @param buf a string message to print
|
||||
*/
|
||||
void lv_log(const char * buf);
|
||||
|
||||
/**
|
||||
* Add a log
|
||||
* @param level the level of log. (From `lv_log_level_t` enum)
|
||||
* @param file name of the file when the log added
|
||||
* @param line line number in the source code where the log added
|
||||
* @param func name of the function when the log added
|
||||
* @param format printf-like format string
|
||||
* @param ... parameters for `format`
|
||||
* @param level the level of log. (From `lv_log_level_t` enum)
|
||||
* @param file name of the file when the log added
|
||||
* @param line line number in the source code where the log added
|
||||
* @param func name of the function when the log added
|
||||
* @param format printf-like format string
|
||||
* @param ... parameters for `format`
|
||||
*/
|
||||
void _lv_log_add(lv_log_level_t level, const char * file, int line, const char * func, const char * format, ...);
|
||||
|
||||
|
||||
@@ -196,6 +196,7 @@ void lv_chart_set_zoom_x(lv_obj_t * obj, uint16_t zoom_x)
|
||||
if(chart->zoom_x == zoom_x) return;
|
||||
|
||||
chart->zoom_x = zoom_x;
|
||||
lv_obj_refresh_self_size(obj);
|
||||
lv_obj_invalidate(obj);
|
||||
}
|
||||
|
||||
@@ -207,6 +208,7 @@ void lv_chart_set_zoom_y(lv_obj_t * obj, uint16_t zoom_y)
|
||||
if(chart->zoom_y == zoom_y) return;
|
||||
|
||||
chart->zoom_y = zoom_y;
|
||||
lv_obj_refresh_self_size(obj);
|
||||
lv_obj_invalidate(obj);
|
||||
}
|
||||
|
||||
@@ -645,7 +647,7 @@ static void lv_chart_event(const lv_obj_class_t * class_p, lv_event_t * e)
|
||||
lv_coord_t * s = lv_event_get_param(e);
|
||||
*s = LV_MAX4(*s, chart->tick[LV_CHART_AXIS_X].draw_size,
|
||||
chart->tick[LV_CHART_AXIS_PRIMARY_Y].draw_size, chart->tick[LV_CHART_AXIS_SECONDARY_Y].draw_size);
|
||||
} else if(code == LV_EVENT_GET_SELF_SIZE) {
|
||||
} else if(code == LV_EVENT_REFR_SELF_SIZE) {
|
||||
lv_point_t * p = lv_event_get_param(e);
|
||||
p->x = (lv_obj_get_content_width(obj) * chart->zoom_x) >> 8;
|
||||
p->y = (lv_obj_get_content_height(obj) * chart->zoom_y) >> 8;
|
||||
|
||||
@@ -82,7 +82,7 @@ void lv_checkbox_set_text(lv_obj_t * obj, const char * txt)
|
||||
|
||||
cb->static_txt = 0;
|
||||
|
||||
lv_obj_handle_self_size_chg(obj);
|
||||
lv_obj_refresh_self_size(obj);
|
||||
}
|
||||
|
||||
void lv_checkbox_set_text_static(lv_obj_t * obj, const char * txt)
|
||||
@@ -94,7 +94,7 @@ void lv_checkbox_set_text_static(lv_obj_t * obj, const char * txt)
|
||||
cb->txt = (char*)txt;
|
||||
cb->static_txt = 1;
|
||||
|
||||
lv_obj_handle_self_size_chg(obj);
|
||||
lv_obj_refresh_self_size(obj);
|
||||
}
|
||||
|
||||
/*=====================
|
||||
@@ -155,7 +155,7 @@ static void lv_checkbox_event(const lv_obj_class_t * class_p, lv_event_t * e)
|
||||
if (code == LV_EVENT_PRESSED || code == LV_EVENT_RELEASED) {
|
||||
lv_obj_invalidate(obj);
|
||||
}
|
||||
else if (code == LV_EVENT_GET_SELF_SIZE) {
|
||||
else if (code == LV_EVENT_REFR_SELF_SIZE) {
|
||||
lv_point_t * p = lv_event_get_param(e);
|
||||
lv_checkbox_t * cb = (lv_checkbox_t *)obj;
|
||||
|
||||
|
||||
@@ -658,10 +658,14 @@ static void lv_dropdown_event(const lv_obj_class_t * class_p, lv_event_t * e)
|
||||
lv_obj_invalidate(obj);
|
||||
}
|
||||
}
|
||||
else if(code == LV_EVENT_STYLE_CHANGED) {
|
||||
lv_obj_refresh_self_size(obj);
|
||||
}
|
||||
else if(code == LV_EVENT_SIZE_CHANGED) {
|
||||
lv_obj_refresh_self_size(obj);
|
||||
if(dropdown->list) lv_dropdown_close(obj);
|
||||
}
|
||||
else if(code == LV_EVENT_GET_SELF_SIZE) {
|
||||
else if(code == LV_EVENT_REFR_SELF_SIZE) {
|
||||
lv_point_t * p = lv_event_get_param(e);
|
||||
const lv_font_t * font = lv_obj_get_style_text_font(obj, LV_PART_MAIN);
|
||||
p->y = lv_font_get_line_height(font);
|
||||
|
||||
@@ -149,7 +149,7 @@ void lv_img_set_src(lv_obj_t * obj, const void * src)
|
||||
img->pivot.x = header.w / 2;
|
||||
img->pivot.y = header.h / 2;
|
||||
|
||||
lv_obj_handle_self_size_chg(obj);
|
||||
lv_obj_refresh_self_size(obj);
|
||||
|
||||
/*Provide enough room for the rotated corners*/
|
||||
if(img->angle || img->zoom != LV_IMG_ZOOM_NONE) lv_obj_refresh_ext_draw_size(obj);
|
||||
@@ -471,7 +471,7 @@ static void lv_img_event(const lv_obj_class_t * class_p, lv_event_t * e)
|
||||
info->result = _lv_area_is_point_on(&a, info->point, 0);
|
||||
}
|
||||
}
|
||||
else if(code == LV_EVENT_GET_SELF_SIZE) {
|
||||
else if(code == LV_EVENT_REFR_SELF_SIZE) {
|
||||
lv_point_t * p = lv_event_get_param(e);;
|
||||
p->x = img->w;
|
||||
p->y = img->h;
|
||||
|
||||
@@ -763,7 +763,7 @@ static void lv_label_event(const lv_obj_class_t * class_p, lv_event_t * e)
|
||||
lv_label_revert_dots(obj);
|
||||
lv_label_refr_text(obj);
|
||||
}
|
||||
else if(code == LV_EVENT_GET_SELF_SIZE) {
|
||||
else if(code == LV_EVENT_REFR_SELF_SIZE) {
|
||||
lv_point_t size;
|
||||
lv_label_t * label = (lv_label_t *)obj;
|
||||
const lv_font_t * font = lv_obj_get_style_text_font(obj, LV_PART_MAIN);
|
||||
@@ -905,7 +905,7 @@ static void lv_label_refr_text(lv_obj_t * obj)
|
||||
|
||||
lv_txt_get_size(&size, label->text, font, letter_space, line_space, max_w, flag);
|
||||
|
||||
lv_obj_handle_self_size_chg(obj);
|
||||
lv_obj_refresh_self_size(obj);
|
||||
|
||||
/*In scroll mode start an offset animations*/
|
||||
if(label->long_mode == LV_LABEL_LONG_SCROLL) {
|
||||
@@ -1079,7 +1079,7 @@ static void lv_label_refr_text(lv_obj_t * obj)
|
||||
}
|
||||
}
|
||||
else if(label->long_mode == LV_LABEL_LONG_DOT) {
|
||||
lv_obj_handle_self_size_chg(obj);
|
||||
lv_obj_refresh_self_size(obj);
|
||||
if(size.y <= lv_area_get_height(&txt_coords)) { /*No dots are required, the text is short enough*/
|
||||
label->dot_end = LV_LABEL_DOT_END_INV;
|
||||
}
|
||||
|
||||
@@ -69,7 +69,7 @@ void lv_line_set_points(lv_obj_t * obj, const lv_point_t points[], uint16_t poin
|
||||
line->point_array = points;
|
||||
line->point_num = point_num;
|
||||
|
||||
lv_obj_handle_self_size_chg(obj);
|
||||
lv_obj_refresh_self_size(obj);
|
||||
|
||||
lv_obj_invalidate(obj);
|
||||
}
|
||||
@@ -138,7 +138,7 @@ static void lv_line_event(const lv_obj_class_t * class_p, lv_event_t * e)
|
||||
lv_coord_t * s = lv_event_get_param(e);
|
||||
if(*s < line_width) *s = line_width;
|
||||
}
|
||||
else if(code == LV_EVENT_GET_SELF_SIZE) {
|
||||
else if(code == LV_EVENT_REFR_SELF_SIZE) {
|
||||
lv_line_t * line = (lv_line_t *)obj;
|
||||
|
||||
lv_point_t * p = lv_event_get_param(e);
|
||||
|
||||
+66
-91
@@ -33,7 +33,6 @@ static void lv_meter_event(const lv_obj_class_t * class_p, lv_event_t * e);
|
||||
static void draw_arcs(lv_obj_t * obj, const lv_area_t * clip_area, const lv_area_t * scale_area);
|
||||
static void draw_ticks_and_labels(lv_obj_t * obj, const lv_area_t * clip_area, const lv_area_t * scale_area);
|
||||
static void draw_needles(lv_obj_t * obj, const lv_area_t * clip_area, const lv_area_t * scale_area);
|
||||
static lv_meter_scale_t * get_scale_of_indic(lv_obj_t * obj, lv_meter_indicator_t * indic);
|
||||
static void inv_arc(lv_obj_t * obj, lv_meter_indicator_t * indic, int32_t old_value, int32_t new_value);
|
||||
static void inv_line(lv_obj_t * obj, lv_meter_indicator_t * indic, int32_t value);
|
||||
|
||||
@@ -74,7 +73,6 @@ lv_meter_scale_t * lv_meter_add_scale(lv_obj_t * obj)
|
||||
LV_ASSERT_MALLOC(scale);
|
||||
lv_memset_00(scale, sizeof(lv_meter_scale_t));
|
||||
|
||||
_lv_ll_init(&scale->indicator_ll, sizeof(lv_meter_indicator_t));
|
||||
scale->angle_range = 270;
|
||||
scale->rotation = 90 + (360 - scale->angle_range) / 2;
|
||||
scale->min = 0;
|
||||
@@ -121,9 +119,11 @@ void lv_meter_set_scale_range(lv_obj_t * obj, lv_meter_scale_t * scale, int32_t
|
||||
|
||||
lv_meter_indicator_t * lv_meter_add_needle_line(lv_obj_t * obj, lv_meter_scale_t * scale, uint16_t width, lv_color_t color, int16_t r_mod)
|
||||
{
|
||||
lv_meter_indicator_t * indic = _lv_ll_ins_head(&scale->indicator_ll);
|
||||
lv_meter_t * meter = (lv_meter_t *)obj;
|
||||
lv_meter_indicator_t * indic = _lv_ll_ins_head(&meter->indicator_ll);
|
||||
LV_ASSERT_MALLOC(indic);
|
||||
lv_memset_00(indic, sizeof(lv_meter_indicator_t));
|
||||
indic->scale = scale;
|
||||
indic->opa = LV_OPA_COVER;
|
||||
|
||||
indic->type = LV_METER_INDICATOR_TYPE_NEEDLE_LINE;
|
||||
@@ -137,9 +137,11 @@ lv_meter_indicator_t * lv_meter_add_needle_line(lv_obj_t * obj, lv_meter_scale_t
|
||||
|
||||
lv_meter_indicator_t * lv_meter_add_needle_img(lv_obj_t * obj, lv_meter_scale_t * scale, const void * src, lv_coord_t pivot_x, lv_coord_t pivot_y)
|
||||
{
|
||||
lv_meter_indicator_t * indic = _lv_ll_ins_head(&scale->indicator_ll);
|
||||
lv_meter_t * meter = (lv_meter_t *)obj;
|
||||
lv_meter_indicator_t * indic = _lv_ll_ins_head(&meter->indicator_ll);
|
||||
LV_ASSERT_MALLOC(indic);
|
||||
lv_memset_00(indic, sizeof(lv_meter_indicator_t));
|
||||
indic->scale = scale;
|
||||
indic->opa = LV_OPA_COVER;
|
||||
|
||||
indic->type = LV_METER_INDICATOR_TYPE_NEEDLE_IMG;
|
||||
@@ -153,9 +155,11 @@ lv_meter_indicator_t * lv_meter_add_needle_img(lv_obj_t * obj, lv_meter_scale_t
|
||||
|
||||
lv_meter_indicator_t * lv_meter_add_arc(lv_obj_t * obj, lv_meter_scale_t * scale, uint16_t width, lv_color_t color, int16_t r_mod)
|
||||
{
|
||||
lv_meter_indicator_t * indic = _lv_ll_ins_head(&scale->indicator_ll);
|
||||
lv_meter_t * meter = (lv_meter_t *)obj;
|
||||
lv_meter_indicator_t * indic = _lv_ll_ins_head(&meter->indicator_ll);
|
||||
LV_ASSERT_MALLOC(indic);
|
||||
lv_memset_00(indic, sizeof(lv_meter_indicator_t));
|
||||
indic->scale = scale;
|
||||
indic->opa = LV_OPA_COVER;
|
||||
|
||||
indic->type = LV_METER_INDICATOR_TYPE_ARC;
|
||||
@@ -169,9 +173,11 @@ lv_meter_indicator_t * lv_meter_add_arc(lv_obj_t * obj, lv_meter_scale_t * scale
|
||||
|
||||
lv_meter_indicator_t * lv_meter_add_scale_lines(lv_obj_t * obj, lv_meter_scale_t * scale, lv_color_t color_start, lv_color_t color_end, bool local, int16_t width_mod)
|
||||
{
|
||||
lv_meter_indicator_t * indic = _lv_ll_ins_head(&scale->indicator_ll);
|
||||
lv_meter_t * meter = (lv_meter_t *)obj;
|
||||
lv_meter_indicator_t * indic = _lv_ll_ins_head(&meter->indicator_ll);
|
||||
LV_ASSERT_MALLOC(indic);
|
||||
lv_memset_00(indic, sizeof(lv_meter_indicator_t));
|
||||
indic->scale = scale;
|
||||
indic->opa = LV_OPA_COVER;
|
||||
|
||||
indic->type = LV_METER_INDICATOR_TYPE_SCALE_LINES;
|
||||
@@ -254,6 +260,7 @@ static void lv_meter_constructor(const lv_obj_class_t * class_p, lv_obj_t * obj)
|
||||
lv_meter_t * meter = (lv_meter_t *)obj;
|
||||
|
||||
_lv_ll_init(&meter->scale_ll, sizeof(lv_meter_scale_t));
|
||||
_lv_ll_init(&meter->indicator_ll, sizeof(lv_meter_indicator_t));
|
||||
|
||||
LV_TRACE_OBJ_CREATE("finished");
|
||||
}
|
||||
@@ -262,19 +269,8 @@ static void lv_meter_destructor(const lv_obj_class_t * class_p, lv_obj_t * obj)
|
||||
{
|
||||
LV_UNUSED(class_p);
|
||||
lv_meter_t * meter = (lv_meter_t *)obj;
|
||||
lv_meter_scale_t * scale;
|
||||
scale = _lv_ll_get_head(&meter->scale_ll);
|
||||
while(scale) {
|
||||
lv_meter_indicator_t * indicator = _lv_ll_get_head(&scale->indicator_ll);
|
||||
while(indicator) {
|
||||
_lv_ll_remove(&scale->indicator_ll, indicator);
|
||||
lv_mem_free(indicator);
|
||||
indicator = _lv_ll_get_head(&scale->indicator_ll);
|
||||
}
|
||||
_lv_ll_remove(&meter->scale_ll, scale);
|
||||
lv_mem_free(scale);
|
||||
scale = _lv_ll_get_head(&meter->scale_ll);
|
||||
}
|
||||
_lv_ll_clear(&meter->indicator_ll);
|
||||
_lv_ll_clear(&meter->scale_ll);
|
||||
|
||||
}
|
||||
|
||||
@@ -328,21 +324,20 @@ static void draw_arcs(lv_obj_t * obj, const lv_area_t * clip_area, const lv_area
|
||||
scale_center.x = scale_area->x1 + r_out;
|
||||
scale_center.y = scale_area->y1 + r_out;
|
||||
|
||||
lv_meter_scale_t * scale;
|
||||
_LV_LL_READ_BACK(&meter->scale_ll, scale) {
|
||||
lv_opa_t opa_main = lv_obj_get_style_opa(obj, LV_PART_MAIN);
|
||||
lv_meter_indicator_t * indic;
|
||||
_LV_LL_READ_BACK(&scale->indicator_ll, indic) {
|
||||
if(indic->type != LV_METER_INDICATOR_TYPE_ARC) continue;
|
||||
lv_opa_t opa_main = lv_obj_get_style_opa(obj, LV_PART_MAIN);
|
||||
lv_meter_indicator_t * indic;
|
||||
_LV_LL_READ_BACK(&meter->indicator_ll, indic) {
|
||||
if(indic->type != LV_METER_INDICATOR_TYPE_ARC) continue;
|
||||
|
||||
arc_dsc.color = indic->type_data.arc.color;
|
||||
arc_dsc.width = indic->type_data.arc.width;
|
||||
arc_dsc.opa = indic->opa > LV_OPA_MAX ? opa_main : (opa_main * indic->opa) >> 8;
|
||||
arc_dsc.color = indic->type_data.arc.color;
|
||||
arc_dsc.width = indic->type_data.arc.width;
|
||||
arc_dsc.opa = indic->opa > LV_OPA_MAX ? opa_main : (opa_main * indic->opa) >> 8;
|
||||
|
||||
int32_t start_angle = lv_map(indic->start_value, scale->min, scale->max, scale->rotation, scale->rotation + scale->angle_range);
|
||||
int32_t end_angle = lv_map(indic->end_value, scale->min, scale->max, scale->rotation, scale->rotation + scale->angle_range);
|
||||
lv_draw_arc(scale_center.x, scale_center.y, r_out + indic->type_data.arc.r_mod, start_angle, end_angle, clip_area, &arc_dsc);
|
||||
}
|
||||
lv_meter_scale_t * scale = indic->scale;
|
||||
|
||||
int32_t start_angle = lv_map(indic->start_value, scale->min, scale->max, scale->rotation, scale->rotation + scale->angle_range);
|
||||
int32_t end_angle = lv_map(indic->end_value, scale->min, scale->max, scale->rotation, scale->rotation + scale->angle_range);
|
||||
lv_draw_arc(scale_center.x, scale_center.y, r_out + indic->type_data.arc.r_mod, start_angle, end_angle, clip_area, &arc_dsc);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -431,7 +426,7 @@ static void draw_ticks_and_labels(lv_obj_t * obj, const lv_area_t * clip_area, c
|
||||
lv_coord_t line_width = line_width_ori;
|
||||
|
||||
lv_meter_indicator_t * indic;
|
||||
_LV_LL_READ_BACK(&scale->indicator_ll, indic) {
|
||||
_LV_LL_READ_BACK(&meter->indicator_ll, indic) {
|
||||
if(indic->type != LV_METER_INDICATOR_TYPE_SCALE_LINES) continue;
|
||||
if(value_of_line >= indic->start_value && value_of_line <= indic->end_value) {
|
||||
line_width += indic->type_data.scale_lines.width_mod;
|
||||
@@ -542,8 +537,6 @@ static void draw_needles(lv_obj_t * obj, const lv_area_t * clip_area, const lv_a
|
||||
{
|
||||
lv_meter_t * meter = (lv_meter_t *)obj;
|
||||
|
||||
lv_meter_scale_t * scale;
|
||||
|
||||
lv_coord_t r_edge = lv_area_get_width(scale_area) / 2;
|
||||
lv_point_t scale_center;
|
||||
scale_center.x = scale_area->x1 + r_edge;
|
||||
@@ -556,64 +549,46 @@ static void draw_needles(lv_obj_t * obj, const lv_area_t * clip_area, const lv_a
|
||||
lv_draw_img_dsc_t img_dsc;
|
||||
lv_draw_img_dsc_init(&img_dsc);
|
||||
lv_obj_init_draw_img_dsc(obj, LV_PART_INDICATOR, &img_dsc);
|
||||
|
||||
img_dsc.antialias = 1;
|
||||
lv_opa_t opa_main = lv_obj_get_style_opa(obj, LV_PART_MAIN);
|
||||
|
||||
_LV_LL_READ_BACK(&meter->scale_ll, scale) {
|
||||
lv_meter_indicator_t * indic;
|
||||
_LV_LL_READ_BACK(&scale->indicator_ll, indic) {
|
||||
if(indic->type == LV_METER_INDICATOR_TYPE_NEEDLE_LINE) {
|
||||
int32_t angle = lv_map(indic->end_value, scale->min, scale->max, scale->rotation, scale->rotation + scale->angle_range);
|
||||
lv_coord_t r_out = r_edge + scale->r_mod + indic->type_data.needle_line.r_mod;
|
||||
lv_point_t p_end;
|
||||
p_end.y = (lv_trigo_sin(angle) * (r_out)) / LV_TRIGO_SIN_MAX + scale_center.y;
|
||||
p_end.x = (lv_trigo_cos(angle) * (r_out)) / LV_TRIGO_SIN_MAX + scale_center.x;
|
||||
line_dsc.color = indic->type_data.needle_line.color;
|
||||
line_dsc.width = indic->type_data.needle_line.width;
|
||||
line_dsc.opa = indic->opa > LV_OPA_MAX ? opa_main : (opa_main * indic->opa) >> 8;
|
||||
lv_draw_line(&scale_center, &p_end, clip_area, &line_dsc);
|
||||
}
|
||||
else if(indic->type == LV_METER_INDICATOR_TYPE_NEEDLE_IMG) {
|
||||
if(indic->type_data.needle_img.src == NULL) continue;
|
||||
lv_meter_indicator_t * indic;
|
||||
_LV_LL_READ_BACK(&meter->indicator_ll, indic) {
|
||||
lv_meter_scale_t * scale = indic->scale;
|
||||
if(indic->type == LV_METER_INDICATOR_TYPE_NEEDLE_LINE) {
|
||||
int32_t angle = lv_map(indic->end_value, scale->min, scale->max, scale->rotation, scale->rotation + scale->angle_range);
|
||||
lv_coord_t r_out = r_edge + scale->r_mod + indic->type_data.needle_line.r_mod;
|
||||
lv_point_t p_end;
|
||||
p_end.y = (lv_trigo_sin(angle) * (r_out)) / LV_TRIGO_SIN_MAX + scale_center.y;
|
||||
p_end.x = (lv_trigo_cos(angle) * (r_out)) / LV_TRIGO_SIN_MAX + scale_center.x;
|
||||
line_dsc.color = indic->type_data.needle_line.color;
|
||||
line_dsc.width = indic->type_data.needle_line.width;
|
||||
line_dsc.opa = indic->opa > LV_OPA_MAX ? opa_main : (opa_main * indic->opa) >> 8;
|
||||
lv_draw_line(&scale_center, &p_end, clip_area, &line_dsc);
|
||||
}
|
||||
else if(indic->type == LV_METER_INDICATOR_TYPE_NEEDLE_IMG) {
|
||||
if(indic->type_data.needle_img.src == NULL) continue;
|
||||
|
||||
int32_t angle = lv_map(indic->end_value, scale->min, scale->max, scale->rotation, scale->rotation + scale->angle_range);
|
||||
lv_img_header_t info;
|
||||
lv_img_decoder_get_info(indic->type_data.needle_img.src, &info);
|
||||
lv_area_t a;
|
||||
a.x1 = scale_center.x - indic->type_data.needle_img.pivot.x;
|
||||
a.y1 = scale_center.y - indic->type_data.needle_img.pivot.y;
|
||||
a.x2 = a.x1 + info.w - 1;
|
||||
a.y2 = a.y1 + info.h - 1;
|
||||
int32_t angle = lv_map(indic->end_value, scale->min, scale->max, scale->rotation, scale->rotation + scale->angle_range);
|
||||
lv_img_header_t info;
|
||||
lv_img_decoder_get_info(indic->type_data.needle_img.src, &info);
|
||||
lv_area_t a;
|
||||
a.x1 = scale_center.x - indic->type_data.needle_img.pivot.x;
|
||||
a.y1 = scale_center.y - indic->type_data.needle_img.pivot.y;
|
||||
a.x2 = a.x1 + info.w - 1;
|
||||
a.y2 = a.y1 + info.h - 1;
|
||||
|
||||
img_dsc.opa = indic->opa > LV_OPA_MAX ? opa_main : (opa_main * indic->opa) >> 8;
|
||||
img_dsc.pivot.x = indic->type_data.needle_img.pivot.x;
|
||||
img_dsc.pivot.y = indic->type_data.needle_img.pivot.y;
|
||||
angle = angle * 10;
|
||||
if(angle > 3600) angle -= 3600;
|
||||
img_dsc.angle = angle;
|
||||
lv_draw_img(&a, clip_area, indic->type_data.needle_img.src, &img_dsc);
|
||||
}
|
||||
img_dsc.opa = indic->opa > LV_OPA_MAX ? opa_main : (opa_main * indic->opa) >> 8;
|
||||
img_dsc.pivot.x = indic->type_data.needle_img.pivot.x;
|
||||
img_dsc.pivot.y = indic->type_data.needle_img.pivot.y;
|
||||
angle = angle * 10;
|
||||
if(angle > 3600) angle -= 3600;
|
||||
img_dsc.angle = angle;
|
||||
lv_draw_img(&a, clip_area, indic->type_data.needle_img.src, &img_dsc);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static lv_meter_scale_t * get_scale_of_indic(lv_obj_t * obj, lv_meter_indicator_t * indic)
|
||||
{
|
||||
lv_meter_t * meter = (lv_meter_t *)obj;
|
||||
|
||||
lv_meter_scale_t * scale;
|
||||
|
||||
_LV_LL_READ_BACK(&meter->scale_ll, scale) {
|
||||
lv_meter_indicator_t * ind;
|
||||
_LV_LL_READ_BACK(&scale->indicator_ll, ind) {
|
||||
if(ind == indic) return scale;
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
static void inv_arc(lv_obj_t * obj, lv_meter_indicator_t * indic, int32_t old_value, int32_t new_value)
|
||||
{
|
||||
bool rounded = lv_obj_get_style_arc_rounded(obj, LV_PART_ITEMS);
|
||||
@@ -628,7 +603,7 @@ static void inv_arc(lv_obj_t * obj, lv_meter_indicator_t * indic, int32_t old_va
|
||||
|
||||
r_out += indic->type_data.arc.r_mod;
|
||||
|
||||
lv_meter_scale_t * scale = get_scale_of_indic(obj, indic);
|
||||
lv_meter_scale_t * scale = indic->scale;
|
||||
|
||||
int32_t start_angle = lv_map(old_value, scale->min, scale->max, scale->rotation, scale->angle_range + scale->rotation);
|
||||
int32_t end_angle = lv_map(new_value, scale->min, scale->max, scale->rotation, scale->angle_range + scale->rotation);
|
||||
@@ -648,7 +623,7 @@ static void inv_line(lv_obj_t * obj, lv_meter_indicator_t * indic, int32_t value
|
||||
scale_center.x = scale_area.x1 + r_out;
|
||||
scale_center.y = scale_area.y1 + r_out;
|
||||
|
||||
lv_meter_scale_t * scale = get_scale_of_indic(obj, indic);
|
||||
lv_meter_scale_t * scale = indic->scale;
|
||||
|
||||
if(indic->type == LV_METER_INDICATOR_TYPE_NEEDLE_LINE) {
|
||||
int32_t angle = lv_map(value, scale->min, scale->max, scale->rotation, scale->rotation + scale->angle_range);
|
||||
@@ -675,10 +650,10 @@ static void inv_line(lv_obj_t * obj, lv_meter_indicator_t * indic, int32_t value
|
||||
|
||||
lv_area_t a;
|
||||
_lv_img_buf_get_transformed_area(&a, info.w, info.h, angle, LV_IMG_ZOOM_NONE, &indic->type_data.needle_img.pivot);
|
||||
a.x1 += scale_center.x;
|
||||
a.y1 += scale_center.y;
|
||||
a.x2 += scale_center.x;
|
||||
a.y2 += scale_center.y;
|
||||
a.x1 += scale_center.x - 2;
|
||||
a.y1 += scale_center.y - 2;
|
||||
a.x2 += scale_center.x + 2;
|
||||
a.y2 += scale_center.y + 2;
|
||||
|
||||
lv_obj_invalidate_area(obj, &a);
|
||||
}
|
||||
|
||||
+23
-22
@@ -27,6 +27,27 @@ extern "C" {
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
|
||||
typedef struct {
|
||||
lv_color_t tick_color;
|
||||
uint16_t tick_cnt;
|
||||
uint16_t tick_length;
|
||||
uint16_t tick_width;
|
||||
|
||||
lv_color_t tick_major_color;
|
||||
uint16_t tick_major_nth;
|
||||
uint16_t tick_major_length;
|
||||
uint16_t tick_major_width;
|
||||
|
||||
int16_t label_gap;
|
||||
int16_t label_color;
|
||||
|
||||
int32_t min;
|
||||
int32_t max;
|
||||
int16_t r_mod;
|
||||
uint16_t angle_range;
|
||||
int16_t rotation;
|
||||
}lv_meter_scale_t;
|
||||
|
||||
typedef enum {
|
||||
LV_METER_INDICATOR_TYPE_NEEDLE_IMG,
|
||||
LV_METER_INDICATOR_TYPE_NEEDLE_LINE,
|
||||
@@ -35,6 +56,7 @@ typedef enum {
|
||||
}lv_meter_indicator_type_t;
|
||||
|
||||
typedef struct {
|
||||
lv_meter_scale_t * scale;
|
||||
lv_meter_indicator_type_t type;
|
||||
lv_opa_t opa;
|
||||
int32_t start_value;
|
||||
@@ -64,33 +86,12 @@ typedef struct {
|
||||
} type_data;
|
||||
}lv_meter_indicator_t;
|
||||
|
||||
typedef struct {
|
||||
lv_ll_t indicator_ll;
|
||||
|
||||
lv_color_t tick_color;
|
||||
uint16_t tick_cnt;
|
||||
uint16_t tick_length;
|
||||
uint16_t tick_width;
|
||||
|
||||
lv_color_t tick_major_color;
|
||||
uint16_t tick_major_nth;
|
||||
uint16_t tick_major_length;
|
||||
uint16_t tick_major_width;
|
||||
|
||||
int16_t label_gap;
|
||||
int16_t label_color;
|
||||
|
||||
int32_t min;
|
||||
int32_t max;
|
||||
int16_t r_mod;
|
||||
uint16_t angle_range;
|
||||
int16_t rotation;
|
||||
}lv_meter_scale_t;
|
||||
|
||||
/*Data of line meter*/
|
||||
typedef struct {
|
||||
lv_obj_t obj;
|
||||
lv_ll_t scale_ll;
|
||||
lv_ll_t indicator_ll;
|
||||
} lv_meter_t;
|
||||
|
||||
extern const lv_obj_class_t lv_meter_class;
|
||||
|
||||
@@ -317,7 +317,7 @@ static void lv_roller_event(const lv_obj_class_t * class_p, lv_event_t * e)
|
||||
lv_obj_t * obj = lv_event_get_target(e);
|
||||
lv_roller_t * roller = (lv_roller_t*)obj;
|
||||
|
||||
if(code == LV_EVENT_GET_SELF_SIZE) {
|
||||
if(code == LV_EVENT_REFR_SELF_SIZE) {
|
||||
lv_point_t * p = lv_event_get_param(e);
|
||||
p->x = get_selected_label_width(obj);
|
||||
}
|
||||
@@ -325,7 +325,7 @@ static void lv_roller_event(const lv_obj_class_t * class_p, lv_event_t * e)
|
||||
lv_obj_t * label = get_label(obj);
|
||||
/*Be sure the label's style is updated before processing the roller*/
|
||||
if(label) lv_event_send(label, LV_EVENT_STYLE_CHANGED, NULL);
|
||||
lv_obj_handle_self_size_chg(obj);
|
||||
lv_obj_refresh_self_size(obj);
|
||||
refr_position(obj, false);
|
||||
}
|
||||
else if(code == LV_EVENT_SIZE_CHANGED) {
|
||||
|
||||
@@ -43,8 +43,8 @@ static void draw_main(lv_event_t * e);
|
||||
const lv_obj_class_t lv_switch_class = {
|
||||
.constructor_cb = lv_switch_constructor,
|
||||
.event_cb = lv_switch_event,
|
||||
.width_def = (5 * LV_DPI_DEF) / 11,
|
||||
.height_def = LV_DPI_DEF / 4,
|
||||
.width_def = (4 * LV_DPI_DEF) / 10,
|
||||
.height_def = (4 * LV_DPI_DEF) / 17,
|
||||
.group_def = LV_OBJ_CLASS_GROUP_DEF_TRUE,
|
||||
.instance_size = sizeof(lv_switch_t),
|
||||
.base_class = &lv_obj_class
|
||||
|
||||
@@ -476,7 +476,7 @@ static void lv_table_event(const lv_obj_class_t * class_p, lv_event_t * e)
|
||||
if(code == LV_EVENT_STYLE_CHANGED) {
|
||||
refr_size(obj, 0);
|
||||
}
|
||||
else if(code == LV_EVENT_GET_SELF_SIZE) {
|
||||
else if(code == LV_EVENT_REFR_SELF_SIZE) {
|
||||
lv_point_t * p = lv_event_get_param(e);
|
||||
uint32_t i;
|
||||
lv_coord_t w = 0;
|
||||
@@ -779,7 +779,7 @@ static void refr_size(lv_obj_t * obj, uint32_t strat_row)
|
||||
table->row_h[i] = LV_CLAMP(minh, table->row_h[i], maxh);
|
||||
}
|
||||
|
||||
lv_obj_handle_self_size_chg(obj) ;
|
||||
lv_obj_refresh_self_size(obj) ;
|
||||
}
|
||||
|
||||
static lv_coord_t get_row_height(lv_obj_t * obj, uint16_t row_id, const lv_font_t * font,
|
||||
|
||||
Reference in New Issue
Block a user