Antkeeper  0.0.1
display.hpp
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2023 Christopher J. Howard
3  *
4  * This file is part of Antkeeper source code.
5  *
6  * Antkeeper source code is free software: you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation, either version 3 of the License, or
9  * (at your option) any later version.
10  *
11  * Antkeeper source code is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with Antkeeper source code. If not, see <http://www.gnu.org/licenses/>.
18  */
19 
20 #ifndef ANTKEEPER_APP_DISPLAY_HPP
21 #define ANTKEEPER_APP_DISPLAY_HPP
22 
27 #include <string>
28 
29 namespace app {
30 
34 class display
35 {
36 public:
42  inline void set_index(int index) noexcept
43  {
44  m_index = index;
45  }
46 
52  inline void set_name(const std::string& name) noexcept
53  {
54  m_name = name;
55  }
56 
62  inline void set_bounds(const geom::rectangle<int>& bounds) noexcept
63  {
64  m_bounds = bounds;
65  }
66 
70  inline void set_usable_bounds(const geom::rectangle<int>& bounds) noexcept
71  {
72  m_usable_bounds = bounds;
73  }
74 
80  inline void set_refresh_rate(int rate) noexcept
81  {
82  m_refresh_rate = rate;
83  }
84 
90  inline void set_dpi(float dpi) noexcept
91  {
92  m_dpi = dpi;
93  }
94 
100  inline void set_orientation(display_orientation orientation) noexcept
101  {
102  m_orientation = orientation;
103  }
104 
106  [[nodiscard]] inline const int& get_index() const noexcept
107  {
108  return m_index;
109  }
110 
112  [[nodiscard]] inline const std::string& get_name() const noexcept
113  {
114  return m_name;
115  }
116 
118  [[nodiscard]] inline const geom::rectangle<int>& get_bounds() const noexcept
119  {
120  return m_bounds;
121  }
122 
124  [[nodiscard]] inline const geom::rectangle<int>& get_usable_bounds() const noexcept
125  {
126  return m_usable_bounds;
127  }
128 
130  [[nodiscard]] inline const int& get_refresh_rate() const noexcept
131  {
132  return m_refresh_rate;
133  }
134 
136  [[nodiscard]] inline const float& get_dpi() const noexcept
137  {
138  return m_dpi;
139  }
140 
142  [[nodiscard]] inline const display_orientation& get_orientation() const noexcept
143  {
144  return m_orientation;
145  }
146 
148  [[nodiscard]] inline const bool& is_connected() const noexcept
149  {
150  return m_connected;
151  }
152 
155  {
156  return m_connected_publisher.channel();
157  }
158 
161  {
162  return m_disconnected_publisher.channel();
163  }
164 
167  {
168  return m_orientation_changed_publisher.channel();
169  }
170 
171 private:
172  friend class window_manager;
173  friend class sdl_window_manager;
174 
175  int m_index{0};
176  std::string m_name;
177  geom::rectangle<int> m_bounds{0};
178  geom::rectangle<int> m_usable_bounds{0};
179  int m_refresh_rate{0};
180  float m_dpi{0.0f};
181  display_orientation m_orientation{0};
182  bool m_connected{false};
183 
184  event::publisher<display_connected_event> m_connected_publisher;
185  event::publisher<display_disconnected_event> m_disconnected_publisher;
186  event::publisher<display_orientation_changed_event> m_orientation_changed_publisher;
187 };
188 
189 } // namespace app
190 
191 #endif // ANTKEEPER_APP_DISPLAY_HPP
Virtual display.
Definition: display.hpp:35
const bool & is_connected() const noexcept
Returns true if the display is connected, false otherwise.
Definition: display.hpp:148
const geom::rectangle< int > & get_bounds() const noexcept
Returns the bounds of the display, in display units.
Definition: display.hpp:118
const std::string & get_name() const noexcept
Returns the name of the display.
Definition: display.hpp:112
void set_bounds(const geom::rectangle< int > &bounds) noexcept
Sets the bounds of the display.
Definition: display.hpp:62
const geom::rectangle< int > & get_usable_bounds() const noexcept
Returns the usable bounds of the display, which excludes areas reserved by the OS for things like men...
Definition: display.hpp:124
event::channel< display_orientation_changed_event > & get_orientation_changed_channel() noexcept
Returns the channel through which display orientation changed events are published.
Definition: display.hpp:166
const int & get_refresh_rate() const noexcept
Returns the refresh rate of the display, in Hz.
Definition: display.hpp:130
const display_orientation & get_orientation() const noexcept
Returns the current orientation of the display.
Definition: display.hpp:142
void set_orientation(display_orientation orientation) noexcept
Sets the orientation of the display.
Definition: display.hpp:100
event::channel< display_disconnected_event > & get_disconnected_channel() noexcept
Returns the channel through which display disconnected events are published.
Definition: display.hpp:160
void set_usable_bounds(const geom::rectangle< int > &bounds) noexcept
Sets the usable bounds of the display, which excludes areas reserved by the OS for things like menus ...
Definition: display.hpp:70
void set_index(int index) noexcept
Sets the index of the display.
Definition: display.hpp:42
void set_dpi(float dpi) noexcept
Sets the DPI of the display.
Definition: display.hpp:90
void set_refresh_rate(int rate) noexcept
Sets the refresh rate of the display.
Definition: display.hpp:80
const float & get_dpi() const noexcept
Returns the DPI of the display.
Definition: display.hpp:136
void set_name(const std::string &name) noexcept
Sets the name of the display.
Definition: display.hpp:52
const int & get_index() const noexcept
Returns the index of the display.
Definition: display.hpp:106
event::channel< display_connected_event > & get_connected_channel() noexcept
Returns the channel through which display connected events are published.
Definition: display.hpp:154
Channel through which messages are published.
Definition: channel.hpp:44
Publishes messages to subscribers.
Definition: publisher.hpp:36
display_orientation
Display orientations.
n-dimensional axis-aligned rectangle.