oveRTOS C++ API
C++20 RAII wrappers for the oveRTOS C API
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | List of all members
ove::lvgl::Label Class Reference

C++ wrapper for an LVGL label widget. More...

#include <lvgl.hpp>

Inheritance diagram for ove::lvgl::Label:
Inheritance graph
[legend]
Collaboration diagram for ove::lvgl::Label:
Collaboration graph
[legend]

Public Member Functions

 Label (lv_obj_t *obj)
 Constructs a Label wrapping an existing LVGL label object.
 
Labeltext (const char *txt)
 Sets the label text by copying the string (LVGL allocates internally).
 
Labeltext_static (const char *txt)
 Sets the label text to a static string (no copy — pointer must remain valid).
 
Labeltext_fmt (const char *fmt,...)
 Sets the label text using a printf-style format string.
 
Labelfont (const lv_font_t *f)
 Sets the font used to render the label text.
 
Labelcolor (lv_color_t c)
 Sets the text color.
 
Labellong_mode (lv_label_long_mode_t mode)
 Sets the long-text mode (wrap, scroll, clip, etc.).
 
- Public Member Functions inherited from ove::lvgl::ObjectView
 ObjectView ()
 Constructs a null ObjectView (no associated LVGL object).
 
 ObjectView (lv_obj_t *obj)
 Constructs an ObjectView wrapping the given lv_obj_t*.
 
lv_obj_t * get () const
 Returns the raw lv_obj_t* pointer.
 
 operator lv_obj_t * () const
 Implicit conversion to lv_obj_t* for use with LVGL C APIs.
 
 operator bool () const
 Contextual bool conversion — true if the object pointer is non-null.
 
ObjectView parent () const
 Returns an ObjectView wrapping the parent of this object.
 
uint32_t child_count () const
 Returns the number of direct children of this object.
 
int32_t get_width () const
 Returns the current rendered width of this object.
 
int32_t get_height () const
 Returns the current rendered height of this object.
 
void del ()
 Deletes the LVGL object and all its children, then nulls the pointer.
 
void clean ()
 Deletes all children of this object without deleting the object itself.
 
- Public Member Functions inherited from ove::lvgl::ObjectMixin< Label >
Labelsize (int32_t w, int32_t h)
 Sets both width and height of the object.
 
Labelwidth (int32_t w)
 Sets the width of the object.
 
Labelheight (int32_t h)
 Sets the height of the object.
 
Labelpos (int32_t x, int32_t y)
 Sets the position of the object relative to its parent.
 
Labelcenter ()
 Centers the object within its parent.
 
Labelalign (lv_align_t a, int32_t x_ofs=0, int32_t y_ofs=0)
 Aligns the object to an anchor with an optional offset.
 
Labelhide ()
 Hides the object by adding LV_OBJ_FLAG_HIDDEN.
 
Labelshow ()
 Shows the object by removing LV_OBJ_FLAG_HIDDEN.
 
Labelvisible (bool v)
 Conditionally shows or hides the object.
 
Labeladd_flag (lv_obj_flag_t f)
 Adds one or more object flags.
 
Labelremove_flag (lv_obj_flag_t f)
 Removes one or more object flags.
 
Labeladd_state (lv_state_t s)
 Adds one or more object states.
 
Labelremove_state (lv_state_t s)
 Removes one or more object states.
 
Labeluser_data (void *data)
 Stores an arbitrary user data pointer on the LVGL object.
 
Labelclickable (bool on)
 Enables or disables click events on the object.
 
- Public Member Functions inherited from ove::lvgl::EventMixin< Label >
Labelon (lv_event_code_t code, F &&fn)
 Registers a stateless callback for the given event code.
 
Labelon (lv_event_code_t code, T *instance)
 Registers a member function pointer as an event callback — zero-cost trampoline.
 
Labelon_click (F &&fn)
 Registers a stateless click callback (shorthand for on(LV_EVENT_CLICKED, fn)).
 
Labelon_click (T *instance)
 Registers a member function click callback.
 
Labelon_value_changed (F &&fn)
 Registers a stateless value-changed callback (shorthand for on(LV_EVENT_VALUE_CHANGED, fn)).
 
Labelon_value_changed (T *instance)
 Registers a member function value-changed callback.
 
- Public Member Functions inherited from ove::lvgl::StyleMixin< Label >
Labelbg_color (lv_color_t c)
 Sets the background color of the object.
 
Labelbg_opa (lv_opa_t opa)
 Sets the background opacity.
 
Labelborder_color (lv_color_t c)
 Sets the border color.
 
Labelborder_width (int32_t w)
 Sets the border width in pixels.
 
Labelradius (int32_t r)
 Sets the corner radius.
 
Labelpad_all (int32_t p)
 Sets uniform padding on all four sides.
 
Labelpad_hor (int32_t p)
 Sets horizontal (left + right) padding.
 
Labelpad_ver (int32_t p)
 Sets vertical (top + bottom) padding.
 
Labelpad_gap (int32_t g)
 Sets the gap between children in flex/grid layouts.
 
Labeltext_color (lv_color_t c)
 Sets the text color.
 
Labeltext_font (const lv_font_t *f)
 Sets the font used to render text.
 

Static Public Member Functions

static Label create (ObjectView parent)
 Factory method — creates a new LVGL label as a child of parent.
 
- Static Public Member Functions inherited from ove::lvgl::ObjectView
static ObjectView screen_active ()
 Returns an ObjectView wrapping the currently active screen.
 

Additional Inherited Members

- Protected Attributes inherited from ove::lvgl::ObjectView
lv_obj_t * obj_
 Raw pointer to the wrapped LVGL object.
 

Detailed Description

C++ wrapper for an LVGL label widget.

Label combines ObjectView, ObjectMixin, EventMixin, and StyleMixin to provide a fully fluent, type-safe API for LVGL label objects. All instances are pointer-sized (asserted via static_assert).

Create a label using the static factory method Label::create(parent).

When LV_USE_OBSERVER is enabled, labels can be bound to a State<T> object so that the displayed text updates automatically.

Note
Does not own the underlying LVGL object. Use del() to destroy it.

Constructor & Destructor Documentation

◆ Label()

ove::lvgl::Label::Label ( lv_obj_t obj)
inlineexplicit

Constructs a Label wrapping an existing LVGL label object.

Parameters
[in]objPointer to an LVGL label created via lv_label_create().

Member Function Documentation

◆ create()

static Label ove::lvgl::Label::create ( ObjectView  parent)
inlinestatic

Factory method — creates a new LVGL label as a child of parent.

Parameters
[in]parentThe parent ObjectView.
Returns
A Label wrapping the newly created LVGL label.

◆ text()

Label & ove::lvgl::Label::text ( const char txt)
inline

Sets the label text by copying the string (LVGL allocates internally).

Parameters
[in]txtNull-terminated string to display.
Returns
Reference to this label for method chaining.

◆ text_static()

Label & ove::lvgl::Label::text_static ( const char txt)
inline

Sets the label text to a static string (no copy — pointer must remain valid).

The string pointed to by txt must remain valid for the lifetime of the label. Avoids a heap allocation in LVGL.

Parameters
[in]txtPointer to a static or otherwise persistent string.
Returns
Reference to this label for method chaining.

◆ text_fmt()

Label & ove::lvgl::Label::text_fmt ( const char fmt,
  ... 
)
inline

Sets the label text using a printf-style format string.

The formatted result is written to a 128-byte stack buffer before being passed to LVGL. Strings longer than 127 characters will be truncated.

Parameters
[in]fmtprintf-style format string.
[in]...Additional arguments matching the format string.
Returns
Reference to this label for method chaining.

◆ font()

Label & ove::lvgl::Label::font ( const lv_font_t f)
inline

Sets the font used to render the label text.

Parameters
[in]fPointer to an LVGL font descriptor.
Returns
Reference to this label for method chaining.

◆ color()

Label & ove::lvgl::Label::color ( lv_color_t  c)
inline

Sets the text color.

Parameters
[in]cText color.
Returns
Reference to this label for method chaining.

◆ long_mode()

Label & ove::lvgl::Label::long_mode ( lv_label_long_mode_t  mode)
inline

Sets the long-text mode (wrap, scroll, clip, etc.).

Parameters
[in]modeOne of the lv_label_long_mode_t constants.
Returns
Reference to this label for method chaining.

The documentation for this class was generated from the following file: