App:Library:LVGL:docs:Widgets:Drop-down list (lv dropdown)

提供: robot-jp wiki
ナビゲーションに移動検索に移動

https://docs.lvgl.io/8.2/widgets/core/arc.html

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 again.

The Drop-down list is added to the default group (if it is set). Besides the Drop-down list is an editable object to allow selecting an option with encoder navigation too.

ドロップダウンリストを使用すると、ユーザーはリストから1つの値を選択できます。

ドロップダウンリストはデフォルトで閉じられており、単一の値または事前定義されたテキストが表示されます。(ドロップダウンリストをクリックして)アクティブ化すると、ユーザーが1つのオプションを選択できるリストが作成されます。ユーザーが新しい値を選択すると、リストは再び削除されます。

ドロップダウンリストがデフォルトグループに追加されます(設定されている場合)。ドロップダウンリストのほかに、エンコーダナビゲーションでオプションを選択できるようにする編集可能なオブジェクトがあります。

戻る : Previous


Parts and Styles

英文 自動翻訳

The Dropdown widget is built from the elements: "button" and "list" (both not related to the button and list widgets)

ドロップダウンウィジェットは、「ボタン」と「リスト」の要素から構築されています(どちらもボタンウィジェットとリストウィジェットには関係ありません)。
戻る : Previous


Button

英文 自動翻訳
  • LV_PART_MAIN The background of the button. Uses the typical background properties and text properties 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 when it's opened.

  • LV_PART_MAINボタンの背景。その上のテキストに一般的な背景プロパティとテキストプロパティを使用します。
  • LV_PART_INDICATOR通常、画像またはテキスト(LV_SYMBOL)の矢印記号。

ボタンが開くとLV_STATE_CHECKEDになる。

戻る : Previous


List

英文 自動翻訳
  • LV_PART_MAIN The list itself. Uses the typical background properties. max_height can be used to limit the height of the list.
  • LV_PART_SCROLLBAR The scrollbar background, border, shadow properties and width (for its own width) and right padding for the spacing on the right.
  • LV_PART_SELECTED Refers to the currently pressed, checked or pressed+checked option. Also uses the typical background properties.


The list is hidden/shown on open/close.

To add styles to it use lv_dropdown_get_list(dropdown) to get the list object.


For example:

lv_obj_t * list = lv_dropdown_get_list(dropdown) /*Get the list*/
lv_obj_add_style(list, &my_style, ...)           /*Add the styles to the list*/}`

Alternatively the theme can be extended with the new styles.

  • LV_PART_MAINリスト自体。一般的な背景プロパティを使用します。max_heightリストの高さを制限するために使用できます。
  • LV_PART_SCROLLBARスクロールバーの背景、境界線、影のプロパティと幅(独自の幅の場合)、および右側の間隔の右側のパディング。
  • LV_PART_SELECTED現在押されている、チェックされている、または押されている+チェックされているオプションを指します。また、一般的な背景プロパティを使用します。


リストは、開いた/閉じたときに非表示/表示されます。

これにスタイルを追加するには、lv_dropdown_get_list(dropdown)を使ってリスト・オブジェクトを取得します。


例えば:

lv_obj_t * list = lv_dropdown_get_list(dropdown)/*リストを取得*/
lv_obj_add_style(list、&my_style、...)/*スタイルをリストに追加*/} `

または、テーマを新しいスタイルで拡張することもできます。

戻る : Previous


Usage

Overview

Set options

英文 自動翻訳

Options are passed to the drop-down list as a string with lv_dropdown_set_options(dropdown, options).

Options should be separated by \n.

For example: "First\nSecond\nThird".


This string will be saved in the drop-down list, so it can in a local variable.

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.

オプションは、lv_dropdown_set_options(dropdown, options)の文字列としてドロップダウンリストに渡されます。

オプションは\nで区切る必要があります。

例:"First\nSecond\nThird"


この文字列はドロップダウンリストに保存されるため、ローカル変数に格納できます。

lv_dropdown_add_option(dropdown, "New option", pos)関数は、posインデックスに新しいオプションを挿入します。


メモリを節約するために、lv_dropdown_set_static_options(dropdown, options)を使用して、オプションを静的な (定数の) 文字列から設定することもできます。


この場合、ドロップダウンリストが存在し、lv_dropdown_add_optionを使用できない間は、オプション文字列を有効にする必要があります。

lv_dropdown_set_selected(dropdown, id)を使用してオプションを手動で選択できます。ここで、idはオプションのインデックスです。

戻る : Previous


Get selected option

英文 自動翻訳

The get the index of the selected option, use lv_dropdown_get_selected(dropdown).

lv_dropdown_get_selected_str(dropdown, buf, buf_size) copies the name of the selected option to buf.

選択されたオプションのインデックスを得るには、 lv_dropdown_get_selected(dropdown)を使用します。

lv_dropdown_get_selected_str(dropdown, buf, buf_size) は選択されたオプションの名前を buf にコピーします。

戻る : Previous


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 be aligned to the edge.

リストはどの側にも作成できる。デフォルトのLV_DIR_BOTTOMlv_dropdown_set_dir(dropdown, LV_DIR_LEFT/RIGHT/UP/BOTTOM)関数で変更することができる。

リストが垂直方向に画面からはみ出してしまう場合は、端に揃えるようにします。

戻る : Previous


Symbol

英文 自動翻訳

A symbol (typically an arrow) can be added to the dropdown 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, otherwise on the right.

シンボル(通常は矢印)は、lv_dropdown_set_symbol(dropdown, LV_SYMBOL_...)でドロップダウン・リストに追加することができる。

ドロップダウン・リストの方向がLV_DIR_LEFTであれば、シンボルは左に表示され、そうでなければ右に表示されます。

戻る : Previous


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.

If the text is NULL the selected option is displayed on the button.

メインパートは、選択されたオプションか静的テキストを表示することができます。

lv_dropdown_set_text(dropdown, "Some text") で静的テキストを設定すると、選択されたオプションに関係なくテキストが表示されます。

text が NULL の場合、選択されたオプションがボタン上に表示されます。

戻る : Previous


Manually open/close

英文 自動翻訳

To manually open or close the drop-down list the lv_dropdown_open/close(dropdown) function can be used.

手動でドロップダウンリストを開いたり閉じたりするには, lv_dropdown_open/close(dropdown)関数を使用します.
戻る : Previous


Events

英文 自動翻訳

Apart from the Generic events, the following 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.
  • LV_EVENT_CANCEL Sent when the list is closed
  • LV_EVENT_READY Sent when the list is opened


See the events of the Base object too.

Learn more about Events.

一般的なイベントとは別に、ドロップダウン・リストから以下の特別なイベントが送信される。
  • LV_EVENT_VALUE_CHANGED 新しいオプションが選択されたとき、またはリストが開かれたり閉じられたりしたときに送信されます。
  • LV_EVENT_CANCEL リストが閉じられたときに送信されます。
  • LV_EVENT_READY リストが開かれたときに送られます。


Baseオブジェクトのイベントもご覧ください。

イベントの詳細を確認してください。

戻る : Previous


Keys

英文 自動翻訳
  • LV_KEY_RIGHT/DOWN Select the next option.
  • LV_KEY_LEFT/UP Select the previous option.
  • LY_KEY_ENTER Apply the selected option (Sends LV_EVENT_VALUE_CHANGED event and closes the drop-down list).


Learn more about Keys.

  • LV_KEY_RIGHT/DOWN 次のオプションを選択します。
  • LV_KEY_LEFT/UP 前のオプションを選択します。
  • LY_KEY_ENTER 選択したオプションを適用します LV_EVENT_VALUE_CHANGEDイベントを送信し、ドロップダウンリストを閉じます)。


キーの詳細を確認してください。

戻る : Previous


Example

英文 自動翻訳

Simple Drop down list

LVGL docs example 072.png

Drop down in four directions

LVGL docs example 073.png

Menu

LVGL docs example 074.png

戻る : Previous


API

英文 自動翻訳

Functions

LV_EXPORT_CONST_INT(LV_DROPDOWN_POS_LAST)

lv_obj_t *lv_dropdown_create(lv_obj_t *parent)

Create a drop-down list object
Parameters
parent -- pointer to an object, it will be the parent of the new drop-down list
Returns
pointer to the created drop-down list

void lv_dropdown_set_text(lv_obj_t *obj, const char *txt)

Set text of the drop-down list's button. If set to NULL the selected option's text will be displayed on the button. If set to a specific text then that text will be shown regardless of the selected option.
Parameters
  • obj -- pointer to a drop-down list object
  • txt -- the text as a string (Only its pointer is saved)

void lv_dropdown_set_options(lv_obj_t *obj, const char *options)

Set the options in a drop-down list from a string. The options will be copied and saved in the object so the options can be destroyed after calling this function
Parameters
  • obj -- pointer to drop-down list object
  • options -- a string with ' ' separated options. E.g. "One\nTwo\nThree"

void lv_dropdown_set_options_static(lv_obj_t *obj, const char *options)

Set the options in a drop-down list from a static string (global, static or dynamically allocated). Only the pointer of the option string will be saved.
Parameters
  • obj -- pointer to drop-down list object
  • options -- a static string with ' ' separated options. E.g. "One\nTwo\nThree"

void lv_dropdown_add_option(lv_obj_t *obj, const char *option, uint32_t pos)

Add an options to a drop-down list from a string. Only works for non-static options.
Parameters
  • obj -- pointer to drop-down list object
  • option -- a string without ' '. E.g. "Four"
  • pos -- the insert position, indexed from 0, LV_DROPDOWN_POS_LAST = end of string

void lv_dropdown_clear_options(lv_obj_t *obj)

Clear all options in a drop-down list. Works with both static and dynamic options.
Parameters
obj -- pointer to drop-down list object

void lv_dropdown_set_selected(lv_obj_t *obj, uint16_t sel_opt)

Set the selected option
Parameters
  • obj -- pointer to drop-down list object
  • sel_opt -- id of the selected option (0 ... number of option - 1);

void lv_dropdown_set_dir(lv_obj_t *obj, lv_dir_t dir)

Set the direction of the a drop-down list
Parameters
  • obj -- pointer to a drop-down list object
  • dir -- LV_DIR_LEFT/RIGHT/TOP/BOTTOM

void lv_dropdown_set_symbol(lv_obj_t *obj, const void *symbol)

Set an arrow or other symbol to display when on drop-down list's button. Typically a down caret or arrow.
Note angle and zoom transformation can be applied if the symbol is an image. E.g. when drop down is checked (opened) rotate the symbol by 180 degree
Parameters
  • obj -- pointer to drop-down list object
  • symbol -- a text like LV_SYMBOL_DOWN, an image (pointer or path) or NULL to not draw symbol icon

void lv_dropdown_set_selected_highlight(lv_obj_t *obj, bool en)

Set whether the selected option in the list should be highlighted or not
Parameters
  • obj -- pointer to drop-down list object
  • en -- true: highlight enabled; false: disabled

lv_obj_t *lv_dropdown_get_list(lv_obj_t *obj)

Get the list of a drop-down to allow styling or other modifications
Parameters
obj -- pointer to a drop-down list object
Returns
pointer to the list of the drop-down

const char *lv_dropdown_get_text(lv_obj_t *obj)

Get text of the drop-down list's button.
Parameters
obj -- pointer to a drop-down list object
Returns
the text as string, NULL if no text

const char *lv_dropdown_get_options(const lv_obj_t *obj)

Get the options of a drop-down list
Parameters
obj -- pointer to drop-down list object
Returns
the options separated by ' '-s (E.g. "Option1\nOption2\nOption3")

uint16_t lv_dropdown_get_selected(const lv_obj_t *obj)

Get the index of the selected option
Parameters
obj -- pointer to drop-down list object
Returns
index of the selected option (0 ... number of option - 1);

uint16_t lv_dropdown_get_option_cnt(const lv_obj_t *obj)

Get the total number of options
Parameters
obj -- pointer to drop-down list object
Returns
the total number of options in the list

void lv_dropdown_get_selected_str(const lv_obj_t *obj, char *buf, uint32_t buf_size)

Get the current selected option as a string
Parameters
  • obj -- pointer to drop-down object
  • buf -- pointer to an array to store the string
  • buf_size -- size of buf in bytes. 0: to ignore it.

const char *lv_dropdown_get_symbol(lv_obj_t *obj)

Get the symbol on the drop-down list. Typically a down caret or arrow.
Parameters
obj -- pointer to drop-down list object
Returns
the symbol or NULL if not enabled

bool lv_dropdown_get_selected_highlight(lv_obj_t *obj)

Get whether the selected option in the list should be highlighted or not
Parameters
obj -- pointer to drop-down list object
Returns
true: highlight enabled; false: disabled

lv_dir_t lv_dropdown_get_dir(const lv_obj_t *obj)

Get the direction of the drop-down list
Parameters
obj -- pointer to a drop-down list object
Returns
LV_DIR_LEF/RIGHT/TOP/BOTTOM

void lv_dropdown_open(lv_obj_t *dropdown_obj)

Open the drop.down list
Parameters
obj -- pointer to drop-down list object

void lv_dropdown_close(lv_obj_t *obj)

Close (Collapse) the drop-down list
Parameters
obj -- pointer to drop-down list object

bool lv_dropdown_is_open(lv_obj_t *obj)

Tells whether the list is opened or not
Parameters
obj -- pointer to a drop-down list object
Returns
true if the list os opened

Variables

const lv_obj_class_t lv_dropdown_class

const lv_obj_class_t lv_dropdownlist_class

struct lv_dropdown_t

Public Members
lv_obj_t obj
lv_obj_t *list
The dropped down list
const char *text
Text to display on the dropdown's button
const void *symbol
Arrow or other icon when the drop-down list is closed
char *options
Options in a ' ' separated list
uint16_t option_cnt
Number of options
uint16_t sel_opt_id
Index of the currently selected option
uint16_t sel_opt_id_orig
Store the original index on focus
uint16_t pr_opt_id
Index of the currently pressed option
lv_dir_t dir
Direction in which the list should open
uint8_t static_txt
1: Only a pointer is saved in options
uint8_t selected_highlight
1: Make the selected option highlighted in the list

struct lv_dropdown_list_t

Public Members
lv_obj_t obj
lv_obj_t *dropdown


機能

LV_EXPORT_CONST_INT(LV_DROPDOWN_POS_LAST)

lv_obj_t * lv_dropdown_create(lv_obj_t * parent)

ドロップダウンリストオブジェクトを作成する
パラメーター
parent-オブジェクトへのポインタ。新しいドロップダウンリストの親になります
戻り値
作成されたドロップダウンリストへのポインタ

void lv_dropdown_set_text(lv_obj_t * obj、const char * txt)

ドロップダウンリストのボタンのテキストを設定します。選択したオプションに設定するとNULL、ボタンにテキストが表示されます。特定のテキストに設定すると、選択したオプションに関係なく、そのテキストが表示されます。
パラメーター
  • obj-ドロップダウンリストオブジェクトへのポインタ
  • txt-文字列としてのテキスト(ポインタのみが保存されます)

void lv_dropdown_set_options(lv_obj_t * obj、const char * options)

文字列からドロップダウンリストにオプションを設定します。オプションがコピーされてオブジェクトに保存されるため、optionsこの関数を呼び出した後にを破棄できます
パラメーター
  • obj-ドロップダウンリストオブジェクトへのポインタ
  • options-''で区切られたオプションを持つ文字列。例:「1つ\n2つ\n3つ」

void lv_dropdown_set_options_static(lv_obj_t * obj、const char * options)

静的文字列(グローバル、静的、または動的に割り当てられた)からドロップダウンリストのオプションを設定します。オプション文字列のポインタのみが保存されます。
パラメーター
  • obj-ドロップダウンリストオブジェクトへのポインタ
  • options-''で区切られたオプションを持つ静的文字列。例:「1つ\n2つ\n3つ」

void lv_dropdown_add_option(lv_obj_t * obj、const char * option、uint32_t pos)

文字列からドロップダウンリストにオプションを追加します。非静的オプションでのみ機能します。
パラメーター
  • obj-ドロップダウンリストオブジェクトへのポインタ
  • オプション-''のない文字列。例:「4」
  • pos-0からインデックス付けされた挿入位置、LV_DROPDOWN_POS_LAST=文字列の終わり

void lv_dropdown_clear_options(lv_obj_t * obj)

ドロップダウンリストのすべてのオプションをクリアします。静的オプションと動的オプションの両方で機能します。
パラメーター
obj-ドロップダウンリストオブジェクトへのポインタ

void lv_dropdown_set_selected(lv_obj_t * obj、uint16_t sel_opt)

選択したオプションを設定します
パラメーター
  • obj-ドロップダウンリストオブジェクトへのポインタ
  • sel_opt-選択したオプションのID(0 ...オプションの数-1);

void lv_dropdown_set_dir(lv_obj_t * obj、lv_dir_t dir)

ドロップダウンリストの方向を設定します
パラメーター
  • obj-ドロップダウンリストオブジェクトへのポインタ
  • dir-LV_DIR_LEFT / RIGHT / TOP / BOTTOM

void lv_dropdown_set_symbol(lv_obj_t * obj、const void * symbol)

ドロップダウンリストのボタンに表示される矢印またはその他の記号を設定します。通常、ダウンキャレットまたは矢印。
シンボルが画像の場合は、角度とズームの変換を適用できることに注意してください。たとえば、ドロップダウンがチェックされている(開いている)場合、シンボルを180度回転します
パラメーター
  • obj-ドロップダウンリストオブジェクトへのポインタ
  • ドロップダウンリストを使用すると、ユーザーはリストから1つの値を選択できます。LV_SYMBOL_DOWNシンボル- 、画像(ポインタまたはパス)などのテキスト、またはシンボルアイコンを描画しない場合はNULL

void lv_dropdown_set_selected_highlight(lv_obj_t * obj、bool en)

リストで選択したオプションを強調表示するかどうかを設定します
パラメーター
  • obj-ドロップダウンリストオブジェクトへのポインタ
  • en --true:ハイライトを有効にします。false:無効

lv_obj_t * lv_dropdown_get_list(lv_obj_t * obj)

ドロップダウンのリストを取得して、スタイリングやその他の変更を許可します
パラメーター
obj-ドロップダウンリストオブジェクトへのポインタ
戻り値
ドロップダウンのリストへのポインタ

const char * lv_dropdown_get_text(lv_obj_t * obj)

ドロップダウンリストのボタンのテキストを取得します。
パラメーター
obj-ドロップダウンリストオブジェクトへのポインタ
戻り値
テキストがない場合は、文字列としてNULLのテキスト

const char * lv_dropdown_get_options(const lv_obj_t * obj)

ドロップダウンリストのオプションを取得する
パラメーター
obj-ドロップダウンリストオブジェクトへのポインタ
戻り値
'' -sで区切られたオプション(例: "Option1 \ nOption2 \ nOption3")

uint16_t lv_dropdown_get_selected(const lv_obj_t * obj)

選択したオプションのインデックスを取得します
パラメーター
obj-ドロップダウンリストオブジェクトへのポインタ
戻り値
選択したオプションのインデックス(0 ...オプションの数-1);

uint16_t lv_dropdown_get_option_cnt(const lv_obj_t * obj)

オプションの総数を取得する
パラメーター
obj-ドロップダウンリストオブジェクトへのポインタ
戻り値
リスト内のオプションの総数

void lv_dropdown_get_selected_str(const lv_obj_t * obj、char * buf、uint32_t buf_size)

現在選択されているオプションを文字列として取得します
パラメーター
  • obj-ドロップダウンオブジェクトへのポインタ
  • buf--文字列を格納する配列へのポインタ
  • buf_size-bufバイト単位のサイズ。0:無視します。

const char * lv_dropdown_get_symbol(lv_obj_t * obj)

ドロップダウンリストでシンボルを取得します。通常、ダウンキャレットまたは矢印。
パラメーター
obj-ドロップダウンリストオブジェクトへのポインタ
戻り値
シンボルまたは有効になっていない場合はNULL

bool lv_dropdown_get_selected_highlight(lv_obj_t * obj)

リストで選択したオプションを強調表示するかどうかを取得します
パラメーター
obj-ドロップダウンリストオブジェクトへのポインタ
戻り値
true:ハイライトが有効です。false:無効

lv_dir_t lv_dropdown_get_dir(const lv_obj_t * obj)

ドロップダウンリストの方向を取得します
パラメーター
obj-ドロップダウンリストオブジェクトへのポインタ
戻り値
LV_DIR_LEF / RIGHT / TOP / BOTTOM

void lv_dropdown_open(lv_obj_t * dropdown_obj)

ドロップダウンリストを開きます
パラメーター
obj-ドロップダウンリストオブジェクトへのポインタ

void lv_dropdown_close(lv_obj_t * obj)

ドロップダウンリストを閉じる(折りたたむ)
パラメーター
obj-ドロップダウンリストオブジェクトへのポインタ

bool lv_dropdown_is_open(lv_obj_t * obj)

リストが開かれているかどうかを示します
パラメーター
obj-ドロップダウンリストオブジェクトへのポインタ
戻り値
リストが開いている場合はtrue

変数

const lv_obj_class_t lv_dropdown_class

const lv_obj_class_t lv_dropdownlist_class

struct lv_dropdown_t

パブリックメンバー
lv_obj_t obj
lv_obj_t * list
ドロップダウンリスト
const char * text
ドロップダウンのボタンに表示するテキスト
const void * symbol
ドロップダウンリストを閉じたときの矢印またはその他のアイコン
char * options
''で区切られたリストのオプション
uint16_t option_cnt
オプションの数
uint16_t sel_opt_id
現在選択されているオプションのインデックス
uint16_t sel_opt_id_orig
元のインデックスをフォーカスに保存
uint16_t pr_opt_id
現在押されているオプションのインデックス
lv_dir_t dir
リストを開く方向
uint8_t static_txt
1:ポインタのみが保存されますoptions
uint8_t selected_highlight
1:選択したオプションをリストで強調表示します

struct lv_dropdown_list_t

パブリックメンバー
lv_obj_t obj
lv_obj_t*ドロップダウン



戻る : Previous