Divide Framework 0.1
A free and open-source 3D Framework under heavy development
Loading...
Searching...
No Matches
WindowManager.inl
Go to the documentation of this file.
1/*
2Copyright (c) 2018 DIVIDE-Studio
3Copyright (c) 2009 Ionut Cava
4
5This file is part of DIVIDE Framework.
6
7Permission is hereby granted, free of charge, to any person obtaining a copy
8of this software
9and associated documentation files (the "Software"), to deal in the Software
10without restriction,
11including without limitation the rights to use, copy, modify, merge, publish,
12distribute, sublicense,
13and/or sell copies of the Software, and to permit persons to whom the
14Software is furnished to do so,
15subject to the following conditions:
16
17The above copyright notice and this permission notice shall be included in
18all copies or substantial portions of the Software.
19
20THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21IMPLIED,
22INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
23PARTICULAR PURPOSE AND NONINFRINGEMENT.
24IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
25DAMAGES OR OTHER LIABILITY,
26WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
27IN CONNECTION WITH THE SOFTWARE
28OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
29
30*/
31
32#ifndef DVD_CORE_WINDOW_MANAGER_INL_
33#define DVD_CORE_WINDOW_MANAGER_INL_
34
35namespace Divide {
36
38{
39 for (auto& win : _windows)
40 {
41 if (win->getGUID() == guid)
42 {
43 return *win;
44 }
45 }
46
47 return *_windows.front();
48}
49
50inline const DisplayWindow& WindowManager::getWindow(const I64 guid) const
51{
52 for (const auto& win : _windows)
53 {
54 if (win->getGUID() == guid)
55 {
56 return *win;
57 }
58 }
59
60 return *_windows.front();
61}
62
64{
65 return _activeWindows.empty() ? nullptr : _activeWindows.top();
66}
67
69{
70 _activeWindows.push(window);
71 return _activeWindows.size();
72}
73
75{
76 _activeWindows.pop();
77 return _activeWindows.size();
78}
79
81{
82 for ( auto& win : _windows)
83 {
84 if (win->hasFocus())
85 {
86 return win.get();
87 }
88 }
89
90 return nullptr;
91}
92
93inline const DisplayWindow* WindowManager::getFocusedWindow() const noexcept
94{
95 for (const auto& win : _windows)
96 {
97 if (win->hasFocus())
98 {
99 return win.get();
100 }
101 }
102
103 return nullptr;
104}
105
107{
108 for ( auto& win : _windows)
109 {
110 if (win->isHovered())
111 {
112 return win.get();
113 }
114 }
115
116 return nullptr;
117}
118
119inline const DisplayWindow* WindowManager::getHoveredWindow() const noexcept
120{
121 for (const auto& win : _windows)
122 {
123 if (win->isHovered())
124 {
125 return win.get();
126 }
127 }
128
129 return nullptr;
130}
131
133{
134 assert(index < to_U32(_windows.size()));
135 return *_windows[index];
136}
137
138inline const DisplayWindow& WindowManager::getWindow(const U32 index) const
139{
140 assert(index < to_U32(_windows.size()));
141 return *_windows[index];
142}
143
145{
146 for ( auto& win : _windows)
147 {
148 if (win->windowID() == ID)
149 {
150 return win.get();
151 }
152 }
153
154 return nullptr;
155}
156
157const DisplayWindow* WindowManager::getWindowByID(const U32 ID) const noexcept
158{
159 for (const auto& win : _windows)
160 {
161 if (win->windowID() == ID)
162 {
163 return win.get();
164 }
165 }
166
167 return nullptr;
168}
169
171{
172 return _monitors;
173}
174
175} //namespace Divide
176
177#endif //DVD_CORE_WINDOW_MANAGER_INL_
DisplayWindow * activeWindow() const noexcept
DisplayWindow * getFocusedWindow() noexcept
vector< std::unique_ptr< DisplayWindow > > _windows
vector< MonitorData > _monitors
size_t pushActiveWindow(DisplayWindow *window)
Returns the total number of active windows after the push.
DisplayWindow * getWindowByID(U32 ID) noexcept
const vector< MonitorData > & monitorData() const noexcept
eastl::stack< DisplayWindow * > _activeWindows
size_t popActiveWindow()
Returns the remaining number of windows after the pop.
DisplayWindow * getHoveredWindow() noexcept
DisplayWindow & getWindow(I64 guid)
Handle console commands that start with a forward slash.
Definition: AIProcessor.cpp:7
constexpr U32 to_U32(const T value)
eastl::vector< Type > vector
Definition: Vector.h:42
int64_t I64
uint32_t U32