From e2a7f559abac4b9fd69c22d1a039ac1cd3ac717d Mon Sep 17 00:00:00 2001 From: Gabor Kiss-Vamosi Date: Wed, 19 May 2021 20:55:44 +0200 Subject: [PATCH] feat(bidi) make base dir a style property and rename lv_bidi_dir_t to lv_base_dir_t --- docs/overview/style-props.md | 485 +++++++-------- examples/layouts/flex/lv_example_flex_6.c | 2 +- examples/layouts/grid/lv_example_grid_6.c | 2 +- examples/widgets/bar/lv_example_bar_5.c | 2 +- lv_conf_template.h | 8 +- scripts/style_api_gen.py | 177 +++--- src/core/lv_event.h | 1 - src/core/lv_obj.c | 65 -- src/core/lv_obj.h | 16 - src/core/lv_obj_draw.c | 4 +- src/core/lv_obj_pos.c | 4 +- src/core/lv_obj_scroll.c | 4 +- src/core/lv_obj_style.h | 1 + src/core/lv_obj_style_gen.h | 602 ++++++++++--------- src/core/lv_obj_tree.c | 6 +- src/draw/lv_draw_label.c | 2 +- src/draw/lv_draw_label.h | 2 +- src/extra/layouts/flex/lv_flex.c | 4 +- src/extra/layouts/grid/lv_grid.c | 4 +- src/extra/widgets/keyboard/lv_keyboard.c | 2 +- src/lv_conf_internal.h | 8 +- src/lv_conf_kconfig.h | 12 +- src/misc/lv_bidi.c | 110 ++-- src/misc/lv_bidi.h | 32 +- src/misc/lv_style.h | 56 +- src/misc/lv_style_gen.h | 688 +++++++++++----------- src/widgets/lv_bar.c | 4 +- src/widgets/lv_btnmatrix.c | 4 +- src/widgets/lv_dropdown.c | 2 +- src/widgets/lv_label.c | 26 +- src/widgets/lv_slider.c | 20 +- src/widgets/lv_switch.c | 4 +- src/widgets/lv_table.c | 2 +- 33 files changed, 1160 insertions(+), 1201 deletions(-) diff --git a/docs/overview/style-props.md b/docs/overview/style-props.md index 87633c278..cbd5bd6ac 100644 --- a/docs/overview/style-props.md +++ b/docs/overview/style-props.md @@ -1,242 +1,5 @@ # Style properties -## Miscellaneous -TODO - - -### radius -Set the radius on every corner. The value is interpreted in pixel (>= 0) or `LV_RADIUS_CIRCLE` for max. radius - - - - -### clip_corner -Enable to clip the overflowed content on the rounded corner. Can be `true` or `false`. - - - - -### transform_width -Make the object wider on both sides with this value. Pixel and percentage (with `lv_pct(x)`) values can be used. Percentage values are relative to the object's width. - - - - -### transform_height -Make the object higher on both sides with this value. Pixel and percentage (with `lv_pct(x)`) values can be used. Percentage values are relative to the object's height. - - - - -### translate_x -Move the object with this value in X direction. Applied after layouts, aligns and other positioning. Pixel and percentage (with `lv_pct(x)`) values can be used. Percentage values are relative to the object's width. - - - - -### translate_y -Move the object with this value in Y direction. Applied after layouts, aligns and other positioning. Pixel and percentage (with `lv_pct(x)`) values can be used. Percentage values are relative to the object's height. - - - - -### transform_zoom -Zoom image-like objects. Multiplied with the zoom set on the object. The value 256 (or `LV_IMG_ZOOM_NONE`) means normal size, 128 half size, 512 double size, and so on - - - - -### transform_angle - Rotate image-like objects. Added to the rotation set on the object. The value is interpreted in 0.1 degree unit. E.g. 45 deg. = 450 - - - - -### opa -Scale down all opacity values of the object by this factor. Value 0, `LV_OPA_0` or `LV_OPA_TRANSP` means fully transparent, 256, `LV_OPA_100` or `LV_OPA_COVER` means fully covering, other values or LV_OPA_10, LV_OPA_20, etc means semi transparency. - - - - -### color_filter_dsc -Mix a color to all colors of the object. - - - - -### color_filter_opa -The intensity of mixing of color filter. - - - - -### anim_time -The animation time in milliseconds. It's meaning is widget specific. E.g. blink time of the cursor on the text area or scroll time of a roller. See the widgets' documentation to learn more. - - - - -### anim_speed -The animation speed in pixel/sec. It's meaning is widget specific. E.g. scroll speed of label. See the widgets' documentation to learn more. - - - - -### transition -An initialized `lv_style_transition_dsc_t` to describe a transition. - - - - -### blend_mode -Describes how to blend the colors to the background. The possibel values are `LV_BLEND_MODE_NORMAL/ADDITIVE/SUBTRACTIVE` - - - -## Padding -TODO - - -### pad_top -Sets the padding on the top. It makes the content area smaller in this direction. - - - - -### pad_bottom -Sets the padding on the bottom. It makes the content area smaller in this direction. - - - - -### pad_left -Sets the padding on the left. It makes the content area smaller in this direction. - - - - -### pad_right -Sets the padding on the right. It makes the content area smaller in this direction. - - - - -### pad_row -Sets the padding between the rows. Used by the layouts. - - - - -### pad_column -Sets the padding between the columns. Used by the layouts. - - - ## Size and position TODO @@ -340,6 +103,243 @@ Set the alignment which tells from which point of the parent the X and Y coordin +### transform_width +Make the object wider on both sides with this value. Pixel and percentage (with `lv_pct(x)`) values can be used. Percentage values are relative to the object's width. + + + + +### transform_height +Make the object higher on both sides with this value. Pixel and percentage (with `lv_pct(x)`) values can be used. Percentage values are relative to the object's height. + + + + +### translate_x +Move the object with this value in X direction. Applied after layouts, aligns and other positioning. Pixel and percentage (with `lv_pct(x)`) values can be used. Percentage values are relative to the object's width. + + + + +### translate_y +Move the object with this value in Y direction. Applied after layouts, aligns and other positioning. Pixel and percentage (with `lv_pct(x)`) values can be used. Percentage values are relative to the object's height. + + + + +### transform_zoom +Zoom image-like objects. Multiplied with the zoom set on the object. The value 256 (or `LV_IMG_ZOOM_NONE`) means normal size, 128 half size, 512 double size, and so on + + + + +### transform_angle + Rotate image-like objects. Added to the rotation set on the object. The value is interpreted in 0.1 degree unit. E.g. 45 deg. = 450 + + + +## Padding +TODO + + +### pad_top +Sets the padding on the top. It makes the content area smaller in this direction. + + + + +### pad_bottom +Sets the padding on the bottom. It makes the content area smaller in this direction. + + + + +### pad_left +Sets the padding on the left. It makes the content area smaller in this direction. + + + + +### pad_right +Sets the padding on the right. It makes the content area smaller in this direction. + + + + +### pad_row +Sets the padding between the rows. Used by the layouts. + + + + +### pad_column +Sets the padding between the columns. Used by the layouts. + + + +## Miscellaneous +TODO + + +### radius +Set the radius on every corner. The value is interpreted in pixel (>= 0) or `LV_RADIUS_CIRCLE` for max. radius + + + + +### clip_corner +Enable to clip the overflowed content on the rounded corner. Can be `true` or `false`. + + + + +### opa +Scale down all opacity values of the object by this factor. Value 0, `LV_OPA_0` or `LV_OPA_TRANSP` means fully transparent, 256, `LV_OPA_100` or `LV_OPA_COVER` means fully covering, other values or LV_OPA_10, LV_OPA_20, etc means semi transparency. + + + + +### color_filter_dsc +Mix a color to all colors of the object. + + + + +### color_filter_opa +The intensity of mixing of color filter. + + + + +### anim_time +The animation time in milliseconds. It's meaning is widget specific. E.g. blink time of the cursor on the text area or scroll time of a roller. See the widgets' documentation to learn more. + + + + +### anim_speed +The animation speed in pixel/sec. It's meaning is widget specific. E.g. scroll speed of label. See the widgets' documentation to learn more. + + + + +### transition +An initialized `lv_style_transition_dsc_t` to describe a transition. + + + + +### blend_mode +Describes how to blend the colors to the background. The possibel values are `LV_BLEND_MODE_NORMAL/ADDITIVE/SUBTRACTIVE` + + + + ### layout Set the layout if the object. The children will be repositioned and resized according to the policies set for the layout. For the possible values see the documentation of the layouts. + +### base_dir +Set the base direction of the obejct. The possible values are `LV_BIDI_DIR_LTR/RTL/AUTO`. + + + ## Background TODO diff --git a/examples/layouts/flex/lv_example_flex_6.c b/examples/layouts/flex/lv_example_flex_6.c index aa89df0ea..e90370d32 100644 --- a/examples/layouts/flex/lv_example_flex_6.c +++ b/examples/layouts/flex/lv_example_flex_6.c @@ -8,7 +8,7 @@ void lv_example_flex_6(void) { lv_obj_t * cont = lv_obj_create(lv_scr_act()); - lv_obj_set_base_dir(cont, LV_BIDI_DIR_RTL); + lv_obj_set_style_base_dir(cont, LV_BASE_DIR_RTL, 0); lv_obj_set_size(cont, 300, 220); lv_obj_center(cont); lv_obj_set_flex_flow(cont, LV_FLEX_FLOW_ROW_WRAP); diff --git a/examples/layouts/grid/lv_example_grid_6.c b/examples/layouts/grid/lv_example_grid_6.c index 59e678dd5..2ff411681 100644 --- a/examples/layouts/grid/lv_example_grid_6.c +++ b/examples/layouts/grid/lv_example_grid_6.c @@ -14,7 +14,7 @@ void lv_example_grid_6(void) lv_obj_t * cont = lv_obj_create(lv_scr_act()); lv_obj_set_size(cont, 300, 220); lv_obj_center(cont); - lv_obj_set_base_dir(cont, LV_BIDI_DIR_RTL); + lv_obj_set_style_base_dir(cont, LV_BASE_DIR_RTL, 0); lv_obj_set_grid_dsc_array(cont, col_dsc, row_dsc); lv_obj_t * label; diff --git a/examples/widgets/bar/lv_example_bar_5.c b/examples/widgets/bar/lv_example_bar_5.c index 35d637ae2..c416380a5 100644 --- a/examples/widgets/bar/lv_example_bar_5.c +++ b/examples/widgets/bar/lv_example_bar_5.c @@ -19,7 +19,7 @@ void lv_example_bar_5(void) lv_obj_align_to(label, bar_ltr, LV_ALIGN_OUT_TOP_MID, 0, -5); lv_obj_t * bar_rtl = lv_bar_create(lv_scr_act()); - lv_obj_set_base_dir(bar_rtl, LV_BIDI_DIR_RTL); + lv_obj_set_style_base_dir(bar_rtl, LV_BASE_DIR_RTL, 0); lv_obj_set_size(bar_rtl, 200, 20); lv_bar_set_value(bar_rtl, 70, LV_ANIM_OFF); lv_obj_align(bar_rtl, LV_ALIGN_CENTER, 0, 30); diff --git a/lv_conf_template.h b/lv_conf_template.h index 29225f123..004904993 100644 --- a/lv_conf_template.h +++ b/lv_conf_template.h @@ -353,10 +353,10 @@ e.g. "stm32f769xx.h" or "stm32f429xx.h"*/ #define LV_USE_BIDI 0 #if LV_USE_BIDI /*Set the default direction. Supported values: - *`LV_BIDI_DIR_LTR` Left-to-Right - *`LV_BIDI_DIR_RTL` Right-to-Left - *`LV_BIDI_DIR_AUTO` detect texts base direction*/ -#define LV_BIDI_BASE_DIR_DEF LV_BIDI_DIR_AUTO + *`LV_BASE_DIR_LTR` Left-to-Right + *`LV_BASE_DIR_RTL` Right-to-Left + *`LV_BASE_DIR_AUTO` detect texts base direction*/ +#define LV_BIDI_BASE_DIR_DEF LV_BASE_DIR_AUTO #endif /*Enable Arabic/Persian processing diff --git a/scripts/style_api_gen.py b/scripts/style_api_gen.py index 889d2c6d4..308389555 100755 --- a/scripts/style_api_gen.py +++ b/scripts/style_api_gen.py @@ -3,92 +3,6 @@ import sys, os, re props = [ -{'section': 'Miscellaneous', 'dsc':'TODO' }, -{'name': 'RADIUS', - 'style_type': 'num', 'var_type': 'lv_coord_t', 'default':0, 'inherited': 0, 'layout': 0, 'ext_draw': 0, - 'dsc': "Set the radius on every corner. The value is interpreted in pixel (>= 0) or `LV_RADIUS_CIRCLE` for max. radius"}, - -{'name': 'CLIP_CORNER', - 'style_type': 'num', 'var_type': 'bool', 'default':0, 'inherited': 0, 'layout': 0, 'ext_draw': 0, - 'dsc': "Enable to clip the overflowed content on the rounded corner. Can be `true` or `false`." }, - -{'name': 'TRANSFORM_WIDTH', - 'style_type': 'num', 'var_type': 'lv_coord_t', 'default':0, 'inherited': 0, 'layout': 0, 'ext_draw': 0, - 'dsc': "Make the object wider on both sides with this value. Pixel and percentage (with `lv_pct(x)`) values can be used. Percentage values are relative to the object's width." }, - -{'name': 'TRANSFORM_HEIGHT', - 'style_type': 'num', 'var_type': 'lv_coord_t', 'default':0, 'inherited': 0, 'layout': 0, 'ext_draw': 0, - 'dsc': "Make the object higher on both sides with this value. Pixel and percentage (with `lv_pct(x)`) values can be used. Percentage values are relative to the object's height." }, - -{'name': 'TRANSLATE_X', - 'style_type': 'num', 'var_type': 'lv_coord_t', 'default':0, 'inherited': 0, 'layout': 0, 'ext_draw': 0, - 'dsc': "Move the object with this value in X direction. Applied after layouts, aligns and other positioning. Pixel and percentage (with `lv_pct(x)`) values can be used. Percentage values are relative to the object's width." }, - -{'name': 'TRANSLATE_Y', - 'style_type': 'num', 'var_type': 'lv_coord_t', 'default':0, 'inherited': 0, 'layout': 0, 'ext_draw': 0, - 'dsc': "Move the object with this value in Y direction. Applied after layouts, aligns and other positioning. Pixel and percentage (with `lv_pct(x)`) values can be used. Percentage values are relative to the object's height." }, - -{'name': 'TRANSFORM_ZOOM', - 'style_type': 'num', 'var_type': 'lv_coord_t', 'default':0, 'inherited': 0, 'layout': 0, 'ext_draw': 0, - 'dsc': "Zoom image-like objects. Multiplied with the zoom set on the object. The value 256 (or `LV_IMG_ZOOM_NONE`) means normal size, 128 half size, 512 double size, and so on" }, - -{'name': 'TRANSFORM_ANGLE', - 'style_type': 'num', 'var_type': 'lv_coord_t', 'default':0, 'inherited': 0, 'layout': 0, 'ext_draw': 0, - 'dsc': " Rotate image-like objects. Added to the rotation set on the object. The value is interpreted in 0.1 degree unit. E.g. 45 deg. = 450 " }, - -{'name': 'OPA', - 'style_type': 'num', 'var_type': 'lv_opa_t', 'default':0, 'inherited': 0, 'layout': 0, 'ext_draw': 0, - 'dsc': "Scale down all opacity values of the object by this factor. Value 0, `LV_OPA_0` or `LV_OPA_TRANSP` means fully transparent, 256, `LV_OPA_100` or `LV_OPA_COVER` means fully covering, other values or LV_OPA_10, LV_OPA_20, etc means semi transparency." }, - -{'name': 'COLOR_FILTER_DSC', - 'style_type': 'ptr', 'var_type': 'const lv_color_filter_dsc_t *', 'default':0, 'inherited': 0, 'layout': 0, 'ext_draw': 0, - 'dsc': "Mix a color to all colors of the object." }, - -{'name': 'COLOR_FILTER_OPA', - 'style_type': 'num', 'var_type': 'lv_opa_t' , 'default':0, 'inherited': 0, 'layout': 0, 'ext_draw': 0, - 'dsc': "The intensity of mixing of color filter."}, - -{'name': 'ANIM_TIME', - 'style_type': 'num', 'var_type': 'uint32_t' , 'default':0, 'inherited': 0, 'layout': 0, 'ext_draw': 0, - 'dsc': "The animation time in milliseconds. It's meaning is widget specific. E.g. blink time of the cursor on the text area or scroll time of a roller. See the widgets' documentation to learn more."}, - -{'name': 'ANIM_SPEED', - 'style_type': 'num', 'var_type': 'uint32_t' , 'default':0, 'inherited': 0, 'layout': 0, 'ext_draw': 0, - 'dsc': "The animation speed in pixel/sec. It's meaning is widget specific. E.g. scroll speed of label. See the widgets' documentation to learn more."}, - -{'name': 'TRANSITION', - 'style_type': 'ptr', 'var_type': 'const lv_style_transition_dsc_t *' , 'default':0, 'inherited': 0, 'layout': 0, 'ext_draw': 0, - 'dsc': "An initialized `lv_style_transition_dsc_t` to describe a transition."}, - -{'name': 'BLEND_MODE', - 'style_type': 'num', 'var_type': 'lv_blend_mode_t' , 'default':0, 'inherited': 0, 'layout': 0, 'ext_draw': 0, - 'dsc': "Describes how to blend the colors to the background. The possibel values are `LV_BLEND_MODE_NORMAL/ADDITIVE/SUBTRACTIVE`"}, - -{'section': 'Padding', 'dsc':'TODO' }, -{'name': 'PAD_TOP', - 'style_type': 'num', 'var_type': 'lv_coord_t', 'default':0, 'inherited': 0, 'layout': 0, 'ext_draw': 0, - 'dsc': "Sets the padding on the top. It makes the content area smaller in this direction."}, - -{'name': 'PAD_BOTTOM', - 'style_type': 'num', 'var_type': 'lv_coord_t', 'default':0, 'inherited': 0, 'layout': 0, 'ext_draw': 0, - 'dsc': "Sets the padding on the bottom. It makes the content area smaller in this direction."}, - -{'name': 'PAD_LEFT', - 'style_type': 'num', 'var_type': 'lv_coord_t', 'default':0, 'inherited': 0, 'layout': 0, 'ext_draw': 0, - 'dsc': "Sets the padding on the left. It makes the content area smaller in this direction."}, - -{'name': 'PAD_RIGHT', - 'style_type': 'num', 'var_type': 'lv_coord_t', 'default':0, 'inherited': 0, 'layout': 0, 'ext_draw': 0, - 'dsc': "Sets the padding on the right. It makes the content area smaller in this direction."}, - -{'name': 'PAD_ROW', - 'style_type': 'num', 'var_type': 'lv_coord_t', 'default':0, 'inherited': 0, 'layout': 0, 'ext_draw': 0, - 'dsc': "Sets the padding between the rows. Used by the layouts."}, - -{'name': 'PAD_COLUMN', - 'style_type': 'num', 'var_type': 'lv_coord_t', 'default':0, 'inherited': 0, 'layout': 0, 'ext_draw': 0, - 'dsc': "Sets the padding between the columns. Used by the layouts."}, - {'section': 'Size and position', 'dsc':'TODO' }, {'name': 'WIDTH', 'style_type': 'num', 'var_type': 'lv_coord_t' , 'default':0, 'inherited': 0, 'layout': 0, 'ext_draw': 0, @@ -126,10 +40,101 @@ props = [ 'style_type': 'num', 'var_type': 'lv_align_t', 'default':0, 'inherited': 0, 'layout': 0, 'ext_draw': 0, 'dsc': "Set the alignment which tells from which point of the parent the X and Y coordinates should be interpreted. The possible values are: `LV_ALIGN_TOP_LEFT/MID/RIGHT`, `LV_ALIGN_BOTTOM_LEFT/MID/RIGHT`, `LV_ALIGN_LEFT/RIGHT_MID`, `LV_ALIGN_CENTER`"}, +{'name': 'TRANSFORM_WIDTH', + 'style_type': 'num', 'var_type': 'lv_coord_t', 'default':0, 'inherited': 0, 'layout': 0, 'ext_draw': 0, + 'dsc': "Make the object wider on both sides with this value. Pixel and percentage (with `lv_pct(x)`) values can be used. Percentage values are relative to the object's width." }, + +{'name': 'TRANSFORM_HEIGHT', + 'style_type': 'num', 'var_type': 'lv_coord_t', 'default':0, 'inherited': 0, 'layout': 0, 'ext_draw': 0, + 'dsc': "Make the object higher on both sides with this value. Pixel and percentage (with `lv_pct(x)`) values can be used. Percentage values are relative to the object's height." }, + +{'name': 'TRANSLATE_X', + 'style_type': 'num', 'var_type': 'lv_coord_t', 'default':0, 'inherited': 0, 'layout': 0, 'ext_draw': 0, + 'dsc': "Move the object with this value in X direction. Applied after layouts, aligns and other positioning. Pixel and percentage (with `lv_pct(x)`) values can be used. Percentage values are relative to the object's width." }, + +{'name': 'TRANSLATE_Y', + 'style_type': 'num', 'var_type': 'lv_coord_t', 'default':0, 'inherited': 0, 'layout': 0, 'ext_draw': 0, + 'dsc': "Move the object with this value in Y direction. Applied after layouts, aligns and other positioning. Pixel and percentage (with `lv_pct(x)`) values can be used. Percentage values are relative to the object's height." }, + +{'name': 'TRANSFORM_ZOOM', + 'style_type': 'num', 'var_type': 'lv_coord_t', 'default':0, 'inherited': 0, 'layout': 0, 'ext_draw': 0, + 'dsc': "Zoom image-like objects. Multiplied with the zoom set on the object. The value 256 (or `LV_IMG_ZOOM_NONE`) means normal size, 128 half size, 512 double size, and so on" }, + +{'name': 'TRANSFORM_ANGLE', + 'style_type': 'num', 'var_type': 'lv_coord_t', 'default':0, 'inherited': 0, 'layout': 0, 'ext_draw': 0, + 'dsc': " Rotate image-like objects. Added to the rotation set on the object. The value is interpreted in 0.1 degree unit. E.g. 45 deg. = 450 " }, + +{'section': 'Padding', 'dsc':'TODO' }, +{'name': 'PAD_TOP', + 'style_type': 'num', 'var_type': 'lv_coord_t', 'default':0, 'inherited': 0, 'layout': 0, 'ext_draw': 0, + 'dsc': "Sets the padding on the top. It makes the content area smaller in this direction."}, + +{'name': 'PAD_BOTTOM', + 'style_type': 'num', 'var_type': 'lv_coord_t', 'default':0, 'inherited': 0, 'layout': 0, 'ext_draw': 0, + 'dsc': "Sets the padding on the bottom. It makes the content area smaller in this direction."}, + +{'name': 'PAD_LEFT', + 'style_type': 'num', 'var_type': 'lv_coord_t', 'default':0, 'inherited': 0, 'layout': 0, 'ext_draw': 0, + 'dsc': "Sets the padding on the left. It makes the content area smaller in this direction."}, + +{'name': 'PAD_RIGHT', + 'style_type': 'num', 'var_type': 'lv_coord_t', 'default':0, 'inherited': 0, 'layout': 0, 'ext_draw': 0, + 'dsc': "Sets the padding on the right. It makes the content area smaller in this direction."}, + +{'name': 'PAD_ROW', + 'style_type': 'num', 'var_type': 'lv_coord_t', 'default':0, 'inherited': 0, 'layout': 0, 'ext_draw': 0, + 'dsc': "Sets the padding between the rows. Used by the layouts."}, + +{'name': 'PAD_COLUMN', + 'style_type': 'num', 'var_type': 'lv_coord_t', 'default':0, 'inherited': 0, 'layout': 0, 'ext_draw': 0, + 'dsc': "Sets the padding between the columns. Used by the layouts."}, + +{'section': 'Miscellaneous', 'dsc':'TODO' }, +{'name': 'RADIUS', + 'style_type': 'num', 'var_type': 'lv_coord_t', 'default':0, 'inherited': 0, 'layout': 0, 'ext_draw': 0, + 'dsc': "Set the radius on every corner. The value is interpreted in pixel (>= 0) or `LV_RADIUS_CIRCLE` for max. radius"}, + +{'name': 'CLIP_CORNER', + 'style_type': 'num', 'var_type': 'bool', 'default':0, 'inherited': 0, 'layout': 0, 'ext_draw': 0, + 'dsc': "Enable to clip the overflowed content on the rounded corner. Can be `true` or `false`." }, + +{'name': 'OPA', + 'style_type': 'num', 'var_type': 'lv_opa_t', 'default':0, 'inherited': 0, 'layout': 0, 'ext_draw': 0, + 'dsc': "Scale down all opacity values of the object by this factor. Value 0, `LV_OPA_0` or `LV_OPA_TRANSP` means fully transparent, 256, `LV_OPA_100` or `LV_OPA_COVER` means fully covering, other values or LV_OPA_10, LV_OPA_20, etc means semi transparency." }, + +{'name': 'COLOR_FILTER_DSC', + 'style_type': 'ptr', 'var_type': 'const lv_color_filter_dsc_t *', 'default':0, 'inherited': 0, 'layout': 0, 'ext_draw': 0, + 'dsc': "Mix a color to all colors of the object." }, + +{'name': 'COLOR_FILTER_OPA', + 'style_type': 'num', 'var_type': 'lv_opa_t' , 'default':0, 'inherited': 0, 'layout': 0, 'ext_draw': 0, + 'dsc': "The intensity of mixing of color filter."}, + +{'name': 'ANIM_TIME', + 'style_type': 'num', 'var_type': 'uint32_t' , 'default':0, 'inherited': 0, 'layout': 0, 'ext_draw': 0, + 'dsc': "The animation time in milliseconds. It's meaning is widget specific. E.g. blink time of the cursor on the text area or scroll time of a roller. See the widgets' documentation to learn more."}, + +{'name': 'ANIM_SPEED', + 'style_type': 'num', 'var_type': 'uint32_t' , 'default':0, 'inherited': 0, 'layout': 0, 'ext_draw': 0, + 'dsc': "The animation speed in pixel/sec. It's meaning is widget specific. E.g. scroll speed of label. See the widgets' documentation to learn more."}, + +{'name': 'TRANSITION', + 'style_type': 'ptr', 'var_type': 'const lv_style_transition_dsc_t *' , 'default':0, 'inherited': 0, 'layout': 0, 'ext_draw': 0, + 'dsc': "An initialized `lv_style_transition_dsc_t` to describe a transition."}, + +{'name': 'BLEND_MODE', + 'style_type': 'num', 'var_type': 'lv_blend_mode_t' , 'default':0, 'inherited': 0, 'layout': 0, 'ext_draw': 0, + 'dsc': "Describes how to blend the colors to the background. The possibel values are `LV_BLEND_MODE_NORMAL/ADDITIVE/SUBTRACTIVE`"}, + {'name': 'LAYOUT', 'style_type': 'num', 'var_type': 'uint16_t', 'default':0, 'inherited': 0, 'layout': 0, 'ext_draw': 0, 'dsc': "Set the layout if the object. The children will be repositioned and resized according to the policies set for the layout. For the possible values see the documentation of the layouts."}, +{'name': 'BASE_DIR', + 'style_type': 'num', 'var_type': 'lv_base_dir_t', 'default':0, 'inherited': 0, 'layout': 0, 'ext_draw': 0, + 'dsc': "Set the base direction of the obejct. The possible values are `LV_BIDI_DIR_LTR/RTL/AUTO`."}, + + {'section': 'Background', 'dsc':'TODO' }, {'name': 'BG_COLOR', 'style_type': 'color', 'var_type': 'lv_color_t', 'default':0, 'inherited': 0, 'layout': 0, 'ext_draw': 0, diff --git a/src/core/lv_event.h b/src/core/lv_event.h index 26d02ef05..3dde99220 100644 --- a/src/core/lv_event.h +++ b/src/core/lv_event.h @@ -75,7 +75,6 @@ typedef enum { LV_EVENT_CHILD_CHANGED, /**< Child was removed/added*/ 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_LAST /** Number of default events*/ diff --git a/src/core/lv_obj.c b/src/core/lv_obj.c index 0b28b1e0b..59ac80278 100644 --- a/src/core/lv_obj.c +++ b/src/core/lv_obj.c @@ -54,7 +54,6 @@ static void draw_scrollbar(lv_obj_t * obj, const lv_area_t * clip_area); static lv_res_t scrollbar_init_draw_dsc(lv_obj_t * obj, lv_draw_rect_dsc_t * dsc); static bool obj_valid_child(const lv_obj_t * parent, const lv_obj_t * obj_to_find); static void lv_obj_set_state(lv_obj_t * obj, lv_state_t new_state); -static void base_dir_refr_children(lv_obj_t * obj); /********************** * STATIC VARIABLES @@ -247,25 +246,6 @@ void lv_obj_clear_state(lv_obj_t * obj, lv_state_t state) } } -void lv_obj_set_base_dir(lv_obj_t * obj, lv_bidi_dir_t dir) -{ - if(dir != LV_BIDI_DIR_LTR && dir != LV_BIDI_DIR_RTL && - dir != LV_BIDI_DIR_AUTO && dir != LV_BIDI_DIR_INHERIT) { - - LV_LOG_WARN("lv_obj_set_base_dir: invalid base direction: %d", dir); - return; - } - - lv_obj_allocate_spec_attr(obj); - obj->spec_attr->base_dir = dir; - lv_event_send(obj, LV_EVENT_BASE_DIR_CHANGED, NULL); - - /*Notify the children about the parent base dir has changed. - *(The children might have `LV_BIDI_DIR_INHERIT`)*/ - base_dir_refr_children(obj); -} - - /*======================= * Getter functions *======================*/ @@ -284,30 +264,6 @@ bool lv_obj_has_flag_any(const lv_obj_t * obj, lv_obj_flag_t f) return (obj->flags & f) ? true : false; } -lv_bidi_dir_t lv_obj_get_base_dir(const lv_obj_t * obj) -{ - LV_ASSERT_OBJ(obj, MY_CLASS); - -#if LV_USE_BIDI - if(obj->spec_attr == NULL) return LV_BIDI_DIR_LTR; - const lv_obj_t * parent = obj; - - while(parent) { - /*If the base dir set use it. If not set assume INHERIT so got the next parent*/ - if(parent->spec_attr) { - if(parent->spec_attr->base_dir != LV_BIDI_DIR_INHERIT) return parent->spec_attr->base_dir; - } - - parent = lv_obj_get_parent(parent); - } - - return LV_BIDI_BASE_DIR_DEF; -#else - (void) obj; /*Unused*/ - return LV_BIDI_DIR_LTR; -#endif -} - lv_state_t lv_obj_get_state(const lv_obj_t * obj) { LV_ASSERT_OBJ(obj, MY_CLASS); @@ -315,7 +271,6 @@ lv_state_t lv_obj_get_state(const lv_obj_t * obj) return obj->state; } - bool lv_obj_has_state(const lv_obj_t * obj, lv_state_t state) { LV_ASSERT_OBJ(obj, MY_CLASS); @@ -349,9 +304,7 @@ void lv_obj_allocate_spec_attr(lv_obj_t * obj) lv_memset_00(obj->spec_attr, sizeof(lv_obj_spec_attr_t)); obj->spec_attr->scroll_dir = LV_DIR_ALL; - obj->spec_attr->base_dir = LV_BIDI_DIR_INHERIT; obj->spec_attr->scrollbar_mode = LV_SCROLLBAR_MODE_AUTO; - } } @@ -709,11 +662,6 @@ static void lv_obj_event(const lv_obj_class_t * class_p, lv_event_t * e) lv_obj_mark_layout_as_dirty(obj); } } - else if(code == LV_EVENT_BASE_DIR_CHANGED) { - /*The layout might depend on the base dir. - *E.g. the first is element is on the left or right*/ - lv_obj_mark_layout_as_dirty(obj); - } else if(code == LV_EVENT_SCROLL_END) { if(lv_obj_get_scrollbar_mode(obj) == LV_SCROLLBAR_MODE_ACTIVE) { lv_obj_invalidate(obj); @@ -808,19 +756,6 @@ static void lv_obj_set_state(lv_obj_t * obj, lv_state_t new_state) } } - -static void base_dir_refr_children(lv_obj_t * obj) -{ - uint32_t i; - for(i = 0; i < lv_obj_get_child_cnt(obj); i++) { - lv_obj_t * child = lv_obj_get_child(obj, i); - if(lv_obj_get_base_dir(child) == LV_BIDI_DIR_INHERIT) { - lv_event_send(child, LV_EVENT_BASE_DIR_CHANGED, NULL); - base_dir_refr_children(child); - } - } -} - static bool obj_valid_child(const lv_obj_t * parent, const lv_obj_t * obj_to_find) { diff --git a/src/core/lv_obj.h b/src/core/lv_obj.h index 94d02caed..17f76f778 100644 --- a/src/core/lv_obj.h +++ b/src/core/lv_obj.h @@ -151,7 +151,6 @@ typedef struct { lv_scroll_snap_t scroll_snap_x : 2; /**< Where to align the snapable children horizontally*/ lv_scroll_snap_t scroll_snap_y : 2; /**< Where to align the snapable children horizontally*/ lv_dir_t scroll_dir :4; /**< The allowed scroll direction(s)*/ - lv_bidi_dir_t base_dir : 2; /**< Base direction of texts related to this object*/ uint8_t event_dsc_cnt; /**< Number of event callabcks stored in `event_cb` array*/ }lv_obj_spec_attr_t; @@ -237,13 +236,6 @@ void lv_obj_add_state(lv_obj_t * obj, lv_state_t state); */ void lv_obj_clear_state(lv_obj_t * obj, lv_state_t state); -/** - * Set the base direction of the object - * @param obj pointer to an object - * @param dir the new base direction. `LV_BIDI_DIR_LTR/RTL/AUTO/INHERIT` - */ -void lv_obj_set_base_dir(lv_obj_t * obj, lv_bidi_dir_t dir); - /** * Set the user_data field of the object * @param obj pointer to an object @@ -276,14 +268,6 @@ bool lv_obj_has_flag(const lv_obj_t * obj, lv_obj_flag_t f); */ bool lv_obj_has_flag_any(const lv_obj_t * obj, lv_obj_flag_t f); - -/** - * Get the base direction of the object - * @param obj pointer to an object - * @return the base direction. `LV_BIDI_DIR_LTR/RTL/AUTO/INHERIT` - */ -lv_bidi_dir_t lv_obj_get_base_dir(const lv_obj_t * obj); - /** * Get the state of an object * @param obj pointer to an object diff --git a/src/core/lv_obj_draw.c b/src/core/lv_obj_draw.c index 7fce7714a..b0f35f9d5 100644 --- a/src/core/lv_obj_draw.c +++ b/src/core/lv_obj_draw.c @@ -202,12 +202,12 @@ void lv_obj_init_draw_label_dsc(lv_obj_t * obj, uint32_t part, lv_draw_label_dsc draw_dsc->font = lv_obj_get_style_text_font(obj, part); #if LV_USE_BIDI == 0 - draw_dsc->bidi_dir = lv_obj_get_base_dir(obj); + draw_dsc->bidi_dir = lv_obj_get_style_base_dir(obj, LV_PART_MAIN); #endif draw_dsc->align = lv_obj_get_style_text_align(obj, part); if(draw_dsc->align == LV_TEXT_ALIGN_AUTO) { - if(draw_dsc->bidi_dir == LV_BIDI_DIR_RTL) draw_dsc->align = LV_TEXT_ALIGN_RIGHT; + if(draw_dsc->bidi_dir == LV_BASE_DIR_RTL) draw_dsc->align = LV_TEXT_ALIGN_RIGHT; draw_dsc->align = LV_TEXT_ALIGN_LEFT; } } diff --git a/src/core/lv_obj_pos.c b/src/core/lv_obj_pos.c index b4d29ec4a..cdc2879cf 100644 --- a/src/core/lv_obj_pos.c +++ b/src/core/lv_obj_pos.c @@ -171,7 +171,7 @@ bool lv_obj_refr_size(lv_obj_t * obj) /*Set the length and height *Be sure the content is not scrolled in an invalid position on the new size*/ obj->coords.y2 = obj->coords.y1 + h - 1; - if(lv_obj_get_base_dir(obj) == LV_BIDI_DIR_RTL) { + if(lv_obj_get_style_base_dir(obj, LV_PART_MAIN) == LV_BASE_DIR_RTL) { obj->coords.x1 = obj->coords.x2 - w + 1; } else { @@ -201,7 +201,7 @@ bool lv_obj_refr_size(lv_obj_t * obj) if(lv_obj_get_scroll_snap_x(obj) == LV_SCROLL_SNAP_NONE) { lv_coord_t sl = lv_obj_get_scroll_left(obj); lv_coord_t sr = lv_obj_get_scroll_right(obj); - if(lv_obj_get_base_dir(obj) != LV_BIDI_DIR_RTL) { + if(lv_obj_get_style_base_dir(obj, LV_PART_MAIN) != LV_BASE_DIR_RTL) { /*Be sure the left side is not remains scrolled in*/ if(sr < 0 && sl > 0) { sr = LV_MIN(sl, -sr); diff --git a/src/core/lv_obj_scroll.c b/src/core/lv_obj_scroll.c index bf1e8f0e6..a6dfed0e3 100644 --- a/src/core/lv_obj_scroll.c +++ b/src/core/lv_obj_scroll.c @@ -161,7 +161,7 @@ lv_coord_t lv_obj_get_scroll_left(lv_obj_t * obj) /*Normally can't scroll the object out on the left. *So simply use the current scroll position as "left size"*/ - if(lv_obj_get_base_dir(obj) != LV_BIDI_DIR_RTL) { + if(lv_obj_get_style_base_dir(obj, LV_PART_MAIN) != LV_BASE_DIR_RTL) { if(obj->spec_attr == NULL) return 0; return -obj->spec_attr->scroll.x; } @@ -200,7 +200,7 @@ lv_coord_t lv_obj_get_scroll_right(lv_obj_t * obj) /*With RTL base dir can't scroll to the object out on the right. *So simply use the current scroll position as "right size"*/ - if(lv_obj_get_base_dir(obj) == LV_BIDI_DIR_RTL) { + if(lv_obj_get_style_base_dir(obj, LV_PART_MAIN) == LV_BASE_DIR_RTL) { if(obj->spec_attr == NULL) return 0; return obj->spec_attr->scroll.x; } diff --git a/src/core/lv_obj_style.h b/src/core/lv_obj_style.h index 3a3831efb..add81c2e6 100644 --- a/src/core/lv_obj_style.h +++ b/src/core/lv_obj_style.h @@ -15,6 +15,7 @@ extern "C" { *********************/ #include #include +#include "../misc/lv_bidi.h" /********************* * DEFINES diff --git a/src/core/lv_obj_style_gen.h b/src/core/lv_obj_style_gen.h index bf4838ddd..557cb538c 100644 --- a/src/core/lv_obj_style_gen.h +++ b/src/core/lv_obj_style_gen.h @@ -1,129 +1,3 @@ -static inline lv_coord_t lv_obj_get_style_radius(const struct _lv_obj_t * obj, uint32_t part) -{ - lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_RADIUS); - return (lv_coord_t)v.num; -} - -static inline bool lv_obj_get_style_clip_corner(const struct _lv_obj_t * obj, uint32_t part) -{ - lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_CLIP_CORNER); - return (bool)v.num; -} - -static inline lv_coord_t lv_obj_get_style_transform_width(const struct _lv_obj_t * obj, uint32_t part) -{ - lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_TRANSFORM_WIDTH); - return (lv_coord_t)v.num; -} - -static inline lv_coord_t lv_obj_get_style_transform_height(const struct _lv_obj_t * obj, uint32_t part) -{ - lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_TRANSFORM_HEIGHT); - return (lv_coord_t)v.num; -} - -static inline lv_coord_t lv_obj_get_style_translate_x(const struct _lv_obj_t * obj, uint32_t part) -{ - lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_TRANSLATE_X); - return (lv_coord_t)v.num; -} - -static inline lv_coord_t lv_obj_get_style_translate_y(const struct _lv_obj_t * obj, uint32_t part) -{ - lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_TRANSLATE_Y); - return (lv_coord_t)v.num; -} - -static inline lv_coord_t lv_obj_get_style_transform_zoom(const struct _lv_obj_t * obj, uint32_t part) -{ - lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_TRANSFORM_ZOOM); - return (lv_coord_t)v.num; -} - -static inline lv_coord_t lv_obj_get_style_transform_angle(const struct _lv_obj_t * obj, uint32_t part) -{ - lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_TRANSFORM_ANGLE); - return (lv_coord_t)v.num; -} - -static inline lv_opa_t lv_obj_get_style_opa(const struct _lv_obj_t * obj, uint32_t part) -{ - lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_OPA); - return (lv_opa_t)v.num; -} - -static inline const lv_color_filter_dsc_t * lv_obj_get_style_color_filter_dsc(const struct _lv_obj_t * obj, uint32_t part) -{ - lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_COLOR_FILTER_DSC); - return (const lv_color_filter_dsc_t *)v.ptr; -} - -static inline lv_opa_t lv_obj_get_style_color_filter_opa(const struct _lv_obj_t * obj, uint32_t part) -{ - lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_COLOR_FILTER_OPA); - return (lv_opa_t)v.num; -} - -static inline uint32_t lv_obj_get_style_anim_time(const struct _lv_obj_t * obj, uint32_t part) -{ - lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_ANIM_TIME); - return (uint32_t)v.num; -} - -static inline uint32_t lv_obj_get_style_anim_speed(const struct _lv_obj_t * obj, uint32_t part) -{ - lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_ANIM_SPEED); - return (uint32_t)v.num; -} - -static inline const lv_style_transition_dsc_t * lv_obj_get_style_transition(const struct _lv_obj_t * obj, uint32_t part) -{ - lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_TRANSITION); - return (const lv_style_transition_dsc_t *)v.ptr; -} - -static inline lv_blend_mode_t lv_obj_get_style_blend_mode(const struct _lv_obj_t * obj, uint32_t part) -{ - lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_BLEND_MODE); - return (lv_blend_mode_t)v.num; -} - -static inline lv_coord_t lv_obj_get_style_pad_top(const struct _lv_obj_t * obj, uint32_t part) -{ - lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_PAD_TOP); - return (lv_coord_t)v.num; -} - -static inline lv_coord_t lv_obj_get_style_pad_bottom(const struct _lv_obj_t * obj, uint32_t part) -{ - lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_PAD_BOTTOM); - return (lv_coord_t)v.num; -} - -static inline lv_coord_t lv_obj_get_style_pad_left(const struct _lv_obj_t * obj, uint32_t part) -{ - lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_PAD_LEFT); - return (lv_coord_t)v.num; -} - -static inline lv_coord_t lv_obj_get_style_pad_right(const struct _lv_obj_t * obj, uint32_t part) -{ - lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_PAD_RIGHT); - return (lv_coord_t)v.num; -} - -static inline lv_coord_t lv_obj_get_style_pad_row(const struct _lv_obj_t * obj, uint32_t part) -{ - lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_PAD_ROW); - return (lv_coord_t)v.num; -} - -static inline lv_coord_t lv_obj_get_style_pad_column(const struct _lv_obj_t * obj, uint32_t part) -{ - lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_PAD_COLUMN); - return (lv_coord_t)v.num; -} - static inline lv_coord_t lv_obj_get_style_width(const struct _lv_obj_t * obj, uint32_t part) { lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_WIDTH); @@ -178,12 +52,144 @@ static inline lv_align_t lv_obj_get_style_align(const struct _lv_obj_t * obj, ui return (lv_align_t)v.num; } +static inline lv_coord_t lv_obj_get_style_transform_width(const struct _lv_obj_t * obj, uint32_t part) +{ + lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_TRANSFORM_WIDTH); + return (lv_coord_t)v.num; +} + +static inline lv_coord_t lv_obj_get_style_transform_height(const struct _lv_obj_t * obj, uint32_t part) +{ + lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_TRANSFORM_HEIGHT); + return (lv_coord_t)v.num; +} + +static inline lv_coord_t lv_obj_get_style_translate_x(const struct _lv_obj_t * obj, uint32_t part) +{ + lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_TRANSLATE_X); + return (lv_coord_t)v.num; +} + +static inline lv_coord_t lv_obj_get_style_translate_y(const struct _lv_obj_t * obj, uint32_t part) +{ + lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_TRANSLATE_Y); + return (lv_coord_t)v.num; +} + +static inline lv_coord_t lv_obj_get_style_transform_zoom(const struct _lv_obj_t * obj, uint32_t part) +{ + lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_TRANSFORM_ZOOM); + return (lv_coord_t)v.num; +} + +static inline lv_coord_t lv_obj_get_style_transform_angle(const struct _lv_obj_t * obj, uint32_t part) +{ + lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_TRANSFORM_ANGLE); + return (lv_coord_t)v.num; +} + +static inline lv_coord_t lv_obj_get_style_pad_top(const struct _lv_obj_t * obj, uint32_t part) +{ + lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_PAD_TOP); + return (lv_coord_t)v.num; +} + +static inline lv_coord_t lv_obj_get_style_pad_bottom(const struct _lv_obj_t * obj, uint32_t part) +{ + lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_PAD_BOTTOM); + return (lv_coord_t)v.num; +} + +static inline lv_coord_t lv_obj_get_style_pad_left(const struct _lv_obj_t * obj, uint32_t part) +{ + lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_PAD_LEFT); + return (lv_coord_t)v.num; +} + +static inline lv_coord_t lv_obj_get_style_pad_right(const struct _lv_obj_t * obj, uint32_t part) +{ + lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_PAD_RIGHT); + return (lv_coord_t)v.num; +} + +static inline lv_coord_t lv_obj_get_style_pad_row(const struct _lv_obj_t * obj, uint32_t part) +{ + lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_PAD_ROW); + return (lv_coord_t)v.num; +} + +static inline lv_coord_t lv_obj_get_style_pad_column(const struct _lv_obj_t * obj, uint32_t part) +{ + lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_PAD_COLUMN); + return (lv_coord_t)v.num; +} + +static inline lv_coord_t lv_obj_get_style_radius(const struct _lv_obj_t * obj, uint32_t part) +{ + lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_RADIUS); + return (lv_coord_t)v.num; +} + +static inline bool lv_obj_get_style_clip_corner(const struct _lv_obj_t * obj, uint32_t part) +{ + lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_CLIP_CORNER); + return (bool)v.num; +} + +static inline lv_opa_t lv_obj_get_style_opa(const struct _lv_obj_t * obj, uint32_t part) +{ + lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_OPA); + return (lv_opa_t)v.num; +} + +static inline const lv_color_filter_dsc_t * lv_obj_get_style_color_filter_dsc(const struct _lv_obj_t * obj, uint32_t part) +{ + lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_COLOR_FILTER_DSC); + return (const lv_color_filter_dsc_t *)v.ptr; +} + +static inline lv_opa_t lv_obj_get_style_color_filter_opa(const struct _lv_obj_t * obj, uint32_t part) +{ + lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_COLOR_FILTER_OPA); + return (lv_opa_t)v.num; +} + +static inline uint32_t lv_obj_get_style_anim_time(const struct _lv_obj_t * obj, uint32_t part) +{ + lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_ANIM_TIME); + return (uint32_t)v.num; +} + +static inline uint32_t lv_obj_get_style_anim_speed(const struct _lv_obj_t * obj, uint32_t part) +{ + lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_ANIM_SPEED); + return (uint32_t)v.num; +} + +static inline const lv_style_transition_dsc_t * lv_obj_get_style_transition(const struct _lv_obj_t * obj, uint32_t part) +{ + lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_TRANSITION); + return (const lv_style_transition_dsc_t *)v.ptr; +} + +static inline lv_blend_mode_t lv_obj_get_style_blend_mode(const struct _lv_obj_t * obj, uint32_t part) +{ + lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_BLEND_MODE); + return (lv_blend_mode_t)v.num; +} + static inline uint16_t lv_obj_get_style_layout(const struct _lv_obj_t * obj, uint32_t part) { lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_LAYOUT); return (uint16_t)v.num; } +static inline lv_base_dir_t lv_obj_get_style_base_dir(const struct _lv_obj_t * obj, uint32_t part) +{ + lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_BASE_DIR); + return (lv_base_dir_t)v.num; +} + static inline lv_color_t lv_obj_get_style_bg_color(const struct _lv_obj_t * obj, uint32_t part) { lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_BG_COLOR); @@ -526,174 +532,6 @@ static inline const void * lv_obj_get_style_arc_img_src(const struct _lv_obj_t * return (const void *)v.ptr; } -static inline void lv_obj_set_style_radius(struct _lv_obj_t * obj, lv_coord_t value, lv_style_selector_t selector) -{ - lv_style_value_t v = { - .num = (int32_t)value - }; - lv_obj_set_local_style_prop(obj, LV_STYLE_RADIUS, v, selector); -} - -static inline void lv_obj_set_style_clip_corner(struct _lv_obj_t * obj, bool value, lv_style_selector_t selector) -{ - lv_style_value_t v = { - .num = (int32_t)value - }; - lv_obj_set_local_style_prop(obj, LV_STYLE_CLIP_CORNER, v, selector); -} - -static inline void lv_obj_set_style_transform_width(struct _lv_obj_t * obj, lv_coord_t value, lv_style_selector_t selector) -{ - lv_style_value_t v = { - .num = (int32_t)value - }; - lv_obj_set_local_style_prop(obj, LV_STYLE_TRANSFORM_WIDTH, v, selector); -} - -static inline void lv_obj_set_style_transform_height(struct _lv_obj_t * obj, lv_coord_t value, lv_style_selector_t selector) -{ - lv_style_value_t v = { - .num = (int32_t)value - }; - lv_obj_set_local_style_prop(obj, LV_STYLE_TRANSFORM_HEIGHT, v, selector); -} - -static inline void lv_obj_set_style_translate_x(struct _lv_obj_t * obj, lv_coord_t value, lv_style_selector_t selector) -{ - lv_style_value_t v = { - .num = (int32_t)value - }; - lv_obj_set_local_style_prop(obj, LV_STYLE_TRANSLATE_X, v, selector); -} - -static inline void lv_obj_set_style_translate_y(struct _lv_obj_t * obj, lv_coord_t value, lv_style_selector_t selector) -{ - lv_style_value_t v = { - .num = (int32_t)value - }; - lv_obj_set_local_style_prop(obj, LV_STYLE_TRANSLATE_Y, v, selector); -} - -static inline void lv_obj_set_style_transform_zoom(struct _lv_obj_t * obj, lv_coord_t value, lv_style_selector_t selector) -{ - lv_style_value_t v = { - .num = (int32_t)value - }; - lv_obj_set_local_style_prop(obj, LV_STYLE_TRANSFORM_ZOOM, v, selector); -} - -static inline void lv_obj_set_style_transform_angle(struct _lv_obj_t * obj, lv_coord_t value, lv_style_selector_t selector) -{ - lv_style_value_t v = { - .num = (int32_t)value - }; - lv_obj_set_local_style_prop(obj, LV_STYLE_TRANSFORM_ANGLE, v, selector); -} - -static inline void lv_obj_set_style_opa(struct _lv_obj_t * obj, lv_opa_t value, lv_style_selector_t selector) -{ - lv_style_value_t v = { - .num = (int32_t)value - }; - lv_obj_set_local_style_prop(obj, LV_STYLE_OPA, v, selector); -} - -static inline void lv_obj_set_style_color_filter_dsc(struct _lv_obj_t * obj, const lv_color_filter_dsc_t * value, lv_style_selector_t selector) -{ - lv_style_value_t v = { - .ptr = value - }; - lv_obj_set_local_style_prop(obj, LV_STYLE_COLOR_FILTER_DSC, v, selector); -} - -static inline void lv_obj_set_style_color_filter_opa(struct _lv_obj_t * obj, lv_opa_t value, lv_style_selector_t selector) -{ - lv_style_value_t v = { - .num = (int32_t)value - }; - lv_obj_set_local_style_prop(obj, LV_STYLE_COLOR_FILTER_OPA, v, selector); -} - -static inline void lv_obj_set_style_anim_time(struct _lv_obj_t * obj, uint32_t value, lv_style_selector_t selector) -{ - lv_style_value_t v = { - .num = (int32_t)value - }; - lv_obj_set_local_style_prop(obj, LV_STYLE_ANIM_TIME, v, selector); -} - -static inline void lv_obj_set_style_anim_speed(struct _lv_obj_t * obj, uint32_t value, lv_style_selector_t selector) -{ - lv_style_value_t v = { - .num = (int32_t)value - }; - lv_obj_set_local_style_prop(obj, LV_STYLE_ANIM_SPEED, v, selector); -} - -static inline void lv_obj_set_style_transition(struct _lv_obj_t * obj, const lv_style_transition_dsc_t * value, lv_style_selector_t selector) -{ - lv_style_value_t v = { - .ptr = value - }; - lv_obj_set_local_style_prop(obj, LV_STYLE_TRANSITION, v, selector); -} - -static inline void lv_obj_set_style_blend_mode(struct _lv_obj_t * obj, lv_blend_mode_t value, lv_style_selector_t selector) -{ - lv_style_value_t v = { - .num = (int32_t)value - }; - lv_obj_set_local_style_prop(obj, LV_STYLE_BLEND_MODE, v, selector); -} - -static inline void lv_obj_set_style_pad_top(struct _lv_obj_t * obj, lv_coord_t value, lv_style_selector_t selector) -{ - lv_style_value_t v = { - .num = (int32_t)value - }; - lv_obj_set_local_style_prop(obj, LV_STYLE_PAD_TOP, v, selector); -} - -static inline void lv_obj_set_style_pad_bottom(struct _lv_obj_t * obj, lv_coord_t value, lv_style_selector_t selector) -{ - lv_style_value_t v = { - .num = (int32_t)value - }; - lv_obj_set_local_style_prop(obj, LV_STYLE_PAD_BOTTOM, v, selector); -} - -static inline void lv_obj_set_style_pad_left(struct _lv_obj_t * obj, lv_coord_t value, lv_style_selector_t selector) -{ - lv_style_value_t v = { - .num = (int32_t)value - }; - lv_obj_set_local_style_prop(obj, LV_STYLE_PAD_LEFT, v, selector); -} - -static inline void lv_obj_set_style_pad_right(struct _lv_obj_t * obj, lv_coord_t value, lv_style_selector_t selector) -{ - lv_style_value_t v = { - .num = (int32_t)value - }; - lv_obj_set_local_style_prop(obj, LV_STYLE_PAD_RIGHT, v, selector); -} - -static inline void lv_obj_set_style_pad_row(struct _lv_obj_t * obj, lv_coord_t value, lv_style_selector_t selector) -{ - lv_style_value_t v = { - .num = (int32_t)value - }; - lv_obj_set_local_style_prop(obj, LV_STYLE_PAD_ROW, v, selector); -} - -static inline void lv_obj_set_style_pad_column(struct _lv_obj_t * obj, lv_coord_t value, lv_style_selector_t selector) -{ - lv_style_value_t v = { - .num = (int32_t)value - }; - lv_obj_set_local_style_prop(obj, LV_STYLE_PAD_COLUMN, v, selector); -} - static inline void lv_obj_set_style_width(struct _lv_obj_t * obj, lv_coord_t value, lv_style_selector_t selector) { lv_style_value_t v = { @@ -766,6 +604,174 @@ static inline void lv_obj_set_style_align(struct _lv_obj_t * obj, lv_align_t val lv_obj_set_local_style_prop(obj, LV_STYLE_ALIGN, v, selector); } +static inline void lv_obj_set_style_transform_width(struct _lv_obj_t * obj, lv_coord_t value, lv_style_selector_t selector) +{ + lv_style_value_t v = { + .num = (int32_t)value + }; + lv_obj_set_local_style_prop(obj, LV_STYLE_TRANSFORM_WIDTH, v, selector); +} + +static inline void lv_obj_set_style_transform_height(struct _lv_obj_t * obj, lv_coord_t value, lv_style_selector_t selector) +{ + lv_style_value_t v = { + .num = (int32_t)value + }; + lv_obj_set_local_style_prop(obj, LV_STYLE_TRANSFORM_HEIGHT, v, selector); +} + +static inline void lv_obj_set_style_translate_x(struct _lv_obj_t * obj, lv_coord_t value, lv_style_selector_t selector) +{ + lv_style_value_t v = { + .num = (int32_t)value + }; + lv_obj_set_local_style_prop(obj, LV_STYLE_TRANSLATE_X, v, selector); +} + +static inline void lv_obj_set_style_translate_y(struct _lv_obj_t * obj, lv_coord_t value, lv_style_selector_t selector) +{ + lv_style_value_t v = { + .num = (int32_t)value + }; + lv_obj_set_local_style_prop(obj, LV_STYLE_TRANSLATE_Y, v, selector); +} + +static inline void lv_obj_set_style_transform_zoom(struct _lv_obj_t * obj, lv_coord_t value, lv_style_selector_t selector) +{ + lv_style_value_t v = { + .num = (int32_t)value + }; + lv_obj_set_local_style_prop(obj, LV_STYLE_TRANSFORM_ZOOM, v, selector); +} + +static inline void lv_obj_set_style_transform_angle(struct _lv_obj_t * obj, lv_coord_t value, lv_style_selector_t selector) +{ + lv_style_value_t v = { + .num = (int32_t)value + }; + lv_obj_set_local_style_prop(obj, LV_STYLE_TRANSFORM_ANGLE, v, selector); +} + +static inline void lv_obj_set_style_pad_top(struct _lv_obj_t * obj, lv_coord_t value, lv_style_selector_t selector) +{ + lv_style_value_t v = { + .num = (int32_t)value + }; + lv_obj_set_local_style_prop(obj, LV_STYLE_PAD_TOP, v, selector); +} + +static inline void lv_obj_set_style_pad_bottom(struct _lv_obj_t * obj, lv_coord_t value, lv_style_selector_t selector) +{ + lv_style_value_t v = { + .num = (int32_t)value + }; + lv_obj_set_local_style_prop(obj, LV_STYLE_PAD_BOTTOM, v, selector); +} + +static inline void lv_obj_set_style_pad_left(struct _lv_obj_t * obj, lv_coord_t value, lv_style_selector_t selector) +{ + lv_style_value_t v = { + .num = (int32_t)value + }; + lv_obj_set_local_style_prop(obj, LV_STYLE_PAD_LEFT, v, selector); +} + +static inline void lv_obj_set_style_pad_right(struct _lv_obj_t * obj, lv_coord_t value, lv_style_selector_t selector) +{ + lv_style_value_t v = { + .num = (int32_t)value + }; + lv_obj_set_local_style_prop(obj, LV_STYLE_PAD_RIGHT, v, selector); +} + +static inline void lv_obj_set_style_pad_row(struct _lv_obj_t * obj, lv_coord_t value, lv_style_selector_t selector) +{ + lv_style_value_t v = { + .num = (int32_t)value + }; + lv_obj_set_local_style_prop(obj, LV_STYLE_PAD_ROW, v, selector); +} + +static inline void lv_obj_set_style_pad_column(struct _lv_obj_t * obj, lv_coord_t value, lv_style_selector_t selector) +{ + lv_style_value_t v = { + .num = (int32_t)value + }; + lv_obj_set_local_style_prop(obj, LV_STYLE_PAD_COLUMN, v, selector); +} + +static inline void lv_obj_set_style_radius(struct _lv_obj_t * obj, lv_coord_t value, lv_style_selector_t selector) +{ + lv_style_value_t v = { + .num = (int32_t)value + }; + lv_obj_set_local_style_prop(obj, LV_STYLE_RADIUS, v, selector); +} + +static inline void lv_obj_set_style_clip_corner(struct _lv_obj_t * obj, bool value, lv_style_selector_t selector) +{ + lv_style_value_t v = { + .num = (int32_t)value + }; + lv_obj_set_local_style_prop(obj, LV_STYLE_CLIP_CORNER, v, selector); +} + +static inline void lv_obj_set_style_opa(struct _lv_obj_t * obj, lv_opa_t value, lv_style_selector_t selector) +{ + lv_style_value_t v = { + .num = (int32_t)value + }; + lv_obj_set_local_style_prop(obj, LV_STYLE_OPA, v, selector); +} + +static inline void lv_obj_set_style_color_filter_dsc(struct _lv_obj_t * obj, const lv_color_filter_dsc_t * value, lv_style_selector_t selector) +{ + lv_style_value_t v = { + .ptr = value + }; + lv_obj_set_local_style_prop(obj, LV_STYLE_COLOR_FILTER_DSC, v, selector); +} + +static inline void lv_obj_set_style_color_filter_opa(struct _lv_obj_t * obj, lv_opa_t value, lv_style_selector_t selector) +{ + lv_style_value_t v = { + .num = (int32_t)value + }; + lv_obj_set_local_style_prop(obj, LV_STYLE_COLOR_FILTER_OPA, v, selector); +} + +static inline void lv_obj_set_style_anim_time(struct _lv_obj_t * obj, uint32_t value, lv_style_selector_t selector) +{ + lv_style_value_t v = { + .num = (int32_t)value + }; + lv_obj_set_local_style_prop(obj, LV_STYLE_ANIM_TIME, v, selector); +} + +static inline void lv_obj_set_style_anim_speed(struct _lv_obj_t * obj, uint32_t value, lv_style_selector_t selector) +{ + lv_style_value_t v = { + .num = (int32_t)value + }; + lv_obj_set_local_style_prop(obj, LV_STYLE_ANIM_SPEED, v, selector); +} + +static inline void lv_obj_set_style_transition(struct _lv_obj_t * obj, const lv_style_transition_dsc_t * value, lv_style_selector_t selector) +{ + lv_style_value_t v = { + .ptr = value + }; + lv_obj_set_local_style_prop(obj, LV_STYLE_TRANSITION, v, selector); +} + +static inline void lv_obj_set_style_blend_mode(struct _lv_obj_t * obj, lv_blend_mode_t value, lv_style_selector_t selector) +{ + lv_style_value_t v = { + .num = (int32_t)value + }; + lv_obj_set_local_style_prop(obj, LV_STYLE_BLEND_MODE, v, selector); +} + static inline void lv_obj_set_style_layout(struct _lv_obj_t * obj, uint16_t value, lv_style_selector_t selector) { lv_style_value_t v = { @@ -774,6 +780,14 @@ static inline void lv_obj_set_style_layout(struct _lv_obj_t * obj, uint16_t valu lv_obj_set_local_style_prop(obj, LV_STYLE_LAYOUT, v, selector); } +static inline void lv_obj_set_style_base_dir(struct _lv_obj_t * obj, lv_base_dir_t value, lv_style_selector_t selector) +{ + lv_style_value_t v = { + .num = (int32_t)value + }; + lv_obj_set_local_style_prop(obj, LV_STYLE_BASE_DIR, v, selector); +} + static inline void lv_obj_set_style_bg_color(struct _lv_obj_t * obj, lv_color_t value, lv_style_selector_t selector) { lv_style_value_t v = { diff --git a/src/core/lv_obj_tree.c b/src/core/lv_obj_tree.c index 8a2f415e8..43e0f29ac 100644 --- a/src/core/lv_obj_tree.c +++ b/src/core/lv_obj_tree.c @@ -144,9 +144,9 @@ void lv_obj_set_parent(lv_obj_t * obj, lv_obj_t * parent) lv_point_t old_pos; old_pos.y = lv_obj_get_y(obj); - lv_bidi_dir_t new_base_dir = lv_obj_get_base_dir(parent); + lv_base_dir_t new_base_dir = lv_obj_get_style_base_dir(parent, LV_PART_MAIN); - if(new_base_dir != LV_BIDI_DIR_RTL) old_pos.x = lv_obj_get_x(obj); + if(new_base_dir != LV_BASE_DIR_RTL) old_pos.x = lv_obj_get_x(obj); else old_pos.x = old_parent->coords.x2 - obj->coords.x2; /*Remove the object from the old parent's child list*/ @@ -169,7 +169,7 @@ void lv_obj_set_parent(lv_obj_t * obj, lv_obj_t * parent) obj->parent = parent; - if(new_base_dir != LV_BIDI_DIR_RTL) { + if(new_base_dir != LV_BASE_DIR_RTL) { lv_obj_set_pos(obj, old_pos.x, old_pos.y); } else { diff --git a/src/draw/lv_draw_label.c b/src/draw/lv_draw_label.c index bc99cd577..77ed63d78 100644 --- a/src/draw/lv_draw_label.c +++ b/src/draw/lv_draw_label.c @@ -98,7 +98,7 @@ LV_ATTRIBUTE_FAST_MEM void lv_draw_label_dsc_init(lv_draw_label_dsc_t * dsc) dsc->sel_end = LV_DRAW_LABEL_NO_TXT_SEL; dsc->sel_color = lv_color_black(); dsc->sel_bg_color = lv_palette_main(LV_PALETTE_BLUE); - dsc->bidi_dir = LV_BIDI_DIR_LTR; + dsc->bidi_dir = LV_BASE_DIR_LTR; } /** diff --git a/src/draw/lv_draw_label.h b/src/draw/lv_draw_label.h index 9cc7abb5f..930a89ef7 100644 --- a/src/draw/lv_draw_label.h +++ b/src/draw/lv_draw_label.h @@ -39,7 +39,7 @@ typedef struct { lv_coord_t ofs_x; lv_coord_t ofs_y; lv_opa_t opa; - lv_bidi_dir_t bidi_dir; + lv_base_dir_t bidi_dir; lv_text_flag_t flag; lv_text_align_t align :2; lv_text_decor_t decor : 3; diff --git a/src/extra/layouts/flex/lv_flex.c b/src/extra/layouts/flex/lv_flex.c index 34ab7f3a2..9cb91c3ac 100644 --- a/src/extra/layouts/flex/lv_flex.c +++ b/src/extra/layouts/flex/lv_flex.c @@ -133,7 +133,7 @@ static void flex_update(lv_obj_t * cont, void * user_data) f.cross_place = lv_obj_get_style_flex_cross_place(cont, LV_PART_MAIN); f.track_place = lv_obj_get_style_flex_track_place(cont, LV_PART_MAIN); - bool rtl = lv_obj_get_base_dir(cont) == LV_BIDI_DIR_RTL ? true : false; + bool rtl = lv_obj_get_style_base_dir(cont, LV_PART_MAIN) == LV_BASE_DIR_RTL ? true : false; lv_coord_t track_gap = !f.row ? lv_obj_get_style_pad_column(cont, LV_PART_MAIN) : lv_obj_get_style_pad_row(cont, LV_PART_MAIN); lv_coord_t item_gap = f.row ? lv_obj_get_style_pad_column(cont, LV_PART_MAIN) : lv_obj_get_style_pad_row(cont, LV_PART_MAIN); lv_coord_t max_main_size = (f.row ? lv_obj_get_content_width(cont) : lv_obj_get_content_height(cont)); @@ -345,7 +345,7 @@ static void children_repos(lv_obj_t * cont, flex_t * f, int32_t item_first_id, i } - bool rtl = lv_obj_get_base_dir(cont) == LV_BIDI_DIR_RTL ? true : false; + bool rtl = lv_obj_get_style_base_dir(cont, LV_PART_MAIN) == LV_BASE_DIR_RTL ? true : false; lv_coord_t main_pos = 0; diff --git a/src/extra/layouts/grid/lv_grid.c b/src/extra/layouts/grid/lv_grid.c index de9dee618..c64d455e3 100644 --- a/src/extra/layouts/grid/lv_grid.c +++ b/src/extra/layouts/grid/lv_grid.c @@ -204,7 +204,7 @@ static void calc(struct _lv_obj_t * cont, _lv_grid_calc_t * calc_out) lv_coord_t col_gap = lv_obj_get_style_pad_column(cont, LV_PART_MAIN); lv_coord_t row_gap = lv_obj_get_style_pad_row(cont, LV_PART_MAIN); - bool rev = lv_obj_get_base_dir(cont) == LV_BIDI_DIR_RTL ? true : false; + bool rev = lv_obj_get_style_base_dir(cont, LV_PART_MAIN) == LV_BASE_DIR_RTL ? true : false; lv_coord_t w_set = lv_obj_get_style_width(cont, LV_PART_MAIN); lv_coord_t h_set = lv_obj_get_style_height(cont, LV_PART_MAIN); @@ -399,7 +399,7 @@ static void item_repos(lv_obj_t * item, _lv_grid_calc_t * c, item_repos_hint_t * /*If the item has RTL base dir switch start and end*/ - if(lv_obj_get_base_dir(item) == LV_BIDI_DIR_RTL) { + if(lv_obj_get_style_base_dir(item, LV_PART_MAIN) == LV_BASE_DIR_RTL) { if(col_align == LV_GRID_ALIGN_START) col_align = LV_GRID_ALIGN_END; else if(col_align == LV_GRID_ALIGN_END) col_align = LV_GRID_ALIGN_START; } diff --git a/src/extra/widgets/keyboard/lv_keyboard.c b/src/extra/widgets/keyboard/lv_keyboard.c index eff7978dd..45434f8fd 100644 --- a/src/extra/widgets/keyboard/lv_keyboard.c +++ b/src/extra/widgets/keyboard/lv_keyboard.c @@ -329,7 +329,7 @@ static void lv_keyboard_constructor(const lv_obj_class_t * class_p, lv_obj_t * o lv_obj_align(obj, LV_ALIGN_BOTTOM_MID, 0, 0); lv_obj_add_event_cb(obj, lv_keyboard_def_event_cb, LV_EVENT_VALUE_CHANGED, NULL); - lv_obj_set_base_dir(obj, LV_BIDI_DIR_LTR); + lv_obj_set_style_base_dir(obj, LV_BASE_DIR_LTR, 0); lv_btnmatrix_set_map(obj, kb_map[keyboard->mode]); lv_btnmatrix_set_ctrl_map(obj, kb_ctrl[keyboard->mode]); diff --git a/src/lv_conf_internal.h b/src/lv_conf_internal.h index 6b1b9a24a..edf4a76cf 100644 --- a/src/lv_conf_internal.h +++ b/src/lv_conf_internal.h @@ -1036,14 +1036,14 @@ e.g. "stm32f769xx.h" or "stm32f429xx.h"*/ #endif #if LV_USE_BIDI /*Set the default direction. Supported values: - *`LV_BIDI_DIR_LTR` Left-to-Right - *`LV_BIDI_DIR_RTL` Right-to-Left - *`LV_BIDI_DIR_AUTO` detect texts base direction*/ + *`LV_BASE_DIR_LTR` Left-to-Right + *`LV_BASE_DIR_RTL` Right-to-Left + *`LV_BASE_DIR_AUTO` detect texts base direction*/ #ifndef LV_BIDI_BASE_DIR_DEF # ifdef CONFIG_LV_BIDI_BASE_DIR_DEF # define LV_BIDI_BASE_DIR_DEF CONFIG_LV_BIDI_BASE_DIR_DEF # else -# define LV_BIDI_BASE_DIR_DEF LV_BIDI_DIR_AUTO +# define LV_BIDI_BASE_DIR_DEF LV_BASE_DIR_AUTO # endif #endif #endif diff --git a/src/lv_conf_kconfig.h b/src/lv_conf_kconfig.h index 805bd2907..1881b0ac4 100644 --- a/src/lv_conf_kconfig.h +++ b/src/lv_conf_kconfig.h @@ -131,12 +131,12 @@ extern "C" { *-----------------*/ #ifndef LV_BIDI_BASE_DIR_DEF -#ifdef CONFIG_LV_BIDI_DIR_LTR -#define CONFIG_LV_BIDI_BASE_DIR_DEF LV_BIDI_DIR_LTR -#elif defined CONFIG_LV_BIDI_DIR_RTL -#define CONFIG_LV_BIDI_BASE_DIR_DEF LV_BIDI_DIR_RTL -#elif defined CONFIG_LV_BIDI_DIR_AUTO -#define CONFIG_LV_BIDI_BASE_DIR_DEF LV_BIDI_DIR_AUTO +#ifdef CONFIG_LV_BASE_DIR_LTR +#define CONFIG_LV_BIDI_BASE_DIR_DEF LV_BASE_DIR_LTR +#elif defined CONFIG_LV_BASE_DIR_RTL +#define CONFIG_LV_BIDI_BASE_DIR_DEF LV_BASE_DIR_RTL +#elif defined CONFIG_LV_BASE_DIR_AUTO +#define CONFIG_LV_BIDI_BASE_DIR_DEF LV_BASE_DIR_AUTO #endif #endif diff --git a/src/misc/lv_bidi.c b/src/misc/lv_bidi.c index 4a6f8fba1..906338348 100644 --- a/src/misc/lv_bidi.c +++ b/src/misc/lv_bidi.c @@ -28,7 +28,7 @@ **********************/ typedef struct { uint32_t bracklet_pos; - lv_bidi_dir_t dir; + lv_base_dir_t dir; } bracket_stack_t; /********************** @@ -36,18 +36,18 @@ typedef struct { **********************/ static uint32_t lv_bidi_get_next_paragraph(const char * txt); -static lv_bidi_dir_t lv_bidi_get_letter_dir(uint32_t letter); +static lv_base_dir_t lv_bidi_get_letter_dir(uint32_t letter); static bool lv_bidi_letter_is_weak(uint32_t letter); static bool lv_bidi_letter_is_rtl(uint32_t letter); static bool lv_bidi_letter_is_neutral(uint32_t letter); -static lv_bidi_dir_t get_next_run(const char * txt, lv_bidi_dir_t base_dir, uint32_t max_len, uint32_t * len, +static lv_base_dir_t get_next_run(const char * txt, lv_base_dir_t base_dir, uint32_t max_len, uint32_t * len, uint16_t * pos_conv_len); static void rtl_reverse(char * dest, const char * src, uint32_t len, uint16_t * pos_conv_out, uint16_t pos_conv_rd_base, uint16_t pos_conv_len); static uint32_t char_change_to_pair(uint32_t letter); -static lv_bidi_dir_t bracket_process(const char * txt, uint32_t next_pos, uint32_t len, uint32_t letter, - lv_bidi_dir_t base_dir); +static lv_base_dir_t bracket_process(const char * txt, uint32_t next_pos, uint32_t len, uint32_t letter, + lv_base_dir_t base_dir); static void fill_pos_conv(uint16_t * out, uint16_t len, uint16_t index); static uint32_t get_txt_len(const char * txt, uint32_t max_len); @@ -72,11 +72,11 @@ static uint8_t br_stack_p; * Unicode Bidirectional Algorithm * @param str_in the text to process * @param str_out store the result here. Has the be `strlen(str_in)` length - * @param base_dir `LV_BIDI_DIR_LTR` or `LV_BIDI_DIR_RTL` + * @param base_dir `LV_BASE_DIR_LTR` or `LV_BASE_DIR_RTL` */ -void _lv_bidi_process(const char * str_in, char * str_out, lv_bidi_dir_t base_dir) +void _lv_bidi_process(const char * str_in, char * str_out, lv_base_dir_t base_dir) { - if(base_dir == LV_BIDI_DIR_AUTO) base_dir = _lv_bidi_detect_base_dir(str_in); + if(base_dir == LV_BASE_DIR_AUTO) base_dir = _lv_bidi_detect_base_dir(str_in); uint32_t par_start = 0; uint32_t par_len; @@ -103,22 +103,22 @@ void _lv_bidi_process(const char * str_in, char * str_out, lv_bidi_dir_t base_di /** * Auto-detect the direction of a text based on the first strong character * @param txt the text to process - * @return `LV_BIDI_DIR_LTR` or `LV_BIDI_DIR_RTL` + * @return `LV_BASE_DIR_LTR` or `LV_BASE_DIR_RTL` */ -lv_bidi_dir_t _lv_bidi_detect_base_dir(const char * txt) +lv_base_dir_t _lv_bidi_detect_base_dir(const char * txt) { uint32_t i = 0; uint32_t letter; while(txt[i] != '\0') { letter = _lv_txt_encoded_next(txt, &i); - lv_bidi_dir_t dir; + lv_base_dir_t dir; dir = lv_bidi_get_letter_dir(letter); - if(dir == LV_BIDI_DIR_RTL || dir == LV_BIDI_DIR_LTR) return dir; + if(dir == LV_BASE_DIR_RTL || dir == LV_BASE_DIR_LTR) return dir; } /*If there were no strong char earlier return with the default base dir*/ - if(LV_BIDI_BASE_DIR_DEF == LV_BIDI_DIR_AUTO) return LV_BIDI_DIR_LTR; + if(LV_BIDI_BASE_DIR_DEF == LV_BASE_DIR_AUTO) return LV_BASE_DIR_LTR; else return LV_BIDI_BASE_DIR_DEF; } @@ -129,12 +129,12 @@ lv_bidi_dir_t _lv_bidi_detect_base_dir(const char * txt) * If not required anymore has to freed with `lv_mem_free()` * Can be `NULL` is unused * @param len length of the line in character count - * @param base_dir base direction of the text: `LV_BIDI_DIR_LTR` or `LV_BIDI_DIR_RTL` + * @param base_dir base direction of the text: `LV_BASE_DIR_LTR` or `LV_BASE_DIR_RTL` * @param visual_pos the visual character position which logical position should be get * @param is_rtl tell the char at `visual_pos` is RTL or LTR context * @return the logical character position */ -uint16_t _lv_bidi_get_logical_pos(const char * str_in, char ** bidi_txt, uint32_t len, lv_bidi_dir_t base_dir, +uint16_t _lv_bidi_get_logical_pos(const char * str_in, char ** bidi_txt, uint32_t len, lv_base_dir_t base_dir, uint32_t visual_pos, bool * is_rtl) { uint32_t pos_conv_len = get_txt_len(str_in, len); @@ -166,12 +166,12 @@ uint16_t _lv_bidi_get_logical_pos(const char * str_in, char ** bidi_txt, uint32_ * If not required anymore has to freed with `lv_mem_free()` * Can be `NULL` is unused * @param len length of the line in character count - * @param base_dir base direction of the text: `LV_BIDI_DIR_LTR` or `LV_BIDI_DIR_RTL` + * @param base_dir base direction of the text: `LV_BASE_DIR_LTR` or `LV_BASE_DIR_RTL` * @param logical_pos the logical character position which visual position should be get * @param is_rtl tell the char at `logical_pos` is RTL or LTR context * @return the visual character position */ -uint16_t _lv_bidi_get_visual_pos(const char * str_in, char ** bidi_txt, uint16_t len, lv_bidi_dir_t base_dir, +uint16_t _lv_bidi_get_visual_pos(const char * str_in, char ** bidi_txt, uint16_t len, lv_base_dir_t base_dir, uint32_t logical_pos, bool * is_rtl) { uint32_t pos_conv_len = get_txt_len(str_in, len); @@ -213,19 +213,19 @@ uint16_t _lv_bidi_get_visual_pos(const char * str_in, char ** bidi_txt, uint16_t * Can be `NULL` is unused * @param pos_conv_len length of `pos_conv_out` in element count */ -void _lv_bidi_process_paragraph(const char * str_in, char * str_out, uint32_t len, lv_bidi_dir_t base_dir, +void _lv_bidi_process_paragraph(const char * str_in, char * str_out, uint32_t len, lv_base_dir_t base_dir, uint16_t * pos_conv_out, uint16_t pos_conv_len) { uint32_t run_len = 0; - lv_bidi_dir_t run_dir; + lv_base_dir_t run_dir; uint32_t rd = 0; uint32_t wr; uint16_t pos_conv_run_len = 0; uint16_t pos_conv_rd = 0; uint16_t pos_conv_wr; - if(base_dir == LV_BIDI_DIR_AUTO) base_dir = _lv_bidi_detect_base_dir(str_in); - if(base_dir == LV_BIDI_DIR_RTL) { + if(base_dir == LV_BASE_DIR_AUTO) base_dir = _lv_bidi_detect_base_dir(str_in); + if(base_dir == LV_BASE_DIR_RTL) { wr = len; pos_conv_wr = pos_conv_len; } @@ -236,7 +236,7 @@ void _lv_bidi_process_paragraph(const char * str_in, char * str_out, uint32_t le if(str_out) str_out[len] = '\0'; - lv_bidi_dir_t dir = base_dir; + lv_base_dir_t dir = base_dir; /*Empty the bracket stack*/ br_stack_p = 0; @@ -246,8 +246,8 @@ void _lv_bidi_process_paragraph(const char * str_in, char * str_out, uint32_t le uint32_t letter = _lv_txt_encoded_next(str_in, &rd); pos_conv_rd++; dir = lv_bidi_get_letter_dir(letter); - if(dir == LV_BIDI_DIR_NEUTRAL) dir = bracket_process(str_in, rd, len, letter, base_dir); - if(dir != LV_BIDI_DIR_NEUTRAL && dir != LV_BIDI_DIR_WEAK) break; + if(dir == LV_BASE_DIR_NEUTRAL) dir = bracket_process(str_in, rd, len, letter, base_dir); + if(dir != LV_BASE_DIR_NEUTRAL && dir != LV_BASE_DIR_WEAK) break; } if(rd && str_in[rd] != '\0') { @@ -256,7 +256,7 @@ void _lv_bidi_process_paragraph(const char * str_in, char * str_out, uint32_t le } if(rd) { - if(base_dir == LV_BIDI_DIR_LTR) { + if(base_dir == LV_BASE_DIR_LTR) { if(str_out) { lv_memcpy(&str_out[wr], str_in, rd); wr += rd; @@ -279,8 +279,8 @@ void _lv_bidi_process_paragraph(const char * str_in, char * str_out, uint32_t le while(rd < len && str_in[rd]) { run_dir = get_next_run(&str_in[rd], base_dir, len - rd, &run_len, &pos_conv_run_len); - if(base_dir == LV_BIDI_DIR_LTR) { - if(run_dir == LV_BIDI_DIR_LTR) { + if(base_dir == LV_BASE_DIR_LTR) { + if(run_dir == LV_BASE_DIR_LTR) { if(str_out) lv_memcpy(&str_out[wr], &str_in[rd], run_len); if(pos_conv_out) fill_pos_conv(&pos_conv_out[pos_conv_wr], pos_conv_run_len, pos_conv_rd); } @@ -292,7 +292,7 @@ void _lv_bidi_process_paragraph(const char * str_in, char * str_out, uint32_t le else { wr -= run_len; pos_conv_wr -= pos_conv_run_len; - if(run_dir == LV_BIDI_DIR_LTR) { + if(run_dir == LV_BASE_DIR_LTR) { if(str_out) lv_memcpy(&str_out[wr], &str_in[rd], run_len); if(pos_conv_out) fill_pos_conv(&pos_conv_out[pos_conv_wr], pos_conv_run_len, pos_conv_rd); } @@ -330,15 +330,15 @@ static uint32_t lv_bidi_get_next_paragraph(const char * txt) /** * Get the direction of a character * @param letter an Unicode character - * @return `LV_BIDI_DIR_RTL/LTR/WEAK/NEUTRAL` + * @return `LV_BASE_DIR_RTL/LTR/WEAK/NEUTRAL` */ -static lv_bidi_dir_t lv_bidi_get_letter_dir(uint32_t letter) +static lv_base_dir_t lv_bidi_get_letter_dir(uint32_t letter) { - if(lv_bidi_letter_is_rtl(letter)) return LV_BIDI_DIR_RTL; - if(lv_bidi_letter_is_neutral(letter)) return LV_BIDI_DIR_NEUTRAL; - if(lv_bidi_letter_is_weak(letter)) return LV_BIDI_DIR_WEAK; + if(lv_bidi_letter_is_rtl(letter)) return LV_BASE_DIR_RTL; + if(lv_bidi_letter_is_neutral(letter)) return LV_BASE_DIR_NEUTRAL; + if(lv_bidi_letter_is_weak(letter)) return LV_BASE_DIR_WEAK; - return LV_BIDI_DIR_LTR; + return LV_BASE_DIR_LTR; } /** * Tell whether a character is weak or not @@ -415,7 +415,7 @@ static void fill_pos_conv(uint16_t * out, uint16_t len, uint16_t index) } } -static lv_bidi_dir_t get_next_run(const char * txt, lv_bidi_dir_t base_dir, uint32_t max_len, uint32_t * len, +static lv_base_dir_t get_next_run(const char * txt, lv_base_dir_t base_dir, uint32_t max_len, uint32_t * len, uint16_t * pos_conv_len) { uint32_t i = 0; @@ -424,15 +424,15 @@ static lv_bidi_dir_t get_next_run(const char * txt, lv_bidi_dir_t base_dir, uint uint16_t pos_conv_i = 0; letter = _lv_txt_encoded_next(txt, NULL); - lv_bidi_dir_t dir = lv_bidi_get_letter_dir(letter); - if(dir == LV_BIDI_DIR_NEUTRAL) dir = bracket_process(txt, 0, max_len, letter, base_dir); + lv_base_dir_t dir = lv_bidi_get_letter_dir(letter); + if(dir == LV_BASE_DIR_NEUTRAL) dir = bracket_process(txt, 0, max_len, letter, base_dir); /*Find the first strong char. Skip the neutrals*/ - while(dir == LV_BIDI_DIR_NEUTRAL || dir == LV_BIDI_DIR_WEAK) { + while(dir == LV_BASE_DIR_NEUTRAL || dir == LV_BASE_DIR_WEAK) { letter = _lv_txt_encoded_next(txt, &i); pos_conv_i++; dir = lv_bidi_get_letter_dir(letter); - if(dir == LV_BIDI_DIR_NEUTRAL) dir = bracket_process(txt, i, max_len, letter, base_dir); + if(dir == LV_BASE_DIR_NEUTRAL) dir = bracket_process(txt, i, max_len, letter, base_dir); if(i >= max_len || txt[i] == '\0' || txt[i] == '\n' || txt[i] == '\r') { *len = i; @@ -441,7 +441,7 @@ static lv_bidi_dir_t get_next_run(const char * txt, lv_bidi_dir_t base_dir, uint } } - lv_bidi_dir_t run_dir = dir; + lv_base_dir_t run_dir = dir; uint32_t i_prev = i; uint32_t i_last_strong = i; @@ -449,15 +449,15 @@ static lv_bidi_dir_t get_next_run(const char * txt, lv_bidi_dir_t base_dir, uint uint16_t pos_conv_i_last_strong = pos_conv_i; /*Find the next char which has different direction*/ - lv_bidi_dir_t next_dir = base_dir; + lv_base_dir_t next_dir = base_dir; while(i_prev < max_len && txt[i] != '\0' && txt[i] != '\n' && txt[i] != '\r') { letter = _lv_txt_encoded_next(txt, &i); pos_conv_i++; next_dir = lv_bidi_get_letter_dir(letter); - if(next_dir == LV_BIDI_DIR_NEUTRAL) next_dir = bracket_process(txt, i, max_len, letter, base_dir); + if(next_dir == LV_BASE_DIR_NEUTRAL) next_dir = bracket_process(txt, i, max_len, letter, base_dir); /*New dir found?*/ - if((next_dir == LV_BIDI_DIR_RTL || next_dir == LV_BIDI_DIR_LTR) && next_dir != run_dir) { + if((next_dir == LV_BASE_DIR_RTL || next_dir == LV_BASE_DIR_LTR) && next_dir != run_dir) { /*Include neutrals if `run_dir == base_dir`*/ if(run_dir == base_dir) { *len = i_prev; @@ -472,7 +472,7 @@ static lv_bidi_dir_t get_next_run(const char * txt, lv_bidi_dir_t base_dir, uint return run_dir; } - if(next_dir != LV_BIDI_DIR_NEUTRAL) { + if(next_dir != LV_BASE_DIR_NEUTRAL) { i_last_strong = i; pos_conv_i_last_strong = pos_conv_i; } @@ -580,10 +580,10 @@ static uint32_t char_change_to_pair(uint32_t letter) return letter; } -static lv_bidi_dir_t bracket_process(const char * txt, uint32_t next_pos, uint32_t len, uint32_t letter, - lv_bidi_dir_t base_dir) +static lv_base_dir_t bracket_process(const char * txt, uint32_t next_pos, uint32_t len, uint32_t letter, + lv_base_dir_t base_dir) { - lv_bidi_dir_t bracket_dir = LV_BIDI_DIR_NEUTRAL; + lv_base_dir_t bracket_dir = LV_BASE_DIR_NEUTRAL; uint8_t i; /*Is the letter an opening bracket?*/ @@ -600,7 +600,7 @@ static lv_bidi_dir_t bracket_process(const char * txt, uint32_t next_pos, uint32 } else { /*Save the dir*/ - lv_bidi_dir_t letter_dir = lv_bidi_get_letter_dir(letter_next); + lv_base_dir_t letter_dir = lv_bidi_get_letter_dir(letter_next); if(letter_dir == base_dir) { bracket_dir = base_dir; } @@ -608,25 +608,25 @@ static lv_bidi_dir_t bracket_process(const char * txt, uint32_t next_pos, uint32 } /*There were no matching closing bracket*/ - if(txt_i > len) return LV_BIDI_DIR_NEUTRAL; + if(txt_i > len) return LV_BASE_DIR_NEUTRAL; /*There where a strong char with base dir in the bracket so the dir is found.*/ - if(bracket_dir != LV_BIDI_DIR_NEUTRAL && bracket_dir != LV_BIDI_DIR_WEAK) break; + if(bracket_dir != LV_BASE_DIR_NEUTRAL && bracket_dir != LV_BASE_DIR_WEAK) break; /*If there were no matching strong chars in the brackets then check the previous chars*/ txt_i = next_pos; if(txt_i) _lv_txt_encoded_prev(txt, &txt_i); while(txt_i > 0) { uint32_t letter_next = _lv_txt_encoded_prev(txt, &txt_i); - lv_bidi_dir_t letter_dir = lv_bidi_get_letter_dir(letter_next); - if(letter_dir == LV_BIDI_DIR_LTR || letter_dir == LV_BIDI_DIR_RTL) { + lv_base_dir_t letter_dir = lv_bidi_get_letter_dir(letter_next); + if(letter_dir == LV_BASE_DIR_LTR || letter_dir == LV_BASE_DIR_RTL) { bracket_dir = letter_dir; break; } } /*There where a previous strong char which can be used*/ - if(bracket_dir != LV_BIDI_DIR_NEUTRAL) break; + if(bracket_dir != LV_BASE_DIR_NEUTRAL) break; /*There were no strong chars before the bracket, so use the base dir.*/ if(txt_i == 0) bracket_dir = base_dir; @@ -638,7 +638,7 @@ static lv_bidi_dir_t bracket_process(const char * txt, uint32_t next_pos, uint32 /*The letter was an opening bracket*/ if(bracket_left[i] != '\0') { - if(bracket_dir == LV_BIDI_DIR_NEUTRAL || br_stack_p == LV_BIDI_BRACKLET_DEPTH) return LV_BIDI_DIR_NEUTRAL; + if(bracket_dir == LV_BASE_DIR_NEUTRAL || br_stack_p == LV_BIDI_BRACKLET_DEPTH) return LV_BASE_DIR_NEUTRAL; br_stack[br_stack_p].bracklet_pos = i; br_stack[br_stack_p].dir = bracket_dir; @@ -655,7 +655,7 @@ static lv_bidi_dir_t bracket_process(const char * txt, uint32_t next_pos, uint32 } } - return LV_BIDI_DIR_NEUTRAL; + return LV_BASE_DIR_NEUTRAL; } #endif /*LV_USE_BIDI*/ diff --git a/src/misc/lv_bidi.h b/src/misc/lv_bidi.h index 826f1c0d8..d3a646e7d 100644 --- a/src/misc/lv_bidi.h +++ b/src/misc/lv_bidi.h @@ -30,17 +30,15 @@ extern "C" { * TYPEDEFS **********************/ enum { - /*The first 4 values are stored in `lv_obj_t` on 2 bits*/ - LV_BIDI_DIR_LTR = 0x00, - LV_BIDI_DIR_RTL = 0x01, - LV_BIDI_DIR_AUTO = 0x02, - LV_BIDI_DIR_INHERIT = 0x03, + LV_BASE_DIR_LTR = 0x00, + LV_BASE_DIR_RTL = 0x01, + LV_BASE_DIR_AUTO = 0x02, - LV_BIDI_DIR_NEUTRAL = 0x20, - LV_BIDI_DIR_WEAK = 0x21, + LV_BASE_DIR_NEUTRAL = 0x20, + LV_BASE_DIR_WEAK = 0x21, }; -typedef uint8_t lv_bidi_dir_t; +typedef uint8_t lv_base_dir_t; /********************** * GLOBAL PROTOTYPES @@ -52,16 +50,16 @@ typedef uint8_t lv_bidi_dir_t; * Unicode Bidirectional Algorithm * @param str_in the text to process * @param str_out store the result here. Has the be `strlen(str_in)` length - * @param base_dir `LV_BIDI_DIR_LTR` or `LV_BIDI_DIR_RTL` + * @param base_dir `LV_BASE_DIR_LTR` or `LV_BASE_DIR_RTL` */ -void _lv_bidi_process(const char * str_in, char * str_out, lv_bidi_dir_t base_dir); +void _lv_bidi_process(const char * str_in, char * str_out, lv_base_dir_t base_dir); /** * Auto-detect the direction of a text based on the first strong character * @param txt the text to process - * @return `LV_BIDI_DIR_LTR` or `LV_BIDI_DIR_RTL` + * @return `LV_BASE_DIR_LTR` or `LV_BASE_DIR_RTL` */ -lv_bidi_dir_t _lv_bidi_detect_base_dir(const char * txt); +lv_base_dir_t _lv_bidi_detect_base_dir(const char * txt); /** * Get the logical position of a character in a line @@ -70,12 +68,12 @@ lv_bidi_dir_t _lv_bidi_detect_base_dir(const char * txt); * If not required anymore has to freed with `lv_mem_free()` * Can be `NULL` is unused * @param len length of the line in character count - * @param base_dir base direction of the text: `LV_BIDI_DIR_LTR` or `LV_BIDI_DIR_RTL` + * @param base_dir base direction of the text: `LV_BASE_DIR_LTR` or `LV_BASE_DIR_RTL` * @param visual_pos the visual character position which logical position should be get * @param is_rtl tell the char at `visual_pos` is RTL or LTR context * @return the logical character position */ -uint16_t _lv_bidi_get_logical_pos(const char * str_in, char ** bidi_txt, uint32_t len, lv_bidi_dir_t base_dir, +uint16_t _lv_bidi_get_logical_pos(const char * str_in, char ** bidi_txt, uint32_t len, lv_base_dir_t base_dir, uint32_t visual_pos, bool * is_rtl); /** @@ -85,12 +83,12 @@ uint16_t _lv_bidi_get_logical_pos(const char * str_in, char ** bidi_txt, uint32_ * If not required anymore has to freed with `lv_mem_free()` * Can be `NULL` is unused * @param len length of the line in character count - * @param base_dir base direction of the text: `LV_BIDI_DIR_LTR` or `LV_BIDI_DIR_RTL` + * @param base_dir base direction of the text: `LV_BASE_DIR_LTR` or `LV_BASE_DIR_RTL` * @param logical_pos the logical character position which visual position should be get * @param is_rtl tell the char at `logical_pos` is RTL or LTR context * @return the visual character position */ -uint16_t _lv_bidi_get_visual_pos(const char * str_in, char ** bidi_txt, uint16_t len, lv_bidi_dir_t base_dir, +uint16_t _lv_bidi_get_visual_pos(const char * str_in, char ** bidi_txt, uint16_t len, lv_base_dir_t base_dir, uint32_t logical_pos, bool * is_rtl); /** @@ -103,7 +101,7 @@ uint16_t _lv_bidi_get_visual_pos(const char * str_in, char ** bidi_txt, uint16_t * Can be `NULL` is unused * @param pos_conv_len length of `pos_conv_out` in element count */ -void _lv_bidi_process_paragraph(const char * str_in, char * str_out, uint32_t len, lv_bidi_dir_t base_dir, +void _lv_bidi_process_paragraph(const char * str_in, char * str_out, uint32_t len, lv_base_dir_t base_dir, uint16_t * pos_conv_out, uint16_t pos_conv_len); /********************** diff --git a/src/misc/lv_style.h b/src/misc/lv_style.h index 72fb5512c..436e551d5 100644 --- a/src/misc/lv_style.h +++ b/src/misc/lv_style.h @@ -21,6 +21,7 @@ extern "C" { #include "lv_txt.h" #include "lv_types.h" #include "lv_assert.h" +#include "lv_bidi.h" /********************* * DEFINES @@ -118,22 +119,21 @@ typedef enum { LV_STYLE_PROP_INV = 0, /*Group 0*/ - LV_STYLE_RADIUS = 1, - LV_STYLE_CLIP_CORNER = 2, - LV_STYLE_TRANSFORM_WIDTH = 3 | LV_STYLE_PROP_EXT_DRAW, - LV_STYLE_TRANSFORM_HEIGHT = 4 | LV_STYLE_PROP_EXT_DRAW, - LV_STYLE_TRANSLATE_X = 5 | LV_STYLE_PROP_LAYOUT_REFR | LV_STYLE_PROP_PARENT_LAYOUT_REFR, - LV_STYLE_TRANSLATE_Y = 6 | LV_STYLE_PROP_LAYOUT_REFR | LV_STYLE_PROP_PARENT_LAYOUT_REFR, - LV_STYLE_TRANSFORM_ZOOM = 7 | LV_STYLE_PROP_EXT_DRAW, - LV_STYLE_TRANSFORM_ANGLE = 8 | LV_STYLE_PROP_EXT_DRAW, - LV_STYLE_OPA = 9 | LV_STYLE_PROP_INHERIT, - - LV_STYLE_COLOR_FILTER_DSC = 10, - LV_STYLE_COLOR_FILTER_OPA = 11, - LV_STYLE_ANIM_TIME = 12, - LV_STYLE_ANIM_SPEED = 12, - LV_STYLE_TRANSITION = 14, - LV_STYLE_BLEND_MODE = 15, + LV_STYLE_WIDTH = 1 | LV_STYLE_PROP_LAYOUT_REFR, + LV_STYLE_MIN_WIDTH = 2 | LV_STYLE_PROP_LAYOUT_REFR, + LV_STYLE_MAX_WIDTH = 3 | LV_STYLE_PROP_LAYOUT_REFR, + LV_STYLE_HEIGHT = 4 | LV_STYLE_PROP_LAYOUT_REFR, + LV_STYLE_MIN_HEIGHT = 5 | LV_STYLE_PROP_LAYOUT_REFR, + LV_STYLE_MAX_HEIGHT = 6 | LV_STYLE_PROP_LAYOUT_REFR, + LV_STYLE_X = 7 | LV_STYLE_PROP_LAYOUT_REFR, + LV_STYLE_Y = 8 | LV_STYLE_PROP_LAYOUT_REFR, + LV_STYLE_ALIGN = 9 | LV_STYLE_PROP_LAYOUT_REFR, + LV_STYLE_TRANSFORM_WIDTH = 10 | LV_STYLE_PROP_EXT_DRAW, + LV_STYLE_TRANSFORM_HEIGHT = 11 | LV_STYLE_PROP_EXT_DRAW, + LV_STYLE_TRANSLATE_X = 12 | LV_STYLE_PROP_LAYOUT_REFR | LV_STYLE_PROP_PARENT_LAYOUT_REFR, + LV_STYLE_TRANSLATE_Y = 13 | LV_STYLE_PROP_LAYOUT_REFR | LV_STYLE_PROP_PARENT_LAYOUT_REFR, + LV_STYLE_TRANSFORM_ZOOM = 14 | LV_STYLE_PROP_EXT_DRAW, + LV_STYLE_TRANSFORM_ANGLE = 15 | LV_STYLE_PROP_EXT_DRAW, /*Group 1*/ LV_STYLE_PAD_TOP = 16 | LV_STYLE_PROP_LAYOUT_REFR, @@ -143,17 +143,6 @@ typedef enum { LV_STYLE_PAD_ROW = 20 | LV_STYLE_PROP_LAYOUT_REFR, LV_STYLE_PAD_COLUMN = 21 | LV_STYLE_PROP_LAYOUT_REFR, - LV_STYLE_WIDTH = 22 | LV_STYLE_PROP_LAYOUT_REFR, - LV_STYLE_MIN_WIDTH = 23 | LV_STYLE_PROP_LAYOUT_REFR, - LV_STYLE_MAX_WIDTH = 24 | LV_STYLE_PROP_LAYOUT_REFR, - LV_STYLE_HEIGHT = 25 | LV_STYLE_PROP_LAYOUT_REFR, - LV_STYLE_MIN_HEIGHT = 26 | LV_STYLE_PROP_LAYOUT_REFR, - LV_STYLE_MAX_HEIGHT = 27 | LV_STYLE_PROP_LAYOUT_REFR, - LV_STYLE_X = 28 | LV_STYLE_PROP_LAYOUT_REFR, - LV_STYLE_Y = 29 | LV_STYLE_PROP_LAYOUT_REFR, - LV_STYLE_LAYOUT = 30 | LV_STYLE_PROP_LAYOUT_REFR, - LV_STYLE_ALIGN = 31 | LV_STYLE_PROP_LAYOUT_REFR, - /*Group 2*/ LV_STYLE_BG_COLOR = 32, LV_STYLE_BG_COLOR_FILTERED = 32 | LV_STYLE_PROP_FILTER, @@ -224,6 +213,19 @@ typedef enum { LV_STYLE_TEXT_DECOR = 92 | LV_STYLE_PROP_INHERIT, LV_STYLE_TEXT_ALIGN = 93 | LV_STYLE_PROP_INHERIT | LV_STYLE_PROP_LAYOUT_REFR, + /*Group 6*/ + LV_STYLE_RADIUS = 96, + LV_STYLE_CLIP_CORNER = 97, + LV_STYLE_OPA = 98 | LV_STYLE_PROP_INHERIT, + LV_STYLE_COLOR_FILTER_DSC = 99, + LV_STYLE_COLOR_FILTER_OPA = 100, + LV_STYLE_ANIM_TIME = 101, + LV_STYLE_ANIM_SPEED = 102, + LV_STYLE_TRANSITION = 103, + LV_STYLE_BLEND_MODE = 104, + LV_STYLE_LAYOUT = 105 | LV_STYLE_PROP_LAYOUT_REFR, + LV_STYLE_BASE_DIR = 106 | LV_STYLE_PROP_INHERIT | LV_STYLE_PROP_LAYOUT_REFR, + _LV_STYLE_LAST_BUILT_IN_PROP = 111, LV_STYLE_PROP_ANY = 0xFFFF diff --git a/src/misc/lv_style_gen.h b/src/misc/lv_style_gen.h index 6e198d9f6..e876c9fa5 100644 --- a/src/misc/lv_style_gen.h +++ b/src/misc/lv_style_gen.h @@ -1,339 +1,3 @@ -static inline void lv_style_set_radius(lv_style_t * style, lv_coord_t value) -{ - lv_style_value_t v = { - .num = (int32_t)value - }; - lv_style_set_prop(style, LV_STYLE_RADIUS, v); -} - -#define LV_STYLE_CONST_RADIUS(val) \ - { \ - .prop = LV_STYLE_RADIUS, \ - .value = { \ - .num = (int32_t)val \ - } \ - } - -static inline void lv_style_set_clip_corner(lv_style_t * style, bool value) -{ - lv_style_value_t v = { - .num = (int32_t)value - }; - lv_style_set_prop(style, LV_STYLE_CLIP_CORNER, v); -} - -#define LV_STYLE_CONST_CLIP_CORNER(val) \ - { \ - .prop = LV_STYLE_CLIP_CORNER, \ - .value = { \ - .num = (int32_t)val \ - } \ - } - -static inline void lv_style_set_transform_width(lv_style_t * style, lv_coord_t value) -{ - lv_style_value_t v = { - .num = (int32_t)value - }; - lv_style_set_prop(style, LV_STYLE_TRANSFORM_WIDTH, v); -} - -#define LV_STYLE_CONST_TRANSFORM_WIDTH(val) \ - { \ - .prop = LV_STYLE_TRANSFORM_WIDTH, \ - .value = { \ - .num = (int32_t)val \ - } \ - } - -static inline void lv_style_set_transform_height(lv_style_t * style, lv_coord_t value) -{ - lv_style_value_t v = { - .num = (int32_t)value - }; - lv_style_set_prop(style, LV_STYLE_TRANSFORM_HEIGHT, v); -} - -#define LV_STYLE_CONST_TRANSFORM_HEIGHT(val) \ - { \ - .prop = LV_STYLE_TRANSFORM_HEIGHT, \ - .value = { \ - .num = (int32_t)val \ - } \ - } - -static inline void lv_style_set_translate_x(lv_style_t * style, lv_coord_t value) -{ - lv_style_value_t v = { - .num = (int32_t)value - }; - lv_style_set_prop(style, LV_STYLE_TRANSLATE_X, v); -} - -#define LV_STYLE_CONST_TRANSLATE_X(val) \ - { \ - .prop = LV_STYLE_TRANSLATE_X, \ - .value = { \ - .num = (int32_t)val \ - } \ - } - -static inline void lv_style_set_translate_y(lv_style_t * style, lv_coord_t value) -{ - lv_style_value_t v = { - .num = (int32_t)value - }; - lv_style_set_prop(style, LV_STYLE_TRANSLATE_Y, v); -} - -#define LV_STYLE_CONST_TRANSLATE_Y(val) \ - { \ - .prop = LV_STYLE_TRANSLATE_Y, \ - .value = { \ - .num = (int32_t)val \ - } \ - } - -static inline void lv_style_set_transform_zoom(lv_style_t * style, lv_coord_t value) -{ - lv_style_value_t v = { - .num = (int32_t)value - }; - lv_style_set_prop(style, LV_STYLE_TRANSFORM_ZOOM, v); -} - -#define LV_STYLE_CONST_TRANSFORM_ZOOM(val) \ - { \ - .prop = LV_STYLE_TRANSFORM_ZOOM, \ - .value = { \ - .num = (int32_t)val \ - } \ - } - -static inline void lv_style_set_transform_angle(lv_style_t * style, lv_coord_t value) -{ - lv_style_value_t v = { - .num = (int32_t)value - }; - lv_style_set_prop(style, LV_STYLE_TRANSFORM_ANGLE, v); -} - -#define LV_STYLE_CONST_TRANSFORM_ANGLE(val) \ - { \ - .prop = LV_STYLE_TRANSFORM_ANGLE, \ - .value = { \ - .num = (int32_t)val \ - } \ - } - -static inline void lv_style_set_opa(lv_style_t * style, lv_opa_t value) -{ - lv_style_value_t v = { - .num = (int32_t)value - }; - lv_style_set_prop(style, LV_STYLE_OPA, v); -} - -#define LV_STYLE_CONST_OPA(val) \ - { \ - .prop = LV_STYLE_OPA, \ - .value = { \ - .num = (int32_t)val \ - } \ - } - -static inline void lv_style_set_color_filter_dsc(lv_style_t * style, const lv_color_filter_dsc_t * value) -{ - lv_style_value_t v = { - .ptr = value - }; - lv_style_set_prop(style, LV_STYLE_COLOR_FILTER_DSC, v); -} - -#define LV_STYLE_CONST_COLOR_FILTER_DSC(val) \ - { \ - .prop = LV_STYLE_COLOR_FILTER_DSC, \ - .value = { \ - .ptr = val \ - } \ - } - -static inline void lv_style_set_color_filter_opa(lv_style_t * style, lv_opa_t value) -{ - lv_style_value_t v = { - .num = (int32_t)value - }; - lv_style_set_prop(style, LV_STYLE_COLOR_FILTER_OPA, v); -} - -#define LV_STYLE_CONST_COLOR_FILTER_OPA(val) \ - { \ - .prop = LV_STYLE_COLOR_FILTER_OPA, \ - .value = { \ - .num = (int32_t)val \ - } \ - } - -static inline void lv_style_set_anim_time(lv_style_t * style, uint32_t value) -{ - lv_style_value_t v = { - .num = (int32_t)value - }; - lv_style_set_prop(style, LV_STYLE_ANIM_TIME, v); -} - -#define LV_STYLE_CONST_ANIM_TIME(val) \ - { \ - .prop = LV_STYLE_ANIM_TIME, \ - .value = { \ - .num = (int32_t)val \ - } \ - } - -static inline void lv_style_set_anim_speed(lv_style_t * style, uint32_t value) -{ - lv_style_value_t v = { - .num = (int32_t)value - }; - lv_style_set_prop(style, LV_STYLE_ANIM_SPEED, v); -} - -#define LV_STYLE_CONST_ANIM_SPEED(val) \ - { \ - .prop = LV_STYLE_ANIM_SPEED, \ - .value = { \ - .num = (int32_t)val \ - } \ - } - -static inline void lv_style_set_transition(lv_style_t * style, const lv_style_transition_dsc_t * value) -{ - lv_style_value_t v = { - .ptr = value - }; - lv_style_set_prop(style, LV_STYLE_TRANSITION, v); -} - -#define LV_STYLE_CONST_TRANSITION(val) \ - { \ - .prop = LV_STYLE_TRANSITION, \ - .value = { \ - .ptr = val \ - } \ - } - -static inline void lv_style_set_blend_mode(lv_style_t * style, lv_blend_mode_t value) -{ - lv_style_value_t v = { - .num = (int32_t)value - }; - lv_style_set_prop(style, LV_STYLE_BLEND_MODE, v); -} - -#define LV_STYLE_CONST_BLEND_MODE(val) \ - { \ - .prop = LV_STYLE_BLEND_MODE, \ - .value = { \ - .num = (int32_t)val \ - } \ - } - -static inline void lv_style_set_pad_top(lv_style_t * style, lv_coord_t value) -{ - lv_style_value_t v = { - .num = (int32_t)value - }; - lv_style_set_prop(style, LV_STYLE_PAD_TOP, v); -} - -#define LV_STYLE_CONST_PAD_TOP(val) \ - { \ - .prop = LV_STYLE_PAD_TOP, \ - .value = { \ - .num = (int32_t)val \ - } \ - } - -static inline void lv_style_set_pad_bottom(lv_style_t * style, lv_coord_t value) -{ - lv_style_value_t v = { - .num = (int32_t)value - }; - lv_style_set_prop(style, LV_STYLE_PAD_BOTTOM, v); -} - -#define LV_STYLE_CONST_PAD_BOTTOM(val) \ - { \ - .prop = LV_STYLE_PAD_BOTTOM, \ - .value = { \ - .num = (int32_t)val \ - } \ - } - -static inline void lv_style_set_pad_left(lv_style_t * style, lv_coord_t value) -{ - lv_style_value_t v = { - .num = (int32_t)value - }; - lv_style_set_prop(style, LV_STYLE_PAD_LEFT, v); -} - -#define LV_STYLE_CONST_PAD_LEFT(val) \ - { \ - .prop = LV_STYLE_PAD_LEFT, \ - .value = { \ - .num = (int32_t)val \ - } \ - } - -static inline void lv_style_set_pad_right(lv_style_t * style, lv_coord_t value) -{ - lv_style_value_t v = { - .num = (int32_t)value - }; - lv_style_set_prop(style, LV_STYLE_PAD_RIGHT, v); -} - -#define LV_STYLE_CONST_PAD_RIGHT(val) \ - { \ - .prop = LV_STYLE_PAD_RIGHT, \ - .value = { \ - .num = (int32_t)val \ - } \ - } - -static inline void lv_style_set_pad_row(lv_style_t * style, lv_coord_t value) -{ - lv_style_value_t v = { - .num = (int32_t)value - }; - lv_style_set_prop(style, LV_STYLE_PAD_ROW, v); -} - -#define LV_STYLE_CONST_PAD_ROW(val) \ - { \ - .prop = LV_STYLE_PAD_ROW, \ - .value = { \ - .num = (int32_t)val \ - } \ - } - -static inline void lv_style_set_pad_column(lv_style_t * style, lv_coord_t value) -{ - lv_style_value_t v = { - .num = (int32_t)value - }; - lv_style_set_prop(style, LV_STYLE_PAD_COLUMN, v); -} - -#define LV_STYLE_CONST_PAD_COLUMN(val) \ - { \ - .prop = LV_STYLE_PAD_COLUMN, \ - .value = { \ - .num = (int32_t)val \ - } \ - } - static inline void lv_style_set_width(lv_style_t * style, lv_coord_t value) { lv_style_value_t v = { @@ -478,6 +142,342 @@ static inline void lv_style_set_align(lv_style_t * style, lv_align_t value) } \ } +static inline void lv_style_set_transform_width(lv_style_t * style, lv_coord_t value) +{ + lv_style_value_t v = { + .num = (int32_t)value + }; + lv_style_set_prop(style, LV_STYLE_TRANSFORM_WIDTH, v); +} + +#define LV_STYLE_CONST_TRANSFORM_WIDTH(val) \ + { \ + .prop = LV_STYLE_TRANSFORM_WIDTH, \ + .value = { \ + .num = (int32_t)val \ + } \ + } + +static inline void lv_style_set_transform_height(lv_style_t * style, lv_coord_t value) +{ + lv_style_value_t v = { + .num = (int32_t)value + }; + lv_style_set_prop(style, LV_STYLE_TRANSFORM_HEIGHT, v); +} + +#define LV_STYLE_CONST_TRANSFORM_HEIGHT(val) \ + { \ + .prop = LV_STYLE_TRANSFORM_HEIGHT, \ + .value = { \ + .num = (int32_t)val \ + } \ + } + +static inline void lv_style_set_translate_x(lv_style_t * style, lv_coord_t value) +{ + lv_style_value_t v = { + .num = (int32_t)value + }; + lv_style_set_prop(style, LV_STYLE_TRANSLATE_X, v); +} + +#define LV_STYLE_CONST_TRANSLATE_X(val) \ + { \ + .prop = LV_STYLE_TRANSLATE_X, \ + .value = { \ + .num = (int32_t)val \ + } \ + } + +static inline void lv_style_set_translate_y(lv_style_t * style, lv_coord_t value) +{ + lv_style_value_t v = { + .num = (int32_t)value + }; + lv_style_set_prop(style, LV_STYLE_TRANSLATE_Y, v); +} + +#define LV_STYLE_CONST_TRANSLATE_Y(val) \ + { \ + .prop = LV_STYLE_TRANSLATE_Y, \ + .value = { \ + .num = (int32_t)val \ + } \ + } + +static inline void lv_style_set_transform_zoom(lv_style_t * style, lv_coord_t value) +{ + lv_style_value_t v = { + .num = (int32_t)value + }; + lv_style_set_prop(style, LV_STYLE_TRANSFORM_ZOOM, v); +} + +#define LV_STYLE_CONST_TRANSFORM_ZOOM(val) \ + { \ + .prop = LV_STYLE_TRANSFORM_ZOOM, \ + .value = { \ + .num = (int32_t)val \ + } \ + } + +static inline void lv_style_set_transform_angle(lv_style_t * style, lv_coord_t value) +{ + lv_style_value_t v = { + .num = (int32_t)value + }; + lv_style_set_prop(style, LV_STYLE_TRANSFORM_ANGLE, v); +} + +#define LV_STYLE_CONST_TRANSFORM_ANGLE(val) \ + { \ + .prop = LV_STYLE_TRANSFORM_ANGLE, \ + .value = { \ + .num = (int32_t)val \ + } \ + } + +static inline void lv_style_set_pad_top(lv_style_t * style, lv_coord_t value) +{ + lv_style_value_t v = { + .num = (int32_t)value + }; + lv_style_set_prop(style, LV_STYLE_PAD_TOP, v); +} + +#define LV_STYLE_CONST_PAD_TOP(val) \ + { \ + .prop = LV_STYLE_PAD_TOP, \ + .value = { \ + .num = (int32_t)val \ + } \ + } + +static inline void lv_style_set_pad_bottom(lv_style_t * style, lv_coord_t value) +{ + lv_style_value_t v = { + .num = (int32_t)value + }; + lv_style_set_prop(style, LV_STYLE_PAD_BOTTOM, v); +} + +#define LV_STYLE_CONST_PAD_BOTTOM(val) \ + { \ + .prop = LV_STYLE_PAD_BOTTOM, \ + .value = { \ + .num = (int32_t)val \ + } \ + } + +static inline void lv_style_set_pad_left(lv_style_t * style, lv_coord_t value) +{ + lv_style_value_t v = { + .num = (int32_t)value + }; + lv_style_set_prop(style, LV_STYLE_PAD_LEFT, v); +} + +#define LV_STYLE_CONST_PAD_LEFT(val) \ + { \ + .prop = LV_STYLE_PAD_LEFT, \ + .value = { \ + .num = (int32_t)val \ + } \ + } + +static inline void lv_style_set_pad_right(lv_style_t * style, lv_coord_t value) +{ + lv_style_value_t v = { + .num = (int32_t)value + }; + lv_style_set_prop(style, LV_STYLE_PAD_RIGHT, v); +} + +#define LV_STYLE_CONST_PAD_RIGHT(val) \ + { \ + .prop = LV_STYLE_PAD_RIGHT, \ + .value = { \ + .num = (int32_t)val \ + } \ + } + +static inline void lv_style_set_pad_row(lv_style_t * style, lv_coord_t value) +{ + lv_style_value_t v = { + .num = (int32_t)value + }; + lv_style_set_prop(style, LV_STYLE_PAD_ROW, v); +} + +#define LV_STYLE_CONST_PAD_ROW(val) \ + { \ + .prop = LV_STYLE_PAD_ROW, \ + .value = { \ + .num = (int32_t)val \ + } \ + } + +static inline void lv_style_set_pad_column(lv_style_t * style, lv_coord_t value) +{ + lv_style_value_t v = { + .num = (int32_t)value + }; + lv_style_set_prop(style, LV_STYLE_PAD_COLUMN, v); +} + +#define LV_STYLE_CONST_PAD_COLUMN(val) \ + { \ + .prop = LV_STYLE_PAD_COLUMN, \ + .value = { \ + .num = (int32_t)val \ + } \ + } + +static inline void lv_style_set_radius(lv_style_t * style, lv_coord_t value) +{ + lv_style_value_t v = { + .num = (int32_t)value + }; + lv_style_set_prop(style, LV_STYLE_RADIUS, v); +} + +#define LV_STYLE_CONST_RADIUS(val) \ + { \ + .prop = LV_STYLE_RADIUS, \ + .value = { \ + .num = (int32_t)val \ + } \ + } + +static inline void lv_style_set_clip_corner(lv_style_t * style, bool value) +{ + lv_style_value_t v = { + .num = (int32_t)value + }; + lv_style_set_prop(style, LV_STYLE_CLIP_CORNER, v); +} + +#define LV_STYLE_CONST_CLIP_CORNER(val) \ + { \ + .prop = LV_STYLE_CLIP_CORNER, \ + .value = { \ + .num = (int32_t)val \ + } \ + } + +static inline void lv_style_set_opa(lv_style_t * style, lv_opa_t value) +{ + lv_style_value_t v = { + .num = (int32_t)value + }; + lv_style_set_prop(style, LV_STYLE_OPA, v); +} + +#define LV_STYLE_CONST_OPA(val) \ + { \ + .prop = LV_STYLE_OPA, \ + .value = { \ + .num = (int32_t)val \ + } \ + } + +static inline void lv_style_set_color_filter_dsc(lv_style_t * style, const lv_color_filter_dsc_t * value) +{ + lv_style_value_t v = { + .ptr = value + }; + lv_style_set_prop(style, LV_STYLE_COLOR_FILTER_DSC, v); +} + +#define LV_STYLE_CONST_COLOR_FILTER_DSC(val) \ + { \ + .prop = LV_STYLE_COLOR_FILTER_DSC, \ + .value = { \ + .ptr = val \ + } \ + } + +static inline void lv_style_set_color_filter_opa(lv_style_t * style, lv_opa_t value) +{ + lv_style_value_t v = { + .num = (int32_t)value + }; + lv_style_set_prop(style, LV_STYLE_COLOR_FILTER_OPA, v); +} + +#define LV_STYLE_CONST_COLOR_FILTER_OPA(val) \ + { \ + .prop = LV_STYLE_COLOR_FILTER_OPA, \ + .value = { \ + .num = (int32_t)val \ + } \ + } + +static inline void lv_style_set_anim_time(lv_style_t * style, uint32_t value) +{ + lv_style_value_t v = { + .num = (int32_t)value + }; + lv_style_set_prop(style, LV_STYLE_ANIM_TIME, v); +} + +#define LV_STYLE_CONST_ANIM_TIME(val) \ + { \ + .prop = LV_STYLE_ANIM_TIME, \ + .value = { \ + .num = (int32_t)val \ + } \ + } + +static inline void lv_style_set_anim_speed(lv_style_t * style, uint32_t value) +{ + lv_style_value_t v = { + .num = (int32_t)value + }; + lv_style_set_prop(style, LV_STYLE_ANIM_SPEED, v); +} + +#define LV_STYLE_CONST_ANIM_SPEED(val) \ + { \ + .prop = LV_STYLE_ANIM_SPEED, \ + .value = { \ + .num = (int32_t)val \ + } \ + } + +static inline void lv_style_set_transition(lv_style_t * style, const lv_style_transition_dsc_t * value) +{ + lv_style_value_t v = { + .ptr = value + }; + lv_style_set_prop(style, LV_STYLE_TRANSITION, v); +} + +#define LV_STYLE_CONST_TRANSITION(val) \ + { \ + .prop = LV_STYLE_TRANSITION, \ + .value = { \ + .ptr = val \ + } \ + } + +static inline void lv_style_set_blend_mode(lv_style_t * style, lv_blend_mode_t value) +{ + lv_style_value_t v = { + .num = (int32_t)value + }; + lv_style_set_prop(style, LV_STYLE_BLEND_MODE, v); +} + +#define LV_STYLE_CONST_BLEND_MODE(val) \ + { \ + .prop = LV_STYLE_BLEND_MODE, \ + .value = { \ + .num = (int32_t)val \ + } \ + } + static inline void lv_style_set_layout(lv_style_t * style, uint16_t value) { lv_style_value_t v = { @@ -494,6 +494,22 @@ static inline void lv_style_set_layout(lv_style_t * style, uint16_t value) } \ } +static inline void lv_style_set_base_dir(lv_style_t * style, lv_base_dir_t value) +{ + lv_style_value_t v = { + .num = (int32_t)value + }; + lv_style_set_prop(style, LV_STYLE_BASE_DIR, v); +} + +#define LV_STYLE_CONST_BASE_DIR(val) \ + { \ + .prop = LV_STYLE_BASE_DIR, \ + .value = { \ + .num = (int32_t)val \ + } \ + } + static inline void lv_style_set_bg_color(lv_style_t * style, lv_color_t value) { lv_style_value_t v = { diff --git a/src/widgets/lv_bar.c b/src/widgets/lv_bar.c index 56ffd12d5..4a0fbdf03 100644 --- a/src/widgets/lv_bar.c +++ b/src/widgets/lv_bar.c @@ -330,8 +330,8 @@ static void draw_indic(lv_event_t * e) anim_cur_value_x = (int32_t)((int32_t)anim_length * (bar->cur_value - bar->min_value)) / range; } - lv_bidi_dir_t base_dir = lv_obj_get_base_dir(obj); - if(hor && base_dir == LV_BIDI_DIR_RTL) { + lv_base_dir_t base_dir = lv_obj_get_style_base_dir(obj, LV_PART_MAIN); + if(hor && base_dir == LV_BASE_DIR_RTL) { /*Swap axes*/ lv_coord_t * tmp; tmp = axis1; diff --git a/src/widgets/lv_btnmatrix.c b/src/widgets/lv_btnmatrix.c index 955ed8e85..7c6212bdb 100644 --- a/src/widgets/lv_btnmatrix.c +++ b/src/widgets/lv_btnmatrix.c @@ -100,7 +100,7 @@ void lv_btnmatrix_set_map(lv_obj_t * obj, const char * map[]) allocate_btn_areas_and_controls(obj, map); btnm->map_p = map; - lv_bidi_dir_t base_dir = lv_obj_get_base_dir(obj); + lv_base_dir_t base_dir = lv_obj_get_style_base_dir(obj, LV_PART_MAIN); /*Set size and positions of the buttons*/ lv_coord_t pleft = lv_obj_get_style_pad_left(obj, LV_PART_MAIN); @@ -160,7 +160,7 @@ void lv_btnmatrix_set_map(lv_obj_t * obj, const char * map[]) lv_coord_t btn_x2 = pleft + (max_w_no_gap * (row_unit_cnt + btn_u)) / unit_cnt + btn * pcol - 1; /*If RTL start from the right*/ - if(base_dir == LV_BIDI_DIR_RTL) { + if(base_dir == LV_BASE_DIR_RTL) { lv_coord_t tmp = btn_x1; btn_x1 = btn_x2; btn_x2 = tmp; diff --git a/src/widgets/lv_dropdown.c b/src/widgets/lv_dropdown.c index 512b43b79..e855a8e39 100644 --- a/src/widgets/lv_dropdown.c +++ b/src/widgets/lv_dropdown.c @@ -749,7 +749,7 @@ static void draw_main(lv_event_t * e) bool symbol_to_left = false; if(dropdown->dir == LV_DIR_LEFT) symbol_to_left = true; - if(lv_obj_get_base_dir(obj) == LV_BIDI_DIR_RTL) symbol_to_left = true; + if(lv_obj_get_style_base_dir(obj, LV_PART_MAIN) == LV_BASE_DIR_RTL) symbol_to_left = true; if(dropdown->symbol) { lv_img_src_t symbol_type = lv_img_src_get_type(dropdown->symbol); diff --git a/src/widgets/lv_label.c b/src/widgets/lv_label.c index d93817ec3..1c5f21f7b 100644 --- a/src/widgets/lv_label.c +++ b/src/widgets/lv_label.c @@ -359,7 +359,7 @@ void lv_label_get_letter_pos(const lv_obj_t * obj, uint32_t char_id, lv_point_t bool is_rtl; uint32_t visual_char_pos = _lv_bidi_get_visual_pos(&txt[line_start], &mutable_bidi_txt, new_line_start - line_start, - lv_obj_get_base_dir(obj), line_char_id, &is_rtl); + lv_obj_get_style_base_dir(obj, LV_PART_MAIN), line_char_id, &is_rtl); bidi_txt = mutable_bidi_txt; if(is_rtl) visual_char_pos++; @@ -447,7 +447,7 @@ uint32_t lv_label_get_letter_on(const lv_obj_t * obj, lv_point_t * pos_in) bidi_txt = lv_mem_buf_get(new_line_start - line_start + 1); uint32_t txt_len = new_line_start - line_start; if(new_line_start > 0 && txt[new_line_start - 1] == '\0' && txt_len > 0) txt_len--; - _lv_bidi_process_paragraph(txt + line_start, bidi_txt, txt_len, lv_obj_get_base_dir(obj), NULL, 0); + _lv_bidi_process_paragraph(txt + line_start, bidi_txt, txt_len, lv_obj_get_style_base_dir(obj, LV_PART_MAIN), NULL, 0); #else bidi_txt = (char *)txt + line_start; #endif @@ -507,7 +507,7 @@ uint32_t lv_label_get_letter_on(const lv_obj_t * obj, lv_point_t * pos_in) else { bool is_rtl; logical_pos = _lv_bidi_get_logical_pos(&txt[line_start], NULL, - txt_len, lv_obj_get_base_dir(obj), cid, &is_rtl); + txt_len, lv_obj_get_style_base_dir(obj, LV_PART_MAIN), cid, &is_rtl); if(is_rtl) logical_pos++; } lv_mem_buf_release(bidi_txt); @@ -660,7 +660,7 @@ void lv_label_ins_text(lv_obj_t * obj, uint32_t pos, const char * txt) LV_ASSERT_MALLOC(bidi_buf); if(bidi_buf == NULL) return; - _lv_bidi_process(txt, bidi_buf, lv_obj_get_base_dir(obj)); + _lv_bidi_process(txt, bidi_buf, lv_obj_get_style_base_dir(obj, LV_PART_MAIN)); _lv_txt_ins(label->text, pos, bidi_buf); lv_mem_buf_release(bidi_buf); @@ -781,12 +781,6 @@ static void lv_label_event(const lv_obj_class_t * class_p, lv_event_t * e) self_size->x = LV_MAX(self_size->x, size.x); self_size->y = LV_MAX(self_size->y, size.y); } - else if(code == LV_EVENT_BASE_DIR_CHANGED) { -#if LV_USE_BIDI - lv_label_t * label = (lv_label_t *)obj; - if(label->static_txt == 0) lv_label_set_text(obj, NULL); -#endif - } else if(code == LV_EVENT_DRAW_MAIN) { draw_main(e); } @@ -926,12 +920,12 @@ static void lv_label_refr_text(lv_obj_t * obj) if(size.x > lv_area_get_width(&txt_coords)) { #if LV_USE_BIDI int32_t start, end; - lv_bidi_dir_t base_dir = lv_obj_get_base_dir(obj); + lv_base_dir_t base_dir = lv_obj_get_style_base_dir(obj, LV_PART_MAIN); - if (base_dir == LV_BIDI_DIR_AUTO) + if (base_dir == LV_BASE_DIR_AUTO) base_dir = _lv_bidi_detect_base_dir(label->text); - if(base_dir == LV_BIDI_DIR_RTL) { + if(base_dir == LV_BASE_DIR_RTL) { start = lv_area_get_width(&txt_coords) - size.x; end = 0; } @@ -1025,12 +1019,12 @@ static void lv_label_refr_text(lv_obj_t * obj) if(size.x > lv_area_get_width(&txt_coords)) { #if LV_USE_BIDI int32_t start, end; - lv_bidi_dir_t base_dir = lv_obj_get_base_dir(obj); + lv_base_dir_t base_dir = lv_obj_get_style_base_dir(obj, LV_PART_MAIN); - if (base_dir == LV_BIDI_DIR_AUTO) + if (base_dir == LV_BASE_DIR_AUTO) base_dir = _lv_bidi_detect_base_dir(label->text); - if(base_dir == LV_BIDI_DIR_RTL) { + if(base_dir == LV_BASE_DIR_RTL) { start = -size.x - lv_font_get_glyph_width(font, ' ', ' ') * LV_LABEL_WAIT_CHAR_COUNT; end = 0; } diff --git a/src/widgets/lv_slider.c b/src/widgets/lv_slider.c index 38368f4b1..415850445 100644 --- a/src/widgets/lv_slider.c +++ b/src/widgets/lv_slider.c @@ -130,15 +130,15 @@ static void lv_slider_event(const lv_obj_class_t * class_p, lv_event_t * e) else if(type == LV_SLIDER_MODE_RANGE) { lv_indev_get_point(lv_indev_get_act(), &p); bool hor = lv_obj_get_width(obj) >= lv_obj_get_height(obj); - lv_bidi_dir_t base_dir = lv_obj_get_base_dir(obj); + lv_base_dir_t base_dir = lv_obj_get_style_base_dir(obj, LV_PART_MAIN); lv_coord_t dist_left, dist_right; if(hor) { - if((base_dir != LV_BIDI_DIR_RTL && p.x > slider->right_knob_area.x2) || (base_dir == LV_BIDI_DIR_RTL && + if((base_dir != LV_BASE_DIR_RTL && p.x > slider->right_knob_area.x2) || (base_dir == LV_BASE_DIR_RTL && p.x < slider->right_knob_area.x1)) { slider->value_to_set = &slider->bar.cur_value; } - else if((base_dir != LV_BIDI_DIR_RTL && p.x < slider->left_knob_area.x1) || (base_dir == LV_BIDI_DIR_RTL && + else if((base_dir != LV_BASE_DIR_RTL && p.x < slider->left_knob_area.x1) || (base_dir == LV_BASE_DIR_RTL && p.x > slider->left_knob_area.x2)) { slider->value_to_set = &slider->bar.start_value; } @@ -189,7 +189,7 @@ static void lv_slider_event(const lv_obj_class_t * class_p, lv_event_t * e) lv_point_t p; lv_indev_get_point(indev, &p); - lv_bidi_dir_t base_dir = lv_obj_get_base_dir(obj); + lv_base_dir_t base_dir = lv_obj_get_style_base_dir(obj, LV_PART_MAIN); lv_coord_t w = lv_obj_get_width(obj); lv_coord_t h = lv_obj_get_height(obj); @@ -206,7 +206,7 @@ static void lv_slider_event(const lv_obj_class_t * class_p, lv_event_t * e) if(w >= h) { lv_coord_t indic_w = w - bg_left - bg_right; - if(base_dir == LV_BIDI_DIR_RTL) { + if(base_dir == LV_BASE_DIR_RTL) { new_value = (obj->coords.x2 - bg_right) - p.x; /*Make the point relative to the indicator*/ } else { @@ -325,7 +325,7 @@ static void draw_knob(lv_event_t * e) lv_obj_t * obj = lv_event_get_target(e); lv_slider_t * slider = (lv_slider_t *)obj; const lv_area_t * clip_area = lv_event_get_param(e); - lv_bidi_dir_t base_dir = lv_obj_get_base_dir(obj); + lv_base_dir_t base_dir = lv_obj_get_style_base_dir(obj, LV_PART_MAIN); lv_coord_t objw = lv_obj_get_width(obj); lv_coord_t objh = lv_obj_get_height(obj); @@ -339,14 +339,14 @@ static void draw_knob(lv_event_t * e) /*Horizontal*/ if(hor) { if(!sym) { - knob_area.x1 = LV_SLIDER_KNOB_COORD(hor, base_dir == LV_BIDI_DIR_RTL, slider->bar.indic_area); + knob_area.x1 = LV_SLIDER_KNOB_COORD(hor, base_dir == LV_BASE_DIR_RTL, slider->bar.indic_area); } else { if(slider->bar.cur_value >= 0) { - knob_area.x1 = LV_SLIDER_KNOB_COORD(hor, base_dir == LV_BIDI_DIR_RTL, slider->bar.indic_area); + knob_area.x1 = LV_SLIDER_KNOB_COORD(hor, base_dir == LV_BASE_DIR_RTL, slider->bar.indic_area); } else { - knob_area.x1 = LV_SLIDER_KNOB_COORD(hor, base_dir != LV_BIDI_DIR_RTL, slider->bar.indic_area); + knob_area.x1 = LV_SLIDER_KNOB_COORD(hor, base_dir != LV_BASE_DIR_RTL, slider->bar.indic_area); } } } @@ -394,7 +394,7 @@ static void draw_knob(lv_event_t * e) /*Draw a second knob for the start_value side*/ if(hor) { - knob_area.x1 = LV_SLIDER_KNOB_COORD(hor, base_dir != LV_BIDI_DIR_RTL, slider->bar.indic_area); + knob_area.x1 = LV_SLIDER_KNOB_COORD(hor, base_dir != LV_BASE_DIR_RTL, slider->bar.indic_area); } else { knob_area.y1 = slider->bar.indic_area.y2; diff --git a/src/widgets/lv_switch.c b/src/widgets/lv_switch.c index 4981a3cb7..21b7608fd 100644 --- a/src/widgets/lv_switch.c +++ b/src/widgets/lv_switch.c @@ -127,7 +127,7 @@ static void draw_main(lv_event_t * e) { lv_obj_t * obj = lv_event_get_target(e); const lv_area_t * clip_area = lv_event_get_param(e); - lv_bidi_dir_t base_dir = lv_obj_get_base_dir(obj); + lv_base_dir_t base_dir = lv_obj_get_style_base_dir(obj, LV_PART_MAIN); /*Calculate the indicator area*/ lv_coord_t bg_left = lv_obj_get_style_pad_left(obj, LV_PART_MAIN); @@ -158,7 +158,7 @@ static void draw_main(lv_event_t * e) lv_area_t knob_area; /*Left*/ - if((base_dir != LV_BIDI_DIR_RTL && !chk) || (base_dir == LV_BIDI_DIR_RTL && chk)) { + if((base_dir != LV_BASE_DIR_RTL && !chk) || (base_dir == LV_BASE_DIR_RTL && chk)) { knob_area.x1 = obj->coords.x1 + bg_left; knob_area.x2 = knob_area.x1 + knob_size; } diff --git a/src/widgets/lv_table.c b/src/widgets/lv_table.c index fdb75bcca..fee70433a 100644 --- a/src/widgets/lv_table.c +++ b/src/widgets/lv_table.c @@ -616,7 +616,7 @@ static void draw_main(lv_event_t * e) cell_area.y2 = obj->coords.y1 + bg_top - 1 - lv_obj_get_scroll_y(obj) ; lv_coord_t scroll_x = lv_obj_get_scroll_x(obj) ; - bool rtl = lv_obj_get_base_dir(obj) == LV_BIDI_DIR_RTL ? true : false; + bool rtl = lv_obj_get_style_base_dir(obj, LV_PART_MAIN) == LV_BASE_DIR_RTL ? true : false; /*Handle custom drawer*/ lv_obj_draw_part_dsc_t dsc;