1
0
mirror of https://github.com/lvgl/lvgl.git synced 2025-02-04 07:13:00 +08:00

minor fixes

This commit is contained in:
Gabor Kiss-Vamosi 2018-11-02 14:21:10 +01:00
parent e2bbbefb04
commit 612c618240
2 changed files with 9 additions and 24 deletions

View File

@ -3,13 +3,6 @@
* *
*/ */
/* TODO Remove these instructions
* Search an replace: spinbox -> object normal name with lower case (e.g. button, label etc.)
* templ -> object short name with lower case(e.g. btn, label etc)
* TEMPL -> object short name with upper case (e.g. BTN, LABEL etc.)
*
*/
/********************* /*********************
* INCLUDES * INCLUDES
*********************/ *********************/
@ -59,7 +52,6 @@ lv_obj_t * lv_spinbox_create(lv_obj_t * par, const lv_obj_t * copy)
LV_LOG_TRACE("spinbox create started"); LV_LOG_TRACE("spinbox create started");
/*Create the ancestor of spinbox*/ /*Create the ancestor of spinbox*/
/*TODO modify it to the ancestor create function */
lv_obj_t * new_spinbox = lv_ta_create(par, copy); lv_obj_t * new_spinbox = lv_ta_create(par, copy);
lv_mem_assert(new_spinbox); lv_mem_assert(new_spinbox);
if(new_spinbox == NULL) return NULL; if(new_spinbox == NULL) return NULL;
@ -71,7 +63,7 @@ lv_obj_t * lv_spinbox_create(lv_obj_t * par, const lv_obj_t * copy)
if(ancestor_signal == NULL) ancestor_signal = lv_obj_get_signal_func(new_spinbox); if(ancestor_signal == NULL) ancestor_signal = lv_obj_get_signal_func(new_spinbox);
if(ancestor_design == NULL) ancestor_design = lv_obj_get_design_func(new_spinbox); if(ancestor_design == NULL) ancestor_design = lv_obj_get_design_func(new_spinbox);
/*Initialize the allocated 'ext' */ /*Initialize the allocated 'ext'*/
ext->ta.one_line = 1; ext->ta.one_line = 1;
ext->ta.pwd_mode = 0; ext->ta.pwd_mode = 0;
ext->ta.accapted_chars = "1234567890+-."; ext->ta.accapted_chars = "1234567890+-.";
@ -84,7 +76,7 @@ lv_obj_t * lv_spinbox_create(lv_obj_t * par, const lv_obj_t * copy)
ext->rangeMax = 99999; ext->rangeMax = 99999;
ext->rangeMin = -99999; ext->rangeMin = -99999;
lv_ta_set_cursor_type(new_spinbox, LV_CURSOR_BLOCK | LV_CURSOR_HIDDEN); //hidden by default lv_ta_set_cursor_type(new_spinbox, LV_CURSOR_BLOCK | LV_CURSOR_HIDDEN); /*hidden by default*/
lv_ta_set_cursor_pos(new_spinbox, 4); lv_ta_set_cursor_pos(new_spinbox, 4);
@ -358,11 +350,11 @@ static lv_res_t lv_spinbox_signal(lv_obj_t * spinbox, lv_signal_t sign, void * p
{ {
if(ext->valueDigit - ext->step >= ext->rangeMin) if(ext->valueDigit - ext->step >= ext->rangeMin)
{ {
//Special mode when zero crossing /*Special mode when zero crossing*/
if((ext->valueDigit - ext->step) < 0 && ext->valueDigit > 0) if((ext->valueDigit - ext->step) < 0 && ext->valueDigit > 0)
{ {
ext->valueDigit = -ext->valueDigit; ext->valueDigit = -ext->valueDigit;
}//end special mode }/*end special mode*/
ext->valueDigit -= ext->step; ext->valueDigit -= ext->step;
} }
@ -374,11 +366,11 @@ static lv_res_t lv_spinbox_signal(lv_obj_t * spinbox, lv_signal_t sign, void * p
{ {
if(ext->valueDigit + ext->step <= ext->rangeMax) if(ext->valueDigit + ext->step <= ext->rangeMax)
{ {
//Special mode when zero crossing /*Special mode when zero crossing*/
if((ext->valueDigit + ext->step) > 0 && ext->valueDigit < 0) if((ext->valueDigit + ext->step) > 0 && ext->valueDigit < 0)
{ {
ext->valueDigit = -ext->valueDigit; ext->valueDigit = -ext->valueDigit;
}//end special mode }/*end special mode*/
ext->valueDigit += ext->step; ext->valueDigit += ext->step;
} }
lv_spinbox_updatevalue(spinbox); lv_spinbox_updatevalue(spinbox);
@ -394,7 +386,7 @@ static lv_res_t lv_spinbox_signal(lv_obj_t * spinbox, lv_signal_t sign, void * p
} }
else else
{ {
if(c == '\n') if(c == LV_GROUP_KEY_ENTER)
{ {
int p = lv_ta_get_cursor_pos(spinbox); int p = lv_ta_get_cursor_pos(spinbox);
if(p == ext->digitCount + 1) if(p == ext->digitCount + 1)

View File

@ -4,13 +4,6 @@
*/ */
/* TODO Remove these instructions
* Search an replace: template -> object normal name with lower case (e.g. button, label etc.)
* templ -> object short name with lower case(e.g. btn, label etc)
* TEMPL -> object short name with upper case (e.g. BTN, LABEL etc.)
*
*/
#ifndef LV_SPINBOX_H #ifndef LV_SPINBOX_H
#define LV_SPINBOX_H #define LV_SPINBOX_H
@ -50,8 +43,8 @@ typedef struct {
int32_t rangeMin; int32_t rangeMin;
int32_t step; int32_t step;
uint8_t digitCount:4; uint8_t digitCount:4;
uint8_t decPointPos:4; //if 0, there is no separator and the number is an integer uint8_t decPointPos:4; /*if 0, there is no separator and the number is an integer*/
uint8_t digits[1+1+16]; //1 sign, 1 point, 16 num digits uint8_t digits[1+1+LV_SPINBOX_MAX_DIGIT_COUNT]; /*1 sign, 1 point, 16 num digits*/
} lv_spinbox_ext_t; } lv_spinbox_ext_t;