-
Notifications
You must be signed in to change notification settings - Fork 50
Expand file tree
/
Copy pathWindowMac.java
More file actions
336 lines (293 loc) · 10.3 KB
/
WindowMac.java
File metadata and controls
336 lines (293 loc) · 10.3 KB
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
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
package io.github.humbleui.jwm;
import java.io.*;
import java.util.concurrent.*;
import java.util.function.*;
import org.jetbrains.annotations.*;
import io.github.humbleui.types.*;
public class WindowMac extends Window {
@ApiStatus.Internal public float _lastProgressBarValue = -1f;
@ApiStatus.Internal
public WindowMac() {
super(_nMake());
}
@Override
public Window setTextInputEnabled(boolean enabled) {
assert _onUIThread() : "Should be run on UI thread";
// TODO: impl me
return this;
}
@Override
public void unmarkText() {
assert _onUIThread() : "Should be run on UI thread";
// TODO: impl me!
}
@Override
public IRect getWindowRect() {
assert _onUIThread() : "Should be run on UI thread";
return _nGetWindowRect();
}
@Override
public IRect getContentRect() {
assert _onUIThread() : "Should be run on UI thread";
return _nGetContentRect();
}
@Override
public Window setWindowPosition(int left, int top) {
assert _onUIThread() : "Should be run on UI thread";
if (_nSetWindowPosition(left, top))
return this;
else
throw new IllegalArgumentException("Position is outside of any screen: " + left + ", " + top);
}
@Override
public Window setWindowSize(int width, int height) {
assert _onUIThread() : "Should be run on UI thread";
_nSetWindowSize(width, height);
return this;
}
@Override
public Window setContentSize(int width, int height) {
assert _onUIThread() : "Should be run on UI thread";
_nSetContentSize(width, height);
return this;
}
@Override
public Window setTitle(String title) {
assert _onUIThread() : "Should be run on UI thread";
_nSetTitle(title);
return this;
}
/**
* Hide the title from the title bar without changing the text content.
*
* @param isVisible visibility flag value
* @return this
*/
@NotNull @Contract("-> this")
public Window setTitleVisible(boolean isVisible) {
assert _onUIThread() : "Should be run on UI thread";
_nSetTitleVisible(isVisible);
return this;
}
@NotNull @Contract("-> this")
public Window setSubtitle(@NotNull String title) {
assert _onUIThread() : "Should be run on UI thread";
_nSetSubtitle(title);
return this;
}
/**
* <p>Adds the system icon for the specified file next to the window title (and allows viewing the parent directories).</p>
*
* @param filename A path to a file
* @return this
*/
@NotNull @Contract("-> this")
public Window setRepresentedFilename(@NotNull String filename) {
assert _onUIThread() : "Should be run on UI thread";
_nSetRepresentedFilename(filename);
return this;
}
@Override
public Window setIcon(File icon) {
assert _onUIThread() : "Should be run on UI thread";
_nSetIcon(icon.getAbsolutePath().toString());
return this;
}
/**
* <p>Shortcut for {@link #setTitleVisible(boolean)}, {@link #setFullSizeContentView(boolean)}</p>
*
* <p>TODO: Traffic light visibility</p>
*
* @param isVisible visibility flag value
* @return this
*/
@Override
public Window setTitlebarVisible(boolean isVisible) {
assert _onUIThread() : "Should be run on UI thread";
setTitleVisible(isVisible);
setFullSizeContentView(!isVisible);
setTrafficLightsVisible(isVisible);
return this;
}
@NotNull @Contract("_ -> this")
public WindowMac setFullSizeContentView(boolean isFullSizeContentView) {
assert _onUIThread() : "Should be run on UI thread";
_nSetFullSizeContentView(isFullSizeContentView);
accept(new EventWindowResize(this));
return this;
}
@NotNull @Contract("_, -> this")
public WindowMac setTitlebarStyle(WindowMacTitlebarStyle titlebarStyle) {
assert _onUIThread() : "Should be run on UI thread";
_nSetTitlebarStyle(titlebarStyle.ordinal());
accept(new EventWindowResize(this));
return this;
}
@NotNull @Contract("_, _ -> this")
public WindowMac setTrafficLightPosition(int left, int top) {
assert _onUIThread() : "Should be run on UI thread";
_nSetTrafficLightPosition(left, top);
return this;
}
@NotNull @Contract("_ -> this")
public WindowMac setTrafficLightsVisible(boolean isVisible) {
assert _onUIThread() : "Should be run on UI thread";
_nSetTrafficLightsVisible(isVisible);
return this;
}
@ApiStatus.Internal @Override
public native void _nSetMouseCursor(int cursorIdx);
@Override
public Window hideMouseCursorUntilMoved(boolean value) {
assert _onUIThread() : "Should be run on UI thread";
_nHideMouseCursorUntilMoved(value);
return this;
}
@Override
public Window lockMouseCursor(boolean value) {
assert _onUIThread() : "Should be run on UI thread";
_nLockMouseCursor(value);
return this;
}
@Override
public Window setVisible(boolean value) {
assert _onUIThread() : "Should be run on UI thread";
_nSetVisible(value);
return super.setVisible(true);
}
@Override
public Window setOpacity(float opacity) {
throw new UnsupportedOperationException("impl me!");
}
@Override
public float getOpacity() {
return 1f;
}
@Override
public Screen getScreen() {
assert _onUIThread() : "Should be run on UI thread";
return _nGetScreen();
}
@Override
public void requestFrame() {
if (!isClosed()) {
App.runOnUIThread(() -> {
if (!isClosed()) {
_nRequestFrame();
}
});
}
}
@Override
public Window maximize() {
assert _onUIThread() : "Should be run on UI thread";
_nMaximize();
return this;
}
@Override
public Window minimize() {
assert _onUIThread() : "Should be run on UI thread";
_nMinimize();
return this;
}
@Override
public Window restore() {
assert _onUIThread() : "Should be run on UI thread";
_nRestore();
return this;
}
@Override
public float getScale() {
return this.getScreen().getScale();
}
@Override
public Window setFullScreen(boolean value) {
assert _onUIThread() : "Should be run on UI thread";
_nSetFullScreen(value);
return this;
}
@Override
public boolean isFullScreen() {
assert _onUIThread() : "Should be run on UI thread";
return _nIsFullScreen();
}
@Override
public Window focus() {
assert _onUIThread() : "Should be run on UI thread";
_nFocus();
return this;
}
@Override
public Window bringToFront() {
assert _onUIThread() : "Should be run on UI thread";
_nBringToFront();
return this;
}
@Override
public boolean isFront() {
assert _onUIThread() : "Should be run on UI thread";
return _nIsFront();
}
@Override
public ZOrder getZOrder() {
assert _onUIThread() : "Should be run on UI thread";
return ZOrder._values[_nGetZOrder()];
}
@Override
public Window setZOrder(ZOrder order) {
assert _onUIThread() : "Should be run on UI thread";
_nSetZOrder(order.ordinal());
return this;
}
@Override
public float getProgressBar() {
assert _onUIThread() : "Should be run on UI thread";
return _lastProgressBarValue;
}
@Override
public Window setProgressBar(float progress) {
assert _onUIThread() : "Should be run on UI thread";
_nSetProgressBar(progress);
_lastProgressBarValue = progress;
return this;
}
@Override
public void close() {
assert _onUIThread() : "Should be run on UI thread";
assert !isClosed() : "Window is already closed";
_nClose();
super.close();
}
@ApiStatus.Internal public static native long _nMake();
@ApiStatus.Internal public native IRect _nGetWindowRect();
@ApiStatus.Internal public native IRect _nGetContentRect();
@ApiStatus.Internal public native boolean _nSetWindowPosition(int left, int top);
@ApiStatus.Internal public native void _nSetWindowSize(int width, int height);
@ApiStatus.Internal public native void _nSetContentSize(int width, int height);
@ApiStatus.Internal public native void _nSetTitle(String title);
@ApiStatus.Internal public native void _nSetTitleVisible(boolean value);
@ApiStatus.Internal public native void _nSetSubtitle(String title);
@ApiStatus.Internal public native void _nSetRepresentedFilename(String filename);
@ApiStatus.Internal public native void _nSetIcon(String path);
@ApiStatus.Internal public native void _nSetFullSizeContentView(boolean value);
@ApiStatus.Internal public native void _nSetTitlebarStyle(int titlebarStyle);
@ApiStatus.Internal public native void _nSetTrafficLightPosition(int left, int top);
@ApiStatus.Internal public native void _nSetTrafficLightsVisible(boolean value);
@ApiStatus.Internal public native void _nHideMouseCursorUntilMoved(boolean value);
@ApiStatus.Internal public native void _nLockMouseCursor(boolean value);
@ApiStatus.Internal public native void _nSetVisible(boolean value);
@ApiStatus.Internal public native boolean _nIsFront();
@ApiStatus.Internal public native void _nBringToFront();
@ApiStatus.Internal public native Screen _nGetScreen();
@ApiStatus.Internal public native void _nRequestFrame();
@ApiStatus.Internal public native void _nMinimize();
@ApiStatus.Internal public native void _nMaximize();
@ApiStatus.Internal public native void _nRestore();
@ApiStatus.Internal public native void _nSetFullScreen(boolean value);
@ApiStatus.Internal public native boolean _nIsFullScreen();
@ApiStatus.Internal public native void _nFocus();
@ApiStatus.Internal public native int _nGetZOrder();
@ApiStatus.Internal public native void _nSetZOrder(int zOrder);
@ApiStatus.Internal public native void _nSetProgressBar(float value);
@ApiStatus.Internal public native void _nClose();
}