VR-Engage  2.2
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 every frame to update the component state
85 //! \param dt Delta time since the last frame in seconds
86 //!
87 //! On the first tick, applies the configured window geometry settings
88 //! to the main application window
89 virtual void tick(double dt) override;
90
91 //! \brief Shuts down the window layout component
92 //!
93 //! Restores the original window geometry that was cached during initialization
94 //! and removes the state change callback
95 virtual void shutdown() override;
96
97 //! \brief Returns the type identifier for this component
98 //! \return The type string for DtWindowLayoutComponent
99 virtual const char* type() const override;
100
101protected:
102 //! \brief Handler for application state changes
103 //! \param state The new application state name
104 //!
105 //! Applies configured window geometry when entering ENGAGED_STATE and
106 //! restores the cached geometry when entering MENU_STATE
107 virtual void onCurrentStateChanged(std::string state);
108
109protected:
110 //! \brief Configured window height in pixels
112
113 //! \brief Configured window width in pixels
115
116 //! \brief Configured window X position in screen coordinates
118
119 //! \brief Configured window Y position in screen coordinates
121
122 //! \brief Original window geometry cached during initialization
124
125 //! \brief Flag indicating if this is the first tick
127
128 //! \brief Pointer to the main application window
129 QMainWindow* myMainWindow;
130};
131
132} // 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
bool myFirstTick
Flag indicating if this is the first tick.
Definition windowLayoutComponent.h:126
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:117
int myPositionY
Configured window Y position in screen coordinates.
Definition windowLayoutComponent.h:120
QRect myCachedGeometry
Original window geometry cached during initialization.
Definition windowLayoutComponent.h:123
virtual void shutdown() override
Shuts down the window layout component.
int myHeight
Configured window height in pixels.
Definition windowLayoutComponent.h:111
virtual void tick(double dt) override
Called every frame to update the component state.
QMainWindow * myMainWindow
Pointer to the main application window.
Definition windowLayoutComponent.h:129
int myWidth
Configured window width in pixels.
Definition windowLayoutComponent.h:114
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
Include export definitions for this library.
Definition glsVreMessageUtil.h:49
constexpr const char * DtWindowLayoutComponentType
Type identifier for DtWindowLayoutComponent component.
Definition windowLayoutComponent.h:55
Definition appLauncherComponent.h:28
Defines the DtPlayerComponent base class for VR-Engage role components.