-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwindow_mini.hpp
121 lines (105 loc) · 2.22 KB
/
window_mini.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
#pragma once
extern "C"
{
#include "window_mini.h"
}
class WMWindow
{
public:
WMWindow() = default;
~WMWindow();
// NOTE: conditions == 0 deduce conditions from what has changed
bool edit(int conditions = EWMEditWindowIf_Always);
bool close();
// struct wm_source_t..
int minWidthInPixels;
int minHeightInPixels;
int maxWidthInPixels;
int maxHeightInPixels;
int widthInPixels;
int heightInPixels;
char* title;
private:
int bNotFullscreen;
public:
// NOTE: sizeof(bool) not guaranteed to be == sizeof(int)
bool bFullscreen;
// struct wm_info_about_window_t..
#if defined(__WIN32)
struct
{
struct
{
HWND a;
} hwnd;
struct
{
HINSTANCE a;
} hinstance;
} win32;
#else //< #elif defined(__linux__)
struct
{
struct
{
Display* a;
} display;
struct
{
Window a;
} window;
} xlib;
#endif
operator bool()
{
return window != -1;
}
protected:
virtual bool on_closed()
{
return true;
}
virtual void on_focused() {}
virtual void on_unfocused() {}
virtual void on_resized(int widthInPixels, int heightInPixels)
{
this->widthInPixels = widthInPixels;
this->heightInPixels = heightInPixels;
}
private:
friend bool wm_add_window(struct wm_window_parameters_t& parameters, WMWindow* window);
struct wm_window_source_t* get_source()
{
// NOTE: should be ok according to https://stackoverflow.com/a/2007980
return (struct wm_window_source_t*)&minWidthInPixels;
}
void update_source();
struct wm_info_about_window_t* get_info()
{
#if defined(_WIN32)
return (struct wm_info_about_window_t*)&win32;
#else
return (struct wm_info_about_window_t*)&xlib;
#endif
}
void update_info();
int window = -1;
//struct wm_window_source_t source;
};
enum
{
EWMWindowParametersFlag_Opengl = EWMAddWindowParametersFlag_Opengl
};
struct wm_window_parameters_t
{
int flags = 0;
int minWidthInPixels = -1;
int minHeightInPixels = -1;
int maxWidthInPixels = -1;
int maxHeightInPixels = -1;
int widthInPixels = -1;
int heightInPixels = -1;
char* title = NULL;
bool bFullscreen = false;
};
bool wm_add_window(struct wm_window_parameters_t& parameters, WMWindow* window);