aboutsummaryrefslogtreecommitdiff
path: root/src/widgets/roller/lv_roller.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/widgets/roller/lv_roller.c')
-rw-r--r--src/widgets/roller/lv_roller.c76
1 files changed, 38 insertions, 38 deletions
diff --git a/src/widgets/roller/lv_roller.c b/src/widgets/roller/lv_roller.c
index fc0a5609b..082752d12 100644
--- a/src/widgets/roller/lv_roller.c
+++ b/src/widgets/roller/lv_roller.c
@@ -41,7 +41,7 @@ static void refr_position(lv_obj_t * obj, lv_anim_enable_t animen);
static lv_result_t release_handler(lv_obj_t * obj);
static void inf_normalize(lv_obj_t * obj_scrl);
static lv_obj_t * get_label(const lv_obj_t * obj);
-static lv_coord_t get_selected_label_width(const lv_obj_t * obj);
+static int32_t get_selected_label_width(const lv_obj_t * obj);
static void scroll_anim_ready_cb(lv_anim_t * a);
static void set_y_anim(void * obj, int32_t v);
static void transform_vect_recursive(lv_obj_t * roller, lv_point_t * vect);
@@ -126,7 +126,7 @@ void lv_roller_set_options(lv_obj_t * obj, const char * options, lv_roller_mode_
roller->mode = LV_ROLLER_MODE_INFINITE;
const lv_font_t * font = lv_obj_get_style_text_font(obj, 0);
- lv_coord_t normal_h = roller->option_cnt * (lv_font_get_line_height(font) + lv_obj_get_style_text_letter_space(obj, 0));
+ int32_t normal_h = roller->option_cnt * (lv_font_get_line_height(font) + lv_obj_get_style_text_letter_space(obj, 0));
roller->inf_page_cnt = LV_CLAMP(3, EXTRA_INF_SIZE / normal_h, 15);
if(!(roller->inf_page_cnt & 1)) roller->inf_page_cnt++; /*Make it odd*/
LV_LOG_INFO("Using %" LV_PRIu32 " pages to make the roller look infinite", roller->inf_page_cnt);
@@ -205,8 +205,8 @@ void lv_roller_set_visible_row_count(lv_obj_t * obj, uint32_t row_cnt)
LV_ASSERT_OBJ(obj, MY_CLASS);
const lv_font_t * font = lv_obj_get_style_text_font(obj, LV_PART_MAIN);
- lv_coord_t line_space = lv_obj_get_style_text_line_space(obj, LV_PART_MAIN);
- lv_coord_t border_width = lv_obj_get_style_border_width(obj, LV_PART_MAIN);
+ int32_t line_space = lv_obj_get_style_text_line_space(obj, LV_PART_MAIN);
+ int32_t border_width = lv_obj_get_style_border_width(obj, LV_PART_MAIN);
lv_obj_set_height(obj, (lv_font_get_line_height(font) + line_space) * row_cnt + 2 * border_width);
}
@@ -447,10 +447,10 @@ static void lv_roller_label_event(const lv_obj_class_t * class_p, lv_event_t * e
lv_obj_t * label = lv_event_get_target(e);
if(code == LV_EVENT_REFR_EXT_DRAW_SIZE) {
/*If the selected text has a larger font it needs some extra space to draw it*/
- lv_coord_t * s = lv_event_get_param(e);
+ int32_t * s = lv_event_get_param(e);
lv_obj_t * obj = lv_obj_get_parent(label);
- lv_coord_t sel_w = get_selected_label_width(obj);
- lv_coord_t label_w = lv_obj_get_width(label);
+ int32_t sel_w = get_selected_label_width(obj);
+ int32_t label_w = lv_obj_get_width(label);
*s = LV_MAX(*s, sel_w - label_w);
}
else if(code == LV_EVENT_SIZE_CHANGED) {
@@ -500,7 +500,7 @@ static void draw_main(lv_event_t * e)
lv_obj_get_width(obj), LV_TEXT_FLAG_EXPAND);
/*Move the selected label proportionally with the background label*/
- lv_coord_t roller_h = lv_obj_get_height(obj);
+ int32_t roller_h = lv_obj_get_height(obj);
int32_t label_y_prop = label->coords.y1 - (roller_h / 2 +
obj->coords.y1); /*label offset from the middle line of the roller*/
label_y_prop = (label_y_prop * 16384) / lv_obj_get_height(
@@ -508,7 +508,7 @@ static void draw_main(lv_event_t * e)
/*Apply a correction with different line heights*/
const lv_font_t * normal_label_font = lv_obj_get_style_text_font(obj, LV_PART_MAIN);
- lv_coord_t corr = (label_dsc.font->line_height - normal_label_font->line_height) / 2;
+ int32_t corr = (label_dsc.font->line_height - normal_label_font->line_height) / 2;
/*Apply the proportional position to the selected text*/
res_p.y -= corr;
@@ -516,9 +516,9 @@ static void draw_main(lv_event_t * e)
label_sel_y += (label_y_prop * res_p.y) >> 14;
label_sel_y -= corr;
- lv_coord_t bwidth = lv_obj_get_style_border_width(obj, LV_PART_MAIN);
- lv_coord_t pleft = lv_obj_get_style_pad_left(obj, LV_PART_MAIN);
- lv_coord_t pright = lv_obj_get_style_pad_right(obj, LV_PART_MAIN);
+ int32_t bwidth = lv_obj_get_style_border_width(obj, LV_PART_MAIN);
+ int32_t pleft = lv_obj_get_style_pad_left(obj, LV_PART_MAIN);
+ int32_t pright = lv_obj_get_style_pad_right(obj, LV_PART_MAIN);
/*Draw the selected text*/
lv_area_t label_sel_area;
@@ -594,10 +594,10 @@ static void get_sel_area(lv_obj_t * obj, lv_area_t * sel_area)
const lv_font_t * font_main = lv_obj_get_style_text_font(obj, LV_PART_MAIN);
const lv_font_t * font_sel = lv_obj_get_style_text_font(obj, LV_PART_SELECTED);
- lv_coord_t font_main_h = lv_font_get_line_height(font_main);
- lv_coord_t font_sel_h = lv_font_get_line_height(font_sel);
- lv_coord_t line_space = lv_obj_get_style_text_line_space(obj, LV_PART_MAIN);
- lv_coord_t d = (font_sel_h + font_main_h) / 2 + line_space;
+ int32_t font_main_h = lv_font_get_line_height(font_main);
+ int32_t font_sel_h = lv_font_get_line_height(font_sel);
+ int32_t line_space = lv_obj_get_style_text_line_space(obj, LV_PART_MAIN);
+ int32_t d = (font_sel_h + font_main_h) / 2 + line_space;
sel_area->y1 = obj->coords.y1 + lv_obj_get_height(obj) / 2 - d / 2;
sel_area->y2 = sel_area->y1 + d;
lv_area_t roller_coords;
@@ -620,7 +620,7 @@ static void refr_position(lv_obj_t * obj, lv_anim_enable_t anim_en)
const lv_text_align_t align = lv_obj_calculate_style_text_align(label, LV_PART_MAIN, lv_label_get_text(label));
- lv_coord_t x = 0;
+ int32_t x = 0;
switch(align) {
case LV_TEXT_ALIGN_CENTER:
x = (lv_obj_get_content_width(obj) - lv_obj_get_width(label)) / 2;
@@ -638,9 +638,9 @@ static void refr_position(lv_obj_t * obj, lv_anim_enable_t anim_en)
lv_obj_set_x(label, x);
const lv_font_t * font = lv_obj_get_style_text_font(obj, LV_PART_MAIN);
- const lv_coord_t line_space = lv_obj_get_style_text_line_space(obj, LV_PART_MAIN);
- const lv_coord_t font_h = lv_font_get_line_height(font);
- const lv_coord_t h = lv_obj_get_content_height(obj);
+ const int32_t line_space = lv_obj_get_style_text_line_space(obj, LV_PART_MAIN);
+ const int32_t font_h = lv_font_get_line_height(font);
+ const int32_t h = lv_obj_get_content_height(obj);
uint32_t anim_time = lv_obj_get_style_anim_time(obj, LV_PART_MAIN);
/*Normally the animation's `end_cb` sets correct position of the roller if infinite.
@@ -652,9 +652,9 @@ static void refr_position(lv_obj_t * obj, lv_anim_enable_t anim_en)
/* Calculate animation configuration */
lv_roller_t * roller = (lv_roller_t *)obj;
int32_t id = roller->sel_opt_id;
- const lv_coord_t sel_y1 = id * (font_h + line_space);
- const lv_coord_t mid_y1 = h / 2 - font_h / 2;
- const lv_coord_t new_y = mid_y1 - sel_y1;
+ const int32_t sel_y1 = id * (font_h + line_space);
+ const int32_t mid_y1 = h / 2 - font_h / 2;
+ const int32_t new_y = mid_y1 - sel_y1;
if(anim_en == LV_ANIM_OFF || anim_time == 0) {
lv_anim_delete(label, set_y_anim);
@@ -722,24 +722,24 @@ static lv_result_t release_handler(lv_obj_t * obj)
else {
/*If dragged then align the list to have an element in the middle*/
const lv_font_t * font = lv_obj_get_style_text_font(obj, LV_PART_MAIN);
- lv_coord_t line_space = lv_obj_get_style_text_line_space(obj, LV_PART_MAIN);
- lv_coord_t font_h = lv_font_get_line_height(font);
+ int32_t line_space = lv_obj_get_style_text_line_space(obj, LV_PART_MAIN);
+ int32_t font_h = lv_font_get_line_height(font);
- lv_coord_t label_unit = font_h + line_space;
- lv_coord_t mid = obj->coords.y1 + (obj->coords.y2 - obj->coords.y1) / 2;
+ int32_t label_unit = font_h + line_space;
+ int32_t mid = obj->coords.y1 + (obj->coords.y2 - obj->coords.y1) / 2;
lv_point_t p = indev->pointer.scroll_throw_vect_ori;
transform_vect_recursive(obj, &p);
- lv_coord_t scroll_throw = indev->scroll_throw;
- lv_coord_t sum = 0;
+ int32_t scroll_throw = indev->scroll_throw;
+ int32_t sum = 0;
int32_t v = p.y;
while(v) {
sum += v;
v = v * (100 - scroll_throw) / 100;
}
- lv_coord_t label_y1 = label->coords.y1 + sum;
+ int32_t label_y1 = label->coords.y1 + sum;
int32_t id = (mid - label_y1) / label_unit;
if(id < 0) id = 0;
@@ -776,15 +776,15 @@ static void inf_normalize(lv_obj_t * obj)
/*Move to the new id*/
const lv_font_t * font = lv_obj_get_style_text_font(obj, LV_PART_MAIN);
- lv_coord_t line_space = lv_obj_get_style_text_line_space(obj, LV_PART_MAIN);
- lv_coord_t font_h = lv_font_get_line_height(font);
- lv_coord_t h = lv_obj_get_content_height(obj);
+ int32_t line_space = lv_obj_get_style_text_line_space(obj, LV_PART_MAIN);
+ int32_t font_h = lv_font_get_line_height(font);
+ int32_t h = lv_obj_get_content_height(obj);
lv_obj_t * label = get_label(obj);
- lv_coord_t sel_y1 = roller->sel_opt_id * (font_h + line_space);
- lv_coord_t mid_y1 = h / 2 - font_h / 2;
- lv_coord_t new_y = mid_y1 - sel_y1;
+ int32_t sel_y1 = roller->sel_opt_id * (font_h + line_space);
+ int32_t mid_y1 = h / 2 - font_h / 2;
+ int32_t new_y = mid_y1 - sel_y1;
lv_obj_set_y(label, new_y);
}
}
@@ -795,13 +795,13 @@ static lv_obj_t * get_label(const lv_obj_t * obj)
}
-static lv_coord_t get_selected_label_width(const lv_obj_t * obj)
+static int32_t get_selected_label_width(const lv_obj_t * obj)
{
lv_obj_t * label = get_label(obj);
if(label == NULL) return 0;
const lv_font_t * font = lv_obj_get_style_text_font(obj, LV_PART_SELECTED);
- lv_coord_t letter_space = lv_obj_get_style_text_letter_space(obj, LV_PART_SELECTED);
+ int32_t letter_space = lv_obj_get_style_text_letter_space(obj, LV_PART_SELECTED);
const char * txt = lv_label_get_text(label);
lv_point_t size;
lv_text_get_size(&size, txt, font, letter_space, 0, LV_COORD_MAX, LV_TEXT_FLAG_NONE);