oveRTOS C++ API
C++20 RAII wrappers for the oveRTOS C API
Loading...
Searching...
No Matches
Public Member Functions | List of all members
ove::lvgl::ObjectMixin< Derived > Class Template Reference

CRTP mixin that adds fluent layout and visibility setters to widget classes. More...

#include <lvgl.hpp>

Public Member Functions

Derived & size (int32_t w, int32_t h)
 Sets both width and height of the object.
 
Derived & width (int32_t w)
 Sets the width of the object.
 
Derived & height (int32_t h)
 Sets the height of the object.
 
Derived & pos (int32_t x, int32_t y)
 Sets the position of the object relative to its parent.
 
Derived & center ()
 Centers the object within its parent.
 
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.
 
Derived & hide ()
 Hides the object by adding LV_OBJ_FLAG_HIDDEN.
 
Derived & show ()
 Shows the object by removing LV_OBJ_FLAG_HIDDEN.
 
Derived & visible (bool v)
 Conditionally shows or hides the object.
 
Derived & add_flag (lv_obj_flag_t f)
 Adds one or more object flags.
 
Derived & remove_flag (lv_obj_flag_t f)
 Removes one or more object flags.
 
Derived & add_state (lv_state_t s)
 Adds one or more object states.
 
Derived & remove_state (lv_state_t s)
 Removes one or more object states.
 
Derived & user_data (void *data)
 Stores an arbitrary user data pointer on the LVGL object.
 
Derived & clickable (bool on)
 Enables or disables click events on the object.
 
Derived & grid_dsc (const int32_t *cols, const int32_t *rows)
 Configures this object as a grid container.
 
Derived & flex_flow (lv_flex_flow_t flow)
 Configure this object as a flex container with the given flow.
 
Derived & flex_align (lv_flex_align_t main, lv_flex_align_t cross, lv_flex_align_t track)
 Set flex alignment for main axis, cross axis (items), and cross axis (tracks).
 
Derived & flex_grow (uint8_t grow)
 Set this child's flex grow factor (0 disables growing).
 
Derived & layout (uint32_t kind)
 Switch the object's layout engine (None / Flex / Grid).
 
Derived & scroll_to_y (int32_t y, bool anim)
 Scroll the object so y is visible. anim enables animated scrolling.
 
Derived & update_layout ()
 Force a layout recomputation (needed before get_content_width/get_scroll_bottom).
 
int32_t get_content_width () const
 
int32_t get_scroll_bottom () const
 
Derived & remove_style_all ()
 
Derived & grid_cell (lv_grid_align_t col_align, int32_t col_pos, int32_t col_span, lv_grid_align_t row_align, int32_t row_pos, int32_t row_span)
 Places this object into a cell of its parent grid.
 
Derived & add_style (Style &style, lv_style_selector_t selector)
 Applies a reusable Style to this object for the given selector.
 

Detailed Description

template<typename Derived>
class ove::lvgl::ObjectMixin< Derived >

CRTP mixin that adds fluent layout and visibility setters to widget classes.

Derive from ObjectMixin<Derived> to gain a chainable API for the most common LVGL object properties (size, position, alignment, flags, state, user data, clickability). All methods return Derived & to support method chaining.

Template Parameters
DerivedThe concrete widget class inheriting this mixin. Must expose a get() method returning lv_obj_t*.

Member Function Documentation

◆ size()

template<typename Derived >
Derived & ove::lvgl::ObjectMixin< Derived >::size ( int32_t  w,
int32_t  h 
)
inline

Sets both width and height of the object.

Parameters
[in]wWidth in pixels (or LV_SIZE_CONTENT / LV_PCT(...)).
[in]hHeight in pixels.
Returns
Reference to the derived object for method chaining.

◆ width()

template<typename Derived >
Derived & ove::lvgl::ObjectMixin< Derived >::width ( int32_t  w)
inline

Sets the width of the object.

Parameters
[in]wWidth in pixels.
Returns
Reference to the derived object for method chaining.

◆ height()

template<typename Derived >
Derived & ove::lvgl::ObjectMixin< Derived >::height ( int32_t  h)
inline

Sets the height of the object.

Parameters
[in]hHeight in pixels.
Returns
Reference to the derived object for method chaining.

◆ pos()

template<typename Derived >
Derived & ove::lvgl::ObjectMixin< Derived >::pos ( int32_t  x,
int32_t  y 
)
inline

Sets the position of the object relative to its parent.

Parameters
[in]xX coordinate in pixels.
[in]yY coordinate in pixels.
Returns
Reference to the derived object for method chaining.

◆ center()

template<typename Derived >
Derived & ove::lvgl::ObjectMixin< Derived >::center ( )
inline

Centers the object within its parent.

Returns
Reference to the derived object for method chaining.

◆ align()

template<typename Derived >
Derived & ove::lvgl::ObjectMixin< Derived >::align ( lv_align_t  a,
int32_t  x_ofs = 0,
int32_t  y_ofs = 0 
)
inline

Aligns the object to an anchor with an optional offset.

Parameters
[in]aAlignment value (e.g., LV_ALIGN_CENTER).
[in]x_ofsHorizontal offset in pixels (default: 0).
[in]y_ofsVertical offset in pixels (default: 0).
Returns
Reference to the derived object for method chaining.

◆ hide()

template<typename Derived >
Derived & ove::lvgl::ObjectMixin< Derived >::hide ( )
inline

Hides the object by adding LV_OBJ_FLAG_HIDDEN.

Returns
Reference to the derived object for method chaining.

◆ show()

template<typename Derived >
Derived & ove::lvgl::ObjectMixin< Derived >::show ( )
inline

Shows the object by removing LV_OBJ_FLAG_HIDDEN.

Returns
Reference to the derived object for method chaining.

◆ visible()

template<typename Derived >
Derived & ove::lvgl::ObjectMixin< Derived >::visible ( bool  v)
inline

Conditionally shows or hides the object.

Parameters
[in]vtrue to show, false to hide.
Returns
Reference to the derived object for method chaining.

◆ add_flag()

template<typename Derived >
Derived & ove::lvgl::ObjectMixin< Derived >::add_flag ( lv_obj_flag_t  f)
inline

Adds one or more object flags.

Parameters
[in]fFlag bitmask (e.g., LV_OBJ_FLAG_CLICKABLE).
Returns
Reference to the derived object for method chaining.

◆ remove_flag()

template<typename Derived >
Derived & ove::lvgl::ObjectMixin< Derived >::remove_flag ( lv_obj_flag_t  f)
inline

Removes one or more object flags.

Parameters
[in]fFlag bitmask to clear.
Returns
Reference to the derived object for method chaining.

◆ add_state()

template<typename Derived >
Derived & ove::lvgl::ObjectMixin< Derived >::add_state ( lv_state_t  s)
inline

Adds one or more object states.

Parameters
[in]sState bitmask (e.g., LV_STATE_CHECKED).
Returns
Reference to the derived object for method chaining.

◆ remove_state()

template<typename Derived >
Derived & ove::lvgl::ObjectMixin< Derived >::remove_state ( lv_state_t  s)
inline

Removes one or more object states.

Parameters
[in]sState bitmask to clear.
Returns
Reference to the derived object for method chaining.

◆ user_data()

template<typename Derived >
Derived & ove::lvgl::ObjectMixin< Derived >::user_data ( void *  data)
inline

Stores an arbitrary user data pointer on the LVGL object.

Parameters
[in]dataOpaque pointer to associate with the object.
Returns
Reference to the derived object for method chaining.

◆ clickable()

template<typename Derived >
Derived & ove::lvgl::ObjectMixin< Derived >::clickable ( bool  on)
inline

Enables or disables click events on the object.

Parameters
[in]ontrue to make the object clickable, false to disable.
Returns
Reference to the derived object for method chaining.

◆ grid_dsc()

template<typename Derived >
Derived & ove::lvgl::ObjectMixin< Derived >::grid_dsc ( const int32_t *  cols,
const int32_t *  rows 
)
inline

Configures this object as a grid container.

Both arrays must terminate with LV_GRID_TEMPLATE_LAST. Track sizes can be fixed pixel values, LV_GRID_CONTENT, or LV_GRID_FR(n) for fractional units. Switches the object's layout to LV_LAYOUT_GRID.

Parameters
[in]colsColumn track descriptor array.
[in]rowsRow track descriptor array.
Returns
Reference to the derived object for method chaining.

◆ get_content_width()

template<typename Derived >
int32_t ove::lvgl::ObjectMixin< Derived >::get_content_width ( ) const
inline
Returns
Inner content width (excludes padding/scrollbars).

◆ get_scroll_bottom()

template<typename Derived >
int32_t ove::lvgl::ObjectMixin< Derived >::get_scroll_bottom ( ) const
inline
Returns
Remaining downward scroll distance.

◆ remove_style_all()

template<typename Derived >
Derived & ove::lvgl::ObjectMixin< Derived >::remove_style_all ( )
inline

Remove all inline and reused styles from this object.

◆ grid_cell()

template<typename Derived >
Derived & ove::lvgl::ObjectMixin< Derived >::grid_cell ( lv_grid_align_t  col_align,
int32_t  col_pos,
int32_t  col_span,
lv_grid_align_t  row_align,
int32_t  row_pos,
int32_t  row_span 
)
inline

Places this object into a cell of its parent grid.

Parameters
[in]col_alignHorizontal cell alignment (LV_GRID_ALIGN_*).
[in]col_posZero-based column index.
[in]col_spanNumber of columns to span (default 1).
[in]row_alignVertical cell alignment (LV_GRID_ALIGN_*).
[in]row_posZero-based row index.
[in]row_spanNumber of rows to span (default 1).
Returns
Reference to the derived object for method chaining.

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