BigW Consortium Gitlab

Commit 45b8364b by Gabor

lv_roller: lv_ddlist_set_selected() updated to work with roller too

parent 024d776d
......@@ -234,7 +234,7 @@ void lv_ddlist_set_selected(lv_obj_t * ddlist, uint16_t sel_opt)
{
lv_ddlist_ext_t * ext = lv_obj_get_ext(ddlist);
ext->sel_opt = sel_opt;
ext->sel_opt = sel_opt < ext->num_opt ? sel_opt : ext->num_opt - 1;
/*Move the list to show the current option*/
if(ext->opened == 0) {
......@@ -540,9 +540,11 @@ static void lv_ddlist_pos_act_option(lv_obj_t * ddlist)
cord_t font_h = font_get_height(font) >> FONT_ANTIALIAS;
lv_style_t * label_style = lv_obj_get_style(ext->opt_label);
lv_obj_t * scrl = lv_page_get_scrl(ddlist);
lv_style_t * style_scrl = lv_obj_get_style(scrl);
lv_obj_set_y(scrl, -(ext->sel_opt * (font_h + label_style->line_space) - label_style->line_space) - style_scrl->hpad);
cord_t h = lv_obj_get_height(ddlist);
cord_t line_y1 = ext->sel_opt * (font_h + label_style->line_space) + ext->opt_label->cords.y1 - scrl->cords.y1;
lv_obj_set_y(scrl, - line_y1 + (h - font_h) / 2);
}
......
......@@ -180,8 +180,6 @@ static bool lv_roller_design(lv_obj_t * roller, const area_t * mask, lv_design_m
}
/*Draw the object*/
else if(mode == LV_DESIGN_DRAW_MAIN) {
lv_style_t * style = lv_obj_get_style(roller);
lv_draw_rect(&roller->cords, mask, style);
......@@ -189,7 +187,7 @@ static bool lv_roller_design(lv_obj_t * roller, const area_t * mask, lv_design_m
lv_roller_ext_t * ext = lv_obj_get_ext(roller);
cord_t font_h = font_get_height(font) >> FONT_ANTIALIAS;
area_t rect_area;
rect_area.y1 = lv_obj_get_height(roller) / 2 - font_h / 2 - style->line_space - 2;
rect_area.y1 = roller->cords.y1 + lv_obj_get_height(roller) / 2 - font_h / 2 - style->line_space - 2;
rect_area.y2 = rect_area.y1 + font_h + style->line_space;
rect_area.x1 = ext->ddlist.opt_label->cords.x1 - style->hpad;
......@@ -221,7 +219,7 @@ bool roller_scrl_signal(lv_obj_t * roller_scrl, lv_signal_t sign, void * param)
lv_roller_ext_t * ext = lv_obj_get_ext(roller);
lv_style_t * style_label = lv_obj_get_style(ext->ddlist.opt_label);
cord_t label_y1 = ext->ddlist.opt_label->cords.y1;
cord_t label_y1 = ext->ddlist.page.scrl->cords.y1 - roller->cords.y1;
cord_t label_unit = (font_get_height(style_label->font) >> FONT_ANTIALIAS) + style_label->line_space / 2;
cord_t mid = (roller->cords.y2 - roller->cords.y1) / 2;
......
......@@ -3,13 +3,6 @@
*
*/
/*Search an replace: roller -> object normal name with lower case (e.g. button, label etc.)
* roller -> object short name with lower case(e.g. btn, label etc)
* ROLLER -> object short name with upper case (e.g. BTN, LABEL etc.)
*
*/
#ifndef LV_ROLLER_H
#define LV_ROLLER_H
......
......@@ -33,6 +33,7 @@ extern "C" {
#include "lv_objx/lv_btnm.h"
#include "lv_objx/lv_kb.h"
#include "lv_objx/lv_ddlist.h"
#include "lv_objx/lv_roller.h"
#include "lv_objx/lv_ta.h"
#include "lv_objx/lv_win.h"
#include "lv_objx/lv_tabview.h"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment