Merge branch 'dev-6.0' into dev-6.0

This commit is contained in:
Gabor Kiss-Vamosi
2019-02-27 06:00:14 +01:00
committed by GitHub
102 changed files with 4136 additions and 4013 deletions

View File

@@ -80,7 +80,7 @@ lv_obj_t * lv_arc_create(lv_obj_t * par, const lv_obj_t * copy)
/*Set the default styles*/
lv_theme_t * th = lv_theme_get_current();
if(th) {
lv_arc_set_style(new_arc, LV_ARC_STYLE_MAIN, th->arc);
lv_arc_set_style(new_arc, LV_ARC_STYLE_MAIN, th->style.arc);
} else {
lv_arc_set_style(new_arc, LV_ARC_STYLE_MAIN, &lv_style_plain_color);
}

View File

@@ -84,8 +84,8 @@ lv_obj_t * lv_bar_create(lv_obj_t * par, const lv_obj_t * copy)
lv_theme_t * th = lv_theme_get_current();
if(th) {
lv_bar_set_style(new_bar, LV_BAR_STYLE_BG, th->bar.bg);
lv_bar_set_style(new_bar, LV_BAR_STYLE_INDIC, th->bar.indic);
lv_bar_set_style(new_bar, LV_BAR_STYLE_BG, th->style.bar.bg);
lv_bar_set_style(new_bar, LV_BAR_STYLE_INDIC, th->style.bar.indic);
} else {
lv_obj_set_style(new_bar, &lv_style_pretty);
}

View File

@@ -123,11 +123,11 @@ lv_obj_t * lv_btn_create(lv_obj_t * par, const lv_obj_t * copy)
/*Set the default styles*/
lv_theme_t * th = lv_theme_get_current();
if(th) {
lv_btn_set_style(new_btn, LV_BTN_STYLE_REL, th->btn.rel);
lv_btn_set_style(new_btn, LV_BTN_STYLE_PR, th->btn.pr);
lv_btn_set_style(new_btn, LV_BTN_STYLE_TGL_REL, th->btn.tgl_rel);
lv_btn_set_style(new_btn, LV_BTN_STYLE_TGL_PR, th->btn.tgl_pr);
lv_btn_set_style(new_btn, LV_BTN_STYLE_INA, th->btn.ina);
lv_btn_set_style(new_btn, LV_BTN_STYLE_REL, th->style.btn.rel);
lv_btn_set_style(new_btn, LV_BTN_STYLE_PR, th->style.btn.pr);
lv_btn_set_style(new_btn, LV_BTN_STYLE_TGL_REL, th->style.btn.tgl_rel);
lv_btn_set_style(new_btn, LV_BTN_STYLE_TGL_PR, th->style.btn.tgl_pr);
lv_btn_set_style(new_btn, LV_BTN_STYLE_INA, th->style.btn.ina);
} else {
lv_obj_set_style(new_btn, ext->styles[LV_BTN_STATE_REL]);
}

View File

@@ -142,15 +142,40 @@ static inline void lv_btn_set_layout(lv_obj_t * btn, lv_layout_t layout)
}
/**
* Enable the horizontal or vertical fit.
* The button size will be set to involve the children horizontally or vertically.
* Set the fit policy in all 4 directions separately.
* It tell how to change the button size automatically.
* @param btn pointer to a button object
* @param hor_en true: enable the horizontal fit
* @param ver_en true: enable the vertical fit
* @param left left fit policy from `lv_fit_t`
* @param right right fit policy from `lv_fit_t`
* @param top bottom fit policy from `lv_fit_t`
* @param bottom bottom fit policy from `lv_fit_t`
*/
static inline void lv_btn_set_fit(lv_obj_t * btn, bool hor_en, bool ver_en)
static inline void lv_btn_set_fit4(lv_obj_t * btn, lv_fit_t left, lv_fit_t right, lv_fit_t top, lv_fit_t bottom)
{
lv_cont_set_fit(btn, hor_en, ver_en);
lv_cont_set_fit4(btn, left, right, top, bottom);
}
/**
* Set the fit policy horizontally and vertically separately.
* It tell how to change the button size automatically.
* @param btn pointer to a button object
* @param hot horizontal fit policy from `lv_fit_t`
* @param ver vertical fit policy from `lv_fit_t`
*/
static inline void lv_btn_set_fit2(lv_obj_t * btn, lv_fit_t hor, lv_fit_t ver)
{
lv_cont_set_fit2(btn, hor, ver);
}
/**
* Set the fit policy in all 4 direction at once.
* It tell how to change the button size automatically.
* @param btn pointer to a button object
* @param fit fit policy from `lv_fit_t`
*/
static inline void lv_btn_set_fit(lv_obj_t * cont, lv_fit_t fit)
{
lv_cont_set_fit(cont, fit);
}
/**
@@ -218,25 +243,46 @@ static inline lv_layout_t lv_btn_get_layout(const lv_obj_t * btn)
}
/**
* Get horizontal fit enable attribute of a button
* Get the left fit mode
* @param btn pointer to a button object
* @return true: horizontal fit is enabled; false: disabled
* @return an element of `lv_fit_t`
*/
static inline bool lv_btn_get_hor_fit(const lv_obj_t * btn)
static inline lv_fit_t lv_btn_get_fit_left(const lv_obj_t * btn)
{
return lv_cont_get_hor_fit(btn);
return lv_cont_get_fit_left(btn);
}
/**
* Get vertical fit enable attribute of a container
* Get the right fit mode
* @param btn pointer to a button object
* @return true: vertical fit is enabled; false: disabled
* @return an element of `lv_fit_t`
*/
static inline bool lv_btn_get_ver_fit(const lv_obj_t * btn)
static inline lv_fit_t lv_btn_get_fit_right(const lv_obj_t * btn)
{
return lv_cont_get_ver_fit(btn);
return lv_cont_get_fit_right(btn);
}
/**
* Get the top fit mode
* @param btn pointer to a button object
* @return an element of `lv_fit_t`
*/
static inline lv_fit_t lv_btn_get_fit_top(const lv_obj_t * btn)
{
return lv_cont_get_fit_top(btn);
}
/**
* Get the bottom fit mode
* @param btn pointer to a button object
* @return an element of `lv_fit_t`
*/
static inline lv_fit_t lv_btn_get_fit_bottom(const lv_obj_t * btn)
{
return lv_cont_get_fit_bottom(btn);
}
/**
* Get time of the ink in effect (draw a circle on click to animate in the new state)
* @param btn pointer to a button object

View File

@@ -101,18 +101,18 @@ lv_obj_t * lv_btnm_create(lv_obj_t * par, const lv_obj_t * copy)
/*Init the new button matrix object*/
if(copy == NULL) {
lv_obj_set_size(new_btnm, LV_HOR_RES / 2, LV_VER_RES / 4);
lv_obj_set_size(new_btnm, LV_DPI * 3, LV_DPI * 2);
lv_btnm_set_map(new_btnm, lv_btnm_def_map);
/*Set the default styles*/
lv_theme_t * th = lv_theme_get_current();
if(th) {
lv_btnm_set_style(new_btnm, LV_BTNM_STYLE_BG, th->btnm.bg);
lv_btnm_set_style(new_btnm, LV_BTNM_STYLE_BTN_REL, th->btnm.btn.rel);
lv_btnm_set_style(new_btnm, LV_BTNM_STYLE_BTN_PR, th->btnm.btn.pr);
lv_btnm_set_style(new_btnm, LV_BTNM_STYLE_BTN_TGL_REL, th->btnm.btn.tgl_rel);
lv_btnm_set_style(new_btnm, LV_BTNM_STYLE_BTN_TGL_PR, th->btnm.btn.tgl_pr);
lv_btnm_set_style(new_btnm, LV_BTNM_STYLE_BTN_INA, th->btnm.btn.ina);
lv_btnm_set_style(new_btnm, LV_BTNM_STYLE_BG, th->style.btnm.bg);
lv_btnm_set_style(new_btnm, LV_BTNM_STYLE_BTN_REL, th->style.btnm.btn.rel);
lv_btnm_set_style(new_btnm, LV_BTNM_STYLE_BTN_PR, th->style.btnm.btn.pr);
lv_btnm_set_style(new_btnm, LV_BTNM_STYLE_BTN_TGL_REL, th->style.btnm.btn.tgl_rel);
lv_btnm_set_style(new_btnm, LV_BTNM_STYLE_BTN_TGL_PR, th->style.btnm.btn.tgl_pr);
lv_btnm_set_style(new_btnm, LV_BTNM_STYLE_BTN_INA, th->style.btnm.btn.ina);
} else {
lv_obj_set_style(new_btnm, &lv_style_pretty);
}
@@ -708,6 +708,7 @@ static lv_res_t lv_btnm_signal(lv_obj_t * btnm, lv_signal_t sign, void * param)
/*Invalidate to old and the new areas*/;
//lv_obj_get_coords(btnm, &btnm_area);
if(btn_pr != ext->btn_id_pr) {
lv_disp_t * disp = lv_obj_get_disp(btnm);
lv_indev_reset_lpr(param);
if(ext->btn_id_pr != LV_BTNM_PR_NONE) {
invalidate_button_area(btnm, ext->btn_id_pr);
@@ -736,6 +737,7 @@ static lv_res_t lv_btnm_signal(lv_obj_t * btnm, lv_signal_t sign, void * param)
if(button_is_inactive(ext->ctrl_bits[ext->btn_id_pr]) == false && txt_i != LV_BTNM_PR_NONE) { /*Ignore the inactive buttons and clicks between the buttons*/
if(ext->action) res = ext->action(btnm, cut_ctrl_byte(ext->map_p[txt_i]));
if(res == LV_RES_OK) {
lv_disp_t * disp = lv_obj_get_disp(btnm);
/*Invalidate to old pressed area*/;
invalidate_button_area(btnm, ext->btn_id_pr);
@@ -743,6 +745,7 @@ static lv_res_t lv_btnm_signal(lv_obj_t * btnm, lv_signal_t sign, void * param)
if(ext->toggle != 0) {
/*Invalidate to old toggled area*/;
invalidate_button_area(btnm, ext->btn_id_tgl);
ext->btn_id_tgl = ext->btn_id_pr;
}

View File

@@ -130,14 +130,14 @@ lv_obj_t * lv_calendar_create(lv_obj_t * par, const lv_obj_t * copy)
lv_theme_t * th = lv_theme_get_current();
if(th) {
lv_calendar_set_style(new_calendar, LV_CALENDAR_STYLE_BG, th->calendar.bg);
lv_calendar_set_style(new_calendar, LV_CALENDAR_STYLE_HEADER, th->calendar.header);
lv_calendar_set_style(new_calendar, LV_CALENDAR_STYLE_HEADER_PR, th->calendar.header_pr);
lv_calendar_set_style(new_calendar, LV_CALENDAR_STYLE_DAY_NAMES, th->calendar.day_names);
lv_calendar_set_style(new_calendar, LV_CALENDAR_STYLE_WEEK_BOX, th->calendar.week_box);
lv_calendar_set_style(new_calendar, LV_CALENDAR_STYLE_TODAY_BOX, th->calendar.today_box);
lv_calendar_set_style(new_calendar, LV_CALENDAR_STYLE_HIGHLIGHTED_DAYS, th->calendar.highlighted_days);
lv_calendar_set_style(new_calendar, LV_CALENDAR_STYLE_INACTIVE_DAYS, th->calendar.inactive_days);
lv_calendar_set_style(new_calendar, LV_CALENDAR_STYLE_BG, th->style.calendar.bg);
lv_calendar_set_style(new_calendar, LV_CALENDAR_STYLE_HEADER, th->style.calendar.header);
lv_calendar_set_style(new_calendar, LV_CALENDAR_STYLE_HEADER_PR, th->style.calendar.header_pr);
lv_calendar_set_style(new_calendar, LV_CALENDAR_STYLE_DAY_NAMES, th->style.calendar.day_names);
lv_calendar_set_style(new_calendar, LV_CALENDAR_STYLE_WEEK_BOX, th->style.calendar.week_box);
lv_calendar_set_style(new_calendar, LV_CALENDAR_STYLE_TODAY_BOX, th->style.calendar.today_box);
lv_calendar_set_style(new_calendar, LV_CALENDAR_STYLE_HIGHLIGHTED_DAYS, th->style.calendar.highlighted_days);
lv_calendar_set_style(new_calendar, LV_CALENDAR_STYLE_INACTIVE_DAYS, th->style.calendar.inactive_days);
} else {
lv_calendar_set_style(new_calendar, LV_CALENDAR_STYLE_BG, &lv_style_pretty);
lv_calendar_set_style(new_calendar, LV_CALENDAR_STYLE_HEADER, ext->style_header);

View File

@@ -81,19 +81,19 @@ lv_obj_t * lv_cb_create(lv_obj_t * par, const lv_obj_t * copy)
lv_cb_set_text(new_cb, "Check box");
lv_btn_set_layout(new_cb, LV_LAYOUT_ROW_M);
lv_btn_set_fit(new_cb, true, true);
lv_btn_set_fit(new_cb, LV_FIT_TIGHT);
lv_btn_set_toggle(new_cb, true);
lv_obj_set_protect(new_cb, LV_PROTECT_PRESS_LOST);
/*Set the default styles*/
lv_theme_t * th = lv_theme_get_current();
if(th) {
lv_cb_set_style(new_cb, LV_CB_STYLE_BG, th->cb.bg);
lv_cb_set_style(new_cb, LV_CB_STYLE_BOX_REL, th->cb.box.rel);
lv_cb_set_style(new_cb, LV_CB_STYLE_BOX_PR, th->cb.box.pr);
lv_cb_set_style(new_cb, LV_CB_STYLE_BOX_TGL_REL, th->cb.box.tgl_rel);
lv_cb_set_style(new_cb, LV_CB_STYLE_BOX_TGL_PR, th->cb.box.tgl_pr);
lv_cb_set_style(new_cb, LV_CB_STYLE_BOX_INA, th->cb.box.ina);
lv_cb_set_style(new_cb, LV_CB_STYLE_BG, th->style.cb.bg);
lv_cb_set_style(new_cb, LV_CB_STYLE_BOX_REL, th->style.cb.box.rel);
lv_cb_set_style(new_cb, LV_CB_STYLE_BOX_PR, th->style.cb.box.pr);
lv_cb_set_style(new_cb, LV_CB_STYLE_BOX_TGL_REL, th->style.cb.box.tgl_rel);
lv_cb_set_style(new_cb, LV_CB_STYLE_BOX_TGL_PR, th->style.cb.box.tgl_pr);
lv_cb_set_style(new_cb, LV_CB_STYLE_BOX_INA, th->style.cb.box.ina);
} else {
lv_cb_set_style(new_cb, LV_CB_STYLE_BG, &lv_style_transp);
lv_cb_set_style(new_cb, LV_CB_STYLE_BOX_REL, &lv_style_pretty);

View File

@@ -90,12 +90,12 @@ lv_obj_t * lv_chart_create(lv_obj_t * par, const lv_obj_t * copy)
/*Init the new chart background object*/
if(copy == NULL) {
lv_obj_set_size(new_chart, LV_HOR_RES / 3, LV_VER_RES / 3);
lv_obj_set_size(new_chart, LV_DPI * 3, LV_DPI * 2);
/*Set the default styles*/
lv_theme_t * th = lv_theme_get_current();
if(th) {
lv_chart_set_style(new_chart, th->chart);
lv_chart_set_style(new_chart, th->style.chart);
} else {
lv_chart_set_style(new_chart, &lv_style_pretty);
}
@@ -175,9 +175,10 @@ void lv_chart_clear_serie(lv_obj_t * chart, lv_chart_series_t * serie)
if(chart == NULL || serie == NULL)
return;
lv_chart_ext_t * ext = lv_obj_get_ext_attr(chart);
if(ext == NULL)
return;
for(uint32_t i = 0; i < ext->point_cnt; i++)
if(ext == NULL) return;
uint32_t i;
for(i = 0; i < ext->point_cnt; i++)
{
serie->points[i] = LV_CHART_POINT_DEF;
}
@@ -764,12 +765,18 @@ static void lv_chart_draw_cols(lv_obj_t * chart, const lv_area_t * mask)
*/
static void lv_chart_draw_vertical_lines(lv_obj_t * chart, const lv_area_t * mask)
{
lv_chart_ext_t * ext = lv_obj_get_ext_attr(chart);
lv_coord_t w = lv_obj_get_width(chart);
/*Vertical lines works only if the width == point count. Else use the normal line type*/
if(ext->point_cnt != w) {
lv_chart_draw_lines(chart, mask);
return;
}
uint16_t i;
lv_point_t p1;
lv_point_t p2;
lv_coord_t w = lv_obj_get_width(chart);
lv_coord_t h = lv_obj_get_height(chart);
lv_coord_t x_ofs = chart->coords.x1;
lv_coord_t y_ofs = chart->coords.y1;
@@ -789,47 +796,28 @@ static void lv_chart_draw_vertical_lines(lv_obj_t * chart, const lv_area_t * mas
p2.x = 0 + x_ofs;
y_tmp = (int32_t)((int32_t) ser->points[0] - ext->ymin) * h;
y_tmp = y_tmp / (ext->ymax - ext->ymin);
p1.y = LV_COORD_MIN;
p2.y = h - y_tmp + y_ofs;
p1.y = p2.y;
if(ext->point_cnt == w)
for(i = 0; i < ext->point_cnt; i++)
{
for(i = 0; i < ext->point_cnt; i++)
y_tmp = (int32_t)((int32_t) ser->points[i] - ext->ymin) * h;
y_tmp = y_tmp / (ext->ymax - ext->ymin);
p2.y = h - y_tmp + y_ofs;
if(p1.y == p2.y)
{
p2.x++;
}
y_tmp = (int32_t)((int32_t) ser->points[i] - ext->ymin) * h;
y_tmp = y_tmp / (ext->ymax - ext->ymin);
p2.y = h - y_tmp + y_ofs;
if(p1.y == p2.y)
{
p2.x++;
}
if(ser->points[i] != LV_CHART_POINT_DEF) {
lv_draw_line(&p1, &p2, mask, &style, opa_scale);
p2.x = ((w * i) / (ext->point_cnt - 1)) + x_ofs;
p1.x = p2.x;
p1.y = p2.y;
}
}
else
{
for(i = 1; i < ext->point_cnt; i ++) {
p1.x = p2.x;
p1.y = p2.y;
p2.x = ((w * i) / (ext->point_cnt - 1)) + x_ofs;
y_tmp = (int32_t)((int32_t) ser->points[i] - ext->ymin) * h;
y_tmp = y_tmp / (ext->ymax - ext->ymin);
p2.y = h - y_tmp + y_ofs;
if(ser->points[i - 1] >= 0 && ser->points[i] >= 0)
{
lv_draw_line(&p1, &p2, mask, &style, opa_scale);
}
}
p2.x = ((w * i) / (ext->point_cnt - 1)) + x_ofs;
p1.x = p2.x;
p1.y = p2.y;
}
}
}

View File

@@ -62,10 +62,10 @@ typedef struct
/*Chart types*/
enum
{
LV_CHART_TYPE_LINE = 0x01,
LV_CHART_TYPE_COLUMN = 0x02,
LV_CHART_TYPE_POINT = 0x04,
LV_CHART_TYPE_VERTICAL_LINE = 0x08,
LV_CHART_TYPE_LINE = 0x01, /*Connect the points with lines*/
LV_CHART_TYPE_COLUMN = 0x02, /*Draw columns*/
LV_CHART_TYPE_POINT = 0x04, /*Draw circles on the points*/
LV_CHART_TYPE_VERTICAL_LINE = 0x08, /*Draw vertical lines on points (useful when chart width == point count)*/
};
typedef uint8_t lv_chart_type_t;

View File

@@ -15,7 +15,7 @@
#include <string.h>
#include "../lv_draw/lv_draw.h"
#include "../lv_draw/lv_draw_vbasic.h"
#include "../lv_draw/lv_draw_basic.h"
#include "../lv_themes/lv_theme.h"
#include "../lv_misc/lv_area.h"
#include "../lv_misc/lv_color.h"
@@ -78,8 +78,10 @@ lv_obj_t * lv_cont_create(lv_obj_t * par, const lv_obj_t * copy)
if(ext == NULL) return NULL;
lv_mem_assert(ext);
ext->hor_fit = 0;
ext->ver_fit = 0;
ext->fit_left = LV_FIT_NONE;
ext->fit_right = LV_FIT_NONE;
ext->fit_top = LV_FIT_NONE;
ext->fit_bottom = LV_FIT_NONE;
ext->layout = LV_LAYOUT_OFF;
lv_obj_set_signal_func(new_cont, lv_cont_signal);
@@ -89,7 +91,7 @@ lv_obj_t * lv_cont_create(lv_obj_t * par, const lv_obj_t * copy)
/*Set the default styles*/
lv_theme_t * th = lv_theme_get_current();
if(th) {
lv_cont_set_style(new_cont, th->cont);
lv_cont_set_style(new_cont, th->style.cont);
} else {
lv_cont_set_style(new_cont, &lv_style_pretty);
}
@@ -97,8 +99,10 @@ lv_obj_t * lv_cont_create(lv_obj_t * par, const lv_obj_t * copy)
/*Copy an existing object*/
else {
lv_cont_ext_t * copy_ext = lv_obj_get_ext_attr(copy);
ext->hor_fit = copy_ext->hor_fit;
ext->ver_fit = copy_ext->ver_fit;
ext->fit_left = copy_ext->fit_left;
ext->fit_right = copy_ext->fit_right;
ext->fit_top = copy_ext->fit_top;
ext->fit_bottom = copy_ext->fit_bottom;
ext->layout = copy_ext->layout;
/*Refresh the style with new signal function*/
@@ -107,7 +111,6 @@ lv_obj_t * lv_cont_create(lv_obj_t * par, const lv_obj_t * copy)
LV_LOG_INFO("container created");
return new_cont;
}
@@ -131,22 +134,31 @@ void lv_cont_set_layout(lv_obj_t * cont, lv_layout_t layout)
cont->signal_func(cont, LV_SIGNAL_CHILD_CHG, NULL);
}
/**
* Enable the horizontal or vertical fit.
* The container size will be set to involve the children horizontally or vertically.
* Set the fit policy in all 4 directions separately.
* It tell how to change the container's size automatically.
* @param cont pointer to a container object
* @param hor_en true: enable the horizontal fit
* @param ver_en true: enable the vertical fit
* @param left left fit policy from `lv_fit_t`
* @param right right fit policy from `lv_fit_t`
* @param top bottom fit policy from `lv_fit_t`
* @param bottom bottom fit policy from `lv_fit_t`
*/
void lv_cont_set_fit(lv_obj_t * cont, bool hor_en, bool ver_en)
void lv_cont_set_fit4(lv_obj_t * cont, lv_fit_t left, lv_fit_t right, lv_fit_t top, lv_fit_t bottom)
{
lv_obj_invalidate(cont);
lv_cont_ext_t * ext = lv_obj_get_ext_attr(cont);
if(ext->hor_fit == hor_en && ext->ver_fit == ver_en) return;
if(ext->fit_left == left &&
ext->fit_right == right &&
ext->fit_top == top &&
ext->fit_bottom == bottom)
{
return;
}
ext->hor_fit = hor_en == false ? 0 : 1;
ext->ver_fit = ver_en == false ? 0 : 1;
ext->fit_left = left;
ext->fit_right = right;
ext->fit_top = top;
ext->fit_bottom = bottom;
/*Send a signal to refresh the layout*/
cont->signal_func(cont, LV_SIGNAL_CHILD_CHG, NULL);
@@ -168,25 +180,47 @@ lv_layout_t lv_cont_get_layout(const lv_obj_t * cont)
}
/**
* Get horizontal fit enable attribute of a container
* Get left fit mode of a container
* @param cont pointer to a container object
* @return true: horizontal fit is enabled; false: disabled
* @return an element of `lv_fit_t`
*/
bool lv_cont_get_hor_fit(const lv_obj_t * cont)
lv_fit_t lv_cont_get_fit_left(const lv_obj_t * cont)
{
lv_cont_ext_t * ext = lv_obj_get_ext_attr(cont);
return ext->hor_fit == 0 ? false : true;
return ext->fit_left;
}
/**
* Get vertical fit enable attribute of a container
* Get right fit mode of a container
* @param cont pointer to a container object
* @return true: vertical fit is enabled; false: disabled
* @return an element of `lv_fit_t`
*/
bool lv_cont_get_ver_fit(const lv_obj_t * cont)
lv_fit_t lv_cont_get_fit_right(const lv_obj_t * cont)
{
lv_cont_ext_t * ext = lv_obj_get_ext_attr(cont);
return ext->ver_fit == 0 ? false : true;
return ext->fit_right;
}
/**
* Get top fit mode of a container
* @param cont pointer to a container object
* @return an element of `lv_fit_t`
*/
lv_fit_t lv_cont_get_fit_top(const lv_obj_t * cont)
{
lv_cont_ext_t * ext = lv_obj_get_ext_attr(cont);
return ext->fit_top;
}
/**
* Get bottom fit mode of a container
* @param cont pointer to a container object
* @return an element of `lv_fit_t`
*/
lv_fit_t lv_cont_get_fit_bottom(const lv_obj_t * cont)
{
lv_cont_ext_t * ext = lv_obj_get_ext_attr(cont);
return ext->fit_bottom;
}
/**
@@ -244,6 +278,10 @@ static lv_res_t lv_cont_signal(lv_obj_t * cont, lv_signal_t sign, void * param)
lv_cont_refr_layout(cont);
lv_cont_refr_autofit(cont);
}
} else if(sign == LV_SIGNAL_PARENT_SIZE_CHG) {
/*FLOOD and FILL fit needs to be refreshed if the parent size has changed*/
lv_cont_refr_autofit(cont);
} else if(sign == LV_SIGNAL_GET_TYPE) {
lv_obj_type_t * buf = param;
uint8_t i;
@@ -574,70 +612,112 @@ static void lv_cont_refr_autofit(lv_obj_t * cont)
{
lv_cont_ext_t * ext = lv_obj_get_ext_attr(cont);
if(ext->hor_fit == 0 &&
ext->ver_fit == 0) {
if(ext->fit_left == LV_FIT_NONE &&
ext->fit_right == LV_FIT_NONE &&
ext->fit_top == LV_FIT_NONE &&
ext->fit_bottom == LV_FIT_NONE)
{
return;
}
lv_area_t new_cords;
lv_area_t tight_area;
lv_area_t ori;
lv_style_t * style = lv_obj_get_style(cont);
lv_obj_t * i;
lv_coord_t hpad = style->body.padding.hor;
lv_coord_t vpad = style->body.padding.ver;
lv_obj_t * par = lv_obj_get_parent(cont);
lv_style_t * par_style = lv_obj_get_style(par);
lv_area_t flood_area;
lv_area_copy(&flood_area, &par->coords);
flood_area.x1 += par_style->body.padding.hor;
flood_area.x2 -= par_style->body.padding.hor;
flood_area.y1 += par_style->body.padding.ver;
flood_area.y2 -= par_style->body.padding.ver;
/*Search the side coordinates of the children*/
lv_obj_get_coords(cont, &ori);
lv_obj_get_coords(cont, &new_cords);
lv_obj_get_coords(cont, &tight_area);
new_cords.x1 = LV_COORD_MAX;
new_cords.y1 = LV_COORD_MAX;
new_cords.x2 = LV_COORD_MIN;
new_cords.y2 = LV_COORD_MIN;
bool has_children = lv_ll_is_empty(&cont->child_ll) ? false : true;
LL_READ(cont->child_ll, i) {
if(lv_obj_get_hidden(i) != false) continue;
new_cords.x1 = LV_MATH_MIN(new_cords.x1, i->coords.x1);
new_cords.y1 = LV_MATH_MIN(new_cords.y1, i->coords.y1);
new_cords.x2 = LV_MATH_MAX(new_cords.x2, i->coords.x2);
new_cords.y2 = LV_MATH_MAX(new_cords.y2, i->coords.y2);
if(has_children) {
tight_area.x1 = LV_COORD_MAX;
tight_area.y1 = LV_COORD_MAX;
tight_area.x2 = LV_COORD_MIN;
tight_area.y2 = LV_COORD_MIN;
LL_READ(cont->child_ll, i) {
if(lv_obj_get_hidden(i) != false) continue;
tight_area.x1 = LV_MATH_MIN(tight_area.x1, i->coords.x1);
tight_area.y1 = LV_MATH_MIN(tight_area.y1, i->coords.y1);
tight_area.x2 = LV_MATH_MAX(tight_area.x2, i->coords.x2);
tight_area.y2 = LV_MATH_MAX(tight_area.y2, i->coords.y2);
}
tight_area.x1 -= hpad;
tight_area.x2 += hpad;
tight_area.y1 -= vpad;
tight_area.y2 += vpad;
}
/*If the value is not the init value then the page has >=1 child.*/
if(new_cords.x1 != LV_COORD_MAX) {
if(ext->hor_fit != 0) {
new_cords.x1 -= hpad;
new_cords.x2 += hpad;
} else {
new_cords.x1 = cont->coords.x1;
new_cords.x2 = cont->coords.x2;
}
if(ext->ver_fit != 0) {
new_cords.y1 -= vpad;
new_cords.y2 += vpad;
} else {
new_cords.y1 = cont->coords.y1;
new_cords.y2 = cont->coords.y2;
}
lv_area_t new_area;
lv_area_copy(&new_area, &ori);
/*Do nothing if the coordinates are not changed*/
if(cont->coords.x1 != new_cords.x1 ||
cont->coords.y1 != new_cords.y1 ||
cont->coords.x2 != new_cords.x2 ||
cont->coords.y2 != new_cords.y2) {
switch(ext->fit_left) {
case LV_FIT_TIGHT: new_area.x1 = tight_area.x1; break;
case LV_FIT_FLOOD: new_area.x1 = flood_area.x1; break;
case LV_FIT_FILL: new_area.x1 = has_children ? LV_MATH_MIN(tight_area.x1, flood_area.x1) : flood_area.x1; break;
default: break;
}
lv_obj_invalidate(cont);
lv_area_copy(&cont->coords, &new_cords);
lv_obj_invalidate(cont);
switch(ext->fit_right) {
case LV_FIT_TIGHT: new_area.x2 = tight_area.x2; break;
case LV_FIT_FLOOD: new_area.x2 = flood_area.x2; break;
case LV_FIT_FILL: new_area.x2 = has_children ? LV_MATH_MAX(tight_area.x2, flood_area.x2) : flood_area.x2; break;
default: break;
}
/*Notify the object about its new coordinates*/
cont->signal_func(cont, LV_SIGNAL_CORD_CHG, &ori);
switch(ext->fit_top) {
case LV_FIT_TIGHT: new_area.y1 = tight_area.y1; break;
case LV_FIT_FLOOD: new_area.y1 = flood_area.y1; break;
case LV_FIT_FILL: new_area.y1 = has_children ? LV_MATH_MIN(tight_area.y1, flood_area.y1) : flood_area.y1; break;
default: break;
}
/*Inform the parent about the new coordinates*/
lv_obj_t * par = lv_obj_get_parent(cont);
par->signal_func(par, LV_SIGNAL_CHILD_CHG, cont);
switch(ext->fit_bottom) {
case LV_FIT_TIGHT: new_area.y2 = tight_area.y2; break;
case LV_FIT_FLOOD: new_area.y2 = flood_area.y2; break;
case LV_FIT_FILL: new_area.y2 = has_children ? LV_MATH_MAX(tight_area.y2, flood_area.y2) : flood_area.y2; break;
default: break;
}
/*Do nothing if the coordinates are not changed*/
if(cont->coords.x1 != new_area.x1 ||
cont->coords.y1 != new_area.y1 ||
cont->coords.x2 != new_area.x2 ||
cont->coords.y2 != new_area.y2)
{
lv_obj_invalidate(cont);
lv_area_copy(&cont->coords, &new_area);
lv_obj_invalidate(cont);
/*Notify the object about its new coordinates*/
cont->signal_func(cont, LV_SIGNAL_CORD_CHG, &ori);
/*Inform the parent about the new coordinates*/
lv_obj_t * par = lv_obj_get_parent(cont);
par->signal_func(par, LV_SIGNAL_CHILD_CHG, cont);
/*Tell the children the parent's size has changed*/
lv_obj_t * i;
LL_READ(cont->child_ll, i) {
i->signal_func(i, LV_SIGNAL_PARENT_SIZE_CHG, NULL);
}
}
}
#endif

View File

@@ -47,13 +47,23 @@ enum
};
typedef uint8_t lv_layout_t;
typedef enum {
LV_FIT_NONE, /*Do not change the size automatically*/
LV_FIT_TIGHT, /*Involve the children*/
LV_FIT_FLOOD, /*Align the size to the parent's edge*/
LV_FIT_FILL, /*Align the size to the parent's edge first but if there is an object out of it then involve it*/
}lv_fit_t;
typedef struct
{
/*Inherited from 'base_obj' so no inherited ext. */ /*Ext. of ancestor*/
/*New data for this type */
uint8_t layout :4; /*A layout from 'lv_cont_layout_t' enum*/
uint8_t hor_fit :1; /*1: Enable horizontal fit to involve all children*/
uint8_t ver_fit :1; /*1: Enable horizontal fit to involve all children*/
uint8_t layout :4; /*A layout from 'lv_layout_t' enum*/
uint8_t fit_left :2; /*A fit type from `lv_fit_t` enum */
uint8_t fit_right :2; /*A fit type from `lv_fit_t` enum */
uint8_t fit_top :2; /*A fit type from `lv_fit_t` enum */
uint8_t fit_bottom :2; /*A fit type from `lv_fit_t` enum */
} lv_cont_ext_t;
@@ -80,15 +90,41 @@ lv_obj_t * lv_cont_create(lv_obj_t * par, const lv_obj_t * copy);
*/
void lv_cont_set_layout(lv_obj_t * cont, lv_layout_t layout);
/**
* Set the fit policy in all 4 directions separately.
* It tell how to change the container's size automatically.
* @param cont pointer to a container object
* @param left left fit policy from `lv_fit_t`
* @param right right fit policy from `lv_fit_t`
* @param top bottom fit policy from `lv_fit_t`
* @param bottom bottom fit policy from `lv_fit_t`
*/
void lv_cont_set_fit4(lv_obj_t * cont, lv_fit_t left, lv_fit_t right, lv_fit_t top, lv_fit_t bottom);
/**
* Enable the horizontal or vertical fit.
* The container size will be set to involve the children horizontally or vertically.
* Set the fit policy horizontally and vertically separately.
* It tell how to change the container's size automatically.
* @param cont pointer to a container object
* @param hor_en true: enable the horizontal fit
* @param ver_en true: enable the vertical fit
* @param hot horizontal fit policy from `lv_fit_t`
* @param ver vertical fit policy from `lv_fit_t`
*/
void lv_cont_set_fit(lv_obj_t * cont, bool hor_en, bool ver_en);
static inline void lv_cont_set_fit2(lv_obj_t * cont, lv_fit_t hor, lv_fit_t ver)
{
lv_cont_set_fit4(cont, hor, hor, ver, ver);
}
/**
* Set the fit policyin all 4 direction at once.
* It tell how to change the container's size automatically.
* @param cont pointer to a container object
* @param fit fit policy from `lv_fit_t`
*/
static inline void lv_cont_set_fit(lv_obj_t * cont, lv_fit_t fit)
{
lv_cont_set_fit4(cont, fit, fit, fit, fit);
}
/**
* Set the style of a container
@@ -112,18 +148,32 @@ static inline void lv_cont_set_style(lv_obj_t *cont, lv_style_t * style)
lv_layout_t lv_cont_get_layout(const lv_obj_t * cont);
/**
* Get horizontal fit enable attribute of a container
* Get left fit mode of a container
* @param cont pointer to a container object
* @return true: horizontal fit is enabled; false: disabled
* @return an element of `lv_fit_t`
*/
bool lv_cont_get_hor_fit(const lv_obj_t * cont);
lv_fit_t lv_cont_get_fit_left(const lv_obj_t * cont);
/**
* Get vertical fit enable attribute of a container
* Get right fit mode of a container
* @param cont pointer to a container object
* @return true: vertical fit is enabled; false: disabled
* @return an element of `lv_fit_t`
*/
bool lv_cont_get_ver_fit(const lv_obj_t * cont);
lv_fit_t lv_cont_get_fit_right(const lv_obj_t * cont);
/**
* Get top fit mode of a container
* @param cont pointer to a container object
* @return an element of `lv_fit_t`
*/
lv_fit_t lv_cont_get_fit_top(const lv_obj_t * cont);
/**
* Get bottom fit mode of a container
* @param cont pointer to a container object
* @return an element of `lv_fit_t`
*/
lv_fit_t lv_cont_get_fit_bottom(const lv_obj_t * cont);
/**

View File

@@ -104,10 +104,10 @@ lv_obj_t * lv_ddlist_create(lv_obj_t * par, const lv_obj_t * copy)
if(copy == NULL) {
lv_obj_t * scrl = lv_page_get_scrl(new_ddlist);
lv_obj_set_drag(scrl, false);
lv_page_set_scrl_fit(new_ddlist, true, true);
lv_page_set_scrl_fit2(new_ddlist, LV_FIT_TIGHT, LV_FIT_TIGHT);
ext->label = lv_label_create(new_ddlist, NULL);
lv_cont_set_fit(new_ddlist, true, false);
lv_cont_set_fit2(new_ddlist, LV_FIT_TIGHT, LV_FIT_NONE);
lv_page_set_rel_action(new_ddlist, lv_ddlist_release_action);
lv_page_set_sb_mode(new_ddlist, LV_SB_MODE_DRAG);
lv_page_set_sb_mode(new_ddlist, LV_SB_MODE_HIDE);
@@ -118,9 +118,9 @@ lv_obj_t * lv_ddlist_create(lv_obj_t * par, const lv_obj_t * copy)
/*Set the default styles*/
lv_theme_t * th = lv_theme_get_current();
if(th) {
lv_ddlist_set_style(new_ddlist, LV_DDLIST_STYLE_BG, th->ddlist.bg);
lv_ddlist_set_style(new_ddlist, LV_DDLIST_STYLE_SEL, th->ddlist.sel);
lv_ddlist_set_style(new_ddlist, LV_DDLIST_STYLE_SB, th->ddlist.sb);
lv_ddlist_set_style(new_ddlist, LV_DDLIST_STYLE_BG, th->style.ddlist.bg);
lv_ddlist_set_style(new_ddlist, LV_DDLIST_STYLE_SEL, th->style.ddlist.sel);
lv_ddlist_set_style(new_ddlist, LV_DDLIST_STYLE_SB, th->style.ddlist.sb);
} else {
lv_ddlist_set_style(new_ddlist, LV_DDLIST_STYLE_BG, &lv_style_pretty);
lv_ddlist_set_style(new_ddlist, LV_DDLIST_STYLE_SEL, &lv_style_plain_color);
@@ -238,12 +238,11 @@ void lv_ddlist_set_fix_height(lv_obj_t * ddlist, lv_coord_t h)
/**
* Enable or disable the horizontal fit to the content
* @param ddlist pointer to a drop down list
* @param en true: enable auto fit; false: disable auto fit
* @param fit fit mode fron `lv_fit_t` (Typically `LV_FIT_NONE` or `LV_FIT_TIGHT`)
*/
void lv_ddlist_set_hor_fit(lv_obj_t * ddlist, bool en)
void lv_ddlist_set_hor_fit(lv_obj_t * ddlist, lv_fit_t fit)
{
lv_cont_set_fit(ddlist, en, lv_cont_get_ver_fit(ddlist));
lv_page_set_scrl_fit(ddlist, en, lv_page_get_scrl_fit_ver(ddlist));
lv_cont_set_fit2(ddlist, fit, lv_cont_get_fit_top(ddlist));
lv_ddlist_refr_size(ddlist, false);
}
@@ -624,6 +623,7 @@ static lv_res_t lv_ddlist_signal(lv_obj_t * ddlist, lv_signal_t sign, void * par
} else if(sign == LV_SIGNAL_CLEANUP) {
ext->label = NULL;
} else if(sign == LV_SIGNAL_FOCUS) {
#if USE_LV_GROUP
lv_group_t * g = lv_obj_get_group(ddlist);
bool editing = lv_group_get_editing(g);
lv_hal_indev_type_t indev_type = lv_indev_get_type(lv_indev_get_act());
@@ -651,6 +651,7 @@ static lv_res_t lv_ddlist_signal(lv_obj_t * ddlist, lv_signal_t sign, void * par
lv_ddlist_refr_size(ddlist, true);
}
}
#endif
} else if(sign == LV_SIGNAL_DEFOCUS) {
if(ext->opened) {
ext->opened = false;
@@ -686,9 +687,11 @@ static lv_res_t lv_ddlist_signal(lv_obj_t * ddlist, lv_signal_t sign, void * par
ext->opened = 0;
if(ext->action) ext->action(ddlist);
#if USE_LV_GROUP
lv_group_t * g = lv_obj_get_group(ddlist);
bool editing = lv_group_get_editing(g);
if(editing) lv_group_set_editing(g, false); /*In edit mode go to navigate mode if an option is selected*/
#endif
} else {
ext->opened = 1;
}

View File

@@ -117,12 +117,13 @@ void lv_ddlist_set_action(lv_obj_t * ddlist, lv_action_t action);
*/
void lv_ddlist_set_fix_height(lv_obj_t * ddlist, lv_coord_t h);
/**
* Enable or disable the horizontal fit to the content
* @param ddlist pointer to a drop down list
* @param en true: enable auto fit; false: disable auto fit
* @param fit fit mode fron `lv_fit_t` (Typically `LV_FIT_NONE` or `LV_FIT_TIGHT`)
*/
void lv_ddlist_set_hor_fit(lv_obj_t * ddlist, bool en);
void lv_ddlist_set_hor_fit(lv_obj_t * ddlist, lv_fit_t fit);
/**
* Set the scroll bar mode of a drop down list

View File

@@ -95,7 +95,7 @@ lv_obj_t * lv_gauge_create(lv_obj_t * par, const lv_obj_t * copy)
/*Set the default styles*/
lv_theme_t * th = lv_theme_get_current();
if(th) {
lv_gauge_set_style(new_gauge, th->gauge);
lv_gauge_set_style(new_gauge, th->style.gauge);
} else {
lv_gauge_set_style(new_gauge, &lv_style_pretty_color);
}

View File

@@ -14,7 +14,7 @@
#error "lv_img: lv_label is required. Enable it in lv_conf.h (USE_LV_LABEL 1) "
#endif
#include "../lv_core/lv_lang.h"
#include "../lv_core/lv_i18n.h"
#include "../lv_themes/lv_theme.h"
#include "../lv_misc/lv_fs.h"
#include "../lv_misc/lv_ufs.h"
@@ -78,9 +78,6 @@ lv_obj_t * lv_img_create(lv_obj_t * par, const lv_obj_t * copy)
ext->w = lv_obj_get_width(new_img);
ext->h = lv_obj_get_height(new_img);
ext->auto_size = 1;
#if USE_LV_MULTI_LANG
ext->lang_txt_id = LV_LANG_TXT_ID_NONE;
#endif
/*Init the new object*/
lv_obj_set_signal_func(new_img, lv_img_signal);
@@ -129,7 +126,7 @@ void lv_img_set_src(lv_obj_t * img, const void * src_img)
lv_img_src_t src_type = lv_img_src_get_type(src_img);
lv_img_ext_t * ext = lv_obj_get_ext_attr(img);
#if LV_LOG_LEVEL >= LV_LOG_LEVEL_INFO
#if USE_LV_LOG && LV_LOG_LEVEL >= LV_LOG_LEVEL_INFO
switch(src_type) {
case LV_IMG_SRC_FILE:
LV_LOG_TRACE("lv_img_set_src: `LV_IMG_SRC_FILE` type found");
@@ -206,22 +203,6 @@ void lv_img_set_src(lv_obj_t * img, const void * src_img)
lv_obj_invalidate(img);
}
#if USE_LV_MULTI_LANG
/**
* Set an ID which means a the same source but in different languages
* @param img pointer to an image object
* @param src_id ID of the source
*/
void lv_img_set_src_id(lv_obj_t * img, uint32_t src_id)
{
lv_img_ext_t * ext = lv_obj_get_ext_attr(img);
ext->lang_txt_id = src_id;
/*Apply the new language*/
img->signal_func(img, LV_SIGNAL_LANG_CHG, NULL);
}
#endif
/**
* Enable the auto size feature.
* If enabled the object size will be same as the picture size.
@@ -266,19 +247,6 @@ const char * lv_img_get_file_name(const lv_obj_t * img)
else return "";
}
#if USE_LV_MULTI_LANG
/**
* Get the source ID of the image. (Used by the multi-language feature)
* @param img pointer to an image
* @return ID of the source
*/
uint16_t lv_img_get_src_id(lv_obj_t * img)
{
lv_img_ext_t * ext = lv_obj_get_ext_attr(img);
return ext->lang_txt_id;
}
#endif
/**
* Get the auto size enable attribute
* @param img pointer to an image
@@ -382,17 +350,6 @@ static lv_res_t lv_img_signal(lv_obj_t * img, lv_signal_t sign, void * param)
lv_img_set_src(img, ext->src);
}
} else if(sign == LV_SIGNAL_LANG_CHG) {
#if USE_LV_MULTI_LANG
if(ext->lang_txt_id != LV_LANG_TXT_ID_NONE) {
const char * lang_src = lv_lang_get_text(ext->lang_txt_id);
if(lang_src) {
lv_img_set_src(img, lang_src);
} else {
LV_LOG_WARN("lv_lang_get_text return NULL for an image's source");
}
}
#endif
} else if(sign == LV_SIGNAL_GET_TYPE) {
lv_obj_type_t * buf = param;
uint8_t i;

View File

@@ -43,9 +43,6 @@ typedef struct
lv_coord_t w; /*Width of the image (Handled by the library)*/
lv_coord_t h; /*Height of the image (Handled by the library)*/
#if USE_LV_MULTI_LANG
uint16_t lang_txt_id; /*The ID of the image to display. */
#endif
uint8_t src_type :2; /*See: lv_img_src_t*/
uint8_t auto_size :1; /*1: automatically set the object size to the image size*/
uint8_t cf :5; /*Color format from `lv_img_color_format_t`*/
@@ -74,15 +71,6 @@ lv_obj_t * lv_img_create(lv_obj_t * par, const lv_obj_t * copy);
*/
void lv_img_set_src(lv_obj_t * img, const void * src_img);
#if USE_LV_MULTI_LANG
/**
* Set an ID which means a the same source but on different languages
* @param img pointer to an image object
* @param src_id ID of the source
*/
void lv_img_set_src_id(lv_obj_t * img, uint32_t txt_id);
#endif
/**
* Obsolete since v5.1. Just for compatibility with v5.0. Will be removed in v6.0.
* Use 'lv_img_set_src()' instead.
@@ -142,15 +130,6 @@ const void * lv_img_get_src(lv_obj_t * img);
*/
const char * lv_img_get_file_name(const lv_obj_t * img);
#if USE_LV_MULTI_LANG
/**
* Get the source ID of the image. (Used by the multi-language feature)
* @param img pointer to an image
* @return ID of the source
*/
uint16_t lv_img_get_src_id(lv_obj_t * img);
#endif
/**
* Get the auto size enable attribute
* @param img pointer to an image

View File

@@ -81,11 +81,10 @@ lv_obj_t * lv_imgbtn_create(lv_obj_t * par, const lv_obj_t * copy)
}
/*Copy an existing image button*/
else {
#if LV_IMGBTN_TILED == 0
memset(ext->img_src, 0, sizeof(ext->img_src));
#else
lv_imgbtn_ext_t * copy_ext = lv_obj_get_ext_attr(copy);
#if LV_IMGBTN_TILED == 0
memcpy(ext->img_src, copy_ext->img_src, sizeof(ext->img_src));
#else
memcpy(ext->img_src_left, copy_ext->img_src_left, sizeof(ext->img_src_left));
memcpy(ext->img_src_mid, copy_ext->img_src_mid, sizeof(ext->img_src_mid));
memcpy(ext->img_src_right, copy_ext->img_src_right, sizeof(ext->img_src_right));
@@ -386,7 +385,7 @@ static void refr_img(lv_obj_t * imgbtn)
ext->act_cf = LV_IMG_CF_UNKOWN;
}
lv_obj_invalidate(imgbtn);
}
#endif

View File

@@ -102,7 +102,7 @@ lv_obj_t * lv_kb_create(lv_obj_t * par, const lv_obj_t * copy)
/*Init the new keyboard keyboard*/
if(copy == NULL) {
lv_obj_set_size(new_kb, LV_HOR_RES, LV_VER_RES / 2);
lv_obj_set_size(new_kb, LV_DPI * 3, LV_DPI * 2);
lv_obj_align(new_kb, NULL, LV_ALIGN_IN_BOTTOM_MID, 0, 0);
lv_btnm_set_action(new_kb, lv_kb_def_action);
lv_btnm_set_map(new_kb, kb_map_lc);
@@ -110,12 +110,12 @@ lv_obj_t * lv_kb_create(lv_obj_t * par, const lv_obj_t * copy)
/*Set the default styles*/
lv_theme_t * th = lv_theme_get_current();
if(th) {
lv_kb_set_style(new_kb, LV_KB_STYLE_BG, th->kb.bg);
lv_kb_set_style(new_kb, LV_KB_STYLE_BTN_REL, th->kb.btn.rel);
lv_kb_set_style(new_kb, LV_KB_STYLE_BTN_PR, th->kb.btn.pr);
lv_kb_set_style(new_kb, LV_KB_STYLE_BTN_TGL_REL, th->kb.btn.tgl_rel);
lv_kb_set_style(new_kb, LV_KB_STYLE_BTN_TGL_PR, th->kb.btn.tgl_pr);
lv_kb_set_style(new_kb, LV_KB_STYLE_BTN_INA, th->kb.btn.ina);
lv_kb_set_style(new_kb, LV_KB_STYLE_BG, th->style.kb.bg);
lv_kb_set_style(new_kb, LV_KB_STYLE_BTN_REL, th->style.kb.btn.rel);
lv_kb_set_style(new_kb, LV_KB_STYLE_BTN_PR, th->style.kb.btn.pr);
lv_kb_set_style(new_kb, LV_KB_STYLE_BTN_TGL_REL, th->style.kb.btn.tgl_rel);
lv_kb_set_style(new_kb, LV_KB_STYLE_BTN_TGL_PR, th->style.kb.btn.tgl_pr);
lv_kb_set_style(new_kb, LV_KB_STYLE_BTN_INA, th->style.kb.btn.ina);
} else {
/*Let the button matrix's styles*/
}

View File

@@ -11,7 +11,7 @@
#include "../lv_core/lv_obj.h"
#include "../lv_core/lv_group.h"
#include "../lv_core/lv_lang.h"
#include "../lv_core/lv_i18n.h"
#include "../lv_draw/lv_draw.h"
#include "../lv_misc/lv_color.h"
#include "../lv_misc/lv_math.h"
@@ -91,9 +91,6 @@ lv_obj_t * lv_label_create(lv_obj_t * par, const lv_obj_t * copy)
ext->anim_speed = LV_LABEL_SCROLL_SPEED;
ext->offset.x = 0;
ext->offset.y = 0;
#if USE_LV_MULTI_LANG
ext->lang_txt_id = LV_LANG_TXT_ID_NONE;
#endif
lv_obj_set_design_func(new_label, lv_label_design);
lv_obj_set_signal_func(new_label, lv_label_signal);
@@ -237,22 +234,6 @@ void lv_label_set_static_text(lv_obj_t * label, const char * text)
lv_label_refr_text(label);
}
#if USE_LV_MULTI_LANG
/**
*Set a text ID which refers a the same text but in a different languages
* @param label pointer to a label object
* @param txt_id ID of the text
*/
void lv_label_set_text_id(lv_obj_t * label, uint32_t txt_id)
{
lv_label_ext_t * ext = lv_obj_get_ext_attr(label);
ext->lang_txt_id = txt_id;
/*Apply the new language*/
label->signal_func(label, LV_SIGNAL_LANG_CHG, NULL);
}
#endif
/**
* Set the behavior of the label with longer text then the object size
* @param label pointer to a label object
@@ -365,19 +346,6 @@ char * lv_label_get_text(const lv_obj_t * label)
return ext->text;
}
#if USE_LV_MULTI_LANG
/**
* Get the text ID of the label. (Used by the multi-language feature)
* @param label pointer to a label object
* @return ID of the text
*/
uint16_t lv_label_get_text_id(lv_obj_t * label)
{
lv_label_ext_t * ext = lv_obj_get_ext_attr(label);
return ext->lang_txt_id;
}
#endif
/**
* Get the long mode of a label
* @param label pointer to a label object
@@ -753,17 +721,6 @@ static lv_res_t lv_label_signal(lv_obj_t * label, lv_signal_t sign, void * param
label->ext_size = LV_MATH_MAX(label->ext_size, style->body.padding.hor);
label->ext_size = LV_MATH_MAX(label->ext_size, style->body.padding.ver);
}
} else if(sign == LV_SIGNAL_LANG_CHG) {
#if USE_LV_MULTI_LANG
if(ext->lang_txt_id != LV_LANG_TXT_ID_NONE) {
const char * lang_txt = lv_lang_get_text(ext->lang_txt_id);
if(lang_txt) {
lv_label_set_text(label, lang_txt);
} else {
LV_LOG_WARN("lv_lang_get_text return NULL for a label's text");
}
}
#endif
} else if(sign == LV_SIGNAL_GET_TYPE) {
lv_obj_type_t * buf = param;
uint8_t i;

View File

@@ -69,9 +69,6 @@ typedef struct
char dot_tmp[LV_LABEL_DOT_NUM * 4 + 1]; /*Store the character which are replaced by dots (Handled by the library)*/
#endif
#if USE_LV_MULTI_LANG
uint16_t lang_txt_id; /*The ID of the text to display*/
#endif
uint16_t dot_end; /*The text end position in dot mode (Handled by the library)*/
uint16_t anim_speed; /*Speed of scroll and roll animation in px/sec unit*/
lv_point_t offset; /*Text draw position offset*/
@@ -123,15 +120,6 @@ void lv_label_set_array_text(lv_obj_t * label, const char * array, uint16_t size
*/
void lv_label_set_static_text(lv_obj_t * label, const char * text);
/**
*Set a text ID which means a the same text but on different languages
* @param label pointer to a label object
* @param txt_id ID of the text
*/
#if USE_LV_MULTI_LANG
void lv_label_set_text_id(lv_obj_t * label, uint32_t txt_id);
#endif
/**
* Set the behavior of the label with longer text then the object size
* @param label pointer to a label object
@@ -188,15 +176,6 @@ static inline void lv_label_set_style(lv_obj_t *label, lv_style_t *style)
*/
char * lv_label_get_text(const lv_obj_t * label);
#if USE_LV_MULTI_LANG
/**
* Get the text ID of the label. (Used by the multi-language feature)
* @param label pointer to a label object
* @return ID of the text
*/
uint16_t lv_label_get_text_id(lv_obj_t * label);
#endif
/**
* Get the long mode of a label
* @param label pointer to a label object

View File

@@ -79,7 +79,7 @@ lv_obj_t * lv_led_create(lv_obj_t * par, const lv_obj_t * copy)
/*Set the default styles*/
lv_theme_t * th = lv_theme_get_current();
if(th) {
lv_led_set_style(new_led, th->led);
lv_led_set_style(new_led, th->style.led);
} else {
lv_led_set_style(new_led, &lv_style_pretty_color);
}

View File

@@ -102,6 +102,7 @@ lv_obj_t * lv_list_create(lv_obj_t * par, const lv_obj_t * copy)
/*Init the new list object*/
if(copy == NULL) {
lv_page_set_scrl_fit2(new_list, LV_FIT_FLOOD, LV_FIT_TIGHT);
lv_obj_set_size(new_list, 2 * LV_DPI, 3 * LV_DPI);
lv_page_set_scrl_layout(new_list, LV_LIST_LAYOUT_DEF);
lv_list_set_sb_mode(new_list, LV_SB_MODE_DRAG);
@@ -109,14 +110,14 @@ lv_obj_t * lv_list_create(lv_obj_t * par, const lv_obj_t * copy)
/*Set the default styles*/
lv_theme_t * th = lv_theme_get_current();
if(th) {
lv_list_set_style(new_list, LV_LIST_STYLE_BG, th->list.bg);
lv_list_set_style(new_list, LV_LIST_STYLE_SCRL, th->list.scrl);
lv_list_set_style(new_list, LV_LIST_STYLE_SB, th->list.sb);
lv_list_set_style(new_list, LV_LIST_STYLE_BTN_REL, th->list.btn.rel);
lv_list_set_style(new_list, LV_LIST_STYLE_BTN_PR, th->list.btn.pr);
lv_list_set_style(new_list, LV_LIST_STYLE_BTN_TGL_REL, th->list.btn.tgl_rel);
lv_list_set_style(new_list, LV_LIST_STYLE_BTN_TGL_PR, th->list.btn.tgl_pr);
lv_list_set_style(new_list, LV_LIST_STYLE_BTN_INA, th->list.btn.ina);
lv_list_set_style(new_list, LV_LIST_STYLE_BG, th->style.list.bg);
lv_list_set_style(new_list, LV_LIST_STYLE_SCRL, th->style.list.scrl);
lv_list_set_style(new_list, LV_LIST_STYLE_SB, th->style.list.sb);
lv_list_set_style(new_list, LV_LIST_STYLE_BTN_REL, th->style.list.btn.rel);
lv_list_set_style(new_list, LV_LIST_STYLE_BTN_PR, th->style.list.btn.pr);
lv_list_set_style(new_list, LV_LIST_STYLE_BTN_TGL_REL, th->style.list.btn.tgl_rel);
lv_list_set_style(new_list, LV_LIST_STYLE_BTN_TGL_PR, th->style.list.btn.tgl_pr);
lv_list_set_style(new_list, LV_LIST_STYLE_BTN_INA, th->style.list.btn.ina);
} else {
lv_list_set_style(new_list, LV_LIST_STYLE_BG, &lv_style_transp_fit);
lv_list_set_style(new_list, LV_LIST_STYLE_SCRL, &lv_style_pretty);
@@ -198,7 +199,7 @@ lv_obj_t * lv_list_add(lv_obj_t * list, const void * img_src, const char * txt,
lv_btn_set_action(liste, LV_BTN_ACTION_CLICK, rel_action);
lv_page_glue_obj(liste, true);
lv_btn_set_layout(liste, LV_LAYOUT_ROW_M);
lv_btn_set_fit(liste, false, true);
lv_btn_set_fit2(liste, LV_FIT_FLOOD, LV_FIT_TIGHT);
lv_obj_set_protect(liste, LV_PROTECT_PRESS_LOST);
lv_obj_set_signal_func(liste, lv_list_btn_signal);
@@ -300,6 +301,9 @@ void lv_list_set_btn_selected(lv_obj_t * list, lv_obj_t * btn)
}
ext->selected_btn = btn;
if( btn != NULL ) {
ext->last_sel = btn;
}
if(ext->selected_btn) {
lv_btn_state_t s = lv_btn_get_state(ext->selected_btn);
@@ -760,7 +764,7 @@ static lv_res_t lv_list_signal(lv_obj_t * list, lv_signal_t sign, void * param)
lv_group_t * g = lv_obj_get_group(list);
if(lv_group_get_editing(g)) {
lv_list_ext_t * ext = lv_obj_get_ext_attr(list);
if(NULL != ext->last_sel) {
if(ext->last_sel) {
/* Select the last used button */
lv_list_set_btn_selected(list, ext->last_sel);
}
@@ -779,7 +783,7 @@ static lv_res_t lv_list_signal(lv_obj_t * list, lv_signal_t sign, void * param)
lv_list_set_btn_selected(list, last_clicked_btn);
} else {
lv_list_ext_t * ext = lv_obj_get_ext_attr(list);
if(NULL != ext->last_sel) {
if(ext->last_sel) {
/* Select the last used button */
lv_list_set_btn_selected(list, ext->last_sel);
}

View File

@@ -59,8 +59,8 @@ typedef struct
uint32_t size; /*the number of items(buttons) in the list*/
bool single_mode; /* whether single selected mode is enabled */
#if USE_LV_GROUP
lv_obj_t * last_sel; /* Last btn selected */
lv_obj_t * selected_btn;
lv_obj_t * last_sel; /* The last selected button. It will be reverted when the list is focused again */
lv_obj_t * selected_btn; /* The button is currently being selected*/
#endif
} lv_list_ext_t;

View File

@@ -84,7 +84,7 @@ lv_obj_t * lv_lmeter_create(lv_obj_t * par, const lv_obj_t * copy)
/*Set the default styles*/
lv_theme_t * th = lv_theme_get_current();
if(th) {
lv_lmeter_set_style(new_lmeter, th->lmeter);
lv_lmeter_set_style(new_lmeter, th->style.lmeter);
} else {
lv_lmeter_set_style(new_lmeter, &lv_style_pretty_color);
}

View File

@@ -90,14 +90,14 @@ lv_obj_t * lv_mbox_create(lv_obj_t * par, const lv_obj_t * copy)
lv_label_set_text(ext->text, "Message");
lv_cont_set_layout(new_mbox, LV_LAYOUT_COL_M);
lv_cont_set_fit(new_mbox, false, true);
lv_obj_set_width(new_mbox, LV_HOR_RES / 2);
lv_cont_set_fit2(new_mbox, LV_FIT_NONE, LV_FIT_TIGHT);
lv_obj_set_width(new_mbox, LV_DPI * 2);
lv_obj_align(new_mbox, NULL, LV_ALIGN_CENTER, 0, 0);
/*Set the default styles*/
lv_theme_t * th = lv_theme_get_current();
if(th) {
lv_mbox_set_style(new_mbox, LV_MBOX_STYLE_BG, th->mbox.bg);
lv_mbox_set_style(new_mbox, LV_MBOX_STYLE_BG, th->style.mbox.bg);
} else {
lv_mbox_set_style(new_mbox, LV_MBOX_STYLE_BG, &lv_style_pretty);
}
@@ -144,9 +144,9 @@ void lv_mbox_add_btns(lv_obj_t * mbox, const char ** btn_map, lv_btnm_action_t a
/*Set the default styles*/
lv_theme_t * th = lv_theme_get_current();
if(th) {
lv_mbox_set_style(mbox, LV_MBOX_STYLE_BTN_BG, th->mbox.btn.bg);
lv_mbox_set_style(mbox, LV_MBOX_STYLE_BTN_REL, th->mbox.btn.rel);
lv_mbox_set_style(mbox, LV_MBOX_STYLE_BTN_PR, th->mbox.btn.pr);
lv_mbox_set_style(mbox, LV_MBOX_STYLE_BTN_BG, th->style.mbox.btn.bg);
lv_mbox_set_style(mbox, LV_MBOX_STYLE_BTN_REL, th->style.mbox.btn.rel);
lv_mbox_set_style(mbox, LV_MBOX_STYLE_BTN_PR, th->style.mbox.btn.pr);
} else {
lv_btnm_set_style(ext->btnm, LV_BTNM_STYLE_BG, &lv_style_transp_fit);
}
@@ -220,7 +220,7 @@ void lv_mbox_start_auto_close(lv_obj_t * mbox, uint16_t delay)
lv_obj_animate(mbox, LV_ANIM_GROW_V | LV_ANIM_OUT, ext->anim_time, delay, lv_mbox_close_end_cb);
/*Disable fit to let shrinking work*/
lv_cont_set_fit(mbox, false, false);
lv_cont_set_fit(mbox, LV_FIT_NONE);
} else {
lv_obj_animate(mbox, LV_ANIM_NONE, ext->anim_time, delay, lv_mbox_close_end_cb);
}

View File

@@ -103,7 +103,7 @@ lv_obj_t * lv_page_create(lv_obj_t * par, const lv_obj_t * copy)
lv_obj_set_drag(ext->scrl, true);
lv_obj_set_drag_throw(ext->scrl, true);
lv_obj_set_protect(ext->scrl, LV_PROTECT_PARENT | LV_PROTECT_PRESS_LOST);
lv_cont_set_fit(ext->scrl, false, true);
lv_cont_set_fit4(ext->scrl, LV_FIT_FILL, LV_FIT_FILL, LV_FIT_FILL, LV_FIT_FILL);
/* Add the signal function only if 'scrolling' is created
* because everything has to be ready before any signal is received*/
@@ -116,14 +116,14 @@ lv_obj_t * lv_page_create(lv_obj_t * par, const lv_obj_t * copy)
lv_theme_t * th = lv_theme_get_current();
if(th) {
if(par == NULL) { /*Different styles if it is screen*/
lv_page_set_style(new_page, LV_PAGE_STYLE_BG, th->bg);
lv_page_set_style(new_page, LV_PAGE_STYLE_BG, th->style.bg);
lv_page_set_style(new_page, LV_PAGE_STYLE_SCRL, &lv_style_transp);
} else {
lv_page_set_style(new_page, LV_PAGE_STYLE_BG, th->page.bg);
lv_page_set_style(new_page, LV_PAGE_STYLE_SCRL, th->page.scrl);
lv_page_set_style(new_page, LV_PAGE_STYLE_BG, th->style.page.bg);
lv_page_set_style(new_page, LV_PAGE_STYLE_SCRL, th->style.page.scrl);
}
lv_page_set_style(new_page, LV_PAGE_STYLE_SB, th->page.sb);
lv_page_set_style(new_page, LV_PAGE_STYLE_SB, th->style.page.sb);
} else {
lv_page_set_style(new_page, LV_PAGE_STYLE_BG, &lv_style_pretty_color);
lv_page_set_style(new_page, LV_PAGE_STYLE_SCRL, &lv_style_pretty);
@@ -567,7 +567,7 @@ void lv_page_scroll_ver(lv_obj_t * page, lv_coord_t dist)
a.repeat_pause = 0;
lv_anim_create(&a);
#else
lv_obj_set_y(scrl, lv_obj_get_x(scrl) + dist);
lv_obj_set_y(scrl, lv_obj_get_y(scrl) + dist);
#endif
}
@@ -765,7 +765,6 @@ static lv_res_t lv_page_signal(lv_obj_t * page, lv_signal_t sign, void * param)
if(res != LV_RES_OK) return res;
lv_page_ext_t * ext = lv_obj_get_ext_attr(page);
lv_style_t * style = lv_obj_get_style(page);
lv_obj_t * child;
if(sign == LV_SIGNAL_CHILD_CHG) { /*Automatically move children to the scrollable object*/
child = lv_obj_get_child(page, NULL);
@@ -773,18 +772,21 @@ static lv_res_t lv_page_signal(lv_obj_t * page, lv_signal_t sign, void * param)
if(lv_obj_is_protected(child, LV_PROTECT_PARENT) == false) {
lv_obj_t * tmp = child;
child = lv_obj_get_child(page, child); /*Get the next child before move this*/
/*Reposition the child to take padding into account*/
lv_style_t * style = lv_page_get_style(page, LV_PAGE_STYLE_SCRL);
child->coords.x1 += style->body.padding.hor;
child->coords.x2 += style->body.padding.hor;
child->coords.y1 += style->body.padding.ver;
child->coords.y2 += style->body.padding.ver;
lv_obj_set_parent(tmp, ext->scrl);
} else {
child = lv_obj_get_child(page, child);
}
}
} else if(sign == LV_SIGNAL_STYLE_CHG) {
/*If no hor_fit enabled set the scrollable's width to the page's width*/
if(lv_cont_get_hor_fit(ext->scrl) == false) {
lv_obj_set_width(ext->scrl, lv_obj_get_width(page) - 2 * style->body.padding.hor);
} else {
ext->scrl->signal_func(ext->scrl, LV_SIGNAL_CORD_CHG, &ext->scrl->coords);
}
ext->scrl->signal_func(ext->scrl, LV_SIGNAL_CORD_CHG, &ext->scrl->coords);
/*The scrollbars are important only if they are visible now*/
if(ext->sb.hor_draw || ext->sb.ver_draw) lv_page_sb_refresh(page);
@@ -796,10 +798,6 @@ static lv_res_t lv_page_signal(lv_obj_t * page, lv_signal_t sign, void * param)
if(ext->scrl != NULL && (lv_obj_get_width(page) != lv_area_get_width(param) ||
lv_obj_get_height(page) != lv_area_get_height(param))) {
/*If no hor_fit enabled set the scrollable's width to the page's width*/
if(lv_cont_get_hor_fit(ext->scrl) == false) {
lv_obj_set_width(ext->scrl, lv_obj_get_width(page) - 2 * style->body.padding.hor);
}
ext->scrl->signal_func(ext->scrl, LV_SIGNAL_CORD_CHG, &ext->scrl->coords);
/*The scrollbars are important only if they are visible now*/
@@ -1000,6 +998,7 @@ static lv_res_t lv_page_scrollable_signal(lv_obj_t * scrl, lv_signal_t sign, voi
/*Hide scrollbars if required*/
if(page_ext->sb.mode == LV_SB_MODE_DRAG) {
lv_disp_t * disp = lv_obj_get_disp(page);
lv_area_t sb_area_tmp;
if(page_ext->sb.hor_draw) {
lv_area_copy(&sb_area_tmp, &page_ext->sb.hor_area);
@@ -1007,7 +1006,7 @@ static lv_res_t lv_page_scrollable_signal(lv_obj_t * scrl, lv_signal_t sign, voi
sb_area_tmp.y1 += page->coords.y1;
sb_area_tmp.x2 += page->coords.x1;
sb_area_tmp.y2 += page->coords.y1;
lv_inv_area(&sb_area_tmp);
lv_inv_area(disp, &sb_area_tmp);
page_ext->sb.hor_draw = 0;
}
if(page_ext->sb.ver_draw) {
@@ -1016,7 +1015,7 @@ static lv_res_t lv_page_scrollable_signal(lv_obj_t * scrl, lv_signal_t sign, voi
sb_area_tmp.y1 += page->coords.y1;
sb_area_tmp.x2 += page->coords.x1;
sb_area_tmp.y2 += page->coords.y1;
lv_inv_area(&sb_area_tmp);
lv_inv_area(disp, &sb_area_tmp);
page_ext->sb.ver_draw = 0;
}
}
@@ -1068,6 +1067,7 @@ static void lv_page_sb_refresh(lv_obj_t * page)
}
/*Invalidate the current (old) scrollbar areas*/
lv_disp_t * disp = lv_obj_get_disp(page);
lv_area_t sb_area_tmp;
if(ext->sb.hor_draw != 0) {
lv_area_copy(&sb_area_tmp, &ext->sb.hor_area);
@@ -1075,7 +1075,7 @@ static void lv_page_sb_refresh(lv_obj_t * page)
sb_area_tmp.y1 += page->coords.y1;
sb_area_tmp.x2 += page->coords.x1;
sb_area_tmp.y2 += page->coords.y1;
lv_inv_area(&sb_area_tmp);
lv_inv_area(disp, &sb_area_tmp);
}
if(ext->sb.ver_draw != 0) {
lv_area_copy(&sb_area_tmp, &ext->sb.ver_area);
@@ -1083,7 +1083,7 @@ static void lv_page_sb_refresh(lv_obj_t * page)
sb_area_tmp.y1 += page->coords.y1;
sb_area_tmp.x2 += page->coords.x1;
sb_area_tmp.y2 += page->coords.y1;
lv_inv_area(&sb_area_tmp);
lv_inv_area(disp, &sb_area_tmp);
}
@@ -1137,7 +1137,7 @@ static void lv_page_sb_refresh(lv_obj_t * page)
sb_area_tmp.y1 += page->coords.y1;
sb_area_tmp.x2 += page->coords.x1;
sb_area_tmp.y2 += page->coords.y1;
lv_inv_area(&sb_area_tmp);
lv_inv_area(disp, &sb_area_tmp);
}
if(ext->sb.ver_draw != 0) {
lv_area_copy(&sb_area_tmp, &ext->sb.ver_area);
@@ -1145,7 +1145,7 @@ static void lv_page_sb_refresh(lv_obj_t * page)
sb_area_tmp.y1 += page->coords.y1;
sb_area_tmp.x2 += page->coords.x1;
sb_area_tmp.y2 += page->coords.y1;
lv_inv_area(&sb_area_tmp);
lv_inv_area(disp, &sb_area_tmp);
}
}

View File

@@ -173,17 +173,42 @@ void lv_page_set_scroll_propagation(lv_obj_t * page, bool en);
*/
void lv_page_set_edge_flash(lv_obj_t * page, bool en);
/**
* Set the fit attribute of the scrollable part of a page.
* It means it can set its size automatically to involve all children.
* (Can be set separately horizontally and vertically)
* Set the fit policy in all 4 directions separately.
* It tell how to change the page size automatically.
* @param page pointer to a page object
* @param hor_en true: enable horizontal fit
* @param ver_en true: enable vertical fit
* @param left left fit policy from `lv_fit_t`
* @param right right fit policy from `lv_fit_t`
* @param top bottom fit policy from `lv_fit_t`
* @param bottom bottom fit policy from `lv_fit_t`
*/
static inline void lv_page_set_scrl_fit(lv_obj_t *page, bool hor_en, bool ver_en)
static inline void lv_page_set_scrl_fit4(lv_obj_t * page, lv_fit_t left, lv_fit_t right, lv_fit_t top, lv_fit_t bottom)
{
lv_cont_set_fit(lv_page_get_scrl(page), hor_en, ver_en);
lv_cont_set_fit4(lv_page_get_scrl(page), left, right, top, bottom);
}
/**
* Set the fit policy horizontally and vertically separately.
* It tell how to change the page size automatically.
* @param page pointer to a page object
* @param hot horizontal fit policy from `lv_fit_t`
* @param ver vertical fit policy from `lv_fit_t`
*/
static inline void lv_page_set_scrl_fit2(lv_obj_t * page, lv_fit_t hor, lv_fit_t ver)
{
lv_cont_set_fit2(lv_page_get_scrl(page), hor, ver);
}
/**
* Set the fit policyin all 4 direction at once.
* It tell how to change the page size automatically.
* @param page pointer to a button object
* @param fit fit policy from `lv_fit_t`
*/
static inline void lv_page_set_scrl_fit(lv_obj_t * page, lv_fit_t fit)
{
lv_cont_set_fit(lv_page_get_scrl(page), fit);
}
/**
@@ -303,23 +328,43 @@ static inline lv_layout_t lv_page_get_scrl_layout(const lv_obj_t * page)
}
/**
* Get horizontal fit attribute of the scrollable part of a page
* @param page pointer to a page object
* @return true: horizontal fit is enabled; false: disabled
*/
static inline bool lv_page_get_scrl_hor_fit(const lv_obj_t * page)
* Get the left fit mode
* @param page pointer to a page object
* @return an element of `lv_fit_t`
*/
static inline lv_fit_t lv_page_get_scrl_fit_left(const lv_obj_t * page)
{
return lv_cont_get_hor_fit(lv_page_get_scrl(page));
return lv_cont_get_fit_left(lv_page_get_scrl(page));
}
/**
* Get vertical fit attribute of the scrollable part of a page
* @param page pointer to a page object
* @return true: vertical fit is enabled; false: disabled
*/
static inline bool lv_page_get_scrl_fit_ver(const lv_obj_t * page)
* Get the right fit mode
* @param page pointer to a page object
* @return an element of `lv_fit_t`
*/
static inline lv_fit_t lv_page_get_scrl_fit_right(const lv_obj_t * page)
{
return lv_cont_get_ver_fit(lv_page_get_scrl(page));
return lv_cont_get_fit_right(lv_page_get_scrl(page));
}
/**
* Get the top fit mode
* @param page pointer to a page object
* @return an element of `lv_fit_t`
*/
static inline lv_fit_t lv_page_get_scrl_get_fit_top(const lv_obj_t * page)
{
return lv_cont_get_fit_top(lv_page_get_scrl(page));
}
/**
* Get the bottom fit mode
* @param page pointer to a page object
* @return an element of `lv_fit_t`
*/
static inline lv_fit_t lv_page_get_scrl_fit_bottom(const lv_obj_t * page)
{
return lv_cont_get_fit_bottom(lv_page_get_scrl(page));
}
/**

View File

@@ -93,7 +93,7 @@ lv_obj_t * lv_preload_create(lv_obj_t * par, const lv_obj_t * copy)
/*Set the default styles*/
lv_theme_t * th = lv_theme_get_current();
if(th) {
lv_preload_set_style(new_preload, LV_PRELOAD_STYLE_MAIN, th->preload);
lv_preload_set_style(new_preload, LV_PRELOAD_STYLE_MAIN, th->style.preload);
} else {
lv_obj_set_style(new_preload, &lv_style_pretty_color);
}

View File

@@ -84,8 +84,8 @@ lv_obj_t * lv_roller_create(lv_obj_t * par, const lv_obj_t * copy)
if(copy == NULL) {
lv_obj_t * scrl = lv_page_get_scrl(new_roller);
lv_obj_set_drag(scrl, true); /*In ddlist is might be disabled*/
lv_page_set_rel_action(new_roller, NULL); /*Roller don't uses it (like ddlist)*/
lv_page_set_scrl_fit(new_roller, true, false); /*Height is specified directly*/
lv_page_set_rel_action(new_roller, NULL); /*Roller don't uses it (like ddlist)*/
lv_page_set_scrl_fit2(new_roller, LV_FIT_TIGHT, LV_FIT_NONE); /*Height is specified directly*/
lv_ddlist_open(new_roller, false);
lv_ddlist_set_anim_time(new_roller, LV_ROLLER_ANIM_TIME);
lv_roller_set_visible_row_count(new_roller, 3);
@@ -96,8 +96,8 @@ lv_obj_t * lv_roller_create(lv_obj_t * par, const lv_obj_t * copy)
/*Set the default styles*/
lv_theme_t * th = lv_theme_get_current();
if(th) {
lv_roller_set_style(new_roller, LV_ROLLER_STYLE_BG, th->roller.bg);
lv_roller_set_style(new_roller, LV_ROLLER_STYLE_SEL, th->roller.sel);
lv_roller_set_style(new_roller, LV_ROLLER_STYLE_BG, th->style.roller.bg);
lv_roller_set_style(new_roller, LV_ROLLER_STYLE_SEL, th->style.roller.sel);
} else {
/*Let the ddlist's style*/
lv_obj_refresh_style(new_roller); /*To set scrollable size automatically*/
@@ -209,7 +209,7 @@ lv_label_align_t lv_roller_get_align(const lv_obj_t * roller)
*/
bool lv_roller_get_hor_fit(const lv_obj_t * roller)
{
return lv_page_get_scrl_hor_fit(roller);
return lv_page_get_scrl_fit_left(roller);
}
/**
@@ -361,6 +361,7 @@ static lv_res_t lv_roller_signal(lv_obj_t * roller, lv_signal_t sign, void * par
refr_position(roller, false);
}
} else if(sign == LV_SIGNAL_FOCUS) {
#if USE_LV_GROUP
lv_group_t * g = lv_obj_get_group(roller);
bool editing = lv_group_get_editing(g);
lv_hal_indev_type_t indev_type = lv_indev_get_type(lv_indev_get_act());
@@ -382,12 +383,15 @@ static lv_res_t lv_roller_signal(lv_obj_t * roller, lv_signal_t sign, void * par
ext->ddlist.sel_opt_id_ori = ext->ddlist.sel_opt_id; /*Save the current value. Used to revert this state if ENER wont't be pressed*/
}
#endif
} else if(sign == LV_SIGNAL_DEFOCUS) {
#if USE_LV_GROUP
/*Revert the original state*/
if(ext->ddlist.sel_opt_id != ext->ddlist.sel_opt_id_ori) {
ext->ddlist.sel_opt_id = ext->ddlist.sel_opt_id_ori;
refr_position(roller, true);
}
#endif
} else if(sign == LV_SIGNAL_CONTROLL) {
char c = *((char *)param);
if(c == LV_GROUP_KEY_RIGHT || c == LV_GROUP_KEY_DOWN) {
@@ -402,9 +406,11 @@ static lv_res_t lv_roller_signal(lv_obj_t * roller, lv_signal_t sign, void * par
ext->ddlist.sel_opt_id_ori = ext->ddlist.sel_opt_id; /*Set the entered value as default*/
if(ext->ddlist.action) ext->ddlist.action(roller);
#if USE_LV_GROUP
lv_group_t * g = lv_obj_get_group(roller);
bool editing = lv_group_get_editing(g);
if(editing) lv_group_set_editing(g, false); /*In edit mode go to navigate mode if an option is selected*/
#endif
}
} else if(sign == LV_SIGNAL_GET_TYPE) {
lv_obj_type_t * buf = param;

View File

@@ -86,9 +86,9 @@ lv_obj_t * lv_slider_create(lv_obj_t * par, const lv_obj_t * copy)
/*Set the default styles*/
lv_theme_t * th = lv_theme_get_current();
if(th) {
lv_slider_set_style(new_slider, LV_SLIDER_STYLE_BG, th->slider.bg);
lv_slider_set_style(new_slider, LV_SLIDER_STYLE_INDIC, th->slider.indic);
lv_slider_set_style(new_slider, LV_SLIDER_STYLE_KNOB, th->slider.knob);
lv_slider_set_style(new_slider, LV_SLIDER_STYLE_BG, th->style.slider.bg);
lv_slider_set_style(new_slider, LV_SLIDER_STYLE_INDIC, th->style.slider.indic);
lv_slider_set_style(new_slider, LV_SLIDER_STYLE_KNOB, th->style.slider.knob);
} else {
lv_slider_set_style(new_slider, LV_SLIDER_STYLE_KNOB, ext->style_knob);
}

View File

@@ -10,6 +10,7 @@
#if USE_LV_SPINBOX != 0
#include "../lv_themes/lv_theme.h"
#include "../lv_misc/lv_math.h"
/*********************
* DEFINES
@@ -64,19 +65,18 @@ lv_obj_t * lv_spinbox_create(lv_obj_t * par, const lv_obj_t * copy)
/*Initialize the allocated 'ext'*/
ext->ta.one_line = 1;
ext->ta.pwd_mode = 0;
ext->ta.accapted_chars = "1234567890+-.";
ext->ta.accapted_chars = "1234567890+-. ";
ext->value = 0;
ext->dec_point_pos = 2;
ext->dec_point_pos = 0;
ext->digit_count = 5;
ext->step = 100;
ext->digit_padding_left = 0;
ext->step = 1;
ext->range_max = 99999;
ext->range_min = -99999;
ext->value_changed_cb = NULL;
lv_ta_set_cursor_type(new_spinbox, LV_CURSOR_BLOCK | LV_CURSOR_HIDDEN); /*hidden by default*/
lv_ta_set_cursor_pos(new_spinbox, 4);
/*The signal and design functions are not copied so set them here*/
lv_obj_set_signal_func(new_spinbox, lv_spinbox_signal);
@@ -87,9 +87,9 @@ lv_obj_t * lv_spinbox_create(lv_obj_t * par, const lv_obj_t * copy)
/*Set the default styles*/
lv_theme_t * th = lv_theme_get_current();
if(th) {
lv_spinbox_set_style(new_spinbox, LV_SPINBOX_STYLE_BG, th->spinbox.bg);
lv_spinbox_set_style(new_spinbox, LV_SPINBOX_STYLE_CURSOR, th->spinbox.cursor);
lv_spinbox_set_style(new_spinbox, LV_SPINBOX_STYLE_SB, th->spinbox.sb);
lv_spinbox_set_style(new_spinbox, LV_SPINBOX_STYLE_BG, th->style.spinbox.bg);
lv_spinbox_set_style(new_spinbox, LV_SPINBOX_STYLE_CURSOR, th->style.spinbox.cursor);
lv_spinbox_set_style(new_spinbox, LV_SPINBOX_STYLE_SB, th->style.spinbox.sb);
}
}
/*Copy an existing spinbox*/
@@ -189,13 +189,11 @@ void lv_spinbox_set_range(lv_obj_t * spinbox, int32_t range_min, int32_t range_m
ext->range_max = range_max;
ext->range_min = range_min;
if(ext->value > ext->range_max)
{
if(ext->value > ext->range_max) {
ext->value = ext->range_max;
lv_obj_invalidate(spinbox);
}
if(ext->value < ext->range_min)
{
if(ext->value < ext->range_min) {
ext->value = ext->range_min;
lv_obj_invalidate(spinbox);
}
@@ -252,11 +250,9 @@ void lv_spinbox_step_next(lv_obj_t * spinbox)
{
lv_spinbox_ext_t * ext = lv_obj_get_ext_attr(spinbox);
if((ext->step / 10) < ext->range_max && (ext->step / 10) > ext->range_min && (ext->step / 10) > 0)
{
ext->step /= 10;
}
int32_t new_step = ext->step / 10;
if((new_step) > 0) ext->step = new_step;
else ext->step = 1;
lv_spinbox_updatevalue(spinbox);
}
@@ -268,12 +264,10 @@ void lv_spinbox_step_next(lv_obj_t * spinbox)
void lv_spinbox_step_previous(lv_obj_t * spinbox)
{
lv_spinbox_ext_t * ext = lv_obj_get_ext_attr(spinbox);
if((ext->step * 10) <= ext->range_max && (ext->step * 10) > ext->range_min && (ext->step * 10) > 0)
{
ext->step *= 10;
}
int32_t step_limit;
step_limit = LV_MATH_MAX(ext->range_max, (ext->range_min < 0 ? (-ext->range_min) : ext->range_min));
int32_t new_step = ext->step * 10;
if(new_step <= step_limit) ext->step = new_step;
lv_spinbox_updatevalue(spinbox);
}
@@ -286,20 +280,16 @@ void lv_spinbox_increment(lv_obj_t * spinbox)
{
lv_spinbox_ext_t * ext = lv_obj_get_ext_attr(spinbox);
if(ext->value + ext->step <= ext->range_max)
{
if(ext->value + ext->step <= ext->range_max) {
/*Special mode when zero crossing*/
if((ext->value + ext->step) > 0 && ext->value < 0)
{
ext->value = -ext->value;
}/*end special mode*/
if((ext->value + ext->step) > 0 && ext->value < 0) ext->value = -ext->value;
ext->value += ext->step;
if(ext->value_changed_cb != NULL)
{
ext->value_changed_cb(spinbox, ext->value);
}
} else {
ext->value = ext->range_max;
}
if(ext->value_changed_cb != NULL) ext->value_changed_cb(spinbox, ext->value);
lv_spinbox_updatevalue(spinbox);
}
@@ -311,20 +301,15 @@ void lv_spinbox_decrement(lv_obj_t * spinbox)
{
lv_spinbox_ext_t * ext = lv_obj_get_ext_attr(spinbox);
if(ext->value - ext->step >= ext->range_min)
{
if(ext->value - ext->step >= ext->range_min) {
/*Special mode when zero crossing*/
if((ext->value - ext->step) < 0 && ext->value > 0)
{
ext->value = -ext->value;
}/*end special mode*/
if((ext->value - ext->step) < 0 && ext->value > 0) ext->value = -ext->value;
ext->value -= ext->step;
if(ext->value_changed_cb != NULL)
{
ext->value_changed_cb(spinbox, ext->value);
}
} else {
ext->value = ext->range_min;
}
if(ext->value_changed_cb != NULL) ext->value_changed_cb(spinbox, ext->value);
lv_spinbox_updatevalue(spinbox);
}
@@ -366,131 +351,121 @@ static lv_res_t lv_spinbox_signal(lv_obj_t * spinbox, lv_signal_t sign, void * p
if(buf->type[i] == NULL) break;
}
buf->type[i] = "lv_spinbox";
}else if(sign == LV_SIGNAL_CONTROLL)
{
}
else if(sign == LV_SIGNAL_CONTROLL) {
lv_hal_indev_type_t indev_type = lv_indev_get_type(lv_indev_get_act());
uint32_t c = *((uint32_t *)param); /*uint32_t because can be UTF-8*/
if(c == LV_GROUP_KEY_RIGHT)
{
if(indev_type == LV_INDEV_TYPE_ENCODER)
{
lv_spinbox_increment(spinbox);
}
else
{
lv_spinbox_step_next(spinbox);
}
if(c == LV_GROUP_KEY_RIGHT) {
if(indev_type == LV_INDEV_TYPE_ENCODER) lv_spinbox_increment(spinbox);
else lv_spinbox_step_next(spinbox);
}
else if(c == LV_GROUP_KEY_LEFT)
{
if(indev_type == LV_INDEV_TYPE_ENCODER)
{
lv_spinbox_decrement(spinbox);
}
else
{
else if(c == LV_GROUP_KEY_LEFT) {
if(indev_type == LV_INDEV_TYPE_ENCODER) lv_spinbox_decrement(spinbox);
else lv_spinbox_step_previous(spinbox);
}
else if(c == LV_GROUP_KEY_UP) {
lv_spinbox_increment(spinbox);
}
else if(c == LV_GROUP_KEY_DOWN) {
lv_spinbox_decrement(spinbox);
}
else if(c == LV_GROUP_KEY_ENTER) {
if(ext->step > 1) {
lv_spinbox_step_next(spinbox);
} else {
/*Restart from the MSB*/
ext->step = 1;
uint32_t i;
for(i = 0; i < ext->digit_count; i++) {
int32_t new_step = ext->step * 10;
if(new_step >= ext->range_max) break;
ext->step = new_step;
}
lv_spinbox_step_previous(spinbox);
}
}
else if(c == LV_GROUP_KEY_UP)
{
lv_spinbox_increment(spinbox);
}
else if(c == LV_GROUP_KEY_DOWN)
{
lv_spinbox_decrement(spinbox);
}
else
{
if(c == LV_GROUP_KEY_ENTER)
{
int p = lv_ta_get_cursor_pos(spinbox);
if(p == (1 + ext->digit_padding_left + ext->digit_count))
{
for(int i = 0; i < ext->digit_count; i++)
lv_spinbox_step_previous(spinbox);
} else
{
lv_spinbox_step_next(spinbox);
}
lv_spinbox_updatevalue(spinbox);
}
else
{
lv_ta_add_char(spinbox, c);
}
else {
lv_ta_add_char(spinbox, c);
}
}
return res;
}
static void lv_spinbox_updatevalue(lv_obj_t * spinbox)
{
lv_spinbox_ext_t * ext = lv_obj_get_ext_attr(spinbox);
int32_t v = ext->value;
int32_t intDigits, decDigits;
uint8_t dc = ext->digit_count;
intDigits = (ext->dec_point_pos==0) ? ext->digit_count : ext->dec_point_pos;
decDigits = ext->digit_count - intDigits;
char buf[LV_SPINBOX_MAX_DIGIT_COUNT + 8];
memset(buf, 0, sizeof(buf));
char * buf_p = buf;
ext->digits[0] = v>=0 ? '+' : '-';
/*Add the sign*/
(*buf_p) = ext->value >= 0 ? '+' : '-';
buf_p++;
int pl; /*padding left*/
for(pl = 0; pl < ext->digit_padding_left; pl++)
{
ext->digits[1 + pl] = ' ';
int i;
/*padding left*/
for(i = 0; i < ext->digit_padding_left; i++) {
(*buf_p) = ' ';
buf_p++;
}
int i = 0;
uint8_t digits[16];
char digits[64];
/*Convert the numbers to string (the sign is already handled so always covert positive number)*/
lv_math_num_to_str(ext->value < 0 ? -ext->value : ext->value, digits);
if(v < 0)
v = -v;
for(i = 0; i < dc; i++)
{
digits[i] = v%10;
v = v/10;
/*Add leading zeros*/
int lz_cnt = ext->digit_count - (int)strlen(digits);
if(lz_cnt > 0) {
for(i = strlen(digits); i >= 0; i--) {
digits[i + lz_cnt] = digits[i];
}
for(i = 0; i < lz_cnt; i++) {
digits[i] = '0';
}
}
int k;
for(k = 0; k < intDigits; k++)
{
ext->digits[1 + pl + k] = '0' + digits[--i];
int32_t intDigits;
intDigits = (ext->dec_point_pos == 0) ? ext->digit_count : ext->dec_point_pos;
/*Add the decimal part*/
for(i = 0; i < intDigits && digits[i] != '\0'; i++) {
(*buf_p) = digits[i];
buf_p++;
}
ext->digits[1 + pl + intDigits] = '.';
if(ext->dec_point_pos != 0) {
/*Insert the decimal point*/
(*buf_p) = '.';
buf_p++;
int d;
for(d = 0; d < decDigits; d++)
{
ext->digits[1 + pl + intDigits + 1 + d] = '0' + digits[--i];
for(/*Leave i*/ ;i < ext->digit_count && digits[i] != '\0'; i++) {
(*buf_p) = digits[i];
buf_p++;
}
}
ext->digits[1 + pl + intDigits + 1 + decDigits] = '\0';
/*Refresh the text*/
lv_ta_set_text(spinbox, (char*)buf);
lv_label_set_text(ext->ta.label, (char*)ext->digits);
/*Set the cursor position*/
int32_t step = ext->step;
uint8_t cPos = ext->digit_count + pl;
uint8_t cur_pos = ext->digit_count;
while(step >= 10)
{
step /= 10;
cPos--;
cur_pos--;
}
if(cPos > pl + intDigits )
{
cPos ++;
}
if(cur_pos > intDigits ) cur_pos ++; /*Skip teh decimal point*/
lv_ta_set_cursor_pos(spinbox, cPos);
cur_pos += ext->digit_padding_left;
lv_ta_set_cursor_pos(spinbox, cur_pos);
}
#endif

View File

@@ -50,11 +50,9 @@ typedef struct {
int32_t range_max;
int32_t range_min;
int32_t step;
uint8_t digit_count:4;
uint8_t dec_point_pos:4; /*if 0, there is no separator and the number is an integer*/
uint8_t digit_padding_left:4;
uint8_t digit_padding_right:4;
uint8_t digits[1+1+LV_SPINBOX_MAX_DIGIT_COUNT]; /*1 sign, 1 point, 16 num digits*/
uint16_t digit_count:4;
uint16_t dec_point_pos:4; /*if 0, there is no separator and the number is an integer*/
uint16_t digit_padding_left:4;
lv_spinbox_value_changed_cb_t value_changed_cb;
} lv_spinbox_ext_t;

View File

@@ -88,10 +88,10 @@ lv_obj_t * lv_sw_create(lv_obj_t * par, const lv_obj_t * copy)
/*Set the default styles*/
lv_theme_t * th = lv_theme_get_current();
if(th) {
lv_sw_set_style(new_sw, LV_SW_STYLE_BG, th->sw.bg);
lv_sw_set_style(new_sw, LV_SW_STYLE_INDIC, th->sw.indic);
lv_sw_set_style(new_sw, LV_SW_STYLE_KNOB_OFF, th->sw.knob_off);
lv_sw_set_style(new_sw, LV_SW_STYLE_KNOB_ON, th->sw.knob_on);
lv_sw_set_style(new_sw, LV_SW_STYLE_BG, th->style.sw.bg);
lv_sw_set_style(new_sw, LV_SW_STYLE_INDIC, th->style.sw.indic);
lv_sw_set_style(new_sw, LV_SW_STYLE_KNOB_OFF, th->style.sw.knob_off);
lv_sw_set_style(new_sw, LV_SW_STYLE_KNOB_ON, th->style.sw.knob_on);
} else {
/*Let the slider' style*/
}

View File

@@ -108,6 +108,7 @@ lv_obj_t * lv_ta_create(lv_obj_t * par, const lv_obj_t * copy)
ext->cursor.valid_x = 0;
ext->one_line = 0;
ext->label = NULL;
ext->placeholder = NULL;
lv_obj_set_signal_func(new_ta, lv_ta_signal);
lv_obj_set_signal_func(lv_page_get_scrl(new_ta), lv_ta_scrollable_signal);
@@ -115,6 +116,8 @@ lv_obj_t * lv_ta_create(lv_obj_t * par, const lv_obj_t * copy)
/*Init the new text area object*/
if(copy == NULL) {
lv_page_set_scrl_fit2(new_ta, LV_FIT_FLOOD, LV_FIT_TIGHT);
ext->label = lv_label_create(new_ta, NULL);
lv_obj_set_design_func(ext->page.scrl, lv_ta_scrollable_design);
@@ -129,8 +132,8 @@ lv_obj_t * lv_ta_create(lv_obj_t * par, const lv_obj_t * copy)
/*Set the default styles*/
lv_theme_t * th = lv_theme_get_current();
if(th) {
lv_ta_set_style(new_ta, LV_TA_STYLE_BG, th->ta.area);
lv_ta_set_style(new_ta, LV_TA_STYLE_SB, th->ta.sb);
lv_ta_set_style(new_ta, LV_TA_STYLE_BG, th->style.ta.area);
lv_ta_set_style(new_ta, LV_TA_STYLE_SB, th->style.ta.sb);
} else {
lv_ta_set_style(new_ta, LV_TA_STYLE_BG, &lv_style_pretty);
}
@@ -607,7 +610,7 @@ void lv_ta_set_one_line(lv_obj_t * ta, bool en)
lv_coord_t font_h = lv_font_get_height(style_label->text.font);
ext->one_line = 1;
lv_page_set_scrl_fit(ta, true, true);
lv_page_set_scrl_fit2(ta, LV_FIT_TIGHT, LV_FIT_FLOOD);
lv_obj_set_height(ta, font_h + (style_ta->body.padding.ver + style_scrl->body.padding.ver) * 2);
lv_label_set_long_mode(ext->label, LV_LABEL_LONG_EXPAND);
if(ext->placeholder) lv_label_set_long_mode(ext->placeholder, LV_LABEL_LONG_EXPAND);
@@ -616,7 +619,7 @@ void lv_ta_set_one_line(lv_obj_t * ta, bool en)
lv_style_t * style_ta = lv_obj_get_style(ta);
ext->one_line = 0;
lv_page_set_scrl_fit(ta, false, true);
lv_page_set_scrl_fit2(ta, LV_FIT_FLOOD, LV_FIT_TIGHT);
lv_label_set_long_mode(ext->label, LV_LABEL_LONG_BREAK);
if(ext->placeholder) lv_label_set_long_mode(ext->placeholder, LV_LABEL_LONG_BREAK);
@@ -645,19 +648,17 @@ void lv_ta_set_text_align(lv_obj_t * ta, lv_label_align_t align)
/*Normal left align. Just let the text expand*/
if(align == LV_LABEL_ALIGN_LEFT) {
lv_label_set_long_mode(label, LV_LABEL_LONG_EXPAND);
lv_page_set_scrl_fit(ta, true, false);
lv_page_set_scrl_fit2(ta, LV_FIT_TIGHT, LV_FIT_FLOOD);
lv_label_set_align(label, align);
}
/*Else use fix label width equal to the Text area width*/
else {
lv_label_set_long_mode(label, LV_LABEL_LONG_CROP);
lv_page_set_scrl_fit(ta, false, false);
lv_page_set_scrl_width(ta, 1); /*To refresh the scrollable's width*/
lv_page_set_scrl_fit2(ta, LV_FIT_FLOOD, LV_FIT_FLOOD);
lv_label_set_align(label, align);
lv_style_t * bg_style = lv_ta_get_style(ta, LV_TA_STYLE_BG);
lv_obj_set_width(label, lv_obj_get_width(ta) - 2 * bg_style->body.padding.hor);
lv_obj_set_width(label, lv_page_get_fit_width(ta));
}
}
@@ -1230,13 +1231,14 @@ static void cursor_blink_anim(lv_obj_t * ta, uint8_t show)
if(ext->cursor.type != LV_CURSOR_NONE &&
(ext->cursor.type & LV_CURSOR_HIDDEN) == 0)
{
lv_disp_t * disp = lv_obj_get_disp(ta);
lv_area_t area_tmp;
lv_area_copy(&area_tmp, &ext->cursor.area);
area_tmp.x1 += ext->label->coords.x1;
area_tmp.y1 += ext->label->coords.y1;
area_tmp.x2 += ext->label->coords.x1;
area_tmp.y2 += ext->label->coords.y1;
lv_inv_area(&area_tmp);
lv_inv_area(disp, &area_tmp);
}
}
}
@@ -1421,13 +1423,14 @@ static void refr_cursor_area(lv_obj_t * ta)
}
/*Save the new area*/
lv_disp_t * disp = lv_obj_get_disp(ta);
lv_area_t area_tmp;
lv_area_copy(&area_tmp, &ext->cursor.area);
area_tmp.x1 += ext->label->coords.x1;
area_tmp.y1 += ext->label->coords.y1;
area_tmp.x2 += ext->label->coords.x1;
area_tmp.y2 += ext->label->coords.y1;
lv_inv_area(&area_tmp);
lv_inv_area(disp, &area_tmp);
lv_area_copy(&ext->cursor.area, &cur_area);
@@ -1436,7 +1439,7 @@ static void refr_cursor_area(lv_obj_t * ta)
area_tmp.y1 += ext->label->coords.y1;
area_tmp.x2 += ext->label->coords.x1;
area_tmp.y2 += ext->label->coords.y1;
lv_inv_area(&area_tmp);
lv_inv_area(disp, &area_tmp);
}
static void placeholder_update(lv_obj_t * ta)
@@ -1470,9 +1473,12 @@ static void update_cursor_position_on_click(lv_obj_t * ta, lv_indev_t * click_so
lv_obj_get_coords(ext->label, &label_coords);
lv_point_t point_act;
lv_indev_get_point(click_source, &point_act);
if(point_act.x < 0 || point_act.y < 0) return; /*Ignore event from keypad*/
lv_point_t relative_position;
relative_position.x = click_source->proc.act_point.x - label_coords.x1;
relative_position.y = click_source->proc.act_point.y - label_coords.y1;
relative_position.x = point_act.x - label_coords.x1;
relative_position.y = point_act.y - label_coords.y1;
lv_coord_t label_width = lv_obj_get_width(ext->label);

View File

@@ -89,11 +89,11 @@ lv_obj_t * lv_table_create(lv_obj_t * par, const lv_obj_t * copy)
/*Set the default styles*/
lv_theme_t * th = lv_theme_get_current();
if(th) {
lv_table_set_style(new_table, LV_TABLE_STYLE_BG, th->table.bg);
lv_table_set_style(new_table, LV_TABLE_STYLE_CELL1, th->table.cell);
lv_table_set_style(new_table, LV_TABLE_STYLE_CELL2, th->table.cell);
lv_table_set_style(new_table, LV_TABLE_STYLE_CELL3, th->table.cell);
lv_table_set_style(new_table, LV_TABLE_STYLE_CELL4, th->table.cell);
lv_table_set_style(new_table, LV_TABLE_STYLE_BG, th->style.table.bg);
lv_table_set_style(new_table, LV_TABLE_STYLE_CELL1, th->style.table.cell);
lv_table_set_style(new_table, LV_TABLE_STYLE_CELL2, th->style.table.cell);
lv_table_set_style(new_table, LV_TABLE_STYLE_CELL3, th->style.table.cell);
lv_table_set_style(new_table, LV_TABLE_STYLE_CELL4, th->style.table.cell);
} else {
lv_table_set_style(new_table, LV_TABLE_STYLE_BG, &lv_style_plain_color);
}

View File

@@ -106,7 +106,8 @@ lv_obj_t * lv_tabview_create(lv_obj_t * par, const lv_obj_t * copy)
ext->tab_name_ptr[0] = "";
ext->tab_cnt = 0;
lv_obj_set_size(new_tabview, LV_HOR_RES, LV_VER_RES);
lv_disp_t * disp = lv_obj_get_disp(new_tabview);
lv_obj_set_size(new_tabview, lv_disp_get_hor_res(disp), lv_disp_get_ver_res(disp));
ext->btns = lv_btnm_create(new_tabview, NULL);
lv_obj_set_height(ext->btns, 3 * LV_DPI / 4);
@@ -120,22 +121,22 @@ lv_obj_t * lv_tabview_create(lv_obj_t * par, const lv_obj_t * copy)
lv_obj_set_click(ext->indic, false);
ext->content = lv_cont_create(new_tabview, NULL);
lv_cont_set_fit(ext->content, true, false);
lv_cont_set_fit2(ext->content, LV_FIT_TIGHT, LV_FIT_NONE);
lv_cont_set_layout(ext->content, LV_LAYOUT_ROW_T);
lv_cont_set_style(ext->content, &lv_style_transp_tight);
lv_obj_set_height(ext->content, LV_VER_RES - lv_obj_get_height(ext->btns));
lv_obj_set_height(ext->content, lv_obj_get_height(new_tabview) - lv_obj_get_height(ext->btns));
lv_obj_align(ext->content, ext->btns, LV_ALIGN_OUT_BOTTOM_LEFT, 0, 0);
/*Set the default styles*/
lv_theme_t * th = lv_theme_get_current();
if(th) {
lv_tabview_set_style(new_tabview, LV_TABVIEW_STYLE_BG, th->tabview.bg);
lv_tabview_set_style(new_tabview, LV_TABVIEW_STYLE_INDIC, th->tabview.indic);
lv_tabview_set_style(new_tabview, LV_TABVIEW_STYLE_BTN_BG, th->tabview.btn.bg);
lv_tabview_set_style(new_tabview, LV_TABVIEW_STYLE_BTN_REL, th->tabview.btn.rel);
lv_tabview_set_style(new_tabview, LV_TABVIEW_STYLE_BTN_PR, th->tabview.btn.pr);
lv_tabview_set_style(new_tabview, LV_TABVIEW_STYLE_BTN_TGL_REL, th->tabview.btn.tgl_rel);
lv_tabview_set_style(new_tabview, LV_TABVIEW_STYLE_BTN_TGL_PR, th->tabview.btn.tgl_pr);
lv_tabview_set_style(new_tabview, LV_TABVIEW_STYLE_BG, th->style.tabview.bg);
lv_tabview_set_style(new_tabview, LV_TABVIEW_STYLE_INDIC, th->style.tabview.indic);
lv_tabview_set_style(new_tabview, LV_TABVIEW_STYLE_BTN_BG, th->style.tabview.btn.bg);
lv_tabview_set_style(new_tabview, LV_TABVIEW_STYLE_BTN_REL, th->style.tabview.btn.rel);
lv_tabview_set_style(new_tabview, LV_TABVIEW_STYLE_BTN_PR, th->style.tabview.btn.pr);
lv_tabview_set_style(new_tabview, LV_TABVIEW_STYLE_BTN_TGL_REL, th->style.tabview.btn.tgl_rel);
lv_tabview_set_style(new_tabview, LV_TABVIEW_STYLE_BTN_TGL_PR, th->style.tabview.btn.tgl_pr);
} else {
lv_tabview_set_style(new_tabview, LV_TABVIEW_STYLE_BG, &lv_style_plain);
lv_tabview_set_style(new_tabview, LV_TABVIEW_STYLE_BTN_BG, &lv_style_transp);
@@ -621,12 +622,14 @@ static lv_res_t lv_tabview_signal(lv_obj_t * tabview, lv_signal_t sign, void * p
lv_hal_indev_type_t indev_type = lv_indev_get_type(lv_indev_get_act());
/*With ENCODER select the first button only in edit mode*/
if(indev_type == LV_INDEV_TYPE_ENCODER) {
#if USE_LV_GROUP
lv_group_t * g = lv_obj_get_group(tabview);
if(lv_group_get_editing(g)) {
lv_btnm_ext_t * btnm_ext = lv_obj_get_ext_attr(ext->btns);
btnm_ext->btn_id_pr = 0;
lv_obj_invalidate(ext->btns);
}
#endif
} else {
lv_btnm_ext_t * btnm_ext = lv_obj_get_ext_attr(ext->btns);
btnm_ext->btn_id_pr = 0;

View File

@@ -89,15 +89,15 @@ lv_obj_t * lv_tileview_create(lv_obj_t * par, const lv_obj_t * copy)
/*Init the new tileview*/
if(copy == NULL) {
lv_obj_set_size(new_tileview, LV_HOR_RES, LV_VER_RES);
lv_obj_set_size(new_tileview, LV_DPI * 3, LV_DPI * 3);
lv_obj_set_drag_throw(lv_page_get_scrl(new_tileview), false);
lv_page_set_scrl_fit(new_tileview, true, true);
lv_page_set_scrl_fit(new_tileview, LV_FIT_TIGHT);
/*Set the default styles*/
lv_theme_t * th = lv_theme_get_current();
if(th) {
lv_page_set_style(new_tileview, LV_PAGE_STYLE_BG, th->tileview.bg);
lv_page_set_style(new_tileview, LV_PAGE_STYLE_SCRL, th->tileview.scrl);
lv_page_set_style(new_tileview, LV_PAGE_STYLE_SB, th->tileview.sb);
lv_page_set_style(new_tileview, LV_PAGE_STYLE_BG, th->style.tileview.bg);
lv_page_set_style(new_tileview, LV_PAGE_STYLE_SCRL, th->style.tileview.scrl);
lv_page_set_style(new_tileview, LV_PAGE_STYLE_SB, th->style.tileview.sb);
} else {
lv_page_set_style(new_tileview, LV_PAGE_STYLE_BG, &lv_style_transp_tight);
lv_page_set_style(new_tileview, LV_PAGE_STYLE_SCRL, &lv_style_transp_tight);
@@ -343,14 +343,14 @@ static lv_res_t lv_tileview_scrl_signal(lv_obj_t * scrl, lv_signal_t sign, void
/*Set horizontal drag constraint if no vertical constraint an dragged to valid x direction */
if(ext->drag_ver == 0 &&
((ext->drag_right_en && indev->proc.drag_sum.x <= -LV_INDEV_DRAG_LIMIT) ||
(ext->drag_left_en && indev->proc.drag_sum.x >= LV_INDEV_DRAG_LIMIT))) {
((ext->drag_right_en && indev->proc.types.pointer.drag_sum.x <= -LV_INDEV_DRAG_LIMIT) ||
(ext->drag_left_en && indev->proc.types.pointer.drag_sum.x >= LV_INDEV_DRAG_LIMIT))) {
ext->drag_hor = 1;
}
/*Set vertical drag constraint if no horizontal constraint an dragged to valid y direction */
if(ext->drag_hor == 0 &&
((ext->drag_bottom_en && indev->proc.drag_sum.y <= -LV_INDEV_DRAG_LIMIT) ||
(ext->drag_top_en && indev->proc.drag_sum.y >= LV_INDEV_DRAG_LIMIT))) {
((ext->drag_bottom_en && indev->proc.types.pointer.drag_sum.y <= -LV_INDEV_DRAG_LIMIT) ||
(ext->drag_top_en && indev->proc.types.pointer.drag_sum.y >= LV_INDEV_DRAG_LIMIT))) {
ext->drag_ver = 1;
}
@@ -369,7 +369,7 @@ static lv_res_t lv_tileview_scrl_signal(lv_obj_t * scrl, lv_signal_t sign, void
lv_coord_t h = lv_obj_get_height(tileview);
lv_coord_t w = lv_obj_get_width(tileview);
if(ext->drag_top_en == 0) {
if(y > -(ext->act_id.y * h) && indev->proc.vect.y > 0 && ext->drag_hor == 0) {
if(y > -(ext->act_id.y * h) && indev->proc.types.pointer.vect.y > 0 && ext->drag_hor == 0) {
if(ext->page.edge_flash.enabled &&
ext->page.edge_flash.left_ip == 0 && ext->page.edge_flash.right_ip == 0 &&
ext->page.edge_flash.top_ip == 0 && ext->page.edge_flash.bottom_ip == 0) {
@@ -380,7 +380,7 @@ static lv_res_t lv_tileview_scrl_signal(lv_obj_t * scrl, lv_signal_t sign, void
lv_obj_set_y(scrl, -ext->act_id.y * h);
}
}
if(ext->drag_bottom_en == 0 && indev->proc.vect.y < 0 && ext->drag_hor == 0) {
if(ext->drag_bottom_en == 0 && indev->proc.types.pointer.vect.y < 0 && ext->drag_hor == 0) {
if(y < -(ext->act_id.y * h)) {
if(ext->page.edge_flash.enabled &&
ext->page.edge_flash.left_ip == 0 && ext->page.edge_flash.right_ip == 0 &&
@@ -393,7 +393,7 @@ static lv_res_t lv_tileview_scrl_signal(lv_obj_t * scrl, lv_signal_t sign, void
lv_obj_set_y(scrl, -ext->act_id.y * h);
}
if(ext->drag_left_en == 0) {
if(x > -(ext->act_id.x * w) && indev->proc.vect.x > 0 && ext->drag_ver == 0) {
if(x > -(ext->act_id.x * w) && indev->proc.types.pointer.vect.x > 0 && ext->drag_ver == 0) {
if(ext->page.edge_flash.enabled &&
ext->page.edge_flash.left_ip == 0 && ext->page.edge_flash.right_ip == 0 &&
ext->page.edge_flash.top_ip == 0 && ext->page.edge_flash.bottom_ip == 0) {
@@ -404,7 +404,7 @@ static lv_res_t lv_tileview_scrl_signal(lv_obj_t * scrl, lv_signal_t sign, void
lv_obj_set_x(scrl, -ext->act_id.x * w);
}
}
if(ext->drag_right_en == 0 && indev->proc.vect.x < 0 && ext->drag_ver == 0) {
if(ext->drag_right_en == 0 && indev->proc.types.pointer.vect.x < 0 && ext->drag_ver == 0) {
if(x < -(ext->act_id.x * w)) {
if(ext->page.edge_flash.enabled &&
ext->page.edge_flash.left_ip == 0 && ext->page.edge_flash.right_ip == 0 &&
@@ -475,14 +475,14 @@ static lv_res_t element_signal_func(lv_obj_t * element, lv_signal_t sign, void *
* let the tileview to finish the move.*/
lv_indev_t * indev = lv_indev_get_act();
lv_tileview_ext_t * ext = lv_obj_get_ext_attr(tileview);
if(indev->proc.drag_in_prog && (ext->drag_hor || ext->drag_ver)) {
if(lv_indev_is_dragging(indev) && (ext->drag_hor || ext->drag_ver)) {
lv_obj_t * drag_obj = element;
while(lv_obj_get_drag_parent(drag_obj)) {
drag_obj = lv_obj_get_parent(drag_obj);
if(drag_obj == NULL) break;
}
indev->proc.drag_in_prog = 0;
indev->proc.types.pointer.drag_in_prog = 0;
if(drag_obj) drag_obj->signal_func(drag_obj, LV_SIGNAL_DRAG_END, NULL);
}
@@ -506,8 +506,8 @@ static void drag_end_handler(lv_obj_t * tileview)
lv_obj_t * scrl = lv_page_get_scrl(tileview);
lv_point_t p;
p.x = - (scrl->coords.x1 - LV_HOR_RES / 2);
p.y = - (scrl->coords.y1 - LV_VER_RES / 2);
p.x = - (scrl->coords.x1 - lv_obj_get_width(tileview) / 2);
p.y = - (scrl->coords.y1 - lv_obj_get_height(tileview) / 2);
/*From the drag vector (drag throw) predict the end position*/
if(ext->drag_hor) {

View File

@@ -10,6 +10,7 @@
#if USE_LV_WIN != 0
#include "../lv_themes/lv_theme.h"
#include "../lv_core/lv_disp.h"
/*********************
* DEFINES
@@ -70,7 +71,10 @@ lv_obj_t * lv_win_create(lv_obj_t * par, const lv_obj_t * copy)
/*Init the new window object*/
if(copy == NULL) {
lv_obj_set_size(new_win, LV_HOR_RES, LV_VER_RES);
lv_disp_t * disp = lv_obj_get_disp(new_win);
lv_coord_t hres = lv_disp_get_hor_res(disp);
lv_coord_t vres = lv_disp_get_ver_res(disp);
lv_obj_set_size(new_win, hres, vres);
lv_obj_set_pos(new_win, 0, 0);
lv_obj_set_style(new_win, &lv_style_pretty);
@@ -92,13 +96,13 @@ lv_obj_t * lv_win_create(lv_obj_t * par, const lv_obj_t * copy)
/*Set the default styles*/
lv_theme_t * th = lv_theme_get_current();
if(th) {
lv_win_set_style(new_win, LV_WIN_STYLE_BG, th->win.bg);
lv_win_set_style(new_win, LV_WIN_STYLE_SB, th->win.sb);
lv_win_set_style(new_win, LV_WIN_STYLE_HEADER, th->win.header);
lv_win_set_style(new_win, LV_WIN_STYLE_CONTENT_BG, th->win.content.bg);
lv_win_set_style(new_win, LV_WIN_STYLE_CONTENT_SCRL, th->win.content.scrl);
lv_win_set_style(new_win, LV_WIN_STYLE_BTN_REL, th->win.btn.rel);
lv_win_set_style(new_win, LV_WIN_STYLE_BTN_PR, th->win.btn.pr);
lv_win_set_style(new_win, LV_WIN_STYLE_BG, th->style.win.bg);
lv_win_set_style(new_win, LV_WIN_STYLE_SB, th->style.win.sb);
lv_win_set_style(new_win, LV_WIN_STYLE_HEADER, th->style.win.header);
lv_win_set_style(new_win, LV_WIN_STYLE_CONTENT_BG, th->style.win.content.bg);
lv_win_set_style(new_win, LV_WIN_STYLE_CONTENT_SCRL, th->style.win.content.scrl);
lv_win_set_style(new_win, LV_WIN_STYLE_BTN_REL, th->style.win.btn.rel);
lv_win_set_style(new_win, LV_WIN_STYLE_BTN_PR, th->style.win.btn.pr);
} else {
lv_win_set_style(new_win, LV_WIN_STYLE_BG, &lv_style_plain);
lv_win_set_style(new_win, LV_WIN_STYLE_CONTENT_BG, &lv_style_plain);
@@ -107,7 +111,6 @@ lv_obj_t * lv_win_create(lv_obj_t * par, const lv_obj_t * copy)
}
lv_obj_set_signal_func(new_win, lv_win_signal);
lv_obj_set_size(new_win, LV_HOR_RES, LV_VER_RES);
}
/*Copy an existing object*/
else {