demo工程暂存 优化菜单界面UI和功能
This commit is contained in:
94
Demo/lvgl/docs/widgets/core/arc.md
Normal file
94
Demo/lvgl/docs/widgets/core/arc.md
Normal file
@ -0,0 +1,94 @@
|
||||
```eval_rst
|
||||
.. include:: /header.rst
|
||||
:github_url: |github_link_base|/widgets/arc.md
|
||||
```
|
||||
# Arc (lv_arc)
|
||||
|
||||
## Overview
|
||||
|
||||
The Arc are consists of a background and a foreground arc. The foregrond (indicator) arc can be adjusted by finger.
|
||||
|
||||
## Parts and Styles
|
||||
- `LV_PART_MAIN` It draws a background using the typical background style properties and an arc using the arc style properties. The arc's size and position will respect the *padding* style properties.
|
||||
- `LV_PART_INDICATOR` It draws an other arc using the *arc* style properties. It's padding values are interpreted relative to the background arc.
|
||||
- `LV_PART_KNOB`It draws a handle on the end of the indicator. It uses all background properties and padding values. With zero padding the knob size is the same as the indicator's width.
|
||||
Larger padding makes it larger, smaller padding makes it smaller.
|
||||
|
||||
## Usage
|
||||
|
||||
### Value and range
|
||||
|
||||
A new value can be set by `lv_arc_set_value(arc, new_value)`.
|
||||
The value is interpreted in a range (minimum and maximum values) which can be modified with `lv_arc_set_range(arc, min, max)`.
|
||||
The default range is 1..100.
|
||||
|
||||
The indicator arc is drawn on the main part's arc. That is if the vale is set to maximum the indicator arc will cover the entire "background" arc.
|
||||
To set the start and end angl of the background arc use the `lv_arc_set_bg_angles(arc, start_angle, end_angle)` function or `lv_arc_set_bg_start/end_angle(arc, start_angle)`.
|
||||
|
||||
Zero degree is at the middle right (3 o'clock) of the object and the degrees are increasing in clockwise direction.
|
||||
The angles should be in [0;360] range.
|
||||
|
||||
### Rotation
|
||||
|
||||
An offset to the 0 degree position can added with `lv_arc_set_rotation(arc, deg)`.
|
||||
|
||||
### Mode
|
||||
|
||||
The arc can be one of the following modes:
|
||||
- `LV_ARC_MODE_NORMAL` The indicator arc is drawn from the minimimum value to the current.
|
||||
- `LV_ARC_MODE_REVERSE` The indicator arc is drawn counter clockwise from the maximum value to the current.
|
||||
- `LV_ARC_MODE_SYMMETRICAL` The indicator arc is drawn from the middle point to the current value.
|
||||
|
||||
The mode can be set by `lv_arc_set_mode(arc, LV_ARC_MODE_...)` and used only if the the angle is set by `lv_arc_set_value()` or the arc is adjusted by finger.
|
||||
|
||||
### Change rate
|
||||
If the the arc is pressed the current value will set with a limited speed according to the set *change rate*.
|
||||
The change rate is defined in degree/second unit and can be set with `lv_arc_set_change_rage(arc, rate)`
|
||||
|
||||
|
||||
### Setting the indicator manually
|
||||
It also possible to set the angles o the indicator arc directly with `lv_arc_set_angles(arc, start_angle, end_angle)` function or `lv_arc_set_start/end_angle(arc, start_angle)` sets the angles of the indicator arc.
|
||||
In this case the set "value" and "mode" is ignored.
|
||||
|
||||
In other words, settings angles and values are independent. You should use either value and angle settings. Mixing the two might result unintended behavior.
|
||||
|
||||
To make the arc non-adjutabe remove the style of the knob and make the object non-clickable:
|
||||
```c
|
||||
lv_obj_remove_style(arc, NULL, LV_PART_KNOB);
|
||||
lv_obj_clear_flag(arc, LV_OBJ_FLAG_CLICKABLE);
|
||||
```
|
||||
|
||||
## Events
|
||||
- `LV_EVENT_VALUE_CHANGED` sent when the arc is pressed/dragged to set a new value.
|
||||
- `LV_EVENT_DRAW_PART_BEGIN` and `LV_EVENT_DRAW_PART_END` are sent for the background rectangle, the background arc, the foreground arc and the knob to allow hooking the drawing.
|
||||
For more detail on the backround rectangle part see the [Base object](/widgets/obj#events)'s documentation. The fields of `lv_obj_draw_dsc_t` is set like the followings:
|
||||
- For both arcs: `clip_area`, `p1` (center of the arc), `radius`, `arc_dsc`, `part`.
|
||||
- For the knob: `clip_area`, `draw_area`, `rect_dsc`, `part`.
|
||||
|
||||
|
||||
Learn more about [Events](/overview/event).
|
||||
|
||||
## Keys
|
||||
- `LV_KEY_RIGHT/UP` Increases the value by one.
|
||||
- `LV_KEY_LEFT/DOWN` Decreases the value by one.
|
||||
|
||||
|
||||
Learn more about [Keys](/overview/indev).
|
||||
|
||||
|
||||
## Example
|
||||
|
||||
```eval_rst
|
||||
|
||||
.. include:: ../../../examples/widgets/arc/index.rst
|
||||
|
||||
```
|
||||
|
||||
## API
|
||||
|
||||
```eval_rst
|
||||
|
||||
.. doxygenfile:: lv_arc.h
|
||||
:project: lvgl
|
||||
|
||||
```
|
62
Demo/lvgl/docs/widgets/core/bar.md
Normal file
62
Demo/lvgl/docs/widgets/core/bar.md
Normal file
@ -0,0 +1,62 @@
|
||||
```eval_rst
|
||||
.. include:: /header.rst
|
||||
:github_url: |github_link_base|/widgets/bar.md
|
||||
```
|
||||
# Bar (lv_bar)
|
||||
|
||||
## Overview
|
||||
|
||||
The bar object has a background and an indicator on it. The width of the indicator is set according to the current value of the bar.
|
||||
|
||||
Vertical bars can be created if the width of the object is smaller than its height.
|
||||
|
||||
Not only the end, but the start value of the bar can be set which changes the start position of the indicator.
|
||||
|
||||
|
||||
## Parts and Styles
|
||||
- `LV_PART_MAIN` The background of the bar and it uses the typical background style properties. Adding padding makes the indicator smaller or larger. The `anim_time` style property sets the animation time if the values set with `LV_ANIM_ON`.
|
||||
- `LV_PART_INDICATOR` The indicator and it also also uses all the typical background properties.
|
||||
|
||||
## Usage
|
||||
|
||||
### Value and range
|
||||
A new value can be set by `lv_bar_set_value(bar, new_value, LV_ANIM_ON/OFF)`.
|
||||
The value is interpreted in a range (minimum and maximum values) which can be modified with `lv_bar_set_range(bar, min, max)`.
|
||||
The default range is 1..100.
|
||||
|
||||
The new value in `lv_bar_set_value` can be set with or without an animation depending on the last parameter (`LV_ANIM_ON/OFF`).
|
||||
|
||||
### Modes
|
||||
The bar can be one the following modes:
|
||||
- `LV_BAR_MODE_NORMAL` A normal bar as described above
|
||||
- `LV_BAR_SYMMETRICAL` Draw the indicator form the zero value to current value. Requires negaitve minimum range and positive maximum range.
|
||||
- `LV_BAR_RANGE` Allows setting the start value too by `lv_bar_set_start_value(bar, new_value, LV_ANIM_ON/OFF)`. The start value has to be always smaller than the end value.
|
||||
|
||||
## Events
|
||||
- `LV_EVENT_DRAW_PART_BEGIN` and `LV_EVENT_DRAW_PART_END` are sent for both main and indicator parts to allow hooking the drawing.
|
||||
The for more detail on the main part see the [Base object](/widgets/obj#events)'s documentation.
|
||||
For the indicator the following fields are used: `clip_area`, `draw_area`, `rect_dsc`, `part`.
|
||||
|
||||
Learn more about [Events](/overview/event).
|
||||
|
||||
## Keys
|
||||
No *Keys* are processed by the object type.
|
||||
|
||||
Learn more about [Keys](/overview/indev).
|
||||
|
||||
## Example
|
||||
|
||||
```eval_rst
|
||||
|
||||
.. include:: ../../../examples/widgets/bar/index.rst
|
||||
|
||||
```
|
||||
|
||||
## API
|
||||
|
||||
```eval_rst
|
||||
|
||||
.. doxygenfile:: lv_bar.h
|
||||
:project: lvgl
|
||||
|
||||
```
|
50
Demo/lvgl/docs/widgets/core/btn.md
Normal file
50
Demo/lvgl/docs/widgets/core/btn.md
Normal file
@ -0,0 +1,50 @@
|
||||
```eval_rst
|
||||
.. include:: /header.rst
|
||||
:github_url: |github_link_base|/widgets/btn.md
|
||||
```
|
||||
# Button (lv_btn)
|
||||
|
||||
## Overview
|
||||
|
||||
Buttons has no new features compared to the [Base object](/widgets/obj). It usufule for semantic purposes and has slightly different default settings.
|
||||
|
||||
Buttons differ from Base object in the following points by default:
|
||||
- Not scrollable
|
||||
- Added to the default group
|
||||
- Its default height and width is `LV_SIZE_CONTENT`
|
||||
|
||||
## Parts and Styles
|
||||
- `LV_PART_MAIN` The background of the button. It uses the typical background style properties.
|
||||
|
||||
## Usage
|
||||
|
||||
There are no new features compared to [Base object](/widgets/obj).
|
||||
|
||||
## Events
|
||||
- `LV_EVENT_VALUE_CHANGED` when the `LV_OBJ_FLAG_CHECKABLE` flag is enabled and the obejct clicked (on transition to/from the checked state)
|
||||
|
||||
|
||||
Learn more about [Events](/overview/event).
|
||||
|
||||
## Keys
|
||||
If `LV_OBJ_FLAG_CHECKABLE` is enabled `LV_KEY_RIGHT` and `LV_KEY_UP` makes the object checked, and `LV_KEY_LEFT` and `LV_KEY_DOWN` makes it unchecked.
|
||||
|
||||
Note that, the state of `LV_KEY_ENTER` is translated to `LV_EVENT_PRESSED/PRESSING/RELEASED` etc.
|
||||
|
||||
Learn more about [Keys](/overview/indev).
|
||||
|
||||
## Example
|
||||
```eval_rst
|
||||
|
||||
.. include:: ../../../examples/widgets/btn/index.rst
|
||||
|
||||
```
|
||||
|
||||
## API
|
||||
|
||||
```eval_rst
|
||||
|
||||
.. doxygenfile:: lv_btn.h
|
||||
:project: lvgl
|
||||
|
||||
```
|
96
Demo/lvgl/docs/widgets/core/btnmatrix.md
Normal file
96
Demo/lvgl/docs/widgets/core/btnmatrix.md
Normal file
@ -0,0 +1,96 @@
|
||||
```eval_rst
|
||||
.. include:: /header.rst
|
||||
:github_url: |github_link_base|/widgets/btnmatrix.md
|
||||
```
|
||||
# Button matrix (lv_btnmatrix)
|
||||
|
||||
## Overview
|
||||
|
||||
The Button Matrix objects can display multiple buttons in rows and columns.
|
||||
|
||||
The Button matrix object is very light weighted because the buttons are not created just virtually drawn on the fly.
|
||||
This way, 1 button use only 8 extra bytes instead of the ~100-150 byte size of a normal [Button](/widgets/core/btn) object and other ~100 byte for the size of the [Label](/widgets/core/label) object.
|
||||
|
||||
The Button matrix is added to the deafult group (if it is set). Besides the Button matrix is an editable object to allow selecting and clicing the buttons with encoder navigation too.
|
||||
|
||||
## Parts and Styles
|
||||
- `LV_PART_MAIN` The bacground of the button matrix. It uses the typical background style properties. `pad_row` and `pad_column` sets the space between the buttons.
|
||||
- `LV_PART_ITEMS` The buttons and they all use the text and typical background style properties expect translations and transformations.
|
||||
|
||||
## Usage
|
||||
|
||||
### Button's text
|
||||
There is a text on each button. To specify them a descriptor string array, called *map*, needs to be used.
|
||||
The map can be set with `lv_btnmatrix_set_map(btnm, my_map)`.
|
||||
The declaration of a map should look like `const char * map[] = {"btn1", "btn2", "btn3", NULL}`.
|
||||
Note that, the last element has to be `NULL` or an empty string (`""`)!
|
||||
|
||||
Use `"\n"` in the map to make **line break**. E.g. `{"btn1", "btn2", "\n", "btn3", ""}`. Each line's buttons have their width calculated automatically.
|
||||
So in the example the first row will have 2 buttons each with 50% width and a second row with 1 button having 100% width.
|
||||
|
||||
### Control buttons
|
||||
The buttons' width can be set relative to the other button in the same row with `lv_btnmatrix_set_btn_width(btnm, btn_id, width)`
|
||||
E.g. in a line with two buttons: *btnA, width = 1* and *btnB, width = 2*, *btnA* will have 33 % width and *btnB* will have 66 % width.
|
||||
It's similar to how the [`flex-grow`](https://developer.mozilla.org/en-US/docs/Web/CSS/flex-grow) property works in CSS.
|
||||
The width's value mus be in the \[1..7\] range and the deafult width is 1.
|
||||
|
||||
In addition to the width, each button can be customized with the following parameters:
|
||||
- `LV_BTNMATRIX_CTRL_HIDDEN` Makes a button hidden (hidden buttons still take up space in the layout, they are just not visible or clickable)
|
||||
- `LV_BTNMATRIX_CTRL_NO_REPEAT` Disable repeating when the button is long pressed
|
||||
- `LV_BTNMATRIX_CTRL_DISABLED` Makes a button disabled Like `LV_STATE_DISABLED` on normal objects
|
||||
- `LV_BTNMATRIX_CTRL_CHECKABLE` Enable toggling of a button. I.e. `LV_STATE_CHECHED` will be added/removed as the button is clicked
|
||||
- `LV_BTNMATRIX_CTRL_CHECKED` MAke the button checked. It will use the `LV_STATE_CHECHKED` styles.
|
||||
- `LV_BTNMATRIX_CTRL_CLICK_TRIG` Enabled: send LV_EVENT_VALUE_CHANGE on CLICK, Disabled: send LV_EVENT_VALUE_CHANGE on PRESS*/
|
||||
- `LV_BTNMATRIX_CTRL_RECOLOR` Enable recoloring of button texts with `#`. E.g. `"It's #ff0000 red#"`
|
||||
- `LV_BTNMATRIX_CTRL_CUSTOM_1` Custom free to use flag
|
||||
- `LV_BTNMATRIX_CTRL_CUSTOM_2` Custom free to use flag
|
||||
|
||||
By deafult all flags are disabled.
|
||||
|
||||
To set or clear a button's control attribute, use `lv_btnmatrix_set_btn_ctrl(btnm, btn_id, LV_BTNM_CTRL_...)` and
|
||||
`lv_btnmatrix_clear_btn_ctrl(btnm, btn_id, LV_BTNMATRIX_CTRL_...)` respectively. More `LV_BTNM_CTRL_...` values can be OR-ed
|
||||
|
||||
To set/clear the same control attribute for all buttons of a button matrix, use `lv_btnmatrix_set_btn_ctrl_all(btnm, btn_id, LV_BTNM_CTRL_...)` and
|
||||
`lv_btnmatrix_clear_btn_ctrl_all(btnm, btn_id, LV_BTNMATRIX_CTRL_...)`.
|
||||
|
||||
The set a control map for a button matrix (similarly to the map for the text), use `lv_btnmatrix_set_ctrl_map(btnm, ctrl_map)`.
|
||||
An element of `ctrl_map` should look like `ctrl_map[0] = width | LV_BTNM_CTRL_NO_REPEAT | LV_BTNM_CTRL_CHECHKABLE`.
|
||||
The number of elements should be equal to the number of buttons (excluding newlines characters).
|
||||
|
||||
### One check
|
||||
The "One check" feature can be enabled with `lv_btnmatrix_set_one_check(btnm, true)` to allow only one button to be checked at once.
|
||||
|
||||
## Events
|
||||
- `LV_EVENT_VALUE_CHANGED` Sent when a button is pressed/released or repeated after long press. The event paramter is set to the ID of the pressed/released button.
|
||||
- `LV_EVENT_DRAW_PART_BEGIN` and `LV_EVENT_DRAW_PART_END` are sent for both the main and the items (buttons) parts to allow hooking the drawing.
|
||||
The for more detail on the main part see the [Base object](/widgets/obj#events)'s documentation.
|
||||
For the buttons the following fields are used: `clip_area`, `draw_area`, `rect_dsc`, `rect_dsc`, `part`, `id` (index of the button being drawn).
|
||||
|
||||
`lv_btnmatrix_get_selected_btn(btnm)` returns the index of the lastly pressed, released or focused button or `LV_BTNMATRIX_BTN_NONE` if no such button.
|
||||
|
||||
`lv_btnmatrix_get_btn_text(btnm, btn_id)` returns a pointer to the text of `btn_id`th button.
|
||||
|
||||
Learn more about [Events](/overview/event).
|
||||
|
||||
## Keys
|
||||
- `LV_KEY_RIGHT/UP/LEFT/RIGHT` To navigate among the buttons to select one
|
||||
- `LV_KEY_ENTER` To press/release the selected button
|
||||
|
||||
Learn more about [Keys](/overview/indev).
|
||||
|
||||
## Example
|
||||
|
||||
```eval_rst
|
||||
|
||||
.. include:: ../../../examples/widgets/btnmatrix/index.rst
|
||||
|
||||
```
|
||||
|
||||
## API
|
||||
|
||||
```eval_rst
|
||||
|
||||
.. doxygenfile:: lv_btnmatrix.h
|
||||
:project: lvgl
|
||||
|
||||
```
|
101
Demo/lvgl/docs/widgets/core/canvas.md
Normal file
101
Demo/lvgl/docs/widgets/core/canvas.md
Normal file
@ -0,0 +1,101 @@
|
||||
```eval_rst
|
||||
.. include:: /header.rst
|
||||
:github_url: |github_link_base|/widgets/canvas.md
|
||||
```
|
||||
# Canvas (lv_canvas)
|
||||
|
||||
|
||||
## Overview
|
||||
|
||||
A Canvas inherites from [Image](/widgets/core/img) where the user can draw anything.
|
||||
Rectangles, texts, images, lines, arcs can be drawn here using lvgl's drawing engine.
|
||||
Besides some "effects" can be applied as well like rotation, zoom and blur.
|
||||
|
||||
|
||||
## Parts and Styles
|
||||
`LV_PART_MAIN` Uses the typical rectangle style properties and image style properties.
|
||||
|
||||
## Usage
|
||||
|
||||
### Buffer
|
||||
The Canvas needs a buffer which stores the drawn image.
|
||||
To assign a buffer to a Canvas, use `lv_canvas_set_buffer(canvas, buffer, width, height, LV_IMG_CF_...)`.
|
||||
Where `buffer` is a static buffer (not just a local variable) to hold the image of the canvas.
|
||||
For example,
|
||||
`static lv_color_t buffer[LV_CANVAS_BUF_SIZE_TRUE_COLOR(width, height)]`.
|
||||
`LV_CANVAS_BUF_SIZE_...` macros help to determine the size of the buffer with different color formats.
|
||||
|
||||
The canvas supports all the built-in color formats like `LV_IMG_CF_TRUE_COLOR` or `LV_IMG_CF_INDEXED_2BIT`.
|
||||
See the full list in the [Color formats](/overview/image.html#color-formats) section.
|
||||
|
||||
### Indexed colors
|
||||
For `LV_IMG_CF_INDEXED_1/2/4/8` color formats a palette needs to be
|
||||
initialized with `lv_canvas_set_palette(canvas, 3, LV_COLOR_RED)`. It sets pixels with *index=3* to red.
|
||||
|
||||
### Drawing
|
||||
To set a pixel on the canvas, use `lv_canvas_set_px(canvas, x, y, LV_COLOR_RED)`.
|
||||
With `LV_IMG_CF_INDEXED_...` or `LV_IMG_CF_ALPHA_...`, the index of the color or the alpha value needs to be passed as color.
|
||||
E.g. `lv_color_t c; c.full = 3;`
|
||||
|
||||
`lv_canvas_fill_bg(canvas, LV_COLOR_BLUE, LV_OPA_50)` fills the whole canvas to blue with 50% opacity. Note that, if the current color format doesn't support colors (e.g. `LV_IMG_CF_ALPHA_2BIT`) the color will be ignored.
|
||||
Similarly, if opacity is not supported (e.g. `LV_IMG_CF_TRUE_COLOR`) it will be ignored.
|
||||
|
||||
An array of pixels can be copied to the canvas with `lv_canvas_copy_buf(canvas, buffer_to_copy, x, y, width, height)`.
|
||||
The color format of the buffer and the canvas need to match.
|
||||
|
||||
To draw something to the canvas use
|
||||
- `lv_canvas_draw_rect(canvas, x, y, width, heigth, &draw_dsc)`
|
||||
- `lv_canvas_draw_text(canvas, x, y, max_width, &draw_dsc, txt)`
|
||||
- `lv_canvas_draw_img(canvas, x, y, &img_src, &draw_dsc)`
|
||||
- `lv_canvas_draw_line(canvas, point_array, point_cnt, &draw_dsc)`
|
||||
- `lv_canvas_draw_polygon(canvas, points_array, point_cnt, &draw_dsc)`
|
||||
- `lv_canvas_draw_arc(canvas, x, y, radius, start_angle, end_angle, &draw_dsc)`
|
||||
|
||||
`draw_dsc` is a `lv_draw_rect/label/img/line/arc_dsc_t` variable which should be first initialized with `lv_draw_rect/label/img/line/arc_dsc_init()` function and then it's filed should be modified with the desired colors and other values.
|
||||
|
||||
The draw function can draw to any color format. For example, it's possible to draw a text to an `LV_IMG_VF_ALPHA_8BIT` canvas and use the result image as a [draw mask](/overview/drawing) later.
|
||||
|
||||
### Transformations
|
||||
`lv_canvas_transform()` can be used to rotate and/or scale the image of an image and store the result on the canvas.
|
||||
The function needs the following parameters:
|
||||
- `canvas` pointer to a canvas object to store the result of the transformation.
|
||||
- `img pointer` to an image descriptor to transform. Can be the image descriptor of an other canvas too (`lv_canvas_get_img()`).
|
||||
- `angle` the angle of rotation (0..3600), 0.1 deg resolution
|
||||
- `zoom` zoom factor (256 no zoom, 512 double size, 128 half size);
|
||||
- `offset_x` offset X to tell where to put the result data on destination canvas
|
||||
- `offset_y` offset X to tell where to put the result data on destination canvas
|
||||
- `pivot_x` pivot X of rotation. Relative to the source canvas. Set to `source width / 2` to rotate around the center
|
||||
- `pivot_y` pivot Y of rotation. Relative to the source canvas. Set to `source height / 2` to rotate around the center
|
||||
- `antialias` true: apply anti-aliasing during the transformation. Looks better but slower.
|
||||
|
||||
Note that a canvas can't be rotated on itself. You need a source and destination canvas or image.
|
||||
|
||||
### Blur
|
||||
A given area of the canvas can be blurred horizontally with `lv_canvas_blur_hor(canvas, &area, r)` or vertically with `lv_canvas_blur_ver(canvas, &area, r)`.
|
||||
`r` is the radius of the blur (greater value means more intensive burring). `area` is the area where the blur should be applied (interpreted relative to the canvas)
|
||||
|
||||
## Events
|
||||
The same events are sent than for the [Images](/widgets/core/img).
|
||||
|
||||
Learn more about [Events](/overview/event).
|
||||
|
||||
## Keys
|
||||
No *Keys* are processed by the object type.
|
||||
|
||||
Learn more about [Keys](/overview/indev).
|
||||
|
||||
## Example
|
||||
```eval_rst
|
||||
|
||||
.. include:: ../../../examples/widgets/canvas/index.rst
|
||||
|
||||
```
|
||||
|
||||
## API
|
||||
|
||||
```eval_rst
|
||||
|
||||
.. doxygenfile:: lv_canvas.h
|
||||
:project: lvgl
|
||||
|
||||
```
|
74
Demo/lvgl/docs/widgets/core/checkbox.md
Normal file
74
Demo/lvgl/docs/widgets/core/checkbox.md
Normal file
@ -0,0 +1,74 @@
|
||||
```eval_rst
|
||||
.. include:: /header.rst
|
||||
:github_url: |github_link_base|/widgets/checkbox.md
|
||||
```
|
||||
# Checkbox (lv_checkbox)
|
||||
|
||||
|
||||
## Overview
|
||||
|
||||
The Checkbox object is created from a "tick box" and a label.
|
||||
When the Chackbox is clicked the tick box is toggled.
|
||||
|
||||
## Parts and Styles
|
||||
- `LV_PART_MAIN` The is the background of the Checkbox and it uses the text and all the typical backround style properties.
|
||||
`pad_column` adjusts the spacing between the tickbox and the label
|
||||
- `LV_PART_INDICATOR` The "tick box" is a square the uses all the typical backround style properties.
|
||||
By deafult its size is equal to the height of the main part's font. Padding properties makes the tick boy larger in the respectiev directions.
|
||||
|
||||
The Checkbox is added to the deafult group (if it is set).
|
||||
|
||||
## Usage
|
||||
|
||||
|
||||
### Text
|
||||
The text can be modified by the `lv_checkbox_set_text(cb, "New text")` function.
|
||||
It will dynamically allocate the text.
|
||||
|
||||
To set a static text,
|
||||
use `lv_checkbox_set_static_text(cb, txt)`. This way, only a pointer of `txt` will be stored and it shouldn't be deallocated while the checkbox exists.
|
||||
|
||||
### Check, uncheck, disable
|
||||
You can manually check, un-check, and disable the Checkbox by using the common state state add/clear function:
|
||||
```c
|
||||
lv_obj_add_state(cb, LV_STATE_CHECKED); /*Make the chekbox checked*/
|
||||
lv_obj_clear_state(cb, LV_STATE_CHECKED); /*MAke the checkbox unchecked*/
|
||||
lv_obj_add_state(cb, LV_STATE_CHECKED | LV_STATE_DISABLED); /*Make the checkbox checked and disabled*/
|
||||
```
|
||||
|
||||
## Events
|
||||
- `LV_EVENT_VALUE_CHANGED` Sent when the checkbox is toggled.
|
||||
- `LV_EVENT_DRAW_PART_BEGIN` and `LV_EVENT_DRAW_PART_END` are sent for both main and indicator parts to allow hooking the drawing.
|
||||
The for more detail on the main part see the [Base object](/widgets/obj#events)'s documentation.
|
||||
For the indicator the following fields are used: `clip_area`, `draw_area`, `rect_dsc`, `part`.
|
||||
|
||||
Learn more about [Events](/overview/event).
|
||||
|
||||
|
||||
## Keys
|
||||
The following *Keys* are processed by the 'Buttons':
|
||||
- `LV_KEY_RIGHT/UP` Go to toggled state if toggling is enabled
|
||||
- `LV_KEY_LEFT/DOWN` Go to non-toggled state if toggling is enabled
|
||||
- `LV_KEY_ENTER` Clicks the checkbox and toggles it
|
||||
|
||||
Note that, as usual, the state of `LV_KEY_ENTER` is translated to `LV_EVENT_PRESSED/PRESSING/RELEASED` etc.
|
||||
|
||||
Learn more about [Keys](/overview/indev).
|
||||
|
||||
|
||||
## Example
|
||||
|
||||
```eval_rst
|
||||
|
||||
.. include:: ../../../examples/widgets/checkbox/index.rst
|
||||
|
||||
```
|
||||
|
||||
## API
|
||||
|
||||
```eval_rst
|
||||
|
||||
.. doxygenfile:: lv_checkbox.h
|
||||
:project: lvgl
|
||||
|
||||
```
|
106
Demo/lvgl/docs/widgets/core/dropdown.md
Normal file
106
Demo/lvgl/docs/widgets/core/dropdown.md
Normal file
@ -0,0 +1,106 @@
|
||||
```eval_rst
|
||||
.. include:: /header.rst
|
||||
:github_url: |github_link_base|/widgets/dropdown.md
|
||||
```
|
||||
# Drop-down list (lv_dropdown)
|
||||
|
||||
|
||||
## Overview
|
||||
|
||||
The drop-down list allows the user to select one value from a list.
|
||||
|
||||
The drop-down list is closed by default and displays a single value or a predefined text.
|
||||
When activated (by click on the drop-down list), a list is created from which the user may select one option.
|
||||
When the user selects a new value, the list is deleted.
|
||||
|
||||
The Drop-down list is added to the deafult group (if it is set). Besides the Drop-down list is an editable object to allow selecting an option with encoder navigation too.
|
||||
|
||||
## Parts and Styles
|
||||
The Dropdown widgets is built from the elements: a "button" and a "list" (they are not realted to the butto and list widgets)
|
||||
|
||||
### Button
|
||||
- `LV_PART_MAIN` The background of the button. It uses the typicaly background proeprties and text proeprties for the text on it.
|
||||
- `LV_PART_INDICATOR` Typically an arrow symbol that can be an image or a text (`LV_SYMBOL`).
|
||||
|
||||
The button goes to `LV_STATE_CHECKED` when its opened.
|
||||
|
||||
### List
|
||||
- `LV_PART_MAIN` The list itself and it uses the typical background proeprties. `max_height` can be used to limit the height of the list.
|
||||
- `LV_PART_SCROLLBAR` The scrollbar the background, border, shadow properties and width (for its width) and right padding for the spacing on the right.
|
||||
- `LV_PART_SELECTED` Refers to the currently pressed, checked or prssed+checked option.
|
||||
It also uses the typical background properties.
|
||||
|
||||
As the list not exists when the drop-down list is closed it's not possible to simply add styles to it.
|
||||
Instead the following should be done:
|
||||
1. Ad an event handler to the button for `LV_EVENT_VALUE_CHANGED` (triggered when the list is opened/closed)
|
||||
2. Use `lv_obj_t * list = lv_dropdown_get_list(dropdown)`
|
||||
3. `if(list != NULL) {/*Add the styles to the list*/}`
|
||||
|
||||
Alternatively the the theme can be extended with the new styles.
|
||||
|
||||
## Usage
|
||||
|
||||
## Overview
|
||||
|
||||
### Set options
|
||||
The options are passed to the drop-down list as a string with `lv_dropdown_set_options(dropdown, options)`. The options should be separated by `\n`. For example: `"First\nSecond\nThird"`.
|
||||
The string will be saved in the drop-down list, so it can in local variable too.
|
||||
|
||||
The `lv_dropdown_add_option(dropdown, "New option", pos)` function inserts a new option to `pos` index.
|
||||
|
||||
To save memory the options can set from a static(constant) string too with `lv_dropdown_set_static_options(dropdown, options)`.
|
||||
In this case the options string should be alive while the drop-down list exists and `lv_dropdown_add_option` can't be used
|
||||
|
||||
You can select an option manually with `lv_dropdown_set_selected(dropdown, id)`, where `id` is the index of an option.
|
||||
|
||||
### Get selected option
|
||||
The get the currently selected option, use `lv_dropdown_get_selected(dropdown)`. It will return the *index* of the selected option.
|
||||
|
||||
`lv_dropdown_get_selected_str(dropdown, buf, buf_size)` copies the name of the selected option to a `buf`.
|
||||
|
||||
### Direction
|
||||
The list can be created on any side. The default `LV_DIR_BOTTOM` can be modified by `lv_dropdown_set_dir(dropdown, LV_DIR_LEFT/RIGHT/UP/BOTTOM)` function.
|
||||
|
||||
If the list would be vertically out of the screen, it will aligned to the edge.
|
||||
|
||||
### Symbol
|
||||
A symbol (typically an arrow) can be added to the drop down list with `lv_dropdown_set_symbol(dropdown, LV_SYMBOL_...)`
|
||||
|
||||
If the direction of the drop-down list is `LV_DIR_LEFT` the symbol will be shown on the left, else on the right.
|
||||
|
||||
### Show selected
|
||||
The main part can either show the selected option or a static text. If a static is set with `lv_dropdown_set_text(dropdown, "Some text")` it will be shown regardless to th selected option.
|
||||
Id the text text is `NULL` the selected option is displayed on the button.
|
||||
|
||||
### Manually open/close
|
||||
To manually open or close the drop-down list the `lv_dropdown_open/close(dropdown)` function can be used.
|
||||
|
||||
## Events
|
||||
Besides the [Generic events](../overview/event.html#generic-events), the following [Special events](../overview/event.html#special-events) are sent by the drop-down list:
|
||||
- `LV_EVENT_VALUE_CHANGED` Sent when the new option is selected or the list is opened/closed.
|
||||
|
||||
Learn more about [Events](/overview/event).
|
||||
|
||||
## Keys
|
||||
- `LV_KEY_RIGHT/DOWN` Select the next option.
|
||||
- `LV_KEY_LEFT/UP` Select the previous option.
|
||||
- `LY_KEY_ENTER` Apply the selected option (Send `LV_EVENT_VALUE_CHANGED` event and close the drop-down list).
|
||||
|
||||
Learn more about [Keys](/overview/indev).
|
||||
|
||||
## Example
|
||||
|
||||
```eval_rst
|
||||
|
||||
.. include:: ../../../examples/widgets/dropdown/index.rst
|
||||
|
||||
```
|
||||
|
||||
## API
|
||||
|
||||
```eval_rst
|
||||
|
||||
.. doxygenfile:: lv_dropdown.h
|
||||
:project: lvgl
|
||||
|
||||
```
|
121
Demo/lvgl/docs/widgets/core/img.md
Normal file
121
Demo/lvgl/docs/widgets/core/img.md
Normal file
@ -0,0 +1,121 @@
|
||||
```eval_rst
|
||||
.. include:: /header.rst
|
||||
:github_url: |github_link_base|/widgets/img.md
|
||||
```
|
||||
# Image (lv_img)
|
||||
|
||||
|
||||
## Overview
|
||||
|
||||
Images are the basic object to display images from the flash (as arrays) or externally as files. Images can display symbols (`LV_SYMBOL_...`) too.
|
||||
|
||||
Using the [Image decoder interface](/overview/image.html#image-decoder) custom image formats can be supported as well.
|
||||
|
||||
## Parts and Styles
|
||||
- `LV_PART_MAIN` A background rectangle that uses the typical background style proeprties and the image itself using teh image style proeprties.
|
||||
|
||||
## Usage
|
||||
|
||||
### Image source
|
||||
To provide maximum flexibility, the source of the image can be:
|
||||
|
||||
- a variable in the code (a C array with the pixels).
|
||||
- a file stored externally (like on an SD card).
|
||||
- a text with [Symbols](/overview/font).
|
||||
|
||||
To set the source of an image, use `lv_img_set_src(img, src)`.
|
||||
|
||||
To generate a pixel array from a PNG, JPG or BMP image, use the [Online image converter tool](https://lvgl.io/tools/imageconverter) and set the converted image with its pointer: `lv_img_set_src(img1, &converted_img_var);`
|
||||
To make the variable visible in the C file, you need to declare it with `LV_IMG_DECLARE(converted_img_var)`.
|
||||
|
||||
To use external files, you also need to convert the image files using the online converter tool but now you should select the binary output format.
|
||||
You also need to use LVGL's file system module and register a driver with some functions for the basic file operation. Go to the [File system](/overview/file-system) to learn more.
|
||||
To set an image sourced from a file, use `lv_img_set_src(img, "S:folder1/my_img.bin")`.
|
||||
|
||||
You can set a symbol similarly to [Labels](/widgets/core/label). In this case, the image will be rendered as text according to the *font* specified in the style. It enables to use of light-weighted mono-color
|
||||
"letters" instead of real images. You can set symbol like `lv_img_set_src(img1, LV_SYMBOL_OK)`.
|
||||
|
||||
### Label as an image
|
||||
Images and labels are sometimes used to convey the same thing. For example, to describe what a button does.
|
||||
Therefore, images and labels are somewhat interchangeable, that is the images can display texts by using `LV_SYMBOL_DUMMY` as the prefix of the text. For example, `lv_img_set_src(img, LV_SYMBOL_DUMMY "Some text")`.
|
||||
|
||||
|
||||
### Transparency
|
||||
The internal (variable) and external images support 2 transparency handling methods:
|
||||
|
||||
- **Chrome keying** - Pixels with `LV_COLOR_CHROMA_KEY` (*lv_conf.h*) color will be transparent.
|
||||
- **Alpha byte** - An alpha byte is added to every pixel that contains the pixel's opacity
|
||||
|
||||
### Palette and Alpha index
|
||||
Besides *True color* (RGB) color format, the following formats are also supported:
|
||||
- **Indexed** - Image has a palette.
|
||||
- **Alpha indexed** - Only alpha values are stored.
|
||||
|
||||
These options can be selected in the image converter. To learn more about the color formats, read the [Images](/overview/image) section.
|
||||
|
||||
### Recolor
|
||||
A color can be mixed to every pixel of an image with a given intensity.
|
||||
It is very useful to show different states (checked, inactive, pressed, etc.) of an image without storing more versions of the same image.
|
||||
This feature can be enabled in the style by setting `img_recolor_opa` between `LV_OPA_TRANSP` (no recolor, value: 0) and `LV_OPA_COVER` (full recolor, value: 255).
|
||||
The default value is `LV_OPA_TRANSP` so this feature is disabled.
|
||||
|
||||
The color to mix is set by `img_recolor`.
|
||||
|
||||
### Auto-size
|
||||
Is the width or height of the image object is set to `LV_SIZE_CONTENT` the obejct's size will be set according to the size of image source in the respective direction.
|
||||
|
||||
### Mosaic
|
||||
If the object's size is greater than the image size in any directions, then the image will be repeated like a mosaic.
|
||||
It's a very useful feature to create a large image from only a very narrow source.
|
||||
For example, you can have a *300 x 5* image with a special gradient and set it as a wallpaper using the mosaic feature.
|
||||
|
||||
### Offset
|
||||
With `lv_img_set_offset_x(img, x_ofs)` and `lv_img_set_offset_y(img, y_ofs)`, you can add some offset to the displayed image.
|
||||
It is useful if the object size is smaller than the image source size.
|
||||
Using the offset parameter a [Texture atlas](https://en.wikipedia.org/wiki/Texture_atlas) or a "running image" effect can be created by [Animating](/overview/animation) the x or y offset.
|
||||
|
||||
## Transformations
|
||||
|
||||
Using the `lv_img_set_zoom(img, factor)` the images will be zoomed. Set `factor` to `256` or `LV_IMG_ZOOM_NONE` to disable zooming.
|
||||
A larger value enlarges the images (e.g. `512` double size), a smaller value shrinks it (e.g. `128` half size).
|
||||
Fractional scale works as well. E.g. `281` for 10% enlargement.
|
||||
|
||||
To rotate the image use `lv_img_set_angle(img, angle)`. Angle has 0.1 degree precision, so for 45.8° set 458.
|
||||
|
||||
The `transform_zoom` and `transform_angle` style proeprties are also used to determin the final zoom and angle.
|
||||
|
||||
By default, the pivot point of the rotation is the center of the image. It can be changed with `lv_img_set_pivot(img, pivot_x, pivot_y)`. `0;0` is the top left corner.
|
||||
|
||||
The quality of the transformation can be adjusted with `lv_img_set_antialias(img, true/false)`. With enabled anti-aliasing the transformations has a higher quality but they are slower.
|
||||
|
||||
The transformations require the whole image to be available. Therefore indexed images (`LV_IMG_CF_INDEXED_...`), alpha only images (`LV_IMG_CF_ALPHA_...`) or images from files can not be transformed.
|
||||
In other words transformations work only on true color images stored as C array, or if a custom [Image decoder](/overview/images#image-edecoder) returns the whole image.
|
||||
|
||||
Note that, the real coordinates of image object won't change during transformation. That is `lv_obj_get_width/height/x/y()` will returned the original, non-zoomed coordinates.
|
||||
|
||||
## Events
|
||||
No special events are sendt by the imge objects.
|
||||
|
||||
Learn more about [Events](/overview/event).
|
||||
|
||||
## Keys
|
||||
No *Keys* are processed by the object type.
|
||||
|
||||
Learn more about [Keys](/overview/indev).
|
||||
|
||||
## Example
|
||||
|
||||
```eval_rst
|
||||
|
||||
.. include:: ../../../examples/widgets/img/index.rst
|
||||
|
||||
```
|
||||
|
||||
## API
|
||||
|
||||
```eval_rst
|
||||
|
||||
.. doxygenfile:: lv_img.h
|
||||
:project: lvgl
|
||||
|
||||
```
|
30
Demo/lvgl/docs/widgets/core/index.md
Normal file
30
Demo/lvgl/docs/widgets/core/index.md
Normal file
@ -0,0 +1,30 @@
|
||||
```eval_rst
|
||||
.. include:: /header.rst
|
||||
:github_url: |github_link_base|/object-types/index.md
|
||||
```
|
||||
# Core widgets
|
||||
|
||||
```eval_rst
|
||||
|
||||
.. toctree::
|
||||
:maxdepth: 1
|
||||
|
||||
arc
|
||||
bar
|
||||
btn
|
||||
btnmatrix
|
||||
canvas
|
||||
checkbox
|
||||
dropdown
|
||||
img
|
||||
label
|
||||
line
|
||||
roller
|
||||
slider
|
||||
switch
|
||||
table
|
||||
textarea
|
||||
|
||||
```
|
||||
|
||||
|
90
Demo/lvgl/docs/widgets/core/label.md
Normal file
90
Demo/lvgl/docs/widgets/core/label.md
Normal file
@ -0,0 +1,90 @@
|
||||
```eval_rst
|
||||
.. include:: /header.rst
|
||||
:github_url: |github_link_base|/widgets/core/label.md
|
||||
```
|
||||
# Label (lv_label)
|
||||
|
||||
## Overview
|
||||
A label is the basic object type that is used to display text.
|
||||
|
||||
## Parts and Styles
|
||||
- `LV_PART_MAIN` Uses all the typical background properties and the text properties. The padding values can be used to add space between the text and the background.
|
||||
- `LV_PART_SCROLLBAR` The scrollbar that is shown when the text is larger than the widget's size.
|
||||
- `LV_PART_SELECTED` Tells the style of the [selected text](#text-selection). Only `text_color` and `bg_color` style properties can be used.
|
||||
|
||||
## Usage
|
||||
|
||||
### Set text
|
||||
You can set the text on a label at runtime with `lv_label_set_text(label, "New text")`.
|
||||
It will allocate a buffer dynamically, and the provided string will be copied into that buffer.
|
||||
Therefore, you don't need to keep the text you pass to `lv_label_set_text` in scope after that function returns.
|
||||
|
||||
With `lv_label_set_text_fmt(label, "Value: %d", 15)` printf formatting can be used to set the text.
|
||||
|
||||
Labels are able to show text from a static character buffer. To do so, use `lv_label_set_text_static(label, "Text")`.
|
||||
In this case, the text is not stored in the dynamic memory and the given buffer is used directly instead.
|
||||
This means that the array can't be a local variable which goes out of scope when the function exits.
|
||||
Constant strings are safe to use with `lv_label_set_text_static` (except when used with `LV_LABEL_LONG_DOT`, as it modifies the buffer in-place), as they are stored in ROM memory, which is always accessible.
|
||||
|
||||
### New line
|
||||
|
||||
New line characters are handled automatically by the label object. You can use `\n` to make a line break. For example: `"line1\nline2\n\nline4"`
|
||||
|
||||
### Long modes
|
||||
By default, the width and height of the label is set to `LV_SIZE_CONTENT`therefore the size of the label is automatically expands to the text size.
|
||||
Otherwise, if the width or height is explicitly set (useing e.g.`lv_obj_set_width` or a layout), the lines wider than the label's width can be manipulated according to several long mode policies.
|
||||
Similary, the policies can be applied if the height of the text is greater than the height of the label.
|
||||
- `LV_LABEL_LONG_WRAP` Wrap too long lines. If the height is `LV_SIZE_CONTENT` the label's height will be expanded, elst the text will be clipped. (Default)
|
||||
- `LV_LABEL_LONG_DOT` Replaces the last 3 characters from bottom right corner of the label with dots (`.`)
|
||||
- `LV_LABEL_LONG_SCROLL` If the text is wider than the label scroll it horizontally back and forth. If it's higher, scroll vertically. Only one direction is scrolled and horizontal scrolling has higher precedence.
|
||||
- `LV_LABEL_LONG_SCROLL_CIRCULAR` If the text is wider than the label scroll it horizontally continously. If it's higher, scroll vertically. Only one direction is scrolled and horizontal scrolling has higher precedence.
|
||||
- `LV_LABEL_LONG_CLIP` Simply clip the parts of the text outside of the label.
|
||||
|
||||
You can specify the long mode with `lv_label_set_long_mode(label, LV_LABEL_LONG_...)`
|
||||
|
||||
Note that `LV_LABEL_LONG_DOT` manipulates the text buffer in-place in order to add/remove the dots.
|
||||
When `lv_label_set_text` or `lv_label_set_array_text` are used, a separate buffer is allocated and this implementation detail is unnoticed.
|
||||
This is not the case with `lv_label_set_text_static`. The buffer you pass to `lv_label_set_text_static` must be writable if you plan to use `LV_LABEL_LONG_DOT`.
|
||||
|
||||
### Text recolor
|
||||
In the text, you can use commands to recolor parts of the text. For example: `"Write a #ff0000 red# word"`.
|
||||
This feature can be enabled individually for each label by `lv_label_set_recolor()` function.
|
||||
|
||||
### Text selection
|
||||
If enabled by `LV_LABEL_TEXT_SELECTION` part of the text can be selected. It's similar when on PC a you use your mouse to select a text.
|
||||
The whole mechanzim (click and select the text as you drag your finger/mouse) is implemeted in [Text area](/widgets/core/textarea) and the Label widget allows only to manually make parts of the text selected with
|
||||
`lv_label_get_text_selection_start(label, start_char_index)` and `lv_label_get_text_selection_start(label, end_char_index)`.
|
||||
|
||||
### Very long texts
|
||||
LVGL can efficiently handle very long (e.g. > 40k characters) by saving some extra data (~12 bytes) to speed up drawing. To enable this feature, set `LV_LABEL_LONG_TXT_HINT 1` in `lv_conf.h`.
|
||||
|
||||
### Symbols
|
||||
The labels can display symbols alongside letters (or on their own). Read the [Font](/overview/font) section to learn more about the symbols.
|
||||
|
||||
## Events
|
||||
No special event's are send by the Label.
|
||||
|
||||
Learn more about [Events](/overview/event).
|
||||
|
||||
## Keys
|
||||
No *Keys* are processed by the object type.
|
||||
|
||||
Learn more about [Keys](/overview/indev).
|
||||
|
||||
## Example
|
||||
|
||||
```eval_rst
|
||||
|
||||
.. include:: ../../../examples/widgets/label/index.rst
|
||||
|
||||
```
|
||||
|
||||
## API
|
||||
|
||||
```eval_rst
|
||||
|
||||
.. doxygenfile:: lv_label.h
|
||||
:project: lvgl
|
||||
|
||||
```
|
||||
|
53
Demo/lvgl/docs/widgets/core/line.md
Normal file
53
Demo/lvgl/docs/widgets/core/line.md
Normal file
@ -0,0 +1,53 @@
|
||||
```eval_rst
|
||||
.. include:: /header.rst
|
||||
:github_url: |github_link_base|/widgets/line.md
|
||||
```
|
||||
# Line (lv_line)
|
||||
|
||||
## Overview
|
||||
The Line object is capable of drawing straight lines between a set of points.
|
||||
|
||||
## Parts and Styles
|
||||
- `LV_PART_MAIN` It uses all the typical backgrund properties and the line style properties.
|
||||
|
||||
## Usage
|
||||
|
||||
### Set points
|
||||
The points has to be stored in an `lv_point_t` array and passed to the object by the `lv_line_set_points(lines, point_array, point_cnt)` function.
|
||||
|
||||
### Auto-size
|
||||
By default the Line's width and height is set to `LV_SIZE_CONTENT` to automatically set its size to involve all the points.
|
||||
If the size if set explicitly the point out of the object
|
||||
It can be enable with the `lv_line_set_auto_size(line, true)` function.
|
||||
If enabled then when the points are set the object's width and height will be changed according to the maximal x and y coordinates among the points. The *auto size* is enabled by default.
|
||||
|
||||
### Invert y
|
||||
By deafult, the *y == 0* point is in the top of the object. It might be conter-intuitive in some cases so the y coordinates can be inverted with `lv_line_set_y_invert(line, true)`. In this case, *y == 0* will be the bottom of teh obejct.
|
||||
The *y invert* is disabled by default.
|
||||
|
||||
## Events
|
||||
Only the [Generic events](../overview/event.html#generic-events) are sent by the object type.
|
||||
|
||||
Learn more about [Events](/overview/event).
|
||||
|
||||
## Keys
|
||||
No *Keys* are processed by the object type.
|
||||
|
||||
Learn more about [Keys](/overview/indev).
|
||||
|
||||
## Example
|
||||
|
||||
```eval_rst
|
||||
|
||||
.. include:: ../../../examples/widgets/line/index.rst
|
||||
|
||||
```
|
||||
|
||||
## API
|
||||
|
||||
```eval_rst
|
||||
|
||||
.. doxygenfile:: lv_line.h
|
||||
:project: lvgl
|
||||
|
||||
```
|
60
Demo/lvgl/docs/widgets/core/roller.md
Normal file
60
Demo/lvgl/docs/widgets/core/roller.md
Normal file
@ -0,0 +1,60 @@
|
||||
```eval_rst
|
||||
.. include:: /header.rst
|
||||
:github_url: |github_link_base|/widgets/roller.md
|
||||
```
|
||||
# Roller (lv_roller)
|
||||
|
||||
## Overview
|
||||
|
||||
Roller allows you to simply select one option from more with scrolling.
|
||||
|
||||
## Parts and Styles
|
||||
- `LV_PART_MAIN` The background of the roller that uses all the typical background properties and the text style properties. `style_text_line_space` adjusts the space between the options.
|
||||
When the Roller is scrolled and doesn't stop exactly on an option it will scroll to the nearest valid option automatically in `anim_time` milliseconds as it's specified in the style.
|
||||
- `LV_PART_SELECTED` The selected option in the middle. Besides the typical background properties it uses the text style properties to change the appearance of the text in the selected area.
|
||||
|
||||
## Usage
|
||||
|
||||
### Set options
|
||||
The options are passed to the Roller as a string with `lv_roller_set_options(roller, options, LV_ROLLER_MODE_NORMAL/INFINITE)`. The options should be separated by `\n`. For example: `"First\nSecond\nThird"`.
|
||||
|
||||
`LV_ROLLER_MODE_INFINITE` make the roller circular.
|
||||
|
||||
You can select an option manually with `lv_roller_set_selected(roller, id, LV_ANIM_ON/OFF)`, where *id* is the index of an option.
|
||||
|
||||
### Get selected option
|
||||
The get the currently selected option use `lv_roller_get_selected(roller)` it will return the *index* of the selected option.
|
||||
|
||||
`lv_roller_get_selected_str(roller, buf, buf_size)` copy the name of the selected option to `buf`.
|
||||
|
||||
### Visible rows
|
||||
The number of visible rows can be adjusted with `lv_roller_set_visible_row_count(roller, num)`.
|
||||
|
||||
This function calculates the height with the current style. If the font, line space, border width, etc of the roller changes this function needs to be called again.
|
||||
|
||||
## Events
|
||||
- `LV_EVENT_VALUE_CHANGED` Sent when a new option is selected.
|
||||
|
||||
Learn more about [Events](/overview/event).
|
||||
|
||||
## Keys
|
||||
- `LV_KEY_RIGHT/DOWN` Select the next option
|
||||
- `LV_KEY_LEFT/UP` Select the previous option
|
||||
- `LY_KEY_ENTER` Apply the selected option (Send `LV_EVENT_VALUE_CHANGED` event)
|
||||
|
||||
## Example
|
||||
|
||||
```eval_rst
|
||||
|
||||
.. include:: ../../../examples/widgets/roller/index.rst
|
||||
|
||||
```
|
||||
|
||||
## API
|
||||
|
||||
```eval_rst
|
||||
|
||||
.. doxygenfile:: lv_roller.h
|
||||
:project: lvgl
|
||||
|
||||
```
|
64
Demo/lvgl/docs/widgets/core/slider.md
Normal file
64
Demo/lvgl/docs/widgets/core/slider.md
Normal file
@ -0,0 +1,64 @@
|
||||
```eval_rst
|
||||
.. include:: /header.rst
|
||||
:github_url: |github_link_base|/widgets/slider.md
|
||||
```
|
||||
# Slider (lv_slider)
|
||||
|
||||
## Overview
|
||||
|
||||
The Slider object looks like a [Bar](/widgets/core/bar) supplemented with a knob. The knob can be dragged to set a value. The Slider also can be vertical or horizontal.
|
||||
|
||||
|
||||
## Parts and Styles
|
||||
- `LV_PART_MAIN` The background of the slider and it uses all the typical background style properties. `padding` makes the indicator smaller in the respective direction.
|
||||
- `LV_PART_INDICATOR` The indicator the show the current state of the slider. Also uses all the typical background style properties.
|
||||
- `LV_PART_KNOB` A rectangle (or circle) drawn at the current value. It also uses all the typical background properties to describe the knob(s). By default the knob is square (with a optional radius) with side length equal to the smaller side of the slider. The knob can be made larger with the `padding` values. Padding values can be asymmetric too.
|
||||
|
||||
## Usage
|
||||
|
||||
### Value and range
|
||||
To set an initial value use `lv_slider_set_value(slider, new_value, LV_ANIM_ON/OFF)`. The animation time is set by the styles' `anim_time` property.
|
||||
|
||||
To specify the range (min, max values) the `lv_slider_set_range(slider, min , max)` can be used.
|
||||
|
||||
### Modes
|
||||
The slider can be one the following modes:
|
||||
- `LV_SLIDER_MODE_NORMAL` A normal slider as described above
|
||||
- `LV_SLIDER_SYMMETRICAL` Draw the indicator form the zero value to current value. Requires negaitve minimum range and positive maximum range.
|
||||
- `LV_SLIDER_RANGE` Allows setting the start value too by `lv_bar_set_start_value(bar, new_value, LV_ANIM_ON/OFF)`. The start value has to be always smaller than the end value.
|
||||
|
||||
The mode can be changed with `lv_slider_set_mode(slider, LV_SLIDER_MODE_...)`
|
||||
|
||||
### Knob-only mode
|
||||
Normally, the slider can be adjusted either by dragging the knob, or clicking on the slider bar.
|
||||
In the latter case the knob moves to the point clicked and slider value changes accordingly. In some cases it is desirable to set the slider to react on dragging the knob only.
|
||||
|
||||
This feature is enabled by adding the `LV_OBJ_FLAG_ADV_HITTEST`: `lv_obj_add_flag(slider, LV_OBJ_FLAG_ADV_HITTEST)`.
|
||||
|
||||
## Events
|
||||
- `LV_EVENT_VALUE_CHANGED` Sent while the slider is being dragged or changed with keys.
|
||||
The event is sent continuously while the slider is dragged and only when it is released. Use `lv_slider_is_dragged` to decide whether is slider is being dragged or just released.
|
||||
|
||||
Learn more about [Events](/overview/event).
|
||||
## Keys
|
||||
- `LV_KEY_UP/RIGHT` Increment the slider's value by 1
|
||||
- `LV_KEY_DOWN/LEFT` Decrement the slider's value by 1
|
||||
|
||||
Learn more about [Keys](/overview/indev).
|
||||
|
||||
## Example
|
||||
|
||||
```eval_rst
|
||||
|
||||
.. include:: ../../../examples/widgets/slider/index.rst
|
||||
|
||||
```
|
||||
|
||||
## API
|
||||
|
||||
```eval_rst
|
||||
|
||||
.. doxygenfile:: lv_slider.h
|
||||
:project: lvgl
|
||||
|
||||
```
|
52
Demo/lvgl/docs/widgets/core/switch.md
Normal file
52
Demo/lvgl/docs/widgets/core/switch.md
Normal file
@ -0,0 +1,52 @@
|
||||
```eval_rst
|
||||
.. include:: /header.rst
|
||||
:github_url: |github_link_base|/widgets/switch.md
|
||||
```
|
||||
|
||||
# Switch (lv_switch)
|
||||
|
||||
## Overview
|
||||
|
||||
The Switch can be used to turn on/off something. It looks like a little slider.
|
||||
|
||||
|
||||
## Parts and Styles
|
||||
- `LV_PART_MAIN` The background of the switch and it uses all the typical background style properties. `padding` makes the indicator smaller in the respective direction.
|
||||
- `LV_PART_INDICATOR` The indicator the show the current state of the switch. Also uses all the typical background style properties.
|
||||
- `LV_PART_KNOB` A rectangle (or circle) drawn at left or right side of teh indicator. It also uses all the typical background properties to describe the knob(s). By default the knob is square (with a optional radius) with side length equal to the smaller side of the slider. The knob can be made larger with the `padding` values. Padding values can be asymmetric too.
|
||||
|
||||
## Usage
|
||||
|
||||
### Change state
|
||||
When the switch is turned on it goes to `LV_STATE_CHACKED`. To get the current satte of the switch use `lv_obj_has_state(switch, LV_STATE_CHECHKED)`.
|
||||
To manually turn the switch on/off call `lvobj_add/clear_state(switch, LV_STATE_CHECKED)`.
|
||||
|
||||
|
||||
## Events
|
||||
- `LV_EVENT_VALUE_CHANGED` Sent when the switch changes state.
|
||||
|
||||
Learn more about [Events](/overview/event).
|
||||
|
||||
## Keys
|
||||
- `LV_KEY_UP/RIGHT` Turns on the slider
|
||||
- `LV_KEY_DOWN/LEFT` Turns off the slider
|
||||
- `LV_KEY_ENTER` Toggles the switch
|
||||
|
||||
Learn more about [Keys](/overview/indev).
|
||||
|
||||
## Example
|
||||
|
||||
```eval_rst
|
||||
|
||||
.. include:: ../../../examples/widgets/switch/index.rst
|
||||
|
||||
```
|
||||
|
||||
## API
|
||||
|
||||
```eval_rst
|
||||
|
||||
.. doxygenfile:: lv_switch.h
|
||||
:project: lvgl
|
||||
|
||||
```
|
83
Demo/lvgl/docs/widgets/core/table.md
Normal file
83
Demo/lvgl/docs/widgets/core/table.md
Normal file
@ -0,0 +1,83 @@
|
||||
```eval_rst
|
||||
.. include:: /header.rst
|
||||
:github_url: |github_link_base|/widgets/table.md
|
||||
```
|
||||
# Table (lv_table)
|
||||
|
||||
## Overview
|
||||
|
||||
Tables, as usual, are built from rows, columns, and cells containing texts.
|
||||
|
||||
The Table object is very light weighted because only the texts are stored. No real objects are created for cells but they are just drawn on the fly.
|
||||
|
||||
|
||||
## Parts and Styles
|
||||
- `LV_PART_MAIN` The background of the table and uses all the typical background style properties.
|
||||
- `LV_PART_ITEMS` The cells of the table and they also use all the typical background style properties and the text properties.
|
||||
|
||||
|
||||
## Usage
|
||||
|
||||
### Set cell value
|
||||
|
||||
The cells can store only texts so numbers needs to be converted to text before displaying them in a table.
|
||||
|
||||
`lv_table_set_cell_value(table, row, col, "Content")`. The text is saved by the table so it can be even a local variable.
|
||||
|
||||
Line break can be used in the text like `"Value\n60.3"`.
|
||||
|
||||
The new rows and column are automatically added is required
|
||||
|
||||
### Rows and Columns
|
||||
|
||||
To explicitly set number of rows and columns use `lv_table_set_row_cnt(table, row_cnt)` and `lv_table_set_col_cnt(table, col_cnt)`
|
||||
|
||||
### Width and Height
|
||||
|
||||
The width of the columns can be set with `lv_table_set_col_width(table, col_id, width)`. The overall width of the Table object will be set to the sum of columns widths.
|
||||
|
||||
The height is calculated automatically from the cell styles (font, padding etc) and the number of rows.
|
||||
|
||||
### Merge cells
|
||||
|
||||
Cells can be merged horizontally with `lv_table_set_cell_merge_right(table, col, row, true)`. To merge more adjacent cells apply this function for each cell.
|
||||
|
||||
### Scroll
|
||||
If the label's width or height is set to `LV_SIZE_CONTENT` that size will be se to show the whole table in the respective direction.
|
||||
E.g. `lv_obj_set_size(table, LV_SIZE_CONTENT, LV_SIZE_CONTENT)` automatically sets the table size to show all the columns and rows.
|
||||
|
||||
If the width or height is set to smaller number than the "intrinsic" size then the table becomes scrollable.
|
||||
|
||||
## Events
|
||||
- `LV_EVENT_DRAW_PART_BEGIN` and `LV_EVENT_DRAW_PART_END` are sent for both main and items parts to allow hooking the drawing.
|
||||
The for more detail on the main part see the [Base object](/widgets/obj#events)'s documentation.
|
||||
For the items (sells) the following fields are used: `clip_area`, `draw_area`, `part`, `rect_dsc`, `label_dsc` `id` (current row × col count + current column).
|
||||
|
||||
|
||||
Learn more about [Events](/overview/event).
|
||||
|
||||
## Keys
|
||||
|
||||
No *Keys* are processed by the object type.
|
||||
|
||||
Learn more about [Keys](/overview/indev).
|
||||
|
||||
## Example
|
||||
|
||||
```eval_rst
|
||||
|
||||
.. include:: ../../../examples/widgets/table/index.rst
|
||||
|
||||
```
|
||||
|
||||
### MicroPython
|
||||
No examples yet.
|
||||
|
||||
## API
|
||||
|
||||
```eval_rst
|
||||
|
||||
.. doxygenfile:: lv_table.h
|
||||
:project: lvgl
|
||||
|
||||
```
|
124
Demo/lvgl/docs/widgets/core/textarea.md
Normal file
124
Demo/lvgl/docs/widgets/core/textarea.md
Normal file
@ -0,0 +1,124 @@
|
||||
```eval_rst
|
||||
.. include:: /header.rst
|
||||
:github_url: |github_link_base|/widgets/textarea.md
|
||||
```
|
||||
# Text area (lv_textarea)
|
||||
|
||||
## Overview
|
||||
|
||||
The Text Area is a [Base object](widgets/obj) with a [Label](/widgets/core/label) and a cursor on it.
|
||||
Texts or characters can be added to it.
|
||||
Long lines are wrapped and when the text becomes long enough the Text area can be scrolled.
|
||||
|
||||
One line mode and password modes are supported.
|
||||
|
||||
## Parts and Styles
|
||||
- `LV_PART_MAIN` The background of the text area and it uses all the typical backgrond style properties and the text related style properties including `text_align` to align the text to the left, right or center.
|
||||
- `LV_PART_SCROLLBAR` The scrollbar that is shown when the text is too long.
|
||||
- `LV_PART_SELECTED` Tells the style of the [selected text](#text-selection). Only `text_color` and `bg_color` style properties can be used.
|
||||
- `LV_PART_CURSOR` Marks the position where the characters are inserted. The cursor's area is always the bounding box of the current character.
|
||||
A block cursor can be created by adding a background color and background opacity to `LV_PART_CURSOR`'s style. The create line cursor let the cursor transparent and set a left border.
|
||||
The `anim_time` style property sets the cursors blink time.
|
||||
- `LV_PART_TEXTAREA_PLACEHOLDER` It's a part related only to the text area and allows styling the placeholder text.
|
||||
|
||||
## Usage
|
||||
|
||||
### Add text
|
||||
|
||||
You can insert text or characters to the current cursor's position with:
|
||||
|
||||
- `lv_textarea_add_char(textarea, 'c')`
|
||||
- `lv_textarea_add_text(textarea, "insert this text")`
|
||||
|
||||
To add wide characters like `'á'`, `'ß'` or CJK characters use `lv_textarea_add_text(ta, "á")`.
|
||||
|
||||
`lv_textarea_set_text(ta, "New text")` changes the whole text.
|
||||
|
||||
### Placeholder
|
||||
|
||||
A placeholder text can be specified - which is displayed when the Text area is empty - with `lv_textarea_set_placeholder_text(ta, "Placeholder text")`
|
||||
|
||||
### Delete character
|
||||
|
||||
To delete a character from the left of the current cursor position use `lv_textarea_del_char(textarea)`.
|
||||
To delete from the right use `lv_textarea_del_char_forward(textarea)`
|
||||
|
||||
### Move the cursor
|
||||
|
||||
The cursor position can be modified directly like `lv_textarea_set_cursor_pos(textarea, 10)`.
|
||||
The `0` position means "before the first characters",
|
||||
`LV_TA_CURSOR_LAST` means "after the last character"
|
||||
|
||||
You can step the cursor with
|
||||
- `lv_textarea_cursor_right(textarea)`
|
||||
- `lv_textarea_cursor_left(textarea)`
|
||||
- `lv_textarea_cursor_up(textarea)`
|
||||
- `lv_textarea_cursor_down(textarea)`
|
||||
|
||||
If `lv_textarea_set_cursor_click_pos(textarea, true)` is applied the cursor will jump to the position where the Text area was clicked.
|
||||
|
||||
### Hide the cursor
|
||||
The cursor is always visible, hiwever it can be good idea to style to be visible only in `LV_STATE_FOCUSED` state.
|
||||
|
||||
### One line mode
|
||||
The Text area can be configures to be one lined with `lv_textarea_set_one_line(textarea, true)`.
|
||||
In this mode the height is set automatically to show only one line, line break character are ignored, and word wrap is disabled.
|
||||
|
||||
### Password mode
|
||||
The text area supports password mode which can be enabled with `lv_textarea_set_password_mode(textarea, true)`.
|
||||
|
||||
If the `•` ([Bullet, U+2022](http://www.fileformat.info/info/unicode/char/2022/index.htm)) character exists in the font, the entered characters are converted to it after some time or when a new character is entered.
|
||||
If `•` not exists, `*` will be used.
|
||||
|
||||
In password mode `lv_textarea_get_text(textarea)` gives the real text, not the bullet characters.
|
||||
|
||||
The visibility time can be adjusted with `LV_TEXTAREA_DEF_PWD_SHOW_TIME)` in `lv_conf.h`.
|
||||
|
||||
### Accepted characters
|
||||
You can set a list of accepted characters with `lv_textarae_set_accepted_chars(textarea, "0123456789.+-")`.
|
||||
Other characters will be ignored.
|
||||
|
||||
### Max text length
|
||||
The maximum number of characters can be limited with `lv_textarea_set_max_length(textarea, max_char_num)`
|
||||
|
||||
### Very long texts
|
||||
If there is a very long text in the Text area (e. g. > 20k characters) its scrolling and drawing might be slow.
|
||||
However, by enabling `LV_LABEL_LONG_TXT_HINT 1` in `lv_conf.h` the performance can be hugely improved.
|
||||
It will save some information about the label to speed up its drawing.
|
||||
Using `LV_LABEL_LONG_TXT_HINT` the scrolling and drawing will as fast as with "normal" short texts.
|
||||
|
||||
### Select text
|
||||
A part of text can be selected if enabled with `lv_textarea_set_text_selection(textarea, true)`.
|
||||
It works like when you select a text on your PC with your mouse.
|
||||
|
||||
## Events
|
||||
- `LV_EVENT_INSERT` Sent when before a character or text is inserted.
|
||||
The event paramter is the text planned to be inserted. `lv_textarea_set_insert_replace(textarea, "New text")` replaces the text to insert.
|
||||
The new text can not be in a local variable which is destroyed when the event callback exists. `""` means do not insert anything.
|
||||
- `LV_EVENT_VALUE_CHANGED` Sent when the content of the text area has been changed.
|
||||
- `LV_EVENT_APPLY` Sent when `LV_KEY_ENTER` is pressed (or(sent) to a one line text area.
|
||||
|
||||
Learn more about [Events](/overview/event).
|
||||
|
||||
## Keys
|
||||
- `LV_KEY_UP/DOWN/LEFT/RIGHT` Move the cursor
|
||||
- `Any character` Add the character to the current cursor position
|
||||
|
||||
Learn more about [Keys](/overview/indev).
|
||||
|
||||
## Example
|
||||
|
||||
```eval_rst
|
||||
|
||||
.. include:: ../../../examples/widgets/textarea/index.rst
|
||||
|
||||
```
|
||||
|
||||
## API
|
||||
|
||||
```eval_rst
|
||||
|
||||
.. doxygenfile:: lv_textarea.h
|
||||
:project: lvgl
|
||||
|
||||
```
|
Reference in New Issue
Block a user