App:Library:LVGL:docs:Overview:Drawing

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

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.


The draw buffer can be smaller than a display's size.

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:

  1. It avoids flickering while the layers of the UI are drawn. For example, if LVGL drew directly onto the display, when drawing a background + button + text, each "stage" would be visible for a short time.
  2. It's faster to modify a buffer in internal RAM and finally write one pixel only once than reading/writing the display directly on each pixel access. (e.g. via a display controller with SPI interface).


Note that this concept is different from "traditional" double buffering where there are two display sized frame buffers: one holds the current image to show on the display, and rendering happens to the other (inactive) frame buffer, and they are swapped when the rendering is finished.


The main difference is that with LVGL you don't have to store two frame buffers (which usually requires external RAM) but only smaller draw buffer(s) that can easily fit into internal RAM.

LVGLを使えば、何も手動で描く必要はありません。

オブジェクト(ボタン、ラベル、円弧など)を作成し、移動、変更するだけで、LVGLは必要なものをリフレッシュして再描画します。

しかし、LVGLでどのように描画が行われるかを基本的に理解しておくことは、カスタマイズの追加やバグの発見を容易にするため、あるいは単なる好奇心で、役に立つことがあるのです。

基本的なコンセプトは、ディスプレイに直接描画するのではなく、まず内部のドローバッファに描画することです。

描画(レンダリング)の準備ができると、そのバッファがディスプレイにコピーされます。


ドローバッファは、ディスプレイのサイズより小さくすることができます。

LVGLは、与えられたドローバッファに収まる「タイル」で単純にレンダリングします。

この方法は、ディスプレイへの直接描画と比較して、主に2つの利点があります。

  1. UIのレイヤーを描画している間のちらつきを回避することができます。例えば、LVGLがディスプレイに直接描画する場合、背景+ボタン+テキストを描画すると、それぞれの「ステージ」が短時間だけ表示されることになる。
  2. ピクセルアクセスのたびにディスプレイを直接読み書きするよりも、内部RAMのバッファを変更し、最終的に1ピクセルだけ書き込む方が高速になるのです。(例:SPIインターフェイスを持つディスプレイコントローラ経由)。


このコンセプトは、ディスプレイサイズのフレームバッファが2つある「従来の」ダブルバッファリングとは異なることに注意してください:1つはディスプレイに表示する現在の画像を保持し、レンダリングは他の(非アクティブな)フレームバッファで行われ、レンダリングの終了時にそれらが交換されます。


主な違いは、LVGLでは、2つのフレームバッファ(これは通常、外部RAMを必要とします)を保存する必要がなく、内部RAMに簡単に収まる小さな描画バッファ(複数可)だけでよいということです。

戻る : Previous


Mechanism of screen refreshing

英文 自動翻訳

Be sure to get familiar with the Buffering modes of LVGL first.

LVGL refreshes the screen in the following steps:

  1. Something happens in the UI which requires redrawing. For example, a button is pressed, a chart is changed, an animation happened, etc.
  2. LVGL saves the changed object's old and new area into a buffer, called an Invalid area buffer. For optimization, in some cases, objects are not added to the buffer:
    • Hidden objects are not added.
    • Objects completely out of their parent are not added.
    • Areas partially out of the parent are cropped to the parent's area.
    • Objects on other screens are not added.
  3. In every LV_DISP_DEF_REFR_PERIOD (set in lv_conf.h) the following happens:
    • LVGL checks the invalid areas and joins those that are adjacent or intersecting.
    • Takes the first joined area, if it's smaller than the draw buffer, then simply renders the area's content into the draw buffer. If the area doesn't fit into the buffer, draw as many lines as possible to the draw buffer.
    • When the area is rendered, call flush_cb from the display driver to refresh the display.
    • If the area was larger than the buffer, render the remaining parts too.
    • Repeat the same with remaining joined areas.


When an area is redrawn the library searches the top-most object which covers that area and starts drawing from that object.

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:

  1. One buffer - LVGL needs to wait for lv_disp_flush_ready() (called from flush_cb) before starting to redraw the next part.
  2. Two buffers - LVGL can immediately draw to the second buffer when the first is sent to flush_cb because the flushing should be done by DMA (or similar hardware) in the background.
  3. Double buffering - flush_cb should only swap the addresses of the frame buffers.
まず,LVGL の Buffering モードに慣れるようにしてください.

LVGLは以下の手順で画面を更新しています。

  1. UIで再描画を必要とするようなことが起こる。例えば、ボタンが押された、チャートが変更された、アニメーションが起こった、などです。
  2. LVGLは、変更されたオブジェクトの旧領域と新領域を、Invalid area bufferと呼ばれるバッファに保存します。最適化のため、場合によっては、オブジェクトはバッファに追加されません。
    • 隠されたオブジェクトは追加されません。
    • 親から完全にはみ出したオブジェクトは追加されません。
    • 親から部分的にはみ出した領域は、親の領域に合わせて切り取られます。
    • 他の画面上のオブジェクトは追加されません。
  3. LV_DISP_DEF_REFR_PERIODlv_conf.hで設定)ごとに、次のようなことが起こります。
    • LVGLは無効な領域をチェックし、隣接または交差しているものを結合します。
    • 最初に結合された領域を取り、それがドローバッファより小さければ、その領域の内容をドローバッファに単純にレンダリングします。領域がバッファに収まらない場合は、ドローバッファにできるだけ多くの線を描画します。
    • 領域が描画されたら、ディスプレイドライバから flush_cb を呼び出して表示を更新する。
    • もし、領域がバッファより大きかったら、残りの部分もレンダリングする。
    • 残りの結合された領域も同様に繰り返す。


ある領域が再描画されると、ライブラリはその領域をカバーする最上位のオブジェクトを検索し、そのオブジェクトから描画を開始します。

例えば、ボタンのラベルが変更された場合、ライブラリは、テキストの下にボタンを描画すれば十分であり、ボタンの残りの部分の表示も再描画する必要はないと判断します。

描画の仕組みに関するバッファリングモードの違いは、以下の通りです。

  1. 1つのバッファ-lv_disp_flush_ready()(flush_cbから呼び出される) まで待機してから、次のパートの再描画を開始する必要があります。
  2. 2つのバッファー-フラッシュはDMA (または同様のハードウェア) によってバックグラウンドで実行されるため、最初のバッファーがflush_cb に送信されると、LVGLはすぐに2番目のバッファーに描画できます。
  3. ダブルバッファリング-flush_cb はフレームバッファのアドレスのみをスワップすべきです。
戻る : Previous


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.

  1. Prepare the draw descriptors Create a draw descriptor from an object's styles (e.g. lv_draw_rect_dsc_t). This gives us the parameters for drawing, for example colors, widths, opacity, fonts, radius, etc.
  2. Call the draw function Call the draw function with the draw descriptor and some other parameters (e.g. lv_draw_rect()). It will render the primitive shape to the current draw buffer.
  3. Create masks If the shape is very simple and doesn't require masks, go to #5. Otherwise, create the required masks in the draw function. (e.g. a rounded rectangle mask)
  4. Calculate all the added mask It composites opacity values into a mask buffer with the "shape" of the created masks. E.g. in case of a "line mask" according to the parameters of the mask, keep one side of the buffer as it is (255 by default) and set the rest to 0 to indicate that this side should be removed.
  5. Blend a color or image During blending, masking (make some pixels transparent or opaque), blending modes (additive, subtractive, etc.) and color/image opacity are handled.


LVGL has the following built-in mask types which can be calculated and applied real-time:

  • LV_DRAW_MASK_TYPE_LINE Removes a side from a line (top, bottom, left or right). lv_draw_line uses four instances of it. Essentially, every (skew) line is bounded with four line masks forming a rectangle.
  • LV_DRAW_MASK_TYPE_RADIUS Removes the inner or outer corners of a rectangle with a radiused transition. It's also used to create circles by setting the radius to large value (LV_RADIUS_CIRCLE)
  • LV_DRAW_MASK_TYPE_ANGLE Removes a circular sector. It is used by lv_draw_arc to remove the "empty" sector.
  • LV_DRAW_MASK_TYPE_FADE Create a vertical fade (change opacity)
  • LV_DRAW_MASK_TYPE_MAP The mask is stored in a bitmap array and the necessary parts are applied


Masks are used to create almost every basic primitive:

  • letters Create a mask from the letter and draw a rectangle with the letter's color using the mask.
  • line Created from four "line masks" to mask out the left, right, top and bottom part of the line to get a perfectly perpendicular perimeter.
  • rounded rectangle A mask is created real-time to add a radius to the corners.
  • clip corner To clip overflowing content (usually children) on rounded corners, a rounded rectangle mask is also applied.
  • rectangle border Same as a rounded rectangle but the inner part is masked out too.
  • arc drawing A circular border is drawn but an arc mask is applied too.
  • ARGB images The alpha channel is separated into a mask and the image is drawn as a normal RGB image.
マスキングは、LVGLの描画エンジンの基本概念です。

LVGLを使用するには、ここで説明したメカニズムについて知る必要はありませんが、内部での描画のしくみを知ることは興味深いことです。マスキングに関する知識は、図面をカスタマイズする場合に役立ちます。


マスクについて学習するには、まず描画の手順を見てみましょう。

LVGLは、次の手順を実行してシェイプ、イメージ、またはテキストをレンダリングします。これは、描画パイプラインと見なすことができます。

  1. 描画記述子を準備するオブジェクトのスタイル(例:lv_draw_rect_dsc_t)から描画記述子を作成します。色、幅、不透明度、フォント、半径など、描画のためのパラメータが表示されます。
  2. 描画関数の呼び出し 描画記述子といくつかのパラメータを指定して、描画関数を呼び出します(例:lv_draw_rect())。この関数は,プリミティブな形状を現在のドローバッファにレンダリングします.
  3. マスクの作成 形状が非常に単純で、マスクを必要としない場合は、#5 に進みます。そうでない場合は、draw 関数で必要なマスクを作成します。(例: 丸みを帯びた矩形マスク)
  4. 追加されたすべてのマスクを計算する 作成されたマスクの「形状」を持つマスクバッファに、It composites opacity 値を格納する。例:マスクのパラメータに従った「ラインマスク」の場合、バッファの一辺をそのまま(デフォルトで255)、残りを0にして、この一辺を削除することを示す。
  5. 色や画像のブレンド ブレンド中、マスキング(一部のピクセルを透明または不透明にする)、ブレンドモード(加算、減算など)、色や画像の不透明度が処理されます。


LVGLには以下のようなマスクが内蔵されており、リアルタイムに計算し適用することができます。

  • LV_DRAW_MASK_TYPE_LINE 線から辺を削除します (上下左右)。 lv_draw_line は、4つのインスタンスを使用します。基本的に、すべての(斜めの)線は、矩形を形成する4つのラインマスクで囲まれています。
  • LV_DRAW_MASK_TYPE_RADIUS 矩形の内角または外角を放射状に変化させて削除します。また、半径を大きな値に設定することで円を作成する場合にも使用されます(LV_RADIUS_CIRCLE)
  • LV_DRAW_MASK_TYPE_ANGLE 円形セクタを削除します。lv_draw_arcで使用され、"空の "セクタを削除します。
  • LV_DRAW_MASK_TYPE_FADE 垂直方向のフェードを作成します(不透明度を変更します)。
  • LV_DRAW_MASK_TYPE_MAPマスクをビットマップ配列に格納し、必要な部分を適用します。


マスクは、ほとんどすべての基本的なプリミティブを作成するために使用されます。

  • 文字 文字からマスクを作成し、マスクを使用して文字の色で長方形を描画します。
  • 線 4つの「ラインマスク」から作成し、線の左、右、上、下の部分をマスクして、完全に垂直な外周を得ることができます。
  • 丸みを帯びた矩形 角に半径をつけるためのマスクをリアルタイムに作成します。
  • clip corner 丸みを帯びたコーナーにはみ出したコンテンツ(通常は子供)をクリップするために、丸みを帯びた長方形のマスクも適用されます。
  • rectangle border 丸みを帯びた矩形と同じだが,内側もマスキングされる。
  • 円弧描画 円形の枠が描かれるが、円弧マスクも適用される。
  • ARGB画像 アルファチャンネルをマスクに分離し、通常のRGB画像として描画します。
戻る : Previous


Using masks

英文 自動翻訳

Every mask type has a related parameter structure to describe the mask's data.

The following parameter types exist:

  • lv_draw_mask_line_param_t
  • lv_draw_mask_radius_param_t
  • lv_draw_mask_angle_param_t
  • lv_draw_mask_fade_param_t
  • lv_draw_mask_map_param_t
  1. Initialize a mask parameter with lv_draw_mask_<type>_init. See lv_draw_mask.h for the whole API.
  2. Add the mask parameter to the draw engine with int16_t mask_id = lv_draw_mask_add(&param, ptr). ptr can be any pointer to identify the mask, (NULL if unused).
  3. Call the draw functions
  4. Remove the mask from the draw engine with lv_draw_mask_remove_id(mask_id) or lv_draw_mask_remove_custom(ptr).
  5. Free the parameter with lv_draw_mask_free_param(&param).


A parameter can be added and removed any number of times, but it needs to be freed when not required anymore.

lv_draw_mask_add saves only the pointer of the mask so the parameter needs to be valid while in use.

すべてのマスクタイプは、マスクのデータを記述するための関連するパラメータ構造を持っています。

以下のパラメータタイプが存在する。

  • lv_draw_mask_line_param_t
  • lv_draw_mask_radius_param_t
  • lv_draw_mask_angle_param_t
  • lv_draw_mask_fade_param_t
  • lv_draw_mask_map_param_t
  1. lv_draw_mask_<type>_initでマスクパラメータを初期化する。API全体は lv_draw_mask.h を参照。
  2. int16_t mask_id = lv_draw_mask_add(&param, ptr).でマスクパラメータを描画エンジンに追加します。ptrはマスクを識別する任意のポインタです(未使用時は NULL).
  3. 描画関数を呼び出す
  4. lv_draw_mask_remove_id(mask_id) または lv_draw_mask_remove_custom(ptr)でマスクを描画エンジンから削除します。
  5. lv_draw_mask_free_param(&param)でパラメータを解放します。

パラメータは何度でも追加・削除できますが、不要になったら解放する必要があります。

lv_draw_mask_add はマスクのポインタだけを保存するので、パラメータが使用されている間は有効である必要があります。

戻る : Previous


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.

ウィジェットはスタイルによって簡単にカスタマイズできますが、よりカスタムなものが必要な場合があります。


柔軟性を確保するために、LVGLは描画中に多くのイベントを送り、LVGLが何を描こうとしているかを示すパラメータを送ります。


これらのパラメータのいくつかのフィールドは、他のものを描画するために変更することができ、任意のカスタム描画操作を手動で追加することができます。


このための良い使用例として、ボタン行列ウィジェットがあります。


デフォルトでは、そのボタンは異なる状態でスタイルを設定することができますが、ボタンを1つずつスタイル設定することはできません。


しかし、各ボタンに対してイベントが送られ、例えば、LVGLに特定のボタンに異なる色を使うように指示したり、いくつかのボタンに手動で画像を描画したりすることができます。


それぞれのイベントについては、以下で詳しく説明します。

戻る : Previous


Main drawing

英文 自動翻訳

These events are related to the actual drawing of an object.

E.g. the drawing of buttons, texts, etc. happens here.


lv_event_get_clip_area(event) can be used to get the current clip area.

The clip area is required in draw functions to make them draw only on a limited area.

これらのイベントは、実際のオブジェクトの描画に関連するものである。

例えば、ボタンやテキストなどの描画はここで行われます。

lv_event_get_clip_area(event) は、現在のクリップ領域を取得するために使用することができます。

クリップ領域は、描画関数が限られた領域にしか描画しないようにするために必要です。

戻る : Previous


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.

オブジェクトの描画を開始する前に送信されます。

ここは、マスクを手動で追加するのに適した場所です。

例えば、オブジェクトの右側を「削除」するラインマスクを追加します。

戻る : Previous


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.

オブジェクトの実際の描画は、このイベントで行われます。

例えば、ボタン用の矩形はここで描画されます。

まず、ウィジェットの内部イベントが呼び出されて描画が行われ、その後、ウィジェットの上に何かを描画することができます。例えば、カスタムテキストや画像を追加することができます。

戻る : Previous


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

メイン描画が終了したときに呼び出される。

ここでも何でも描画でき、LV_EVENT_DRAW_MAIN_BEGINで作成されたマスクを削除するのにも良い場所である。

戻る : Previous


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.

lv_event_get_clip_area(event) can be used to get the current clip area.

ポストドローイングイベントは、オブジェクトの子オブジェクトがすべて描画されたときに呼び出される。

例えば、LVGLはスクロールバーを描画するためにポストドローイングフェーズを使用します。

lv_event_get_clip_area(event) は、現在のクリップ領域を取得するために使用されます。

戻る : Previous


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.

ポストドローイングフェーズを開始する前に送信される。

描画後の内容をマスクするために、ここでもマスクを追加することができる。

戻る : Previous


LV_EVENT_DRAW_POST

英文 自動翻訳

The actual drawing should happen here.

実際の描画はここで行う必要があります。
戻る : Previous


LV_EVENT_DRAW_POST_END

英文 自動翻訳

Called when post drawing has finished.

If masks were not removed in LV_EVENT_DRAW_MAIN_END they should be removed here.

後描画が終了したときに呼び出される。

LV_EVENT_DRAW_MAIN_END でマスクが削除されていない場合は、ここで削除する必要があります。

戻る : Previous


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.


This allows changing the parts on a very low level with masks, extra drawing, or changing the parameters that LVGL is planning to use for drawing.

In these events an lv_obj_draw_part_t structure is used to describe the context of the drawing.

Not all fields are set for every part and widget.


To see which fields are set for a widget refer to the widget's documentation.

lv_obj_draw_part_t has the following fields:

 // 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_get_draw_part_dsc(event) can be used to get a pointer to lv_obj_draw_part_t.

LVGLがオブジェクトの一部分(例えば、スライダーのインジケータ、テーブルのセル、ボタンマトリックスのボタン)を描画するとき、描画のいくつかのコンテキストでその部分の描画の前後にイベントを送信します。



これにより、マスク、追加描画、LVGLが描画に使おうとしているパラメータの変更など、非常に低いレベルで部品を変更することができます。

これらのイベントでは、 lv_obj_draw_part_t構造体が、描画のコンテキストを記述するために使用される。

すべてのフィールドが、すべての部品とウィジェットに設定されているわけではない事に注意して下さい。


ウィジェットに設定されているフィールドを確認するには、ウィジェットのドキュメントを参照してください。

lv_obj_draw_part_t には、以下のフィールドがあります。

 // 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_get_draw_part_dsc(event) は、 lv_obj_draw_part_t へのポインタを取得するために使用することができます。

戻る : Previous


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), or add masks.

部品の描画を開始します。ここで描画記述子(例:rect_dscなど)を変更したり、マスクを追加したりします。
戻る : Previous


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.

パーツの描画を終了する。部品に追加コンテンツを描画したり、LV_EVENT_DRAW_PART_BEGINで追加したマスクを削除するのに適した場所です。
戻る : Previous


Others

LV_EVENT_COVER_CHECK

英文 自動翻訳

This event is used to check whether an object fully covers an area or not.

lv_event_get_cover_area(event) returns a pointer to an area to check and lv_event_set_cover_res(event, res) can be used to set one of these results:

  • LV_COVER_RES_COVER the area is fully covered by the object
  • LV_COVER_RES_NOT_COVER the area is not covered by the object
  • LV_COVER_RES_MASKED there is a mask on the object, so it does not fully cover the area


Here are some reasons why an object would be unable to fully cover an area:

  • It's simply not fully in area
  • It has a radius
  • It doesn't have 100% background opacity
  • It's an ARGB or chroma keyed image
  • It does not have normal blending mode.
  • In this case LVGL needs to know the colors under the object to apply blending properly
  • It's a text, etc


In short if for any reason the area below an object is visible than the object doesn't cover that area.

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.


You need to check only the drawing you have added.

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 radius only if you will modify it and the widget won't know about it.

このイベントは、オブジェクトがある領域を完全に覆っているかどうかをチェックするために使用されます。

lv_event_get_cover_area(event)はチェックする領域へのポインタを返し、lv_event_set_cover_res(event, res)はこれらの結果のいずれかを設定するために使用されます。

  • LV_COVER_RES_COVER 領域はオブジェクトによって完全にカバーされている.
  • LV_COVER_RES_NOT_COVER 領域はオブジェクトによって覆われていない.
  • LV_COVER_RES_MASKEDオブジェクトにマスクがあり,その領域を完全に覆っていません.


ここでは、物体が領域を完全にカバーできない理由を説明します。

  • 単純に面積が足りない
  • 半径を持っている
  • 背景の不透明度が100%でない
  • ARGBまたはクロマキー画像である
  • 通常のブレンディングモードを持っていない。
  • この場合、LVGLはオブジェクトの下の色を知っていなければ、適切にブレンディングを適用することができません。
  • テキストである、など


要するに、何らかの理由でオブジェクトの下の領域が見えている場合、そのオブジェクトはその領域をカバーしていません。

このイベントを送る前に、LVGLは、少なくともウィジェットの座標がその領域を完全に覆っているかどうかをチェックします。

もしそうでなければ、このイベントは呼ばれません。


追加した描画のみを確認する必要があります。

ウィジェットが知っている既存のプロパティは、その内部イベントで処理されます。


例えば、ウィジェットの半径が > 0 の場合、領域をカバーできないかもしれませんが、radius を変更する場合のみ処理する必要があり、ウィジェットはそれを知ることはありません。

戻る : Previous


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 lv_event_set_ext_draw_size(e, size).

ウィジェットの外側に描画する必要がある場合、LVGLは描画のための余分なスペースを提供するために、そのことを知る必要があります。

例えば、スライダーの現在値をそのノブの上に書き込むイベントを作るとします。

この場合、LVGLは、スライダーの描画領域がテキストに必要な大きさより大きいことを知る必要があります。

lv_event_set_ext_draw_size(e, size)で必要な描画領域を設定すればよいのです。


戻る : Previous