mirror of
https://github.com/lvgl/lvgl.git
synced 2025-01-14 06:42:58 +08:00
fix(disp) change lv_dpx_disp and lv_dpx_obj to lv_disp_dpx and lv_obj_dpx forr Micropython compatibility
This commit is contained in:
parent
94a47dc6d9
commit
796ca68f2a
@ -242,7 +242,7 @@ static inline lv_coord_t lv_dpx(lv_coord_t n)
|
||||
* @param n the number of pixels to scale
|
||||
* @return `n x current_dpi/160`
|
||||
*/
|
||||
static inline lv_coord_t lv_dpx_disp(const lv_disp_t * disp, lv_coord_t n)
|
||||
static inline lv_coord_t lv_disp_dpx(const lv_disp_t * disp, lv_coord_t n)
|
||||
{
|
||||
return _LV_DPX_CALC(lv_disp_get_dpi(disp), n);
|
||||
}
|
||||
|
@ -360,6 +360,20 @@ const lv_obj_class_t * lv_obj_get_class(const lv_obj_t * obj);
|
||||
*/
|
||||
bool lv_obj_is_valid(const lv_obj_t * obj);
|
||||
|
||||
/**
|
||||
* Scale the given number of pixels (a distance or size) relative to a 160 DPI display
|
||||
* considering the DPI of the `obj`'s display.
|
||||
* It ensures that e.g. `lv_dpx(100)` will have the same physical size regardless to the
|
||||
* DPI of the display.
|
||||
* @param obj an object whose display's dpi should be considered
|
||||
* @param n the number of pixels to scale
|
||||
* @return `n x current_dpi/160`
|
||||
*/
|
||||
static inline lv_coord_t lv_dpx_obj(const lv_obj_t * obj, lv_coord_t n)
|
||||
{
|
||||
return _LV_DPX_CALC(lv_disp_get_dpi(lv_obj_get_disp(obj)), n);
|
||||
}
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
@ -17,7 +17,7 @@
|
||||
* DEFINES
|
||||
*********************/
|
||||
#define MODE_DARK 1
|
||||
#define RADIUS_DEFAULT (disp_size == DISP_LARGE ? lv_dpx_disp(theme.disp, 12) : lv_dpx_disp(theme.disp, 8))
|
||||
#define RADIUS_DEFAULT (disp_size == DISP_LARGE ? lv_disp_dpx(theme.disp, 12) : lv_disp_dpx(theme.disp, 8))
|
||||
|
||||
/*SCREEN*/
|
||||
#define LIGHT_COLOR_SCR lv_palette_lighten(LV_PALETTE_GREY, 4)
|
||||
@ -30,12 +30,12 @@
|
||||
#define DARK_COLOR_GREY lv_color_hex(0x2f3237)
|
||||
|
||||
#define TRANSITION_TIME LV_THEME_DEFAULT_TRANSITON_TIME
|
||||
#define BORDER_WIDTH lv_dpx_disp(theme.disp, 2)
|
||||
#define OUTLINE_WIDTH lv_dpx_disp(theme.disp, 3)
|
||||
#define BORDER_WIDTH lv_disp_dpx(theme.disp, 2)
|
||||
#define OUTLINE_WIDTH lv_disp_dpx(theme.disp, 3)
|
||||
|
||||
#define PAD_DEF (disp_size == DISP_LARGE ? lv_dpx_disp(theme.disp, 24) : disp_size == DISP_MEDIUM ? lv_dpx_disp(theme.disp, 20) : lv_dpx_disp(theme.disp, 16))
|
||||
#define PAD_SMALL (disp_size == DISP_LARGE ? lv_dpx_disp(theme.disp, 14) : disp_size == DISP_MEDIUM ? lv_dpx_disp(theme.disp, 12) : lv_dpx_disp(theme.disp, 10))
|
||||
#define PAD_TINY (disp_size == DISP_LARGE ? lv_dpx_disp(theme.disp, 8) : disp_size == DISP_MEDIUM ? lv_dpx_disp(theme.disp, 6) : lv_dpx_disp(theme.disp, 2))
|
||||
#define PAD_DEF (disp_size == DISP_LARGE ? lv_disp_dpx(theme.disp, 24) : disp_size == DISP_MEDIUM ? lv_disp_dpx(theme.disp, 20) : lv_disp_dpx(theme.disp, 16))
|
||||
#define PAD_SMALL (disp_size == DISP_LARGE ? lv_disp_dpx(theme.disp, 14) : disp_size == DISP_MEDIUM ? lv_disp_dpx(theme.disp, 12) : lv_disp_dpx(theme.disp, 10))
|
||||
#define PAD_TINY (disp_size == DISP_LARGE ? lv_disp_dpx(theme.disp, 8) : disp_size == DISP_MEDIUM ? lv_disp_dpx(theme.disp, 6) : lv_disp_dpx(theme.disp, 2))
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
@ -227,9 +227,9 @@ static void style_init(void)
|
||||
style_init_reset(&styles->scrollbar);
|
||||
lv_style_set_bg_color(&styles->scrollbar, (theme.flags & MODE_DARK) ? lv_palette_darken(LV_PALETTE_GREY, 2) : lv_palette_main(LV_PALETTE_GREY));
|
||||
lv_style_set_radius(&styles->scrollbar, LV_RADIUS_CIRCLE);
|
||||
lv_style_set_pad_right(&styles->scrollbar, lv_dpx_disp(theme.disp, 7));
|
||||
lv_style_set_pad_top(&styles->scrollbar, lv_dpx_disp(theme.disp, 7));
|
||||
lv_style_set_size(&styles->scrollbar, lv_dpx_disp(theme.disp, 5));
|
||||
lv_style_set_pad_right(&styles->scrollbar, lv_disp_dpx(theme.disp, 7));
|
||||
lv_style_set_pad_top(&styles->scrollbar, lv_disp_dpx(theme.disp, 7));
|
||||
lv_style_set_size(&styles->scrollbar, lv_disp_dpx(theme.disp, 5));
|
||||
lv_style_set_bg_opa(&styles->scrollbar, LV_OPA_40);
|
||||
lv_style_set_transition(&styles->scrollbar, &trans_normal);
|
||||
|
||||
@ -255,7 +255,7 @@ static void style_init(void)
|
||||
lv_style_set_pad_row(&styles->card, PAD_SMALL);
|
||||
lv_style_set_pad_column(&styles->card, PAD_SMALL);
|
||||
lv_style_set_line_color(&styles->card, lv_palette_main(LV_PALETTE_GREY));
|
||||
lv_style_set_line_width(&styles->card, lv_dpx_disp(theme.disp, 1));
|
||||
lv_style_set_line_width(&styles->card, lv_disp_dpx(theme.disp, 1));
|
||||
|
||||
style_init_reset(&styles->outline_primary);
|
||||
lv_style_set_outline_color(&styles->outline_primary, theme.color_primary);
|
||||
@ -269,19 +269,19 @@ static void style_init(void)
|
||||
lv_style_set_outline_opa(&styles->outline_secondary, LV_OPA_50);
|
||||
|
||||
style_init_reset(&styles->btn);
|
||||
lv_style_set_radius(&styles->btn, (disp_size == DISP_LARGE ? lv_dpx_disp(theme.disp, 16) : disp_size == DISP_MEDIUM ? lv_dpx_disp(theme.disp, 12) : lv_dpx_disp(theme.disp, 8)));
|
||||
lv_style_set_radius(&styles->btn, (disp_size == DISP_LARGE ? lv_disp_dpx(theme.disp, 16) : disp_size == DISP_MEDIUM ? lv_disp_dpx(theme.disp, 12) : lv_disp_dpx(theme.disp, 8)));
|
||||
lv_style_set_bg_opa(&styles->btn, LV_OPA_COVER);
|
||||
lv_style_set_bg_color(&styles->btn, color_grey);
|
||||
if(!(theme.flags & MODE_DARK)) {
|
||||
lv_style_set_shadow_color(&styles->btn, lv_palette_lighten(LV_PALETTE_GREY, 3));
|
||||
lv_style_set_shadow_width(&styles->btn, 1);
|
||||
lv_style_set_shadow_ofs_y(&styles->btn, lv_dpx_disp(theme.disp, 4));
|
||||
lv_style_set_shadow_ofs_y(&styles->btn, lv_disp_dpx(theme.disp, 4));
|
||||
}
|
||||
lv_style_set_text_color(&styles->btn, color_text);
|
||||
lv_style_set_pad_hor(&styles->btn, PAD_DEF);
|
||||
lv_style_set_pad_ver(&styles->btn, PAD_SMALL);
|
||||
lv_style_set_pad_column(&styles->btn, lv_dpx_disp(theme.disp, 5));
|
||||
lv_style_set_pad_row(&styles->btn, lv_dpx_disp(theme.disp, 5));
|
||||
lv_style_set_pad_column(&styles->btn, lv_disp_dpx(theme.disp, 5));
|
||||
lv_style_set_pad_row(&styles->btn, lv_disp_dpx(theme.disp, 5));
|
||||
|
||||
static lv_color_filter_dsc_t dark_filter;
|
||||
lv_color_filter_dsc_init(&dark_filter, dark_color_filter_cb);
|
||||
@ -310,11 +310,11 @@ static void style_init(void)
|
||||
lv_style_set_pad_gap(&styles->pad_small, PAD_SMALL);
|
||||
|
||||
style_init_reset(&styles->pad_gap);
|
||||
lv_style_set_pad_row(&styles->pad_gap, lv_dpx_disp(theme.disp, 10));
|
||||
lv_style_set_pad_column(&styles->pad_gap, lv_dpx_disp(theme.disp, 10));
|
||||
lv_style_set_pad_row(&styles->pad_gap, lv_disp_dpx(theme.disp, 10));
|
||||
lv_style_set_pad_column(&styles->pad_gap, lv_disp_dpx(theme.disp, 10));
|
||||
|
||||
style_init_reset(&styles->line_space_large);
|
||||
lv_style_set_text_line_space(&styles->line_space_large, lv_dpx_disp(theme.disp, 20));
|
||||
lv_style_set_text_line_space(&styles->line_space_large, lv_disp_dpx(theme.disp, 20));
|
||||
|
||||
style_init_reset(&styles->text_align_center);
|
||||
lv_style_set_text_align(&styles->text_align_center, LV_TEXT_ALIGN_CENTER);
|
||||
@ -367,14 +367,14 @@ static void style_init(void)
|
||||
|
||||
#if LV_THEME_DEFAULT_GROW
|
||||
style_init_reset(&styles->grow);
|
||||
lv_style_set_transform_width(&styles->grow, lv_dpx_disp(theme.disp, 3));
|
||||
lv_style_set_transform_height(&styles->grow, lv_dpx_disp(theme.disp, 3));
|
||||
lv_style_set_transform_width(&styles->grow, lv_disp_dpx(theme.disp, 3));
|
||||
lv_style_set_transform_height(&styles->grow, lv_disp_dpx(theme.disp, 3));
|
||||
#endif
|
||||
|
||||
style_init_reset(&styles->knob);
|
||||
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_disp(theme.disp, 6));
|
||||
lv_style_set_pad_all(&styles->knob, lv_disp_dpx(theme.disp, 6));
|
||||
lv_style_set_radius(&styles->knob, LV_RADIUS_CIRCLE);
|
||||
|
||||
style_init_reset(&styles->anim);
|
||||
@ -383,7 +383,7 @@ static void style_init(void)
|
||||
#if LV_USE_ARC
|
||||
style_init_reset(&styles->arc_indic);
|
||||
lv_style_set_arc_color(&styles->arc_indic, color_grey);
|
||||
lv_style_set_arc_width(&styles->arc_indic, lv_dpx_disp(theme.disp, 15));
|
||||
lv_style_set_arc_width(&styles->arc_indic, lv_disp_dpx(theme.disp, 15));
|
||||
lv_style_set_arc_rounded(&styles->arc_indic, true);
|
||||
|
||||
style_init_reset(&styles->arc_indic_primary);
|
||||
@ -396,7 +396,7 @@ static void style_init(void)
|
||||
#endif
|
||||
#if LV_USE_CHECKBOX
|
||||
style_init_reset(&styles->cb_marker);
|
||||
lv_style_set_pad_all(&styles->cb_marker, lv_dpx_disp(theme.disp, 3));
|
||||
lv_style_set_pad_all(&styles->cb_marker, lv_disp_dpx(theme.disp, 3));
|
||||
lv_style_set_border_width(&styles->cb_marker, BORDER_WIDTH);
|
||||
lv_style_set_border_color(&styles->cb_marker, theme.color_primary);
|
||||
lv_style_set_bg_color(&styles->cb_marker, color_card);
|
||||
@ -411,7 +411,7 @@ static void style_init(void)
|
||||
|
||||
#if LV_USE_SWITCH
|
||||
style_init_reset(&styles->switch_knob);
|
||||
lv_style_set_pad_all(&styles->switch_knob, - lv_dpx_disp(theme.disp, 4));
|
||||
lv_style_set_pad_all(&styles->switch_knob, - lv_disp_dpx(theme.disp, 4));
|
||||
lv_style_set_bg_color(&styles->switch_knob, lv_color_white());
|
||||
#endif
|
||||
|
||||
@ -424,45 +424,45 @@ static void style_init(void)
|
||||
#if LV_USE_CHART
|
||||
style_init_reset(&styles->chart_bg);
|
||||
lv_style_set_border_post(&styles->chart_bg, false);
|
||||
lv_style_set_pad_column(&styles->chart_bg, lv_dpx_disp(theme.disp, 10));
|
||||
lv_style_set_pad_column(&styles->chart_bg, lv_disp_dpx(theme.disp, 10));
|
||||
lv_style_set_line_color(&styles->chart_bg, color_grey);
|
||||
|
||||
style_init_reset(&styles->chart_series);
|
||||
lv_style_set_line_width(&styles->chart_series, lv_dpx_disp(theme.disp, 3));
|
||||
lv_style_set_radius(&styles->chart_series, lv_dpx_disp(theme.disp, 3));
|
||||
lv_style_set_size(&styles->chart_series, lv_dpx_disp(theme.disp, 8));
|
||||
lv_style_set_pad_column(&styles->chart_series, lv_dpx_disp(theme.disp, 2));
|
||||
lv_style_set_line_width(&styles->chart_series, lv_disp_dpx(theme.disp, 3));
|
||||
lv_style_set_radius(&styles->chart_series, lv_disp_dpx(theme.disp, 3));
|
||||
lv_style_set_size(&styles->chart_series, lv_disp_dpx(theme.disp, 8));
|
||||
lv_style_set_pad_column(&styles->chart_series, lv_disp_dpx(theme.disp, 2));
|
||||
|
||||
style_init_reset(&styles->chart_indic);
|
||||
lv_style_set_radius(&styles->chart_indic,LV_RADIUS_CIRCLE);
|
||||
lv_style_set_size(&styles->chart_indic, lv_dpx_disp(theme.disp, 8));
|
||||
lv_style_set_size(&styles->chart_indic, lv_disp_dpx(theme.disp, 8));
|
||||
lv_style_set_bg_color(&styles->chart_indic, theme.color_primary);
|
||||
lv_style_set_bg_opa(&styles->chart_indic, LV_OPA_COVER);
|
||||
|
||||
style_init_reset(&styles->chart_ticks);
|
||||
lv_style_set_line_width(&styles->chart_ticks, lv_dpx_disp(theme.disp, 1));
|
||||
lv_style_set_line_width(&styles->chart_ticks, lv_disp_dpx(theme.disp, 1));
|
||||
lv_style_set_line_color(&styles->chart_ticks, color_text);
|
||||
lv_style_set_pad_all(&styles->chart_ticks, lv_dpx_disp(theme.disp, 2));
|
||||
lv_style_set_pad_all(&styles->chart_ticks, lv_disp_dpx(theme.disp, 2));
|
||||
lv_style_set_text_color(&styles->chart_ticks, lv_palette_main(LV_PALETTE_GREY));
|
||||
#endif
|
||||
|
||||
#if LV_USE_METER
|
||||
style_init_reset(&styles->meter_marker);
|
||||
lv_style_set_line_width(&styles->meter_marker, lv_dpx_disp(theme.disp, 5));
|
||||
lv_style_set_line_width(&styles->meter_marker, lv_disp_dpx(theme.disp, 5));
|
||||
lv_style_set_line_color(&styles->meter_marker, color_text);
|
||||
lv_style_set_size(&styles->meter_marker, lv_dpx_disp(theme.disp, 20));
|
||||
lv_style_set_pad_left(&styles->meter_marker, lv_dpx_disp(theme.disp, 15));
|
||||
lv_style_set_size(&styles->meter_marker, lv_disp_dpx(theme.disp, 20));
|
||||
lv_style_set_pad_left(&styles->meter_marker, lv_disp_dpx(theme.disp, 15));
|
||||
|
||||
style_init_reset(&styles->meter_indic);
|
||||
lv_style_set_radius(&styles->meter_indic, LV_RADIUS_CIRCLE);
|
||||
lv_style_set_bg_color(&styles->meter_indic, color_text);
|
||||
lv_style_set_bg_opa(&styles->meter_indic, LV_OPA_COVER);
|
||||
lv_style_set_size(&styles->meter_indic, lv_dpx_disp(theme.disp, 15));
|
||||
lv_style_set_size(&styles->meter_indic, lv_disp_dpx(theme.disp, 15));
|
||||
#endif
|
||||
|
||||
#if LV_USE_TABLE
|
||||
style_init_reset(&styles->table_cell);
|
||||
lv_style_set_border_width(&styles->table_cell, lv_dpx_disp(theme.disp, 1));
|
||||
lv_style_set_border_width(&styles->table_cell, lv_disp_dpx(theme.disp, 1));
|
||||
lv_style_set_border_color(&styles->table_cell, color_grey);
|
||||
lv_style_set_border_side(&styles->table_cell, LV_BORDER_SIDE_TOP | LV_BORDER_SIDE_BOTTOM );
|
||||
#endif
|
||||
@ -470,8 +470,8 @@ static void style_init(void)
|
||||
#if LV_USE_TEXTAREA
|
||||
style_init_reset(&styles->ta_cursor);
|
||||
lv_style_set_border_color(&styles->ta_cursor, color_text);
|
||||
lv_style_set_border_width(&styles->ta_cursor, lv_dpx_disp(theme.disp, 2));
|
||||
lv_style_set_pad_left(&styles->ta_cursor, lv_dpx_disp(theme.disp, 1));
|
||||
lv_style_set_border_width(&styles->ta_cursor, lv_disp_dpx(theme.disp, 2));
|
||||
lv_style_set_pad_left(&styles->ta_cursor, lv_disp_dpx(theme.disp, 1));
|
||||
lv_style_set_border_side(&styles->ta_cursor, LV_BORDER_SIDE_LEFT);
|
||||
lv_style_set_anim_time(&styles->ta_cursor, 400);
|
||||
|
||||
@ -486,7 +486,7 @@ static void style_init(void)
|
||||
lv_style_set_radius(&styles->calendar_bg, 0);
|
||||
|
||||
style_init_reset(&styles->calendar_day);
|
||||
lv_style_set_border_width(&styles->calendar_day, lv_dpx_disp(theme.disp, 1));
|
||||
lv_style_set_border_width(&styles->calendar_day, lv_disp_dpx(theme.disp, 1));
|
||||
lv_style_set_border_color(&styles->calendar_day, color_grey);
|
||||
lv_style_set_bg_color(&styles->calendar_day, color_card);
|
||||
lv_style_set_bg_opa(&styles->calendar_day, LV_OPA_20);
|
||||
@ -494,13 +494,13 @@ static void style_init(void)
|
||||
|
||||
#if LV_USE_COLORWHEEL
|
||||
style_init_reset(&styles->colorwheel_main);
|
||||
lv_style_set_arc_width(&styles->colorwheel_main, lv_dpx_disp(theme.disp, 10));
|
||||
lv_style_set_arc_width(&styles->colorwheel_main, lv_disp_dpx(theme.disp, 10));
|
||||
#endif
|
||||
|
||||
#if LV_USE_MSGBOX
|
||||
/*To add space for for the button shadow*/
|
||||
style_init_reset(&styles->msgbox_btn_bg);
|
||||
lv_style_set_pad_all(&styles->msgbox_btn_bg, lv_dpx_disp(theme.disp, 4));
|
||||
lv_style_set_pad_all(&styles->msgbox_btn_bg, lv_disp_dpx(theme.disp, 4));
|
||||
|
||||
style_init_reset(&styles->msgbox_bg);
|
||||
lv_style_set_max_width(&styles->msgbox_bg, lv_pct(100));
|
||||
@ -529,7 +529,7 @@ static void style_init(void)
|
||||
lv_style_set_clip_corner(&styles->list_bg, true);
|
||||
|
||||
style_init_reset(&styles->list_btn);
|
||||
lv_style_set_border_width(&styles->list_btn, lv_dpx_disp(theme.disp, 1));
|
||||
lv_style_set_border_width(&styles->list_btn, lv_disp_dpx(theme.disp, 1));
|
||||
lv_style_set_border_color(&styles->list_btn, color_grey);
|
||||
lv_style_set_border_side(&styles->list_btn, LV_BORDER_SIDE_BOTTOM);
|
||||
lv_style_set_pad_all(&styles->list_btn, PAD_SMALL);
|
||||
@ -548,9 +548,9 @@ static void style_init(void)
|
||||
lv_style_set_bg_color(&styles->led, lv_color_white());
|
||||
lv_style_set_bg_grad_color(&styles->led, lv_palette_main(LV_PALETTE_GREY));
|
||||
lv_style_set_radius(&styles->led, LV_RADIUS_CIRCLE);
|
||||
lv_style_set_shadow_width(&styles->led, lv_dpx_disp(theme.disp, 15));
|
||||
lv_style_set_shadow_width(&styles->led, lv_disp_dpx(theme.disp, 15));
|
||||
lv_style_set_shadow_color(&styles->led, lv_color_white());
|
||||
lv_style_set_shadow_spread(&styles->led, lv_dpx_disp(theme.disp, 5));
|
||||
lv_style_set_shadow_spread(&styles->led, lv_disp_dpx(theme.disp, 5));
|
||||
#endif
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user