Window Framework v1.2.4
Window Framework for Unity UI Toolkit
Loading...
Searching...
No Matches
GWG.WindowFramework.WindowFrame Class Reference

Represents a customizable window frame for UI elements in Unity. Provides functionality for resizing, moving, locking, and saving window state. Includes support for themes, tooltips, and context menus. More...

Inheritance diagram for GWG.WindowFramework.WindowFrame:

Public Member Functions

 WindowFrame ()
 Represents a custom UI element serving as a container for window-based content, including a header, content, and footer, providing event handling and theme adaptability for Unity's UI Toolkit.
void CloseWindow (bool forceAll=false)
 Closes the window if allowed.
void Hide ()
 Hides the window while keeping it in memory.
void SetOpeningPosition ()
 Sets the opening position of the window based on the selected position. Options include: TopLeft, Top, TopRight, Left, Center, Right, BottomLeft, Bottom, BottomRight.
void Show ()
 Shows the window by setting its display style to flex and opacity to 1.0f.

Properties

bool Active [get, set]
 Gets or sets whether the window is active.
bool AllowClose = true [get, set]
 Gets or sets whether the window can be closed.
bool AllowFullscreen = true [get, set]
 Determines whether the window frame can toggle to fullscreen mode.
bool AllowLock [get, set]
 Gets or sets whether the window can be locked.
bool AllowMove = true [get, set]
 Gets or sets whether the window can be moved.
bool AllowMultipleInstances = true [get, set]
 Gets or sets whether multiple instances of this window are allowed.
bool AllowResize [get, set]
 Gets or sets whether the window can be resized.
VisualElement Content [get, set]
 Gets or sets the content area of the window.
override VisualElement contentContainer [get]
 Overrides the contentContainer to return the window's content area instead of the root.
ContextMenuConfig ContextMenuConfig [get, set]
 Gets or sets the context menu configuration for this window.
float DefaultHeight = 300 [get, set]
 Gets or sets the default height of the window.
float DefaultWidth = 300 [get, set]
 Gets or sets the default width of the window.
VisualElement FooterToolbar [get, set]
 Gets or sets the toolbar in the footer area of the window.
bool Fullscreen [get, set]
 Gets or sets whether the window is in fullscreen mode.
bool Locked [get, set]
 Gets or sets whether the window is locked.
bool LockedFullscreen [get, set]
 Determines whether the fullscreen mode of the window is locked, preventing the user from toggling fullscreen on or off.
bool LockedToStartPosition [get, set]
 Gets or sets whether the window is locked to its start position.
float MinHeight [get, set]
 Gets or sets the minimum height of the window.
float MinWidth [get, set]
 Gets or sets the minimum width of the window.
string OptionsMenuTooltip [get, set]
 Gets or sets the tooltip for the options menu button.
string ParentObjectId [get, set]
 Gets or sets the ID of the parent object associated with the window.
string ResizeAreaTooltip [get, set]
 Gets or sets the tooltip for the resize area.
bool ShowFooter [get, set]
 Gets or sets whether the footer is visible.
bool ShowHeader [get, set]
 Gets or sets whether the header is visible.
WindowFramePosition StartPosition [get, set]
 Gets or sets the position of the window frame.
List< StyleSheet > StyleSheet [get, set]
 Gets or sets the stylesheet applied to the window.
string Title [get, set]
 Gets or sets the title of the window.
string WindowId [get, set]
 Gets or sets the unique ID of the window.
bool WindowMemoryEnabled = false [get, set]
 Gets or sets whether the window memory is enabled.

Events

static Action< WindowFrameOnWindowFrameAdded
 Event triggered when a new WindowFrame is added to the panel.
static Action< WindowFrameOnWindowFrameRemoved
 Event triggered when a WindowFrame is removed from the panel.

Private Member Functions

void Close ()
 Performs complete window closure and cleanup.
ContextMenuConfig ContextMenuDefaultConfig ()
 Creates the default context menu configuration with standard window operations.
void CreateLayout ()
 Creates the basic layout structure of the window by adding header, content, and footer.
void GeometryChangeCallback (GeometryChangedEvent evt)
 Called whenever a change in the window geometry occurs.
bool HandleMultipleInstanceCheck ()
 Checks if multiple instances are allowed and handles singleton behavior.
void KeepOnScreen ()
 Ensures the window remains within screen boundaries.
bool LoadWindowData ()
 Loads previously saved window data and applies it to the current window.
void OnAttachToPanel (AttachToPanelEvent evt)
 Handles the panel attach event.
void OnClickEvent (ClickEvent evt)
 Handles click events on the window for activation.
void OnDetachFromPanel (DetachFromPanelEvent evt)
 Handles the panel detach event for proper cleanup.
void OnOnScreenSizeChanged (GeometryChangedEvent evt)
 Handles screen size changes by repositioning windows as needed.
void OnWindowMove ()
 Called when the window is moved, starts a resetable timmer watching for idle and then save the window data.
void RegisterCallbacks ()
 Registers all necessary event callbacks for window functionality.
void SaveWindowData ()
 Save window data.
void SaveWindowData (bool isOpen)
 Saves the window data to the WindowFrameController.
void SetFullScreenMode (bool value)
 Toggles the fullscreen mode for the window frame.
void SetHeaderFade ()
 Updates header visual appearance based on active state.
void UnregisterCallbacks ()
 Unregisters all event callbacks to prevent memory leaks.
void UpdateTheme (List< StyleSheet > newTheme, List< StyleSheet > oldTheme)
 Updates the theme stylesheet for the windows in the system.
async void WaitForIdle ()
 Waits for the window to not be moving for 2 seconds before saving the window data.
VisualElement WindowFrameContent ()
 Creates the content area of the WindowFrame custom control.
VisualElement WindowFrameFooter ()
 Generates the Footer portion of a WindowFrame custom control.
VisualElement WindowFrameHeader ()
 Generates the header portion of a WindowFrame custom control.

Static Private Member Functions

static void ApplyContentStyles (VisualElement newContentContainer)
 Applies standard content styling to a container element.

Private Attributes

bool _active = true
 Indicates whether the window is currently active/focused.
bool _allowLock = true
 Indicates whether the window can be locked.
bool _allowResize = true
 Indicates whether the window can be resized.
VisualElement _content
 Content area of the window where main UI elements are placed.
ContextMenuConfig _contextMenuConfig
 Configuration for the context menu associated with this window.
VisualElement _footer
 Footer area of the window containing toolbar and resize handle.
VisualElement _footerToolbar
 Toolbar element in the footer area.
VisualElement _footerToolbarArea
 Container for the footer toolbar.
bool _fullScreen
 Indicates whether the window is in fullscreen mode.
VisualElement _header
 Header area of the window containing title and controls.
float _lastMoveTime
 Timestamp of the last window move operation.
Vector2 _lastPosition
 Last recorded position of the window for change detection.
Vector2 _lastSize
 Last recorded size of the window for change detection.
bool _locked
 Indicates whether the window is currently locked.
bool _lockedFullScreen = false
 Whether fullscreen mode is locked and cannot be changed.
bool _lockedToStartPosition = false
 Whether the window is locked to its start position.
VisualElement _lockIndicator = new Button()
 Button indicator for locking/unlocking the window.
float _minHeight = 50
 Minimum height of the window in pixels.
float _minWidth = 50
 Minimum width of the window in pixels.
VisualElement _optionsMenu = new Button()
 Button for opening the options menu.
bool _origAllowMove
 Original value of the allow move flag before fullscreen.
bool _origAllowResize
 Original value of the allow resize flag before fullscreen.
float _origBorderBLRadius
 Original bottom-left border radius value before fullscreen.
float _origBorderBRRadius
 Original bottom-right border radius value before fullscreen.
float _origBorderTLRadius
 Original top-left border radius value before fullscreen.
float _origBorderTRRadius
 Original top-right border radius value before fullscreen.
float _origHeight
 Original height before fullscreen mode.
float _origWidth
 Original width before fullscreen mode.
float _origX
 Original X position before fullscreen mode.
float _origY
 Original Y position before fullscreen mode.
bool _overrideStartPosition
 Indicates whether to override the default start position.
string _parentObjectId
 ID of the parent object associated with the window.
VisualElement _resizeArea = new VisualElement()
 Area for resizing the window, typically in the bottom-right corner.
Color _resolvedHeaderBgColor
 The resolved background color for the active header state.
Color _resolvedHeaderBgColorInactive
 The resolved background color for the inactive header state.
WindowFramePosition _selectedPosition = WindowFramePosition.TopLeft
 Initial positioning preference for the window.
bool _showFooter = true
 Indicates whether the footer is visible.
bool _showHeader = true
 Indicates whether the header is visible.
List< StyleSheet_styleSheet
 List of stylesheets applied to the window.
string _title = "Window Title"
 Title of the window displayed in the header.
Label _titleLabel = new Label()
 Label displaying the window title in the header.
bool _waitingForIdle
 Indicates whether the window is waiting for idle state before saving data.

Static Private Attributes

static readonly CustomStyleProperty< Color > s_CustomColor = new("--windowFrame__header-background-color")
 Custom style property for header background color theming.

Detailed Description

WindowFrame is a comprehensive window system that provides desktop-style window functionality including:

  • Complete window lifecycle management (create, show, hide, close)
  • Drag-and-drop window movement with boundary constraints
  • Resizable windows with configurable size limits
  • Fullscreen toggle with state preservation
  • Window locking system to prevent accidental modifications
  • Persistent window state across sessions
  • Multiple instance management
  • Theme integration and custom styling support
  • Context menu integration
  • Tooltip support throughout the interface
// Basic window creation
var window = new WindowFrame
{
WindowId = "MainWindow",
Title = "My Application",
DefaultWidth = 400,
};
// Add content
var content = new VisualElement();
content.Add(new Label("Hello World"));
window.Content = content;
// Show window
// Custom window subclass
public class InventoryWindow : WindowFrame
{
public InventoryWindow()
{
WindowId = "Inventory";
Title = "Player Inventory";
CreateInventoryInterface();
}
}
The WindowFrameController is the central management component for the Window Framework system....
Definition WindowFrameController.cs:77
static void AddElement(VisualElement newElement)
Adds a visual element to the window framework's root element with special handling for WindowFrame in...
Definition WindowFrameController.cs:2454
Represents a customizable window frame for UI elements in Unity. Provides functionality for resizing,...
Definition WindowFrame.cs:162
float DefaultHeight
Gets or sets the default height of the window.
Definition WindowFrame.cs:758
string WindowId
Gets or sets the unique ID of the window.
Definition WindowFrame.cs:437
bool AllowMultipleInstances
Gets or sets whether multiple instances of this window are allowed.
Definition WindowFrame.cs:552
string Title
Gets or sets the title of the window.
Definition WindowFrame.cs:654
WindowFrame()
Represents a custom UI element serving as a container for window-based content, including a header,...
Definition WindowFrame.cs:1413
float DefaultWidth
Gets or sets the default width of the window.
Definition WindowFrame.cs:737
bool WindowMemoryEnabled
Gets or sets whether the window memory is enabled.
Definition WindowFrame.cs:533

Constructor & Destructor Documentation

◆ WindowFrame()

GWG.WindowFramework.WindowFrame.WindowFrame ( )

The constructor performs comprehensive initialization including:

  • Multiple instance checking (if AllowMultipleInstances is false)
  • Editor/runtime visibility configuration
  • Basic styling and layout setup
  • Event callback registration
  • Theme integration and tooltip application
// Basic window creation
var window = new WindowFrame();
// Customized window
var customWindow = new WindowFrame {
WindowId = "CustomWindow",
Title = "My Window",
DefaultWidth = 500,
};
// Specialized subclass
public class InventoryWindow : WindowFrame {
public InventoryWindow() {
WindowId = "Inventory";
Title = "Player Inventory";
CreateInventoryUI();
}
}

Member Function Documentation

◆ ApplyContentStyles()

void GWG.WindowFramework.WindowFrame.ApplyContentStyles ( VisualElement newContentContainer)
staticprivate
Parameters
newContentContainerThe container to apply styling to

Configures the container for flexible vertical layout with proper overflow handling. Ensures consistent content area behavior across all windows.

◆ Close()

void GWG.WindowFramework.WindowFrame.Close ( )
private

Handles the full window closure process including:

  • Unregistering all event callbacks
  • Removing from UI hierarchy
  • Saving final state as closed
  • Updating WindowFrameController active window state Called internally after permission checks in CloseWindow().

◆ CloseWindow()

void GWG.WindowFramework.WindowFrame.CloseWindow ( bool forceAll = false)
Parameters
forceAllForces closure regardless of permissions when true

Respects AllowClose and Locked properties unless forceAll is true. When forceAll is true, overrides all restrictions for emergency shutdown scenarios. Calls the private Close() method to perform actual cleanup.

// Normal close (respects permissions)
window.CloseWindow();
// Force close (ignores all restrictions)
window.CloseWindow(true);
// Close all windows during shutdown
foreach (var win in windows) {
win.CloseWindow(true);
}

◆ ContextMenuDefaultConfig()

ContextMenuConfig GWG.WindowFramework.WindowFrame.ContextMenuDefaultConfig ( )
private
Returns
ContextMenuConfig with fullscreen, lock, and close options

Provides a standard context menu with common window operations. Each item includes appropriate visibility and enabled logic based on window permissions. Serves as an example for creating custom context menu configurations.

// The default menu includes:
// - Fullscreen (when not fullscreen and allowed)
// - Restore (when fullscreen and not locked)
// - Lock (when not locked and allowed)
// - Unlock (when locked and allowed)
// - Separator
// - Close (when allowed and in play mode)

◆ CreateLayout()

void GWG.WindowFramework.WindowFrame.CreateLayout ( )
private

Establishes the three-part window structure in the correct hierarchical order. Each section is created and configured for its specific purpose.

◆ GeometryChangeCallback()

void GWG.WindowFramework.WindowFrame.GeometryChangeCallback ( GeometryChangedEvent evt)
private
Parameters
evtThe geometry change event data

Handles window geometry changes by tracking position and size changes. Implements idle detection to avoid excessive save operations during continuous movement. Respects LockedToStartPosition setting by resetting position when needed.

◆ HandleMultipleInstanceCheck()

bool GWG.WindowFramework.WindowFrame.HandleMultipleInstanceCheck ( )
private
Returns
True if window should continue initialization, false if it should be destroyed

When AllowMultipleInstances is false, searches for existing instances of the same type. If found, activates the existing instance and marks the new one for destruction. Only performs check during runtime to avoid editor issues.

◆ Hide()

void GWG.WindowFramework.WindowFrame.Hide ( )

Removes the window from layout calculations while keeping it in the hierarchy. Updates display style and visibility flag for fast show/hide operations. Schedules a save operation to persist the hidden state.

// Hide window temporarily
window.Hide();
// Window becomes:
// - display: none (excluded from layout)
// - visible: false (marked as hidden)
// - Still in hierarchy for fast restoration

◆ KeepOnScreen()

void GWG.WindowFramework.WindowFrame.KeepOnScreen ( )
private

Adjusts window position to prevent it from moving off-screen. Handles all four screen edges and maintains window visibility. Called automatically during positioning operations.

// Called automatically during:
// - Window movement
// - Screen size changes
// - Window positioning operations
// Ensures window stays fully visible

◆ LoadWindowData()

bool GWG.WindowFramework.WindowFrame.LoadWindowData ( )
private
Returns
True if loading completed successfully, false if window should be destroyed

Attempts to restore window state from saved data including position, size, and visibility. Falls back to default positioning if no saved data exists or memory is disabled. Handles multiple instance checking and applies appropriate sizing for fullscreen mode.

// Called automatically during window initialization
// Restores saved position, size, visibility from previous session
// Falls back to StartPosition if no saved data

◆ OnAttachToPanel()

void GWG.WindowFramework.WindowFrame.OnAttachToPanel ( AttachToPanelEvent evt)
private
Parameters
evtThe attach event data

Triggered when the window is added to the UI hierarchy. Fires the OnWindowFrameAdded event for system notification.

◆ OnClickEvent()

void GWG.WindowFramework.WindowFrame.OnClickEvent ( ClickEvent evt)
private
Parameters
evtThe click event data

Sets this window as the active window when clicked (except options menu clicks). Only operates during play mode to avoid editor interference. Uses WindowFrameController to properly manage window activation.

// User clicks anywhere on window
// (except options menu button)
// → Window becomes active/focused
// → Other windows become inactive

◆ OnDetachFromPanel()

void GWG.WindowFramework.WindowFrame.OnDetachFromPanel ( DetachFromPanelEvent evt)
private
Parameters
evtThe detach event data

Triggered when the window is removed from the UI hierarchy. Fires the OnWindowFrameRemoved event and unregisters all callbacks. Essential for notifying other systems and preventing memory leaks.

◆ OnOnScreenSizeChanged()

void GWG.WindowFramework.WindowFrame.OnOnScreenSizeChanged ( GeometryChangedEvent evt)
private
Parameters
evtThe geometry change event from the screen/panel

Responds to screen resolution changes or panel size modifications. Updates window position if LockedToStartPosition is true. Ensures windows remain on screen after size changes.

◆ OnWindowMove()

void GWG.WindowFramework.WindowFrame.OnWindowMove ( )
private

Tracks the last move time and initiates idle detection to batch save operations. Prevents excessive saving during continuous window movement operations.

◆ RegisterCallbacks()

void GWG.WindowFramework.WindowFrame.RegisterCallbacks ( )
private

Sets up comprehensive event handling including:

  • Initial geometry setup and data loading
  • Ongoing geometry change monitoring
  • Window activation/focus handling
  • Theme change subscriptions
  • Screen size change responses
  • Manipulator setup for drag/resize/context menu Uses scheduled execution to ensure proper initialization timing.
// Called automatically during constructor
// Sets up all event handling for:
// - Window movement and resizing
// - Focus and activation
// - Theme changes
// - Context menu and manipulators

◆ SaveWindowData() [1/2]

void GWG.WindowFramework.WindowFrame.SaveWindowData ( )
private

Convenience method that saves window data with current visibility state. Uses the more detailed SaveWindowData(bool) method internally.

◆ SaveWindowData() [2/2]

void GWG.WindowFramework.WindowFrame.SaveWindowData ( bool isOpen)
private
Parameters
isOpenWhether the window is currently open

Saves comprehensive window state including position, size, visibility, lock state, and other properties. Only saves if WindowMemoryEnabled is true and proper identification is available. Creates a unique data key combining type, parent ID, and window ID.

// Save current state
SaveWindowData(true); // Window is open
// Save when closing
SaveWindowData(false); // Window is closed
// Data key format: "MyWindowType|ParentId|WindowId"
void SaveWindowData()
Save window data.
Definition WindowFrame.cs:1750

◆ SetFullScreenMode()

void GWG.WindowFramework.WindowFrame.SetFullScreenMode ( bool value)
private
Parameters
valueA boolean indicating whether to enable or disable fullscreen mode.

Manages fullscreen state by storing original dimensions and settings. Temporarily disables resize and move capabilities in fullscreen mode. Restores original state when exiting fullscreen. Respects AllowFullscreen, Locked, and LockedFullscreen properties.

// Enter fullscreen
// Stores: original width, height, x, y, allowResize, allowMove
// Sets: 100% width/height, position (0,0), disables resize/move
// Exit fullscreen
// Restores: original dimensions and settings
void SetFullScreenMode(bool value)
Toggles the fullscreen mode for the window frame.
Definition WindowFrame.cs:2069

◆ SetHeaderFade()

void GWG.WindowFramework.WindowFrame.SetHeaderFade ( )
private

Applies different opacity levels to provide visual feedback about window focus:

  • Active windows: Full opacity (1.0)
  • Inactive windows: Reduced opacity (0.7) Helps users identify which window currently has focus.

◆ SetOpeningPosition()

void GWG.WindowFramework.WindowFrame.SetOpeningPosition ( )

Calculates window position based on screen dimensions and window size. Respects LockedToStartPosition and _overrideStartPosition settings. Uses scheduled execution to ensure layout calculations are complete.

// Positions calculated relative to screen:
// TopLeft: (0, 0)
// Center: (screenWidth-windowWidth)/2, (screenHeight-windowHeight)/2
// BottomRight: screenWidth-windowWidth, screenHeight-windowHeight

◆ Show()

void GWG.WindowFramework.WindowFrame.Show ( )

Makes the window immediately visible and interactive. Updates display style, visibility flag, and opacity. Schedules a save operation to persist the visible state.

// Show window immediately
window.Show();
// Window becomes:
// - display: flex (part of layout)
// - visible: true (marked as visible)
// - opacity: 1.0 (fully opaque)

◆ UnregisterCallbacks()

void GWG.WindowFramework.WindowFrame.UnregisterCallbacks ( )
private

Removes all registered event callbacks including:

  • Geometry change callbacks
  • Click events
  • Panel detach events
  • Theme change subscriptions
  • Screen size change callbacks Essential for proper cleanup and memory management.

◆ UpdateTheme()

void GWG.WindowFramework.WindowFrame.UpdateTheme ( List< StyleSheet > newTheme,
List< StyleSheet > oldTheme )
private
Parameters
newThemeThe new stylesheet to apply
oldThemeThe old stylesheet to remove

Safely replaces old stylesheets with new ones during theme changes. Ensures proper cleanup and prevents style conflicts.

◆ WaitForIdle()

async void GWG.WindowFramework.WindowFrame.WaitForIdle ( )
private

Implements asynchronous idle detection to batch save operations. Waits 1 second of inactivity before saving to avoid excessive file operations. Includes error handling for async operation failures.

// Called automatically after window movement stops
// Waits 1 second of no movement, then saves window data
// Prevents continuous saving during drag operations

◆ WindowFrameContent()

VisualElement GWG.WindowFramework.WindowFrame.WindowFrameContent ( )
private
Returns
VisualElement as the container section of the windowframe

Creates the main content container with appropriate flex layout settings. This is where application content should be placed.

◆ WindowFrameFooter()

VisualElement GWG.WindowFramework.WindowFrame.WindowFrameFooter ( )
private
Returns
VisualElement containing the complete window footer

Creates the footer with toolbar area and resize handle. Configured for proper layout and resize functionality.

◆ WindowFrameHeader()

VisualElement GWG.WindowFramework.WindowFrame.WindowFrameHeader ( )
private
Returns
VisualElement containing the complete window header

Creates the header with title label, lock indicator, and options menu. Configured for dragging and proper event handling.

Member Data Documentation

◆ _active

bool GWG.WindowFramework.WindowFrame._active = true
private

◆ _allowLock

bool GWG.WindowFramework.WindowFrame._allowLock = true
private

◆ _allowResize

bool GWG.WindowFramework.WindowFrame._allowResize = true
private

◆ _content

VisualElement GWG.WindowFramework.WindowFrame._content
private

◆ _contextMenuConfig

ContextMenuConfig GWG.WindowFramework.WindowFrame._contextMenuConfig
private

◆ _footer

VisualElement GWG.WindowFramework.WindowFrame._footer
private

◆ _footerToolbar

VisualElement GWG.WindowFramework.WindowFrame._footerToolbar
private

◆ _footerToolbarArea

VisualElement GWG.WindowFramework.WindowFrame._footerToolbarArea
private

◆ _fullScreen

bool GWG.WindowFramework.WindowFrame._fullScreen
private

◆ _header

VisualElement GWG.WindowFramework.WindowFrame._header
private

◆ _lastMoveTime

float GWG.WindowFramework.WindowFrame._lastMoveTime
private

◆ _lastPosition

Vector2 GWG.WindowFramework.WindowFrame._lastPosition
private

◆ _lastSize

Vector2 GWG.WindowFramework.WindowFrame._lastSize
private

◆ _locked

bool GWG.WindowFramework.WindowFrame._locked
private

◆ _lockedFullScreen

bool GWG.WindowFramework.WindowFrame._lockedFullScreen = false
private

◆ _lockedToStartPosition

bool GWG.WindowFramework.WindowFrame._lockedToStartPosition = false
private

◆ _lockIndicator

VisualElement GWG.WindowFramework.WindowFrame._lockIndicator = new Button()
private

◆ _minHeight

float GWG.WindowFramework.WindowFrame._minHeight = 50
private

◆ _minWidth

float GWG.WindowFramework.WindowFrame._minWidth = 50
private

◆ _optionsMenu

VisualElement GWG.WindowFramework.WindowFrame._optionsMenu = new Button()
private

◆ _origAllowMove

bool GWG.WindowFramework.WindowFrame._origAllowMove
private

◆ _origAllowResize

bool GWG.WindowFramework.WindowFrame._origAllowResize
private

◆ _origBorderBLRadius

float GWG.WindowFramework.WindowFrame._origBorderBLRadius
private

◆ _origBorderBRRadius

float GWG.WindowFramework.WindowFrame._origBorderBRRadius
private

◆ _origBorderTLRadius

float GWG.WindowFramework.WindowFrame._origBorderTLRadius
private

◆ _origBorderTRRadius

float GWG.WindowFramework.WindowFrame._origBorderTRRadius
private

◆ _origHeight

float GWG.WindowFramework.WindowFrame._origHeight
private

◆ _origWidth

float GWG.WindowFramework.WindowFrame._origWidth
private

◆ _origX

float GWG.WindowFramework.WindowFrame._origX
private

◆ _origY

float GWG.WindowFramework.WindowFrame._origY
private

◆ _overrideStartPosition

bool GWG.WindowFramework.WindowFrame._overrideStartPosition
private

◆ _parentObjectId

string GWG.WindowFramework.WindowFrame._parentObjectId
private

◆ _resizeArea

VisualElement GWG.WindowFramework.WindowFrame._resizeArea = new VisualElement()
private

◆ _resolvedHeaderBgColor

Color GWG.WindowFramework.WindowFrame._resolvedHeaderBgColor
private

◆ _resolvedHeaderBgColorInactive

Color GWG.WindowFramework.WindowFrame._resolvedHeaderBgColorInactive
private

◆ _selectedPosition

WindowFramePosition GWG.WindowFramework.WindowFrame._selectedPosition = WindowFramePosition.TopLeft
private

◆ _showFooter

bool GWG.WindowFramework.WindowFrame._showFooter = true
private

◆ _showHeader

bool GWG.WindowFramework.WindowFrame._showHeader = true
private

◆ _styleSheet

List<StyleSheet> GWG.WindowFramework.WindowFrame._styleSheet
private

◆ _title

string GWG.WindowFramework.WindowFrame._title = "Window Title"
private

◆ _titleLabel

Label GWG.WindowFramework.WindowFrame._titleLabel = new Label()
private

◆ _waitingForIdle

bool GWG.WindowFramework.WindowFrame._waitingForIdle
private

◆ s_CustomColor

readonly CustomStyleProperty<Color> GWG.WindowFramework.WindowFrame.s_CustomColor = new("--windowFrame__header-background-color")
staticprivate

Property Documentation

◆ Active

bool GWG.WindowFramework.WindowFrame.Active
getset

Active state affects visual appearance (inactive windows appear dimmed). Only one window should be active at a time. Managed by WindowFrameController.

// Check if window is active
if (window.Active) {
Debug.Log("Window has focus");
}
// Set active through controller (recommended)
void SetActiveWindow(WindowFrame newTarget)
Sets the specified window as the active window and deactivates all others.
Definition WindowFrameController.cs:1921
static WindowFrameController Instance
Gets the singleton instance of the WindowFrameController.
Definition WindowFrameController.cs:221

◆ AllowClose

bool GWG.WindowFramework.WindowFrame.AllowClose = true
getset

When disabled, users cannot close the window through normal means. Can still be closed programmatically with CloseWindow(true).

// Essential system window
systemWindow.AllowClose = false;
// Conditional closing
documentWindow.AllowClose = !hasUnsavedChanges;

◆ AllowFullscreen

bool GWG.WindowFramework.WindowFrame.AllowFullscreen = true
getset

When disabled, users cannot toggle fullscreen through context menu or double-click. The Fullscreen property can still be set programmatically if needed.

// Main window with fullscreen support
mainWindow.AllowFullscreen = true;
// Small utility without fullscreen
toolPalette.AllowFullscreen = false;

◆ AllowLock

bool GWG.WindowFramework.WindowFrame.AllowLock
getset

When enabled, users can lock/unlock through context menu or lock indicator. Locked windows cannot be moved, resized, or closed by normal interactions.

// Window that can be locked
importantWindow.AllowLock = true;
// Window where locking isn't needed
temporaryWindow.AllowLock = false;

◆ AllowMove

bool GWG.WindowFramework.WindowFrame.AllowMove = true
getset

When enabled, users can drag the header to reposition the window. Movement is constrained to keep window within screen bounds. Automatically disabled when locked or in fullscreen mode.

// Fixed-position status window
statusWindow.AllowMove = false;
statusWindow.LockedToStartPosition = true;
// Moveable dialog
dialogWindow.AllowMove = true;

◆ AllowMultipleInstances

bool GWG.WindowFramework.WindowFrame.AllowMultipleInstances = true
getset

When false, creating a new instance will activate the existing one instead. Useful for singleton windows like settings or main inventory.

// Only one settings window
settingsWindow.AllowMultipleInstances = false;
// Multiple chat windows allowed
chatWindow.AllowMultipleInstances = true;

◆ AllowResize

bool GWG.WindowFramework.WindowFrame.AllowResize
getset

When enabled, users can drag the resize handle to change dimensions. Subject to MinWidth/MinHeight constraints and disabled when locked.

// Fixed-size dialog
alertWindow.AllowResize = false;
// Resizable main window
mainWindow.AllowResize = true;
mainWindow.MinWidth = 400;
mainWindow.MinHeight = 300;

◆ Content

VisualElement GWG.WindowFramework.WindowFrame.Content
getset

The main container where application UI elements should be placed. When set, existing content is removed and tooltips are automatically applied. This is where forms, data displays, and interactive controls go.

// Simple content
var content = new VisualElement();
content.Add(new Label("Welcome"));
content.Add(new Button("Start"));
window.Content = content;
// Complex content with layout
var complexContent = new VisualElement();
complexContent.Add(CreateHeaderSection());
complexContent.Add(CreateDataSection());
complexContent.Add(CreateButtonSection());
window.Content = complexContent;

◆ contentContainer

override VisualElement GWG.WindowFramework.WindowFrame.contentContainer
get

This ensures that elements added directly to the WindowFrame are placed in the content area rather than the root, maintaining the window's internal structure while providing intuitive behavior.

// These automatically go to content area:
window.Add(new Label("Hello"));
window.hierarchy.Add(new Button("Click"));
// Equivalent to:
window.Content.Add(new Label("Hello"));

◆ ContextMenuConfig

ContextMenuConfig GWG.WindowFramework.WindowFrame.ContextMenuConfig
getset

If no custom configuration is provided, a default context menu is generated with standard window operations (fullscreen, lock, close). Custom configurations can add application-specific options.

// Custom context menu
var config = new ContextMenuConfig {
Title = "Window Options",
Items = new List<ContextMenuItem> {
new ContextMenuItem("Save Layout", SaveLayout),
new ContextMenuItem("Reset", ResetWindow),
new ContextMenuItem(), // Separator
}
};
window.ContextMenuConfig = config;
Used to define the items that will be displayed in the context menu.
Definition ContextMenuItem.cs:9
ContextMenuConfig ContextMenuConfig
Gets or sets the context menu configuration for this window.
Definition WindowFrame.cs:1120
void CloseWindow(bool forceAll=false)
Closes the window if allowed.
Definition WindowFrame.cs:2133

◆ DefaultHeight

float GWG.WindowFramework.WindowFrame.DefaultHeight = 300
getset

Used when the window is first created or when no saved size data is available. Provides the initial height for new window instances.

// Portrait window
inventoryWindow.DefaultHeight = 400;
inventoryWindow.DefaultWidth = 300;
// Landscape window
timelineWindow.DefaultHeight = 200;
timelineWindow.DefaultWidth = 600;

◆ DefaultWidth

float GWG.WindowFramework.WindowFrame.DefaultWidth = 300
getset

Used when the window is first created or when no saved size data is available. Provides the initial width for new window instances.

// Different defaults for different window types
settingsWindow.DefaultWidth = 400;
chatWindow.DefaultWidth = 350;
mainWindow.DefaultWidth = 800;

◆ FooterToolbar

VisualElement GWG.WindowFramework.WindowFrame.FooterToolbar
getset

Provides a dedicated area for action buttons and controls at the bottom of the window. Positioned to the left of the resize handle. Setting to null removes toolbar content.

// Simple button toolbar
var toolbar = new VisualElement();
toolbar.style.flexDirection = FlexDirection.Row;
toolbar.Add(new Button("Save"));
toolbar.Add(new Button("Cancel"));
window.FooterToolbar = toolbar;
// Status and actions
var statusToolbar = new VisualElement();
statusToolbar.Add(new Label("Ready"));
statusToolbar.Add(CreateActionButtons());
window.FooterToolbar = statusToolbar;

◆ Fullscreen

bool GWG.WindowFramework.WindowFrame.Fullscreen
getset

Fullscreen mode expands the window to fill the entire screen and temporarily disables movement and resizing. Original dimensions are preserved for restoration.

// Toggle fullscreen
window.Fullscreen = !window.Fullscreen;
// Start in fullscreen
mediaWindow.Fullscreen = true;

◆ Locked

bool GWG.WindowFramework.WindowFrame.Locked
getset

When locked, the window cannot be moved, resized, or closed through normal means. Displays lock indicator and adds appropriate CSS classes for styling. Only available if AllowLock is true.

// Lock window programmatically
window.Locked = true;
// Toggle lock state
window.Locked = !window.Locked;
// Check before operations
if (!window.Locked) {
// Can perform operation
}

◆ LockedFullscreen

bool GWG.WindowFramework.WindowFrame.LockedFullscreen
getset

When true, forces the window into fullscreen mode and prevents users from exiting. Creates a kiosk-style interface where the window permanently occupies the screen.

// Kiosk mode application
kioskWindow.LockedFullscreen = true;
// Presentation mode
presentationWindow.LockedFullscreen = presentationMode;

◆ LockedToStartPosition

bool GWG.WindowFramework.WindowFrame.LockedToStartPosition
getset

When true, the window will always return to its StartPosition and ignore saved position data. Useful for windows that should maintain consistent positioning.

// System window that stays in top-left
systemWindow.LockedToStartPosition = true;
systemWindow.StartPosition = WindowFramePosition.TopLeft;
WindowFramePosition
Enumeration defining predefined positioning options for window frames within the screen space.
Definition WindowFrame.cs:32

◆ MinHeight

float GWG.WindowFramework.WindowFrame.MinHeight
getset

Enforces a lower bound on window resizing to ensure usability. Should account for header, content area, and footer visibility.

// Standard minimum
window.MinHeight = 100;
// Dynamic based on components
float minHeight = (ShowHeader ? 30 : 0) +
(ShowFooter ? 25 : 0) +
100; // content minimum
window.MinHeight = minHeight;
bool ShowHeader
Gets or sets whether the header is visible.
Definition WindowFrame.cs:861
bool ShowFooter
Gets or sets whether the footer is visible.
Definition WindowFrame.cs:890

◆ MinWidth

float GWG.WindowFramework.WindowFrame.MinWidth
getset

Enforces a lower bound on window resizing to ensure usability. Applied through both CSS styling and drag-resize operations.

// Set reasonable minimums
window.MinWidth = 200; // Enough for buttons
window.MinHeight = 150; // Header + content
// Content-based minimum
window.MinWidth = CalculateMinimumContentWidth();

◆ OptionsMenuTooltip

string GWG.WindowFramework.WindowFrame.OptionsMenuTooltip
getset

Supports positioning hints using format "Position:Text" where Position can be T, B, L, or R. Provides users with information about the options menu functionality.

// Default tooltip
window.OptionsMenuTooltip = "B:Open window options";
// Custom tooltip
window.OptionsMenuTooltip = "T:Advanced settings";

◆ ParentObjectId

string GWG.WindowFramework.WindowFrame.ParentObjectId
getset

ParentObjectId allows windows to be associated with specific game objects or contexts. This enables multiple windows of the same type to maintain separate state data.

// Associate with specific container
chestWindow.ParentObjectId = "Chest_001";
// Associate with NPC
shopWindow.ParentObjectId = "Merchant_Village";

◆ ResizeAreaTooltip

string GWG.WindowFramework.WindowFrame.ResizeAreaTooltip
getset

Supports positioning hints using format "Position:Text" where Position can be T, B, L, or R. Provides users with instructions for resizing the window.

// Standard resize tooltip
window.ResizeAreaTooltip = "B:Drag to resize";
// Custom instructions
window.ResizeAreaTooltip = "T:Click and drag corner to change size";

◆ ShowFooter

bool GWG.WindowFramework.WindowFrame.ShowFooter
getset

The footer contains toolbar area and resize handle. Hiding it removes resize functionality unless handled elsewhere.

// Simple dialog without footer
dialogWindow.ShowFooter = false;
dialogWindow.AllowResize = false;
// Compact mode
window.ShowFooter = !compactMode;

◆ ShowHeader

bool GWG.WindowFramework.WindowFrame.ShowHeader
getset

The header contains title, options menu, and lock indicator. Hiding it removes the drag handle, so ensure alternative movement methods if needed.

// Borderless window
window.ShowHeader = false;
window.ShowFooter = false;
// Toggle header for fullscreen
window.ShowHeader = !isFullscreenMode;

◆ StartPosition

WindowFramePosition GWG.WindowFramework.WindowFrame.StartPosition
getset

Determines where the window will initially appear on screen. Can be overridden by saved window data if WindowMemoryEnabled is true.

// Center window on screen
window.StartPosition = WindowFramePosition.Center;
// Position in top-left
debugWindow.StartPosition = WindowFramePosition.TopLeft;

◆ StyleSheet

List<StyleSheet> GWG.WindowFramework.WindowFrame.StyleSheet
getset

Allows individual windows to have custom styling beyond the global theme. Stylesheets are applied immediately and replace existing window-specific styles. Falls back to global theme on loading failure.

// Custom window styling
window.StyleSheet = new List<StyleSheet> {
Resources.Load<StyleSheet>("CustomTheme"),
Resources.Load<StyleSheet>("WindowEffects")
};
// Error window with special styling
errorWindow.StyleSheet = new List<StyleSheet> {
Resources.Load<StyleSheet>("ErrorStyle")
};
List< StyleSheet > StyleSheet
Gets or sets the stylesheet applied to the window.
Definition WindowFrame.cs:784

◆ Title

string GWG.WindowFramework.WindowFrame.Title
getset

The title is displayed in the window header and can be changed dynamically. Changes immediately update the visual title label.

// Static title
window.Title = "My Application";
// Dynamic title
window.Title = $"Document - {fileName}";
// Status in title
window.Title = $"Chat - {channelName} ({userCount} users)";

◆ WindowId

string GWG.WindowFramework.WindowFrame.WindowId
getset

The WindowId is used for persistence and should be unique within the application. It's combined with ParentObjectId to create unique save keys.

// Static ID for singleton windows
window.WindowId = "MainInventory";
// Dynamic ID for multiple instances
window.WindowId = $"ItemDetail_{itemId}";

◆ WindowMemoryEnabled

bool GWG.WindowFramework.WindowFrame.WindowMemoryEnabled = false
getset

When enabled, window position, size, and state are automatically saved and restored. Requires both this property and WindowFrameController.MemoryEnabled to be true.

// Enable persistence for user windows
inventoryWindow.WindowMemoryEnabled = true;
// Disable for temporary dialogs
alertDialog.WindowMemoryEnabled = false;

Event Documentation

◆ OnWindowFrameAdded

Action<WindowFrame> GWG.WindowFramework.WindowFrame.OnWindowFrameAdded
static

This static event allows other systems to respond to window creation for registration, initialization, or UI management purposes.

Debug.Log($"Window added: {window.Title}");
RegisterWindow(window);
};
static Action< WindowFrame > OnWindowFrameAdded
Event triggered when a new WindowFrame is added to the panel.
Definition WindowFrame.cs:178

◆ OnWindowFrameRemoved

Action<WindowFrame> GWG.WindowFramework.WindowFrame.OnWindowFrameRemoved
static

This static event allows other systems to respond to window removal for cleanup, deregistration, or UI management purposes.

Debug.Log($"Window removed: {window.Title}");
UnregisterWindow(window);
};
static Action< WindowFrame > OnWindowFrameRemoved
Event triggered when a WindowFrame is removed from the panel.
Definition WindowFrame.cs:195