Debian Codegraph @

ui/uisys.h

raw symbols SCIP
1 /*
2 * Descent 3
3 * Copyright (C) 2024 Parallax Software
4 *
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, either version 3 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 */
18
19
20
21 #ifndef UISYS_H
22 #define UISYS_Hcxx . . $ `ui/uisys.h:22:9`!
23
24 /////////////////////////////////////////////////////////////////////////////
25 // DEFINITIONS
26
27 #define UIMSEBTN_PRESSEDcxx . . $ `ui/uisys.h:27:9`! 1
28 #define UIMSEBTN_RELEASEDcxx . . $ `ui/uisys.h:28:9`! 2
29 #define UIMSEBTN_CLICKEDcxx . . $ `ui/uisys.h:29:9`! 3
30
31 #define UIKEY_PRESSEDcxx . . $ `ui/uisys.h:31:9`! 1
32 #define UIKEY_RELEASEDcxx . . $ `ui/uisys.h:32:9`! 2
33 #define UIKEY_CLICKEDcxx . . $ `ui/uisys.h:33:9`! 3
34
35 // variables (OnMouseDown, etc)
36 #define UILMSEBTNcxx . . $ `ui/uisys.h:36:9`! 1
37 #define UIRMSEBTNcxx . . $ `ui/uisys.h:37:9`! 2
38
39 // mouse click properties
40 #define UI_DBLCLICK_DELAYcxx . . $ `ui/uisys.h:40:9`! 0.60f
41 #define UI_DBLCLICK_MSEDELTAcxx . . $ `ui/uisys.h:41:9`! 4
42
43 struct tUIInitInfocxx . . $ tUIInitInfo# {
44 int window_fontcxx . . $ tUIInitInfo#window_font.; // default font for windows
45 int wcxx . . $ tUIInitInfo#w., hcxx . . $ tUIInitInfo#h.; // width and height of screen.
46 };
47
48 struct tUIInputcxx . . $ tUIInput# {
49 int mxcxx . . $ tUIInput#mx., mycxx . . $ tUIInput#my., last_mxcxx . . $ tUIInput#last_mx., last_mycxx . . $ tUIInput#last_my.;
50 int b1_statuscxx . . $ tUIInput#b1_status., b1_last_statuscxx . . $ tUIInput#b1_last_status.;
51 int b1_countcxx . . $ tUIInput#b1_count.;
52 int keycxx . . $ tUIInput#key., last_keycxx . . $ tUIInput#last_key.;
53 int key_statuscxx . . $ tUIInput#key_status., last_key_statuscxx . . $ tUIInput#last_key_status.;
54 float cur_timecxx . . $ tUIInput#cur_time.;
55
56 bool key_first_presscxx . . $ tUIInput#key_first_press.; // if the key was really pressed or just held down.
57 bool printscreencxx . . $ tUIInput#printscreen.;
58 };
59
60 // user interface frame time
61 extern float UIFrameTimecxx . . $ UIFrameTime.;
62
63 // user input structure
64 extern tUIInputcxx . . $ tUIInput# UI_inputcxx . . $ UI_input.;
65 extern int UI_screen_widthcxx . . $ UI_screen_width., UI_screen_heightcxx . . $ UI_screen_height.;
66
67 class oeApplicationcxx . . $ oeApplication#;
68
69 //////////////////////////////////////////////////////////////////////////////
70 // MACROS
71
72 #define ISKEYPRESSEDcxx . . $ `ui/uisys.h:72:9`!(_k) \
73 ((UI_input.key == (_k) && (UI_input.key_status == UIKEY_PRESSED || UI_input.key_status == UIKEY_CLICKED)) ? true \
74 : false)
75 #define ISKEYRELEASEDcxx . . $ `ui/uisys.h:75:9`!(_k) ((UI_input.key == (_k) && UI_input.key_status == UIKEY_RELEASED) ? true : false)
76
77 // inlined supporter functions
78 static inline bool PT_IN_GADGETcxx . . $ PT_IN_GADGET(55d2799d541f12b5).(UIWindowcxx . . $ UIWindow# *wnd, UIGadgetcxx . . $ UIGadget# *gadget, int x, int y) {
79 int gl, gt, gr, gb;
80 gl = wnd->Xcxx . . $ UIObject#X(455f465bc33b4cdf).() + gadget->Xcxx . . $ UIObject#X(455f465bc33b4cdf).();
81 gt = wnd->Ycxx . . $ UIObject#Y(455f465bc33b4cdf).() + gadget->Ycxx . . $ UIObject#Y(455f465bc33b4cdf).();
82 gr = wnd->Xcxx . . $ UIObject#X(455f465bc33b4cdf).() + gadget->Xcxx . . $ UIObject#X(455f465bc33b4cdf).() + gadget->Wcxx . . $ UIObject#W(455f465bc33b4cdf).();
83 gb = wnd->Ycxx . . $ UIObject#Y(455f465bc33b4cdf).() + gadget->Ycxx . . $ UIObject#Y(455f465bc33b4cdf).() + gadget->Hcxx . . $ UIObject#H(455f465bc33b4cdf).();
84
85 if (x >= gl && x < gr)
86 if (y >= gt && y < gb)
87 return true;
88
89 return false;
90 }
91
92 static inline bool PT_IN_RECTcxx . . $ PT_IN_RECT(33820514f83722bc).(int x, int y, int l, int t, int w, int h) {
93 if (x >= l && x < (l + w) && y >= t && y < (t + h))
94 return true;
95 else
96 return false;
97 }
98
99 static inline int SCREEN_TO_WND_Xcxx . . $ SCREEN_TO_WND_X(a476385de694f262).(UIWindowcxx . . $ UIWindow# *wnd, int x) { return (x - wnd->Xcxx . . $ UIObject#X(455f465bc33b4cdf).()); }
100
101 static inline int SCREEN_TO_WND_Ycxx . . $ SCREEN_TO_WND_Y(a476385de694f262).(UIWindowcxx . . $ UIWindow# *wnd, int y) { return (y - wnd->Ycxx . . $ UIObject#Y(455f465bc33b4cdf).()); }
102
103 static inline int SCREEN_TO_GAD_Xcxx . . $ SCREEN_TO_GAD_X(dafe5a5d85eeac89).(UIGadgetcxx . . $ UIGadget# *gad, int x) { return (SCREEN_TO_WND_Xcxx . . $ SCREEN_TO_WND_X(a476385de694f262).(gad->GetWindowcxx . . $ UIGadget#GetWindow(97182dad698053bc).(), x) - gad->Xcxx . . $ UIObject#X(455f465bc33b4cdf).()); }
104
105 static inline int SCREEN_TO_GAD_Ycxx . . $ SCREEN_TO_GAD_Y(dafe5a5d85eeac89).(UIGadgetcxx . . $ UIGadget# *gad, int y) { return (SCREEN_TO_WND_Ycxx . . $ SCREEN_TO_WND_Y(a476385de694f262).(gad->GetWindowcxx . . $ UIGadget#GetWindow(97182dad698053bc).(), y) - gad->Ycxx . . $ UIObject#Y(455f465bc33b4cdf).()); }
106
107 #define LOCK_FOCUScxx . . $ `ui/uisys.h:107:9`!(_gadget) (_gadget)->LockFocus();
108
109 #define UNLOCK_FOCUScxx . . $ `ui/uisys.h:109:9`!(_gadget) (_gadget)->UnlockFocus();
110
111 static inline float UI_TIMEcxx . . $ UI_TIME(9b8c9e39889c762c).() { return UI_inputcxx . . $ UI_input..cur_timecxx . . $ tUIInput#cur_time.; }
112
113 //////////////////////////////////////////////////////////////////////////////
114 // FUNCTIONS
115
116 // call this function to initialize the UI system. pass a viewport where all UI will occur
117 void ui_Initcxx . . $ ui_Init(506d4ea8517b8bcc).(oeApplicationcxx . . $ oeApplication# *app, tUIInitInfocxx . . $ tUIInitInfo# *init_info);
118
119 // closes UI system. do this when setting a new surface.
120 void ui_Closecxx . . $ ui_Close(49f6e7a06ebc5aa8).();
121
122 // set user interface screen resolution
123 void ui_SetScreenModecxx . . $ ui_SetScreenMode(3e454b8ccf442868).(int w, int h);
124
125 // adds a window to the ui list. it is topmost, and has focus.
126 void ui_AddWindowcxx . . $ ui_AddWindow(e2cbbde2a2931ad2).(UIWindowcxx . . $ UIWindow# *wnd);
127
128 // removes a window from ui list.if topmost, the next topmost window has focus.
129 void ui_RemoveAllWindowscxx . . $ ui_RemoveAllWindows(49f6e7a06ebc5aa8).();
130
131 // removes a window from ui list.if topmost, the next topmost window has focus.
132 void ui_RemoveWindowcxx . . $ ui_RemoveWindow(e2cbbde2a2931ad2).(UIWindowcxx . . $ UIWindow# *wnd);
133
134 // does a ui frame given a list of windows. returns result list.
135 int ui_DoFramecxx . . $ ui_DoFrame(73da94e76e6bd037).(bool input = true);
136
137 // does a ui frame and gets mouse and key information.
138 int ui_DoFramecxx . . $ ui_DoFrame(5389c97c8c5fa9ba).(tUIInputcxx . . $ tUIInput# *input, bool doinput = true);
139
140 // ability to load/use mouse cursors
141 void ui_UseCursorcxx . . $ ui_UseCursor(85c52e162fed56f9).(const char *fname);
142
143 // hide and show cursor. effects are cumulative (returns whether the cursor was already shown or hidden.)
144 bool ui_ShowCursorcxx . . $ ui_ShowCursor(c9857a73d68e59ba).(); // return value false if cursor is currently visible.
145 bool ui_HideCursorcxx . . $ ui_HideCursor(c9857a73d68e59ba).(); // return value true if cursor was already hidden
146 bool ui_IsCursorVisiblecxx . . $ ui_IsCursorVisible(c9857a73d68e59ba).(); // is the cursor visible?
147
148 // frees ui input cache
149 void ui_Flushcxx . . $ ui_Flush(49f6e7a06ebc5aa8).();
150
151 // does screen shot
152 void ui_DoScreenshotcxx . . $ ui_DoScreenshot(49f6e7a06ebc5aa8).();
153
154 #endif