feat(scale): add additional style properties (#6649)
Co-authored-by: Gabor Kiss-Vamosi <kisvegabor@gmail.com>
This commit is contained in:
@@ -123,6 +123,8 @@ void lv_example_scale_4(void);
|
||||
void lv_example_scale_5(void);
|
||||
void lv_example_scale_6(void);
|
||||
void lv_example_scale_7(void);
|
||||
void lv_example_scale_8(void);
|
||||
void lv_example_scale_9(void);
|
||||
|
||||
void lv_example_slider_1(void);
|
||||
void lv_example_slider_2(void);
|
||||
|
||||
@@ -22,8 +22,8 @@ A round scale with section and custom styling
|
||||
.. lv_example:: widgets/scale/lv_example_scale_4
|
||||
:language: c
|
||||
|
||||
An scale with section and custom styling
|
||||
----------------------------------------
|
||||
A scale with section and custom styling
|
||||
"""""""""""""""""""""""""""""""""""""""
|
||||
|
||||
.. lv_example:: widgets/scale/lv_example_scale_5
|
||||
:language: c
|
||||
@@ -40,3 +40,14 @@ Customizing scale major tick label color with `LV_EVENT_DRAW_TASK_ADDED` event
|
||||
.. lv_example:: widgets/scale/lv_example_scale_7
|
||||
:language: c
|
||||
|
||||
A round scale with labels rotated and translated
|
||||
""""""""""""""""""""""""""""""""""""""""""""""""
|
||||
|
||||
.. lv_example:: widgets/scale/lv_example_scale_8
|
||||
:language: c
|
||||
|
||||
A horizontal scale with labels rotated and translated
|
||||
"""""""""""""""""""""""""""""""""""""""""""""""""""""
|
||||
|
||||
.. lv_example:: widgets/scale/lv_example_scale_9
|
||||
:language: c
|
||||
|
||||
47
examples/widgets/scale/lv_example_scale_8.c
Normal file
47
examples/widgets/scale/lv_example_scale_8.c
Normal file
@@ -0,0 +1,47 @@
|
||||
#include "../../lv_examples.h"
|
||||
#if LV_USE_SCALE && LV_BUILD_EXAMPLES
|
||||
|
||||
|
||||
/**
|
||||
* A simple round scale with label/tick translation
|
||||
*/
|
||||
void lv_example_scale_8(void)
|
||||
{
|
||||
lv_obj_t * scale_line = lv_scale_create(lv_screen_active());
|
||||
lv_obj_set_size(scale_line, 150, 150);
|
||||
lv_scale_set_mode(scale_line, LV_SCALE_MODE_ROUND_INNER);
|
||||
lv_obj_set_style_bg_opa(scale_line, LV_OPA_COVER, 0);
|
||||
lv_obj_set_style_bg_color(scale_line, lv_palette_lighten(LV_PALETTE_RED, 5), 0);
|
||||
lv_obj_set_style_radius(scale_line, LV_RADIUS_CIRCLE, 0);
|
||||
lv_obj_align(scale_line, LV_ALIGN_LEFT_MID, LV_PCT(2), 0);
|
||||
|
||||
/*Set the texts' and major ticks' style (make the texts rotated)*/
|
||||
lv_obj_set_style_transform_rotation(scale_line, LV_SCALE_LABEL_ROTATE_MATCH_TICKS | LV_SCALE_LABEL_ROTATE_KEEP_UPRIGHT,
|
||||
LV_PART_INDICATOR);
|
||||
lv_obj_set_style_translate_x(scale_line, 10, LV_PART_INDICATOR);
|
||||
lv_obj_set_style_length(scale_line, 15, LV_PART_INDICATOR);
|
||||
lv_obj_set_style_radial_offset(scale_line, 10, LV_PART_INDICATOR);
|
||||
|
||||
/*Set the style of the minor ticks*/
|
||||
lv_obj_set_style_length(scale_line, 10, LV_PART_ITEMS);
|
||||
lv_obj_set_style_radial_offset(scale_line, 5, LV_PART_ITEMS);
|
||||
lv_obj_set_style_line_opa(scale_line, LV_OPA_50, LV_PART_ITEMS);
|
||||
|
||||
lv_scale_set_label_show(scale_line, true);
|
||||
|
||||
lv_scale_set_total_tick_count(scale_line, 31);
|
||||
lv_scale_set_major_tick_every(scale_line, 5);
|
||||
|
||||
lv_scale_set_range(scale_line, 10, 40);
|
||||
|
||||
lv_scale_set_angle_range(scale_line, 270);
|
||||
lv_scale_set_rotation(scale_line, 135);
|
||||
|
||||
lv_obj_t * needle_line = lv_line_create(scale_line);
|
||||
|
||||
lv_obj_set_style_line_width(needle_line, 3, LV_PART_MAIN);
|
||||
lv_obj_set_style_line_rounded(needle_line, true, LV_PART_MAIN);
|
||||
lv_scale_set_line_needle_value(scale_line, needle_line, 60, 33);
|
||||
}
|
||||
|
||||
#endif
|
||||
27
examples/widgets/scale/lv_example_scale_9.c
Normal file
27
examples/widgets/scale/lv_example_scale_9.c
Normal file
@@ -0,0 +1,27 @@
|
||||
#include "../../lv_examples.h"
|
||||
#if LV_USE_SCALE && LV_BUILD_EXAMPLES
|
||||
|
||||
/**
|
||||
* A simple horizontal scale with transforms
|
||||
*/
|
||||
void lv_example_scale_9(void)
|
||||
{
|
||||
lv_obj_t * scale = lv_scale_create(lv_screen_active());
|
||||
lv_obj_set_size(scale, 200, 100);
|
||||
lv_scale_set_mode(scale, LV_SCALE_MODE_HORIZONTAL_BOTTOM);
|
||||
lv_obj_center(scale);
|
||||
|
||||
lv_scale_set_label_show(scale, true);
|
||||
lv_obj_set_style_transform_rotation(scale, 450, LV_PART_INDICATOR);
|
||||
lv_obj_set_style_length(scale, 30, LV_PART_INDICATOR);
|
||||
lv_obj_set_style_translate_x(scale, 5, LV_PART_INDICATOR);
|
||||
|
||||
lv_scale_set_total_tick_count(scale, 31);
|
||||
lv_scale_set_major_tick_every(scale, 5);
|
||||
|
||||
lv_obj_set_style_length(scale, 5, LV_PART_ITEMS);
|
||||
lv_obj_set_style_length(scale, 10, LV_PART_INDICATOR);
|
||||
lv_scale_set_range(scale, 10, 40);
|
||||
}
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user