This repository has been archived by the owner on Mar 12, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Window.hx
1723 lines (1198 loc) · 53.2 KB
/
Window.hx
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
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
package glfw;
import cpp.Float32;
import cpp.UInt32;
import cpp.Star;
import glfw.keyboard.*;
import glfw.mouse.*;
import glfw.errors.*;
/**
A window.
To create a new window use `GLFW.createWindow`.
Using the window after it was destroyed with `Window.destroy` or after the GLFW object was destroyed with `GLFW.destroy` will throw a `UseAfterDestroyException` exception.
**/
@:allow(glfw)
@:cppNamespaceCode('
static bool find_window(GLFWwindow *window, unsigned int *index) {
for (unsigned int i = 0; i < glfw::Window_obj::windows->length; ++i) {
auto elem = glfw::Window_obj::windows->__get(i).StaticCast<glfw::Window>();
if (elem->native == window) {
*index = i;
return true;
}
}
return false;
}
static void char_callback(GLFWwindow *window, unsigned int codepoint) {
unsigned int index;
if (find_window(window, &index)) {
auto elem = glfw::Window_obj::windows->__get(index).StaticCast<glfw::Window>();
for (unsigned int j = 0; j < elem->onChar->length; ++j) {
elem->onChar->__get(j)(codepoint);
}
}
}
static void char_mods_callback(GLFWwindow *window, unsigned int codepoint, int mods) {
unsigned int index;
if (find_window(window, &index)) {
auto elem = glfw::Window_obj::windows->__get(index).StaticCast<glfw::Window>();
for (unsigned int j = 0; j < elem->onCharModifiers->length; ++j) {
elem->onCharModifiers->__get(j)(codepoint, mods);
}
}
}
static void close_callback(GLFWwindow *window) {
unsigned int index;
if (find_window(window, &index)) {
auto elem = glfw::Window_obj::windows->__get(index).StaticCast<glfw::Window>();
for (unsigned int j = 0; j < elem->onClose->length; ++j) {
elem->onClose->__get(j)();
}
}
}
static void contentscale_callback(GLFWwindow *window, float x, float y) {
unsigned int index;
if (find_window(window, &index)) {
auto elem = glfw::Window_obj::windows->__get(index).StaticCast<glfw::Window>();
for (unsigned int j = 0; j < elem->onContentScaleChange->length; ++j) {
elem->onContentScaleChange->__get(j)(x, y);
}
}
}
static void cursor_enter_callback(GLFWwindow *window, int entered) {
unsigned int index;
if (find_window(window, &index)) {
auto elem = glfw::Window_obj::windows->__get(index).StaticCast<glfw::Window>();
for (unsigned int j = 0; j < elem->onCursorHoverChange->length; ++j) {
elem->onCursorHoverChange->__get(j)(entered == GLFW_TRUE);
}
}
}
static void cursor_pos_callback(GLFWwindow *window, double x, double y) {
unsigned int index;
if (find_window(window, &index)) {
auto elem = glfw::Window_obj::windows->__get(index).StaticCast<glfw::Window>();
for (unsigned int j = 0; j < elem->onCursorPositionChange->length; ++j) {
elem->onCursorPositionChange->__get(j)(x, y);
}
}
}
static void drop_callback(GLFWwindow *window, int count, const char **paths) {
unsigned int index;
if (find_window(window, &index)) {
auto elem = glfw::Window_obj::windows->__get(index).StaticCast<glfw::Window>();
for (unsigned int j = 0; j < elem->onPathDrop->length; ++j) {
Array<String> haxe_paths = Array_obj<String>::__new();
for (unsigned int k = 0; k < count; ++k) {
cpp::Pointer<char> ptr = paths[index];
haxe_paths->push(String(ptr->ptr));
}
elem->onPathDrop->__get(j)(haxe_paths);
}
}
}
static void focus_callback(GLFWwindow *window, int focused) {
unsigned int index;
if (find_window(window, &index)) {
auto elem = glfw::Window_obj::windows->__get(index).StaticCast<glfw::Window>();
for (unsigned int j = 0; j < elem->onFocusChange->length; ++j) {
elem->onFocusChange->__get(j)(focused == GLFW_TRUE);
}
}
}
static void iconify_callback(GLFWwindow *window, int iconified) {
unsigned int index;
if (find_window(window, &index)) {
auto elem = glfw::Window_obj::windows->__get(index).StaticCast<glfw::Window>();
for (unsigned int j = 0; j < elem->onIconifyChange->length; ++j) {
elem->onIconifyChange->__get(j)(iconified == GLFW_TRUE);
}
}
}
static void key_callback(GLFWwindow *window, int key, int scancode, int action, int mods) {
unsigned int index;
if (find_window(window, &index)) {
auto elem = glfw::Window_obj::windows->__get(index).StaticCast<glfw::Window>();
for (unsigned int j = 0; j < elem->onKey->length; ++j) {
elem->onKey->__get(j)(key, scancode, action, mods);
}
}
}
static void maximize_callback(GLFWwindow *window, int maximized) {
unsigned int index;
if (find_window(window, &index)) {
auto elem = glfw::Window_obj::windows->__get(index).StaticCast<glfw::Window>();
for (unsigned int j = 0; j < elem->onMaximizeChange->length; ++j) {
elem->onMaximizeChange->__get(j)(maximized == GLFW_TRUE);
}
}
}
static void mouse_button_callback(GLFWwindow *window, int button, int action, int mods) {
unsigned int index;
if (find_window(window, &index)) {
auto elem = glfw::Window_obj::windows->__get(index).StaticCast<glfw::Window>();
for (unsigned int j = 0; j < elem->onMouseButton->length; ++j) {
elem->onMouseButton->__get(j)(button, action == GLFW_PRESS, mods);
}
}
}
static void pos_callback(GLFWwindow *window, int x, int y) {
unsigned int index;
if (find_window(window, &index)) {
auto elem = glfw::Window_obj::windows->__get(index).StaticCast<glfw::Window>();
for (unsigned int j = 0; j < elem->onPositionChange->length; ++j) {
elem->onPositionChange->__get(j)(x, y);
}
}
}
static void refresh_callback(GLFWwindow *window) {
unsigned int index;
if (find_window(window, &index)) {
auto elem = glfw::Window_obj::windows->__get(index).StaticCast<glfw::Window>();
for (unsigned int j = 0; j < elem->onRefresh->length; ++j) {
elem->onRefresh->__get(j)();
}
}
}
static void scroll_callback(GLFWwindow *window, double x, double y) {
unsigned int index;
if (find_window(window, &index)) {
auto elem = glfw::Window_obj::windows->__get(index).StaticCast<glfw::Window>();
for (unsigned int j = 0; j < elem->onMouseScroll->length; ++j) {
elem->onMouseScroll->__get(j)(x, y);
}
}
}
static void size_callback(GLFWwindow *window, int width, int height) {
unsigned int index;
if (find_window(window, &index)) {
auto elem = glfw::Window_obj::windows->__get(index).StaticCast<glfw::Window>();
for (unsigned int j = 0; j < elem->onSizeChange->length; ++j) {
elem->onSizeChange->__get(j)(width, height);
}
}
}
')
@:headerClassCode('
GLFWwindow *native;
')
@:headerInclude('./glfw.h')
class Window {
static var windows:Array<Window> = [];
/**
Whether the fullscreen window will automatically iconify and restore the previous video mode on input focus loss.
This is ignored for windowed mode windows.
**Thread safety:** This variable must only be used from the main thread.
@throws PlatformErrorException
@throws UseAfterDestroyException
**/
public var autoIconify(get, set):Bool;
/**
The content scale of the window.
The content scale is the ratio between the current DPI and the platform's default DPI.
This is especially important for text and any UI elements.
If the pixel dimensions of your UI scaled by this look appropriate on your machine then it should appear at a reasonable size on other machines regardless of their DPI and scaling settings.
This relies on the system DPI and scaling settings being somewhat correct.
On systems where each monitors can have its own content scale, the window content scale will depend on which monitor the system considers the window to be on.
**Thread safety:** This variable must only be used from the main thread.
@throws PlatformErrorException
@throws UseAfterDestroyException
**/
public var contentScale(get, never):{x:Float, y:Float};
/**
The cursor of the window.
This is the cursor image to be used when the cursor is over the content area of the window.
Set this to `null` (the default value) to return to the system cursor.
It will only be visible if the `Window.cursorMode` is `CursorMode.Normal`.
On some platforms, the set cursor may not be visible unless the window also has input focus.
**Thread safety:** This variable must only be used from the main thread.
@throws PlatformErrorException
@throws UseAfterDestroyException
**/
public var cursor(default, set):Null<Cursor>;
/**
The mode of the cursor, default to `CursorMode.Normal`.
See `CursorMode` for more details about the available modes.
**Thread safety:** This variable must only be used from the main thread.
@throws PlatformErrorException
@throws UseAfterDestroyException
**/
public var cursorMode(get, set):CursorMode;
/**
The horizontal position of the cursor, in screen coordinates, relative to the upper-left corner of the content area of the window.
If the cursor is disabled (`Window.cursorMode` is `CursorMode.Disabled`) then the cursor position is unbounded and limited only by the minimum and maximum values of a `Float`.
The coordinate can be converted to their integer equivalents with the `Math.floor` function.
Casting directly to an integer type works for positive coordinates, but fails for negative ones.
**Thread safety:** This variable must only be used from the main thread.
@throws PlatformErrorException
@throws UseAfterDestroyException
**/
public var cursorPositionX(get, set):Float;
/**
The vertical position of the cursor, in screen coordinates, relative to the upper-left corner of the content area of the window.
If the cursor is disabled (`Window.cursorMode` is `CursorMode.Disabled`) then the cursor position is unbounded and limited only by the minimum and maximum values of a `Float`.
The coordinate can be converted to their integer equivalents with the `Math.floor` function.
Casting directly to an integer type works for positive coordinates, but fails for negative ones.
**Thread safety:** This variable must only be used from the main thread.
@throws PlatformErrorException
@throws UseAfterDestroyException
**/
public var cursorPositionY(get, set):Float;
/**
Whether the windowed mode window will have window decorations such as a border, a close widget, etc. An undecorated window will not be resizable by the user but will still allow the user to generate close events on some platforms.
This is ignored for fullscreen windows.
**Thread safety:** This variable must only be used from the main thread.
@throws PlatformErrorException
@throws UseAfterDestroyException
**/
public var decorated(get, set):Bool;
/**
Whether the windowed mode window will be floating above other regular windows, also called topmost or always-on-top. This is intended primarily for debugging purposes and cannot be used to implement proper fullscreen windows.
This is ignored for fullscreen windows.
**Thread safety:** This variable must only be used from the main thread.
@throws PlatformErrorException
@throws UseAfterDestroyException
**/
public var floating(get, set):Bool;
/**
The current input focus state.
**Thread safety:** This variable must only be used from the main thread.
@see `Window.focus`
@see `Window.requestAttention`
@throws PlatformErrorException
@throws UseAfterDestroyException
**/
public var focused(get, never):Bool;
/**
Whether the window will be given input focus when `Window.show` is called.
**Thread safety:** This variable must only be used from the main thread.
@throws PlatformErrorException
@throws UseAfterDestroyException
**/
public var focusOnShow(get, set):Bool;
/**
The size of the frame of the window.
This is the size, in screen coordinates, of each edge of the frame of the window.
This size includes the title bar, if the window has one.
Because this function retrieves the size of each window frame edge and not the offset along a particular coordinate axis, the retrieved values will always be zero or positive.
**Thread safety:** This variable must only be used from the main thread.
@throws PlatformErrorException
@throws UseAfterDestroyException
**/
public var frameSize(get, never):{
left:Int,
top:Int,
right:Int,
bottom:Int
};
/**
Whether sticky keys are enabled.
When sticky keys mode is enabled, the pollable state of a key will remain `KeyState.Press` until the state of that key is polled with `Window.getKeyState`. Once it has been polled, if a key release event had been processed in the meantime, the state will reset to `KeyState.Release`, otherwise it will remain `KeyState.Press`.
**Thread safety:** This variable must only be used from the main thread.
@throws PlatformErrorException
@throws UseAfterDestroyException
**/
public var keysSticky(get, set):Bool;
/**
Whether caps lock and num lock key modifiers are set for key events.
When this input mode is enabled, any callback that receives `Modifiers` state will have the `Modifiers.capsLock` set to `true` set if Caps Lock was on when the event occurred and the `Modifiers.numLock` set to `true` if Num Lock was on.
**Thread safety:** This variable must only be used from the main thread.
@throws PlatformErrorException
@throws UseAfterDestroyException
**/
public var lockKeyModifiers(get, set):Bool;
/**
The current maximization state.
**Thread safety:** This variable must only be used from the main thread.
@see `Window.maximize`
@see `Window.restore`
@throws PlatformErrorException
@throws UseAfterDestroyException
**/
public var maximized(get, never):Bool;
/**
Whether sticky mouse buttons are enabled.
If true a mouse button press will ensure that `Window.getMouseButton` returns `true` the next time it is called even if the mouse button had been released before the call.
This is useful when you are only interested in whether mouse buttons have been pressed but not when or in which order.
**Thread safety:** This variable must only be used from the main thread.
@throws PlatformErrorException
@throws UseAfterDestroyException
**/
public var mouseButtonsSticky(get, set):Bool;
/**
The callbacks to be called when a Unicode character is input.
The character callback is intended for Unicode text input. As it deals with characters, it is keyboard layout dependent, whereas the key callback is not. Characters do not map 1:1 to physical keys, as a key may produce zero, one or more characters. If you want to know whether a specific physical key was pressed or released, see the `Window.onKey` callback instead.
The character callback behaves as system text input normally does and will not be called if modifier keys are held down that would prevent normal text input on that platform, for example a Super (Command) key on macOS or Alt key on Windows. For that use `Window.onCharModifiers`.
Arguments:
* `codePoint` The Unicode code point of the character.
To add a callback push a function to this array.
**/
public var onChar:Array<(codePoint:UInt) -> Void>;
/**
The callbacks to be called when a Unicode character is input regardless of what modifier keys are used.
The character with modifiers callback is intended for implementing custom Unicode character input. For regular Unicode text input, see the `Window.onChar` callback. Like the character callback, the character with modifiers callback deals with characters and is keyboard layout dependent. Characters do not map 1:1 to physical keys, as a key may produce zero, one or more characters. If you want to know whether a specific physical key was pressed or released, see the `Window.onKey` callback instead.
Arguments:
* `codePoint` The Unicode code point of the character.
* `modifiers` The modifier keys status.
To add a callback push a function to this array.
**/
@:deprecated("Scheduled for removal in GLFW version 4.0")
public var onCharModifiers:Array<(codePoint:UInt, modifiers:Modifiers) -> Void> = [];
/**
The callbacks to be called when the window is closed.
It is called when the user attempts to close the window, for example by clicking the close widget in the title bar.
The close flag is set before this callback is called, but you can modify it at any time with `Window.shouldClose`.
The close callback is not triggered by `Window.destroy`.
On MacOS selecting Quit from the application menu will trigger the close callback for all windows.
To add a callback push a function to this array.
**/
public var onClose:Array<() -> Void>;
/**
The callbacks to be called when the window's content scale change.
Arguments:
* `x` The new x-axis content scale of the window.
* `y` The new y-axis content scale of the window.
To add a callback push a function to this array.
@see `Window.contentScale`
**/
public var onContentScaleChange:Array<(x:Float, y:Float) -> Void>;
/**
The callbacks to be called when the window's cursor enter or leave the window's content area.
Arguments:
* `inside` True if the cursor is over the window's content area.
To add a callback push a function to this array.
**/
public var onCursorHoverChange:Array<(inside:Bool) -> Void>;
/**
The callbacks to be called when the window's cursor change position.
Arguments:
* `x` The new cursor x-coordinate, relative to the left edge of the content area.
* `y` The new cursor y-coordinate, relative to the left edge of the content area.
To add a callback push a function to this array.
**/
public var onCursorPositionChange:Array<(x:Float, y:Float) -> Void>;
/**
The callbacks to be called when the window gains or loses input focus.
Arguments:
* `focused` True if the window was given input focus, false if it lost it.
To add a callback push a function to this array.
**/
public var onFocusChange:Array<(focused:Bool) -> Void>;
/**
The callbacks to be called when the window is iconified or restored.
Arguments:
* `iconified` True if the window was iconified, false if it was restored.
To add a callback push a function to this array.
**/
public var onIconifyChange:Array<(iconified:Bool) -> Void>;
/**
The callbacks to be called when a key is pressed, repeated or released.
This deals with physical keys, with layout independent `Key` tokens named after their values in the standard US keyboard layout.
If you want to input text, use the `Window.onChar` callback instead.
When a window loses input focus, it will generate synthetic key release events for all pressed keys.
You can tell these events from user-generated events by the fact that the synthetic ones are generated after the focus loss event has been processed, i.e. after the window focus callback has been called.
The scancode of a key is specific to that platform or sometimes even to that machine. Scancodes are intended to allow users to bind keys that don't have a GLFW key token. Such keys have key set to `Key.Unknown`, their state is not saved and so it cannot be queried with `Window.getKeyState`.
Sometimes GLFW needs to generate synthetic key events, in which case the scancode may be zero.
Arguments:
* `key` The keyboard key that was pressed or released.
* `scancode` The system-specific scancode of the key.
* `state` The state of the key.
* `modifiers` The modifier keys status.
**/
public var onKey:Array<(key:Key, scancode:Scancode, state:KeyState, modifiers:Modifiers) -> Void>;
/**
The callbacks to be called when the window is maximized or restored.
Arguments:
* `maximized` True if the window was maximized, false if it was restored.
To add a callback push a function to this array.
**/
public var onMaximizeChange:Array<(maximized:Bool) -> Void>;
/**
The callbacks to be called when a mouse button is pressed or released.
When a window loses input focus, it will generate synthetic mouse button release events for all pressed mouse buttons.
You can tell these events from user-generated events by the fact that the synthetic ones are generated after the focus loss event has been processed, i.e. after the `Window.onFocusChange` have been called.
Arguments:
* `button` The button that was pressed or released.
* `pressed` True if the button was pressed, false if released.
* `modifiers` The modifier keys status.
To add a callback push a function to this array.
**/
public var onMouseButton:Array<(button:MouseButton, pressed:Bool, modifiers:Modifiers) -> Void>;
/**
The callbacks to be called when a scrolling device is used, such as a mouse wheel or scrolling area of a touchpad.
Arguments:
* `x` The scroll offset along the x-axis.
* `y` The scroll offset along the y-axis.
To add a callback push a function to this array.
**/
public var onMouseScroll:Array<(x:Float, y:Float) -> Void>;
/**
The callbacks to be called when one or more dragged paths are dropped on the window.
Arguments:
* `paths` The array of UTF-8 encoded file and/or directory path names.
To add a callback push a function to this array.
**/
public var onPathDrop:Array<(paths:Array<String>) -> Void>;
/**
The callbacks to be called when the window is moved.
Arguments:
* `x` The new x-coordinate, in screen coordinates, of the upper-left corner of the content area of the window.
* `y` The new y-coordinate, in screen coordinates, of the upper-left corner of the content area of the window.
To add a callback push a function to this array.
**/
public var onPositionChange:Array<(x:Int, y:Int) -> Void>;
/**
The callbacks to be called when the content area of the window needs to be redrawn, for example if the window has been exposed after having been covered by another window.
On compositing window systems such as Aero, Compiz, Aqua or Wayland, where the window contents are saved off-screen, this callback may be called only very infrequently or never at all.
To add a callback push a function to this array.
**/
public var onRefresh:Array<() -> Void>;
/**
The callbacks to be called when the window is resized.
Arguments:
* `width` The new width, in screen coordinates, of the window.
* `height` The new height, in screen coordinates, of the window.
To add a callback push a function to this array.
**/
public var onSizeChange:Array<(width:Int, height:Int) -> Void>;
/**
The opacity of the whole window, including any decorations.
The opacity (or alpha) value is a positive finite number between zero and one, where zero is fully transparent and one is fully opaque.
If the system does not support whole window transparency, this is always one.
The initial opacity value for newly created windows is one.
**Thread safety:** This variable must only be used from the main thread.
@throws PlatformErrorException
@throws UseAfterDestroyException
**/
public var opacity(get, set):Float;
var parent:GLFW;
/**
Whether raw mouse motion is enabled.
Raw mouse motion is closer to the actual motion of the mouse across a surface.
It is not affected by the scaling and acceleration applied to the motion of the desktop cursor.
That processing is suitable for a cursor while raw motion is better for controlling for example a 3D camera.
Because of this, raw mouse motion is only provided when the cursor is disabled.
Setting this to `true` if `Window.rawMouseMotionSupported` is `false` will leave it to `false`.
**Thread safety:** This variable must only be used from the main thread.
@throws PlatformErrorException
@throws UseAfterDestroyException
**/
public var rawMouseMotion(get, set):Bool;
/**
Whether raw mouse motion is supported on the current system.
This status does not change after GLFW has been initialized so you only need to check this once.
**Thread safety:** This variable must only be used from the main thread.
@see `Window.rawMouseMotion`
@throws UseAfterDestroyException
**/
public var rawMouseMotionSupported(get, never):Bool;
/**
Whether the windowed mode window will be resizable by the user. The window will still be resizable using the `Window.setSize` function.
This is ignored for fullscreen and undecorated windows.
**Thread safety:** This variable must only be used from the main thread.
@throws PlatformErrorException
@throws UseAfterDestroyException
**/
public var resizable(get, set):Bool;
/**
The close flag of the window.
Setting this can be used to override the user's attempt to close the window, or to signal that it should be closed.
**Thread safety:** This variable may be used from any thread. Access is not synchronized.
@throws UseAfterDestroyException
**/
public var shouldClose(get, set):Bool;
/**
The title of the window.
**Thread safety:** This variable must only be used from the main thread.
@throws PlatformErrorException
@throws UseAfterDestroyException
**/
public var title(default, set):String;
/**
The current visibility state.
**Thread safety:** This variable must only be used from the main thread.
@throws PlatformErrorException
@throws UseAfterDestroyException
**/
public var visible(get, never):Bool;
function get_autoIconify():Bool {
validate();
return untyped __cpp__('glfwGetWindowAttrib(native, GLFW_AUTO_ICONIFY)');
}
function set_autoIconify(value:Bool):Bool {
validate();
untyped __cpp__('glfwSetWindowAttrib(native, GLFW_AUTO_ICONIFY, value ? GLFW_TRUE : GLFW_FALSE)');
return value;
}
function get_contentScale():{x:Float, y:Float} {
validate();
var x:Float32 = 0.0;
var y:Float32 = 0.0;
untyped __cpp__('glfwGetWindowContentScale(native, &x, &y)');
return {
x: x,
y: y,
};
}
function set_cursor(value:Null<Cursor>):Null<Cursor> {
validate();
untyped __cpp__('glfwSetCursor(native, hx::IsNull(value) ? nullptr : value->native)');
return cursor = value;
}
function get_cursorMode():CursorMode {
validate();
return untyped __cpp__('glfwGetInputMode(native, GLFW_CURSOR)');
}
function set_cursorMode(value:CursorMode):CursorMode {
validate();
untyped __cpp__('glfwSetInputMode(native, GLFW_CURSOR, value)');
return value;
}
function get_cursorPositionX():Float {
validate();
var position = 0.0;
untyped __cpp__('glfwGetCursorPos(native, &position, nullptr)');
return position;
}
function set_cursorPositionX(value:Float):Float {
validate();
untyped __cpp__('
double y;
glfwGetCursorPos(native, nullptr, &y);
glfwSetCursorPos(native, value, y);
');
return value;
}
function get_cursorPositionY():Float {
validate();
var position = 0.0;
untyped __cpp__('glfwGetCursorPos(native, nullptr, &position)');
return position;
}
function set_cursorPositionY(value:Float):Float {
validate();
untyped __cpp__('
double x;
glfwGetCursorPos(native, &x, nullptr);
glfwSetCursorPos(native, x, value);
');
return value;
}
function get_decorated():Bool {
validate();
return untyped __cpp__('glfwGetWindowAttrib(native, GLFW_DECORATED)');
}
function set_decorated(value:Bool):Bool {
validate();
untyped __cpp__('glfwSetWindowAttrib(native, GLFW_DECORATED, value ? GLFW_TRUE : GLFW_FALSE)');
return value;
}
function get_floating():Bool {
validate();
return untyped __cpp__('glfwGetWindowAttrib(native, GLFW_FLOATING)');
}
function set_floating(value:Bool):Bool {
validate();
untyped __cpp__('glfwSetWindowAttrib(native, GLFW_FLOATING, value ? GLFW_TRUE : GLFW_FALSE)');
return value;
}
function get_focused():Bool {
validate();
return untyped __cpp__('glfwGetWindowAttrib(native, GLFW_FOCUSED)');
}
function get_focusOnShow():Bool {
validate();
return untyped __cpp__('glfwGetWindowAttrib(native, GLFW_FOCUS_ON_SHOW)');
}
function set_focusOnShow(value:Bool):Bool {
validate();
untyped __cpp__('glfwSetWindowAttrib(native, GLFW_FOCUS_ON_SHOW, value ? GLFW_TRUE : GLFW_FALSE)');
return value;
}
function get_frameSize():{
left:Int,
top:Int,
right:Int,
bottom:Int
} {
validate();
var left = 0;
var top = 0;
var right = 0;
var bottom = 0;
untyped __cpp__('glfwGetWindowFrameSize(native, &left, &top, &right, &bottom)');
return {
left: left,
top: top,
right: right,
bottom: bottom,
};
}
function get_keysSticky():Bool {
validate();
return untyped __cpp__('glfwGetInputMode(native, GLFW_STICKY_KEYS) == GLFW_TRUE');
}
function set_keysSticky(value:Bool):Bool {
validate();
untyped __cpp__('glfwSetInputMode(native, GLFW_STICKY_KEYS, value ? GLFW_TRUE : GLFW_FALSE)');
return value;
}
function get_lockKeyModifiers():Bool {
validate();
return untyped __cpp__('glfwGetInputMode(native, GLFW_STICKY_KEYS) == GLFW_TRUE');
}
function set_lockKeyModifiers(value:Bool):Bool {
validate();
untyped __cpp__('glfwSetInputMode(native, GLFW_STICKY_KEYS, value ? GLFW_TRUE : GLFW_FALSE)');
return value;
}
function get_maximized():Bool {
validate();
return untyped __cpp__('glfwGetWindowAttrib(native, GLFW_MAXIMIZED)');
}
function get_mouseButtonsSticky():Bool {
validate();
return untyped __cpp__('glfwGetInputMode(native, GLFW_STICKY_MOUSE_BUTTONS) == GLFW_TRUE');
}
function set_mouseButtonsSticky(value:Bool):Bool {
validate();
untyped __cpp__('glfwSetInputMode(native, GLFW_STICKY_MOUSE_BUTTONS, value ? GLFW_TRUE : GLFW_FALSE)');
return value;
}
function get_opacity():Float {
validate();
return untyped __cpp__('glfwGetWindowOpacity(native)');
}
function set_opacity(value:Float):Float {
validate();
untyped __cpp__('glfwSetWindowOpacity(native, (float)value)');
return value;
}
function get_rawMouseMotion():Bool {
validate();
return untyped __cpp__('glfwGetInputMode(native, GLFW_RAW_MOUSE_MOTION) == GLFW_TRUE');
}
function set_rawMouseMotion(value:Bool):Bool {
validate();
if (!rawMouseMotionSupported) {
return false;
}
untyped __cpp__('glfwSetInputMode(native, GLFW_RAW_MOUSE_MOTION, value ? GLFW_TRUE : GLFW_FALSE)');
return value;
}
function get_rawMouseMotionSupported():Bool {
validate();
return untyped __cpp__('glfwRawMouseMotionSupported() == GLFW_TRUE');
}
function get_resizable():Bool {
validate();
return untyped __cpp__('glfwGetWindowAttrib(native, GLFW_RESIZABLE)');
}
function set_resizable(value:Bool):Bool {
validate();
untyped __cpp__('glfwSetWindowAttrib(native, GLFW_RESIZABLE, value ? GLFW_TRUE : GLFW_FALSE)');
return value;
}
function get_shouldClose():Bool {