VR-Engage  2.3
Loading...
Searching...
No Matches
windowLayoutComponent.h
Go to the documentation of this file.
1/******************************************************************************
2** Copyright (c) 2025 MAK Technologies
3** All rights reserved.
4******************************************************************************/
5
6//! \file windowLayoutComponent.h
7//! \brief Component that modifies the application window geometry for specific roles
8//! \ingroup vreCommonComponents
9
10#pragma once
11
14
15#include <QRect>
16
17#include <string>
18
19namespace makVrv
20{
21class DtDe;
22}
23
24class QMainWindow;
25
26namespace makVre
27{
28class DtInitTable;
29class DtPlayerStation;
30
32{
33//! \ingroup RoleConfigParams
34//! \defgroup WindowLayoutComponentRoleParams Window Layout Component Role Parameters
35//! \roleInherits{PlayerComponentRoleParams}
36//! Configuration Options for window layout component role.
37//! @{
38
39//! \vreRoleParam{height,int,768,windowLayoutComponent,Height of the application window in pixels when this role is active.}
40constexpr const char* height = "height";
41
42//! \vreRoleParam{positionX,int,100,windowLayoutComponent,Horizontal position of the application window in pixels from the left edge of the screen.}
43constexpr const char* positionX = "positionX";
44
45//! \vreRoleParam{positionY,int,300,windowLayoutComponent,Vertical position of the application window in pixels from the top edge of the screen.}
46constexpr const char* positionY = "positionY";
47
48//! \vreRoleParam{width,int,1024,windowLayoutComponent,Width of the application window in pixels when this role is active.}
49constexpr const char* width = "width";
50
51//! @}
52} // namespace WindowLayoutComponentConfig
53
54//! \brief Type identifier for DtWindowLayoutComponent component
55constexpr const char* DtWindowLayoutComponentType = "DtWindowLayoutComponent";
56
57//! \brief Component that modifies and restores main window geometry for specific roles
58//!
59//! DtWindowLayoutComponent changes the size and position of the main application window
60//! when a player engages in a role that includes this component, and restores the
61//! original window geometry when the player leaves the role. This allows different
62//! roles to have customized window layouts optimized for their specific needs.
64{
65public:
66 //! \brief Constructor for DtWindowLayoutComponent
67 //!
68 //! Initializes the component with default settings
70
71 //! \brief Virtual destructor for DtWindowLayoutComponent
72 virtual ~DtWindowLayoutComponent() override;
73
74 //! \brief Initializes the window layout component
75 //! \param station Pointer to the player station this component belongs to
76 //! \param config Configuration table containing window geometry settings
77 //! \return True if initialization succeeded, false otherwise
78 //!
79 //! Reads window geometry parameters from the configuration, including width, height,
80 //! and position coordinates. Caches the current main window geometry to allow
81 //! restoration when leaving the role or shutting down the component.
82 virtual bool initialize(DtPlayerStation* station, DtInitTable& config) override;
83
84 //! \brief Called after postInitialize() to apply one-time window geometry
85 //! \param dt Delta time since the last frame in seconds
86 //! \return Ready once window geometry has been applied
87 //!
88 //! Applies the configured window geometry settings to the main application
89 //! window. This runs during the LOADING_PLAYER_STATE phase before engaged tick.
90 virtual DtInitTickStatus finalizeInitTick(double dt) override;
91
92 //! \brief Called every frame to update the component state
93 //! \param dt Delta time since the last frame in seconds
94 //! This component does not require per-frame updates, so this function is a no-op.
95 virtual void tick(double dt) override {};
96
97 //! \brief Shuts down the window layout component
98 //!
99 //! Restores the original window geometry that was cached during initialization
100 //! and removes the state change callback
101 virtual void shutdown() override;
102
103 //! \brief Returns the type identifier for this component
104 //! \return The type string for DtWindowLayoutComponent
105 virtual const char* type() const override;
106
107protected:
108 //! \brief Handler for application state changes
109 //! \param state The new application state name
110 //!
111 //! Applies configured window geometry when entering ENGAGED_STATE and
112 //! restores the cached geometry when entering MENU_STATE
113 virtual void onCurrentStateChanged(std::string state);
114
115protected:
116 //! \brief Configured window height in pixels
118
119 //! \brief Configured window width in pixels
121
122 //! \brief Configured window X position in screen coordinates
124
125 //! \brief Configured window Y position in screen coordinates
127
128 //! \brief Original window geometry cached during initialization
130
131 //! \brief Pointer to the main application window
132 QMainWindow* myMainWindow;
133};
134
135} // namespace makVre
Table-based access to Lua state for configuration data.
Definition initializer.h:38
DtPlayerComponent()
Constructor.
Class for managing the user interface for engaged roles.
Definition playerStation.h:51
virtual DtInitTickStatus finalizeInitTick(double dt) override
Called after postInitialize() to apply one-time window geometry.
virtual void onCurrentStateChanged(std::string state)
Handler for application state changes.
virtual bool initialize(DtPlayerStation *station, DtInitTable &config) override
Initializes the window layout component.
int myPositionX
Configured window X position in screen coordinates.
Definition windowLayoutComponent.h:123
int myPositionY
Configured window Y position in screen coordinates.
Definition windowLayoutComponent.h:126
QRect myCachedGeometry
Original window geometry cached during initialization.
Definition windowLayoutComponent.h:129
virtual void shutdown() override
Shuts down the window layout component.
int myHeight
Configured window height in pixels.
Definition windowLayoutComponent.h:117
virtual void tick(double dt) override
Called every frame to update the component state.
Definition windowLayoutComponent.h:95
QMainWindow * myMainWindow
Pointer to the main application window.
Definition windowLayoutComponent.h:132
int myWidth
Configured window width in pixels.
Definition windowLayoutComponent.h:120
DtWindowLayoutComponent()
Constructor for DtWindowLayoutComponent.
virtual const char * type() const override
Returns the type identifier for this component.
virtual ~DtWindowLayoutComponent() override
Virtual destructor for DtWindowLayoutComponent.
constexpr const char * height
Definition windowLayoutComponent.h:40
constexpr const char * positionY
Definition windowLayoutComponent.h:46
constexpr const char * positionX
Definition windowLayoutComponent.h:43
constexpr const char * width
Definition windowLayoutComponent.h:49
Defines export/import macros for the vreCommonComponents library.
#define VRECOMMONCOMPONENTS_DLL
DLL export/import macro for the vreCommonComponents library.
Definition export.h:28
Definition windowLayoutComponent.h:32
!
Definition glsVreMessageUtil.h:50
constexpr const char * DtWindowLayoutComponentType
Type identifier for DtWindowLayoutComponent component.
Definition windowLayoutComponent.h:55
DtInitTickStatus
Status returned by DtPlayerComponent::finalizeInitTick() to indicate deferred initialization progress...
Definition playerComponent.h:80
Definition appLauncherComponent.h:28
Defines the DtPlayerComponent base class for VR-Engage role components.