summaryrefslogtreecommitdiff
path: root/src/ui/window.h
diff options
context:
space:
mode:
authorJaakko Keränen <jaakko.keranen@iki.fi>2021-02-12 20:52:30 +0200
committerJaakko Keränen <jaakko.keranen@iki.fi>2021-02-12 20:52:30 +0200
commit51a74dc9c66b76dff795a9da3874602f3f0f0285 (patch)
treef7e5aed92bca8017027cf42bd38fdd298254b2e0 /src/ui/window.h
parent73c8166d5c8b397c166ee9ece0173f2b278b6ddb (diff)
Windows: Custom frame behavior
A borderless SDL window gets no standard window behavior, so this commit implements support for some of them. There is special handling for the window frame and various snapping modes. Not quite finished yet... It might make sense to research if a custom window class could work with this app (with SDL); could be less work.
Diffstat (limited to 'src/ui/window.h')
-rw-r--r--src/ui/window.h34
1 files changed, 31 insertions, 3 deletions
diff --git a/src/ui/window.h b/src/ui/window.h
index 5bde9065..ddb03847 100644
--- a/src/ui/window.h
+++ b/src/ui/window.h
@@ -32,13 +32,35 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */
32iDeclareType(Window) 32iDeclareType(Window)
33iDeclareTypeConstructionArgs(Window, iRect rect) 33iDeclareTypeConstructionArgs(Window, iRect rect)
34 34
35enum iWindowSnap {
36 none_WindowSnap = 0,
37 left_WindowSnap = 1,
38 right_WindowSnap = 2,
39 maximized_WindowSnap = 3,
40 yMaximized_WindowSnap = 4,
41 fullscreen_WindowSnap = 5,
42 mask_WindowSnap = 0xff,
43 topBit_WindowSnap = iBit(9),
44 bottomBit_WindowSnap = iBit(10),
45};
46
47iDeclareType(WindowPlacement)
48
49/* Tracking of window placement. */
50struct Impl_WindowPlacement {
51 iInt2 initialPos;
52 iRect normalRect; /* updated when window is moved/resized */
53 iInt2 lastNotifiedSize; /* keep track of horizontal/vertical notifications */
54 int snap; /* LAGRANGE_CUSTOM_FRAME */
55 int lastHit;
56};
57
35struct Impl_Window { 58struct Impl_Window {
36 SDL_Window * win; 59 SDL_Window * win;
37 iInt2 initialPos; 60 iWindowPlacement place;
38 iRect lastRect; /* updated when window is moved/resized */
39 iInt2 lastNotifiedSize; /* keep track of horizontal/vertical notifications */
40 iBool isDrawFrozen; /* avoids premature draws while restoring window state */ 61 iBool isDrawFrozen; /* avoids premature draws while restoring window state */
41 iBool isExposed; 62 iBool isExposed;
63 iBool isMinimized;
42 iBool isMouseInside; 64 iBool isMouseInside;
43 uint32_t focusGainedAt; 65 uint32_t focusGainedAt;
44 SDL_Renderer *render; 66 SDL_Renderer *render;
@@ -60,6 +82,7 @@ void setTitle_Window (iWindow *, const iString *title);
60void setUiScale_Window (iWindow *, float uiScale); 82void setUiScale_Window (iWindow *, float uiScale);
61void setFreezeDraw_Window (iWindow *, iBool freezeDraw); 83void setFreezeDraw_Window (iWindow *, iBool freezeDraw);
62void setCursor_Window (iWindow *, int cursor); 84void setCursor_Window (iWindow *, int cursor);
85void setSnap_Window (iWindow *, int snapMode);
63 86
64uint32_t id_Window (const iWindow *); 87uint32_t id_Window (const iWindow *);
65iInt2 rootSize_Window (const iWindow *); 88iInt2 rootSize_Window (const iWindow *);
@@ -68,6 +91,11 @@ iInt2 coord_Window (const iWindow *, int x, int y);
68iInt2 mouseCoord_Window (const iWindow *); 91iInt2 mouseCoord_Window (const iWindow *);
69uint32_t frameTime_Window (const iWindow *); 92uint32_t frameTime_Window (const iWindow *);
70SDL_Renderer *renderer_Window (const iWindow *); 93SDL_Renderer *renderer_Window (const iWindow *);
94int snap_Window (const iWindow *);
71iBool isFullscreen_Window (const iWindow *); 95iBool isFullscreen_Window (const iWindow *);
72 96
73iWindow * get_Window (void); 97iWindow * get_Window (void);
98
99#if defined (LAGRANGE_CUSTOM_FRAME)
100SDL_HitTestResult hitTest_Window(const iWindow *d, iInt2 pos);
101#endif