refactor: rename LV_THEME_BASIC to LV_THEME_SIMPLE

This commit is contained in:
Gabor Kiss-Vamosi
2023-12-15 09:12:54 +01:00
parent b773abbb08
commit 3fa47263c8
10 changed files with 53 additions and 31 deletions

View File

@@ -514,7 +514,7 @@
#endif /*LV_USE_THEME_DEFAULT*/
/*A very simple theme that is a good starting point for a custom theme*/
#define LV_USE_THEME_BASIC 1
#define LV_USE_THEME_SIMPLE 1
/*A theme designed for monochrome displays*/
#define LV_USE_THEME_MONO 1

View File

@@ -540,7 +540,7 @@
#endif /*LV_USE_THEME_DEFAULT*/
/*A very simple theme that is a good starting point for a custom theme*/
#define LV_USE_THEME_BASIC 1
#define LV_USE_THEME_SIMPLE 1
/*A theme designed for monochrome displays*/
#define LV_USE_THEME_MONO 1

View File

@@ -124,8 +124,8 @@ typedef struct _lv_global_t {
uint32_t log_last_log_time;
#endif
#if LV_USE_THEME_BASIC
struct _my_theme_t * theme_basic;
#if LV_USE_THEME_SIMPLE
struct _my_theme_t * theme_simple;
#endif
#if LV_USE_THEME_DEFAULT

View File

@@ -107,6 +107,13 @@ lv_display_t * lv_display_create(int32_t hor_res, int32_t ver_res)
else {
disp->theme = lv_theme_default_get();
}
#elif LV_USE_THEME_SIMPLE
if(lv_theme_simple_is_inited() == false) {
disp->theme = lv_theme_simple_init(disp);
}
else {
disp->theme = lv_theme_simple_get();
}
#endif
disp->bottom_layer = lv_obj_create(NULL); /*Create bottom layer on the display*/

View File

@@ -1822,15 +1822,15 @@
#endif /*LV_USE_THEME_DEFAULT*/
/*A very simple theme that is a good starting point for a custom theme*/
#ifndef LV_USE_THEME_BASIC
#ifndef LV_USE_THEME_SIMPLE
#ifdef _LV_KCONFIG_PRESENT
#ifdef CONFIG_LV_USE_THEME_BASIC
#define LV_USE_THEME_BASIC CONFIG_LV_USE_THEME_BASIC
#ifdef CONFIG_LV_USE_THEME_SIMPLE
#define LV_USE_THEME_SIMPLE CONFIG_LV_USE_THEME_SIMPLE
#else
#define LV_USE_THEME_BASIC 0
#define LV_USE_THEME_SIMPLE 0
#endif
#else
#define LV_USE_THEME_BASIC 1
#define LV_USE_THEME_SIMPLE 1
#endif
#endif

View File

@@ -331,8 +331,8 @@ void lv_deinit(void)
lv_theme_default_deinit();
#endif
#if LV_USE_THEME_BASIC
lv_theme_basic_deinit();
#if LV_USE_THEME_SIMPLE
lv_theme_simple_deinit();
#endif
#if LV_USE_THEME_MONO

View File

@@ -115,7 +115,7 @@ lv_color_t lv_theme_get_color_secondary(lv_obj_t * obj);
#include "default/lv_theme_default.h"
#include "mono/lv_theme_mono.h"
#include "basic/lv_theme_basic.h"
#include "simple/lv_theme_simple.h"
#ifdef __cplusplus
} /*extern "C"*/

View File

@@ -1,5 +1,5 @@
/**
* @file lv_theme_basic.c
* @file lv_theme_simple.c
*
*/
@@ -8,15 +8,15 @@
*********************/
#include "../../../lvgl.h" /*To see all the widgets*/
#if LV_USE_THEME_BASIC
#if LV_USE_THEME_SIMPLE
#include "lv_theme_basic.h"
#include "lv_theme_simple.h"
#include "../../core/lv_global.h"
/*********************
* DEFINES
*********************/
#define theme_def (LV_GLOBAL_DEFAULT()->theme_basic)
#define theme_def (LV_GLOBAL_DEFAULT()->theme_simple)
#define COLOR_SCR lv_palette_lighten(LV_PALETTE_GREY, 4)
#define COLOR_WHITE lv_color_white()
@@ -137,14 +137,23 @@ static void style_init(struct _my_theme_t * theme)
* GLOBAL FUNCTIONS
**********************/
bool lv_theme_basic_is_inited(void)
bool lv_theme_simple_is_inited(void)
{
struct _my_theme_t * theme = theme_def;
if(theme == NULL) return false;
return theme->inited;
}
void lv_theme_basic_deinit(void)
lv_theme_t * lv_theme_simple_get(void)
{
if(!lv_theme_simple_is_inited()) {
return NULL;
}
return (lv_theme_t *)theme_def;
}
void lv_theme_simple_deinit(void)
{
struct _my_theme_t * theme = theme_def;
if(theme) {
@@ -160,12 +169,12 @@ void lv_theme_basic_deinit(void)
}
}
lv_theme_t * lv_theme_basic_init(lv_display_t * disp)
lv_theme_t * lv_theme_simple_init(lv_display_t * disp)
{
/*This trick is required only to avoid the garbage collection of
*styles' data if LVGL is used in a binding (e.g. Micropython)
*In a general case styles could be in simple `static lv_style_t my_style...` variables*/
if(!lv_theme_basic_is_inited()) {
if(!lv_theme_simple_is_inited()) {
theme_def = lv_malloc_zeroed(sizeof(my_theme_t));
}
@@ -419,7 +428,7 @@ static void theme_apply(lv_theme_t * th, lv_obj_t * obj)
static void style_init_reset(lv_style_t * style)
{
if(lv_theme_basic_is_inited()) {
if(lv_theme_simple_is_inited()) {
lv_style_reset(style);
}
else {

View File

@@ -1,10 +1,10 @@
/**
* @file lv_theme_basic.h
* @file lv_theme_simple.h
*
*/
#ifndef LV_THEME_BASIC_H
#define LV_THEME_BASIC_H
#ifndef LV_THEME_SIMPLE_H
#define LV_THEME_SIMPLE_H
#ifdef __cplusplus
extern "C" {
@@ -16,7 +16,7 @@ extern "C" {
#include "../lv_theme.h"
#include "../../display/lv_display.h"
#if LV_USE_THEME_BASIC
#if LV_USE_THEME_SIMPLE
/*********************
* DEFINES
@@ -35,18 +35,24 @@ extern "C" {
* @param disp pointer to display to attach the theme
* @return a pointer to reference this theme later
*/
lv_theme_t * lv_theme_basic_init(lv_display_t * disp);
lv_theme_t * lv_theme_simple_init(lv_display_t * disp);
/**
* Check if the theme is initialized
* @return true if default theme is initialized, false otherwise
*/
bool lv_theme_basic_is_inited(void);
bool lv_theme_simple_is_inited(void);
/**
* Deinitialize the basic theme
* Get simple theme
* @return a pointer to simple theme, or NULL if this is not initialized
*/
void lv_theme_basic_deinit(void);
lv_theme_t * lv_theme_simple_get(void);
/**
* Deinitialize the simple theme
*/
void lv_theme_simple_deinit(void);
/**********************
* MACROS
@@ -58,4 +64,4 @@ void lv_theme_basic_deinit(void);
} /*extern "C"*/
#endif
#endif /*LV_THEME_BASIC_H*/
#endif /*LV_THEME_SIMPLE_H*/

View File

@@ -12,7 +12,7 @@
#define LV_BUILD_EXAMPLES 1
#define LV_USE_THEME_BASIC 1
#define LV_USE_THEME_SIMPLE 1
#define LV_USE_THEME_DEFAULT 0
#define LV_USE_LODEPNG 1