「App:Library:LVGL:docs:Widgets:Base object」の版間の差分

提供: robot-jp wiki
ナビゲーションに移動検索に移動
209行目: 209行目:
 
Typedefs
 
Typedefs
  
typedef uint16_t lv_state_t  
+
<span style="background-color:#e7f2fa;color:#2980b9;">typedef uint16_t lv_state_t </span>
 
:
 
:
  
typedef uint32_t lv_part_t  
+
<span style="background-color:#e7f2fa;color:#2980b9;">typedef uint32_t lv_part_t </span>
 
:
 
:
  
typedef uint32_t lv_obj_flag_t  
+
<span style="background-color:#e7f2fa;color:#2980b9;">typedef uint32_t lv_obj_flag_t </span>
 
:
 
:
  
typedef struct _lv_obj_t lv_obj_t  
+
<span style="background-color:#e7f2fa;color:#2980b9;">typedef struct _lv_obj_t lv_obj_t </span>
 
:
 
:
  
Enums
+
'''Enums'''
  
enum [anonymous]  
+
<span style="background-color:#e7f2fa;color:#2980b9;">enum [anonymous] </span>
 
: Possible states of a widget. OR-ed values are possible  ''Values:''
 
: Possible states of a widget. OR-ed values are possible  ''Values:''
:enumerator LV_STATE_DEFAULT  
+
:<span style="background-color: #eeeeee;">enumerator LV_STATE_DEFAULT </span>
 
::
 
::
:enumerator LV_STATE_CHECKED  
+
:<span style="background-color: #eeeeee;">enumerator LV_STATE_CHECKED </span>
 
::
 
::
:enumerator LV_STATE_FOCUSED  
+
:<span style="background-color: #eeeeee;">enumerator LV_STATE_FOCUSED </span>
 
::
 
::
:enumerator LV_STATE_FOCUS_KEY  
+
:<span style="background-color: #eeeeee;">enumerator LV_STATE_FOCUS_KEY </span>
 
::
 
::
:enumerator LV_STATE_EDITED  
+
:<span style="background-color: #eeeeee;">enumerator LV_STATE_EDITED </span>
 
::
 
::
:enumerator LV_STATE_HOVERED  
+
:<span style="background-color: #eeeeee;">enumerator LV_STATE_HOVERED </span>
 
::
 
::
:enumerator LV_STATE_PRESSED  
+
:<span style="background-color: #eeeeee;">enumerator LV_STATE_PRESSED </span>
 
::
 
::
:enumerator LV_STATE_SCROLLED  
+
:<span style="background-color: #eeeeee;">enumerator LV_STATE_SCROLLED </span>
 
::
 
::
:enumerator LV_STATE_DISABLED  
+
:<span style="background-color: #eeeeee;">enumerator LV_STATE_DISABLED </span>
 
::
 
::
:enumerator LV_STATE_USER_1  
+
:<span style="background-color: #eeeeee;">enumerator LV_STATE_USER_1 </span>
 
::
 
::
:enumerator LV_STATE_USER_2  
+
:<span style="background-color: #eeeeee;">enumerator LV_STATE_USER_2 </span>
 
::
 
::
:enumerator LV_STATE_USER_3  
+
:<span style="background-color: #eeeeee;">enumerator LV_STATE_USER_3 </span>
 
::
 
::
:enumerator LV_STATE_USER_4  
+
:<span style="background-color: #eeeeee;">enumerator LV_STATE_USER_4 </span>
 
::
 
::
:enumerator LV_STATE_ANY  
+
:<span style="background-color: #eeeeee;">enumerator LV_STATE_ANY </span>
 
:: Special value can be used in some functions to target all states
 
:: Special value can be used in some functions to target all states
  
enum [anonymous]  
+
<span style="background-color:#e7f2fa;color:#2980b9;">enum [anonymous] </span>
 
: The possible parts of widgets. The parts can be considered as the internal building block of the widgets. E.g. slider = background + indicator + knob Note every part is used by every widget  ''Values:''
 
: The possible parts of widgets. The parts can be considered as the internal building block of the widgets. E.g. slider = background + indicator + knob Note every part is used by every widget  ''Values:''
:enumerator LV_PART_MAIN  
+
:<span style="background-color: #eeeeee;">enumerator LV_PART_MAIN </span>
 
:: A background like rectangle
 
:: A background like rectangle
:enumerator LV_PART_SCROLLBAR  
+
:<span style="background-color: #eeeeee;">enumerator LV_PART_SCROLLBAR </span>
 
:: The scrollbar(s)
 
:: The scrollbar(s)
:enumerator LV_PART_INDICATOR  
+
:<span style="background-color: #eeeeee;">enumerator LV_PART_INDICATOR </span>
 
:: Indicator, e.g. for slider, bar, switch, or the tick box of the checkbox
 
:: Indicator, e.g. for slider, bar, switch, or the tick box of the checkbox
:enumerator LV_PART_KNOB  
+
:<span style="background-color: #eeeeee;">enumerator LV_PART_KNOB </span>
 
:: Like handle to grab to adjust the value
 
:: Like handle to grab to adjust the value
:enumerator LV_PART_SELECTED  
+
:<span style="background-color: #eeeeee;">enumerator LV_PART_SELECTED </span>
 
:: Indicate the currently selected option or section
 
:: Indicate the currently selected option or section
:enumerator LV_PART_ITEMS  
+
:<span style="background-color: #eeeeee;">enumerator LV_PART_ITEMS </span>
 
:: Used if the widget has multiple similar elements (e.g. table cells)
 
:: Used if the widget has multiple similar elements (e.g. table cells)
:enumerator LV_PART_TICKS  
+
:<span style="background-color: #eeeeee;">enumerator LV_PART_TICKS </span>
 
:: Ticks on scale e.g. for a chart or meter
 
:: Ticks on scale e.g. for a chart or meter
:enumerator LV_PART_CURSOR  
+
:<span style="background-color: #eeeeee;">enumerator LV_PART_CURSOR </span>
 
:: Mark a specific place e.g. for text area's cursor or on a chart
 
:: Mark a specific place e.g. for text area's cursor or on a chart
:enumerator LV_PART_CUSTOM_FIRST  
+
:<span style="background-color: #eeeeee;">enumerator LV_PART_CUSTOM_FIRST </span>
 
:: Extension point for custom widgets
 
:: Extension point for custom widgets
:enumerator LV_PART_ANY  
+
:<span style="background-color: #eeeeee;">enumerator LV_PART_ANY </span>
 
:: Special value can be used in some functions to target all parts
 
:: Special value can be used in some functions to target all parts
  
enum [anonymous]  
+
<span style="background-color:#e7f2fa;color:#2980b9;">enum [anonymous] </span>
 
: On/Off features controlling the object's behavior. OR-ed values are possible  ''Values:''
 
: On/Off features controlling the object's behavior. OR-ed values are possible  ''Values:''
:enumerator LV_OBJ_FLAG_HIDDEN  
+
:<span style="background-color: #eeeeee;">enumerator LV_OBJ_FLAG_HIDDEN </span>
 
:: Make the object hidden. (Like it wasn't there at all)
 
:: Make the object hidden. (Like it wasn't there at all)
:enumerator LV_OBJ_FLAG_CLICKABLE  
+
:<span style="background-color: #eeeeee;">enumerator LV_OBJ_FLAG_CLICKABLE </span>
 
:: Make the object clickable by the input devices
 
:: Make the object clickable by the input devices
:enumerator LV_OBJ_FLAG_CLICK_FOCUSABLE  
+
:<span style="background-color: #eeeeee;">enumerator LV_OBJ_FLAG_CLICK_FOCUSABLE </span>
 
:: Add focused state to the object when clicked
 
:: Add focused state to the object when clicked
:enumerator LV_OBJ_FLAG_CHECKABLE  
+
:<span style="background-color: #eeeeee;">enumerator LV_OBJ_FLAG_CHECKABLE </span>
 
:: Toggle checked state when the object is clicked
 
:: Toggle checked state when the object is clicked
:enumerator LV_OBJ_FLAG_SCROLLABLE  
+
:<span style="background-color: #eeeeee;">enumerator LV_OBJ_FLAG_SCROLLABLE </span>
 
:: Make the object scrollable  
 
:: Make the object scrollable  
:enumerator LV_OBJ_FLAG_SCROLL_ELASTIC  
+
:<span style="background-color: #eeeeee;">enumerator LV_OBJ_FLAG_SCROLL_ELASTIC </span>
 
:: Allow scrolling inside but with slower speed
 
:: Allow scrolling inside but with slower speed
:enumerator LV_OBJ_FLAG_SCROLL_MOMENTUM  
+
:<span style="background-color: #eeeeee;">enumerator LV_OBJ_FLAG_SCROLL_MOMENTUM </span>
 
:: Make the object scroll further when "thrown"
 
:: Make the object scroll further when "thrown"
:enumerator LV_OBJ_FLAG_SCROLL_ONE  
+
:<span style="background-color: #eeeeee;">enumerator LV_OBJ_FLAG_SCROLL_ONE </span>
 
:: Allow scrolling only one snappable children
 
:: Allow scrolling only one snappable children
:enumerator LV_OBJ_FLAG_SCROLL_CHAIN_HOR  
+
:<span style="background-color: #eeeeee;">enumerator LV_OBJ_FLAG_SCROLL_CHAIN_HOR </span>
 
:: Allow propagating the horizontal scroll to a parent
 
:: Allow propagating the horizontal scroll to a parent
:enumerator LV_OBJ_FLAG_SCROLL_CHAIN_VER  
+
:<span style="background-color: #eeeeee;">enumerator LV_OBJ_FLAG_SCROLL_CHAIN_VER </span>
 
:: Allow propagating the vertical scroll to a parent
 
:: Allow propagating the vertical scroll to a parent
:enumerator LV_OBJ_FLAG_SCROLL_CHAIN  
+
:<span style="background-color: #eeeeee;">enumerator LV_OBJ_FLAG_SCROLL_CHAIN </span>
 
::
 
::
:enumerator LV_OBJ_FLAG_SCROLL_ON_FOCUS  
+
:<span style="background-color: #eeeeee;">enumerator LV_OBJ_FLAG_SCROLL_ON_FOCUS </span>
 
:: Automatically scroll object to make it visible when focused
 
:: Automatically scroll object to make it visible when focused
:enumerator LV_OBJ_FLAG_SCROLL_WITH_ARROW  
+
:<span style="background-color: #eeeeee;">enumerator LV_OBJ_FLAG_SCROLL_WITH_ARROW </span>
 
:: Allow scrolling the focused object with arrow keys
 
:: Allow scrolling the focused object with arrow keys
:enumerator LV_OBJ_FLAG_SNAPPABLE  
+
:<span style="background-color: #eeeeee;">enumerator LV_OBJ_FLAG_SNAPPABLE </span>
 
:: If scroll snap is enabled on the parent it can snap to this object
 
:: If scroll snap is enabled on the parent it can snap to this object
:enumerator LV_OBJ_FLAG_PRESS_LOCK  
+
:<span style="background-color: #eeeeee;">enumerator LV_OBJ_FLAG_PRESS_LOCK </span>
 
:: Keep the object pressed even if the press slid from the object
 
:: Keep the object pressed even if the press slid from the object
:enumerator LV_OBJ_FLAG_EVENT_BUBBLE  
+
:<span style="background-color: #eeeeee;">enumerator LV_OBJ_FLAG_EVENT_BUBBLE </span>
 
:: Propagate the events to the parent too
 
:: Propagate the events to the parent too
:enumerator LV_OBJ_FLAG_GESTURE_BUBBLE  
+
:<span style="background-color: #eeeeee;">enumerator LV_OBJ_FLAG_GESTURE_BUBBLE </span>
 
:: Propagate the gestures to the parent
 
:: Propagate the gestures to the parent
:enumerator LV_OBJ_FLAG_ADV_HITTEST  
+
:<span style="background-color: #eeeeee;">enumerator LV_OBJ_FLAG_ADV_HITTEST </span>
 
:: Allow performing more accurate hit (click) test. E.g. consider rounded corners.
 
:: Allow performing more accurate hit (click) test. E.g. consider rounded corners.
:enumerator LV_OBJ_FLAG_IGNORE_LAYOUT  
+
:<span style="background-color: #eeeeee;">enumerator LV_OBJ_FLAG_IGNORE_LAYOUT </span>
 
:: Make the object position-able by the layouts
 
:: Make the object position-able by the layouts
:enumerator LV_OBJ_FLAG_FLOATING  
+
:<span style="background-color: #eeeeee;">enumerator LV_OBJ_FLAG_FLOATING </span>
 
:: Do not scroll the object when the parent scrolls and ignore layout
 
:: Do not scroll the object when the parent scrolls and ignore layout
:enumerator LV_OBJ_FLAG_OVERFLOW_VISIBLE  
+
:<span style="background-color: #eeeeee;">enumerator LV_OBJ_FLAG_OVERFLOW_VISIBLE </span>
 
:: Do not clip the children's content to the parent's boundary
 
:: Do not clip the children's content to the parent's boundary
:enumerator LV_OBJ_FLAG_LAYOUT_1  
+
:<span style="background-color: #eeeeee;">enumerator LV_OBJ_FLAG_LAYOUT_1 </span>
 
:: Custom flag, free to use by layouts
 
:: Custom flag, free to use by layouts
:enumerator LV_OBJ_FLAG_LAYOUT_2  
+
:<span style="background-color: #eeeeee;">enumerator LV_OBJ_FLAG_LAYOUT_2 </span>
 
:: Custom flag, free to use by layouts
 
:: Custom flag, free to use by layouts
:enumerator LV_OBJ_FLAG_WIDGET_1  
+
:<span style="background-color: #eeeeee;">enumerator LV_OBJ_FLAG_WIDGET_1 </span>
 
:: Custom flag, free to use by widget
 
:: Custom flag, free to use by widget
:enumerator LV_OBJ_FLAG_WIDGET_2  
+
:<span style="background-color: #eeeeee;">enumerator LV_OBJ_FLAG_WIDGET_2 </span>
 
:: Custom flag, free to use by widget
 
:: Custom flag, free to use by widget
:enumerator LV_OBJ_FLAG_USER_1  
+
:<span style="background-color: #eeeeee;">enumerator LV_OBJ_FLAG_USER_1 </span>
 
:: Custom flag, free to use by user
 
:: Custom flag, free to use by user
:enumerator LV_OBJ_FLAG_USER_2  
+
:<span style="background-color: #eeeeee;">enumerator LV_OBJ_FLAG_USER_2 </span>
 
:: Custom flag, free to use by user
 
:: Custom flag, free to use by user
:enumerator LV_OBJ_FLAG_USER_3  
+
:<span style="background-color: #eeeeee;">enumerator LV_OBJ_FLAG_USER_3 </span>
 
:: Custom flag, free to use by user
 
:: Custom flag, free to use by user
:enumerator LV_OBJ_FLAG_USER_4  
+
:<span style="background-color: #eeeeee;">enumerator LV_OBJ_FLAG_USER_4 </span>
 
:: Custom flag, free to use by user
 
:: Custom flag, free to use by user
  
enum lv_obj_draw_part_type_t  
+
<span style="background-color:#e7f2fa;color:#2980b9;">enum lv_obj_draw_part_type_t </span>
 
: <code style="color: #bb0000;">type</code> field in <code style="color: #bb0000;">lv_obj_dra</code><code style="color: #bb0000;">w_part_dsc_t</code> if <code style="color: #bb0000;">class_p = lv_obj_class</code> Used in <code style="color: #bb0000;">LV_EVENT_DRAW_PART_BEGIN</code> and <code style="color: #bb0000;">LV_EVENT_DRAW_PART_END</code>  ''Values:''
 
: <code style="color: #bb0000;">type</code> field in <code style="color: #bb0000;">lv_obj_dra</code><code style="color: #bb0000;">w_part_dsc_t</code> if <code style="color: #bb0000;">class_p = lv_obj_class</code> Used in <code style="color: #bb0000;">LV_EVENT_DRAW_PART_BEGIN</code> and <code style="color: #bb0000;">LV_EVENT_DRAW_PART_END</code>  ''Values:''
:enumerator LV_OBJ_DRAW_PART_RECTANGLE  
+
:<span style="background-color: #eeeeee;">enumerator LV_OBJ_DRAW_PART_RECTANGLE </span>
 
:: The main rectangle
 
:: The main rectangle
:enumerator LV_OBJ_DRAW_PART_BORDER_POST  
+
:<span style="background-color: #eeeeee;">enumerator LV_OBJ_DRAW_PART_BORDER_POST </span>
 
:: The border if style_border_post = true
 
:: The border if style_border_post = true
:enumerator LV_OBJ_DRAW_PART_SCROLLBAR  
+
:<span style="background-color: #eeeeee;">enumerator LV_OBJ_DRAW_PART_SCROLLBAR </span>
 
:: The scrollbar
 
:: The scrollbar
  
 
Functions
 
Functions
  
void lv_init(void)  
+
<span style="background-color:#e7f2fa;color:#2980b9;">void lv_init(void) </span>
 
: Initialize LVGL library. Should be called before any other LVGL related function.
 
: Initialize LVGL library. Should be called before any other LVGL related function.
  
void lv_deinit(void)  
+
<span style="background-color:#e7f2fa;color:#2980b9;">void lv_deinit(void) </span>
 
: Deinit the 'lv' library Currently only implemented when not using custom allocators, or GC is enabled.
 
: Deinit the 'lv' library Currently only implemented when not using custom allocators, or GC is enabled.
  
bool lv_is_initialized(void)  
+
<span style="background-color:#e7f2fa;color:#2980b9;">bool lv_is_initialized(void) </span>
 
: Returns whether the 'lv' library is currently initialized
 
: Returns whether the 'lv' library is currently initialized
  
lv_obj_t *lv_obj_create(lv_obj_t *parent)  
+
<span style="background-color:#e7f2fa;color:#2980b9;">lv_obj_t *lv_obj_create(lv_obj_t *parent) </span>
 
: Create a base object (a rectangle)
 
: Create a base object (a rectangle)
 
:Parameters
 
:Parameters
365行目: 365行目:
 
:: pointer to the new object
 
:: pointer to the new object
  
void lv_obj_add_flag(lv_obj_t *obj, lv_obj_flag_t f)  
+
<span style="background-color:#e7f2fa;color:#2980b9;">void lv_obj_add_flag(lv_obj_t *obj, lv_obj_flag_t f) </span>
 
: Set one or more flags
 
: Set one or more flags
 
:Parameters
 
:Parameters
371行目: 371行目:
 
::* f -- R-ed values from <code style="color: #bb0000;">lv_obj_flag_t</code> to set.
 
::* f -- R-ed values from <code style="color: #bb0000;">lv_obj_flag_t</code> to set.
  
void lv_obj_clear_flag(lv_obj_t *obj, lv_obj_flag_t f)  
+
<span style="background-color:#e7f2fa;color:#2980b9;">void lv_obj_clear_flag(lv_obj_t *obj, lv_obj_flag_t f) </span>
 
: Clear one or more flags
 
: Clear one or more flags
 
:Parameters
 
:Parameters
377行目: 377行目:
 
::* f -- OR-ed values from <code style="color: #bb0000;">lv_obj_flag_t</code> to set.
 
::* f -- OR-ed values from <code style="color: #bb0000;">lv_obj_flag_t</code> to set.
  
void lv_obj_add_state(lv_obj_t *obj, lv_state_t state)  
+
<span style="background-color:#e7f2fa;color:#2980b9;">void lv_obj_add_state(lv_obj_t *obj, lv_state_t state) </span>
 
: Add one or more states to the object. The other state bits will remain unchanged. If specified in the styles, transition animation will be started from the previous state to the current.
 
: Add one or more states to the object. The other state bits will remain unchanged. If specified in the styles, transition animation will be started from the previous state to the current.
 
:Parameters
 
:Parameters
383行目: 383行目:
 
::* state -- the states to add. E.g <code style="color: #bb0000;">LV_STATE_PRESSED | LV_STATE_FOCUSED</code>
 
::* state -- the states to add. E.g <code style="color: #bb0000;">LV_STATE_PRESSED | LV_STATE_FOCUSED</code>
  
void lv_obj_clear_state(lv_obj_t *obj, lv_state_t state)  
+
<span style="background-color:#e7f2fa;color:#2980b9;">void lv_obj_clear_state(lv_obj_t *obj, lv_state_t state) </span>
 
: Remove one or more states to the object. The other state bits will remain unchanged. If specified in the styles, transition animation will be started from the previous state to the current.
 
: Remove one or more states to the object. The other state bits will remain unchanged. If specified in the styles, transition animation will be started from the previous state to the current.
 
:Parameters
 
:Parameters
389行目: 389行目:
 
::* state -- the states to add. E.g <code style="color: #bb0000;">LV_STATE_PRESSED | LV_STATE_FOCUSED</code>
 
::* state -- the states to add. E.g <code style="color: #bb0000;">LV_STATE_PRESSED | LV_STATE_FOCUSED</code>
  
static inline void lv_obj_set_user_data(lv_obj_t *obj, void *user_data)  
+
<span style="background-color:#e7f2fa;color:#2980b9;">static inline void lv_obj_set_user_data(lv_obj_t *obj, void *user_data) </span>
 
: Set the user_data field of the object
 
: Set the user_data field of the object
 
:Parameters
 
:Parameters
395行目: 395行目:
 
::* user_data -- pointer to the new user_data.
 
::* user_data -- pointer to the new user_data.
  
bool lv_obj_has_flag(const lv_obj_t *obj, lv_obj_flag_t f)  
+
<span style="background-color:#e7f2fa;color:#2980b9;">bool lv_obj_has_flag(const lv_obj_t *obj, lv_obj_flag_t f) </span>
 
: Check if a given flag or all the given flags are set on an object.
 
: Check if a given flag or all the given flags are set on an object.
 
:Parameters
 
:Parameters
403行目: 403行目:
 
:: true: all flags are setfalse: not all flags are set
 
:: true: all flags are setfalse: not all flags are set
  
bool lv_obj_has_flag_any(const lv_obj_t *obj, lv_obj_flag_t f)  
+
<span style="background-color:#e7f2fa;color:#2980b9;">bool lv_obj_has_flag_any(const lv_obj_t *obj, lv_obj_flag_t f) </span>
 
: Check if a given flag or any of the flags are set on an object.
 
: Check if a given flag or any of the flags are set on an object.
 
:Parameters
 
:Parameters
411行目: 411行目:
 
:: true: at lest one flag flag is setfalse: none of the flags are set
 
:: true: at lest one flag flag is setfalse: none of the flags are set
  
lv_state_t lv_obj_get_state(const lv_obj_t *obj)  
+
<span style="background-color:#e7f2fa;color:#2980b9;">lv_state_t lv_obj_get_state(const lv_obj_t *obj) </span>
 
: Get the state of an object
 
: Get the state of an object
 
:Parameters
 
:Parameters
418行目: 418行目:
 
:: the state (OR-ed values from <code style="color: #bb0000;">lv_state_t</code>)
 
:: the state (OR-ed values from <code style="color: #bb0000;">lv_state_t</code>)
  
bool lv_obj_has_state(const lv_obj_t *obj, lv_state_t state)  
+
<span style="background-color:#e7f2fa;color:#2980b9;">bool lv_obj_has_state(const lv_obj_t *obj, lv_state_t state) </span>
 
: Check if the object is in a given state or not.
 
: Check if the object is in a given state or not.
 
:Parameters
 
:Parameters
426行目: 426行目:
 
:: true: <code style="color: #bb0000;">obj</code> is in <code style="color: #bb0000;">state</code>false: <code style="color: #bb0000;">obj</code> is not in <code style="color: #bb0000;">state</code>
 
:: true: <code style="color: #bb0000;">obj</code> is in <code style="color: #bb0000;">state</code>false: <code style="color: #bb0000;">obj</code> is not in <code style="color: #bb0000;">state</code>
  
void *lv_obj_get_group(const lv_obj_t *obj)  
+
<span style="background-color:#e7f2fa;color:#2980b9;">void *lv_obj_get_group(const lv_obj_t *obj) </span>
 
: Get the group of the object
 
: Get the group of the object
 
:Parameters
 
:Parameters
433行目: 433行目:
 
:: the pointer to group of the object
 
:: the pointer to group of the object
  
static inline void *lv_obj_get_user_data(lv_obj_t *obj)  
+
<span style="background-color:#e7f2fa;color:#2980b9;">static inline void *lv_obj_get_user_data(lv_obj_t *obj) </span>
 
: Get the user_data field of the object
 
: Get the user_data field of the object
 
:Parameters
 
:Parameters
440行目: 440行目:
 
:: the pointer to the user_data of the object
 
:: the pointer to the user_data of the object
  
void lv_obj_allocate_spec_attr(lv_obj_t *obj)  
+
<span style="background-color:#e7f2fa;color:#2980b9;">void lv_obj_allocate_spec_attr(lv_obj_t *obj) </span>
 
: Allocate special data for an object if not allocated yet.
 
: Allocate special data for an object if not allocated yet.
 
:Parameters
 
:Parameters
 
:: obj -- pointer to an object
 
:: obj -- pointer to an object
  
bool lv_obj_check_type(const lv_obj_t *obj, const lv_obj_class_t *class_p)  
+
<span style="background-color:#e7f2fa;color:#2980b9;">bool lv_obj_check_type(const lv_obj_t *obj, const lv_obj_class_t *class_p) </span>
 
: Check the type of obj.
 
: Check the type of obj.
 
:Parameters
 
:Parameters
453行目: 453行目:
 
:: true: <code style="color: #bb0000;">class_p</code> is the <code style="color: #bb0000;">obj</code> class.
 
:: true: <code style="color: #bb0000;">class_p</code> is the <code style="color: #bb0000;">obj</code> class.
  
bool lv_obj_has_class(const lv_obj_t *obj, const lv_obj_class_t *class_p)  
+
<span style="background-color:#e7f2fa;color:#2980b9;">bool lv_obj_has_class(const lv_obj_t *obj, const lv_obj_class_t *class_p) </span>
 
: Check if any object has a given class (type). It checks the ancestor classes too.
 
: Check if any object has a given class (type). It checks the ancestor classes too.
 
:Parameters
 
:Parameters
461行目: 461行目:
 
:: true: <code style="color: #bb0000;">obj</code> has the given class
 
:: true: <code style="color: #bb0000;">obj</code> has the given class
  
const lv_obj_class_t *lv_obj_get_class(const lv_obj_t *obj)  
+
<span style="background-color:#e7f2fa;color:#2980b9;">const lv_obj_class_t *lv_obj_get_class(const lv_obj_t *obj) </span>
 
: Get the class (type) of the object
 
: Get the class (type) of the object
 
:Parameters
 
:Parameters
468行目: 468行目:
 
:: the class (type) of the object
 
:: the class (type) of the object
  
bool lv_obj_is_valid(const lv_obj_t *obj)  
+
<span style="background-color:#e7f2fa;color:#2980b9;">bool lv_obj_is_valid(const lv_obj_t *obj) </span>
 
: Check if any object is still "alive".
 
: Check if any object is still "alive".
 
:Parameters
 
:Parameters
475行目: 475行目:
 
:: true: valid
 
:: true: valid
  
static inline lv_coord_t lv_obj_dpx(const lv_obj_t *obj, lv_coord_t n)  
+
<span style="background-color:#e7f2fa;color:#2980b9;">static inline lv_coord_t lv_obj_dpx(const lv_obj_t *obj, lv_coord_t n) </span>
 
: Scale the given number of pixels (a distance or size) relative to a 160 DPI display considering the DPI of the <code style="color: #bb0000;">obj</code>'s display. It ensures that e.g. <code style="color: #bb0000;">lv_dpx(100)</code> will have the same physical size regardless to the DPI of the display.
 
: Scale the given number of pixels (a distance or size) relative to a 160 DPI display considering the DPI of the <code style="color: #bb0000;">obj</code>'s display. It ensures that e.g. <code style="color: #bb0000;">lv_dpx(100)</code> will have the same physical size regardless to the DPI of the display.
 
:Parameters
 
:Parameters
485行目: 485行目:
 
Variables
 
Variables
  
const lv_obj_class_t lv_obj_class  
+
<span style="background-color:#e7f2fa;color:#2980b9;">const lv_obj_class_t lv_obj_class </span>
 
: Make the base object's class publicly available.
 
: Make the base object's class publicly available.
  
struct _lv_obj_spec_attr_t  
+
<span style="background-color:#e7f2fa;color:#2980b9;">struct _lv_obj_spec_attr_t </span>
 
: ''#include <lv_obj.h>'' Special, rarely used attributes. They are allocated automatically if any elements is set.  Public Members
 
: ''#include <lv_obj.h>'' Special, rarely used attributes. They are allocated automatically if any elements is set.  Public Members
:struct _lv_obj_t **children  
+
:<span style="background-color: #eeeeee;">struct _lv_obj_t **children </span>
 
:: Store the pointer of the children in an array.
 
:: Store the pointer of the children in an array.
:uint32_t child_cnt  
+
:<span style="background-color: #eeeeee;">uint32_t child_cnt </span>
 
:: Number of children
 
:: Number of children
:lv_group_t *group_p  
+
:<span style="background-color: #eeeeee;">lv_group_t *group_p </span>
 
::
 
::
:struct _lv_event_dsc_t *event_dsc  
+
:<span style="background-color: #eeeeee;">struct _lv_event_dsc_t *event_dsc </span>
 
:: Dynamically allocated event callback and user data array
 
:: Dynamically allocated event callback and user data array
:lv_point_t scroll  
+
:<span style="background-color: #eeeeee;">lv_point_t scroll </span>
 
:: The current X/Y scroll offset
 
:: The current X/Y scroll offset
:lv_coord_t ext_click_pad  
+
:<span style="background-color: #eeeeee;">lv_coord_t ext_click_pad </span>
 
:: Extra click padding in all direction
 
:: Extra click padding in all direction
:lv_coord_t ext_draw_size  
+
:<span style="background-color: #eeeeee;">lv_coord_t ext_draw_size </span>
 
:: EXTend the size in every direction for drawing.
 
:: EXTend the size in every direction for drawing.
:lv_scrollbar_mode_t scrollbar_mode  
+
:<span style="background-color: #eeeeee;">lv_scrollbar_mode_t scrollbar_mode </span>
 
:: How to display scrollbars
 
:: How to display scrollbars
:lv_scroll_snap_t scroll_snap_x  
+
:<span style="background-color: #eeeeee;">lv_scroll_snap_t scroll_snap_x </span>
 
:: Where to align the snappable children horizontally
 
:: Where to align the snappable children horizontally
:lv_scroll_snap_t scroll_snap_y  
+
:<span style="background-color: #eeeeee;">lv_scroll_snap_t scroll_snap_y </span>
 
:: Where to align the snappable children vertically
 
:: Where to align the snappable children vertically
:lv_dir_t scroll_dir  
+
:<span style="background-color: #eeeeee;">lv_dir_t scroll_dir </span>
 
:: The allowed scroll direction(s)
 
:: The allowed scroll direction(s)
:uint8_t event_dsc_cnt  
+
:<span style="background-color: #eeeeee;">uint8_t event_dsc_cnt </span>
 
:: Number of event callbacks stored in <code style="color: #bb0000;">event_dsc</code> array
 
:: Number of event callbacks stored in <code style="color: #bb0000;">event_dsc</code> array
  
struct _lv_obj_t  
+
 
 +
<span style="background-color:#e7f2fa;color:#2980b9;">struct _lv_obj_t </span>
 
: Public Members
 
: Public Members
:const lv_obj_class_t *class_p  
+
:<span style="background-color: #eeeeee;">const lv_obj_class_t *class_p </span>
 
::
 
::
:struct _lv_obj_t *parent  
+
:<span style="background-color: #eeeeee;">struct _lv_obj_t *parent </span>
 
::
 
::
:_lv_obj_spec_attr_t *spec_attr  
+
:<span style="background-color: #eeeeee;">_lv_obj_spec_attr_t *spec_attr </span>
 
::
 
::
:_lv_obj_style_t *styles  
+
:<span style="background-color: #eeeeee;">_lv_obj_style_t *styles </span>
 
::
 
::
:void *user_data  
+
:<span style="background-color: #eeeeee;">void *user_data </span>
 
::
 
::
:lv_area_t coords  
+
:<span style="background-color: #eeeeee;">lv_area_t coords </span>
 
::
 
::
:lv_obj_flag_t flags  
+
:<span style="background-color: #eeeeee;">lv_obj_flag_t flags </span>
 
::
 
::
:lv_state_t state  
+
:<span style="background-color: #eeeeee;">lv_state_t state </span>
 
::
 
::
:uint16_t layout_inv  
+
:<span style="background-color: #eeeeee;">uint16_t layout_inv </span>
 
::
 
::
:uint16_t scr_layout_inv  
+
:<span style="background-color: #eeeeee;">uint16_t scr_layout_inv </span>
 
::
 
::
:uint16_t skip_trans  
+
:<span style="background-color: #eeeeee;">uint16_t skip_trans </span>
 
::
 
::
:uint16_t style_cnt  
+
:<span style="background-color: #eeeeee;">uint16_t style_cnt </span>
 
::
 
::
:uint16_t h_layout  
+
:<span style="background-color: #eeeeee;">uint16_t h_layout </span>
 
::
 
::
:uint16_t w_layout
+
:<span style="background-color: #eeeeee;">uint16_t w_layout</span>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
  
  
  
 
:[[App:Library:LVGL#Widgets|戻る : Previous]]
 
:[[App:Library:LVGL#Widgets|戻る : Previous]]

2022年6月28日 (火) 17:16時点における版

https://docs.lvgl.io/8.2/widgets/index.html

英文 自動翻訳


Base object (lv_obj)

Overview

The 'Base Object' implements the basic properties of widgets on a screen, such as:

  • coordinates
  • parent object
  • children
  • contains the styles
  • attributes like Clickable, Scrollable, etc.


In object-oriented thinking, it is the base class from which all other objects in LVGL are inherited.

The functions and functionalities of the Base object can be used with other widgets too. For example lv_obj_set_width(slider, 100)


The Base object can be directly used as a simple widget: it's nothing more than a rectangle. In HTML terms, think of it as a <div>.

Coordinates

Only a small subset of coordinate settings is described here. To see all the features of LVGL (padding, coordinates in styles, layouts, etc) visit the Coordinates page.

Size

The object size can be modified on individual axes with lv_obj_set_width(obj, new_width) and lv_obj_set_height(obj, new_height), or both axes can be modified at the same time with lv_obj_set_size(obj, new_width, new_height).

Position

You can set the position relative to the parent with lv_obj_set_x(obj, new_x) and lv_obj_set_y(obj, new_y), or both axes at the same time with lv_obj_set_pos(obj, new_x, new_y).

Alignment

You can align the object on its parent with lv_obj_set_align(obj, LV_ALIGN_...). After this every x and y setting will be relative to the set alignment mode. For example, this will shift the object by 10;20 px from the center of its parent:

 
 lv_obj_set_align(obj, LV_ALIGN_CENTER);
 lv_obj_set_pos(obj, 10, 20);
 
 //Or in one function
 lv_obj_align(obj, LV_ALIGN_CENTER, 10, 20);

To align one object to another use: lv_obj_align_to(obj_to_align, obj_referece, LV_ALIGN_..., x, y)


For example, to align a text below an image: lv_obj_align_to(text, image, LV_ALIGN_OUT_BOTTOM_MID, 0, 10).

The following align types exist: LVGL docs widgets obj 01.png


Parents and children

You can set a new parent for an object with lv_obj_set_parent(obj, new_parent). To get the current parent, use lv_obj_get_parent(obj).


To get a specific child of a parent use lv_obj_get_child(parent, idx). Some examples for idx:

  • 0 get the child created first
  • 1 get the child created second
  • -1 get the child created last


The children can be iterated lke this:

 uint32_t i;
 for(i = 0i < lv_obj_get_child_cnt(parent)i++) {
   lv_obj_t * child = lv_obj_get_child(parent, i);
   /*Do something with child*/
 }

lv_obj_get_index(obj) returns the index of the object in its parent. It is equivalent to the number of younger children in the parent.


You can bring an object to the foreground or send it to the background with lv_obj_move_foreground(obj) and lv_obj_move_background(obj).

You can change the index of an object in its parent using lv_obj_move_to_index(obj, index).


You can swap the position of two objects with lv_obj_swap(obj1, obj2).

Display and Screens

At the highest level of the LVGL object hierarchy is the display which represents the driver for a display device (physical display or simulator). A display can have one or more screens associated with it. Each screen contains a hierarchy of objects for graphical widgets representing a layout that covers the entire display.


When you have created a screen like lv_obj_t * screen = lv_obj_create(NULL), you can make it active with lv_scr_load(screen). The lv_scr_act() function gives you a pointer to the active screen.

If you have multiple displays, it's important to know that the screen functions operate on the most recently created display or the one explicitly selected with lv_disp_set_default.


To get an object's screen use the lv_obj_get_screen(obj) function.

Events

To set an event callback for an object, use lv_obj_add_event_cb(obj, event_cb, LV_EVENT_..., user_data),


To manually send an event to an object, use lv_event_send(obj, LV_EVENT_..., param)

Read the Event overview to learn more about events.

Styles

Be sure to read the Style overview. Here only the most essential functions are described.


A new style can be added to an object with the lv_obj_add_style(obj, &new_style, selector) function. selector is an ORed combination of part and state(s). E.g. LV_PART_SCROLLBAR | LV_STATE_PRESSED.

The base objects use LV_PART_MAIN style properties and LV_PART_SCROLLBAR with the typical background style properties.

Flags

There are some attributes which can be enabled/disabled by lv_obj_add/clear_flag(obj, LV_OBJ_FLAG_...):

  • LV_OBJ_FLAG_HIDDEN Make the object hidden. (Like it wasn't there at all)
  • LV_OBJ_FLAG_CLICKABLE Make the object clickable by input devices
  • LV_OBJ_FLAG_CLICK_FOCUSABLE Add focused state to the object when clicked
  • LV_OBJ_FLAG_CHECKABLE Toggle checked state when the object is clicked
  • LV_OBJ_FLAG_SCROLLABLE Make the object scrollable
  • LV_OBJ_FLAG_SCROLL_ELASTIC Allow scrolling inside but with slower speed
  • LV_OBJ_FLAG_SCROLL_MOMENTUM Make the object scroll further when "thrown"
  • LV_OBJ_FLAG_SCROLL_ONE Allow scrolling only one snappable children
  • LV_OBJ_FLAG_SCROLL_CHAIN_HOR Allow propagating the horizontal scroll to a parent
  • LV_OBJ_FLAG_SCROLL_CHAIN_VER Allow propagating the vertical scroll to a parent
  • LV_OBJ_FLAG_SCROLL_CHAIN Simple packaging for (LV_OBJ_FLAG_SCROLL_CHAIN_HOR | LV_OBJ_FLAG_SCROLL_CHAIN_VER)
  • LV_OBJ_FLAG_SCROLL_ON_FOCUS Automatically scroll object to make it visible when focused
  • LV_OBJ_FLAG_SCROLL_WITH_ARROW Allow scrolling the focused object with arrow keys
  • LV_OBJ_FLAG_SNAPPABLE If scroll snap is enabled on the parent it can snap to this object
  • LV_OBJ_FLAG_PRESS_LOCK Keep the object pressed even if the press slid from the object
  • LV_OBJ_FLAG_EVENT_BUBBLE Propagate the events to the parent too
  • LV_OBJ_FLAG_GESTURE_BUBBLE Propagate the gestures to the parent
  • LV_OBJ_FLAG_ADV_HITTEST Allow performing more accurate hit (click) test. E.g. accounting for rounded corners
  • LV_OBJ_FLAG_IGNORE_LAYOUT Make the object positionable by the layouts
  • LV_OBJ_FLAG_FLOATING Do not scroll the object when the parent scrolls and ignore layout
  • LV_OBJ_FLAG_OVERFLOW_VISIBLE Do not clip the children's content to the parent's boundary
  • LV_OBJ_FLAG_LAYOUT_1 Custom flag, free to use by layouts
  • LV_OBJ_FLAG_LAYOUT_2 Custom flag, free to use by layouts
  • LV_OBJ_FLAG_WIDGET_1 Custom flag, free to use by widget
  • LV_OBJ_FLAG_WIDGET_2 Custom flag, free to use by widget
  • LV_OBJ_FLAG_USER_1 Custom flag, free to use by user
  • LV_OBJ_FLAG_USER_2 Custom flag, free to use by user
  • LV_OBJ_FLAG_USER_3 Custom flag, free to use by user
  • LV_OBJ_FLAG_USER_4 Custom flag, free to use by user


Some examples:

 /*Hide on object*/
 lv_obj_add_flag(obj, LV_OBJ_FLAG_HIDDEN);
 
 /*Make an object non-clickable*/
 lv_obj_clear_flag(obj, LV_OBJ_FLAG_CLICKABLE);

Groups

Read the Input devices overview to learn more about Groups.


Objects are added to a group with lv_group_add_obj(group, obj), and you can use lv_obj_get_group(obj) to see which group an object belongs to.

lv_obj_is_focused(obj) returns if the object is currently focused on its group or not. If the object is not added to a group, false will be returned.


Extended click area

By default, the objects can be clicked only within their bounding area. However, this can be extended with lv_obj_set_ext_click_area(obj, size).

Events

  • LV_EVENT_VALUE_CHANGED when the LV_OBJ_FLAG_CHECKABLE flag is enabled and the object clicked (on transition to/from the checked state)
  • LV_EVENT_DRAW_PART_BEGIN and LV_EVENT_DRAW_PART_END is sent for the following types:
    • LV_OBJ_DRAW_PART_RECTANGLE The main rectangle
      • part: LV_PART_MAIN
      • rect_dsc
      • draw_area: the area of the rectangle
    • LV_OBJ_DRAW_PART_BORDER_POST The border if the border_post style property is true
      • part: LV_PART_MAIN
      • rect_dsc
      • draw_area: the area of the rectangle
    • LV_OBJ_DRAW_PART_SCROLLBAR the scrollbars
      • part: LV_PART_SCROLLBAR
      • rect_dsc
      • draw_area: the area of the rectangle

Learn more about Events.

Keys

If LV_OBJ_FLAG_CHECKABLE is enabled, LV_KEY_RIGHT and LV_KEY_UP make the object checked, and LV_KEY_LEFT and LV_KEY_DOWN make it unchecked.

If LV_OBJ_FLAG_SCROLLABLE is enabled, but the object is not editable (as declared by the widget class), the arrow keys (LV_KEY_UP, LV_KEY_DOWN, LV_KEY_LEFT, LV_KEY_RIGHT) scroll the object. If the object can only scroll vertically, LV_KEY_LEFT and LV_KEY_RIGHT will scroll up/down instead, making it compatible with an encoder input device. See Input devices overview for more on encoder behaviors and the edit mode.

Learn more about Keys.

Example

Base objects with custom styles

LVGL docs example 042.png


Make an object draggable

LVGL docs example 043.png



API

Typedefs

typedef uint16_t lv_state_t

typedef uint32_t lv_part_t

typedef uint32_t lv_obj_flag_t

typedef struct _lv_obj_t lv_obj_t

Enums

enum [anonymous]

Possible states of a widget. OR-ed values are possible Values:
enumerator LV_STATE_DEFAULT
enumerator LV_STATE_CHECKED
enumerator LV_STATE_FOCUSED
enumerator LV_STATE_FOCUS_KEY
enumerator LV_STATE_EDITED
enumerator LV_STATE_HOVERED
enumerator LV_STATE_PRESSED
enumerator LV_STATE_SCROLLED
enumerator LV_STATE_DISABLED
enumerator LV_STATE_USER_1
enumerator LV_STATE_USER_2
enumerator LV_STATE_USER_3
enumerator LV_STATE_USER_4
enumerator LV_STATE_ANY
Special value can be used in some functions to target all states

enum [anonymous]

The possible parts of widgets. The parts can be considered as the internal building block of the widgets. E.g. slider = background + indicator + knob Note every part is used by every widget Values:
enumerator LV_PART_MAIN
A background like rectangle
enumerator LV_PART_SCROLLBAR
The scrollbar(s)
enumerator LV_PART_INDICATOR
Indicator, e.g. for slider, bar, switch, or the tick box of the checkbox
enumerator LV_PART_KNOB
Like handle to grab to adjust the value
enumerator LV_PART_SELECTED
Indicate the currently selected option or section
enumerator LV_PART_ITEMS
Used if the widget has multiple similar elements (e.g. table cells)
enumerator LV_PART_TICKS
Ticks on scale e.g. for a chart or meter
enumerator LV_PART_CURSOR
Mark a specific place e.g. for text area's cursor or on a chart
enumerator LV_PART_CUSTOM_FIRST
Extension point for custom widgets
enumerator LV_PART_ANY
Special value can be used in some functions to target all parts

enum [anonymous]

On/Off features controlling the object's behavior. OR-ed values are possible Values:
enumerator LV_OBJ_FLAG_HIDDEN
Make the object hidden. (Like it wasn't there at all)
enumerator LV_OBJ_FLAG_CLICKABLE
Make the object clickable by the input devices
enumerator LV_OBJ_FLAG_CLICK_FOCUSABLE
Add focused state to the object when clicked
enumerator LV_OBJ_FLAG_CHECKABLE
Toggle checked state when the object is clicked
enumerator LV_OBJ_FLAG_SCROLLABLE
Make the object scrollable
enumerator LV_OBJ_FLAG_SCROLL_ELASTIC
Allow scrolling inside but with slower speed
enumerator LV_OBJ_FLAG_SCROLL_MOMENTUM
Make the object scroll further when "thrown"
enumerator LV_OBJ_FLAG_SCROLL_ONE
Allow scrolling only one snappable children
enumerator LV_OBJ_FLAG_SCROLL_CHAIN_HOR
Allow propagating the horizontal scroll to a parent
enumerator LV_OBJ_FLAG_SCROLL_CHAIN_VER
Allow propagating the vertical scroll to a parent
enumerator LV_OBJ_FLAG_SCROLL_CHAIN
enumerator LV_OBJ_FLAG_SCROLL_ON_FOCUS
Automatically scroll object to make it visible when focused
enumerator LV_OBJ_FLAG_SCROLL_WITH_ARROW
Allow scrolling the focused object with arrow keys
enumerator LV_OBJ_FLAG_SNAPPABLE
If scroll snap is enabled on the parent it can snap to this object
enumerator LV_OBJ_FLAG_PRESS_LOCK
Keep the object pressed even if the press slid from the object
enumerator LV_OBJ_FLAG_EVENT_BUBBLE
Propagate the events to the parent too
enumerator LV_OBJ_FLAG_GESTURE_BUBBLE
Propagate the gestures to the parent
enumerator LV_OBJ_FLAG_ADV_HITTEST
Allow performing more accurate hit (click) test. E.g. consider rounded corners.
enumerator LV_OBJ_FLAG_IGNORE_LAYOUT
Make the object position-able by the layouts
enumerator LV_OBJ_FLAG_FLOATING
Do not scroll the object when the parent scrolls and ignore layout
enumerator LV_OBJ_FLAG_OVERFLOW_VISIBLE
Do not clip the children's content to the parent's boundary
enumerator LV_OBJ_FLAG_LAYOUT_1
Custom flag, free to use by layouts
enumerator LV_OBJ_FLAG_LAYOUT_2
Custom flag, free to use by layouts
enumerator LV_OBJ_FLAG_WIDGET_1
Custom flag, free to use by widget
enumerator LV_OBJ_FLAG_WIDGET_2
Custom flag, free to use by widget
enumerator LV_OBJ_FLAG_USER_1
Custom flag, free to use by user
enumerator LV_OBJ_FLAG_USER_2
Custom flag, free to use by user
enumerator LV_OBJ_FLAG_USER_3
Custom flag, free to use by user
enumerator LV_OBJ_FLAG_USER_4
Custom flag, free to use by user

enum lv_obj_draw_part_type_t

type field in lv_obj_draw_part_dsc_t if class_p = lv_obj_class Used in LV_EVENT_DRAW_PART_BEGIN and LV_EVENT_DRAW_PART_END Values:
enumerator LV_OBJ_DRAW_PART_RECTANGLE
The main rectangle
enumerator LV_OBJ_DRAW_PART_BORDER_POST
The border if style_border_post = true
enumerator LV_OBJ_DRAW_PART_SCROLLBAR
The scrollbar

Functions

void lv_init(void)

Initialize LVGL library. Should be called before any other LVGL related function.

void lv_deinit(void)

Deinit the 'lv' library Currently only implemented when not using custom allocators, or GC is enabled.

bool lv_is_initialized(void)

Returns whether the 'lv' library is currently initialized

lv_obj_t *lv_obj_create(lv_obj_t *parent)

Create a base object (a rectangle)
Parameters
parent -- pointer to a parent object. If NULL then a screen will be created.
Returns
pointer to the new object

void lv_obj_add_flag(lv_obj_t *obj, lv_obj_flag_t f)

Set one or more flags
Parameters
  • obj -- pointer to an object
  • f -- R-ed values from lv_obj_flag_t to set.

void lv_obj_clear_flag(lv_obj_t *obj, lv_obj_flag_t f)

Clear one or more flags
Parameters
  • obj -- pointer to an object
  • f -- OR-ed values from lv_obj_flag_t to set.

void lv_obj_add_state(lv_obj_t *obj, lv_state_t state)

Add one or more states to the object. The other state bits will remain unchanged. If specified in the styles, transition animation will be started from the previous state to the current.
Parameters
  • obj -- pointer to an object
  • state -- the states to add. E.g LV_STATE_PRESSED | LV_STATE_FOCUSED

void lv_obj_clear_state(lv_obj_t *obj, lv_state_t state)

Remove one or more states to the object. The other state bits will remain unchanged. If specified in the styles, transition animation will be started from the previous state to the current.
Parameters
  • obj -- pointer to an object
  • state -- the states to add. E.g LV_STATE_PRESSED | LV_STATE_FOCUSED

static inline void lv_obj_set_user_data(lv_obj_t *obj, void *user_data)

Set the user_data field of the object
Parameters
  • obj -- pointer to an object
  • user_data -- pointer to the new user_data.

bool lv_obj_has_flag(const lv_obj_t *obj, lv_obj_flag_t f)

Check if a given flag or all the given flags are set on an object.
Parameters
  • obj -- pointer to an object
  • f -- the flag(s) to check (OR-ed values can be used)
Returns
true: all flags are setfalse: not all flags are set

bool lv_obj_has_flag_any(const lv_obj_t *obj, lv_obj_flag_t f)

Check if a given flag or any of the flags are set on an object.
Parameters
  • obj -- pointer to an object
  • f -- the flag(s) to check (OR-ed values can be used)
Returns
true: at lest one flag flag is setfalse: none of the flags are set

lv_state_t lv_obj_get_state(const lv_obj_t *obj)

Get the state of an object
Parameters
obj -- pointer to an object
Returns
the state (OR-ed values from lv_state_t)

bool lv_obj_has_state(const lv_obj_t *obj, lv_state_t state)

Check if the object is in a given state or not.
Parameters
  • obj -- pointer to an object
  • state -- a state or combination of states to check
Returns
true: obj is in statefalse: obj is not in state

void *lv_obj_get_group(const lv_obj_t *obj)

Get the group of the object
Parameters
obj -- pointer to an object
Returns
the pointer to group of the object

static inline void *lv_obj_get_user_data(lv_obj_t *obj)

Get the user_data field of the object
Parameters
obj -- pointer to an object
Returns
the pointer to the user_data of the object

void lv_obj_allocate_spec_attr(lv_obj_t *obj)

Allocate special data for an object if not allocated yet.
Parameters
obj -- pointer to an object

bool lv_obj_check_type(const lv_obj_t *obj, const lv_obj_class_t *class_p)

Check the type of obj.
Parameters
  • obj -- pointer to an object
  • class_p -- a class to check (e.g. lv_slider_class)
Returns
true: class_p is the obj class.

bool lv_obj_has_class(const lv_obj_t *obj, const lv_obj_class_t *class_p)

Check if any object has a given class (type). It checks the ancestor classes too.
Parameters
  • obj -- pointer to an object
  • class_p -- a class to check (e.g. lv_slider_class)
Returns
true: obj has the given class

const lv_obj_class_t *lv_obj_get_class(const lv_obj_t *obj)

Get the class (type) of the object
Parameters
obj -- pointer to an object
Returns
the class (type) of the object

bool lv_obj_is_valid(const lv_obj_t *obj)

Check if any object is still "alive".
Parameters
obj -- pointer to an object
Returns
true: valid

static inline lv_coord_t lv_obj_dpx(const lv_obj_t *obj, lv_coord_t n)

Scale the given number of pixels (a distance or size) relative to a 160 DPI display considering the DPI of the obj's display. It ensures that e.g. lv_dpx(100) will have the same physical size regardless to the DPI of the display.
Parameters
  • obj -- an object whose display's dpi should be considered
  • n -- the number of pixels to scale
Returns
n x current_dpi/160

Variables

const lv_obj_class_t lv_obj_class

Make the base object's class publicly available.

struct _lv_obj_spec_attr_t

#include <lv_obj.h> Special, rarely used attributes. They are allocated automatically if any elements is set. Public Members
struct _lv_obj_t **children
Store the pointer of the children in an array.
uint32_t child_cnt
Number of children
lv_group_t *group_p
struct _lv_event_dsc_t *event_dsc
Dynamically allocated event callback and user data array
lv_point_t scroll
The current X/Y scroll offset
lv_coord_t ext_click_pad
Extra click padding in all direction
lv_coord_t ext_draw_size
EXTend the size in every direction for drawing.
lv_scrollbar_mode_t scrollbar_mode
How to display scrollbars
lv_scroll_snap_t scroll_snap_x
Where to align the snappable children horizontally
lv_scroll_snap_t scroll_snap_y
Where to align the snappable children vertically
lv_dir_t scroll_dir
The allowed scroll direction(s)
uint8_t event_dsc_cnt
Number of event callbacks stored in event_dsc array


struct _lv_obj_t

Public Members
const lv_obj_class_t *class_p
struct _lv_obj_t *parent
_lv_obj_spec_attr_t *spec_attr
_lv_obj_style_t *styles
void *user_data
lv_area_t coords
lv_obj_flag_t flags
lv_state_t state
uint16_t layout_inv
uint16_t scr_layout_inv
uint16_t skip_trans
uint16_t style_cnt
uint16_t h_layout
uint16_t w_layout


戻る : Previous