add themes to spinbox, table and tileview

This commit is contained in:
Gabor Kiss-Vamosi
2019-01-01 01:20:10 +01:00
parent 9c7c200048
commit bf43316942
11 changed files with 242 additions and 16 deletions
+8 -1
View File
@@ -9,6 +9,7 @@
#include "lv_spinbox.h"
#if USE_LV_SPINBOX != 0
#include "../lv_themes/lv_theme.h"
/*********************
* DEFINES
@@ -83,7 +84,13 @@ lv_obj_t * lv_spinbox_create(lv_obj_t * par, const lv_obj_t * copy)
/*Init the new spinbox spinbox*/
if(copy == NULL) {
/*Already inited above*/
/*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);
}
}
/*Copy an existing spinbox*/
else {
+5 -4
View File
@@ -900,21 +900,22 @@ void lv_ta_cursor_up(lv_obj_t * ta)
* LV_DESIGN_DRAW_POST: drawing after every children are drawn
* @param return true/false, depends on 'mode'
*/
static bool lv_ta_design(lv_obj_t * ta, const lv_area_t * masp, lv_design_mode_t mode)
static bool lv_ta_design(lv_obj_t * ta, const lv_area_t * mask, lv_design_mode_t mode)
{
if(mode == LV_DESIGN_COVER_CHK) {
/*Return false if the object is not covers the mask_p area*/
return ancestor_design(ta, masp, mode);
return ancestor_design(ta, mask, mode);
} else if(mode == LV_DESIGN_DRAW_MAIN) {
/*Draw the object*/
ancestor_design(ta, masp, mode);
ancestor_design(ta, mask, mode);
} else if(mode == LV_DESIGN_DRAW_POST) {
ancestor_design(ta, masp, mode);
ancestor_design(ta, mask, mode);
}
return true;
}
/**
* An extended scrollable design of the page. Calls the normal design function and draws a cursor.
* @param scrl pointer to the scrollable part of the Text area
+9 -1
View File
@@ -12,6 +12,7 @@
#include "../lv_misc/lv_txt.h"
#include "../lv_misc/lv_math.h"
#include "../lv_draw/lv_draw_label.h"
#include "../lv_themes/lv_theme.h"
/*********************
* DEFINES
@@ -82,7 +83,14 @@ lv_obj_t * lv_table_create(lv_obj_t * par, const lv_obj_t * copy)
/*Init the new table table*/
if(copy == NULL) {
lv_table_set_style(new_table, LV_TABLE_STYLE_BG, &lv_style_plain_color);
/*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_CELL, th->table.cell);
} else {
lv_table_set_style(new_table, LV_TABLE_STYLE_BG, &lv_style_plain_color);
}
}
/*Copy an existing table*/
else {
+11 -3
View File
@@ -11,6 +11,7 @@
#include <stdbool.h>
#include "lv_cont.h"
#include "../lv_themes/lv_theme.h"
/*********************
* DEFINES
@@ -89,11 +90,18 @@ 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_drag_throw(lv_page_get_scrl(new_tileview), false);
lv_page_set_scrl_fit(new_tileview, true, true);
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);
/*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);
} 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);
}
}
/*Copy an existing tileview*/
else {
+1 -1
View File
@@ -37,7 +37,7 @@ static lv_theme_t * current_theme;
/* Store the styles in this array.
* Can't determine the size in compile time because sizeof is not evaluated (should be `sizeof(lv_theme_t) / sizeof(lv_style_t*)`).
* Error will be generated in run time if too small.*/
static lv_style_t th_styles[100];
static lv_style_t th_styles[120];
static bool inited = false;
static lv_theme_t current_theme;
#endif
+23
View File
@@ -207,6 +207,14 @@ typedef struct {
} ta;
#endif
#if USE_LV_SPINBOX != 0
struct {
lv_style_t *bg;
lv_style_t *cursor;
lv_style_t *sb;
} spinbox;
#endif
#if USE_LV_LIST
struct {
lv_style_t *bg;
@@ -251,6 +259,21 @@ typedef struct {
} tabview;
#endif
#if USE_LV_TILEVIEW != 0
struct {
lv_style_t *bg;
lv_style_t *scrl;
lv_style_t *sb;
} tileview;
#endif
#if USE_LV_TABLE != 0
struct {
lv_style_t *bg;
lv_style_t *cell;
} table;
#endif
#if USE_LV_WIN != 0
struct {
lv_style_t *bg;
+37
View File
@@ -595,6 +595,15 @@ static void ta_init(void)
#endif
}
static void spinbox_init(void)
{
#if USE_LV_SPINBOX
theme.spinbox.bg= &panel;
theme.spinbox.cursor = theme.ta.cursor;
theme.spinbox.sb = theme.ta.sb;
#endif
}
static void list_init(void)
{
#if USE_LV_LIST != 0
@@ -737,6 +746,31 @@ static void tabview_init(void)
#endif
}
static void tileview_init(void)
{
#if USE_LV_TILEVIEW != 0
theme.tileview.bg = &lv_style_transp_tight;
theme.tileview.scrl = &lv_style_transp_tight;
theme.tileview.sb = theme.page.sb;
#endif
}
static void table_init(void)
{
#if USE_LV_TABLE != 0
static lv_style_t cell;
lv_style_copy(&cell, &panel);
cell.body.radius = 0;
cell.body.border.width = 1;
cell.body.padding.hor = LV_DPI / 12;
cell.body.padding.ver = LV_DPI / 12;
theme.table.bg = &lv_style_transp_tight;
theme.table.cell = &cell;
#endif
}
static void win_init(void)
{
#if USE_LV_WIN != 0
@@ -811,10 +845,13 @@ lv_theme_t * lv_theme_alien_init(uint16_t hue, lv_font_t * font)
mbox_init();
page_init();
ta_init();
spinbox_init();
list_init();
ddlist_init();
roller_init();
tabview_init();
tileview_init();
table_init();
win_init();
return &theme;
+37 -1
View File
@@ -29,6 +29,7 @@
**********************/
static lv_theme_t theme;
static lv_style_t def;
static lv_style_t bg, panel;
/*Static style definitions*/
static lv_style_t sb;
@@ -51,7 +52,6 @@ static void basic_init(void)
def.text.font = _font;
def.body.radius = DEF_RADIUS;
static lv_style_t bg, panel;
lv_style_copy(&bg, &def);
bg.body.main_color = LV_COLOR_HEX(0xf0f0f0);
bg.body.grad_color = bg.body.main_color;
@@ -540,6 +540,15 @@ static void ta_init(void)
#endif
}
static void spinbox_init(void)
{
#if USE_LV_SPINBOX
theme.spinbox.bg= &panel;
theme.spinbox.cursor = theme.ta.cursor;
theme.spinbox.sb = theme.ta.sb;
#endif
}
static void list_init(void)
{
#if USE_LV_LIST != 0
@@ -708,6 +717,30 @@ static void tabview_init(void)
#endif
}
static void tileview_init(void)
{
#if USE_LV_TILEVIEW != 0
theme.tileview.bg = &lv_style_transp_tight;
theme.tileview.scrl = &lv_style_transp_tight;
theme.tileview.sb = theme.page.sb;
#endif
}
static void table_init(void)
{
#if USE_LV_TABLE != 0
static lv_style_t cell;
lv_style_copy(&cell, &panel);
cell.body.radius = 0;
cell.body.border.width = 1;
cell.body.padding.hor = LV_DPI / 12;
cell.body.padding.ver = LV_DPI / 12;
theme.table.bg = &lv_style_transp_tight;
theme.table.cell = &cell;
#endif
}
static void win_init(void)
{
@@ -795,10 +828,13 @@ lv_theme_t * lv_theme_material_init(uint16_t hue, lv_font_t * font)
mbox_init();
page_init();
ta_init();
spinbox_init();
list_init();
ddlist_init();
roller_init();
tabview_init();
tileview_init();
table_init();
win_init();
return &theme;
+34
View File
@@ -584,6 +584,15 @@ static void ta_init(void)
#endif
}
static void spinbox_init(void)
{
#if USE_LV_SPINBOX
theme.spinbox.bg= &panel;
theme.spinbox.cursor = theme.ta.cursor;
theme.spinbox.sb = theme.ta.sb;
#endif
}
static void list_init(void)
{
#if USE_LV_LIST != 0
@@ -726,6 +735,28 @@ static void tabview_init(void)
#endif
}
static void tileview_init(void)
{
#if USE_LV_TILEVIEW != 0
theme.tileview.bg = &lv_style_transp_tight;
theme.tileview.scrl = &lv_style_transp_tight;
theme.tileview.sb = theme.page.sb;
#endif
}
static void table_init(void)
{
#if USE_LV_TABLE != 0
static lv_style_t cell;
lv_style_copy(&cell, &panel);
cell.body.radius = 0;
cell.body.border.width = 1;
theme.table.bg = &lv_style_transp_tight;
theme.table.cell = &cell;
#endif
}
static void win_init(void)
{
#if USE_LV_WIN != 0
@@ -796,10 +827,13 @@ lv_theme_t * lv_theme_nemo_init(uint16_t hue, lv_font_t * font)
mbox_init();
page_init();
ta_init();
spinbox_init();
list_init();
ddlist_init();
roller_init();
tabview_init();
tileview_init();
table_init();
win_init();
return &theme;
+38 -2
View File
@@ -522,6 +522,15 @@ static void ta_init(void)
#endif
}
static void spinbox_init(void)
{
#if USE_LV_SPINBOX
theme.spinbox.bg= &panel;
theme.spinbox.cursor = theme.ta.cursor;
theme.spinbox.sb = theme.ta.sb;
#endif
}
static void list_init(void)
{
#if USE_LV_LIST != 0
@@ -539,6 +548,7 @@ static void list_init(void)
list_btn_rel.body.border.width = 1;
list_btn_rel.body.radius = LV_DPI / 10;
list_btn_rel.text.color = lv_color_hsv_to_rgb(_hue, 5, 80);
list_btn_rel.image.color = lv_color_hsv_to_rgb(_hue, 5, 80);
list_btn_rel.body.padding.ver = LV_DPI / 6;
list_btn_rel.body.padding.hor = LV_DPI / 8;
@@ -547,16 +557,15 @@ static void list_init(void)
list_btn_pr.body.grad_color = btn_pr.body.main_color;
list_btn_pr.body.border.color = lv_color_hsv_to_rgb(_hue, 10, 5);
list_btn_pr.body.border.width = 0;
list_btn_pr.body.radius = LV_DPI / 30;
list_btn_pr.body.padding.ver = LV_DPI / 6;
list_btn_pr.body.padding.hor = LV_DPI / 8;
list_btn_pr.text.color = lv_color_hsv_to_rgb(_hue, 5, 80);
list_btn_pr.image.color = lv_color_hsv_to_rgb(_hue, 5, 80);
lv_style_copy(&list_btn_tgl_rel, &list_btn_rel);
list_btn_tgl_rel.body.empty = 0;
list_btn_tgl_rel.body.main_color = lv_color_hsv_to_rgb(_hue, 10, 8);
list_btn_tgl_rel.body.grad_color = lv_color_hsv_to_rgb(_hue, 10, 8);
list_btn_tgl_rel.body.radius = LV_DPI / 30;
lv_style_copy(&list_btn_tgl_pr, &list_btn_tgl_rel);
list_btn_tgl_pr.body.main_color = btn_tgl_pr.body.main_color;
@@ -622,6 +631,30 @@ static void tabview_init(void)
#endif
}
static void tileview_init(void)
{
#if USE_LV_TILEVIEW != 0
theme.tileview.bg = &lv_style_transp_tight;
theme.tileview.scrl = &lv_style_transp_tight;
theme.tileview.sb = theme.page.sb;
#endif
}
static void table_init(void)
{
#if USE_LV_TABLE != 0
static lv_style_t cell;
lv_style_copy(&cell, &panel);
cell.body.radius = 0;
cell.body.border.width = 1;
cell.body.padding.hor = LV_DPI / 12;
cell.body.padding.ver = LV_DPI / 12;
theme.table.bg = &lv_style_transp_tight;
theme.table.cell = &cell;
#endif
}
static void win_init(void)
{
@@ -705,10 +738,13 @@ lv_theme_t * lv_theme_night_init(uint16_t hue, lv_font_t * font)
mbox_init();
page_init();
ta_init();
spinbox_init();
list_init();
ddlist_init();
roller_init();
tabview_init();
tileview_init();
table_init();
win_init();
return &theme;
+39 -3
View File
@@ -27,8 +27,10 @@
* STATIC VARIABLES
**********************/
static lv_theme_t theme;
static lv_style_t def;
/*Static style definitions*/
static lv_style_t def;
static lv_style_t bg;
static lv_style_t panel;
static lv_style_t sb;
/*Saved input parameters*/
@@ -45,8 +47,6 @@ static lv_font_t * _font;
static void basic_init(void)
{
static lv_style_t bg;
static lv_style_t panel;
lv_style_copy(&def, &lv_style_pretty); /*Initialize the default style*/
def.body.border.opa = LV_OPA_COVER;
@@ -560,6 +560,15 @@ static void ta_init(void)
#endif
}
static void spinbox_init(void)
{
#if USE_LV_SPINBOX
theme.spinbox.bg= &panel;
theme.spinbox.cursor = theme.ta.cursor;
theme.spinbox.sb = theme.ta.sb;
#endif
}
static void list_init(void)
{
#if USE_LV_LIST != 0
@@ -682,6 +691,30 @@ static void tabview_init(void)
#endif
}
static void tileview_init(void)
{
#if USE_LV_TILEVIEW != 0
theme.tileview.bg = &lv_style_transp_tight;
theme.tileview.scrl = &lv_style_transp_tight;
theme.tileview.sb = theme.page.sb;
#endif
}
static void table_init(void)
{
#if USE_LV_TABLE != 0
static lv_style_t cell;
lv_style_copy(&cell, &panel);
cell.body.radius = 0;
cell.body.border.width = 1;
cell.body.shadow.width = 0;
cell.body.padding.hor = LV_DPI / 12;
cell.body.padding.ver = LV_DPI / 12;
theme.table.bg = &lv_style_transp_tight;
theme.table.cell = &cell;
#endif
}
static void win_init(void)
{
@@ -762,10 +795,13 @@ lv_theme_t * lv_theme_zen_init(uint16_t hue, lv_font_t * font)
mbox_init();
page_init();
ta_init();
spinbox_init();
list_init();
ddlist_init();
roller_init();
tabview_init();
tileview_init();
table_init();
win_init();
return &theme;