BigW Consortium Gitlab

Commit c0715b4c by Gabor Kiss-Vamosi

rever reset

parent d6ccc489
......@@ -14,7 +14,7 @@
#include "misc/os/idle.h"
#include "lvgl/lv_objx/lv_chart.h"
#include "lvgl/lv_app/lv_app_util/lv_app_notice.h"
#include "hal/systick/systick.h"
#include "../hal/systick/systick.h"
/*********************
* DEFINES
......
......@@ -134,7 +134,6 @@
/*Text area (dependencies: lv_label, lv_page)*/
#define USE_LV_TA 1
#if USE_LV_TA != 0
#define LV_TA_MAX_LENGTH 256
#define LV_TA_CUR_BLINK_TIME 400 /*ms*/
#define LV_TA_PWD_SHOW_TIME 1500 /*ms*/
#endif
......
......@@ -6,17 +6,17 @@
/*********************
* INCLUDES
*********************/
#include <misc/gfx/circ.h>
#include "lv_conf.h"
#include <stdio.h>
#include <stdbool.h>
#include "misc/gfx/text.h"
#include "lv_draw.h"
#include "misc/fs/fsint.h"
#include "misc/math/math_base.h"
#include "lv_draw_rbasic.h"
#include "lv_draw_vbasic.h"
#include "misc/gfx/text.h"
#include "misc/gfx/circ.h"
#include "misc/fs/fsint.h"
#include "misc/math/math_base.h"
#include "misc/fs/ufs/ufs.h"
#include "../lv_objx/lv_img.h"
......@@ -64,14 +64,14 @@ static void point_swap(point_t * p1, point_t * p2);
#if LV_VDB_SIZE != 0
static void (*px_fp)(cord_t x, cord_t y, const area_t * mask_p, color_t color, opa_t opa) = lv_vpx;
static void (*fill_fp)(const area_t * cords_p, const area_t * mask_p, color_t color, opa_t opa) = lv_vfill;
static void (*letter_fp)(const point_t * pos_p, const area_t * mask_p, const font_t * font_p, uint8_t letter, color_t color, opa_t opa) = lv_vletter;
static void (*letter_fp)(const point_t * pos_p, const area_t * mask_p, const font_t * font_p, uint32_t letter, color_t color, opa_t opa) = lv_vletter;
#if USE_FSINT != 0
static void (*map_fp)(const area_t * cords_p, const area_t * mask_p, const color_t * map_p, opa_t opa, bool transp, bool upscale, color_t recolor, opa_t recolor_opa) = lv_vmap;
#endif
#else
static void (*px_fp)(cord_t x, cord_t y, const area_t * mask_p, color_t color, opa_t opa) = lv_rpx;
static void (*fill_fp)(const area_t * cords_p, const area_t * mask_p, color_t color, opa_t opa) = lv_rfill;
static void (*letter_fp)(const point_t * pos_p, const area_t * mask_p, const font_t * font_p, uint8_t letter, color_t color, opa_t opa) = lv_rletter;
static void (*letter_fp)(const point_t * pos_p, const area_t * mask_p, const font_t * font_p, uint32_t letter, color_t color, opa_t opa) = lv_rletter;
#if USE_LV_IMG != 0 && USE_FSINT != 0
static void (*map_fp)(const area_t * cords_p, const area_t * mask_p, const color_t * map_p, opa_t opa, bool transp, bool upscale, color_t recolor, opa_t recolor_opa) = lv_rmap;
#endif
......@@ -280,13 +280,15 @@ void lv_draw_label(const area_t * cords_p,const area_t * mask_p, const lv_style_
}
/*Write all letter of a line*/
cmd_state = CMD_STATE_WAIT;
for(i = line_start; i < line_end; i++) {
i = line_start;
uint32_t letter;
while(i < line_end) {
letter = txt_utf8_next(txt, &i);
/*Handle the re-color command*/
if((flag & TXT_FLAG_RECOLOR) != 0) {
if(txt[i] == TXT_RECOLOR_CMD) {
if(letter == TXT_RECOLOR_CMD) {
if(cmd_state == CMD_STATE_WAIT) { /*Start char*/
par_start = i + 1;
par_start = i + txt_utf8_size(txt[i]);
cmd_state = CMD_STATE_PAR;
continue;
} else if(cmd_state == CMD_STATE_PAR) { /*Other start char in parameter escaped cmd. char */
......@@ -299,7 +301,7 @@ void lv_draw_label(const area_t * cords_p,const area_t * mask_p, const lv_style_
/*Skip the color parameter and wait the space after it*/
if(cmd_state == CMD_STATE_PAR) {
if(txt[i] == ' ') {
if(letter == ' ') {
/*Get the parameter*/
if(i - par_start == LABEL_RECOLOR_PAR_LENGTH) {
char buf[LABEL_RECOLOR_PAR_LENGTH + 1];
......@@ -320,9 +322,9 @@ void lv_draw_label(const area_t * cords_p,const area_t * mask_p, const lv_style_
color_t color = style->ccolor;
if(cmd_state == CMD_STATE_IN) color = recolor;
letter_fp(&pos, mask_p, font, txt[i], color, style->opa);
letter_fp(&pos, mask_p, font, letter, color, style->opa);
pos.x += (font_get_width(font, txt[i]) >> FONT_ANTIALIAS) + style->letter_space;
pos.x += (font_get_width(font, letter) >> FONT_ANTIALIAS) + style->letter_space;
}
/*Go to next line*/
......
......@@ -8,7 +8,7 @@
*********************/
#include "lv_draw_rbasic.h"
#include "lv_conf.h"
#include "hal/disp/disp.h"
#include "../hal/disp/hal_disp.h"
#include "misc/gfx/font.h"
/*********************
......@@ -77,7 +77,7 @@ void lv_rfill(const area_t * cords_p, const area_t * mask_p,
if(union_ok != false){
disp_fill(masked_area.x1, masked_area.y1, masked_area.x2, masked_area.y2, color);
//TODO disp_fill(masked_area.x1, masked_area.y1, masked_area.x2, masked_area.y2, color);
}
}
......@@ -95,6 +95,7 @@ void lv_rletter(const point_t * pos_p, const area_t * mask_p,
color_t color, opa_t opa)
{
uint8_t w = font_get_width(font_p, letter);
const uint8_t * bitmap_p = font_get_bitmap(font_p, letter);
uint8_t col, col_sub, row;
......@@ -110,15 +111,14 @@ void lv_rletter(const point_t * pos_p, const area_t * mask_p,
col_sub = 8;
}
}
/*Correction if the letter is short*/
bitmap_p += font_p->width_byte - ((w >> 3) + 1);
/*Go to the next row*/
bitmap_p ++;
}
#else
uint8_t width_byte = w >> 3; /*Width in bytes (e.g. w = 11 -> 2 bytes wide)*/
if(w & 0x7) width_byte++;
const uint8_t * map1_p = bitmap_p;
const uint8_t * map2_p = bitmap_p + font_p->width_byte;
const uint8_t * map2_p = bitmap_p + width_byte;
uint8_t px_cnt;
uint8_t col_byte_cnt;
for(row = 0; row < (font_p->height_row >> 1); row ++) {
......@@ -152,10 +152,10 @@ void lv_rletter(const point_t * pos_p, const area_t * mask_p,
}
}
map1_p += font_p->width_byte;
map2_p += font_p->width_byte;
map1_p += font_p->width_byte - col_byte_cnt;
map2_p += font_p->width_byte - col_byte_cnt;
map1_p += width_byte;
map2_p += width_byte;
map1_p += width_byte - col_byte_cnt;
map2_p += width_byte - col_byte_cnt;
}
#endif
}
......@@ -192,7 +192,7 @@ void lv_rmap(const area_t * cords_p, const area_t * mask_p,
cord_t row;
cord_t mask_w = area_get_width(&masked_a) - 1;
for(row = 0; row < area_get_height(&masked_a); row++) {
disp_map(masked_a.x1, masked_a.y1 + row, masked_a.x1 + mask_w, masked_a.y1 + row, map_p);
//TODO disp_map(masked_a.x1, masked_a.y1 + row, masked_a.x1 + mask_w, masked_a.y1 + row, map_p);
map_p += map_width;
}
......
......@@ -10,7 +10,7 @@
#include "misc/gfx/area.h"
#include "misc/gfx/font.h"
#include "misc/gfx/color.h"
#include "hal/disp/disp.h"
#include "../hal/disp/hal_disp.h"
#if LV_VDB_SIZE != 0
......@@ -148,7 +148,7 @@ void lv_vfill(const area_t * cords_p, const area_t * mask_p,
* @param opa opacity of letter (0..255)
*/
void lv_vletter(const point_t * pos_p, const area_t * mask_p,
const font_t * font_p, uint8_t letter,
const font_t * font_p, uint32_t letter,
color_t color, opa_t opa)
{
if(font_p == NULL) return;
......@@ -170,6 +170,8 @@ void lv_vletter(const point_t * pos_p, const area_t * mask_p,
cord_t col, row;
uint8_t col_bit;
uint8_t col_byte_cnt;
uint8_t width_byte = letter_w >> 3; /*Width in bytes (e.g. w = 11 -> 2 bytes wide)*/
if(letter_w & 0x7) width_byte++;
/* Calculate the col/row start/end on the map
* If font anti alaiassing is enabled use the reduced letter sizes*/
......@@ -186,13 +188,13 @@ void lv_vletter(const point_t * pos_p, const area_t * mask_p,
vdb_buf_tmp += (row_start * vdb_width) + col_start;
/*Move on the map too*/
map_p += ((row_start << FONT_ANTIALIAS) * font_p->width_byte) + ((col_start << FONT_ANTIALIAS) >> 3);
map_p += ((row_start << FONT_ANTIALIAS) * width_byte) + ((col_start << FONT_ANTIALIAS) >> 3);
#if FONT_ANTIALIAS != 0
opa_t opa_tmp = opa;
if(opa_tmp != OPA_COVER) opa_tmp = opa_tmp >> 2; /*Opacity per pixel (used when sum the pixels)*/
const uint8_t * map1_p = map_p;
const uint8_t * map2_p = map_p + font_p->width_byte;
const uint8_t * map2_p = map_p + width_byte;
uint8_t px_cnt;
for(row = row_start; row < row_end; row ++) {
col_byte_cnt = 0;
......@@ -228,10 +230,10 @@ void lv_vletter(const point_t * pos_p, const area_t * mask_p,
vdb_buf_tmp++;
}
map1_p += font_p->width_byte;
map2_p += font_p->width_byte;
map1_p += font_p->width_byte - col_byte_cnt;
map2_p += font_p->width_byte - col_byte_cnt;
map1_p += width_byte;
map2_p += width_byte;
map1_p += width_byte - col_byte_cnt;
map2_p += width_byte - col_byte_cnt;
vdb_buf_tmp += vdb_width - ((col_end) - (col_start)); /*Next row in VDB*/
}
#else
......@@ -255,7 +257,7 @@ void lv_vletter(const point_t * pos_p, const area_t * mask_p,
}
}
map_p += font_p->width_byte - col_byte_cnt;
map_p += width_byte - col_byte_cnt;
vdb_buf_tmp += vdb_width - (col_end - col_start); /*Next row in VDB*/
}
#endif
......
......@@ -54,7 +54,7 @@ void lv_vfill(const area_t * cords_p, const area_t * mask_p,
* @param opa opacity of letter (0..255)
*/
void lv_vletter(const point_t * pos_p, const area_t * mask_p,
const font_t * font_p, uint8_t letter,
const font_t * font_p, uint32_t letter,
color_t color, opa_t opa);
/**
......
......@@ -12,8 +12,8 @@
#include "misc/math/math_base.h"
#include "lv_dispi.h"
#include "../lv_draw/lv_draw_rbasic.h"
#include "hal/indev/indev.h"
#include "hal/systick/systick.h"
#include "../hal/indev/hal_indev.h"
#include "../hal/systick/systick.h"
#include "lv_obj.h"
/*********************
......@@ -41,7 +41,7 @@ static void dispi_drag_throw(lv_dispi_t * dispi_p);
static ptask_t* dispi_task_p;
static bool lv_dispi_reset_qry;
static bool lv_dispi_reset_now;
static lv_dispi_t dispi_array[INDEV_NUM];
static lv_dispi_t dispi_array[2];
/**********************
* MACROS
......@@ -90,8 +90,8 @@ void lv_dispi_reset(void)
void lv_dispi_reset_lpr(lv_dispi_t * dispi)
{
dispi->long_press_sent = 0;
dispi->lpr_rep_time_stamp = systick_get();
dispi->press_time_stamp = systick_get();
dispi->lpr_rep_time_stamp = lv_hal_tick_get();
dispi->press_time_stamp = lv_hal_tick_get();
}
/**
......@@ -145,13 +145,15 @@ void lv_dispi_wait_release(lv_dispi_t * dispi)
*/
static void dispi_task(void * param)
{
cord_t x;
cord_t y;
uint8_t i;
lv_hal_indev_data_t data;
lv_indev_t * drv;
drv = lv_hal_indev_next(NULL);
for (i = 0; i < INDEV_NUM; i++) {
dispi_array[i].pressed = indev_get(i, &x, &y);
dispi_proc_point(&dispi_array[i], x, y);
while(drv) {
drv->drv.get_data(&data);
drv->dispi.pressed = data.state;
dispi_proc_point(&drv->dispi,data.point.x , data.point.y);
drv = lv_hal_indev_next(drv);
}
/*If reset query occurred in this round then set a flag to
......@@ -251,7 +253,7 @@ static void dispi_proc_press(lv_dispi_t * dispi_p)
if(pr_obj != NULL) {
/* Save the time when the obj pressed.
* It is necessary to count the long press time.*/
dispi_p->press_time_stamp = systick_get();
dispi_p->press_time_stamp = lv_hal_tick_get();
dispi_p->long_press_sent = 0;
dispi_p->drag_range_out = 0;
dispi_p->drag_in_prog = 0;
......@@ -298,22 +300,22 @@ static void dispi_proc_press(lv_dispi_t * dispi_p)
/*If there is no drag then check for long press time*/
if(dispi_p->drag_in_prog == 0 && dispi_p->long_press_sent == 0) {
/*Send a signal about the long press if enough time elapsed*/
if(systick_elaps(dispi_p->press_time_stamp) > LV_DISPI_LONG_PRESS_TIME) {
if(lv_hal_tick_elaps(dispi_p->press_time_stamp) > LV_DISPI_LONG_PRESS_TIME) {
pr_obj->signal_f(pr_obj, LV_SIGNAL_LONG_PRESS, dispi_p);
/*Mark the signal sending to do not send it again*/
dispi_p->long_press_sent = 1;
/*Save the long press time stamp for the long press repeat handler*/
dispi_p->lpr_rep_time_stamp = systick_get();
dispi_p->lpr_rep_time_stamp = lv_hal_tick_get();
}
}
/*Send long press repeated signal*/
if(dispi_p->drag_in_prog == 0 && dispi_p->long_press_sent == 1) {
/*Send a signal about the long press repeate if enough time elapsed*/
if(systick_elaps(dispi_p->lpr_rep_time_stamp) > LV_DISPI_LONG_PRESS_REP_TIME) {
if(lv_hal_tick_elaps(dispi_p->lpr_rep_time_stamp) > LV_DISPI_LONG_PRESS_REP_TIME) {
pr_obj->signal_f(pr_obj, LV_SIGNAL_LONG_PRESS_REP, dispi_p);
dispi_p->lpr_rep_time_stamp = systick_get();
dispi_p->lpr_rep_time_stamp = lv_hal_tick_get();
}
}
......
......@@ -16,7 +16,7 @@
#include "lv_group.h"
#include "../lv_app/lv_app.h"
#include "misc/gfx/anim.h"
#include "hal/indev/indev.h"
#include "../hal/indev/hal_indev.h"
#include <stdint.h>
#include <string.h>
......@@ -294,23 +294,24 @@ void lv_obj_del(lv_obj_t * obj)
if(obj->ext != NULL) dm_free(obj->ext);
dm_free(obj); /*Free the object itself*/
/* Reset all display input (dispi) if
* the currently pressed object is deleted too*/
lv_dispi_t * dispi_array = lv_dispi_get_array();
lv_obj_t * dpar;
uint8_t d;
for(d = 0; d < INDEV_NUM; d++) {
dpar = obj;
while(dpar != NULL) {
if(dispi_array[d].act_obj == dpar ||
dispi_array[d].last_obj == dpar) {
lv_dispi_reset();
break;
} else {
dpar = lv_obj_get_parent(dpar);
}
}
}
// TODO Update with the new HAL
// /* Reset all display input (dispi) if
// * the currently pressed object is deleted too*/
// lv_dispi_t * dispi_array = lv_dispi_get_array();
// lv_obj_t * dpar;
// uint8_t d;
// for(d = 0; d < INDEV_NUM; d++) {
// dpar = obj;
// while(dpar != NULL) {
// if(dispi_array[d].act_obj == dpar ||
// dispi_array[d].last_obj == dpar) {
// lv_dispi_reset();
// break;
// } else {
// dpar = lv_obj_get_parent(dpar);
// }
// }
// }
/*Send a signal to the parent to notify it about the child delete*/
if(par != NULL) {
......@@ -1525,13 +1526,14 @@ static void lv_child_refr_style(lv_obj_t * obj)
lv_obj_t * child = lv_obj_get_child(obj, NULL);
while(child != NULL) {
if(child->style_p == NULL) {
lv_child_refr_style(child); /*Check children too*/
lv_obj_refr_style(obj); /*Send a style change signal to the object*/
} else if(child->style_p->glass) {
/*Children with 'glass' parent might be effected if their style == NULL*/
lv_child_refr_style(child);
}
child = lv_obj_get_child(obj, child);
child = lv_obj_get_child(child, NULL);
}
/*Send a style change signal to the object*/
lv_obj_refr_style(obj);
}
/**
......
......@@ -14,9 +14,9 @@ extern "C" {
* INCLUDES
*********************/
#include "lv_conf.h"
#include <misc/gfx/area.h>
#include <stddef.h>
#include <stdbool.h>
#include "misc/gfx/area.h"
#include "misc/mem/dyn_mem.h"
#include "misc/mem/linked_list.h"
#include "misc/gfx/color.h"
......
......@@ -12,7 +12,7 @@
#include "misc/mem/fifo.h"
#include "lv_refr.h"
#include "lv_vdb.h"
#include "hal/systick/systick.h"
#include "../hal/systick/systick.h"
/*********************
* DEFINES
......@@ -147,7 +147,7 @@ void lv_refr_set_monitor_cb(void (*cb)(uint32_t, uint32_t))
static void lv_refr_task(void * param)
{
uint32_t start = systick_get();
uint32_t start = lv_hal_tick_get();
lv_refr_join_area();
......@@ -162,7 +162,7 @@ static void lv_refr_task(void * param)
* therefore be sure the inv_buf is cleared prior to it*/
if(refr_done != false) {
if(monitor_cb != NULL) {
monitor_cb(systick_elaps(start), px_num);
monitor_cb(lv_hal_tick_elaps(start), px_num);
}
}
}
......
......@@ -5,7 +5,7 @@
#include "lv_conf.h"
#if LV_VDB_SIZE != 0
#include "hal/disp/disp.h"
#include "../hal/disp/hal_disp.h"
#include <stddef.h>
#include "lv_vdb.h"
......@@ -146,7 +146,7 @@ void lv_vdb_flush(void)
/* Now the full the VDB is filtered and the result is stored in the first quarter of it
* Write out the filtered map to the display*/
disp_map(vdb_act->area.x1 >> 1, vdb_act->area.y1 >> 1, vdb_act->area.x2 >> 1, vdb_act->area.y2 >> 1, vdb_act->buf);
hal_disp_map(vdb_act->area.x1 >> 1, vdb_act->area.y1 >> 1, vdb_act->area.x2 >> 1, vdb_act->area.y2 >> 1, vdb_act->buf);
#endif
}
......
......@@ -353,14 +353,21 @@ void lv_btnm_set_tgl(lv_obj_t * btnm, bool en, uint16_t id)
/**
* Set the styles of the buttons of the button matrix
* @param btnm pointer to a button matrix object
* @param state style in this state (LV_BTN_STATE_PR or LV_BTN_STATE_REL)
* @param style pointer to style
* @param rel pointer to a style for releases state
* @param pr pointer to a style for pressed state
* @param trel pointer to a style for toggled releases state
* @param tpr pointer to a style for toggled pressed state
* @param ina pointer to a style for inactive state
*/
void lv_btnm_set_styles_btn(lv_obj_t * btnm, lv_style_t * rel, lv_style_t * pr)
void lv_btnm_set_styles_btn(lv_obj_t * btnm, lv_style_t * rel, lv_style_t * pr,
lv_style_t * trel, lv_style_t * tpr, lv_style_t * ina)
{
lv_btnm_ext_t * ext = lv_obj_get_ext(btnm);
ext->style_btn_rel = rel;
ext->style_btn_pr = pr;
ext->style_btn_trel = trel;
ext->style_btn_tpr = tpr;
ext->style_btn_ina = ina;
lv_obj_inv(btnm);
......
......@@ -47,8 +47,9 @@ typedef struct
lv_btnm_callback_t cb; /*A function to call when a button is releases*/
lv_style_t * style_btn_rel; /*Style of the released buttons*/
lv_style_t * style_btn_pr; /*Style of the pressed buttons*/
lv_style_t * style_btn_trel; /*Style of the released buttons*/
lv_style_t * style_btn_tpr; /*Style of the pressed buttons*/
lv_style_t * style_btn_trel; /*Style of the toggled released buttons*/
lv_style_t * style_btn_tpr; /*Style of the toggled pressed buttons*/
lv_style_t * style_btn_ina; /*Style of the inactive buttons*/
uint8_t tgl :1; /*Enable toggling*/
}lv_btnm_ext_t;
......@@ -100,13 +101,18 @@ void lv_btnm_set_action(lv_obj_t * btnm, lv_btnm_callback_t cb);
*/
void lv_btnm_set_tgl(lv_obj_t * btnm, bool en, uint16_t id);
/**
* Set the styles of the buttons of the button matrox
* Set the styles of the buttons of the button matrix
* @param btnm pointer to a button matrix object
* @param state style in this state (LV_BTN_STATE_PR or LV_BTN_STATE_REL)
* @param style pointer to style
* @param rel pointer to a style for releases state
* @param pr pointer to a style for pressed state
* @param trel pointer to a style for toggled releases state
* @param tpr pointer to a style for toggled pressed state
* @param ina pointer to a style for inactive state
*/
void lv_btnm_set_styles_btn(lv_obj_t * btnm, lv_style_t * rel, lv_style_t * pr);
void lv_btnm_set_styles_btn(lv_obj_t * btnm, lv_style_t * rel, lv_style_t * pr,
lv_style_t * trel, lv_style_t * tpr, lv_style_t * ina);
/**
* Get the current map of a button matrix
......
......@@ -70,7 +70,7 @@ lv_obj_t * lv_ddlist_create(lv_obj_t * par, lv_obj_t * copy)
ext->opt_label = NULL;
ext->cb = NULL;
ext->opened = 0;
ext->auto_size = 0;
ext->fix_height = 0;
ext->sel_opt = 0;
ext->num_opt = 0;
ext->anim_time = LV_DDLIST_DEF_ANIM_TIME;
......@@ -86,7 +86,7 @@ lv_obj_t * lv_ddlist_create(lv_obj_t * par, lv_obj_t * copy)
if(copy == NULL) {
lv_obj_t * scrl = lv_page_get_scrl(new_ddlist);
lv_obj_set_drag(scrl, false);
lv_obj_set_style(scrl, lv_style_get(LV_STYLE_TRANSP, NULL));;
lv_obj_set_style(scrl, lv_style_get(LV_STYLE_TRANSP, NULL));
lv_cont_set_fit(scrl, true, true);
ext->opt_label = lv_label_create(new_ddlist, NULL);
......@@ -102,7 +102,7 @@ lv_obj_t * lv_ddlist_create(lv_obj_t * par, lv_obj_t * copy)
ext->opt_label = lv_label_create(new_ddlist, copy_ext->opt_label);
lv_label_set_text(ext->opt_label, lv_label_get_text(copy_ext->opt_label));
ext->sel_opt = copy_ext->sel_opt;
ext->auto_size = copy_ext->auto_size;
ext->fix_height = copy_ext->fix_height;
ext->cb = copy_ext->cb;
ext->num_opt = copy_ext->num_opt;
......@@ -131,8 +131,6 @@ bool lv_ddlist_signal(lv_obj_t * ddlist, lv_signal_t sign, void * param)
* make the object specific signal handling */
if(valid != false) {
if(sign == LV_SIGNAL_STYLE_CHG) {
lv_ddlist_ext_t * ext = lv_obj_get_ext(ddlist);
lv_obj_set_style(ext->opt_label, lv_obj_get_style(ddlist));
lv_ddlist_refr_size(ddlist, 0);
} else if(sign == LV_SIGNAL_FOCUS) {
lv_ddlist_ext_t * ext = lv_obj_get_ext(ddlist);
......@@ -195,8 +193,8 @@ void lv_ddlist_set_options(lv_obj_t * ddlist, const char ** options)
lv_label_set_text(ext->opt_label, "");
uint16_t i = 0;
while(options[i][0] != '\0') {
lv_label_append_text(ext->opt_label, options[i]);
if(options[i + 1][0] != '\0') lv_label_append_text(ext->opt_label, "\n");
lv_label_ins_text(ext->opt_label, LV_LABEL_POS_LAST, options[i]);
if(options[i + 1][0] != '\0') lv_label_ins_text(ext->opt_label, LV_LABEL_POS_LAST, "\n");
i++;
}
......@@ -235,11 +233,13 @@ 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) {
lv_ddlist_pos_act_option(ddlist);
} else {
lv_obj_inv(ddlist);
}
}
......@@ -255,15 +255,16 @@ void lv_ddlist_set_action(lv_obj_t * ddlist, lv_action_t cb)
}
/**
* Set the auto size attribute. If enabled the height will reduced to be visible on the parent.
* In this case the drop down list can be scrolled.
* Set the fix height value.
* If 0 then the opened ddlist will be auto. sized else the set height will be applied.
* @param ddlist pointer to a drop down list
* @param auto_size true: enable auto size, false: disable
* @param h the height when the list is opened (0: auto size)
*/
void lv_ddlist_set_auto_size(lv_obj_t * ddlist, bool auto_size)
void lv_ddlist_set_fix_height(lv_obj_t * ddlist, cord_t h)
{
lv_ddlist_ext_t * ext = lv_obj_get_ext(ddlist);
ext->auto_size = auto_size == false ? 0 : 1;
ext->fix_height = h;
lv_ddlist_refr_size(ddlist, 0);
}
/**
......@@ -288,6 +289,20 @@ void lv_ddlist_set_style_select(lv_obj_t * ddlist, lv_style_t * style)
ext->style_sel = style;
}
/**
* Open or Collapse the drop down list
* @param ddlist pointer to drop down list object
* @param state true: open; false: collapse
* @param anim true: use animations; false: not use animations
*/
void lv_ddlist_open(lv_obj_t * ddlist, bool state, bool anim)
{
lv_ddlist_ext_t * ext = lv_obj_get_ext(ddlist);
ext->opened = state ? 1 : 0;
lv_ddlist_refr_size(ddlist, anim ? ext->anim_time : 0);
}
/*=====================
* Getter functions
*====================*/
......@@ -341,14 +356,14 @@ void lv_ddlist_get_selected_str(lv_obj_t * ddlist, char * buf)
}
/**
* Get the auto size attribute.
* Get the fix height value.
* @param ddlist pointer to a drop down list object
* @return true: the auto_size is enabled, false: disabled
* @return the height if the ddlist is opened (0: auto size)
*/
bool lv_ddlist_get_auto_size(lv_obj_t * ddlist, bool auto_size)
cord_t lv_ddlist_get_fix_height(lv_obj_t * ddlist)
{
lv_ddlist_ext_t * ext = lv_obj_get_ext(ddlist);
return ext->auto_size == 0 ? false : true;
return ext->fix_height;
}
/**
......@@ -469,7 +484,7 @@ static lv_action_res_t lv_ddlist_rel_action(lv_obj_t * ddlist, lv_dispi_t * disp
}
/**
* Refresh the size of drop down list according its status (open or closed)
* Refresh the size of drop down list according to its status (open or closed)
* @param ddlist pointer to a drop down list object
* @param anim_time animations time for open/close [ms]
*/
......@@ -478,13 +493,9 @@ static void lv_ddlist_refr_size(lv_obj_t * ddlist, uint16_t anim_time)
lv_ddlist_ext_t * ext = lv_obj_get_ext(ddlist);
lv_style_t * style = lv_obj_get_style(ddlist);
cord_t new_height;
if(ext->opened != 0) { /*Open the list*/
new_height = lv_obj_get_height(lv_page_get_scrl(ddlist)) + 2 * style->vpad;
lv_obj_t * parent = lv_obj_get_parent(ddlist);
/*Reduce the height if enabled and required*/
if(ext->auto_size != 0 && new_height + ddlist->cords.y1 > parent->cords.y2) {
new_height = parent->cords.y2 - ddlist->cords.y1;
}
if(ext->opened) { /*Open the list*/
if(ext->fix_height == 0) new_height = lv_obj_get_height(lv_page_get_scrl(ddlist)) + 2 * style->vpad;
else new_height = ext->fix_height;
} else { /*Close the list*/
const font_t * font = style->font;
lv_style_t * label_style = lv_obj_get_style(ext->opt_label);
......@@ -525,9 +536,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);
}
......
......@@ -48,7 +48,7 @@ typedef struct
uint16_t sel_opt; /*Index of the current option*/
uint16_t anim_time; /*Open/Close animation time [ms]*/
uint8_t opened :1; /*1: The list is opened*/
uint8_t auto_size :1; /*1: Set height to show all options. 0: Set height maximum to the parent bottom*/
cord_t fix_height; /*Height if the ddlist is opened. (0: auto-size)*/
}lv_ddlist_ext_t;
......@@ -99,12 +99,12 @@ void lv_ddlist_set_selected(lv_obj_t * ddlist, uint16_t sel_opt);
void lv_ddlist_set_action(lv_obj_t * ddlist, lv_action_t cb);
/**
* Set the auto size attribute. If enabled the height will reduced to be visible on the parent.
* In this case the drop down list can be scrolled.
* Set the fix height value.
* If 0 then the opened ddlist will be auto. sized else the set height will be applied.
* @param ddlist pointer to a drop down list
* @param auto_size true: enable auto size, false: disable
* @param h the height when the list is opened (0: auto size)
*/
void lv_ddlist_set_auto_size(lv_obj_t * ddlist, bool auto_size);
void lv_ddlist_set_fix_height(lv_obj_t * ddlist, cord_t h);
/**
* Set the style of the rectangle on the selected option
......@@ -114,6 +114,14 @@ void lv_ddlist_set_auto_size(lv_obj_t * ddlist, bool auto_size);
void lv_ddlist_set_style_select(lv_obj_t * ddlist, lv_style_t * style);
/**
* Open or Collapse the drop down list
* @param ddlist pointer to drop down list object
* @param state true: open; false: collapse
* @param anim true: use animations; false: not use animations
*/
void lv_ddlist_open(lv_obj_t * ddlist, bool state, bool anim);
/**
* Get the options of a drop down list
* @param ddlist pointer to drop down list object
* @return the options separated by '\n'-s (E.g. "Option1\nOption2\nOption3")
......@@ -134,12 +142,13 @@ uint16_t lv_ddlist_get_selected(lv_obj_t * ddlist);
*/
void lv_ddlist_get_selected_str(lv_obj_t * ddlist, char * buf);
/**
* Get the auto size attribute.
* Get the fix height value.
* @param ddlist pointer to a drop down list object
* @return true: the auto_size is enabled, false: disabled
* @return the height if the ddlist is opened (0: auto size)
*/
bool lv_ddlist_get_auto_size(lv_obj_t * ddlist, bool auto_size);
cord_t lv_ddlist_get_fix_height(lv_obj_t * ddlist);
/**
* Get the style of the rectangle on the selected option
......
/**
* @file lv_kb.c
*
......@@ -15,7 +16,6 @@
/*********************
* DEFINES
*********************/
/**********************
* TYPEDEFS
**********************/
......@@ -80,7 +80,6 @@ static const char * kb_map_num[] = {
lv_obj_t * lv_kb_create(lv_obj_t * par, lv_obj_t * copy)
{
/*Create the ancestor of keyboard*/
/*TODO modify it to the ancestor create function */
lv_obj_t * new_kb = lv_btnm_create(par, copy);
dm_assert(new_kb);
......@@ -214,6 +213,7 @@ void lv_kb_set_close_action(lv_obj_t * kb, lv_action_t action)
ext->close_action = action;
}
/*=====================
* Getter functions
*====================*/
......@@ -362,10 +362,10 @@ static lv_action_res_t lv_app_kb_action(lv_obj_t * kb, uint16_t i)
lv_ta_set_cursor_pos(ext->ta, cur + 1);
}
} else if(strcmp(txt, "Hide") == 0) {
//lv_app_kb_close(false);
if(ext->close_action) ext->close_action(kb, NULL);
return LV_ACTION_RES_INV;
} else if(strcmp(txt, "Ok") == 0) {
//lv_app_kb_close(true);
if(ext->ok_action) ext->ok_action(kb, NULL);
return LV_ACTION_RES_INV;
} else {
lv_ta_add_text(ext->ta, txt);
......
......@@ -10,6 +10,7 @@
#if USE_LV_LABEL != 0
#include "misc/gfx/color.h"
#include "misc/gfx/text.h"
#include "misc/math/math_base.h"
#include "lv_label.h"
#include "../lv_obj/lv_obj.h"
......@@ -165,21 +166,27 @@ void lv_label_set_text(lv_obj_t * label, const char * text)
lv_label_ext_t * ext = lv_obj_get_ext(label);
/*If trying to set its own text or the text is NULL then refresh */
if(text == ext->txt || text == NULL) {
/*If text is NULL then refresh */
if(text == NULL) {
lv_label_refr_text(label);
return;
}
if(ext->txt == text) {
/*If set its own text then reallocate it (maybe its size changed)*/
ext->txt = dm_realloc(ext->txt, strlen(ext->txt) + 1);
} else {
/*Allocate space for the new text*/
uint32_t len = strlen(text) + 1;
if(ext->txt != NULL && ext->static_txt == 0) {
dm_free(ext->txt);
ext->txt = NULL;
}
ext->txt = dm_alloc(len);
strcpy(ext->txt, text);
ext->static_txt = 0; /*Now the text is dynamically allocated*/
}
lv_label_refr_text(label);
}
......@@ -238,11 +245,14 @@ void lv_label_set_text_static(lv_obj_t * label, const char * text)
}
/**
* Append a text to the label. The label current label text can not be static.
* Insert a text to the label. The label current label text can not be static.
* @param label pointer to label object
* @param text pointe rto the new text
* @param pos character index to insert
* 0: before first char.
* LV_LABEL_POS_LAST: after last char.
* @param txt pointer to the text to insert
*/
void lv_label_append_text(lv_obj_t * label, const char * text)
void lv_label_ins_text(lv_obj_t * label, uint32_t pos, const char * txt)
{
lv_label_ext_t * ext = lv_obj_get_ext(label);
......@@ -253,11 +263,19 @@ void lv_label_append_text(lv_obj_t * label, const char * text)
/*Allocate space for the new text*/
uint32_t old_len = strlen(ext->txt);
uint32_t app_len = strlen(text);
uint32_t new_len = app_len + old_len;
uint32_t ins_len = strlen(txt);
uint32_t new_len = ins_len + old_len;
ext->txt = dm_realloc(ext->txt, new_len + 1);
memcpy(ext->txt + old_len, text, app_len);
ext->txt[new_len] = '\0';
if(pos == LV_LABEL_POS_LAST) {
#if TXT_UTF8 == 0
pos = old_len;
#else
pos = txt_len(ext->txt);
#endif
}
txt_ins(ext->txt, pos, txt);
lv_label_refr_text(label);
}
......@@ -271,15 +289,6 @@ void lv_label_set_long_mode(lv_obj_t * label, lv_label_long_mode_t long_mode)
{
lv_label_ext_t * ext = lv_obj_get_ext(label);
/*When changing from dot mode reload the characters replaced by dots*/
if(ext->long_mode == LV_LABEL_LONG_DOTS &&
ext->dot_end != LV_LABEL_DOT_END_INV) {
uint8_t i;
for(i = 0; i < LV_LABEL_DOT_NUM + 1; i++) {
ext->txt[ext->dot_end - LV_LABEL_DOT_NUM + i] = ext->dot_tmp[i];
}
}
/*Delete the old animation (if exists)*/
anim_del(label, (anim_fp_t) lv_obj_set_x);
anim_del(label, (anim_fp_t) lv_obj_set_y);
......@@ -363,7 +372,7 @@ bool lv_label_get_recolor(lv_obj_t * label)
/**
* Get the relative x and y coordinates of a letter
* @param label pointer to a label object
* @param index index of the letter (0 ... text length)
* @param index index of the letter [0 ... text length]. Expressed in character index, not byte index (different in UTF-8)
* @param pos store the result here (E.g. index = 0 gives 0;0 coordinates)
*/
void lv_label_get_letter_pos(lv_obj_t * label, uint16_t index, point_t * pos)
......@@ -388,6 +397,8 @@ void lv_label_get_letter_pos(lv_obj_t * label, uint16_t index, point_t * pos)
max_w = CORD_MAX;
}
index = txt_utf8_get_id(txt, index);
/*Search the line of the index letter */;
while (txt[new_line_start] != '\0') {
new_line_start += txt_get_next_line(&txt[line_start], font, style->letter_space, max_w, flag);
......@@ -397,6 +408,7 @@ void lv_label_get_letter_pos(lv_obj_t * label, uint16_t index, point_t * pos)
line_start = new_line_start;
}
/*If the last character is line break then go to the next line*/
if((txt[index - 1] == '\n' || txt[index - 1] == '\r') && txt[index] == '\0') {
y += letter_height + style->line_space;
line_start = index;
......@@ -404,16 +416,20 @@ void lv_label_get_letter_pos(lv_obj_t * label, uint16_t index, point_t * pos)
/*Calculate the x coordinate*/
cord_t x = 0;
uint32_t i;
uint32_t i = line_start;
uint32_t cnt = line_start; /*Count the letter (in UTF-8 1 letter not 1 byte)*/
txt_cmd_state_t cmd_state = TXT_CMD_STATE_WAIT;
for(i = line_start; i < index; i++) {
uint32_t letter;
while(cnt < index) {
cnt += txt_utf8_size(txt[i]);
letter = txt_utf8_next(txt, &i);
/*Handle the recolor command*/
if((flag & TXT_FLAG_RECOLOR) != 0) {
if(txt_is_cmd(&cmd_state, txt[i]) != false) {
continue; /*Skip the letter is it is part of a command*/
}
}
x += (font_get_width(font, txt[i]) >> FONT_ANTIALIAS) + style->letter_space;
x += (font_get_width(font, letter) >> FONT_ANTIALIAS) + style->letter_space;
}
if(style->txt_align == LV_TXT_ALIGN_MID) {
......@@ -474,8 +490,10 @@ uint16_t lv_label_get_letter_on(lv_obj_t * label, point_t * pos)
}
txt_cmd_state_t cmd_state = TXT_CMD_STATE_WAIT;
uint16_t i;
for(i = line_start; i < new_line_start - 1; i++) {
uint32_t i = line_start;
uint32_t letter;
while(i < new_line_start - 1) {
letter = txt_utf8_next(txt, &i);
/*Handle the recolor command*/
if((flag & TXT_FLAG_RECOLOR) != 0) {
if(txt_is_cmd(&cmd_state, txt[i]) != false) {
......@@ -483,8 +501,8 @@ uint16_t lv_label_get_letter_on(lv_obj_t * label, point_t * pos)
}
}
x += (font_get_width(font, txt[i]) >> FONT_ANTIALIAS) + style->letter_space;
if(pos->x < x) break;
x += (font_get_width(font, letter) >> FONT_ANTIALIAS) + style->letter_space;
if(pos->x < x) break; /*Get the position*/
}
return i;
......@@ -660,40 +678,7 @@ static void lv_label_refr_text(lv_obj_t * label)
else if (ext->long_mode == LV_LABEL_LONG_BREAK) {
lv_obj_set_height(label, size.y);
}
/*Replace the last 'LV_LABEL_DOT_NUM' characters with dots
* and save these characters*/
else if(ext->long_mode == LV_LABEL_LONG_DOTS) {
point_t point;
point.x = lv_obj_get_width(label) - 1;
point.y = lv_obj_get_height(label) - 1;
uint16_t index = lv_label_get_letter_on(label, &point);
if(index < strlen(ext->txt) - 1) {
/* Change the last 'LV_LABEL_DOT_NUM' to dots
* (if there are at least 'LV_LABEL_DOT_NUM' characters*/
if(index > LV_LABEL_DOT_NUM) {
uint8_t i;
for(i = 0; i < LV_LABEL_DOT_NUM; i++) {
ext->dot_tmp[i] = ext->txt[index - LV_LABEL_DOT_NUM + i];
ext->txt[index - LV_LABEL_DOT_NUM + i] = '.';
}
/*The last character is '\0'. Save this character from the text too.*/
ext->dot_tmp[i] = ext->txt[index];
ext->txt[index] = '\0';
}
/*Else with short text change all characters to dots*/
else {
uint8_t i;
for(i = 0; i < LV_LABEL_DOT_NUM; i++) {
ext->txt[i] = '.';
}
ext->txt[i] = '\0';
}
/*Save the dot end index*/
ext->dot_end = index;
}
}
lv_obj_inv(label);
}
......
......@@ -19,12 +19,13 @@ extern "C" {
#include "../lv_obj/lv_obj.h"
#include "misc/gfx/font.h"
#include "misc/gfx/text.h"
#include "misc/gfx/fonts/symbol_def.h"
/*********************
* DEFINES
*********************/
#define LV_LABEL_DOT_NUM 3
#define LV_LABEL_POS_LAST 0xFFFF
/**********************
* TYPEDEFS
**********************/
......@@ -34,7 +35,6 @@ typedef enum
{
LV_LABEL_LONG_EXPAND, /*Expand the object size to the text size*/
LV_LABEL_LONG_BREAK, /*Keep the object width, break the too long lines and expand the object height*/
LV_LABEL_LONG_DOTS, /*Keep the object size, break the text and write dots in the last line*/
LV_LABEL_LONG_SCROLL, /*Expand the object size and scroll the text on the parent (move the label object)*/
LV_LABEL_LONG_ROLL, /*Keep the size and roll the text infinitely*/
}lv_label_long_mode_t;
......@@ -46,7 +46,11 @@ typedef struct
/*New data for this type */
char * txt; /*Text of the label*/
lv_label_long_mode_t long_mode; /*Determinate what to do with the long texts*/
#if TXT_UTF8 == 0
char dot_tmp[LV_LABEL_DOT_NUM + 1]; /*Store the character which are replaced by dots (Handled by the library)*/
#else
uint32_t dot_tmp[LV_LABEL_DOT_NUM + 1]; /*Store the character which are replaced by dots (Handled by the library)*/
#endif
uint16_t dot_end; /*The text end position in dot mode (Handled by the library)*/
point_t offset; /*Text draw position offset*/
uint8_t static_txt :1; /*Flag to indicate the text is static*/
......@@ -100,11 +104,16 @@ void lv_label_set_text_array(lv_obj_t * label, const char * array, uint16_t size
void lv_label_set_text_static(lv_obj_t * label, const char * text);
/**
* Append a text to the label. The label current label text can not be static.
* Insert a text to the label. The label current label text can not be static.
* @param label pointer to label object
* @param text pointe rto the new text
*/
void lv_label_append_text(lv_obj_t * label, const char * text);
* @param pos character index to insert
* 0: before first char.
* LV_LABEL_POS_LAST: after last char.
* < 0: count from the end
* -1: before the last char.
* @param txt pointer to the text to insert
*/
void lv_label_ins_text(lv_obj_t * label, uint32_t pos, const char * txt);
/**
* Set the behavior of the label with longer text then the object size
......
......@@ -349,25 +349,6 @@ void lv_list_set_sb_out(lv_obj_t * list, bool out)
ext->sb_out = out == false ? 0 : 1;
}
/**
* Enable or disable the text rolling on a list element
* @param liste pinter to list element
* @param en true: enable text scrolling, false: disable text scrolling
*/
void lv_list_set_element_text_roll(lv_obj_t * liste, bool en)
{
lv_obj_t * label = lv_list_get_element_label(liste);
if(label == NULL) return;
if(en == false) {
lv_label_set_long_mode(label, LV_LABEL_LONG_DOTS);
} else {
lv_obj_set_width(label, liste->cords.x2 - label->cords.x1);
lv_label_set_long_mode(label, LV_LABEL_LONG_ROLL);
}
}
/**
* Set styles of the list elements of a list in each state
......
......@@ -104,13 +104,6 @@ void lv_list_down(lv_obj_t * list);
void lv_list_set_sb_out(lv_obj_t * list, bool out);
/**
* Enable or disable the text rolling on a list element
* @param liste pinter to list element
* @param en true: enable text scrolling, false: disable text scrolling
*/
void lv_list_set_element_text_roll(lv_obj_t * liste, bool en);
/**
* Set styles of the list elements of a list in each state
* @param list pointer to list object
* @param rel pointer to a style for releases state
......
......@@ -3,7 +3,8 @@
*
*/
/*Search an replace: template -> object normal name with lower case (e.g. button, label etc.)
/* 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.)
*
......
......@@ -4,7 +4,8 @@
*/
/*Search an replace: template -> object normal name with lower case (e.g. button, label etc.)
/* 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.)
*
......
......@@ -14,6 +14,7 @@
#include "../lv_obj/lv_group.h"
#include "../lv_draw/lv_draw.h"
#include "misc/gfx/anim.h"
#include "misc/gfx/text.h"
#include "misc/math/math_base.h"
/*********************
......@@ -244,7 +245,7 @@ bool lv_ta_scrl_signal(lv_obj_t * scrl, lv_signal_t sign, void * param)
* @param ta pointer to a text area object
* @param c a character
*/
void lv_ta_add_char(lv_obj_t * ta, char c)
void lv_ta_add_char(lv_obj_t * ta, uint32_t c)
{
lv_ta_ext_t * ext = lv_obj_get_ext(ta);
......@@ -305,7 +306,6 @@ void lv_ta_add_char(lv_obj_t * ta, char c)
void lv_ta_add_text(lv_obj_t * ta, const char * txt)
{
lv_ta_ext_t * ext = lv_obj_get_ext(ta);
const char * label_txt = lv_label_get_text(ext->label);
uint16_t label_len = strlen(label_txt);
uint16_t txt_len = strlen(txt);
......@@ -325,7 +325,6 @@ void lv_ta_add_text(lv_obj_t * ta, const char * txt)
lv_label_set_text(ext->label, buf);
if(ext->pwd_mode != 0) {
ext->pwd_tmp = dm_realloc(ext->pwd_tmp, strlen(ext->pwd_tmp) + txt_len + 1);
dm_assert(ext->pwd_tmp);
......@@ -816,7 +815,7 @@ static bool lv_ta_design(lv_obj_t * ta, const area_t * masp, lv_design_mode_t mo
/**
* An extended scrollable design of the page. Calls the normal design function and draws a cursor.
* @param scrl pointer to the scrollabla part of the Text area
* @param scrl pointer to the scrollable part of the Text area
* @param mask the object will be drawn only in this area
* @param mode LV_DESIGN_COVER_CHK: only check if the object fully covers the 'mask_p' area
* (return 'true' if yes)
......@@ -865,30 +864,40 @@ static bool lv_ta_scrling_design(lv_obj_t * scrl, const area_t * mask, lv_design
uint16_t cur_pos = lv_ta_get_cursor_pos(ta);
const char * txt = lv_label_get_text(ta_ext->label);
cord_t letter_h = font_get_height(label_style->font) >> FONT_ANTIALIAS;
uint32_t byte_pos;
#if TXT_UTF8 != 0
byte_pos = txt_utf8_get_id(txt, cur_pos);
#else
byte_pos = cur_pos;
#endif
uint32_t letter = txt_utf8_next(&txt[byte_pos], NULL);
cord_t letter_h = font_get_height(label_style->font) >> FONT_ANTIALIAS;
/*Set letter_w (set not 0 on non printable but valid chars)*/
cord_t letter_w;
if(txt[cur_pos] == '\0' || txt[cur_pos] == '\n' || txt[cur_pos] == '\r') {
if(letter == '\0' || letter == '\n' || letter == '\r') {
letter_w = font_get_width(label_style->font, ' ');
} else {
letter_w = font_get_width(label_style->font, txt[cur_pos]);
letter_w = font_get_width(label_style->font, letter);
}
point_t letter_pos;
lv_label_get_letter_pos(ta_ext->label, cur_pos, &letter_pos);
/*If the cursor is out of the text (most right) draw it to the next line*/
if(letter_pos.x + ta_ext->label->cords.x1 + letter_w> ta_ext->label->cords.x2 && ta_ext->one_line == 0) {
if(letter_pos.x + ta_ext->label->cords.x1 + letter_w > ta_ext->label->cords.x2 && ta_ext->one_line == 0) {
letter_pos.x = 0;
letter_pos.y += letter_h + label_style->line_space;
if(txt[cur_pos] != '\0') cur_pos++;
if(letter != '\0'){
byte_pos += txt_utf8_size(txt[byte_pos]);
letter = txt_utf8_next(&txt[byte_pos], NULL);
}
if(txt[cur_pos] == '\0' || txt[cur_pos] == '\n' || txt[cur_pos] == '\r') {
if(letter == '\0' || letter == '\n' || letter == '\r') {
letter_w = font_get_width(label_style->font, ' ');
} else {
letter_w = font_get_width(label_style->font, txt[cur_pos]);
letter_w = font_get_width(label_style->font, letter);
}
}
......
......@@ -97,7 +97,7 @@ bool lv_ta_scrl_signal(lv_obj_t * scrl, lv_signal_t sign, void * param);
* @param ta pointer to a text area object
* @param c a character
*/
void lv_ta_add_char(lv_obj_t * ta, char c);
void lv_ta_add_char(lv_obj_t * ta, uint32_t c);
/**
* Insert a text to the current cursor position
......
......@@ -151,10 +151,11 @@ bool lv_tabview_signal(lv_obj_t * tabview, lv_signal_t sign, void * param)
/* The object can be deleted so check its validity and then
* make the object specific signal handling */
if(valid != false) {
lv_tabview_ext_t * ext = lv_obj_get_ext(tabview);
if(sign == LV_SIGNAL_CLEANUP) {
/*Nothing to cleanup. (No dynamically allocated memory in 'ext')*/
dm_free(ext->tab_name_ptr);
ext->tab_name_ptr = NULL;
} else if(sign == LV_SIGNAL_CORD_CHG) {
lv_tabview_ext_t * ext = lv_obj_get_ext(tabview);
if(ext->content != NULL &&
(lv_obj_get_width(tabview) != area_get_width(param) ||
lv_obj_get_height(tabview) != area_get_height(param)))
......
......@@ -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