Custom UI & Drawbot¶
Custom UI uses a composited drawing model using Drawbot. The Drawbot suites can be used for:
- Basic 2D path drawing: Lines, Rect, Arc, Bezier
- Stroking/Filling/Shading paths
- Image drawing: Compositing an ARGB/BGRA buffer onto the surface
- Pushing/popping surface state
- Text drawing, if supplier supports it (clients should first check if text drawing is supported before actual drawing)
Drawing may only occur during PF_Event_DRAW
(and not during PF_Event_DRAG
or PF_Event_DO_CLICK
).
To use Drawbot, first get the drawing reference by passing in PF_Context to a new suite call PF_GetDrawingReference.
If a non-NULL drawing reference is returned, use it to get the supplier and surface references from DRAWBOT_DrawbotSuite.
The Drawbot suites include DRAWBOT_DrawbotSuite
, DRAWBOT_SupplierSuite
, DRAWBOT_SurfaceSuite
, DRAWBOT_PathSuite
.
Make Your Custom UI Look Not So "Custom"¶
Use the new PF_EffectCustomUIOverlayThemeSuite to match the host application UI. Your users will thank you.
Redrawing¶
In order to redraw a specific area of a pane, we recommend the following:
- Call
PF_InvalidateRect
(from PF_AppSuite) from the effect. This will cause a lazy display redraw, and will update at the next available idle moment. This rect is in coordinates related to the associated pane. Using a NULL rect will update the entire pane. - Set the event outflag to
PF_EO_UPDATE_NOW
, which will cause an immediate draw event for the specified pane when the current event returns.
If an effect needs to update more than one window at a time, it should set PF_OutFlag_REFRESH_UI
(from PF_OutFlags), which will cause a redraw of the entire ECW, comp, and layer windows.
HiDPI and Retina Display Support¶
To support HiDPI and Retina Displays, you can use offscreen images that are twice the size, and then use the Transform
function from Drawbot_SurfaceSuite to scale the image down in half before drawing it.
PF_EffectCustomUISuite¶
Enables an effect to get the drawing reference. This is the first call needed to use Drawbot.
PF_EffectCustomUISuite1¶
Function |
Purpose |
---|---|
|
Get the drawing reference.
|
Drawbot_DrawbotSuite¶
Using the Drawbot reference, get the supplier and surface references.
Drawbot_DrawbotSuite1¶
Function |
Purpose |
---|---|
|
Get the supplier reference. Needed to use Drawbot_SupplierSuite.
|
|
Get the surface reference. Needed to use Drawbot_SurfaceSuite.
|
Drawbot_SupplierSuite¶
Calls to create and release drawing tools, get default settings, and query drawing capabilities.
Drawbot_SupplierSuite1¶
Function |
Purpose |
---|---|
|
Create a new pen. Release this using
|
|
Create a new brush. Release this using
|
|
Check if current supplier supports text.
|
|
Get the default font size.
|
|
Create a new font with default settings. You can pass the default font size from Release this using
|
|
Create a new image from buffer passed to in_dataP. Release this using
|
|
Create a new path. Release this using
|
|
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
|
|
|
|
|
|
|
|
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.
|
|
Release (decrease reference count on) any object (pen, brush, path, etc). This function MUST be called for any object created using Do not call this function on a
|
Drawbot_SurfaceSuite¶
Calls to draw on the surface, and to query and set drawing settings.
Drawbot_SurfaceSuite1¶
Function |
Purpose |
---|---|
|
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.
|
|
Pop the last pushed surface state off the stack.
|
|
Paint a rectangle with a color on the surface.
|
|
Fill a path using a brush and fill type.
|
|
Stroke a path using a pen.
|
|
Clip the surface.
|
|
Get clip bounds.
|
|
Checks whether a rect is within the clip bounds.
|
|
Transform the last surface state.
|
|
Draw a string.
|
|
Draw an image created using
|
|
|
|
|
|
|
|
|
|
Flush drawing. This is not always needed, and if overused, may cause excessive redrawing and flashing.
|
Drawbot_PathSuite¶
Calls to draw paths.
Drawbot_PathSuite1¶
Function |
Purpose |
---|---|
|
Move to a point.
|
|
Add a line to the path.
|
|
Add a cubic bezier to the path.
|
|
Add a rect to the path.
|
|
Add a arc to the path. Zero start degrees == 3 o'clock. Sweep is clockwise. Units for angle are in degrees.
|
|
Close the path.
|
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¶
Function |
Purpose |
---|---|
|
Get the preferred foreground color.
|
|
Get the preferred shadow color.
|
|
Get the preferred foreground & shadow stroke width.
|
|
Get the preferred vertex size.
|
|
Get the preferred shadow offset.
|
|
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.
|
|
Fills the path with overlay theme foreground color. Optionally draw the shadow using the overlay theme shadow color.
|
|
Fills a square vertex around the center point using the overlay theme foreground color and vertex size.
|