カスタムUIとDrawbot
カスタム UI は、Drawbot を使用した複合描画モデルを使用します。 Drawbot スイートは次の用途に使用できます。
- 基本的な 2D パス描画: 線、長方形、円弧、ベジェ
- パスのストローク/塗りつぶし/シェーディング
- 画像描画:ARGB/BGRAバッファを表面に合成
- プッシング/ポッピングの表面状態
- テキスト描画(サプライヤーがサポートしている場合)(クライアントは、実際に描画する前にテキスト描画がサポートされているかどうかを最初に確認する必要があります)
描画は PF_Event_DRAW 中にのみ発生します (PF_Event_DRAG や PF_Event_DO_CLICK 中には発生しません)。
Drawbot を使用するには、まず、PF_Context を新しいスイート呼び出し PF_GetDrawingReference に渡して図面参照を取得します。
NULL 以外の図面参照が返された場合は、それを使用して DRAWBOT_DrawbotSuite からサプライヤーとサーフェスの参照を取得します。
Drawbot スイートには、DRAWBOT_DrawbotSuite、DRAWBOT_SupplierSuite、DRAWBOT_SurfaceSuite、DRAWBOT_PathSuite が含まれます。
カスタム UI を「カスタム」らしく見せないようにする
Section titled “カスタム UI を「カスタム」らしく見せないようにする”ホスト アプリケーション UI と一致させるには、新しい PF_EffectCustomUIOverlayThemeSuite を使用します。ユーザーはあなたに感謝するでしょう。
ペインの特定の領域を再描画するには、次のことをお勧めします。
- エフェクトから
PF_InvalidateRect(PF_AppSuite から) を呼び出します。これにより、遅延表示の再描画が発生し、次に利用可能なアイドル状態の瞬間に更新されます。この四角形は、関連付けられたペインに関連する座標にあります。 NULL の四角形を使用すると、ペイン全体が更新されます。 - event outflag を
PF_EO_UPDATE_NOWに設定します。これにより、現在のイベントが返されたときに、指定されたペインの即時描画イベントが発生します。
エフェクトが一度に複数のウィンドウを更新する必要がある場合は、PF_OutFlag_REFRESH_UI (PF_OutFlags から) を設定する必要があります。これにより、ECW、コンプ、およびレイヤー ウィンドウ全体が再描画されます。
HiDPI および Retina ディスプレイのサポート
Section titled “HiDPI および Retina ディスプレイのサポート”HiDPI および Retina ディスプレイをサポートするには、2 倍のサイズのオフスクリーン イメージを使用し、Drawbot_SurfaceSuite の Transform 関数を使用して、描画前にイメージを半分に縮小します。
PF_EffectCustomUISuite
Section titled “PF_EffectCustomUISuite”エフェクトが図面参照を取得できるようにします。これは、Drawbot を使用するために必要な最初の呼び出しです。
PF_EffectCustomUISuite1
Section titled “PF_EffectCustomUISuite1”| Function | Purpose |
|---|---|
PF_GetDrawingReference | Get the drawing reference. PF_GetDrawingReference( |
Drawbot_DrawbotSuite
Section titled “Drawbot_DrawbotSuite”Using the Drawbot reference, get the supplier and surface references.
Drawbot_DrawbotSuite1
Section titled “Drawbot_DrawbotSuite1”| Function | Purpose |
|---|---|
GetSupplier | Get the supplier reference. Needed to use Drawbot_SupplierSuite. GetSupplier( |
GetSurface | Get the surface reference. Needed to use Drawbot_SurfaceSuite. GetSurface( |
Drawbot_SupplierSuite
Section titled “Drawbot_SupplierSuite”Calls to create and release drawing tools, get default settings, and query drawing capabilities.
Drawbot_SupplierSuite1
Section titled “Drawbot_SupplierSuite1”| Function | Purpose |
|---|---|
NewPen | Create a new pen. Release this using ReleaseObject from Drawbot_SupplierSuite. NewPen( |
NewBrush | Create a new brush. Release this using ReleaseObject from Drawbot_SupplierSuite. NewBrush( |
SupportsText | Check if current supplier supports text. SupportsText( |
GetDefaultFontSize | Get the default font size. GetDefaultFontSize( |
NewDefaultFont | Create a new font with default settings. You can pass the default font size from GetDefaultFontSize.Release this using ReleaseObject from Drawbot_SupplierSuite. NewDefaultFont( |
NewImageFromBuffer | Create a new image from buffer passed to in_dataP. Release this using ReleaseObject from Drawbot_SupplierSuite. NewImageFromBuffer(DRAWBOT_PixelLayout can be one of the following:- kDRAWBOT_PixelLayout_24RGB- kDRAWBOT_PixelLayout_24BGR- kDRAWBOT_PixelLayout_32RGB- ARGB (A is ignored)- kDRAWBOT_PixelLayout_32BGR- BGRA (A is ignored)- kDRAWBOT_PixelLayout_32ARGB_Straight- kDRAWBOT_PixelLayout_32ARGB_Premul- kDRAWBOT_PixelLayout_32BGRA_Straight- kDRAWBOT_PixelLayout_32BGRA_Premul |
NewPath | Create a new path. Release this using ReleaseObject from Drawbot_SupplierSuite. NewPath( |
SupportsPixelLayoutBGRA | A given Drawbot implementation can support multiple channel orders, but will likely prefer one over the other. Use the following four callbacks to get the preferred channel order for any API that takes a DRAWBOT_PixelLayout (e.g. NewImageFromBuffer). SupportsPixelLayoutBGRA( |
PrefersPixelLayoutBGRA | PrefersPixelLayoutBGRA( |
SupportsPixelLayoutARGB | SupportsPixelLayoutARGB( |
PrefersPixelLayoutARGB | PrefersPixelLayoutARGB( |
RetainObject | Retain (increase reference count on) any object (pen, brush, path, etc). For example, it should be used when any object is copied and the copied object should be retained. RetainObject( |
ReleaseObject | Release (decrease reference count on) any object (pen, brush, path, etc). This function MUST be called for any object created using NewXYZ() from this suite.Do not call this function on a DRAWBOT_SupplierRef and DRAWBOT_SupplierRef, since these are not created by the plug-in. ReleaseObject( |
Drawbot_SurfaceSuite
Section titled “Drawbot_SurfaceSuite”Calls to draw on the surface, and to query and set drawing settings.
Drawbot_SurfaceSuite1
Section titled “Drawbot_SurfaceSuite1”| Function | Purpose |
|---|---|
PushStateStack | Push the current surface state onto the stack. It should be popped to retrieve old state. It is required to restore state if you are going to clip or transform a surface or change the interpolation or anti-aliasing policy. PushStateStack( |
PopStateStack | Pop the last pushed surface state off the stack. PopStateStack( |
PaintRect | Paint a rectangle with a color on the surface. PaintRect( |
FillPath | Fill a path using a brush and fill type. FillPath(DRAWBOT_FillType is one of the following:- kDRAWBOT_FillType_EvenOdd- kDRAWBOT_FillType_Winding |
StrokePath | Stroke a path using a pen. StrokePath( |
Clip | Clip the surface. Clip( |
GetClipBounds | Get clip bounds. GetClipBounds( |
IsWithinClipBounds | Checks whether a rect is within the clip bounds. IsWithinClipBounds( |
Transform | Transform the last surface state. Transform( |
DrawString | Draw a string. DrawString(DRAWBOT_TextAlignment is one of the following:- kDRAWBOT_TextAlignment_Left- kDRAWBOT_TextAlignment_Center- kDRAWBOT_TextAlignment_RightDRAWBOT_TextTruncation is one of the following:- kDRAWBOT_TextTruncation_None- kDRAWBOT_TextTruncation_End- kDRAWBOT_TextTruncation_EndEllipsis- kDRAWBOT_TextTruncation_PathEllipsis |
DrawImage | Draw an image created using NewImageFromBuffer() on the surface. Alpha = [0.0f, 1.0f ]. DrawImage( |
SetInterpolationPolicy | SetInterpolationPolicy(DRAWBOT_InterpolationPolicy is one of the following:- kDRAWBOT_InterpolationPolicy_None- kDRAWBOT_InterpolationPolicy_Med- kDRAWBOT_InterpolationPolicy_High |
GetInterpolationPolicy | GetInterpolationPolicy( |
SetAntiAliasPolicy | SetAntiAliasPolicy(DRAWBOT_AntiAliasPolicy is one of the following:- kDRAWBOT_AntiAliasPolicy_None- kDRAWBOT_AntiAliasPolicy_Med- kDRAWBOT_AntiAliasPolicy_High |
GetAntiAliasPolicy | GetAntiAliasPolicy( |
Flush | Flush drawing. This is not always needed, and if overused, may cause excessive redrawing and flashing. Flush( |
Drawbot_PathSuite
Section titled “Drawbot_PathSuite”Calls to draw paths.
Drawbot_PathSuite1
Section titled “Drawbot_PathSuite1”| Function | Purpose |
|---|---|
MoveTo | Move to a point. MoveTo( |
LineTo | Add a line to the path. LineTo( |
BezierTo | Add a cubic bezier to the path. BezierTo( |
AddRect | Add a rect to the path. AddRect( |
AddArc | Add a arc to the path. Zero start degrees == 3 o’clock. Sweep is clockwise. Units for angle are in degrees. AddArc( |
Close | Close the path. Close( |
PF_EffectCustomUIOverlayThemeSuite
Section titled “PF_EffectCustomUIOverlayThemeSuite”This suite should be used for stroking and filling paths and vertices on the Composition and Layer Windows. After Effects is using this suite internally, and we have made it available to make custom UI look consistent across effects. The foreground/shadow colors are computed based on the app brightness level so that custom UI is always visible regardless of the application’s Brightness setting in the Preferences.
PF_EffectCustomUIOverlayThemeSuite1
Section titled “PF_EffectCustomUIOverlayThemeSuite1”| Function | Purpose |
|---|---|
PF_GetPreferredForegroundColor | Get the preferred foreground color. PF_GetPreferredForegroundColor( |
PF_GetPreferredShadowColor | Get the preferred shadow color. PF_GetPreferredShadowColor( |
PF_GetPreferredStrokeWidth | Get the preferred foreground & shadow stroke width. PF_GetPreferredStrokeWidth( |
PF_GetPreferredVertexSize | Get the preferred vertex size. PF_GetPreferredVertexSize( |
PF_GetPreferredShadowOffset | Get the preferred shadow offset. PF_GetPreferredShadowOffset( |
PF_StrokePath | Stroke the path with the overlay theme foreground color. Optionally draw the shadow using the overlay theme shadow color. Uses overlay theme stroke width for stroking foreground and shadow strokes. PF_StrokePath( |
PF_FillPath | Fills the path with overlay theme foreground color. Optionally draw the shadow using the overlay theme shadow color. PF_FillPath( |
PF_FillVertex | Fills a square vertex around the center point using the overlay theme foreground color and vertex size. PF_FillVertex( |