Cogs.Core
Monitor.h
1#pragma once
2
3#if defined( _WIN32 )
4 #include <WinSock2.h>
5 #undef GetObject
6#endif
7
8#include "../FoundationBase.h"
9
10#include <glm/vec2.hpp>
11
12#include <string>
13#include <vector>
14
15namespace Cogs {
19 class COGSFOUNDATION_API Monitor {
20 public:
21 Monitor() = default;
22 Monitor(const glm::ivec2& position, const glm::ivec2& size);
23 Monitor(const Monitor&) = default;
24 Monitor(Monitor&&) = default;
25
26 static void enumerate();
27 static size_t getCount();
28 static const Monitor& get(size_t idx);
29 static const Monitor* findByName(const std::string& name);
30 static const Monitor* findFromPoint(const glm::ivec2& point);
31 static const Monitor* findFromRect(const glm::ivec2& tl, const glm::ivec2& br);
32
33 void* getIdentifier() const { return identifier; }
34 const std::string& getName() const { return name; }
35 const glm::ivec2& getPosition() const { return position; }
36 const glm::ivec2& getSize() const { return size; }
37 glm::ivec2 getCentre() const { return position + (size / 2); }
38
39 private:
40 using List = std::vector<Monitor>;
41
42 static List monitors;
43 void* identifier = nullptr;
44 std::string name;
45 glm::ivec2 position;
46 glm::ivec2 size;
47 bool primary = false;
48
49#if defined( _WIN32 )
50 static BOOL callback(HMONITOR monitor, HDC, RECT* coords, LPARAM);
51#endif
52 };
53}
Helper class for enumerating available displays on the host computer.
Definition: Monitor.h:19
glm::ivec2 size
Size of this monitor in desktop coordinates.
Definition: Monitor.h:46
glm::ivec2 position
Position of this monitor in desktop coordinates.
Definition: Monitor.h:45
std::string name
User-friendly name for this monitor.
Definition: Monitor.h:44
Contains all Cogs related functionality.
Definition: FieldSetter.h:23