acid-drop

- Hacking the planet from a LilyGo T-Deck using custom firmware
git clone git://git.acid.vegas/acid-drop.git
Log | Files | Refs | Archive | README | LICENSE

roller.md (2206B)

      1 ```eval_rst
      2 .. include:: /header.rst
      3 :github_url: |github_link_base|/widgets/core/roller.md
      4 ```
      5 # Roller (lv_roller)
      6 
      7 ## Overview
      8 
      9 Roller allows you to simply select one option from a list by scrolling.
     10 
     11 ## Parts and Styles
     12 - `LV_PART_MAIN` The background of the roller uses all the typical background properties and text style properties. `style_text_line_space` adjusts the space between the options.
     13 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 specified in the style.
     14 - `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.
     15 
     16 ## Usage
     17 
     18 ### Set options
     19 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"`.
     20 
     21 `LV_ROLLER_MODE_INFINITE` makes the roller circular.
     22 
     23 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.
     24 
     25 ### Get selected option
     26 To get the *index* of the currently selected option use `lv_roller_get_selected(roller)`.
     27 
     28 `lv_roller_get_selected_str(roller, buf, buf_size)` will copy the name of the selected option to `buf`.
     29 
     30 ### Visible rows
     31 The number of visible rows can be adjusted with `lv_roller_set_visible_row_count(roller, num)`.
     32 
     33 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.
     34 
     35 ## Events
     36 - `LV_EVENT_VALUE_CHANGED` Sent when a new option is selected.
     37 
     38 See the events of the [Base object](/widgets/obj) too.
     39 
     40 Learn more about [Events](/overview/event).
     41 
     42 ## Keys
     43 - `LV_KEY_RIGHT/DOWN` Select the next option
     44 - `LV_KEY_LEFT/UP` Select the previous option
     45 - `LY_KEY_ENTER` Apply the selected option (Send `LV_EVENT_VALUE_CHANGED` event)
     46 
     47 ## Example
     48 
     49 ```eval_rst
     50 
     51 .. include:: ../../../examples/widgets/roller/index.rst
     52 
     53 ```
     54 
     55 ## API
     56 
     57 ```eval_rst
     58 
     59 .. doxygenfile:: lv_roller.h
     60   :project: lvgl
     61 
     62 ```