mirror of
https://github.com/lvgl/lvgl.git
synced 2025-01-28 07:03:00 +08:00
More Snapable --> Snappable replacements (#2304)
This commit is contained in:
parent
e697807cf5
commit
c7169762a3
@ -100,7 +100,8 @@ However, with `LV_OBJ_FLAG_SCROLL_ELASTIC` a fancy effect can be added when the
|
||||
When the object is released the content scrolled in it will be animated back to the valid position.
|
||||
|
||||
### Snapping
|
||||
The children of an object can be snapped according to specific rules when scrolling ends. Children can be made snappable individually with the `LV_OBJ_FLAG_SNAPABLE` flag. (Note misspelling of the flag name: your code needs to spell it with one P.)
|
||||
The children of an object can be snapped according to specific rules when scrolling ends. Children can be made snappable individually with the `LV_OBJ_FLAG_SNAPPABLE` flag.
|
||||
|
||||
The object can align the snapped children in 4 ways:
|
||||
- `LV_SCROLL_SNAP_NONE` Snapping is disabled. (default)
|
||||
- `LV_SCROLL_SNAP_START` Align the children to the left/top side of the scrolled object
|
||||
@ -117,7 +118,7 @@ Under the hood the following happens:
|
||||
|
||||
### Scroll one
|
||||
The "scroll one" feature tells LVGL to allow scrolling only one snappable child at a time.
|
||||
So this requires to make the children snappable (LV_OBJ_FLAG_SNAPABLE spelled with one P in code) and and set a scroll snap alignment different from `LV_SCROLL_SNAP_NONE`.
|
||||
So this requires to make the children snappable and set a scroll snap alignment different from `LV_SCROLL_SNAP_NONE`.
|
||||
|
||||
This feature can be enabled by the `LV_OBJ_FLAG_SCROLL_ONE` flag.
|
||||
|
||||
|
@ -104,10 +104,10 @@ There are some attributes which can be enabled/disabled by `lv_obj_add/clear_fla
|
||||
- `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 snapable children
|
||||
- `LV_OBJ_FLAG_SCROLL_ONE` Allow scrolling only one snappable children
|
||||
- `LV_OBJ_FLAG_SCROLL_CHAIN` Allow propagating the scroll to a parent
|
||||
- `LV_OBJ_FLAG_SCROLL_ON_FOCUS` Automatically scroll object to make it visible when focused
|
||||
- `LV_OBJ_FLAG_SNAPABLE` If scroll snap is enabled on the parent it can snap to this object
|
||||
- `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
|
||||
|
@ -28,7 +28,7 @@ for i in range(10):
|
||||
label = lv.label(btn)
|
||||
if i == 3:
|
||||
label.set_text("Panel {:d}\nno snap".format(i))
|
||||
btn.clear_flag(lv.obj.FLAG.SNAPABLE)
|
||||
btn.clear_flag(lv.obj.FLAG.SNAPPABLE)
|
||||
else:
|
||||
label.set_text("Panel {:d}".format(i))
|
||||
label.center()
|
||||
|
@ -94,7 +94,7 @@ enum {
|
||||
LV_OBJ_FLAG_SCROLLABLE = (1 << 4), /**< Make the object scrollable*/
|
||||
LV_OBJ_FLAG_SCROLL_ELASTIC = (1 << 5), /**< Allow scrolling inside but with slower speed*/
|
||||
LV_OBJ_FLAG_SCROLL_MOMENTUM = (1 << 6), /**< Make the object scroll further when "thrown"*/
|
||||
LV_OBJ_FLAG_SCROLL_ONE = (1 << 7), /**< Allow scrolling only one snapable children*/
|
||||
LV_OBJ_FLAG_SCROLL_ONE = (1 << 7), /**< Allow scrolling only one snappable children*/
|
||||
LV_OBJ_FLAG_SCROLL_CHAIN = (1 << 8), /**< Allow propagating the scroll to a parent*/
|
||||
LV_OBJ_FLAG_SCROLL_ON_FOCUS = (1 << 9), /**< Automatically scroll object to make it visible when focused*/
|
||||
LV_OBJ_FLAG_SNAPPABLE = (1 << 10), /**< If scroll snap is enabled on the parent it can snap to this object*/
|
||||
@ -148,8 +148,8 @@ typedef struct {
|
||||
lv_coord_t ext_draw_size; /**< EXTend the size in every direction for drawing.*/
|
||||
|
||||
lv_scrollbar_mode_t scrollbar_mode :2; /**< How to display scrollbars*/
|
||||
lv_scroll_snap_t scroll_snap_x : 2; /**< Where to align the snapable children horizontally*/
|
||||
lv_scroll_snap_t scroll_snap_y : 2; /**< Where to align the snapable children horizontally*/
|
||||
lv_scroll_snap_t scroll_snap_x : 2; /**< Where to align the snappable children horizontally*/
|
||||
lv_scroll_snap_t scroll_snap_y : 2; /**< Where to align the snappable children horizontally*/
|
||||
lv_dir_t scroll_dir :4; /**< The allowed scroll direction(s)*/
|
||||
uint8_t event_dsc_cnt; /**< Number of event callabcks stored in `event_cb` array*/
|
||||
}_lv_obj_spec_attr_t;
|
||||
|
@ -37,7 +37,7 @@ enum {
|
||||
typedef uint8_t lv_scrollbar_mode_t;
|
||||
|
||||
|
||||
/** Scroll span align options. Tells where to align the snapable children when scroll stops.*/
|
||||
/** Scroll span align options. Tells where to align the snappable children when scroll stops.*/
|
||||
enum {
|
||||
LV_SCROLL_SNAP_NONE, /**< Do not align, leave where it is*/
|
||||
LV_SCROLL_SNAP_START, /**< Align to to the left/top*/
|
||||
|
Loading…
x
Reference in New Issue
Block a user