Divide Framework 0.1
A free and open-source 3D Framework under heavy development
Loading...
Searching...
No Matches
DisplayWindow.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#pragma once
33#ifndef DVD_DISPLAY_WINDOW_INL_
34#define DVD_DISPLAY_WINDOW_INL_
35
37
38namespace Divide {
39
40 inline SDL_Window* DisplayWindow::getRawWindow() const noexcept
41 {
42 return _sdlWindow;
43 }
44
45 inline bool DisplayWindow::fullscreen() const noexcept
46 {
47 return type() == WindowType::FULLSCREEN ||
49 }
50
51 inline void DisplayWindow::setPosition(const vec2<I32> position, const bool global)
52 {
53 setPosition(position.x, position.y, global);
54 }
55
56 inline bool DisplayWindow::isHovered() const noexcept
57 {
58 return _flags & to_base(WindowFlags::IS_HOVERED);
59 }
60
61 inline bool DisplayWindow::hasFocus() const noexcept
62 {
63 return _flags & to_base(WindowFlags::HAS_FOCUS);
64 }
65
66 inline U8 DisplayWindow::prevOpacity() const noexcept
67 {
68 return _prevOpacity;
69 }
70
71 inline bool DisplayWindow::minimized() const noexcept
72 {
73 return _flags & to_base(WindowFlags::MINIMIZED);
74 }
75
76 inline bool DisplayWindow::maximized() const noexcept
77 {
78 return _flags & to_base(WindowFlags::MAXIMIZED);
79 }
80
81 inline bool DisplayWindow::decorated() const noexcept
82 {
83 return _flags & to_base(WindowFlags::DECORATED);
84 }
85
86 inline bool DisplayWindow::hidden() const noexcept
87 {
88 return _flags & to_base(WindowFlags::HIDDEN);
89 }
90
91 inline void DisplayWindow::changeType(const WindowType newType)
92 {
94 }
95
97 {
99 }
100
101 inline const char* DisplayWindow::title() const noexcept
102 {
103 return SDL_GetWindowTitle(_sdlWindow);
104 }
105
106 inline void DisplayWindow::addEventListener(const WindowEvent windowEvent, const EventListener& listener)
107 {
108 _eventListeners[to_base(windowEvent)].push_back(listener);
109 }
110
111 inline void DisplayWindow::clearEventListeners(const WindowEvent windowEvent)
112 {
113 _eventListeners[to_base(windowEvent)].clear();
114 }
115
116 inline void DisplayWindow::destroyCbk(const DELEGATE<void>& destroyCbk)
117 {
119 }
120
122 {
123 const vec2<U16> dim = getDimensions();
124 return Rect<I32>(0, 0, to_I32(dim.width), to_I32(dim.height));
125 }
126
127 inline const Rect<I32>& DisplayWindow::renderingViewport() const noexcept
128 {
129 return _renderingViewport;
130 }
131
132 template<typename... Args>
133 void DisplayWindow::title(const char* format, Args&& ...args) noexcept
134 {
135 if constexpr(sizeof...(Args) > 0)
136 {
137 SDL_SetWindowTitle( _sdlWindow, Util::StringFormat<string>( format, static_cast<Args&&>(args)... ).c_str());
138 }
139 else
140 {
141 SDL_SetWindowTitle( _sdlWindow, format);
142 }
143 }
144}; //namespace Divide
145
146#endif //DVD_DISPLAY_WINDOW_INL_
SDL_Window SDL_Window
Definition: DisplayWindow.h:42
bool hasFocus() const noexcept
void handleChangeWindowType(WindowType newWindowType)
bool hidden() const noexcept
bool maximized() const noexcept
bool minimized() const noexcept
SDL_Window * _sdlWindow
Rect< I32 > windowViewport() const noexcept
void clearEventListeners(WindowEvent windowEvent)
std::array< EventListeners, to_base(WindowEvent::COUNT)> _eventListeners
const Rect< I32 > & renderingViewport() const noexcept
bool isHovered() const noexcept
bool decorated() const noexcept
Rect< I32 > _renderingViewport
void setPosition(I32 x, I32 y, bool global=false, bool offset=false)
Window positioning is handled by SDL.
DELEGATE< void > _destroyCbk
bool fullscreen() const noexcept
const char * title() const noexcept
void destroyCbk(const DELEGATE< void > &destroyCbk)
U8 prevOpacity() const noexcept
vec2< U16 > getDimensions() const noexcept
SDL_Window * getRawWindow() const noexcept
void changeType(WindowType newType)
DELEGATE< bool, const WindowEventArgs & > EventListener
void addEventListener(WindowEvent windowEvent, const EventListener &listener)
Handle console commands that start with a forward slash.
Definition: AIProcessor.cpp:7
DELEGATE_STD< Ret, Args... > DELEGATE
uint8_t U8
constexpr I32 to_I32(const T value)
constexpr auto to_base(const Type value) -> Type