App:Library:LVGL:docs:Overview:Drawing
https://docs.lvgl.io/8.2/overview/drawing.html
Drawing
英文 | 自動翻訳 |
---|---|
With LVGL, you don't need to draw anything manually. Just create objects (like buttons, labels, arc, etc.), move and change them, and LVGL will refresh and redraw what is required. However, it can be useful to have a basic understanding of how drawing happens in LVGL to add customization, make it easier to find bugs or just out of curiosity. The basic concept is to not draw directly onto the display but rather to first draw on an internal draw buffer. When a drawing (rendering) is ready that buffer is copied to the display.
LVGL will simply render in "tiles" that fit into the given draw buffer. This approach has two main advantages compared to directly drawing to the display:
|
LVGLを使えば、何も手動で描く必要はありません。
オブジェクト(ボタン、ラベル、円弧など)を作成し、移動、変更するだけで、LVGLは必要なものをリフレッシュして再描画します。 しかし、LVGLでどのように描画が行われるかを基本的に理解しておくことは、カスタマイズの追加やバグの発見を容易にするため、あるいは単なる好奇心で、役に立つことがあるのです。 基本的なコンセプトは、ディスプレイに直接描画するのではなく、まず内部のドローバッファに描画することです。 描画(レンダリング)の準備ができると、そのバッファがディスプレイにコピーされます。
LVGLは、与えられたドローバッファに収まる「タイル」で単純にレンダリングします。 この方法は、ディスプレイへの直接描画と比較して、主に2つの利点があります。
|
Mechanism of screen refreshing
英文 | 自動翻訳 |
---|---|
Be sure to get familiar with the Buffering modes of LVGL first. LVGL refreshes the screen in the following steps:
For example, if a button's label has changed, the library will see that it's enough to draw the button under the text and it's not necessary to redraw the display under the rest of the button too. The difference between buffering modes regarding the drawing mechanism is the following:
|
まず,LVGL の Buffering モードに慣れるようにしてください.
LVGLは以下の手順で画面を更新しています。
例えば、ボタンのラベルが変更された場合、ライブラリは、テキストの下にボタンを描画すれば十分であり、ボタンの残りの部分の表示も再描画する必要はないと判断します。 描画の仕組みに関するバッファリングモードの違いは、以下の通りです。
|
Masking
英文 | 自動翻訳 |
---|---|
Masking is the basic concept of LVGL's draw engine. To use LVGL it's not required to know about the mechanisms described here but you might find interesting to know how drawing works under hood. Knowing about masking comes in handy if you want to customize drawing. To learn about masking let's see the steps of drawing first. LVGL performs the following steps to render any shape, image or text. It can be considered as a drawing pipeline.
|
マスキングは、LVGLの描画エンジンの基本概念です。
LVGLを使用するには、ここで説明したメカニズムについて知る必要はありませんが、内部での描画のしくみを知ることは興味深いことです。マスキングに関する知識は、図面をカスタマイズする場合に役立ちます。
LVGLは、次の手順を実行してシェイプ、イメージ、またはテキストをレンダリングします。これは、描画パイプラインと見なすことができます。
|
Using masks
英文 | 自動翻訳 |
---|---|
Every mask type has a related parameter structure to describe the mask's data. The following parameter types exist:
|
すべてのマスクタイプは、マスクのデータを記述するための関連するパラメータ構造を持っています。
以下のパラメータタイプが存在する。
パラメータは何度でも追加・削除できますが、不要になったら解放する必要があります。
|
Hook drawing
英文 | 自動翻訳 |
---|---|
Although widgets can be easily customized by styles there might be cases when something more custom is required. To ensure a great level of flexibility LVGL sends a lot of events during drawing with parameters that tell what LVGL is about to draw. Some fields of these parameters can be modified to draw something else or any custom drawing operations can be added manually. A good use case for this is the Button matrix widget. By default, its buttons can be styled in different states, but you can't style the buttons one by one. However, an event is sent for every button and you can, for example, tell LVGL to use different colors on a specific button or to manually draw an image on some buttons. Each of these events is described in detail below. |
ウィジェットはスタイルによって簡単にカスタマイズできますが、よりカスタムなものが必要な場合があります。
|
Main drawing
英文 | 自動翻訳 |
---|---|
These events are related to the actual drawing of an object. E.g. the drawing of buttons, texts, etc. happens here.
The clip area is required in draw functions to make them draw only on a limited area. |
これらのイベントは、実際のオブジェクトの描画に関連するものである。
例えば、ボタンやテキストなどの描画はここで行われます。
クリップ領域は、描画関数が限られた領域にしか描画しないようにするために必要です。 |
LV_EVENT_DRAW_MAIN_BEGIN
英文 | 自動翻訳 |
---|---|
Sent before starting to draw an object. This is a good place to add masks manually. E.g. add a line mask that "removes" the right side of an object. |
オブジェクトの描画を開始する前に送信されます。
ここは、マスクを手動で追加するのに適した場所です。 例えば、オブジェクトの右側を「削除」するラインマスクを追加します。 |
LV_EVENT_DRAW_MAIN
英文 | 自動翻訳 |
---|---|
The actual drawing of an object happens in this event. E.g. a rectangle for a button is drawn here. First, the widgets' internal events are called to perform drawing and after that you can draw anything on top of them. For example you can add a custom text or an image. |
オブジェクトの実際の描画は、このイベントで行われます。
例えば、ボタン用の矩形はここで描画されます。 まず、ウィジェットの内部イベントが呼び出されて描画が行われ、その後、ウィジェットの上に何かを描画することができます。例えば、カスタムテキストや画像を追加することができます。 |
LV_EVENT_DRAW_MAIN_END
英文 | 自動翻訳 |
---|---|
Called when the main drawing is finished. You can draw anything here as well and it's also a good place to remove any masks created in |
メイン描画が終了したときに呼び出される。
ここでも何でも描画でき、 |
Post drawing
英文 | 自動翻訳 |
---|---|
Post drawing events are called when all the children of an object are drawn. For example LVGL use the post drawing phase to draw scrollbars because they should be above all of the children.
|
ポストドローイングイベントは、オブジェクトの子オブジェクトがすべて描画されたときに呼び出される。
例えば、LVGLはスクロールバーを描画するためにポストドローイングフェーズを使用します。
|
LV_EVENT_DRAW_POST_BEGIN
英文 | 自動翻訳 |
---|---|
Sent before starting the post draw phase. Masks can be added here too to mask out the post drawn content. |
ポストドローイングフェーズを開始する前に送信される。
描画後の内容をマスクするために、ここでもマスクを追加することができる。 |
LV_EVENT_DRAW_POST
英文 | 自動翻訳 |
---|---|
The actual drawing should happen here. |
実際の描画はここで行う必要があります。 |
LV_EVENT_DRAW_POST_END
英文 | 自動翻訳 |
---|---|
Called when post drawing has finished. If masks were not removed in |
後描画が終了したときに呼び出される。
|
Part drawing
英文 | 自動翻訳 |
---|---|
When LVGL draws a part of an object (e.g. a slider's indicator, a table's cell or a button matrix's button) it sends events before and after drawing that part with some context of the drawing.
In these events an Not all fields are set for every part and widget.
// Always set
const lv_area_t * clip_area; // The current clip area, required if you need to draw something in the event
uint32_t part; // The current part for which the event is sent
uint32_t id; // The index of the part. E.g. a button's index on button matrix or table cell index.
// Draw desciptors, set only if related
lv_draw_rect_dsc_t * rect_dsc; // A draw descriptor that can be modified to changed what LVGL will draw. Set only for rectangle-like parts
lv_draw_label_dsc_t * label_dsc; // A draw descriptor that can be modified to changed what LVGL will draw. Set only for text-like parts
lv_draw_line_dsc_t * line_dsc; // A draw descriptor that can be modified to changed what LVGL will draw. Set only for line-like parts
lv_draw_img_dsc_t * img_dsc; // A draw descriptor that can be modified to changed what LVGL will draw. Set only for image-like parts
lv_draw_arc_dsc_t * arc_dsc; // A draw descriptor that can be modified to changed what LVGL will draw. Set only for arc-like parts
// Other parameters
lv_area_t * draw_area; // The area of the part being drawn
const lv_point_t * p1; // A point calculated during drawing. E.g. a point of a chart or the center of an arc.
const lv_point_t * p2; // A point calculated during drawing. E.g. a point of a chart.
char text[16]; // A text calculated during drawing. Can be modified. E.g. tick labels on a chart axis.
lv_coord_t radius; // E.g. the radius of an arc (not the corner radius).
int32_t value; // A value calculated during drawing. E.g. Chart's tick line value.
const void * sub_part_ptr; // A pointer the identifies something in the part. E.g. chart series.
|
LVGLがオブジェクトの一部分(例えば、スライダーのインジケータ、テーブルのセル、ボタンマトリックスのボタン)を描画するとき、描画のいくつかのコンテキストでその部分の描画の前後にイベントを送信します。
これらのイベントでは、 すべてのフィールドが、すべての部品とウィジェットに設定されているわけではない事に注意して下さい。
ウィジェットに設定されているフィールドを確認するには、ウィジェットのドキュメントを参照してください。
// Always set
const lv_area_t * clip_area; // The current clip area, required if you need to draw something in the event
uint32_t part; // The current part for which the event is sent
uint32_t id; // The index of the part. E.g. a button's index on button matrix or table cell index.
// Draw desciptors, set only if related
lv_draw_rect_dsc_t * rect_dsc; // A draw descriptor that can be modified to changed what LVGL will draw. Set only for rectangle-like parts
lv_draw_label_dsc_t * label_dsc; // A draw descriptor that can be modified to changed what LVGL will draw. Set only for text-like parts
lv_draw_line_dsc_t * line_dsc; // A draw descriptor that can be modified to changed what LVGL will draw. Set only for line-like parts
lv_draw_img_dsc_t * img_dsc; // A draw descriptor that can be modified to changed what LVGL will draw. Set only for image-like parts
lv_draw_arc_dsc_t * arc_dsc; // A draw descriptor that can be modified to changed what LVGL will draw. Set only for arc-like parts
// Other parameters
lv_area_t * draw_area; // The area of the part being drawn
const lv_point_t * p1; // A point calculated during drawing. E.g. a point of a chart or the center of an arc.
const lv_point_t * p2; // A point calculated during drawing. E.g. a point of a chart.
char text[16]; // A text calculated during drawing. Can be modified. E.g. tick labels on a chart axis.
lv_coord_t radius; // E.g. the radius of an arc (not the corner radius).
int32_t value; // A value calculated during drawing. E.g. Chart's tick line value.
const void * sub_part_ptr; // A pointer the identifies something in the part. E.g. chart series.
|
LV_EVENT_DRAW_PART_BEGIN
英文 | 自動翻訳 |
---|---|
Start the drawing of a part. This is a good place to modify the draw descriptors (e.g. |
部品の描画を開始します。ここで描画記述子(例:rect_dsc など)を変更したり、マスクを追加したりします。
|
LV_EVENT_DRAW_PART_END
英文 | 自動翻訳 |
---|---|
Finish the drawing of a part. This is a good place to draw extra content on the part or remove masks added in |
パーツの描画を終了する。部品に追加コンテンツを描画したり、LV_EVENT_DRAW_PART_BEGIN で追加したマスクを削除するのに適した場所です。
|
Others
LV_EVENT_COVER_CHECK
英文 | 自動翻訳 |
---|---|
This event is used to check whether an object fully covers an area or not.
Before sending this event LVGL checks if at least the widget's coordinates fully cover the area or not. If not the event is not called.
The existing properties known by a widget are handled in its internal events. E.g. if a widget has > 0 radius it might not cover an area, but you need to handle |
このイベントは、オブジェクトがある領域を完全に覆っているかどうかをチェックするために使用されます。
このイベントを送る前に、LVGLは、少なくともウィジェットの座標がその領域を完全に覆っているかどうかをチェックします。 もしそうでなければ、このイベントは呼ばれません。
ウィジェットが知っている既存のプロパティは、その内部イベントで処理されます。
|
LV_EVENT_REFR_EXT_DRAW_SIZE
英文 | 自動翻訳 |
---|---|
If you need to draw outside a widget, LVGL needs to know about it to provide extra space for drawing. Let's say you create an event which writes the current value of a slider above its knob. In this case LVGL needs to know that the slider's draw area should be larger with the size required for the text. You can simply set the required draw area with |
ウィジェットの外側に描画する必要がある場合、LVGLは描画のための余分なスペースを提供するために、そのことを知る必要があります。
例えば、スライダーの現在値をそのノブの上に書き込むイベントを作るとします。 この場合、LVGLは、スライダーの描画領域がテキストに必要な大きさより大きいことを知る必要があります。
|