In DaVinci Resolve's Fusion scripting environment, particularly when using the Fusion UI with Lua, you can create and customize windows using the disp:AddWindow function. This function accepts a table of parameters that define various window properties, often referred to as "flags." These flags determine the appearance and behavior of the window.
Below is a comprehensive list of the common window properties (flags) you can use with disp:AddWindow, along with explanations and example values:
Common Window Flags
-
ID
- Type:
string
- Description: A unique identifier for the window. Useful for referencing the window later in your script.
- Example:
"Playhead"
-
WindowTitle
- Type:
string
- Description: The text displayed in the window's title bar.
- Example:
"Playhead"
-
BorderStyle
- Type:
string
- Description: Determines the style of the window's border.
- Possible Values:
"None": No border.
"Single": Single-line border.
"Dialog": Dialog-style border.
- Example:
"None"
-
Resizable
- Type:
boolean
- Description: Specifies whether the window can be resized by the user.
- Possible Values:
true: Window is resizable.
false: Window size is fixed.
- Example:
false
-
Geometry
- Type:
table (array)
- Description: Defines the window's position and size on the screen.
- Structure:
{ x, y, width, height }
- Example:
{ 100, 100, 220, 50 }
-
AlwaysOnTop
- Type:
boolean
- Description: Keeps the window above all other windows.
- Possible Values:
true: Window stays on top.
false: Window behaves normally.
- Example:
true
-
Modal
- Type:
boolean
- Description: Makes the window modal, blocking interaction with other windows until closed.
- Possible Values:
true: Window is modal.
false: Window is non-modal.
- Example:
false
-
ShowCloseButton
- Type:
boolean
- Description: Displays the close (X) button on the window.
- Possible Values:
true: Show close button.
false: Hide close button.
- Example:
true
-
ShowMinimizeButton
- Type:
boolean
- Description: Displays the minimize button on the window.
- Possible Values:
true: Show minimize button.
false: Hide minimize button.
- Example:
false
-
ShowMaximizeButton
- Type:
boolean
- Description: Displays the maximize button on the window.
- Possible Values:
true: Show maximize button.
false: Hide maximize button.
- Example:
false
-
AcceptsFocus
- Type:
boolean
- Description: Determines whether the window can receive keyboard focus.
- Possible Values:
true: Window can accept focus.
false: Window cannot accept focus.
- Example:
true
-
Icon
- Type:
string
- Description: Path to an icon file to display in the window's title bar.
- Example:
"path/to/icon.png"
-
Theme
- Type:
string
- Description: Specifies the UI theme for the window (if supported).
- Possible Values: Depends on Fusion's supported themes.
- Example:
"Dark" or "Light"
Example Usage
Here's how you might incorporate some of these flags into your AddWindow function:
local win = disp:AddWindow({
ID = "Playhead",
WindowTitle = "Playhead",
BorderStyle = "None",
Resizable = false,
Geometry = { 100, 100, 220, 50 },
AlwaysOnTop = true,
ShowCloseButton = false,
ShowMinimizeButton = false,
ShowMaximizeButton = false,
AcceptsFocus = true,
ui:VGroup {
ID = "playground",
ui:HGroup {
Weight = 0,
ui:Button { ID = "btnLock", Text = "PLAYHEAD FREE" },
},
},
})
Additional Considerations
-
UI Hierarchy: The ui:VGroup and ui:HGroup in your example define the layout of UI elements within the window. Ensure that these groups are correctly structured to achieve the desired layout.
-
Event Handling: After creating the window, you might want to handle events (like button clicks) by connecting to relevant signals or using callback functions.
-
Scripting API Documentation: While the above list covers common flags, Fusion's scripting API may offer additional or updated properties based on the version you're using. It's advisable to consult the latest DaVinci Resolve Fusion Scripting Documentation for detailed and version-specific information.
Summary
When using disp:AddWindow in Fusion's Lua scripting environment, you have access to a variety of window flags that allow you to customize the window's appearance and behavior extensively. By setting these flags appropriately, you can create user interfaces that are tailored to your specific needs within DaVinci Resolve.
If you have specific requirements or encounter limitations, referring to the official documentation or community forums can provide additional guidance and examples.