Class Views.Windows.Window

The Window class is the base class for all windows in the library.

A window in this context is a standard frame that makes use of the World of Warcraft CreateFrame function, but with some additional features: a title bar that can move the window, a close button, a resize button at the bottom, a content area with a scroll bar, plus a few other.

The motivation behind this class is to provide a simple way to create windows, considering that the CreateFrame function is a bit cumbersome to use, and that the standard window features can be enough for most addons.

It's necessary to note that this class is not as flexible as the CreateFrame function, and that it's not meant to replace it. It's just a simple way to create a basic window with some standard features. And if the addon developer needs more flexibility, it's possible to extend this class to override some methods and add new features.

Local Functions

views.windows.window.createCloseButton () Creates a close button in the title bar.
views.windows.window.createContentFrame () Creates the content frame, where the window's content will be placed.
views.windows.window.createFooter () Creates a footer bar that contains a resize button.
views.windows.window.createFrame () This is just a facade method to call World of Warcraft's CreateFrame.
views.windows.window.createResizeButton () Creates a resize button in the footer bar.
views.windows.window.createScrollbar () Creates a scrollbar to the window's content area.
views.windows.window.createTitleBar () Creates a title bar that contains a title and a close button.
views.windows.window.createTitleText () Creates the title text in the title bar.
views.windows.window.getProperty (key) Gets a window property using the library configuration instance.
views.windows.window.getPropertyKey (key) Gets the property key used by the window instance to persist its state using the library configuration instance.
views.windows.window.hide () Hides the window.
views.windows.window.positionPages () Positions the pages inside the content frame.
views.windows.window.setProperty (key, any) Sets a window property using the library configuration instance.
views.windows.window.setWindowPositionOnCreation () Sets the window position on creation.
views.windows.window.setWindowSizeOnCreation () Sets the window size on creation.
views.windows.window.setWindowVisibilityOnCreation () Sets the window visibility on creation.
views.windows.window.show () Shows the window.
views.windows.window.storeWindowPoint () Stores the window's point in the configuration instance if the window is persisting its state.
views.windows.window.storeWindowSize () Stores the window's size in the configuration instance if the window is persisting its state.

Methods

views.windows.window:addPage (windowPage) Adds a page to the window.
views.windows.window:config (...) Decides whether this window instance should proxy to the player's or the global configuration instance.
views.windows.window:create () Creates the window frame if it doesn't exist yet.
views.windows.window:getWindow () Gets the window's frame instance.
views.windows.window:isPersistingState () Determines if the window is persisting its state.
views.windows.window:setActivePage (pageId) Sets the active page in the Window.
views.windows.window:setFirstPosition (position) Sets the window's first position.
views.windows.window:setFirstSize (size) Sets the window's first size.
views.windows.window:setFirstVisibility (visibility) Sets the window's first visibility.
views.windows.window:setPersistStateByPlayer (value) Sets the window instance to have its stated persisted in the player's configuration instead of the global one.
views.windows.window:setTitle (string) Sets the window title.
views.windows.window:setVisibility (visible) Sets the window visibility.
views.windows.window:toggleVisibility () Toggles the window visibility.

Metamethods

views.windows.window:__construct (string) Window constructor.


Local Functions

Methods
views.windows.window.createCloseButton ()
Creates a close button in the title bar.

This method shouldn't be called directly. It's considered a complement to the createTitleBar() method.

Returns:

    table The button created by CreateFrame
views.windows.window.createContentFrame ()
Creates the content frame, where the window's content will be placed.

This method shouldn't be called directly. It's considered a complement to the create() method.

Returns:

    table The content frame created by CreateFrame
views.windows.window.createFooter ()
Creates a footer bar that contains a resize button.

This method shouldn't be called directly. It's considered a complement to the create() method.

Returns:

    table The footer bar frame created by CreateFrame
views.windows.window.createFrame ()
This is just a facade method to call World of Warcraft's CreateFrame.

Returns:

    table The window frame created by CreateFrame

See also:

views.windows.window.createResizeButton ()
Creates a resize button in the footer bar.

This method shouldn't be called directly. It's considered a complement to the createFooter() method.

Returns:

    table The button created by CreateFrame
views.windows.window.createScrollbar ()
Creates a scrollbar to the window's content area.

This method shouldn't be called directly. It's considered a complement to the create() method.

Returns:

    table The scrollbar frame created by CreateFrame
views.windows.window.createTitleBar ()
Creates a title bar that contains a title and a close button.

This method shouldn't be called directly. It's considered a complement to the create() method.

Returns:

    table The title bar frame created by CreateFrame
views.windows.window.createTitleText ()
Creates the title text in the title bar.

This method shouldn't be called directly. It's considered a complement to the createTitleBar() method.

Returns:

    table The title text frame created by CreateFrame
views.windows.window.getProperty (key)
Gets a window property using the library configuration instance.

This method is used internally by the library to persist the window's state. It's not meant to be called by addons.

Parameters:

Returns:

    any The property value
views.windows.window.getPropertyKey (key)
Gets the property key used by the window instance to persist its state using the library configuration instance.

A property key is a result of the concatenation of a static prefix, this window's id, and the key parameter.

This method is used internally by the library to persist the window's state. It's not meant to be called by addons.

Parameters:

Returns:

    string The property key used by the window instance to persist its state using the library configuration instance
views.windows.window.hide ()
Hides the window.

This is just a facade method to call Hide() on the window frame. However, it shouldn't be used by addons as an internal method. Use setVisibility(false) instead.

See also:

views.windows.window.positionPages ()
Positions the pages inside the content frame.

This is an internal method and it shouldn't be called by addons.

views.windows.window.setProperty (key, any)
Sets a window property using the library configuration instance.

This method is used internally by the library to persist the window's state. It's not meant to be called by addons.

Parameters:

  • key string The property key
  • any value The property value
views.windows.window.setWindowPositionOnCreation ()
Sets the window position on creation.

This method is called when the window is created, and it sets the window position to the first position set by the developer or the persisted position if it's found.

This method shouldn't be called directly. It's considered a complement to the create() method.

views.windows.window.setWindowSizeOnCreation ()
Sets the window size on creation.

This method is called when the window is created, and it sets the window size to the first size set by the developer or the persisted size if it's found.

This method shouldn't be called directly. It's considered a complement to the create() method.

views.windows.window.setWindowVisibilityOnCreation ()
Sets the window visibility on creation.

This method is called when the window is created, and it sets the window visibility to the first state set by the developer or the persisted state if it's found.

This method shouldn't be called directly. It's considered a complement to the create() method.

views.windows.window.show ()
Shows the window.

This is just a facade method to call Show() on the window frame. However, it shouldn't be used by addons as an internal method. Use setVisibility(true) instead.

See also:

views.windows.window.storeWindowPoint ()
Stores the window's point in the configuration instance if the window is persisting its state.

This method is used internally by the library to persist the window's state. It's not meant to be called by addons.

views.windows.window.storeWindowSize ()
Stores the window's size in the configuration instance if the window is persisting its state.

This method is used internally by the library to persist the window's state. It's not meant to be called by addons.

Methods

views.windows.window:addPage (windowPage)
Adds a page to the window.

Parameters:

Returns:

    Views.Windows.Window The window instance, for method chaining
views.windows.window:config (...)
Decides whether this window instance should proxy to the player's or the global configuration instance.

By default, the window will proxy to the global configuration instance.

Parameters:

  • ...
views.windows.window:create ()
Creates the window frame if it doesn't exist yet.

Returns:

    Views.Windows.Window The window instance, for method chaining
views.windows.window:getWindow ()
Gets the window's frame instance.

This method has effect only after Window:create() is called.

Returns:

    table The window frame instance
views.windows.window:isPersistingState ()
Determines if the window is persisting its state.

A window is considered to be persisting its state if it has an id and the library is created with a configuration set.

Returns:

    boolean true if the window is persisting its state, false otherwise
views.windows.window:setActivePage (pageId)
Sets the active page in the Window.

This method basically hides all pages and shows the one with the given page id and adjusts the content frame height to the current page height.

Parameters:

  • pageId
views.windows.window:setFirstPosition (position)
Sets the window's first position.

The first position is the position that the window will have when it's first created. If the player moves the window and this window is persisting its state, this property will be ignored.

Because this class represents a window that's not tied to any specific frame, the relativeTo parameter will be omitted. The window will always be created with a nil relativeTo parameter.

Parameters:

  • position table The position table, with the keys point, relativePoint, xOfs, and yOfs

Returns:

    Views.Windows.Window The window instance, for method chaining

Usage:

    window:setFirstSize({point = 'CENTER', relativePoint = 'CENTER', xOfs = 0, yOfs = 0})
views.windows.window:setFirstSize (size)
Sets the window's first size.

The first size is the size that the window will have when it's first created. If the player resizes the window and this window is persisting its state, this property will be ignored.

Parameters:

  • size table The size table, with the keys width and height

Returns:

    Views.Windows.Window The window instance, for method chaining

Usage:

    window:setFirstSize({width = 200, height = 100})
views.windows.window:setFirstVisibility (visibility)
Sets the window's first visibility.

The first visibility is the visibility that the window will have when it's first created. If the player hides the window and this window is persisting its state, this property will be ignored.

Parameters:

  • visibility boolean The first visibility state

Returns:

    Views.Windows.Window The window instance, for method chaining

Usage:

    window:setFirstVisibility(false)
views.windows.window:setPersistStateByPlayer (value)
Sets the window instance to have its stated persisted in the player's configuration instead of the global one.

Parameters:

  • value boolean Whether the window should persist its state by player

Returns:

    Views.Windows.Window The window instance, for method chaining
views.windows.window:setTitle (string)
Sets the window title.

The window title will be displayed in the title bar, the same one that users can click and drag to move the window.

Parameters:

  • string title The window title

Returns:

    Views.Windows.Window The window instance, for method chaining

Usage:

    window:setTitle('My Window Title')
views.windows.window:setVisibility (visible)
Sets the window visibility.

This is the method to be called by addons to show or hide the window, instead of the local show() and hide(), considering that it not only controls the window visibility but also persists the state if the window is persisting its state.

Parameters:

  • visible boolean The visibility state

Returns:

    Views.Windows.Window The window instance, for method chaining
views.windows.window:toggleVisibility ()
Toggles the window visibility.

If the window is visible, it will be hidden. If it's hidden, it will be shown.

Returns:

    Views.Windows.Window The window instance, for method chaining

Metamethods

views.windows.window:__construct (string)
Window constructor.

When built with an id and the library is created with the data property, the window will be capable to persist its position, size, and other user preferences.

Parameters:

  • string id The window identifier, which is used mostly to persist information about the window, like its position and size
generated by LDoc 1.5.0 Last updated 2024-09-11 16:27:53