lv_app impovements

This commit is contained in:
Gabor
2016-12-20 15:02:23 +01:00
parent 373b75bd53
commit 3566b74dab
9 changed files with 347 additions and 194 deletions

View File

@@ -225,20 +225,24 @@ void lv_btnm_set_map(lv_obj_t * btnm, const char ** map)
/*Only deal with the non empty lines*/
if(btn_cnt != 0) {
/*Calculate the unit width*/
cord_t unit_w = max_w - ((btn_cnt-1) * btnms->rects.opad);
unit_w = unit_w / unit_cnt;
/*Calculate the width of all units*/
cord_t all_unit_w = max_w - ((btn_cnt-1) * btnms->rects.opad);
/*Set the button size and positions and set the texts*/
uint16_t i;
cord_t act_x = btnms->rects.hpad;
cord_t act_unit_w;
for(i = 0; i < btn_cnt; i++) {
/* one_unit_w = all_unit_w / unit_cnt
* act_unit_w = one_unit_w * button_width
* do this two operation but the multiplications first to divide a greater number */
act_unit_w = (all_unit_w * lv_btnm_get_width_unit(map_p_tmp[i])) / unit_cnt;
area_set(&ext->btn_areas[btn_i], act_x,
act_y,
act_x + unit_w * lv_btnm_get_width_unit(map_p_tmp[i]),
act_x + act_unit_w,
act_y + btn_h);
act_x += unit_w * lv_btnm_get_width_unit(map_p_tmp[i]) + btnms->rects.opad;
act_x += act_unit_w + btnms->rects.opad;
i_tot ++;
btn_i ++;

View File

@@ -162,7 +162,6 @@ void lv_label_set_text(lv_obj_t * label, const char * text)
cord_t max_w = lv_obj_get_width(label);
lv_labels_t * style = lv_obj_get_style(label);
const font_t * font = font_get(style->font);
uint8_t letter_height = font_get_height(font);
ext->dot_end = LV_LABEL_DOT_END_INV; /*Initialize the dot end index*/
@@ -331,7 +330,7 @@ void lv_label_get_letter_pos(lv_obj_t * label, uint16_t index, point_t * pos)
lv_label_ext_t * ext = lv_obj_get_ext(label);
uint32_t line_start = 0;
uint32_t new_line_start = 0;
cord_t max_length = lv_obj_get_width(label);
cord_t max_w = lv_obj_get_width(label);
lv_labels_t * labels = lv_obj_get_style(label);
const font_t * font = font_get(labels->font);
uint8_t letter_height = font_get_height(font);
@@ -339,18 +338,23 @@ void lv_label_get_letter_pos(lv_obj_t * label, uint16_t index, point_t * pos)
/*If the width will be expanded the set the max length to very big */
if(ext->long_mode == LV_LABEL_LONG_EXPAND || ext->long_mode == LV_LABEL_LONG_SCROLL) {
max_length = LV_CORD_MAX;
max_w = LV_CORD_MAX;
}
/*Search the line of the index letter */;
while (text[new_line_start] != '\0') {
new_line_start += txt_get_next_line(&text[line_start], font, labels->letter_space, max_length);
new_line_start += txt_get_next_line(&text[line_start], font, labels->letter_space, max_w);
if(index < new_line_start || text[new_line_start] == '\0') break; /*The line of 'index' letter begins at 'line_start'*/
y += letter_height + labels->line_space;
line_start = new_line_start;
}
if((text[index - 1] == '\n' || text[index - 1] == '\r') && text[index] == '\0') {
y += letter_height + labels->line_space;
line_start = index;
}
/*Calculate the x coordinate*/
cord_t x = 0;
uint32_t i;
@@ -382,37 +386,37 @@ uint16_t lv_label_get_letter_on(lv_obj_t * label, point_t * pos)
lv_label_ext_t * ext = lv_obj_get_ext(label);
uint32_t line_start = 0;
uint32_t new_line_start = 0;
cord_t max_length = lv_obj_get_width(label);
lv_labels_t * labels = lv_obj_get_style(label);
const font_t * font = font_get(labels->font);
cord_t max_w = lv_obj_get_width(label);
lv_labels_t * style = lv_obj_get_style(label);
const font_t * font = font_get(style->font);
uint8_t letter_height = font_get_height(font);
cord_t y = 0;
/*If the width will be expanded set the max length to very big */
if(ext->long_mode == LV_LABEL_LONG_EXPAND || ext->long_mode == LV_LABEL_LONG_SCROLL) {
max_length = LV_CORD_MAX;
max_w = LV_CORD_MAX;
}
/*Search the line of the index letter */;
while (text[line_start] != '\0') {
new_line_start += txt_get_next_line(&text[line_start], font, labels->letter_space, max_length);
if(pos->y <= y + letter_height + labels->line_space) break; /*The line is found ('line_start')*/
y += letter_height + labels->line_space;
new_line_start += txt_get_next_line(&text[line_start], font, style->letter_space, max_w);
if(pos->y <= y + letter_height + style->line_space) break; /*The line is found ('line_start')*/
y += letter_height + style->line_space;
line_start = new_line_start;
}
/*Calculate the x coordinate*/
cord_t x = 0;
if(labels->mid != 0) {
if(style->mid != 0) {
cord_t line_w;
line_w = txt_get_width(&text[line_start], new_line_start - line_start,
font, labels->letter_space);
font, style->letter_space);
x += lv_obj_get_width(label) / 2 - line_w / 2;
}
uint16_t i;
for(i = line_start; i < new_line_start-1; i++) {
x += font_get_width(font, text[i]) + labels->letter_space;
x += font_get_width(font, text[i]) + style->letter_space;
if(pos->x < x) break;
}

View File

@@ -154,7 +154,10 @@ bool lv_page_signal(lv_obj_t * page, lv_signal_t sign, void * param)
break;
case LV_SIGNAL_CORD_CHG:
lv_page_sb_refresh(page);
if(ext->scrolling != NULL) {
ext->scrolling->signal_f(ext->scrolling, LV_SIGNAL_CORD_CHG, &ext->scrolling->cords);
lv_page_sb_refresh(page);
}
break;
default:
break;