样式

样式 用于设置对象的外观。LVGL 中的样式深受 CSS 的启发。其核心概念如下:

  • 样式是一个 lv_style_t 变量,可以包含属性,例如边框宽度、文本颜色等。它类似于 CSS 中的 class

  • 样式可以分配给对象以更改其外观。在分配时,可以指定目标部分(CSS 中的 伪元素)和目标状态(伪类)。 例如,可以将 style_blue 添加到滑块的旋钮上,当其处于按下状态时生效。

  • 同一个样式可以被任意数量的对象使用。

  • 样式可以级联,这意味着可以为一个对象分配多个样式,每个样式可以具有不同的属性。 因此,不需要在一个样式中指定所有属性。LVGL 会搜索属性,直到某个样式定义了它,或者如果没有样式指定该属性,则使用默认值。 例如,style_btn 可以生成一个默认的灰色按钮,而 style_btn_red 仅添加 background-color=red 来覆盖背景颜色。

  • 最近添加的样式具有更高的优先级。这意味着如果一个属性在两个样式中都被指定,则对象中最新的样式将被使用。

  • 某些属性(例如文本颜色)可以从父对象继承,如果在对象中未指定。

  • 对象还可以具有本地样式,其优先级高于“普通”样式。

  • 与 CSS 不同(伪类描述不同的状态,例如 :focus),在 LVGL 中,属性是分配给给定状态的。

  • 当对象更改状态时,可以应用过渡效果。

状态

对象可以处于以下状态的组合中:

  • LV_STATE_DEFAULT (0x0000) 正常,释放状态

  • LV_STATE_CHECKED (0x0001) 切换或选中状态

  • LV_STATE_FOCUSED (0x0002) 通过键盘或编码器聚焦,或通过触摸板/鼠标点击

  • LV_STATE_FOCUS_KEY (0x0004) 通过键盘或编码器聚焦,但不是通过触摸板/鼠标

  • LV_STATE_EDITED (0x0008) 通过编码器编辑

  • LV_STATE_HOVERED (0x0010) 被鼠标悬停(目前不支持)

  • LV_STATE_PRESSED (0x0020) 被按下

  • LV_STATE_SCROLLED (0x0040) 被滚动

  • LV_STATE_DISABLED (0x0080) 禁用状态

  • LV_STATE_USER_1 (0x1000) 自定义状态

  • LV_STATE_USER_2 (0x2000) 自定义状态

  • LV_STATE_USER_3 (0x4000) 自定义状态

  • LV_STATE_USER_4 (0x8000) 自定义状态

一个对象可以同时处于多个状态的组合中,例如同时被聚焦和按下。这表示为 LV_STATE_FOCUSED | LV_STATE_PRESSED

可以将样式添加到任何状态或状态组合中。 例如,为默认状态和按下状态设置不同的背景颜色。 如果在某个状态中未定义属性,则将使用最匹配状态的属性。通常,这意味着使用 LV_STATE_DEFAULT 的属性。 如果即使在默认状态下也未设置属性,则将使用默认值。(稍后详述)

但“最匹配状态的属性”到底是什么意思? 状态具有优先级,其值由其值(见上表)表示。值越高,优先级越高。 为了确定使用哪个状态的属性,让我们举个例子。假设背景颜色定义如下:

  • LV_STATE_DEFAULT:白色

  • LV_STATE_PRESSED:灰色

  • LV_STATE_FOCUSED:红色

  1. 最初,对象处于默认状态,因此这是一个简单的情况:属性在对象的当前状态中完美定义为白色。

  2. 当对象被按下时,有两个相关属性:默认的白色(默认与每个状态相关)和按下的灰色。 按下状态的优先级为 0x0020,高于默认状态的优先级 0x0000,因此将使用灰色。

  3. 当对象被聚焦时,与按下状态相同,红色将被使用。(聚焦状态的优先级高于默认状态)。

  4. 当对象被聚焦并按下时,灰色和红色都可以使用,但按下状态的优先级高于聚焦状态,因此将使用灰色。

  5. 可以为 LV_STATE_PRESSED | LV_STATE_FOCUSED 设置玫瑰色。 在这种情况下,此组合状态的优先级为 0x0020 + 0x0002 = 0x0022,高于按下状态的优先级,因此将使用玫瑰色。

  6. 当对象处于选中状态时,没有属性为此状态设置背景颜色。因此,由于没有更好的选择,对象将保持默认状态的白色。

一些实用的注意事项:

  • 状态的优先级(值)非常直观,这是用户自然期望的。例如,如果一个对象被聚焦,用户仍然希望看到它是否被按下,因此按下状态具有更高的优先级。 如果聚焦状态具有更高的优先级,它将覆盖按下颜色。

  • 如果要为所有状态设置属性(例如红色背景颜色),只需为默认状态设置即可。如果对象无法为其当前状态找到属性,它将回退到默认状态的属性。

  • 使用 OR 运算符组合状态来描述复杂情况的属性。(例如,按下 + 选中 + 聚焦)

  • 为不同的状态使用不同的样式元素可能是个好主意。 例如,为释放、按下、选中 + 按下、聚焦、聚焦 + 按下、聚焦 + 按下 + 选中等状态找到背景颜色是相当困难的。 相反,例如,可以为按下和选中状态使用背景颜色,并使用不同的边框颜色指示聚焦状态。

样式级联

不需要在一个样式中设置所有属性。可以向一个对象添加更多样式,并让后添加的样式修改或扩展外观。 例如,创建一个通用的灰色按钮样式,并为红色按钮创建一个新样式,其中仅设置新的背景颜色。

这类似于在 CSS 中使用类时列出类,例如 <div class=".btn .btn-red">

后添加的样式优先于先设置的样式。因此,在上述灰色/红色按钮示例中,普通按钮样式应首先添加,红色样式应其次添加。 然而,状态的优先级仍然会被考虑。 让我们来看看以下情况:

  • 基本按钮样式为默认状态定义了深灰色,为按下状态定义了浅灰色

  • 红色按钮样式仅在默认状态下定义了背景颜色为红色

在这种情况下,当按钮被释放(处于默认状态)时,它将是红色的,因为在最近添加的样式(红色)中找到了完美匹配。 当按钮被按下时,浅灰色是更好的匹配,因为它完美描述了当前状态,因此按钮将是浅灰色。

继承

某些属性(通常是与文本相关的属性)可以从父对象的样式中继承。 仅当对象的样式中未设置给定属性时(即使在默认状态下)才会应用继承。 在这种情况下,如果属性是可继承的,将在父对象中搜索该属性的值,直到某个对象为该属性指定一个值。父对象将使用其自己的状态来确定值。 因此,如果一个按钮被按下,并且文本颜色来自这里,将使用按下的文本颜色。

强制值继承/默认值

有时您可能希望强制子对象使用父对象的值作为给定样式属性的值。为此,您可以使用以下方法之一(取决于您使用的样式类型):

/* 常规样式 */
lv_style_set_prop_meta(&style, LV_STYLE_TEXT_COLOR, LV_STYLE_PROP_META_INHERIT);
/* 本地样式 */
lv_obj_set_local_style_prop_meta(child, LV_STYLE_TEXT_COLOR, LV_STYLE_PROP_META_INHERIT, LV_PART_MAIN);

这就像在样式上设置了一个值,因此之后设置属性的值将移除该标志。

您可能还希望强制使用属性的默认值,而无需在应用程序中硬编码。 为此,您可以使用相同的 API,但使用 LV_STYLE_PROP_META_INITIAL。在 LVGL 的未来版本中,这将基于当前主题使用值,但目前它只选择无论主题如何的内部默认值。

部件

对象可以由 部件 组成,每个部件可以有自己的样式。

LVGL 中存在以下预定义部件:

  • LV_PART_MAIN 类似于背景的矩形

  • LV_PART_SCROLLBAR 滚动条

  • LV_PART_INDICATOR 指示器,例如滑块、进度条、开关的指示器,或复选框的勾选框

  • LV_PART_KNOB 类似于用于调整值的手柄

  • LV_PART_SELECTED 指示当前选中的选项或部分

  • LV_PART_ITEMS 如果小部件有多个相似的元素(例如表格单元格)使用

  • LV_PART_TICKS 刻度,例如图表或仪表的刻度

  • LV_PART_CURSOR 标记特定位置,例如文本区域或图表的光标

  • LV_PART_CUSTOM_FIRST 自定义部件标识符可以从这里开始添加。

例如,一个 滑块 有三个部件:

  • 背景

  • 指示器

  • 旋钮

这意味着滑块的所有三个部件都可以有自己的样式。稍后将介绍如何将样式添加到对象和部件。

初始化样式并设置/获取属性

样式存储在 lv_style_t 变量中。样式变量应为 static、全局或动态分配。 换句话说,它们不能是函数中的局部变量,因为函数退出时会销毁它们。 在使用样式之前,应使用 lv_style_init(&my_style) 初始化样式。 初始化样式后,可以添加或更改属性。

属性设置函数如下所示:lv_style_set_<property_name>(&style, <value>); 例如:

static lv_style_t style_btn;
lv_style_init(&style_btn);
lv_style_set_bg_color(&style_btn, lv_color_hex(0x115588));
lv_style_set_bg_opa(&style_btn, LV_OPA_50);
lv_style_set_border_width(&style_btn, 2);
lv_style_set_border_color(&style_btn, lv_color_black());

static lv_style_t style_btn_red;
lv_style_init(&style_btn_red);
lv_style_set_bg_color(&style_btn_red, lv_plaette_main(LV_PALETTE_RED));
lv_style_set_bg_opa(&style_btn_red, LV_OPA_COVER);

要移除属性,请使用:

lv_style_remove_prop(&style, LV_STYLE_BG_COLOR);

要从样式中获取属性的值:

lv_style_value_t v;
lv_res_t res = lv_style_get_prop(&style, LV_STYLE_BG_COLOR, &v);
if(res == LV_RES_OK) {	/*找到*/
	do_something(v.color);
}

lv_style_value_t 有三个字段:

  • num 用于整数、布尔值和不透明度属性

  • color 用于颜色属性

  • ptr 用于指针属性

要重置样式(释放其所有数据),请使用:

lv_style_reset(&style);

样式也可以构建为 const 以节省 RAM:

const lv_style_const_prop_t style1_props[] = {
   LV_STYLE_CONST_WIDTH(50),
   LV_STYLE_CONST_HEIGHT(50),
   LV_STYLE_PROP_INV,
};

LV_STYLE_CONST_INIT(style1, style1_props);

稍后,const 样式可以像任何其他样式一样使用,但(显然)不能添加新属性。

向小部件添加和移除样式

单独的样式并没有多大用处。它必须分配给对象才能生效。

添加样式

要向对象添加样式,请使用 lv_obj_add_style(obj, &style, <selector>)<selector> 是部件和状态的 OR 值,样式应添加到这些部件和状态。例如:

  • LV_PART_MAIN | LV_STATE_DEFAULT

  • LV_STATE_PRESSED:按下状态的主部件。可以省略 LV_PART_MAIN

  • LV_PART_SCROLLBAR:默认状态的滚动条部件。可以省略 LV_STATE_DEFAULT

  • LV_PART_SCROLLBAR | LV_STATE_SCROLLED:对象被滚动时的滚动条部件

  • 0LV_PART_MAIN | LV_STATE_DEFAULT 相同。

  • LV_PART_INDICATOR | LV_STATE_PRESSED | LV_STATE_CHECKED:对象同时被按下和选中时的指示器部件。

使用 lv_obj_add_style

lv_obj_add_style(btn, &style_btn, 0);      				  /*默认按钮样式*/
lv_obj_add_style(btn, &btn_red, LV_STATE_PRESSED);  /*仅在按下时将某些颜色覆盖为红色*/

移除样式

要从对象中移除所有样式,请使用 lv_obj_remove_style_all(obj)

要移除特定样式,请使用 lv_obj_remove_style(obj, style, selector)。此函数仅在 selectorlv_obj_add_style 中使用的 selector 匹配时移除 stylestyle 可以为 NULL,以仅检查 selector 并移除所有匹配的样式。selector 可以使用 LV_STATE_ANYLV_PART_ANY 值,从任何状态或部件中移除样式。

报告样式更改

如果已分配给对象的样式发生更改(即添加或更改了属性),则应通知使用该样式的对象。有三种选项可以执行此操作:

  1. 如果您知道更改的属性可以通过简单的重绘应用(例如颜色或不透明度更改),只需调用 lv_obj_invalidate(obj)lv_obj_invalidate(lv_scr_act())

  2. 如果更复杂的样式属性发生更改或添加,并且您知道哪些对象受该样式影响,请调用 lv_obj_refresh_style(obj, part, property)。 要刷新所有部件和属性,请使用 lv_obj_refresh_style(obj, LV_PART_ANY, LV_STYLE_PROP_ANY)

  3. 要使 LVGL 检查所有对象以查看它们是否使用样式并在需要时刷新它们,请调用 lv_obj_report_style_change(&style)。如果 styleNULL,则所有对象都将收到样式更改的通知。

获取对象上的属性值

要获取属性的最终值 - 考虑级联、继承、本地样式和过渡(见下文) - 可以使用如下的属性获取函数: lv_obj_get_style_<property_name>(obj, <part>)。 这些函数使用对象的当前状态,如果没有更好的候选项,则返回默认值。   例如:

lv_color_t color = lv_obj_get_style_bg_color(btn, LV_PART_MAIN);

本地样式

除了“普通”样式,对象还可以存储本地样式。此概念类似于 CSS 中的内联样式(例如 <div style="color:red">),但有所修改。

本地样式类似于普通样式,但不能在其他对象之间共享。如果使用,本地样式会自动分配,并在对象删除时释放。 它们对于向对象添加本地自定义非常有用。

与 CSS 不同,LVGL 本地样式可以分配给状态(伪类)和部件(伪元素)。

要设置本地属性,请使用类似 lv_obj_set_style_<property_name>(obj, <value>, <selector>); 的函数   例如:

lv_obj_set_style_bg_color(slider, lv_color_red(), LV_PART_INDICATOR | LV_STATE_FOCUSED);

属性

有关样式属性的完整列表,请点击此处

典型背景属性

在小部件的文档中,您会看到诸如“该小部件使用典型的背景属性”之类的句子。这些“典型背景属性”是与以下内容相关的属性:

  • 背景

  • 边框

  • 轮廓

  • 阴影

  • 内边距

  • 宽度和高度变换

  • X 和 Y 平移

过渡

默认情况下,当对象更改状态(例如被按下)时,新状态的新属性会立即设置。然而,通过过渡,可以在状态更改时播放动画。 例如,按下按钮时,其背景颜色可以在 300 毫秒内动画到按下颜色。

过渡的参数存储在样式中。可以设置

  • 过渡时间

  • 开始过渡前的延迟

  • 动画路径(也称为时间或缓动函数)

  • 要动画的属性

过渡属性可以为每个状态定义。例如,在默认状态下设置 500 毫秒的过渡时间意味着当对象进入默认状态时,将应用 500 毫秒的过渡时间。 在按下状态下设置 100 毫秒的过渡时间会导致进入按下状态时的 100 毫秒过渡。 此示例配置导致快速进入按下状态,然后缓慢返回默认状态。

要描述过渡,需要初始化一个 lv_transition_dsc_t 变量并将其添加到样式中:

/* 仅保存其指针,因此必须是静态、全局或动态分配 */
static const lv_style_prop_t trans_props[] = {
											LV_STYLE_BG_OPA, LV_STYLE_BG_COLOR,
											0, /*结束标记*/
};

static lv_style_transition_dsc_t trans1;
lv_style_transition_dsc_init(&trans1, trans_props, lv_anim_path_ease_out, duration_ms, delay_ms);

lv_style_set_transition(&style1, &trans1);

不透明度、混合模式和变换

如果将 opablend_modetransform_angletransform_zoom 属性设置为其非默认值,LVGL 会为小部件及其所有子项创建一个快照,以便使用设置的不透明度、混合模式和变换属性混合整个小部件。

这些属性仅对小部件的 MAIN 部件产生此效果。

创建的快照称为“中间层”或简称为“层”。如果仅将 opa 和/或 blend_mode 设置为非默认值,LVGL 可以从较小的块构建层。这些块的大小可以通过 lv_conf.h 中的以下属性进行配置:

  • LV_LAYER_SIMPLE_BUF_SIZE:[字节] 最佳目标缓冲区大小。LVGL 将尝试分配此大小的内存。

  • LV_LAYER_SIMPLE_FALLBACK_BUF_SIZE:[字节] 如果无法分配 LV_LAYER_SIMPLE_BUF_SIZE,则使用。

如果还使用了变换属性,则无法分块渲染层,而是需要分配一个更大的内存。所需的内存取决于角度、缩放和枢轴参数以及需要重绘的区域的大小,但从不大于小部件的大小(包括用于阴影、轮廓等的额外绘制大小)。

如果小部件可以完全覆盖需要重绘的区域,LVGL 会创建一个 RGB 层(渲染速度更快且使用更少的内存)。如果相反的情况需要使用 ARGB 渲染。如果小部件具有半径、bg_opa != 255、阴影、轮廓等,则可能无法覆盖其区域。

小部件的点击区域也会相应地进行变换。

颜色过滤器

TODO

主题

主题是样式的集合。如果有一个活动的主题,LVGL 会将其应用于每个创建的小部件。 这将为 UI 提供默认外观,然后可以通过添加更多样式进行修改。

每个显示器可以有不同的主题。例如,您可以在 TFT 上使用彩色主题,在辅助单色显示器上使用单色主题。

要为显示器设置主题,需要两个步骤:

  1. 初始化主题

  2. 将初始化的主题分配给显示器。

主题初始化函数可以具有不同的原型。此示例显示如何设置“默认”主题:

lv_theme_t * th = lv_theme_default_init(display,  /*使用此显示器的 DPI、大小等*/
                                        LV_COLOR_PALETTE_BLUE, LV_COLOR_PALETTE_CYAN,   /*主调色板和次调色板*/
                                        false,    /*浅色或深色模式*/
                                        &lv_font_montserrat_10, &lv_font_montserrat_14, &lv_font_montserrat_18); /*小号、普通、大号字体*/

lv_disp_set_theme(display, th); /*将主题分配给显示器*/

包含的主题在 lv_conf.h 中启用。如果通过 LV_USE_THEME_DEFAULT 1 启用默认主题,则 LVGL 会在创建显示器时自动初始化并设置它。

扩展主题

内置主题可以扩展。 如果创建了自定义主题,可以选择一个父主题。父主题的样式将在自定义主题的样式之前添加。 可以通过这种方式链接任意数量的主题。例如,默认主题 -> 自定义主题 -> 深色主题。

lv_theme_set_parent(new_theme, base_theme) 使用 new_theme 扩展 base_theme

下面有一个示例。

示例

尺寸样式

C code  

 GitHub
#include "../lv_examples.h"
#if LV_BUILD_EXAMPLES && LV_USE_IMG

/**
 * Using the Size, Position and Padding style properties
 */
void lv_example_style_1(void)
{
    static lv_style_t style;
    lv_style_init(&style);
    lv_style_set_radius(&style, 5);

    /*Make a gradient*/
    lv_style_set_width(&style, 150);
    lv_style_set_height(&style, LV_SIZE_CONTENT);

    lv_style_set_pad_ver(&style, 20);
    lv_style_set_pad_left(&style, 5);

    lv_style_set_x(&style, lv_pct(50));
    lv_style_set_y(&style, 80);

    /*Create an object with the new style*/
    lv_obj_t * obj = lv_obj_create(lv_scr_act());
    lv_obj_add_style(obj, &style, 0);

    lv_obj_t * label = lv_label_create(obj);
    lv_label_set_text(label, "Hello");
}

#endif

MicroPython code  

 GitHub Simulator
#
# Using the Size, Position and Padding style properties
#
style = lv.style_t()
style.init()
style.set_radius(5)

# Make a gradient
style.set_width(150)
style.set_height(lv.SIZE.CONTENT)

style.set_pad_ver(20)
style.set_pad_left(5)

style.set_x(lv.pct(50))
style.set_y(80)

# Create an object with the new style
obj = lv.obj(lv.scr_act())
obj.add_style(style, 0)

label = lv.label(obj)
label.set_text("Hello")


背景样式

C code  

 GitHub
#include "../lv_examples.h"
#if LV_BUILD_EXAMPLES

/**
 * Using the background style properties
 */
void lv_example_style_2(void)
{
    static lv_style_t style;
    lv_style_init(&style);
    lv_style_set_radius(&style, 5);

    /*Make a gradient*/
    lv_style_set_bg_opa(&style, LV_OPA_COVER);
    static lv_grad_dsc_t grad;
    grad.dir = LV_GRAD_DIR_VER;
    grad.stops_count = 2;
    grad.stops[0].color = lv_palette_lighten(LV_PALETTE_GREY, 1);
    grad.stops[1].color = lv_palette_main(LV_PALETTE_BLUE);

    /*Shift the gradient to the bottom*/
    grad.stops[0].frac  = 128;
    grad.stops[1].frac  = 192;

    lv_style_set_bg_grad(&style, &grad);

    /*Create an object with the new style*/
    lv_obj_t * obj = lv_obj_create(lv_scr_act());
    lv_obj_add_style(obj, &style, 0);
    lv_obj_center(obj);
}

#endif

MicroPython code  

 GitHub Simulator
#
# Using the background style properties
#
style = lv.style_t()
style.init()
style.set_radius(5)

# Make a gradient
style.set_bg_opa(lv.OPA.COVER)
style.set_bg_color(lv.palette_lighten(lv.PALETTE.GREY, 1))
style.set_bg_grad_color(lv.palette_main(lv.PALETTE.BLUE))
style.set_bg_grad_dir(lv.GRAD_DIR.VER)

# Shift the gradient to the bottom
style.set_bg_main_stop(128)
style.set_bg_grad_stop(192)

# Create an object with the new style
obj = lv.obj(lv.scr_act())
obj.add_style(style, 0)
obj.center()

边框样式

C code  

 GitHub
#include "../lv_examples.h"
#if LV_BUILD_EXAMPLES

/**
 * Using the border style properties
 */
void lv_example_style_3(void)
{
    static lv_style_t style;
    lv_style_init(&style);

    /*Set a background color and a radius*/
    lv_style_set_radius(&style, 10);
    lv_style_set_bg_opa(&style, LV_OPA_COVER);
    lv_style_set_bg_color(&style, lv_palette_lighten(LV_PALETTE_GREY, 1));

    /*Add border to the bottom+right*/
    lv_style_set_border_color(&style, lv_palette_main(LV_PALETTE_BLUE));
    lv_style_set_border_width(&style, 5);
    lv_style_set_border_opa(&style, LV_OPA_50);
    lv_style_set_border_side(&style, LV_BORDER_SIDE_BOTTOM | LV_BORDER_SIDE_RIGHT);

    /*Create an object with the new style*/
    lv_obj_t * obj = lv_obj_create(lv_scr_act());
    lv_obj_add_style(obj, &style, 0);
    lv_obj_center(obj);
}

#endif

MicroPython code  

 GitHub Simulator
#
# Using the border style properties
#
style = lv.style_t()
style.init()

# Set a background color and a radius
style.set_radius(10)
style.set_bg_opa(lv.OPA.COVER)
style.set_bg_color(lv.palette_lighten(lv.PALETTE.GREY, 1))

# Add border to the bottom+right
style.set_border_color(lv.palette_main(lv.PALETTE.BLUE))
style.set_border_width(5)
style.set_border_opa(lv.OPA._50)
style.set_border_side(lv.BORDER_SIDE.BOTTOM | lv.BORDER_SIDE.RIGHT)

# Create an object with the new style
obj = lv.obj(lv.scr_act())
obj.add_style(style, 0)
obj.center()

轮廓样式

C code  

 GitHub
#include "../lv_examples.h"
#if LV_BUILD_EXAMPLES

/**
 * Using the outline style properties
 */
void lv_example_style_4(void)
{
    static lv_style_t style;
    lv_style_init(&style);

    /*Set a background color and a radius*/
    lv_style_set_radius(&style, 5);
    lv_style_set_bg_opa(&style, LV_OPA_COVER);
    lv_style_set_bg_color(&style, lv_palette_lighten(LV_PALETTE_GREY, 1));

    /*Add outline*/
    lv_style_set_outline_width(&style, 2);
    lv_style_set_outline_color(&style, lv_palette_main(LV_PALETTE_BLUE));
    lv_style_set_outline_pad(&style, 8);

    /*Create an object with the new style*/
    lv_obj_t * obj = lv_obj_create(lv_scr_act());
    lv_obj_add_style(obj, &style, 0);
    lv_obj_center(obj);
}

#endif

MicroPython code  

 GitHub Simulator
#
# Using the outline style properties
#

style = lv.style_t()
style.init()

# Set a background color and a radius
style.set_radius(5)
style.set_bg_opa(lv.OPA.COVER)
style.set_bg_color(lv.palette_lighten(lv.PALETTE.GREY, 1))

# Add outline
style.set_outline_width(2)
style.set_outline_color(lv.palette_main(lv.PALETTE.BLUE))
style.set_outline_pad(8)

# Create an object with the new style
obj = lv.obj(lv.scr_act())
obj.add_style(style, 0)
obj.center()

阴影样式

C code  

 GitHub
#include "../lv_examples.h"
#if LV_BUILD_EXAMPLES

/**
 * Using the Shadow style properties
 */
void lv_example_style_5(void)
{
    static lv_style_t style;
    lv_style_init(&style);

    /*Set a background color and a radius*/
    lv_style_set_radius(&style, 5);
    lv_style_set_bg_opa(&style, LV_OPA_COVER);
    lv_style_set_bg_color(&style, lv_palette_lighten(LV_PALETTE_GREY, 1));

    /*Add a shadow*/
    lv_style_set_shadow_width(&style, 55);
    lv_style_set_shadow_color(&style, lv_palette_main(LV_PALETTE_BLUE));
    //    lv_style_set_shadow_ofs_x(&style, 10);
    //    lv_style_set_shadow_ofs_y(&style, 20);

    /*Create an object with the new style*/
    lv_obj_t * obj = lv_obj_create(lv_scr_act());
    lv_obj_add_style(obj, &style, 0);
    lv_obj_center(obj);
}

#endif

MicroPython code  

 GitHub Simulator
#
# Using the Shadow style properties
#

style = lv.style_t()
style.init()

# Set a background color and a radius
style.set_radius(5)
style.set_bg_opa(lv.OPA.COVER)
style.set_bg_color(lv.palette_lighten(lv.PALETTE.GREY, 1))

# Add a shadow
style.set_shadow_width(8)
style.set_shadow_color(lv.palette_main(lv.PALETTE.BLUE))
style.set_shadow_ofs_x(10)
style.set_shadow_ofs_y(20)

# Create an object with the new style
obj = lv.obj(lv.scr_act())
obj.add_style(style, 0)
obj.center()

图像样式

C code  

 GitHub
#include "../lv_examples.h"
#if LV_BUILD_EXAMPLES && LV_USE_IMG

/**
 * Using the Image style properties
 */
void lv_example_style_6(void)
{
    static lv_style_t style;
    lv_style_init(&style);

    /*Set a background color and a radius*/
    lv_style_set_radius(&style, 5);
    lv_style_set_bg_opa(&style, LV_OPA_COVER);
    lv_style_set_bg_color(&style, lv_palette_lighten(LV_PALETTE_GREY, 3));
    lv_style_set_border_width(&style, 2);
    lv_style_set_border_color(&style, lv_palette_main(LV_PALETTE_BLUE));

    lv_style_set_img_recolor(&style, lv_palette_main(LV_PALETTE_BLUE));
    lv_style_set_img_recolor_opa(&style, LV_OPA_50);
    lv_style_set_transform_angle(&style, 300);

    /*Create an object with the new style*/
    lv_obj_t * obj = lv_img_create(lv_scr_act());
    lv_obj_add_style(obj, &style, 0);

    LV_IMG_DECLARE(img_cogwheel_argb);
    lv_img_set_src(obj, &img_cogwheel_argb);

    lv_obj_center(obj);
}

#endif

MicroPython code  

 GitHub Simulator
from imagetools import get_png_info, open_png
# Register PNG image decoder
decoder = lv.img.decoder_create()
decoder.info_cb = get_png_info
decoder.open_cb = open_png

# Create an image from the png file
try:
    with open('../assets/img_cogwheel_argb.png', 'rb') as f:
        png_data = f.read()
except:
    print("Could not find img_cogwheel_argb.png")
    sys.exit()

img_cogwheel_argb = lv.img_dsc_t({
  'data_size': len(png_data),
  'data': png_data
})

#
# Using the Image style properties
#
style = lv.style_t()
style.init()

# Set a background color and a radius
style.set_radius(5)
style.set_bg_opa(lv.OPA.COVER)
style.set_bg_color(lv.palette_lighten(lv.PALETTE.GREY, 3))
style.set_border_width(2)
style.set_border_color(lv.palette_main(lv.PALETTE.BLUE))

style.set_img_recolor(lv.palette_main(lv.PALETTE.BLUE))
style.set_img_recolor_opa(lv.OPA._50)
# style.set_transform_angle(300)

# Create an object with the new style
obj = lv.img(lv.scr_act())
obj.add_style(style, 0)

obj.set_src(img_cogwheel_argb)

obj.center()

弧形样式

C code  

 GitHub
Error encountered while trying to open D:\lv_port_pc_eclipse-release-v8.3\lvgl\examples\style\lv_example_style_7.c

MicroPython code  

 GitHub Simulator
Error encountered while trying to open D:\lv_port_pc_eclipse-release-v8.3\lvgl\examples\style\lv_example_style_7.py

文本样式

C code  

 GitHub
#include "../lv_examples.h"
#if LV_BUILD_EXAMPLES && LV_USE_LABEL

/**
 * Using the text style properties
 */
void lv_example_style_8(void)
{
    static lv_style_t style;
    lv_style_init(&style);

    lv_style_set_radius(&style, 5);
    lv_style_set_bg_opa(&style, LV_OPA_COVER);
    lv_style_set_bg_color(&style, lv_palette_lighten(LV_PALETTE_GREY, 2));
    lv_style_set_border_width(&style, 2);
    lv_style_set_border_color(&style, lv_palette_main(LV_PALETTE_BLUE));
    lv_style_set_pad_all(&style, 10);

    lv_style_set_text_color(&style, lv_palette_main(LV_PALETTE_BLUE));
    lv_style_set_text_letter_space(&style, 5);
    lv_style_set_text_line_space(&style, 20);
    lv_style_set_text_decor(&style, LV_TEXT_DECOR_UNDERLINE);

    /*Create an object with the new style*/
    lv_obj_t * obj = lv_label_create(lv_scr_act());
    lv_obj_add_style(obj, &style, 0);
    lv_label_set_text(obj, "Text of\n"
                      "a label");

    lv_obj_center(obj);
}

#endif

MicroPython code  

 GitHub Simulator
#
# Using the text style properties
#

style = lv.style_t()
style.init()

style.set_radius(5)
style.set_bg_opa(lv.OPA.COVER)
style.set_bg_color(lv.palette_lighten(lv.PALETTE.GREY, 3))
style.set_border_width(2)
style.set_border_color(lv.palette_main(lv.PALETTE.BLUE))
style.set_pad_all(10)

style.set_text_color(lv.palette_main(lv.PALETTE.BLUE))
style.set_text_letter_space(5)
style.set_text_line_space(20)
style.set_text_decor(lv.TEXT_DECOR.UNDERLINE)

# Create an object with the new style
obj = lv.label(lv.scr_act())
obj.add_style(style, 0)
obj.set_text("Text of\n"
             "a label")

obj.center()


线条样式

C code  

 GitHub
#include "../lv_examples.h"
#if LV_BUILD_EXAMPLES && LV_USE_LINE

/**
 * Using the line style properties
 */
void lv_example_style_9(void)
{
    static lv_style_t style;
    lv_style_init(&style);

    lv_style_set_line_color(&style, lv_palette_main(LV_PALETTE_GREY));
    lv_style_set_line_width(&style, 6);
    lv_style_set_line_rounded(&style, true);

    /*Create an object with the new style*/
    lv_obj_t * obj = lv_line_create(lv_scr_act());
    lv_obj_add_style(obj, &style, 0);

    static lv_point_t p[] = {{10, 30}, {30, 50}, {100, 0}};
    lv_line_set_points(obj, p, 3);

    lv_obj_center(obj);
}

#endif

MicroPython code  

 GitHub Simulator
#
# Using the line style properties
#

style = lv.style_t()
style.init()

style.set_line_color(lv.palette_main(lv.PALETTE.GREY))
style.set_line_width(6)
style.set_line_rounded(True)

# Create an object with the new style
obj = lv.line(lv.scr_act())
obj.add_style(style, 0)
p =  [ {"x":10, "y":30},
       {"x":30, "y":50},
       {"x":100, "y":0}]

obj.set_points(p, 3)

obj.center()

过渡效果

C code  

 GitHub
#include "../lv_examples.h"
#if LV_BUILD_EXAMPLES && LV_USE_IMG

/**
 * Creating a transition
 */
void lv_example_style_10(void)
{
    static const lv_style_prop_t props[] = {LV_STYLE_BG_COLOR, LV_STYLE_BORDER_COLOR, LV_STYLE_BORDER_WIDTH, 0};

    /* A default transition
     * Make it fast (100ms) and start with some delay (200 ms)*/
    static lv_style_transition_dsc_t trans_def;
    lv_style_transition_dsc_init(&trans_def, props, lv_anim_path_linear, 100, 200, NULL);

    /* A special transition when going to pressed state
     * Make it slow (500 ms) but start  without delay*/
    static lv_style_transition_dsc_t trans_pr;
    lv_style_transition_dsc_init(&trans_pr, props, lv_anim_path_linear, 500, 0, NULL);

    static lv_style_t style_def;
    lv_style_init(&style_def);
    lv_style_set_transition(&style_def, &trans_def);

    static lv_style_t style_pr;
    lv_style_init(&style_pr);
    lv_style_set_bg_color(&style_pr, lv_palette_main(LV_PALETTE_RED));
    lv_style_set_border_width(&style_pr, 6);
    lv_style_set_border_color(&style_pr, lv_palette_darken(LV_PALETTE_RED, 3));
    lv_style_set_transition(&style_pr, &trans_pr);

    /*Create an object with the new style_pr*/
    lv_obj_t * obj = lv_obj_create(lv_scr_act());
    lv_obj_add_style(obj, &style_def, 0);
    lv_obj_add_style(obj, &style_pr, LV_STATE_PRESSED);

    lv_obj_center(obj);
}

#endif

MicroPython code  

 GitHub Simulator
#
# Creating a transition
#

props = [lv.STYLE.BG_COLOR, lv.STYLE.BORDER_COLOR, lv.STYLE.BORDER_WIDTH, 0]

# A default transition
# Make it fast (100ms) and start with some delay (200 ms)

trans_def = lv.style_transition_dsc_t()
trans_def.init(props, lv.anim_t.path_linear, 100, 200, None)

# A special transition when going to pressed state
# Make it slow (500 ms) but start  without delay

trans_pr = lv.style_transition_dsc_t()
trans_pr.init(props, lv.anim_t.path_linear, 500, 0, None)

style_def = lv.style_t()
style_def.init()
style_def.set_transition(trans_def)

style_pr = lv.style_t()
style_pr.init()
style_pr.set_bg_color(lv.palette_main(lv.PALETTE.RED))
style_pr.set_border_width(6)
style_pr.set_border_color(lv.palette_darken(lv.PALETTE.RED, 3))
style_pr.set_transition(trans_pr)

# Create an object with the new style_pr
obj = lv.obj(lv.scr_act())
obj.add_style(style_def, 0)
obj.add_style(style_pr, lv.STATE.PRESSED)

obj.center()

使用多个样式

C code  

 GitHub
#include "../lv_examples.h"
#if LV_BUILD_EXAMPLES && LV_USE_IMG

/**
 * Using multiple styles
 */
void lv_example_style_11(void)
{
    /*A base style*/
    static lv_style_t style_base;
    lv_style_init(&style_base);
    lv_style_set_bg_color(&style_base, lv_palette_main(LV_PALETTE_LIGHT_BLUE));
    lv_style_set_border_color(&style_base, lv_palette_darken(LV_PALETTE_LIGHT_BLUE, 3));
    lv_style_set_border_width(&style_base, 2);
    lv_style_set_radius(&style_base, 10);
    lv_style_set_shadow_width(&style_base, 10);
    lv_style_set_shadow_ofs_y(&style_base, 5);
    lv_style_set_shadow_opa(&style_base, LV_OPA_50);
    lv_style_set_text_color(&style_base, lv_color_white());
    lv_style_set_width(&style_base, 100);
    lv_style_set_height(&style_base, LV_SIZE_CONTENT);

    /*Set only the properties that should be different*/
    static lv_style_t style_warning;
    lv_style_init(&style_warning);
    lv_style_set_bg_color(&style_warning, lv_palette_main(LV_PALETTE_YELLOW));
    lv_style_set_border_color(&style_warning, lv_palette_darken(LV_PALETTE_YELLOW, 3));
    lv_style_set_text_color(&style_warning, lv_palette_darken(LV_PALETTE_YELLOW, 4));

    /*Create an object with the base style only*/
    lv_obj_t * obj_base = lv_obj_create(lv_scr_act());
    lv_obj_add_style(obj_base, &style_base, 0);
    lv_obj_align(obj_base, LV_ALIGN_LEFT_MID, 20, 0);

    lv_obj_t * label = lv_label_create(obj_base);
    lv_label_set_text(label, "Base");
    lv_obj_center(label);

    /*Create another object with the base style and earnings style too*/
    lv_obj_t * obj_warning = lv_obj_create(lv_scr_act());
    lv_obj_add_style(obj_warning, &style_base, 0);
    lv_obj_add_style(obj_warning, &style_warning, 0);
    lv_obj_align(obj_warning, LV_ALIGN_RIGHT_MID, -20, 0);

    label = lv_label_create(obj_warning);
    lv_label_set_text(label, "Warning");
    lv_obj_center(label);
}

#endif

MicroPython code  

 GitHub Simulator
#
# Using multiple styles
#
# A base style

style_base = lv.style_t()
style_base.init()
style_base.set_bg_color(lv.palette_main(lv.PALETTE.LIGHT_BLUE))
style_base.set_border_color(lv.palette_darken(lv.PALETTE.LIGHT_BLUE, 3))
style_base.set_border_width(2)
style_base.set_radius(10)
style_base.set_shadow_width(10)
style_base.set_shadow_ofs_y(5)
style_base.set_shadow_opa(lv.OPA._50)
style_base.set_text_color(lv.color_white())
style_base.set_width(100)
style_base.set_height(lv.SIZE.CONTENT)

# Set only the properties that should be different
style_warning = lv.style_t()
style_warning.init()
style_warning.set_bg_color(lv.palette_main(lv.PALETTE.YELLOW))
style_warning.set_border_color(lv.palette_darken(lv.PALETTE.YELLOW, 3))
style_warning.set_text_color(lv.palette_darken(lv.PALETTE.YELLOW, 4))

# Create an object with the base style only
obj_base = lv.obj(lv.scr_act())
obj_base.add_style(style_base, 0)
obj_base.align(lv.ALIGN.LEFT_MID, 20, 0)

label = lv.label(obj_base)
label.set_text("Base")
label.center()

# Create another object with the base style and earnings style too
obj_warning = lv.obj(lv.scr_act())
obj_warning.add_style(style_base, 0)
obj_warning.add_style(style_warning, 0)
obj_warning.align(lv.ALIGN.RIGHT_MID, -20, 0)

label = lv.label(obj_warning)
label.set_text("Warning")
label.center()

局部样式

C code  

 GitHub
#include "../lv_examples.h"
#if LV_BUILD_EXAMPLES && LV_USE_IMG

/**
 * Local styles
 */
void lv_example_style_12(void)
{
    static lv_style_t style;
    lv_style_init(&style);
    lv_style_set_bg_color(&style, lv_palette_main(LV_PALETTE_GREEN));
    lv_style_set_border_color(&style, lv_palette_lighten(LV_PALETTE_GREEN, 3));
    lv_style_set_border_width(&style, 3);

    lv_obj_t * obj = lv_obj_create(lv_scr_act());
    lv_obj_add_style(obj, &style, 0);

    /*Overwrite the background color locally*/
    lv_obj_set_style_bg_color(obj, lv_palette_main(LV_PALETTE_ORANGE), LV_PART_MAIN);

    lv_obj_center(obj);
}

#endif

MicroPython code  

 GitHub Simulator
#
# Local styles
#

style = lv.style_t()
style.init()
style.set_bg_color(lv.palette_main(lv.PALETTE.GREEN))
style.set_border_color(lv.palette_lighten(lv.PALETTE.GREEN, 3))
style.set_border_width(3)

obj = lv.obj(lv.scr_act())
obj.add_style(style, 0)

# Overwrite the background color locally
obj.set_style_bg_color(lv.palette_main(lv.PALETTE.ORANGE), lv.PART.MAIN)

obj.center()

为部件和状态添加样式

C code  

 GitHub
#include "../lv_examples.h"
#if LV_BUILD_EXAMPLES && LV_USE_IMG

/**
 * Add styles to parts and states
 */
void lv_example_style_13(void)
{
    static lv_style_t style_indic;
    lv_style_init(&style_indic);
    lv_style_set_bg_color(&style_indic, lv_palette_lighten(LV_PALETTE_RED, 3));
    lv_style_set_bg_grad_color(&style_indic, lv_palette_main(LV_PALETTE_RED));
    lv_style_set_bg_grad_dir(&style_indic, LV_GRAD_DIR_HOR);

    static lv_style_t style_indic_pr;
    lv_style_init(&style_indic_pr);
    lv_style_set_shadow_color(&style_indic_pr, lv_palette_main(LV_PALETTE_RED));
    lv_style_set_shadow_width(&style_indic_pr, 10);
    lv_style_set_shadow_spread(&style_indic_pr, 3);

    /*Create an object with the new style_pr*/
    lv_obj_t * obj = lv_slider_create(lv_scr_act());
    lv_obj_add_style(obj, &style_indic, LV_PART_INDICATOR);
    lv_obj_add_style(obj, &style_indic_pr, LV_PART_INDICATOR | LV_STATE_PRESSED);
    lv_slider_set_value(obj, 70, LV_ANIM_OFF);
    lv_obj_center(obj);
}

#endif

MicroPython code  

 GitHub Simulator
#
# Add styles to parts and states
#

style_indic = lv.style_t()
style_indic.init()
style_indic.set_bg_color(lv.palette_lighten(lv.PALETTE.RED, 3))
style_indic.set_bg_grad_color(lv.palette_main(lv.PALETTE.RED))
style_indic.set_bg_grad_dir(lv.GRAD_DIR.HOR)

style_indic_pr = lv.style_t()
style_indic_pr.init()
style_indic_pr.set_shadow_color(lv.palette_main(lv.PALETTE.RED))
style_indic_pr.set_shadow_width(10)
style_indic_pr.set_shadow_spread(3)

# Create an object with the new style_pr
obj = lv.slider(lv.scr_act())
obj.add_style(style_indic, lv.PART.INDICATOR)
obj.add_style(style_indic_pr, lv.PART.INDICATOR | lv.STATE.PRESSED)
obj.set_value(70, lv.ANIM.OFF)
obj.center()

扩展当前主题

C code  

 GitHub
#include "../lv_examples.h"
#if LV_BUILD_EXAMPLES && LV_USE_IMG


static lv_style_t style_btn;

/*Will be called when the styles of the base theme are already added
  to add new styles*/
static void new_theme_apply_cb(lv_theme_t * th, lv_obj_t * obj)
{
    LV_UNUSED(th);

    if(lv_obj_check_type(obj, &lv_btn_class)) {
        lv_obj_add_style(obj, &style_btn, 0);
    }
}

static void new_theme_init_and_set(void)
{
    /*Initialize the styles*/
    lv_style_init(&style_btn);
    lv_style_set_bg_color(&style_btn, lv_palette_main(LV_PALETTE_GREEN));
    lv_style_set_border_color(&style_btn, lv_palette_darken(LV_PALETTE_GREEN, 3));
    lv_style_set_border_width(&style_btn, 3);

    /*Initialize the new theme from the current theme*/
    lv_theme_t * th_act = lv_disp_get_theme(NULL);
    static lv_theme_t th_new;
    th_new = *th_act;

    /*Set the parent theme and the style apply callback for the new theme*/
    lv_theme_set_parent(&th_new, th_act);
    lv_theme_set_apply_cb(&th_new, new_theme_apply_cb);

    /*Assign the new theme to the current display*/
    lv_disp_set_theme(NULL, &th_new);
}



/**
 * Extending the current theme
 */
void lv_example_style_14(void)
{
    lv_obj_t * btn;
    lv_obj_t * label;

    btn = lv_btn_create(lv_scr_act());
    lv_obj_align(btn, LV_ALIGN_TOP_MID, 0, 20);

    label = lv_label_create(btn);
    lv_label_set_text(label, "Original theme");

    new_theme_init_and_set();

    btn = lv_btn_create(lv_scr_act());
    lv_obj_align(btn, LV_ALIGN_BOTTOM_MID, 0, -20);

    label = lv_label_create(btn);
    lv_label_set_text(label, "New theme");
}

#endif

MicroPython code  

 GitHub Simulator
# Will be called when the styles of the base theme are already added
# to add new styles


class NewTheme(lv.theme_t):
    def __init__(self):
        super().__init__()
        # Initialize the styles
        self.style_btn = lv.style_t()
        self.style_btn.init()
        self.style_btn.set_bg_color(lv.palette_main(lv.PALETTE.GREEN))
        self.style_btn.set_border_color(lv.palette_darken(lv.PALETTE.GREEN, 3))
        self.style_btn.set_border_width(3)

        # This theme is based on active theme
        th_act = lv.theme_get_from_obj(lv.scr_act())
        # This theme will be applied only after base theme is applied
        self.set_parent(th_act)


class ExampleStyle_14:

    def __init__(self):
        #
        # Extending the current theme
        #

        btn = lv.btn(lv.scr_act())
        btn.align(lv.ALIGN.TOP_MID, 0, 20)

        label = lv.label(btn)
        label.set_text("Original theme")

        self.new_theme_init_and_set()

        btn = lv.btn(lv.scr_act())
        btn.align(lv.ALIGN.BOTTOM_MID, 0, -20)

        label = lv.label(btn)
        label.set_text("New theme")

    def new_theme_apply_cb(self, th, obj):
        print(th,obj)
        if obj.get_class() == lv.btn_class:
            obj.add_style(self.th_new.style_btn, 0)

    def new_theme_init_and_set(self):
        print("new_theme_init_and_set")
        # Initialize the new theme from the current theme
        self.th_new = NewTheme()
        self.th_new.set_apply_cb(self.new_theme_apply_cb)
        lv.disp_get_default().set_theme(self.th_new)


exampleStyle_14 = ExampleStyle_14()

不透明度和变换

C code  

 GitHub
#include "../lv_examples.h"
#if LV_BUILD_EXAMPLES && LV_USE_BTN && LV_USE_LABEL



/**
 * Opacity and Transformations
 */
void lv_example_style_15(void)
{
    lv_obj_t * btn;
    lv_obj_t * label;

    /*Normal button*/
    btn = lv_btn_create(lv_scr_act());
    lv_obj_set_size(btn, 100, 40);
    lv_obj_align(btn, LV_ALIGN_CENTER, 0, -70);

    label = lv_label_create(btn);
    lv_label_set_text(label, "Normal");
    lv_obj_center(label);

    /*Set opacity
     *The button and the label is rendered to a layer first and that layer is blended*/
    btn = lv_btn_create(lv_scr_act());
    lv_obj_set_size(btn, 100, 40);
    lv_obj_set_style_opa(btn, LV_OPA_50, 0);
    lv_obj_align(btn, LV_ALIGN_CENTER, 0, 0);

    label = lv_label_create(btn);
    lv_label_set_text(label, "Opa:50%");
    lv_obj_center(label);

    /*Set transformations
     *The button and the label is rendered to a layer first and that layer is transformed*/
    btn = lv_btn_create(lv_scr_act());
    lv_obj_set_size(btn, 100, 40);
    lv_obj_set_style_transform_angle(btn, 150, 0);        /*15 deg*/
    lv_obj_set_style_transform_zoom(btn, 256 + 64, 0);   /*1.25x*/
    lv_obj_set_style_transform_pivot_x(btn, 50, 0);
    lv_obj_set_style_transform_pivot_y(btn, 20, 0);
    lv_obj_set_style_opa(btn, LV_OPA_50, 0);
    lv_obj_align(btn, LV_ALIGN_CENTER, 0, 70);

    label = lv_label_create(btn);
    lv_label_set_text(label, "Transf.");
    lv_obj_center(label);
}

#endif

MicroPython code  

 GitHub Simulator
Error encountered while trying to open D:\lv_port_pc_eclipse-release-v8.3\lvgl\examples\styles\lv_example_style_15.py

API

Typedefs

typedef uint8_t lv_blend_mode_t
typedef uint8_t lv_text_decor_t
typedef uint8_t lv_border_side_t
typedef uint8_t lv_grad_dir_t
typedef uint8_t lv_dither_mode_t
typedef uint8_t lv_style_res_t

Enums

Possible options how to blend opaque drawings

Values:

enumerator LV_BLEND_MODE_NORMAL

Simply mix according to the opacity value

enumerator LV_BLEND_MODE_ADDITIVE

Add the respective color channels

enumerator LV_BLEND_MODE_SUBTRACTIVE

Subtract the foreground from the background

enumerator LV_BLEND_MODE_MULTIPLY

Multiply the foreground and background

enumerator LV_BLEND_MODE_REPLACE

Replace background with foreground in the area

Some options to apply decorations on texts. 'OR'ed values can be used.

Values:

enumerator LV_TEXT_DECOR_NONE
enumerator LV_TEXT_DECOR_UNDERLINE
enumerator LV_TEXT_DECOR_STRIKETHROUGH

Selects on which sides border should be drawn 'OR'ed values can be used.

Values:

enumerator LV_BORDER_SIDE_NONE
enumerator LV_BORDER_SIDE_BOTTOM
enumerator LV_BORDER_SIDE_TOP
enumerator LV_BORDER_SIDE_LEFT
enumerator LV_BORDER_SIDE_RIGHT
enumerator LV_BORDER_SIDE_FULL
enumerator LV_BORDER_SIDE_INTERNAL

FOR matrix-like objects (e.g. Button matrix)

The direction of the gradient.

Values:

enumerator LV_GRAD_DIR_NONE

No gradient (the grad_color property is ignored)

enumerator LV_GRAD_DIR_VER

Vertical (top to bottom) gradient

enumerator LV_GRAD_DIR_HOR

Horizontal (left to right) gradient

The dithering algorithm for the gradient Depends on LV_DITHER_GRADIENT

Values:

enumerator LV_DITHER_NONE

No dithering, colors are just quantized to the output resolution

enumerator LV_DITHER_ORDERED

Ordered dithering. Faster to compute and use less memory but lower quality

enumerator LV_DITHER_ERR_DIFF

Error diffusion mode. Slower to compute and use more memory but give highest dither quality

enum lv_style_prop_t

Enumeration of all built in style properties

Props are split into groups of 16. When adding a new prop to a group, ensure it does not overflow into the next one.

Values:

enumerator LV_STYLE_PROP_INV
enumerator LV_STYLE_WIDTH
enumerator LV_STYLE_MIN_WIDTH
enumerator LV_STYLE_MAX_WIDTH
enumerator LV_STYLE_HEIGHT
enumerator LV_STYLE_MIN_HEIGHT
enumerator LV_STYLE_MAX_HEIGHT
enumerator LV_STYLE_X
enumerator LV_STYLE_Y
enumerator LV_STYLE_ALIGN
enumerator LV_STYLE_LAYOUT
enumerator LV_STYLE_RADIUS
enumerator LV_STYLE_PAD_TOP
enumerator LV_STYLE_PAD_BOTTOM
enumerator LV_STYLE_PAD_LEFT
enumerator LV_STYLE_PAD_RIGHT
enumerator LV_STYLE_PAD_ROW
enumerator LV_STYLE_PAD_COLUMN
enumerator LV_STYLE_BASE_DIR
enumerator LV_STYLE_CLIP_CORNER
enumerator LV_STYLE_BG_COLOR
enumerator LV_STYLE_BG_OPA
enumerator LV_STYLE_BG_GRAD_COLOR
enumerator LV_STYLE_BG_GRAD_DIR
enumerator LV_STYLE_BG_MAIN_STOP
enumerator LV_STYLE_BG_GRAD_STOP
enumerator LV_STYLE_BG_GRAD
enumerator LV_STYLE_BG_DITHER_MODE
enumerator LV_STYLE_BG_IMG_SRC
enumerator LV_STYLE_BG_IMG_OPA
enumerator LV_STYLE_BG_IMG_RECOLOR
enumerator LV_STYLE_BG_IMG_RECOLOR_OPA
enumerator LV_STYLE_BG_IMG_TILED
enumerator LV_STYLE_BORDER_COLOR
enumerator LV_STYLE_BORDER_OPA
enumerator LV_STYLE_BORDER_WIDTH
enumerator LV_STYLE_BORDER_SIDE
enumerator LV_STYLE_BORDER_POST
enumerator LV_STYLE_OUTLINE_WIDTH
enumerator LV_STYLE_OUTLINE_COLOR
enumerator LV_STYLE_OUTLINE_OPA
enumerator LV_STYLE_OUTLINE_PAD
enumerator LV_STYLE_SHADOW_WIDTH
enumerator LV_STYLE_SHADOW_OFS_X
enumerator LV_STYLE_SHADOW_OFS_Y
enumerator LV_STYLE_SHADOW_SPREAD
enumerator LV_STYLE_SHADOW_COLOR
enumerator LV_STYLE_SHADOW_OPA
enumerator LV_STYLE_IMG_OPA
enumerator LV_STYLE_IMG_RECOLOR
enumerator LV_STYLE_IMG_RECOLOR_OPA
enumerator LV_STYLE_LINE_WIDTH
enumerator LV_STYLE_LINE_DASH_WIDTH
enumerator LV_STYLE_LINE_DASH_GAP
enumerator LV_STYLE_LINE_ROUNDED
enumerator LV_STYLE_LINE_COLOR
enumerator LV_STYLE_LINE_OPA
enumerator LV_STYLE_ARC_WIDTH
enumerator LV_STYLE_ARC_ROUNDED
enumerator LV_STYLE_ARC_COLOR
enumerator LV_STYLE_ARC_OPA
enumerator LV_STYLE_ARC_IMG_SRC
enumerator LV_STYLE_TEXT_COLOR
enumerator LV_STYLE_TEXT_OPA
enumerator LV_STYLE_TEXT_FONT
enumerator LV_STYLE_TEXT_LETTER_SPACE
enumerator LV_STYLE_TEXT_LINE_SPACE
enumerator LV_STYLE_TEXT_DECOR
enumerator LV_STYLE_TEXT_ALIGN
enumerator LV_STYLE_OPA
enumerator LV_STYLE_COLOR_FILTER_DSC
enumerator LV_STYLE_COLOR_FILTER_OPA
enumerator LV_STYLE_ANIM
enumerator LV_STYLE_ANIM_TIME
enumerator LV_STYLE_ANIM_SPEED
enumerator LV_STYLE_TRANSITION
enumerator LV_STYLE_BLEND_MODE
enumerator LV_STYLE_TRANSFORM_WIDTH
enumerator LV_STYLE_TRANSFORM_HEIGHT
enumerator LV_STYLE_TRANSLATE_X
enumerator LV_STYLE_TRANSLATE_Y
enumerator LV_STYLE_TRANSFORM_ZOOM
enumerator LV_STYLE_TRANSFORM_ANGLE
enumerator LV_STYLE_TRANSFORM_PIVOT_X
enumerator LV_STYLE_TRANSFORM_PIVOT_Y
enumerator _LV_STYLE_LAST_BUILT_IN_PROP
enumerator _LV_STYLE_NUM_BUILT_IN_PROPS
enumerator LV_STYLE_PROP_ANY
enumerator _LV_STYLE_PROP_CONST

Values:

enumerator LV_STYLE_RES_NOT_FOUND
enumerator LV_STYLE_RES_FOUND
enumerator LV_STYLE_RES_INHERIT

Functions

LV_EXPORT_CONST_INT(LV_IMG_ZOOM_NONE)
void lv_style_init(lv_style_t *style)

Initialize a style

Note

Do not call lv_style_init on styles that already have some properties because this function won't free the used memory, just sets a default state for the style. In other words be sure to initialize styles only once!

Parameters

style -- pointer to a style to initialize

void lv_style_reset(lv_style_t *style)

Clear all properties from a style and free all allocated memories.

Parameters

style -- pointer to a style

lv_style_prop_t lv_style_register_prop(uint8_t flag)
lv_style_prop_t lv_style_get_num_custom_props(void)

Get the number of custom properties that have been registered thus far.

bool lv_style_remove_prop(lv_style_t *style, lv_style_prop_t prop)

Remove a property from a style

Parameters
  • style -- pointer to a style

  • prop -- a style property ORed with a state.

Returns

true: the property was found and removed; false: the property wasn't found

void lv_style_set_prop(lv_style_t *style, lv_style_prop_t prop, lv_style_value_t value)

Set the value of property in a style. This function shouldn't be used directly by the user. Instead use lv_style_set_<prop_name>(). E.g. lv_style_set_bg_color()

Parameters
  • style -- pointer to style

  • prop -- the ID of a property (e.g. LV_STYLE_BG_COLOR)

  • value -- lv_style_value_t variable in which a field is set according to the type of prop

void lv_style_set_prop_meta(lv_style_t *style, lv_style_prop_t prop, uint16_t meta)

Set a special meta state for a property in a style. This function shouldn't be used directly by the user.

Parameters
  • style -- pointer to style

  • prop -- the ID of a property (e.g. LV_STYLE_BG_COLOR)

  • meta -- the meta value to attach to the property in the style

lv_style_res_t lv_style_get_prop(const lv_style_t *style, lv_style_prop_t prop, lv_style_value_t *value)

Get the value of a property

Note

For performance reasons there are no sanity check on style

Parameters
  • style -- pointer to a style

  • prop -- the ID of a property

  • value -- pointer to a lv_style_value_t variable to store the value

Returns

LV_RES_INV: the property wasn't found in the style (value is unchanged) LV_RES_OK: the property was fond, and value is set accordingly

void lv_style_transition_dsc_init(lv_style_transition_dsc_t *tr, const lv_style_prop_t props[], lv_anim_path_cb_t path_cb, uint32_t time, uint32_t delay, void *user_data)
lv_style_value_t lv_style_prop_get_default(lv_style_prop_t prop)

Get the default value of a property

Parameters

prop -- the ID of a property

Returns

the default value

static inline lv_style_res_t lv_style_get_prop_inlined(const lv_style_t *style, lv_style_prop_t prop, lv_style_value_t *value)

Get the value of a property

Note

For performance reasons there are no sanity check on style

Note

This function is the same as lv_style_get_prop but inlined. Use it only on performance critical places

Parameters
  • style -- pointer to a style

  • prop -- the ID of a property

  • value -- pointer to a lv_style_value_t variable to store the value

Returns

LV_RES_INV: the property wasn't found in the style (value is unchanged) LV_RES_OK: the property was fond, and value is set accordingly

bool lv_style_is_empty(const lv_style_t *style)

Checks if a style is empty (has no properties)

Parameters

style -- pointer to a style

Returns

true if the style is empty

uint8_t _lv_style_get_prop_group(lv_style_prop_t prop)

Tell the group of a property. If the a property from a group is set in a style the (1 << group) bit of style->has_group is set. It allows early skipping the style if the property is not exists in the style at all.

Parameters

prop -- a style property

Returns

the group [0..7] 7 means all the custom properties with index > 112

uint8_t _lv_style_prop_lookup_flags(lv_style_prop_t prop)

Get the flags of a built-in or custom property.

Parameters

prop -- a style property

Returns

the flags of the property

static inline void lv_style_set_size(lv_style_t *style, lv_coord_t value)
static inline void lv_style_set_pad_all(lv_style_t *style, lv_coord_t value)
static inline void lv_style_set_pad_hor(lv_style_t *style, lv_coord_t value)
static inline void lv_style_set_pad_ver(lv_style_t *style, lv_coord_t value)
static inline void lv_style_set_pad_gap(lv_style_t *style, lv_coord_t value)
static inline bool lv_style_prop_has_flag(lv_style_prop_t prop, uint8_t flag)

Check if the style property has a specified behavioral flag.

Do not pass multiple flags to this function as backwards-compatibility is not guaranteed for that.

Parameters
  • prop -- Property ID

  • flag -- Flag

Returns

true if the flag is set for this property

struct lv_gradient_stop_t
#include <lv_style.h>

A gradient stop definition. This matches a color and a position in a virtual 0-255 scale.

Public Members

lv_color_t color

The stop color

uint8_t frac

The stop position in 1/255 unit

struct lv_grad_dsc_t
#include <lv_style.h>

A descriptor of a gradient.

Public Members

lv_gradient_stop_t stops[LV_GRADIENT_MAX_STOPS]

A gradient stop array

uint8_t stops_count

The number of used stops in the array

lv_grad_dir_t dir

The gradient direction. Any of LV_GRAD_DIR_HOR, LV_GRAD_DIR_VER, LV_GRAD_DIR_NONE

lv_dither_mode_t dither

Whether to dither the gradient or not. Any of LV_DITHER_NONE, LV_DITHER_ORDERED, LV_DITHER_ERR_DIFF

union lv_style_value_t
#include <lv_style.h>

A common type to handle all the property types in the same way.

Public Members

int32_t num

Number integer number (opacity, enums, booleans or "normal" numbers)

const void *ptr

Constant pointers (font, cone text, etc)

lv_color_t color

Colors

struct lv_style_transition_dsc_t
#include <lv_style.h>

Descriptor for style transitions

Public Members

const lv_style_prop_t *props

An array with the properties to animate.

void *user_data

A custom user data that will be passed to the animation's user_data

lv_anim_path_cb_t path_xcb

A path for the animation.

uint32_t time

Duration of the transition in [ms]

uint32_t delay

Delay before the transition in [ms]

struct lv_style_const_prop_t
#include <lv_style.h>

Descriptor of a constant style property.

Public Members

lv_style_prop_t prop
lv_style_value_t value
struct lv_style_t
#include <lv_style.h>

Descriptor of a style (a collection of properties and values).

Public Members

uint32_t sentinel
lv_style_value_t value1
uint8_t *values_and_props
const lv_style_const_prop_t *const_props
union lv_style_t v_p
uint16_t prop1
uint8_t has_group
uint8_t prop_cnt

Typedefs

typedef void (*lv_theme_apply_cb_t)(struct _lv_theme_t*, lv_obj_t*)
typedef struct _lv_theme_t lv_theme_t

Functions

lv_theme_t *lv_theme_get_from_obj(lv_obj_t *obj)

Get the theme assigned to the display of the object

Parameters

obj -- pointer to a theme object

Returns

the theme of the object's display (can be NULL)

void lv_theme_apply(lv_obj_t *obj)

Apply the active theme on an object

Parameters

obj -- pointer to an object

void lv_theme_set_parent(lv_theme_t *new_theme, lv_theme_t *parent)

Set a base theme for a theme. The styles from the base them will be added before the styles of the current theme. Arbitrary long chain of themes can be created by setting base themes.

Parameters
  • new_theme -- pointer to theme which base should be set

  • parent -- pointer to the base theme

void lv_theme_set_apply_cb(lv_theme_t *theme, lv_theme_apply_cb_t apply_cb)

Set an apply callback for a theme. The apply callback is used to add styles to different objects

Parameters
  • theme -- pointer to theme which callback should be set

  • apply_cb -- pointer to the callback

const lv_font_t *lv_theme_get_font_small(lv_obj_t *obj)

Get the small font of the theme

Parameters

obj -- pointer to an object

Returns

pointer to the font

const lv_font_t *lv_theme_get_font_normal(lv_obj_t *obj)

Get the normal font of the theme

Parameters

obj -- pointer to an object

Returns

pointer to the font

const lv_font_t *lv_theme_get_font_large(lv_obj_t *obj)

Get the subtitle font of the theme

Parameters

obj -- pointer to an object

Returns

pointer to the font

lv_color_t lv_theme_get_color_primary(lv_obj_t *obj)

Get the primary color of the theme

Parameters

obj -- pointer to an object

Returns

the color

lv_color_t lv_theme_get_color_secondary(lv_obj_t *obj)

Get the secondary color of the theme

Parameters

obj -- pointer to an object

Returns

the color

struct _lv_theme_t

Public Members

lv_theme_apply_cb_t apply_cb
struct _lv_theme_t *parent

Apply the current theme's style on top of this theme.

void *user_data
struct _lv_disp_t *disp
lv_color_t color_primary
lv_color_t color_secondary
const lv_font_t *font_small
const lv_font_t *font_normal
const lv_font_t *font_large
uint32_t flags

Functions

static inline lv_coord_t lv_obj_get_style_width(const struct _lv_obj_t *obj, uint32_t part)
static inline lv_coord_t lv_obj_get_style_min_width(const struct _lv_obj_t *obj, uint32_t part)
static inline lv_coord_t lv_obj_get_style_max_width(const struct _lv_obj_t *obj, uint32_t part)
static inline lv_coord_t lv_obj_get_style_height(const struct _lv_obj_t *obj, uint32_t part)
static inline lv_coord_t lv_obj_get_style_min_height(const struct _lv_obj_t *obj, uint32_t part)
static inline lv_coord_t lv_obj_get_style_max_height(const struct _lv_obj_t *obj, uint32_t part)
static inline lv_coord_t lv_obj_get_style_x(const struct _lv_obj_t *obj, uint32_t part)
static inline lv_coord_t lv_obj_get_style_y(const struct _lv_obj_t *obj, uint32_t part)
static inline lv_align_t lv_obj_get_style_align(const struct _lv_obj_t *obj, uint32_t part)
static inline lv_coord_t lv_obj_get_style_transform_width(const struct _lv_obj_t *obj, uint32_t part)
static inline lv_coord_t lv_obj_get_style_transform_height(const struct _lv_obj_t *obj, uint32_t part)
static inline lv_coord_t lv_obj_get_style_translate_x(const struct _lv_obj_t *obj, uint32_t part)
static inline lv_coord_t lv_obj_get_style_translate_y(const struct _lv_obj_t *obj, uint32_t part)
static inline lv_coord_t lv_obj_get_style_transform_zoom(const struct _lv_obj_t *obj, uint32_t part)
static inline lv_coord_t lv_obj_get_style_transform_angle(const struct _lv_obj_t *obj, uint32_t part)
static inline lv_coord_t lv_obj_get_style_transform_pivot_x(const struct _lv_obj_t *obj, uint32_t part)
static inline lv_coord_t lv_obj_get_style_transform_pivot_y(const struct _lv_obj_t *obj, uint32_t part)
static inline lv_coord_t lv_obj_get_style_pad_top(const struct _lv_obj_t *obj, uint32_t part)
static inline lv_coord_t lv_obj_get_style_pad_bottom(const struct _lv_obj_t *obj, uint32_t part)
static inline lv_coord_t lv_obj_get_style_pad_left(const struct _lv_obj_t *obj, uint32_t part)
static inline lv_coord_t lv_obj_get_style_pad_right(const struct _lv_obj_t *obj, uint32_t part)
static inline lv_coord_t lv_obj_get_style_pad_row(const struct _lv_obj_t *obj, uint32_t part)
static inline lv_coord_t lv_obj_get_style_pad_column(const struct _lv_obj_t *obj, uint32_t part)
static inline lv_color_t lv_obj_get_style_bg_color(const struct _lv_obj_t *obj, uint32_t part)
static inline lv_color_t lv_obj_get_style_bg_color_filtered(const struct _lv_obj_t *obj, uint32_t part)
static inline lv_opa_t lv_obj_get_style_bg_opa(const struct _lv_obj_t *obj, uint32_t part)
static inline lv_color_t lv_obj_get_style_bg_grad_color(const struct _lv_obj_t *obj, uint32_t part)
static inline lv_color_t lv_obj_get_style_bg_grad_color_filtered(const struct _lv_obj_t *obj, uint32_t part)
static inline lv_grad_dir_t lv_obj_get_style_bg_grad_dir(const struct _lv_obj_t *obj, uint32_t part)
static inline lv_coord_t lv_obj_get_style_bg_main_stop(const struct _lv_obj_t *obj, uint32_t part)
static inline lv_coord_t lv_obj_get_style_bg_grad_stop(const struct _lv_obj_t *obj, uint32_t part)
static inline const lv_grad_dsc_t *lv_obj_get_style_bg_grad(const struct _lv_obj_t *obj, uint32_t part)
static inline lv_dither_mode_t lv_obj_get_style_bg_dither_mode(const struct _lv_obj_t *obj, uint32_t part)
static inline const void *lv_obj_get_style_bg_img_src(const struct _lv_obj_t *obj, uint32_t part)
static inline lv_opa_t lv_obj_get_style_bg_img_opa(const struct _lv_obj_t *obj, uint32_t part)
static inline lv_color_t lv_obj_get_style_bg_img_recolor(const struct _lv_obj_t *obj, uint32_t part)
static inline lv_color_t lv_obj_get_style_bg_img_recolor_filtered(const struct _lv_obj_t *obj, uint32_t part)
static inline lv_opa_t lv_obj_get_style_bg_img_recolor_opa(const struct _lv_obj_t *obj, uint32_t part)
static inline bool lv_obj_get_style_bg_img_tiled(const struct _lv_obj_t *obj, uint32_t part)
static inline lv_color_t lv_obj_get_style_border_color(const struct _lv_obj_t *obj, uint32_t part)
static inline lv_color_t lv_obj_get_style_border_color_filtered(const struct _lv_obj_t *obj, uint32_t part)
static inline lv_opa_t lv_obj_get_style_border_opa(const struct _lv_obj_t *obj, uint32_t part)
static inline lv_coord_t lv_obj_get_style_border_width(const struct _lv_obj_t *obj, uint32_t part)
static inline lv_border_side_t lv_obj_get_style_border_side(const struct _lv_obj_t *obj, uint32_t part)
static inline bool lv_obj_get_style_border_post(const struct _lv_obj_t *obj, uint32_t part)
static inline lv_coord_t lv_obj_get_style_outline_width(const struct _lv_obj_t *obj, uint32_t part)
static inline lv_color_t lv_obj_get_style_outline_color(const struct _lv_obj_t *obj, uint32_t part)
static inline lv_color_t lv_obj_get_style_outline_color_filtered(const struct _lv_obj_t *obj, uint32_t part)
static inline lv_opa_t lv_obj_get_style_outline_opa(const struct _lv_obj_t *obj, uint32_t part)
static inline lv_coord_t lv_obj_get_style_outline_pad(const struct _lv_obj_t *obj, uint32_t part)
static inline lv_coord_t lv_obj_get_style_shadow_width(const struct _lv_obj_t *obj, uint32_t part)
static inline lv_coord_t lv_obj_get_style_shadow_ofs_x(const struct _lv_obj_t *obj, uint32_t part)
static inline lv_coord_t lv_obj_get_style_shadow_ofs_y(const struct _lv_obj_t *obj, uint32_t part)
static inline lv_coord_t lv_obj_get_style_shadow_spread(const struct _lv_obj_t *obj, uint32_t part)
static inline lv_color_t lv_obj_get_style_shadow_color(const struct _lv_obj_t *obj, uint32_t part)
static inline lv_color_t lv_obj_get_style_shadow_color_filtered(const struct _lv_obj_t *obj, uint32_t part)
static inline lv_opa_t lv_obj_get_style_shadow_opa(const struct _lv_obj_t *obj, uint32_t part)
static inline lv_opa_t lv_obj_get_style_img_opa(const struct _lv_obj_t *obj, uint32_t part)
static inline lv_color_t lv_obj_get_style_img_recolor(const struct _lv_obj_t *obj, uint32_t part)
static inline lv_color_t lv_obj_get_style_img_recolor_filtered(const struct _lv_obj_t *obj, uint32_t part)
static inline lv_opa_t lv_obj_get_style_img_recolor_opa(const struct _lv_obj_t *obj, uint32_t part)
static inline lv_coord_t lv_obj_get_style_line_width(const struct _lv_obj_t *obj, uint32_t part)
static inline lv_coord_t lv_obj_get_style_line_dash_width(const struct _lv_obj_t *obj, uint32_t part)
static inline lv_coord_t lv_obj_get_style_line_dash_gap(const struct _lv_obj_t *obj, uint32_t part)
static inline bool lv_obj_get_style_line_rounded(const struct _lv_obj_t *obj, uint32_t part)
static inline lv_color_t lv_obj_get_style_line_color(const struct _lv_obj_t *obj, uint32_t part)
static inline lv_color_t lv_obj_get_style_line_color_filtered(const struct _lv_obj_t *obj, uint32_t part)
static inline lv_opa_t lv_obj_get_style_line_opa(const struct _lv_obj_t *obj, uint32_t part)
static inline lv_coord_t lv_obj_get_style_arc_width(const struct _lv_obj_t *obj, uint32_t part)
static inline bool lv_obj_get_style_arc_rounded(const struct _lv_obj_t *obj, uint32_t part)
static inline lv_color_t lv_obj_get_style_arc_color(const struct _lv_obj_t *obj, uint32_t part)
static inline lv_color_t lv_obj_get_style_arc_color_filtered(const struct _lv_obj_t *obj, uint32_t part)
static inline lv_opa_t lv_obj_get_style_arc_opa(const struct _lv_obj_t *obj, uint32_t part)
static inline const void *lv_obj_get_style_arc_img_src(const struct _lv_obj_t *obj, uint32_t part)
static inline lv_color_t lv_obj_get_style_text_color(const struct _lv_obj_t *obj, uint32_t part)
static inline lv_color_t lv_obj_get_style_text_color_filtered(const struct _lv_obj_t *obj, uint32_t part)
static inline lv_opa_t lv_obj_get_style_text_opa(const struct _lv_obj_t *obj, uint32_t part)
static inline const lv_font_t *lv_obj_get_style_text_font(const struct _lv_obj_t *obj, uint32_t part)
static inline lv_coord_t lv_obj_get_style_text_letter_space(const struct _lv_obj_t *obj, uint32_t part)
static inline lv_coord_t lv_obj_get_style_text_line_space(const struct _lv_obj_t *obj, uint32_t part)
static inline lv_text_decor_t lv_obj_get_style_text_decor(const struct _lv_obj_t *obj, uint32_t part)
static inline lv_text_align_t lv_obj_get_style_text_align(const struct _lv_obj_t *obj, uint32_t part)
static inline lv_coord_t lv_obj_get_style_radius(const struct _lv_obj_t *obj, uint32_t part)
static inline bool lv_obj_get_style_clip_corner(const struct _lv_obj_t *obj, uint32_t part)
static inline lv_opa_t lv_obj_get_style_opa(const struct _lv_obj_t *obj, uint32_t part)
static inline const lv_color_filter_dsc_t *lv_obj_get_style_color_filter_dsc(const struct _lv_obj_t *obj, uint32_t part)
static inline lv_opa_t lv_obj_get_style_color_filter_opa(const struct _lv_obj_t *obj, uint32_t part)
static inline const lv_anim_t *lv_obj_get_style_anim(const struct _lv_obj_t *obj, uint32_t part)
static inline uint32_t lv_obj_get_style_anim_time(const struct _lv_obj_t *obj, uint32_t part)
static inline uint32_t lv_obj_get_style_anim_speed(const struct _lv_obj_t *obj, uint32_t part)
static inline const lv_style_transition_dsc_t *lv_obj_get_style_transition(const struct _lv_obj_t *obj, uint32_t part)
static inline lv_blend_mode_t lv_obj_get_style_blend_mode(const struct _lv_obj_t *obj, uint32_t part)
static inline uint16_t lv_obj_get_style_layout(const struct _lv_obj_t *obj, uint32_t part)
static inline lv_base_dir_t lv_obj_get_style_base_dir(const struct _lv_obj_t *obj, uint32_t part)
void lv_obj_set_style_width(struct _lv_obj_t *obj, lv_coord_t value, lv_style_selector_t selector)
void lv_obj_set_style_min_width(struct _lv_obj_t *obj, lv_coord_t value, lv_style_selector_t selector)
void lv_obj_set_style_max_width(struct _lv_obj_t *obj, lv_coord_t value, lv_style_selector_t selector)
void lv_obj_set_style_height(struct _lv_obj_t *obj, lv_coord_t value, lv_style_selector_t selector)
void lv_obj_set_style_min_height(struct _lv_obj_t *obj, lv_coord_t value, lv_style_selector_t selector)
void lv_obj_set_style_max_height(struct _lv_obj_t *obj, lv_coord_t value, lv_style_selector_t selector)
void lv_obj_set_style_x(struct _lv_obj_t *obj, lv_coord_t value, lv_style_selector_t selector)
void lv_obj_set_style_y(struct _lv_obj_t *obj, lv_coord_t value, lv_style_selector_t selector)
void lv_obj_set_style_align(struct _lv_obj_t *obj, lv_align_t value, lv_style_selector_t selector)
void lv_obj_set_style_transform_width(struct _lv_obj_t *obj, lv_coord_t value, lv_style_selector_t selector)
void lv_obj_set_style_transform_height(struct _lv_obj_t *obj, lv_coord_t value, lv_style_selector_t selector)
void lv_obj_set_style_translate_x(struct _lv_obj_t *obj, lv_coord_t value, lv_style_selector_t selector)
void lv_obj_set_style_translate_y(struct _lv_obj_t *obj, lv_coord_t value, lv_style_selector_t selector)
void lv_obj_set_style_transform_zoom(struct _lv_obj_t *obj, lv_coord_t value, lv_style_selector_t selector)
void lv_obj_set_style_transform_angle(struct _lv_obj_t *obj, lv_coord_t value, lv_style_selector_t selector)
void lv_obj_set_style_transform_pivot_x(struct _lv_obj_t *obj, lv_coord_t value, lv_style_selector_t selector)
void lv_obj_set_style_transform_pivot_y(struct _lv_obj_t *obj, lv_coord_t value, lv_style_selector_t selector)
void lv_obj_set_style_pad_top(struct _lv_obj_t *obj, lv_coord_t value, lv_style_selector_t selector)
void lv_obj_set_style_pad_bottom(struct _lv_obj_t *obj, lv_coord_t value, lv_style_selector_t selector)
void lv_obj_set_style_pad_left(struct _lv_obj_t *obj, lv_coord_t value, lv_style_selector_t selector)
void lv_obj_set_style_pad_right(struct _lv_obj_t *obj, lv_coord_t value, lv_style_selector_t selector)
void lv_obj_set_style_pad_row(struct _lv_obj_t *obj, lv_coord_t value, lv_style_selector_t selector)
void lv_obj_set_style_pad_column(struct _lv_obj_t *obj, lv_coord_t value, lv_style_selector_t selector)
void lv_obj_set_style_bg_color(struct _lv_obj_t *obj, lv_color_t value, lv_style_selector_t selector)
void lv_obj_set_style_bg_opa(struct _lv_obj_t *obj, lv_opa_t value, lv_style_selector_t selector)
void lv_obj_set_style_bg_grad_color(struct _lv_obj_t *obj, lv_color_t value, lv_style_selector_t selector)
void lv_obj_set_style_bg_grad_dir(struct _lv_obj_t *obj, lv_grad_dir_t value, lv_style_selector_t selector)
void lv_obj_set_style_bg_main_stop(struct _lv_obj_t *obj, lv_coord_t value, lv_style_selector_t selector)
void lv_obj_set_style_bg_grad_stop(struct _lv_obj_t *obj, lv_coord_t value, lv_style_selector_t selector)
void lv_obj_set_style_bg_grad(struct _lv_obj_t *obj, const lv_grad_dsc_t *value, lv_style_selector_t selector)
void lv_obj_set_style_bg_dither_mode(struct _lv_obj_t *obj, lv_dither_mode_t value, lv_style_selector_t selector)
void lv_obj_set_style_bg_img_src(struct _lv_obj_t *obj, const void *value, lv_style_selector_t selector)
void lv_obj_set_style_bg_img_opa(struct _lv_obj_t *obj, lv_opa_t value, lv_style_selector_t selector)
void lv_obj_set_style_bg_img_recolor(struct _lv_obj_t *obj, lv_color_t value, lv_style_selector_t selector)
void lv_obj_set_style_bg_img_recolor_opa(struct _lv_obj_t *obj, lv_opa_t value, lv_style_selector_t selector)
void lv_obj_set_style_bg_img_tiled(struct _lv_obj_t *obj, bool value, lv_style_selector_t selector)
void lv_obj_set_style_border_color(struct _lv_obj_t *obj, lv_color_t value, lv_style_selector_t selector)
void lv_obj_set_style_border_opa(struct _lv_obj_t *obj, lv_opa_t value, lv_style_selector_t selector)
void lv_obj_set_style_border_width(struct _lv_obj_t *obj, lv_coord_t value, lv_style_selector_t selector)
void lv_obj_set_style_border_side(struct _lv_obj_t *obj, lv_border_side_t value, lv_style_selector_t selector)
void lv_obj_set_style_border_post(struct _lv_obj_t *obj, bool value, lv_style_selector_t selector)
void lv_obj_set_style_outline_width(struct _lv_obj_t *obj, lv_coord_t value, lv_style_selector_t selector)
void lv_obj_set_style_outline_color(struct _lv_obj_t *obj, lv_color_t value, lv_style_selector_t selector)
void lv_obj_set_style_outline_opa(struct _lv_obj_t *obj, lv_opa_t value, lv_style_selector_t selector)
void lv_obj_set_style_outline_pad(struct _lv_obj_t *obj, lv_coord_t value, lv_style_selector_t selector)
void lv_obj_set_style_shadow_width(struct _lv_obj_t *obj, lv_coord_t value, lv_style_selector_t selector)
void lv_obj_set_style_shadow_ofs_x(struct _lv_obj_t *obj, lv_coord_t value, lv_style_selector_t selector)
void lv_obj_set_style_shadow_ofs_y(struct _lv_obj_t *obj, lv_coord_t value, lv_style_selector_t selector)
void lv_obj_set_style_shadow_spread(struct _lv_obj_t *obj, lv_coord_t value, lv_style_selector_t selector)
void lv_obj_set_style_shadow_color(struct _lv_obj_t *obj, lv_color_t value, lv_style_selector_t selector)
void lv_obj_set_style_shadow_opa(struct _lv_obj_t *obj, lv_opa_t value, lv_style_selector_t selector)
void lv_obj_set_style_img_opa(struct _lv_obj_t *obj, lv_opa_t value, lv_style_selector_t selector)
void lv_obj_set_style_img_recolor(struct _lv_obj_t *obj, lv_color_t value, lv_style_selector_t selector)
void lv_obj_set_style_img_recolor_opa(struct _lv_obj_t *obj, lv_opa_t value, lv_style_selector_t selector)
void lv_obj_set_style_line_width(struct _lv_obj_t *obj, lv_coord_t value, lv_style_selector_t selector)
void lv_obj_set_style_line_dash_width(struct _lv_obj_t *obj, lv_coord_t value, lv_style_selector_t selector)
void lv_obj_set_style_line_dash_gap(struct _lv_obj_t *obj, lv_coord_t value, lv_style_selector_t selector)
void lv_obj_set_style_line_rounded(struct _lv_obj_t *obj, bool value, lv_style_selector_t selector)
void lv_obj_set_style_line_color(struct _lv_obj_t *obj, lv_color_t value, lv_style_selector_t selector)
void lv_obj_set_style_line_opa(struct _lv_obj_t *obj, lv_opa_t value, lv_style_selector_t selector)
void lv_obj_set_style_arc_width(struct _lv_obj_t *obj, lv_coord_t value, lv_style_selector_t selector)
void lv_obj_set_style_arc_rounded(struct _lv_obj_t *obj, bool value, lv_style_selector_t selector)
void lv_obj_set_style_arc_color(struct _lv_obj_t *obj, lv_color_t value, lv_style_selector_t selector)
void lv_obj_set_style_arc_opa(struct _lv_obj_t *obj, lv_opa_t value, lv_style_selector_t selector)
void lv_obj_set_style_arc_img_src(struct _lv_obj_t *obj, const void *value, lv_style_selector_t selector)
void lv_obj_set_style_text_color(struct _lv_obj_t *obj, lv_color_t value, lv_style_selector_t selector)
void lv_obj_set_style_text_opa(struct _lv_obj_t *obj, lv_opa_t value, lv_style_selector_t selector)
void lv_obj_set_style_text_font(struct _lv_obj_t *obj, const lv_font_t *value, lv_style_selector_t selector)
void lv_obj_set_style_text_letter_space(struct _lv_obj_t *obj, lv_coord_t value, lv_style_selector_t selector)
void lv_obj_set_style_text_line_space(struct _lv_obj_t *obj, lv_coord_t value, lv_style_selector_t selector)
void lv_obj_set_style_text_decor(struct _lv_obj_t *obj, lv_text_decor_t value, lv_style_selector_t selector)
void lv_obj_set_style_text_align(struct _lv_obj_t *obj, lv_text_align_t value, lv_style_selector_t selector)
void lv_obj_set_style_radius(struct _lv_obj_t *obj, lv_coord_t value, lv_style_selector_t selector)
void lv_obj_set_style_clip_corner(struct _lv_obj_t *obj, bool value, lv_style_selector_t selector)
void lv_obj_set_style_opa(struct _lv_obj_t *obj, lv_opa_t value, lv_style_selector_t selector)
void lv_obj_set_style_color_filter_dsc(struct _lv_obj_t *obj, const lv_color_filter_dsc_t *value, lv_style_selector_t selector)
void lv_obj_set_style_color_filter_opa(struct _lv_obj_t *obj, lv_opa_t value, lv_style_selector_t selector)
void lv_obj_set_style_anim(struct _lv_obj_t *obj, const lv_anim_t *value, lv_style_selector_t selector)
void lv_obj_set_style_anim_time(struct _lv_obj_t *obj, uint32_t value, lv_style_selector_t selector)
void lv_obj_set_style_anim_speed(struct _lv_obj_t *obj, uint32_t value, lv_style_selector_t selector)
void lv_obj_set_style_transition(struct _lv_obj_t *obj, const lv_style_transition_dsc_t *value, lv_style_selector_t selector)
void lv_obj_set_style_blend_mode(struct _lv_obj_t *obj, lv_blend_mode_t value, lv_style_selector_t selector)
void lv_obj_set_style_layout(struct _lv_obj_t *obj, uint16_t value, lv_style_selector_t selector)
void lv_obj_set_style_base_dir(struct _lv_obj_t *obj, lv_base_dir_t value, lv_style_selector_t selector)

Functions

void lv_style_set_width(lv_style_t *style, lv_coord_t value)
void lv_style_set_min_width(lv_style_t *style, lv_coord_t value)
void lv_style_set_max_width(lv_style_t *style, lv_coord_t value)
void lv_style_set_height(lv_style_t *style, lv_coord_t value)
void lv_style_set_min_height(lv_style_t *style, lv_coord_t value)
void lv_style_set_max_height(lv_style_t *style, lv_coord_t value)
void lv_style_set_x(lv_style_t *style, lv_coord_t value)
void lv_style_set_y(lv_style_t *style, lv_coord_t value)
void lv_style_set_align(lv_style_t *style, lv_align_t value)
void lv_style_set_transform_width(lv_style_t *style, lv_coord_t value)
void lv_style_set_transform_height(lv_style_t *style, lv_coord_t value)
void lv_style_set_translate_x(lv_style_t *style, lv_coord_t value)
void lv_style_set_translate_y(lv_style_t *style, lv_coord_t value)
void lv_style_set_transform_zoom(lv_style_t *style, lv_coord_t value)
void lv_style_set_transform_angle(lv_style_t *style, lv_coord_t value)
void lv_style_set_transform_pivot_x(lv_style_t *style, lv_coord_t value)
void lv_style_set_transform_pivot_y(lv_style_t *style, lv_coord_t value)
void lv_style_set_pad_top(lv_style_t *style, lv_coord_t value)
void lv_style_set_pad_bottom(lv_style_t *style, lv_coord_t value)
void lv_style_set_pad_left(lv_style_t *style, lv_coord_t value)
void lv_style_set_pad_right(lv_style_t *style, lv_coord_t value)
void lv_style_set_pad_row(lv_style_t *style, lv_coord_t value)
void lv_style_set_pad_column(lv_style_t *style, lv_coord_t value)
void lv_style_set_bg_color(lv_style_t *style, lv_color_t value)
void lv_style_set_bg_opa(lv_style_t *style, lv_opa_t value)
void lv_style_set_bg_grad_color(lv_style_t *style, lv_color_t value)
void lv_style_set_bg_grad_dir(lv_style_t *style, lv_grad_dir_t value)
void lv_style_set_bg_main_stop(lv_style_t *style, lv_coord_t value)
void lv_style_set_bg_grad_stop(lv_style_t *style, lv_coord_t value)
void lv_style_set_bg_grad(lv_style_t *style, const lv_grad_dsc_t *value)
void lv_style_set_bg_dither_mode(lv_style_t *style, lv_dither_mode_t value)
void lv_style_set_bg_img_src(lv_style_t *style, const void *value)
void lv_style_set_bg_img_opa(lv_style_t *style, lv_opa_t value)
void lv_style_set_bg_img_recolor(lv_style_t *style, lv_color_t value)
void lv_style_set_bg_img_recolor_opa(lv_style_t *style, lv_opa_t value)
void lv_style_set_bg_img_tiled(lv_style_t *style, bool value)
void lv_style_set_border_color(lv_style_t *style, lv_color_t value)
void lv_style_set_border_opa(lv_style_t *style, lv_opa_t value)
void lv_style_set_border_width(lv_style_t *style, lv_coord_t value)
void lv_style_set_border_side(lv_style_t *style, lv_border_side_t value)
void lv_style_set_border_post(lv_style_t *style, bool value)
void lv_style_set_outline_width(lv_style_t *style, lv_coord_t value)
void lv_style_set_outline_color(lv_style_t *style, lv_color_t value)
void lv_style_set_outline_opa(lv_style_t *style, lv_opa_t value)
void lv_style_set_outline_pad(lv_style_t *style, lv_coord_t value)
void lv_style_set_shadow_width(lv_style_t *style, lv_coord_t value)
void lv_style_set_shadow_ofs_x(lv_style_t *style, lv_coord_t value)
void lv_style_set_shadow_ofs_y(lv_style_t *style, lv_coord_t value)
void lv_style_set_shadow_spread(lv_style_t *style, lv_coord_t value)
void lv_style_set_shadow_color(lv_style_t *style, lv_color_t value)
void lv_style_set_shadow_opa(lv_style_t *style, lv_opa_t value)
void lv_style_set_img_opa(lv_style_t *style, lv_opa_t value)
void lv_style_set_img_recolor(lv_style_t *style, lv_color_t value)
void lv_style_set_img_recolor_opa(lv_style_t *style, lv_opa_t value)
void lv_style_set_line_width(lv_style_t *style, lv_coord_t value)
void lv_style_set_line_dash_width(lv_style_t *style, lv_coord_t value)
void lv_style_set_line_dash_gap(lv_style_t *style, lv_coord_t value)
void lv_style_set_line_rounded(lv_style_t *style, bool value)
void lv_style_set_line_color(lv_style_t *style, lv_color_t value)
void lv_style_set_line_opa(lv_style_t *style, lv_opa_t value)
void lv_style_set_arc_width(lv_style_t *style, lv_coord_t value)
void lv_style_set_arc_rounded(lv_style_t *style, bool value)
void lv_style_set_arc_color(lv_style_t *style, lv_color_t value)
void lv_style_set_arc_opa(lv_style_t *style, lv_opa_t value)
void lv_style_set_arc_img_src(lv_style_t *style, const void *value)
void lv_style_set_text_color(lv_style_t *style, lv_color_t value)
void lv_style_set_text_opa(lv_style_t *style, lv_opa_t value)
void lv_style_set_text_font(lv_style_t *style, const lv_font_t *value)
void lv_style_set_text_letter_space(lv_style_t *style, lv_coord_t value)
void lv_style_set_text_line_space(lv_style_t *style, lv_coord_t value)
void lv_style_set_text_decor(lv_style_t *style, lv_text_decor_t value)
void lv_style_set_text_align(lv_style_t *style, lv_text_align_t value)
void lv_style_set_radius(lv_style_t *style, lv_coord_t value)
void lv_style_set_clip_corner(lv_style_t *style, bool value)
void lv_style_set_opa(lv_style_t *style, lv_opa_t value)
void lv_style_set_color_filter_dsc(lv_style_t *style, const lv_color_filter_dsc_t *value)
void lv_style_set_color_filter_opa(lv_style_t *style, lv_opa_t value)
void lv_style_set_anim(lv_style_t *style, const lv_anim_t *value)
void lv_style_set_anim_time(lv_style_t *style, uint32_t value)
void lv_style_set_anim_speed(lv_style_t *style, uint32_t value)
void lv_style_set_transition(lv_style_t *style, const lv_style_transition_dsc_t *value)
void lv_style_set_blend_mode(lv_style_t *style, lv_blend_mode_t value)
void lv_style_set_layout(lv_style_t *style, uint16_t value)
void lv_style_set_base_dir(lv_style_t *style, lv_base_dir_t value)