App:Library:LVGL:docs:Layouts:Grid

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

https://docs.lvgl.io/8.2/widgets/index.html

Grid

Overview

英文 自動翻訳

The Grid layout is a subset of CSS Flexbox.

It can arrange items into a 2D "table" that has rows or columns (tracks). The item can span through multiple columns or rows. The track's size can be set in pixel, to the largest item (LV_GRID_CONTENT) or in "Free unit" (FR) to distribute the free space proportionally.

To make an object a grid container call lv_obj_set_layout(obj, LV_LAYOUT_GRID).

Note that the grid layout feature of LVGL needs to be globally enabled with LV_USE_GRID in lv_conf.h.

グリッドレイアウトはCSSFlexboxのサブセットです。

行または列(トラック)を持つ2D「テーブル」にアイテムを配置できます。アイテムは、複数の列または行にまたがることができます。トラックのサイズは、ピクセル単位、最大項目(LV_GRID_CONTENT)、または「空き単位」(FR)で設定して、空き領域を比例配分することができます。

オブジェクトをグリッドコンテナにするには、lv_obj_set_layout(obj, LV_LAYOUT_GRID)を呼び出します。

LVGLのグリッドレイアウト機能は、lv_conf.hの中のLV_USE_GRIDでグローバルに有効にする必要があることに注意してください。

戻る : Previous


Terms

英文 自動翻訳
  • tracks: the rows or columns
  • free unit (FR): if set on track's size is set in FR it will grow to fill the remaining space on the parent.
  • gap: the space between the rows and columns or the items on a track
  • トラック:行または列
  • フリーユニット(FR):トラックのサイズがFRで設定されている場合、親の残りのスペースを埋めるためにトラックが大きくなります。
  • ギャップ:行と列の間のスペース、またはトラック上のアイテム
戻る : Previous


Simple interface

英文 自動翻訳

With the following functions you can easily set a Grid layout on any parent.

次の関数を使用すると、任意の親にグリッドレイアウトを簡単に設定できます。
戻る : Previous


Grid descriptors

英文 自動翻訳

First you need to describe the size of rows and columns. It can be done by declaring 2 arrays and the track sizes in them.

The last element must be LV_GRID_TEMPLATE_LAST.

For example:

 static lv_coord_t column_dsc[] = {100, 400, LV_GRID_TEMPLATE_LAST};   /*2 columns with 100 and 400 ps width*/
 static lv_coord_t row_dsc[] = {100, 100, 100, LV_GRID_TEMPLATE_LAST}; /*3 100 px tall rows*/

To set the descriptors on a parent use lv_obj_set_grid_dsc_array(obj, col_dsc, row_dsc).

Besides simple settings the size in pixel you can use two special values:

  • LV_GRID_CONTENT set the width to the largest children on this track
  • LV_GRID_FR(X) tell what portion of the remaining space should be used by this track. Larger value means larger space.


まず、行と列のサイズを説明する必要があります。これは、2つの配列とその中のトラックサイズを宣言することで実行できます。

最後の要素はLV_GRID_TEMPLATE_LASTである必要があります。

例えば:

 static lv_coord_t column_dsc [] = {100400LV_GRID_TEMPLATE_LAST}; /*100および400ps幅の2列*/
 static lv_coord_t row_dsc [] = {100100100LV_GRID_TEMPLATE_LAST}; / *3100ピクセルの高さの行*/

親に記述子を設定するには、lv_obj_set_grid_dsc_array(obj, col_dsc, row_dsc)を使用します。

ピクセル単位のサイズの簡単な設定に加えて、2つの特別な値を使用できます。

  • LV_GRID_CONTENTこのトラックで最大の子に幅を設定します
  • LV_GRID_FR(X)残りのスペースのどの部分をこのトラックで使用するかを指定します。値が大きいほど、スペースが大きくなります。
戻る : Previous


Grid items

英文 自動翻訳

By default, the children are not added to the grid. They need to be added manually to a cell.

To do this call lv_obj_set_grid_cell(child, column_align, column_pos, column_span, row_align, row_pos, row_span).

column_align and row_align determine how to align the children in its cell. The possible values are:

  • LV_GRID_ALIGN_START means left on a horizontally and top vertically. (default)
  • LV_GRID_ALIGN_END means right on a horizontally and bottom vertically
  • LV_GRID_ALIGN_CENTER simply center


colum_pos and row_pos means the zero based index of the cell into the item should be placed.

colum_span and row_span means how many tracks should the item involve from the start cell. Must be > 1.

デフォルトでは、子はグリッドに追加されません。それらは手動でセルに追加する必要があります。


これを行うにはlv_obj_set_grid_cell(child, column_align, column_pos, column_span, row_align, row_pos, row_span)を呼び出します。


column_alignrow_alignは、セル内の子を整列させる方法を決定します。可能な値は次のとおりです。

  • LV_GRID_ALIGN_START水平に左に、垂直に上に置くことを意味します。(デフォルト)
  • LV_GRID_ALIGN_END水平方向に右、垂直方向に下を意味します
  • LV_GRID_ALIGN_CENTER単に中央に配置する


colum_posrow_posはアイテムへのセルのゼロベースのインデックスを配置する必要があることを意味します 。


colum_spanrow_spanはアイテムが開始セルからいくつのトラックを含むべきかを意味します。>1である必要があります。

戻る : Previous


Grid align

英文 自動翻訳

If there are some empty space the track can be aligned several ways:

  • LV_GRID_ALIGN_START means left on a horizontally and top vertically. (default)
  • LV_GRID_ALIGN_END means right on a horizontally and bottom vertically
  • LV_GRID_ALIGN_CENTER simply center
  • LV_GRID_ALIGN_SPACE_EVENLY items are distributed so that the spacing between any two items (and the space to the edges) is equal. Not applies to track_cross_place.
  • LV_GRID_ALIGN_SPACE_AROUND items are evenly distributed in the track with equal space around them. Note that visually the spaces aren’t equal, since all the items have equal space on both sides. The first item will have one unit of space against the container edge, but two units of space between the next item because that next item has its own spacing that applies. Not applies to track_cross_place.
  • LV_GRID_ALIGN_SPACE_BETWEEN items are evenly distributed in the track: first item is on the start line, last item on the end line. Not applies to track_cross_place.


To set the track's alignment use lv_obj_set_grid_align(obj, column_align, row_align).

空きスペースがある場合は、トラックをいくつかの方法で整列させることができます。
  • LV_GRID_ALIGN_START水平に左に、垂直に上に置くことを意味します。(デフォルト)
  • LV_GRID_ALIGN_END水平方向に右、垂直方向に下を意味します
  • LV_GRID_ALIGN_CENTER単に中央に配置する
  • LV_GRID_ALIGN_SPACE_EVENLYアイテムは、任意の2つのアイテム間の間隔(およびエッジまでのスペース)が等しくなるように分散されます。には適用されませんtrack_cross_place
  • LV_GRID_ALIGN_SPACE_AROUNDアイテムは、トラック内に均等に配置され、周囲に等間隔で配置されます。すべてのアイテムの両側に等しいスペースがあるため、視覚的にはスペースが等しくないことに注意してください。最初のアイテムには、コンテナの端に対して1単位のスペースがありますが、次のアイテムには独自の間隔が適用されるため、次のアイテムの間に2単位のスペースがあります。には適用されませんtrack_cross_place
  • LV_GRID_ALIGN_SPACE_BETWEENアイテムはトラックに均等に分散されます。最初のアイテムはスタートラインにあり、最後のアイテムはエンドラインにあります。には適用されませんtrack_cross_place


トラックの配置を設定するには、lv_obj_set_grid_align(obj, column_align, row_align)を使用します。

戻る : Previous


Style interface

英文 自動翻訳

All the Grid related values are style properties under the hood and you can use them similarly to any other style properties. The following Grid related style properties exist:

  • GRID_COLUMN_DSC_ARRAY
  • GRID_ROW_DSC_ARRAY
  • GRID_COLUMN_ALIGN
  • GRID_ROW_ALIGN
  • GRID_CELL_X_ALIGN
  • GRID_CELL_COLUMN_POS
  • GRID_CELL_COLUMN_SPAN
  • GRID_CELL_Y_ALIGN
  • GRID_CELL_ROW_POS
  • GRID_CELL_ROW_SPAN

グリッドに関連するすべての値は、内部のスタイルプロパティであり、他のスタイルプロパティと同様に使用できます。次のグリッド関連のスタイルプロパティが存在します。

  • GRID_COLUMN_DSC_ARRAY
  • GRID_ROW_DSC_ARRAY
  • GRID_COLUMN_ALIGN
  • GRID_ROW_ALIGN
  • GRID_CELL_X_ALIGN
  • GRID_CELL_COLUMN_POS
  • GRID_CELL_COLUMN_SPAN
  • GRID_CELL_Y_ALIGN
  • GRID_CELL_ROW_POS
  • GRID_CELL_ROW_SPAN
戻る : Previous


Internal padding

英文 自動翻訳

To modify the minimum space Grid inserts between objects, the following properties can be set on the Grid container style:

  • pad_row Sets the padding between the rows.
  • pad_column Sets the padding between the columns.

オブジェクト間にグリッドが挿入する最小スペースを変更するには、グリッドコンテナスタイルに次のプロパティを設定できます。

  • pad_row行間のパディングを設定します。
  • pad_column列間のパディングを設定します。
戻る : Previous


Other features

RTL

英文 自動翻訳

If the base direction of the container is set to LV_BASE_DIR_RTL, the meaning of LV_GRID_ALIGN_START and LV_GRID_ALIGN_END is swapped. I.e. START will mean right-most.

The columns will be placed from right to left.

コンテナのベース方向がLV_BASE_DIR_RTLに設定されている場合、LV_GRID_ALIGN_STARTLV_GRID_ALIGN_ENDの意味が入れ替わります。つまり、STARTは右端を意味します。

列は右から左に配置されます。

戻る : Previous


Example

英文 自動翻訳

A simple grid

LVGL docs example 030.png

Demonstrate cell placement and span

LVGL docs example 031.png

Demonstrate grid's "free unit"

LVGL docs example 032.png

Demonstrate track placement

LVGL docs example 033.png

Demonstrate column and row gap

LVGL docs example 034.png

Demonstrate RTL direction on grid

LVGL docs example 035.png

戻る : Previous


API

英文 自動翻訳

Enums

enum lv_grid_align_t

Values:
enumerator LV_GRID_ALIGN_START
enumerator LV_GRID_ALIGN_CENTER
enumerator LV_GRID_ALIGN_END
enumerator LV_GRID_ALIGN_STRETCH
enumerator LV_GRID_ALIGN_SPACE_EVENLY
enumerator LV_GRID_ALIGN_SPACE_AROUND
enumerator LV_GRID_ALIGN_SPACE_BETWEEN

Functions

LV_EXPORT_CONST_INT(LV_GRID_CONTENT)

LV_EXPORT_CONST_INT(LV_GRID_TEMPLATE_LAST)

void lv_grid_init(void)

void lv_obj_set_grid_dsc_array( *obj, const lv_coord_t col_dsc[], const lv_coord_t row_dsc[])

void lv_obj_set_grid_align( *obj, column_align, row_align)

void lv_obj_set_grid_cell( *obj, column_align, uint8_t col_pos, uint8_t col_span, row_align, uint8_t row_pos, uint8_t row_span)

Set the cell of an object. The object's parent needs to have grid layout, else nothing will happen
Parameters
  • obj -- pointer to an object
  • column_align -- the vertical alignment in the cell. LV_GRID_START/END/CENTER/STRETCH
  • col_pos -- column ID
  • col_span -- number of columns to take (>= 1)
  • row_align -- the horizontal alignment in the cell. LV_GRID_START/END/CENTER/STRETCH
  • row_pos -- row ID
  • row_span -- number of rows to take (>= 1)

static inline lv_coord_t lv_grid_fr(uint8_t x)

Just a wrapper to LV_GRID_FR for bindings.

void lv_style_set_grid_row_dsc_array( *style, const lv_coord_t value[])

void lv_style_set_grid_column_dsc_array( *style, const lv_coord_t value[])

void lv_style_set_grid_row_align( *style, value)

void lv_style_set_grid_column_align( *style, value)

void lv_style_set_grid_cell_column_pos( *style, lv_coord_t value)

void lv_style_set_grid_cell_column_span( *style, lv_coord_t value)

void lv_style_set_grid_cell_row_pos( *style, lv_coord_t value)

void lv_style_set_grid_cell_row_span( *style, lv_coord_t value)

void lv_style_set_grid_cell_x_align( *style, lv_coord_t value)

void lv_style_set_grid_cell_y_align( *style, lv_coord_t value)

void lv_obj_set_style_grid_row_dsc_array( *obj, const lv_coord_t value[], lv_style_selector_t selector)

void lv_obj_set_style_grid_column_dsc_array( *obj, const lv_coord_t value[], lv_style_selector_t selector)

void lv_obj_set_style_grid_row_align( *obj, value, lv_style_selector_t selector)

void lv_obj_set_style_grid_column_align( *obj, value, lv_style_selector_t selector)

void lv_obj_set_style_grid_cell_column_pos( *obj, lv_coord_t value, lv_style_selector_t selector)

void lv_obj_set_style_grid_cell_column_span( *obj, lv_coord_t value, lv_style_selector_t selector)

void lv_obj_set_style_grid_cell_row_pos( *obj, lv_coord_t value, lv_style_selector_t selector)

void lv_obj_set_style_grid_cell_row_span( *obj, lv_coord_t value, lv_style_selector_t selector)

void lv_obj_set_style_grid_cell_x_align( *obj, lv_coord_t value, lv_style_selector_t selector)

void lv_obj_set_style_grid_cell_y_align( *obj, lv_coord_t value, lv_style_selector_t selector)

static inline const lv_coord_t *lv_obj_get_style_grid_row_dsc_array(const *obj, uint32_t part)

static inline const lv_coord_t *lv_obj_get_style_grid_column_dsc_array(const *obj, uint32_t part)

static inline lv_obj_get_style_grid_row_align(const *obj, uint32_t part)

static inline lv_obj_get_style_grid_column_align(const *obj, uint32_t part)

static inline lv_coord_t lv_obj_get_style_grid_cell_column_pos(const *obj, uint32_t part)

static inline lv_coord_t lv_obj_get_style_grid_cell_column_span(const *obj, uint32_t part)

static inline lv_coord_t lv_obj_get_style_grid_cell_row_pos(const *obj, uint32_t part)

static inline lv_coord_t lv_obj_get_style_grid_cell_row_span(const *obj, uint32_t part)

static inline lv_coord_t lv_obj_get_style_grid_cell_x_align(const *obj, uint32_t part)

static inline lv_coord_t lv_obj_get_style_grid_cell_y_align(const *obj, uint32_t part)

Variables

uint32_t LV_LAYOUT_GRID

LV_STYLE_GRID_COLUMN_DSC_ARRAY

LV_STYLE_GRID_COLUMN_ALIGN

LV_STYLE_GRID_ROW_DSC_ARRAY

LV_STYLE_GRID_ROW_ALIGN

LV_STYLE_GRID_CELL_COLUMN_POS

LV_STYLE_GRID_CELL_COLUMN_SPAN

LV_STYLE_GRID_CELL_X_ALIGN

LV_STYLE_GRID_CELL_ROW_POS

LV_STYLE_GRID_CELL_ROW_SPAN

LV_STYLE_GRID_CELL_Y_ALIGN

列挙型

列挙型lv_grid_align_t

値:
列挙子LV_GRID_ALIGN_START
列挙子LV_GRID_ALIGN_CENTER
列挙子LV_GRID_ALIGN_END
列挙子LV_GRID_ALIGN_STRETCH
列挙子LV_GRID_ALIGN_SPACE_EVENLY
列挙子LV_GRID_ALIGN_SPACE_AROUND
列挙子LV_GRID_ALIGN_SPACE_BETWEEN

機能

LV_EXPORT_CONST_INT(LV_GRID_CONTENT)

LV_EXPORT_CONST_INT(LV_GRID_TEMPLATE_LAST)

void lv_grid_init(void)

void lv_obj_set_grid_dsc_array(lv_obj_t * obj、const lv_coord_t col_dsc []、const lv_coord_t row_dsc [])

void lv_obj_set_grid_align(lv_obj_t * obj、lv_grid_align_t column_align、lv_grid_align_t row_align)

void lv_obj_set_grid_cell(lv_obj_t * obj、lv_grid_align_t column_align、uint8_t col_pos、uint8_t col_span、lv_grid_align_t row_align、uint8_t row_pos、uint8_t row_span)

オブジェクトのセルを設定します。オブジェクトの親はグリッドレイアウトである必要があります。そうでない場合、何も起こりません。
パラメーター
  • obj-オブジェクトへのポインタ
  • column_align-セルの垂直方向の配置。LV_GRID_START/END/CENTER/STRETCH
  • col_pos-列ID
  • col_span-取得する列の数(> = 1)
  • row_align-セルの水平方向の配置。LV_GRID_START/END/CENTER/STRETCH
  • row_pos-行ID
  • row_span-取得する行数(> = 1)

静的インラインlv_coord_tlv_grid_fr(uint8_t x)

オブジェクト間にグリッドが挿入する最小スペースを変更するには、グリッドコンテナスタイルに次のプロパティを設定できます。LV_GRID_FRバインディングの単なるラッパー。

void lv_style_set_grid_row_dsc_array(lv_style_t * style、const lv_coord_t value [])

void lv_style_set_grid_column_dsc_array(lv_style_t * style、const lv_coord_t value [])

void lv_style_set_grid_row_align(lv_style_t * style、lv_grid_align_t value)

void lv_style_set_grid_column_align(lv_style_t * style、lv_grid_align_t value)

void lv_style_set_grid_cell_column_pos(lv_style_t * style、lv_coord_t value)

void lv_style_set_grid_cell_column_span(lv_style_t * style、lv_coord_t value)

void lv_style_set_grid_cell_row_pos(lv_style_t * style、lv_coord_t value)

void lv_style_set_grid_cell_row_span(lv_style_t * style、lv_coord_t value)

void lv_style_set_grid_cell_x_align(lv_style_t * style、lv_coord_t value)

void lv_style_set_grid_cell_y_align(lv_style_t * style、lv_coord_t value)

void lv_obj_set_style_grid_row_dsc_array(lv_obj_t * obj、const lv_coord_t value []、lv_style_selector_tセレクター)

void lv_obj_set_style_grid_column_dsc_array(lv_obj_t * obj、const lv_coord_t value []、lv_style_selector_tセレクター)

void lv_obj_set_style_grid_row_align(lv_obj_t * obj、lv_grid_align_t value、lv_style_selector_tセレクター)

void lv_obj_set_style_grid_column_align(lv_obj_t * obj、lv_grid_align_t value、lv_style_selector_tセレクター)

void lv_obj_set_style_grid_cell_column_pos(lv_obj_t * obj、lv_coord_t value、lv_style_selector_tセレクター)

void lv_obj_set_style_grid_cell_column_span(lv_obj_t * obj、lv_coord_t value、lv_style_selector_tセレクター)

void lv_obj_set_style_grid_cell_row_pos(lv_obj_t * obj、lv_coord_t value、lv_style_selector_tセレクター)

void lv_obj_set_style_grid_cell_row_span(lv_obj_t * obj、lv_coord_t value、lv_style_selector_tセレクター)

void lv_obj_set_style_grid_cell_x_align(lv_obj_t * obj、lv_coord_t value、lv_style_selector_tセレクター)

void lv_obj_set_style_grid_cell_y_align(lv_obj_t * obj、lv_coord_t value、lv_style_selector_tセレクター)

static inline const lv_coord_t * lv_obj_get_style_grid_row_dsc_array(const lv_obj_t * obj、uint32_t part)

static inline const lv_coord_t * lv_obj_get_style_grid_column_dsc_array(const lv_obj_t * obj、uint32_t part)

static inline lv_grid_align_t lv_obj_get_style_grid_row_align(const lv_obj_t * obj、uint32_t part)

static inline lv_grid_align_t lv_obj_get_style_grid_column_align(const lv_obj_t * obj、uint32_t part)

static inline lv_coord_t lv_obj_get_style_grid_cell_column_pos(const lv_obj_t * obj、uint32_t part)

static inline lv_coord_t lv_obj_get_style_grid_cell_column_span(const lv_obj_t * obj、uint32_t part)

static inline lv_coord_t lv_obj_get_style_grid_cell_row_pos(const lv_obj_t * obj、uint32_t part)

static inline lv_coord_t lv_obj_get_style_grid_cell_row_span(const lv_obj_t * obj、uint32_t part)

static inline lv_coord_t lv_obj_get_style_grid_cell_x_align(const lv_obj_t * obj、uint32_t part)

static inline lv_coord_t lv_obj_get_style_grid_cell_y_align(const lv_obj_t * obj、uint32_t part)

変数

uint32_t LV_LAYOUT_GRID

lv_style_prop_t LV_STYLE_GRID_COLUMN_DSC_ARRAY

lv_style_prop_t LV_STYLE_GRID_COLUMN_ALIGN

lv_style_prop_t LV_STYLE_GRID_ROW_DSC_ARRAY

lv_style_prop_t LV_STYLE_GRID_ROW_ALIGN

lv_style_prop_t LV_STYLE_GRID_CELL_COLUMN_POS

lv_style_prop_t LV_STYLE_GRID_CELL_COLUMN_SPAN

lv_style_prop_t LV_STYLE_GRID_CELL_X_ALIGN

lv_style_prop_t LV_STYLE_GRID_CELL_ROW_POS

lv_style_prop_t LV_STYLE_GRID_CELL_ROW_SPAN

lv_style_prop_t LV_STYLE_GRID_CELL_Y_ALIGN



戻る : Previous