lvgl一些常用的功能标志
·
用来实现一些UI交互真的很方便,记录下来方便以后自己开发用到。
添加标志的接口:
/**
* Set one or more flags
* @param obj pointer to an object
* @param f OR-ed values from `lv_obj_flag_t` to set.
*/
void lv_obj_add_flag(lv_obj_t * obj, lv_obj_flag_t f);
lv_obj_add_flag 是 LVGL 中用于给对象(lv_obj_t)添加功能标志的核心接口,通过这些标志可以快速修改对象的行为或特性.
标志可以支持按位或。
标志解析:
/**
* On/Off features controlling the object's behavior.
* OR-ed values are possible
*
* Note: update obj flags corresponding properties below
* whenever add/remove flags or change bit definition of flags.
*/
typedef enum {
//基础交互与控制显示
//隐藏对象
LV_OBJ_FLAG_HIDDEN = (1L << 0), /**< Make the object hidden. (Like it wasn't there at all)*/
//允许接收点击/触摸事件
LV_OBJ_FLAG_CLICKABLE = (1L << 1), /**< Make the object clickable by the input devices*/
//点击对象时自动添加“聚焦”状态,用于需要焦点的组件,如输入框
LV_OBJ_FLAG_CLICK_FOCUSABLE = (1L << 2), /**< Add focused state to the object when clicked*/
//点击时切换选中状态
LV_OBJ_FLAG_CHECKABLE = (1L << 3), /**< Toggle checked state when the object is clicked*/
//滚动相关(适用于容器/可滚动对象)
//允许对象被滚动,如列表、文本区域等容器需添加此标志
LV_OBJ_FLAG_SCROLLABLE = (1L << 4), /**< Make the object scrollable*/
// 滚动到边界时允许弹性效果(超过界面后缓慢回弹。类似手机界面的滚动体验)
LV_OBJ_FLAG_SCROLL_ELASTIC = (1L << 5), /**< Allow scrolling inside but with slower speed*/
//支持“惯性滚动”(滑动后对象会因惯性继续滚动一段距离)
LV_OBJ_FLAG_SCROLL_MOMENTUM = (1L << 6), /**< Make the object scroll further when "thrown"*/
// 限制一次滚动,只能切换到下一个/上一个 "可吸附"子对象(如轮播图切换页面)
LV_OBJ_FLAG_SCROLL_ONE = (1L << 7), /**< Allow scrolling only one snappable children*/
//水平滚动时,若当前对象滚动到边界,将滚动事件传递给父对象。(如嵌套列表的横向滚动传递)
LV_OBJ_FLAG_SCROLL_CHAIN_HOR = (1L << 8), /**< Allow propagating the horizontal scroll to a parent*/
// 垂直滚动时,时间传递给父对象(同上,适用于纵向)
LV_OBJ_FLAG_SCROLL_CHAIN_VER = (1L << 9), /**< Allow propagating the vertical scroll to a parent*/
//等价于HOR + VER 同时允许水平和垂直事件传递给父对象
LV_OBJ_FLAG_SCROLL_CHAIN = (LV_OBJ_FLAG_SCROLL_CHAIN_HOR | LV_OBJ_FLAG_SCROLL_CHAIN_VER),
//当对象获得焦点时,自动滚动父对象容器使其完全可见(如长列表中聚焦某个项时自动定位)
LV_OBJ_FLAG_SCROLL_ON_FOCUS = (1L << 10), /**< Automatically scroll object to make it visible when focused*/
// 允许通过方向滚动键滚动聚焦对象(适用于键盘操作)
LV_OBJ_FLAG_SCROLL_WITH_ARROW = (1L << 11), /**< Allow scrolling the focused object with arrow keys*/
// 若父对象启用了“滚动吸附”,则滚动时会自动对齐到该对象(如网格布局中的子项吸附)
LV_OBJ_FLAG_SNAPPABLE = (1L << 12), /**< If scroll snap is enabled on the parent it can snap to this object*/
// 事件与手势传递
// 按下对象后即使手指/鼠标滑出对象范围,仍保持“按下”转态(如网格布局中的子项吸附)
LV_OBJ_FLAG_PRESS_LOCK = (1L << 13), /**< Keep the object pressed even if the press slid from the object*/
// 事件冒泡:对象触发的事件会传递给父对象(如子按钮点击事件同时通知父容器)
LV_OBJ_FLAG_EVENT_BUBBLE = (1L << 14), /**< Propagate the events to the parent too*/
//手势冒泡:对象识别的手势(如滑动、缩放)会传递给父对象
LV_OBJ_FLAG_GESTURE_BUBBLE = (1L << 15), /**< Propagate the gestures to the parent*/
//布局与绘制控制
//启用精确点击检测(如忽略圆角外的区域,默认点击检测师矩形区域)
LV_OBJ_FLAG_ADV_HITTEST = (1L << 16), /**< Allow performing more accurate hit (click) test. E.g. consider rounded corners.*/
//使对象不受父容器的布局管理器(Flex/Grid)控制,需要手动设置位置(lv_obj_set_pos)
LV_OBJ_FLAG_IGNORE_LAYOUT = (1L << 17), /**< Make the object not positioned by the layouts*/
//浮动模式:不受父容器滚动影响,切忽略布局(结合IGNORE_LAYOUT,适用于悬浮组件如弹窗)
LV_OBJ_FLAG_FLOATING = (1L << 18), /**< Do not scroll the object when the parent scrolls and ignore layout*/
//发送绘制任务相关事件(LV_EVENT_DRAW_TASK_ADDED),用于监控绘制过程。
LV_OBJ_FLAG_SEND_DRAW_TASK_EVENTS = (1L << 19), /**< Send `LV_EVENT_DRAW_TASK_ADDED` events*/
//允许子对象超过父对象的绘制范围(默认子对象会被父对象裁剪)
LV_OBJ_FLAG_OVERFLOW_VISIBLE = (1L << 20),/**< Do not clip the children to the parent's ext draw size*/
//当启用Flex布局时有效
#if LV_USE_FLEX
// 强制当前Flex子项单独占一行
LV_OBJ_FLAG_FLEX_IN_NEW_TRACK = (1L << 21), /**< Start a new flex track on this item*/
#endif
//布局专用自定义标志,供LVGL内部布局管理器或用户自定义布局使用
LV_OBJ_FLAG_LAYOUT_1 = (1L << 23), /**< Custom flag, free to use by layouts*/
LV_OBJ_FLAG_LAYOUT_2 = (1L << 24), /**< Custom flag, free to use by layouts*/
//组件专用自定义标志,供LVGL内置组件(如按钮、滑块)或用户自定义组件使用
LV_OBJ_FLAG_WIDGET_1 = (1L << 25), /**< Custom flag, free to use by widget*/
LV_OBJ_FLAG_WIDGET_2 = (1L << 26), /**< Custom flag, free to use by widget*/
//用户自定义标志,完全由开发者使用(标志对象状态/分组等)
LV_OBJ_FLAG_USER_1 = (1L << 27), /**< Custom flag, free to use by user*/
LV_OBJ_FLAG_USER_2 = (1L << 28), /**< Custom flag, free to use by user*/
LV_OBJ_FLAG_USER_3 = (1L << 29), /**< Custom flag, free to use by user*/
LV_OBJ_FLAG_USER_4 = (1L << 30), /**< Custom flag, free to use by user*/
} lv_obj_flag_t;
更多推荐



所有评论(0)