App:Library:LVGL:docs:Overview:Scroll
https://docs.lvgl.io/8.2/overview/scroll.html
Scroll
Overview
英文 | 自動翻訳 |
---|---|
In LVGL scrolling works very intuitively: if an object is outside its parent content area (the size without padding), the parent becomes scrollable and scrollbar(s) will appear. That's it.
The object can either be scrolled horizontally or vertically in one stroke; diagonal scrolling is not possible. |
LVGLのスクロールは、非常に直感的に動作します。オブジェクトが親のコンテンツ領域(パディングなしのサイズ)の外に出た場合、親はスクロール可能になり、スクロールバー(複数可)が表示されるのです。
これだけです。
オブジェクトは、一筆書きで水平または垂直にスクロールすることができ、斜め方向のスクロールはできません。 |
Scrollbar
Mode
英文 | 自動翻訳 |
---|---|
Scrollbars are displayed according to a configured
|
スクロールバーは、設定されたmode に従って表示されます。以下のmode が存在する。
|
Styling
英文 | 自動翻訳 |
---|---|
The scrollbars have their own dedicated part, called static lv_style_t style_red; lv_style_init(&style_red); lv_style_set_bg_color(&style_red, lv_color_red()); ... lv_obj_add_style(obj, &style_red, LV_PART_SCROLLBAR); An object goes to the static lv_style_t style_blue; lv_style_init(&style_blue); lv_style_set_bg_color(&style_blue, lv_color_blue()); ... lv_obj_add_style(obj, &style_blue, LV_STATE_SCROLLED | LV_PART_SCROLLBAR); If the base direction of the
|
The scrollbars have their own dedicated part, called LV_PART_SCROLLBAR . For example a scrollbar can turn to red like this:
static lv_style_t style_red; lv_style_init(&style_red); lv_style_set_bg_color(&style_red, lv_color_red()); ... lv_obj_add_style(obj, &style_red, LV_PART_SCROLLBAR); An object goes to the static lv_style_t style_blue; lv_style_init(&style_blue); lv_style_set_bg_color(&style_blue, lv_color_blue()); ... lv_obj_add_style(obj, &style_blue, LV_STATE_SCROLLED | LV_PART_SCROLLBAR); If the base direction of the
|
Events
英文 | 自動翻訳 |
---|---|
The following events are related to scrolling:
|
Basic example
英文 | 自動翻訳 |
---|---|
TODO |
Features of scrolling
英文 | 自動翻訳 |
---|---|
Besides, managing "normal" scrolling there are many interesting and useful additional features. |
Scrollable
英文 | 自動翻訳 |
---|---|
It's possible to make an object non-scrollable with Non-scrollable objects can still propagate the scrolling (chain) to their parents. The direction in which scrolling happens can be controlled by
OR-ed values are also possible. E.g. |
Scroll chain
英文 | 自動翻訳 |
---|---|
If an object can't be scrolled further (e.g. its content has reached the bottom-most position) additional scrolling is propagated to its parent. If the parent can be scrolled in that direction than it will be scrolled instead. It continues propagating to the grandparent and grand-grandparents as well. The propagation on scrolling is called "scroll chaining" and it can be enabled/disabled with |
Scroll momentum
英文 | 自動翻訳 |
---|---|
When the user scrolls an object and releases it, LVGL can emulate inertial momentum for the scrolling. It's like the object was thrown and scrolling slows down smoothly. The scroll momentum can be enabled/disabled with the |
Elastic scroll
英文 | 自動翻訳 |
---|---|
Normally an object can't be scrolled past the extremeties of its content. That is the top side of the content can't be below the top side of the object. However, with |
Snapping
英文 | 自動翻訳 |
---|---|
The children of an object can be snapped according to specific rules when scrolling ends. Children can be made snappable individually with the An object can align snapped children in four ways:
Snap alignment is set with Under the hood the following happens:
|
Scroll one
英文 | 自動翻訳 |
---|---|
The "scroll one" feature tells LVGL to allow scrolling only one snappable child at a time. This requires making the children snappable and setting a scroll snap alignment different from This feature can be enabled by the |
Scroll on focus
英文 | 自動翻訳 |
---|---|
Imagine that there a lot of objects in a group that are on a scrollable object. Pressing the "Tab" button focuses the next object but it might be outside the visible area of the scrollable object. If the "scroll on focus" feature is enabled LVGL will automatically scroll objects to bring their children into view. The scrolling happens recursively therefore even nested scrollable objects are handled properly. The object will be scrolled into view even if it's on a different page of a tabview. |
Scroll manually
英文 | 自動翻訳 |
---|---|
The following API functions allow manual scrolling of objects:
|
Self size
英文 | 自動翻訳 |
---|---|
Self size is a property of an object. Normally, the user shouldn't use this parameter but if a custom widget is created it might be useful. In short, self size establishes the size of an object's content. To understand it better take the example of a table. Let's say it has 10 rows each with 50 px height. So the total height of the content is 500 px. In other words the "self height" is 500 px. If the user sets only 200 px height for the table LVGL will see that the self size is larger and make the table scrollable. This means not only the children can make an object scrollable but a larger self size will too. LVGL uses the if(event_code == LV_EVENT_GET_SELF_SIZE) {
lv_point_t * p = lv_event_get_param(e);
//If x or y < 0 then it doesn't neesd to be calculated now
if(p->x >= 0) {
p->x = 200; //Set or calculate the self width
}
if(p->y >= 0) {
p->y = 50; //Set or calculate the self height
}
}
|
Examples
英文 | 自動翻訳 |
---|---|
Nested scrolling |
|
Snapping |
|
Floating button |
|
Styling the scrollbars |
|
Right to left scrolling |
|
Translate on scroll |