NAP
display.h
1 /* This Source Code Form is subject to the terms of the Mozilla Public
2  * License, v. 2.0. If a copy of the MPL was not distributed with this
3  * file, You can obtain one at https://mozilla.org/MPL/2.0/. */
4 
5 #pragma once
6 
7 // External includes
8 #include <string>
9 #include <rect.h>
10 #include <utility/dllexport.h>
11 #include <nap/numeric.h>
12 
13 // Forward declares
14 struct SDL_Window;
15 
16 namespace nap
17 {
24  class NAPAPI Display final
25  {
26  public:
30  enum class EOrientation : int8
31  {
32  Unknown = 0,
33  Landscape = 1,
34  LandscapeFlipped = 2,
35  Portrait = 3,
36  PortraitFlipped = 4
37  };
38 
42  Display() = default;
43 
48  Display(int index);
49 
54  bool isValid() const { return mValid; }
55 
62  int getIndex() const { return mIndex; }
63 
68  const std::string& getName() const { return mName; }
69 
73  const glm::ivec2& getMin() const { return mMin; }
74 
78  const glm::ivec2& getMax() const { return mMax; }
79 
83  math::Rect getBounds() const { return { glm::vec2(mMin), glm::vec2(mMax) }; }
84 
93  float getContentScale() const { return mScale; }
94 
99  float getDPI() const { return mDPI; }
100 
104  EOrientation getOrientation() const { return mOrientation; }
105 
110  [[deprecated]]
111  float getDiagonalDPI() const { return mDPI; }
112 
117  [[deprecated]]
118  float getHorizontalDPI() const { return mDPI; }
119 
124  [[deprecated]]
125  float getVerticalDPI() const { return mDPI; }
126 
130  std::string toString() const;
131 
135  bool operator== (const Display& rhs) const { return rhs.getIndex() == this->getIndex(); }
136 
140  bool operator!=(const Display& rhs) const { return !(rhs == *this); }
141 
142  private:
143  std::string mName;
144  int mIndex = -1;
145  float mDPI = 96.0f;
146  float mScale = 1.0f;
147  glm::ivec2 mMin = { 0, 0 };
148  glm::ivec2 mMax = { 0, 0 };
149  EOrientation mOrientation;
150  bool mValid = false;
151  };
152 }
153 
154 
nap::toString
NAPAPI std::string toString(EDay day)
nap::Display::getName
const std::string & getName() const
Definition: display.h:68
nap::EDay::Unknown
@ Unknown
Unknown.
nap::math::Rect
Definition: rect.h:19
nap::Display::operator!=
bool operator!=(const Display &rhs) const
Definition: display.h:140
nap::Display
Definition: display.h:24
nap::int8
int8_t int8
Definition: numeric.h:15
nap::Display::getOrientation
EOrientation getOrientation() const
Definition: display.h:104
nap::Display::getHorizontalDPI
float getHorizontalDPI() const
Definition: display.h:118
nap::Display::getDPI
float getDPI() const
Definition: display.h:99
nap::Display::getVerticalDPI
float getVerticalDPI() const
Definition: display.h:125
nap::Display::getMax
const glm::ivec2 & getMax() const
Definition: display.h:78
nap::Display::EOrientation
EOrientation
Definition: display.h:30
nap::Display::isValid
bool isValid() const
Definition: display.h:54
nap
Definition: templateapp.h:17
nap::Display::getIndex
int getIndex() const
Definition: display.h:62
nap::Display::getMin
const glm::ivec2 & getMin() const
Definition: display.h:73
nap::Display::getBounds
math::Rect getBounds() const
Definition: display.h:83
nap::Display::getContentScale
float getContentScale() const
Definition: display.h:93
nap::Display::getDiagonalDPI
float getDiagonalDPI() const
Definition: display.h:111