oveRTOS C++ API
C++20 RAII wrappers for the oveRTOS C API
Loading...
Searching...
No Matches
lvgl.hpp
Go to the documentation of this file.
1/*
2 * Copyright (C) 2026 Kamil Lulko <kamil.lulko@gmail.com>
3 *
4 * SPDX-License-Identifier: GPL-3.0-or-later
5 *
6 * This file is part of oveRTOS.
7 */
8
14#pragma once
15
16#include <ove/lvgl.h>
17#include <cstdarg>
18#include <cstdint>
19#include <cstdio>
20#include <type_traits>
21#include <concepts>
22
42namespace ove::lvgl {
43
44/* ================================================================== */
45/* LvglGuard — RAII lock for thread-safe LVGL access */
46/* ================================================================== */
47
66class LvglGuard {
67public:
71 LvglGuard() { ove_lvgl_lock(); }
72
76 ~LvglGuard() { ove_lvgl_unlock(); }
77
78 LvglGuard(const LvglGuard &) = delete;
79 LvglGuard &operator=(const LvglGuard &) = delete;
80 LvglGuard(LvglGuard &&) = delete;
81 LvglGuard &operator=(LvglGuard &&) = delete;
82};
83
84/* ================================================================== */
85/* ObjectView — non-owning lv_obj_t* wrapper */
86/* ================================================================== */
87
103public:
107 ObjectView() : obj_(nullptr) {}
108
113 explicit ObjectView(lv_obj_t *obj) : obj_(obj) {}
114
119 lv_obj_t *get() const { return obj_; }
120
125 operator lv_obj_t *() const { return obj_; }
126
131 explicit operator bool() const { return obj_ != nullptr; }
132
138 return ObjectView(lv_obj_get_parent(obj_));
139 }
140
145 uint32_t child_count() const {
146 return lv_obj_get_child_count(obj_);
147 }
148
153 int32_t get_width() const { return lv_obj_get_width(obj_); }
154
159 int32_t get_height() const { return lv_obj_get_height(obj_); }
160
166 void del() { lv_obj_delete(obj_); obj_ = nullptr; }
167
171 void clean() { lv_obj_clean(obj_); }
172
178 return ObjectView(lv_screen_active());
179 }
180
181protected:
183 lv_obj_t *obj_;
184};
185
186static_assert(sizeof(ObjectView) == sizeof(void *),
187 "ObjectView must be pointer-sized");
188
189/* ================================================================== */
190/* ObjectMixin<Derived> — fluent setters via CRTP */
191/* ================================================================== */
192
205template <typename Derived>
207public:
214 Derived &size(int32_t w, int32_t h) {
215 lv_obj_set_size(self().get(), w, h);
216 return self();
217 }
218
224 Derived &width(int32_t w) {
225 lv_obj_set_width(self().get(), w);
226 return self();
227 }
228
234 Derived &height(int32_t h) {
235 lv_obj_set_height(self().get(), h);
236 return self();
237 }
238
245 Derived &pos(int32_t x, int32_t y) {
246 lv_obj_set_pos(self().get(), x, y);
247 return self();
248 }
249
254 Derived &center() {
255 lv_obj_center(self().get());
256 return self();
257 }
258
266 Derived &align(lv_align_t a, int32_t x_ofs = 0, int32_t y_ofs = 0) {
267 lv_obj_align(self().get(), a, x_ofs, y_ofs);
268 return self();
269 }
270
275 Derived &hide() {
276 lv_obj_add_flag(self().get(), LV_OBJ_FLAG_HIDDEN);
277 return self();
278 }
279
284 Derived &show() {
285 lv_obj_remove_flag(self().get(), LV_OBJ_FLAG_HIDDEN);
286 return self();
287 }
288
294 Derived &visible(bool v) { return v ? show() : hide(); }
295
301 Derived &add_flag(lv_obj_flag_t f) {
302 lv_obj_add_flag(self().get(), f);
303 return self();
304 }
305
311 Derived &remove_flag(lv_obj_flag_t f) {
312 lv_obj_remove_flag(self().get(), f);
313 return self();
314 }
315
321 Derived &add_state(lv_state_t s) {
322 lv_obj_add_state(self().get(), s);
323 return self();
324 }
325
331 Derived &remove_state(lv_state_t s) {
332 lv_obj_remove_state(self().get(), s);
333 return self();
334 }
335
341 Derived &user_data(void *data) {
342 lv_obj_set_user_data(self().get(), data);
343 return self();
344 }
345
351 Derived &clickable(bool on) {
352 if (on)
353 lv_obj_add_flag(self().get(), LV_OBJ_FLAG_CLICKABLE);
354 else
355 lv_obj_remove_flag(self().get(), LV_OBJ_FLAG_CLICKABLE);
356 return self();
357 }
358
359private:
360 Derived &self() { return static_cast<Derived &>(*this); }
361};
362
363/* ================================================================== */
364/* EventMixin<Derived> — type-safe event callbacks via CRTP */
365/* ================================================================== */
366
367namespace detail {
368
378template <typename F>
379concept StatelessCallable = std::is_convertible_v<F, void (*)(lv_event_t *)>;
380
381} /* namespace detail */
382
399template <typename Derived>
401public:
413 template <detail::StatelessCallable F>
414 Derived &on(lv_event_code_t code, F &&fn) {
415 lv_obj_add_event_cb(self().get(),
416 static_cast<lv_event_cb_t>(fn),
417 code, nullptr);
418 return self();
419 }
420
434 template <auto MemFn, typename T>
435 Derived &on(lv_event_code_t code, T *instance) {
436 lv_obj_add_event_cb(self().get(),
437 [](lv_event_t *e) {
438 auto *self = static_cast<T *>(
439 lv_event_get_user_data(e));
440 (self->*MemFn)(e);
441 },
442 code, instance);
443 return self();
444 }
445
452 template <detail::StatelessCallable F>
453 Derived &on_click(F &&fn) {
454 return on(LV_EVENT_CLICKED, static_cast<F &&>(fn));
455 }
456
464 template <auto MemFn, typename T>
465 Derived &on_click(T *instance) {
467 }
468
475 template <detail::StatelessCallable F>
477 return on(LV_EVENT_VALUE_CHANGED, static_cast<F &&>(fn));
478 }
479
487 template <auto MemFn, typename T>
491
492private:
493 Derived &self() { return static_cast<Derived &>(*this); }
494};
495
496/* ================================================================== */
497/* StyleMixin<Derived> — inline style setters via CRTP */
498/* ================================================================== */
499
512template <typename Derived>
514public:
520 Derived &bg_color(lv_color_t c) {
521 lv_obj_set_style_bg_color(self().get(), c, LV_PART_MAIN);
522 return self();
523 }
524
530 Derived &bg_opa(lv_opa_t opa) {
531 lv_obj_set_style_bg_opa(self().get(), opa, LV_PART_MAIN);
532 return self();
533 }
534
540 Derived &border_color(lv_color_t c) {
541 lv_obj_set_style_border_color(self().get(), c, LV_PART_MAIN);
542 return self();
543 }
544
550 Derived &border_width(int32_t w) {
551 lv_obj_set_style_border_width(self().get(), w, LV_PART_MAIN);
552 return self();
553 }
554
560 Derived &radius(int32_t r) {
561 lv_obj_set_style_radius(self().get(), r, LV_PART_MAIN);
562 return self();
563 }
564
570 Derived &pad_all(int32_t p) {
571 lv_obj_set_style_pad_all(self().get(), p, LV_PART_MAIN);
572 return self();
573 }
574
580 Derived &pad_hor(int32_t p) {
581 lv_obj_set_style_pad_hor(self().get(), p, LV_PART_MAIN);
582 return self();
583 }
584
590 Derived &pad_ver(int32_t p) {
591 lv_obj_set_style_pad_ver(self().get(), p, LV_PART_MAIN);
592 return self();
593 }
594
600 Derived &pad_gap(int32_t g) {
601 lv_obj_set_style_pad_gap(self().get(), g, LV_PART_MAIN);
602 return self();
603 }
604
610 Derived &text_color(lv_color_t c) {
611 lv_obj_set_style_text_color(self().get(), c, LV_PART_MAIN);
612 return self();
613 }
614
620 Derived &text_font(const lv_font_t *f) {
621 lv_obj_set_style_text_font(self().get(), f, LV_PART_MAIN);
622 return self();
623 }
624
625private:
626 Derived &self() { return static_cast<Derived &>(*this); }
627};
628
629/* ================================================================== */
630/* Style — RAII style object */
631/* ================================================================== */
632
646class Style {
647public:
651 Style() { lv_style_init(&style_); }
652
656 ~Style() { lv_style_reset(&style_); }
657
658 Style(const Style &) = delete;
659 Style &operator=(const Style &) = delete;
660
665 Style(Style &&other) noexcept : style_(other.style_) {
666 lv_style_init(&other.style_);
667 }
668
674 Style &operator=(Style &&other) noexcept {
675 if (this != &other) {
676 lv_style_reset(&style_);
677 style_ = other.style_;
678 lv_style_init(&other.style_);
679 }
680 return *this;
681 }
682
687 lv_style_t *get() { return &style_; }
688
693 const lv_style_t *get() const { return &style_; }
694
700 Style &bg_color(lv_color_t c) {
701 lv_style_set_bg_color(&style_, c);
702 return *this;
703 }
704
710 Style &bg_opa(lv_opa_t opa) {
711 lv_style_set_bg_opa(&style_, opa);
712 return *this;
713 }
714
720 Style &radius(int32_t r) {
721 lv_style_set_radius(&style_, r);
722 return *this;
723 }
724
730 Style &border_color(lv_color_t c) {
731 lv_style_set_border_color(&style_, c);
732 return *this;
733 }
734
740 Style &border_width(int32_t w) {
741 lv_style_set_border_width(&style_, w);
742 return *this;
743 }
744
750 Style &pad_all(int32_t p) {
751 lv_style_set_pad_all(&style_, p);
752 return *this;
753 }
754
760 Style &text_color(lv_color_t c) {
761 lv_style_set_text_color(&style_, c);
762 return *this;
763 }
764
770 Style &text_font(const lv_font_t *f) {
771 lv_style_set_text_font(&style_, f);
772 return *this;
773 }
774
775private:
776 lv_style_t style_;
777};
778
779/* ================================================================== */
780/* State<T> — reactive state (requires LV_USE_OBSERVER) */
781/* ================================================================== */
782
783#if LV_USE_OBSERVER
784
801template <std::integral T>
802class State {
803public:
808 explicit State(T initial = 0) {
809 lv_subject_init_int(&subject_, static_cast<int32_t>(initial));
810 }
811
815 ~State() { lv_subject_deinit(&subject_); }
816
817 State(const State &) = delete;
818 State &operator=(const State &) = delete;
819
824 void set(T val) { lv_subject_set_int(&subject_, static_cast<int32_t>(val)); }
825
830 T get() const {
831 return static_cast<T>(lv_subject_get_int(
832 const_cast<lv_subject_t *>(&subject_)));
833 }
834
839 operator T() const { return get(); }
840
845 State &operator++() { set(get() + 1); return *this; }
846
851 State &operator--() { set(get() - 1); return *this; }
852
857 lv_subject_t *subject() { return &subject_; }
858
859private:
860 lv_subject_t subject_;
861};
862
863
864#endif /* LV_USE_OBSERVER */
865
866/* ================================================================== */
867/* Widget wrappers — Label, Bar, Box */
868/* ================================================================== */
869
885class Label : public ObjectView,
886 public ObjectMixin<Label>,
887 public EventMixin<Label>,
888 public StyleMixin<Label> {
889public:
894 explicit Label(lv_obj_t *obj) : ObjectView(obj) {}
895
903 }
904
910 Label &text(const char *txt) {
912 return *this;
913 }
914
924 Label &text_static(const char *txt) {
926 return *this;
927 }
928
939 Label &text_fmt(const char *fmt, ...) {
941 va_start(args, fmt);
942 /* LVGL doesn't have a va_list variant, use snprintf + set */
943 char buf[128];
944 vsnprintf(buf, sizeof(buf), fmt, args);
945 va_end(args);
947 return *this;
948 }
949
957 return *this;
958 }
959
969
979
980#if LV_USE_OBSERVER
994 template <std::integral T>
995 Label &bind_text(State<T> &state, const char *fmt) {
996 lv_label_bind_text(obj_, state.subject(), fmt);
997 return *this;
998 }
999#endif
1000};
1001
1002static_assert(sizeof(Label) == sizeof(void *),
1003 "Label must be pointer-sized");
1004
1019class Bar : public ObjectView,
1020 public ObjectMixin<Bar>,
1021 public EventMixin<Bar>,
1022 public StyleMixin<Bar> {
1023public:
1028 explicit Bar(lv_obj_t *obj) : ObjectView(obj) {}
1029
1036 return Bar(lv_bar_create(parent));
1037 }
1038
1046 return *this;
1047 }
1048
1057 return *this;
1058 }
1059
1068 return *this;
1069 }
1070
1080
1088 return *this;
1089 }
1090
1091 /* Note: lv_bar_bind_value() does NOT exist in LVGL 9.2-9.3 */
1092};
1093
1094static_assert(sizeof(Bar) == sizeof(void *),
1095 "Bar must be pointer-sized");
1096
1110class Box : public ObjectView,
1111 public ObjectMixin<Box>,
1112 public EventMixin<Box>,
1113 public StyleMixin<Box> {
1114public:
1119 explicit Box(lv_obj_t *obj) : ObjectView(obj) {}
1120
1131};
1132
1133static_assert(sizeof(Box) == sizeof(void *),
1134 "Box must be pointer-sized");
1135
1136/* ================================================================== */
1137/* Layout helpers */
1138/* ================================================================== */
1139
1145inline Box vbox(ObjectView parent) {
1146 auto b = Box::create(parent);
1147 lv_obj_set_flex_flow(b.get(), LV_FLEX_FLOW_COLUMN);
1148 lv_obj_set_size(b.get(), LV_SIZE_CONTENT, LV_SIZE_CONTENT);
1149 return b;
1150}
1151
1157inline Box hbox(ObjectView parent) {
1158 auto b = Box::create(parent);
1159 lv_obj_set_flex_flow(b.get(), LV_FLEX_FLOW_ROW);
1160 lv_obj_set_size(b.get(), LV_SIZE_CONTENT, LV_SIZE_CONTENT);
1161 return b;
1162}
1163
1164/* ================================================================== */
1165/* Component<Derived> — CRTP UI composition base */
1166/* ================================================================== */
1167
1189template <typename Derived>
1191public:
1193 Component() = default;
1194 ~Component() = default;
1195
1196 Component(const Component &) = delete;
1197 Component &operator=(const Component &) = delete;
1198
1209 void mount(ObjectView parent) {
1210 if (root_)
1211 return;
1212 root_ = static_cast<Derived *>(this)->build(parent);
1213 /* Store 'this' in root's user data for from_event() */
1214 lv_obj_set_user_data(root_.get(), this);
1215 /* Track external deletion (e.g. screen auto_del) */
1216 lv_obj_add_event_cb(root_.get(),
1217 delete_cb, LV_EVENT_DELETE, this);
1218 }
1219
1227 void unmount() {
1228 if (!root_)
1229 return;
1230 /* Remove the delete callback before we delete, to avoid
1231 * the callback nulling root_ and then us using it. */
1232 lv_obj_t *obj = root_.get();
1233 root_ = ObjectView();
1234 lv_obj_delete(obj);
1235 }
1236
1241 bool is_mounted() const { return static_cast<bool>(root_); }
1242
1247 ObjectView root() const { return root_; }
1248
1252 void hide() {
1253 if (root_)
1254 lv_obj_add_flag(root_.get(), LV_OBJ_FLAG_HIDDEN);
1255 }
1256
1260 void show() {
1261 if (root_)
1262 lv_obj_remove_flag(root_.get(), LV_OBJ_FLAG_HIDDEN);
1263 }
1264
1275 static Derived *from_event(lv_event_t *e) {
1276 lv_obj_t *target = static_cast<lv_obj_t *>(lv_event_get_target(e));
1277 while (target) {
1278 void *ud = lv_obj_get_user_data(target);
1279 if (ud)
1280 return static_cast<Derived *>(
1281 static_cast<Component *>(ud));
1282 target = lv_obj_get_parent(target);
1283 }
1284 return nullptr;
1285 }
1286
1287protected:
1290
1291private:
1297 static void delete_cb(lv_event_t *e) {
1298 auto *self = static_cast<Component *>(
1299 lv_event_get_user_data(e));
1300 /* Object is being deleted externally — just clear our ref */
1301 self->root_ = ObjectView();
1302 }
1303};
1304
1305} /* namespace ove::lvgl */
C++ wrapper for an LVGL progress-bar widget.
Definition lvgl.hpp:1022
static Bar create(ObjectView parent)
Factory method — creates a new LVGL bar as a child of parent.
Definition lvgl.hpp:1035
Bar & range(int32_t min, int32_t max)
Sets the minimum and maximum values for the bar.
Definition lvgl.hpp:1066
Bar & indicator_color(lv_color_t c)
Sets the background color of the indicator (filled) part.
Definition lvgl.hpp:1076
Bar & bar_color(lv_color_t c)
Sets the background color of the bar track (unfilled) part.
Definition lvgl.hpp:1086
Bar & value(int32_t val)
Sets the current value of the bar with animation enabled.
Definition lvgl.hpp:1044
Bar(lv_obj_t *obj)
Constructs a Bar wrapping an existing LVGL bar object.
Definition lvgl.hpp:1028
Bar & value(int32_t val, lv_anim_enable_t anim)
Sets the current value of the bar with explicit animation control.
Definition lvgl.hpp:1055
C++ wrapper for a generic LVGL container object with scrolling disabled.
Definition lvgl.hpp:1113
static Box create(ObjectView parent)
Factory method — creates a new LVGL container with scrolling disabled.
Definition lvgl.hpp:1126
Box(lv_obj_t *obj)
Constructs a Box wrapping an existing LVGL object.
Definition lvgl.hpp:1119
CRTP base class for reusable, self-contained LVGL UI components.
Definition lvgl.hpp:1190
bool is_mounted() const
Returns true if the component is currently mounted.
Definition lvgl.hpp:1241
void mount(ObjectView parent)
Builds and mounts the component under the given parent.
Definition lvgl.hpp:1209
Component()=default
Default constructor — component starts in the unmounted state.
void show()
Shows the component's root widget if mounted.
Definition lvgl.hpp:1260
ObjectView root_
Non-owning view of the component's root LVGL widget.
Definition lvgl.hpp:1289
void unmount()
Unmounts and deletes the component's widget subtree.
Definition lvgl.hpp:1227
static Derived * from_event(lv_event_t *e)
Walks up the LVGL object tree from the event target to find the Derived component instance.
Definition lvgl.hpp:1275
void hide()
Hides the component's root widget if mounted.
Definition lvgl.hpp:1252
ObjectView root() const
Returns an ObjectView of the component's root widget.
Definition lvgl.hpp:1247
CRTP mixin that adds type-safe LVGL event registration to widget classes.
Definition lvgl.hpp:400
Derived & on_click(F &&fn)
Registers a stateless click callback (shorthand for on(LV_EVENT_CLICKED, fn)).
Definition lvgl.hpp:453
Derived & on_value_changed(F &&fn)
Registers a stateless value-changed callback (shorthand for on(LV_EVENT_VALUE_CHANGED,...
Definition lvgl.hpp:476
Derived & on_click(T *instance)
Registers a member function click callback.
Definition lvgl.hpp:465
Derived & on(lv_event_code_t code, F &&fn)
Registers a stateless callback for the given event code.
Definition lvgl.hpp:414
Derived & on_value_changed(T *instance)
Registers a member function value-changed callback.
Definition lvgl.hpp:488
Derived & on(lv_event_code_t code, T *instance)
Registers a member function pointer as an event callback — zero-cost trampoline.
Definition lvgl.hpp:435
C++ wrapper for an LVGL label widget.
Definition lvgl.hpp:888
Label & font(const lv_font_t *f)
Sets the font used to render the label text.
Definition lvgl.hpp:955
Label & color(lv_color_t c)
Sets the text color.
Definition lvgl.hpp:965
Label & text(const char *txt)
Sets the label text by copying the string (LVGL allocates internally).
Definition lvgl.hpp:910
Label & long_mode(lv_label_long_mode_t mode)
Sets the long-text mode (wrap, scroll, clip, etc.).
Definition lvgl.hpp:975
Label(lv_obj_t *obj)
Constructs a Label wrapping an existing LVGL label object.
Definition lvgl.hpp:894
Label & text_fmt(const char *fmt,...)
Sets the label text using a printf-style format string.
Definition lvgl.hpp:939
static Label create(ObjectView parent)
Factory method — creates a new LVGL label as a child of parent.
Definition lvgl.hpp:901
Label & text_static(const char *txt)
Sets the label text to a static string (no copy — pointer must remain valid).
Definition lvgl.hpp:924
RAII scoped lock for thread-safe access to the LVGL rendering context.
Definition lvgl.hpp:66
LvglGuard()
Acquires the LVGL lock, blocking until it is available.
Definition lvgl.hpp:71
~LvglGuard()
Releases the LVGL lock.
Definition lvgl.hpp:76
CRTP mixin that adds fluent layout and visibility setters to widget classes.
Definition lvgl.hpp:206
Derived & hide()
Hides the object by adding LV_OBJ_FLAG_HIDDEN.
Definition lvgl.hpp:275
Derived & user_data(void *data)
Stores an arbitrary user data pointer on the LVGL object.
Definition lvgl.hpp:341
Derived & show()
Shows the object by removing LV_OBJ_FLAG_HIDDEN.
Definition lvgl.hpp:284
Derived & height(int32_t h)
Sets the height of the object.
Definition lvgl.hpp:234
Derived & clickable(bool on)
Enables or disables click events on the object.
Definition lvgl.hpp:351
Derived & width(int32_t w)
Sets the width of the object.
Definition lvgl.hpp:224
Derived & size(int32_t w, int32_t h)
Sets both width and height of the object.
Definition lvgl.hpp:214
Derived & align(lv_align_t a, int32_t x_ofs=0, int32_t y_ofs=0)
Aligns the object to an anchor with an optional offset.
Definition lvgl.hpp:266
Derived & add_state(lv_state_t s)
Adds one or more object states.
Definition lvgl.hpp:321
Derived & visible(bool v)
Conditionally shows or hides the object.
Definition lvgl.hpp:294
Derived & pos(int32_t x, int32_t y)
Sets the position of the object relative to its parent.
Definition lvgl.hpp:245
Derived & center()
Centers the object within its parent.
Definition lvgl.hpp:254
Derived & remove_flag(lv_obj_flag_t f)
Removes one or more object flags.
Definition lvgl.hpp:311
Derived & add_flag(lv_obj_flag_t f)
Adds one or more object flags.
Definition lvgl.hpp:301
Derived & remove_state(lv_state_t s)
Removes one or more object states.
Definition lvgl.hpp:331
Non-owning, pointer-sized wrapper around an lv_obj_t*.
Definition lvgl.hpp:102
ObjectView(lv_obj_t *obj)
Constructs an ObjectView wrapping the given lv_obj_t*.
Definition lvgl.hpp:113
uint32_t child_count() const
Returns the number of direct children of this object.
Definition lvgl.hpp:145
void clean()
Deletes all children of this object without deleting the object itself.
Definition lvgl.hpp:171
static ObjectView screen_active()
Returns an ObjectView wrapping the currently active screen.
Definition lvgl.hpp:177
int32_t get_width() const
Returns the current rendered width of this object.
Definition lvgl.hpp:153
int32_t get_height() const
Returns the current rendered height of this object.
Definition lvgl.hpp:159
lv_obj_t * get() const
Returns the raw lv_obj_t* pointer.
Definition lvgl.hpp:119
ObjectView()
Constructs a null ObjectView (no associated LVGL object).
Definition lvgl.hpp:107
lv_obj_t * obj_
Raw pointer to the wrapped LVGL object.
Definition lvgl.hpp:183
void del()
Deletes the LVGL object and all its children, then nulls the pointer.
Definition lvgl.hpp:166
ObjectView parent() const
Returns an ObjectView wrapping the parent of this object.
Definition lvgl.hpp:137
CRTP mixin that adds inline per-object style setters to widget classes.
Definition lvgl.hpp:513
Derived & radius(int32_t r)
Sets the corner radius.
Definition lvgl.hpp:560
Derived & pad_gap(int32_t g)
Sets the gap between children in flex/grid layouts.
Definition lvgl.hpp:600
Derived & pad_hor(int32_t p)
Sets horizontal (left + right) padding.
Definition lvgl.hpp:580
Derived & border_width(int32_t w)
Sets the border width in pixels.
Definition lvgl.hpp:550
Derived & text_font(const lv_font_t *f)
Sets the font used to render text.
Definition lvgl.hpp:620
Derived & pad_all(int32_t p)
Sets uniform padding on all four sides.
Definition lvgl.hpp:570
Derived & bg_color(lv_color_t c)
Sets the background color of the object.
Definition lvgl.hpp:520
Derived & pad_ver(int32_t p)
Sets vertical (top + bottom) padding.
Definition lvgl.hpp:590
Derived & border_color(lv_color_t c)
Sets the border color.
Definition lvgl.hpp:540
Derived & text_color(lv_color_t c)
Sets the text color.
Definition lvgl.hpp:610
Derived & bg_opa(lv_opa_t opa)
Sets the background opacity.
Definition lvgl.hpp:530
RAII wrapper around an lv_style_t object.
Definition lvgl.hpp:646
const lv_style_t * get() const
Returns a const pointer to the underlying lv_style_t.
Definition lvgl.hpp:693
Style & pad_all(int32_t p)
Sets uniform padding on all four sides.
Definition lvgl.hpp:750
Style & border_color(lv_color_t c)
Sets the border color.
Definition lvgl.hpp:730
Style & bg_opa(lv_opa_t opa)
Sets the background opacity.
Definition lvgl.hpp:710
Style()
Constructs and initialises an empty LVGL style.
Definition lvgl.hpp:651
Style & operator=(Style &&other) noexcept
Move-assignment operator — transfers the style data and reinitialises the source.
Definition lvgl.hpp:674
Style & border_width(int32_t w)
Sets the border width in pixels.
Definition lvgl.hpp:740
~Style()
Destroys the style, releasing any resources held by LVGL.
Definition lvgl.hpp:656
Style & bg_color(lv_color_t c)
Sets the background color.
Definition lvgl.hpp:700
Style & text_color(lv_color_t c)
Sets the text color.
Definition lvgl.hpp:760
Style & text_font(const lv_font_t *f)
Sets the font used to render text.
Definition lvgl.hpp:770
lv_style_t * get()
Returns a mutable pointer to the underlying lv_style_t.
Definition lvgl.hpp:687
Style & radius(int32_t r)
Sets the corner radius.
Definition lvgl.hpp:720
Style(Style &&other) noexcept
Move constructor — transfers the style data and reinitialises the source.
Definition lvgl.hpp:665
Concept satisfied by callables that are directly convertible to void(*)(lv_event_t*).
Definition lvgl.hpp:379
int get(unsigned int port, unsigned int pin)
Reads the current logic level of a GPIO pin.
Definition gpio.hpp:62
int set(unsigned int port, unsigned int pin, int value)
Drives a GPIO output pin to the specified logic level.
Definition gpio.hpp:51
C++ abstractions for the LVGL embedded GUI library.
Box hbox(ObjectView parent)
Creates a horizontal flex container (LV_FLEX_FLOW_ROW) sized to its content.
Definition lvgl.hpp:1157
Box vbox(ObjectView parent)
Creates a vertical flex container (LV_FLEX_FLOW_COLUMN) sized to its content.
Definition lvgl.hpp:1145