Skip to content

WindowManager

Application window manager. More...

#include "GUI/WindowManager.h"

Public Functions

Name
WindowManager() =default
voidaddWindow(Ptr< IWindow > window)<br>Add a dockable window.
voidclear()<br>Remove all managed windows.
voiddraw()<br>Draw all managed windows.
voidfocusWindow(IWindow * window)
voidfocusWindow(Ptr< IWindow > window)
Ptr< IWindow >getCurrentWindow()<br>Returns the last window that started being constructed (eg.
Ptr< IWindow >getFocusedWindow()
template <typename T &gt; <br>Ptr< T >getWindowPtr()<br>Find a dockable window of type T and return a shared pointer to it.
boolhasWindow(const std::string & id)
template <typename T &gt; <br>boolisFocused()
template <typename TStrategy &gt; <br>voidopenConfirmModal()
template <typename T &gt; <br>voidopenModal()
voidopenModal(UPtr< IWindow > modalInstance)
voidremoveWindow(const std::string & windowId)<br>Hide and remove window.
template <typename T &gt; <br>voidshowUniqueWindow()<br>Create and show desired window.
voidshowWindow(IWindow * window, bool show)
voidshowWindow(Ptr< IWindow > window, bool show)
voidupdateFocus()<br>Handles automatic window focus change.
glm::vec2getMousePositionForWindow(const IWindow * window)<br>Returns relative mouse position for a specified window.

Friends

Name
classIWindow

Detailed Description

cpp
class WindowManager;
class WindowManager;

Application window manager.

Handles window lifetime, visibility, focus and drawing. As well as some utility methods. Also holds a reference to the last drawn window (See below).

Each window should call its IWindow::updateWindowInfo() method after its ImGui::Begin() call. This method updates its window dimension/position information and marks itself as the current window of its assigned WindowManager. With access to window manager any code can retrieve window information without an explicit reference to the window being constructed.

Public Functions Documentation

function WindowManager

cpp
WindowManager() =default
WindowManager() =default

function addWindow

cpp
void addWindow(
    Ptr< IWindow > window
)
void addWindow(
    Ptr< IWindow > window
)

Add a dockable window.

function clear

cpp
void clear()
void clear()

Remove all managed windows.

function draw

cpp
void draw()
void draw()

Draw all managed windows.

function focusWindow

cpp
void focusWindow(
    IWindow * window
)
void focusWindow(
    IWindow * window
)

function focusWindow

cpp
void focusWindow(
    Ptr< IWindow > window
)
void focusWindow(
    Ptr< IWindow > window
)

function getCurrentWindow

cpp
inline Ptr< IWindow > getCurrentWindow()
inline Ptr< IWindow > getCurrentWindow()

Returns the last window that started being constructed (eg.

the last window that called IWindow::updateWindowInfo() after its ImGui::Begin() call).

function getFocusedWindow

cpp
inline Ptr< IWindow > getFocusedWindow()
inline Ptr< IWindow > getFocusedWindow()

function getWindowPtr

cpp
template <typename T >
inline Ptr< T > getWindowPtr()
template <typename T >
inline Ptr< T > getWindowPtr()

Find a dockable window of type T and return a shared pointer to it.

Template Parameters:

  • T

Return:

function hasWindow

cpp
bool hasWindow(
    const std::string & id
)
bool hasWindow(
    const std::string & id
)

function isFocused

cpp
template <typename T >
inline bool isFocused()
template <typename T >
inline bool isFocused()

function openConfirmModal

cpp
template <typename TStrategy >
inline void openConfirmModal()
template <typename TStrategy >
inline void openConfirmModal()

function openModal

cpp
template <typename T >
void openModal()
template <typename T >
void openModal()

function openModal

cpp
void openModal(
    UPtr< IWindow > modalInstance
)
void openModal(
    UPtr< IWindow > modalInstance
)

function removeWindow

cpp
void removeWindow(
    const std::string & windowId
)
void removeWindow(
    const std::string & windowId
)

Hide and remove window.

Parameters:

  • windowId identification of window to hide.

Called by HideWindowCommand.

function showUniqueWindow

cpp
template <typename T >
inline void showUniqueWindow()
template <typename T >
inline void showUniqueWindow()

Create and show desired window.

Template Parameters:

  • T window to create. T must be derived from IWindow class.

function showWindow

cpp
void showWindow(
    IWindow * window,
    bool show
)
void showWindow(
    IWindow * window,
    bool show
)

function showWindow

cpp
void showWindow(
    Ptr< IWindow > window,
    bool show
)
void showWindow(
    Ptr< IWindow > window,
    bool show
)

function updateFocus

cpp
void updateFocus()
void updateFocus()

Handles automatic window focus change.

function getMousePositionForWindow

cpp
static glm::vec2 getMousePositionForWindow(
    const IWindow * window
)
static glm::vec2 getMousePositionForWindow(
    const IWindow * window
)

Returns relative mouse position for a specified window.

This is a utility method to fetch current mouse position from InputManager and then make that position relative to the specified window.

Friends

friend IWindow

cpp
friend class IWindow(
    IWindow 
);
friend class IWindow(
    IWindow 
);

Updated on 2024-03-16 at 19:15:00 +0000