-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy patheyeGUI.h
More file actions
969 lines (861 loc) · 32.2 KB
/
eyeGUI.h
File metadata and controls
969 lines (861 loc) · 32.2 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
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
// The MIT License (MIT)
//
// Copyright(c) 2016 Raphael Menges
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files(the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and / or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions :
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
/*!
* \brief Interface to access eyeGUI functions.
* \details This interface provides multiply functions and abstract class declarations to create, render and manipulate the eyeGUI user interface.
* \author Raphael Menges
* \version 0.8
* \license This project is released under the MIT License (MIT)
*/
#ifndef EYE_GUI_H_
#define EYE_GUI_H_
#include <string>
#include <memory>
#include <map>
namespace eyegui
{
class GUI;
class Layout;
class Frame;
//! Enumeration of possible character sets for font rendering.
enum class CharacterSet { GERMANY_GERMAN, US_ENGLISH };
//! Enumeration of possible font sizes. Size of keyboard font cannot be set in GUIBuilder.
enum class FontSize { TALL, MEDIUM, SMALL, KEYBOARD };
//! Enumeration of possible text flow alignments
enum class TextFlowAlignment { LEFT, RIGHT, CENTER, JUSTIFY };
//! Enumeration of possible vertical text flow alignments
enum class TextFlowVerticalAlignment { TOP, CENTER, BOTTOM };
//! Enumeration of possible image alignments.
enum class ImageAlignment { ORIGINAL, STRETCHED, ZOOMED };
//! Enumeration of cases of keyboard.
enum class KeyboardCase { LOWER, UPPER };
//! Abstract listener class for buttons.
class ButtonListener
{
public:
//! Constructor.
ButtonListener();
//! Destructor.
virtual ~ButtonListener() = 0;
//! Callback for hitting of button.
/*!
\param pLayout pointer to layout from which callback is coming.
\param id is the unique id of the button which causes the callback.
*/
void virtual hit(Layout* pLayout, std::string id) = 0;
//! Callback for pushing button down.
/*!
\param pLayout pointer to layout from which callback is coming.
\param id is the unique id of the button which causes the callback.
*/
void virtual down(Layout* pLayout, std::string id) = 0;
//! Callback for pulling button up.
/*!
\param pLayout pointer to layout from which callback is coming.
\param id is the unique id of the button which causes the callback.
*/
void virtual up(Layout* pLayout, std::string id) = 0;
};
//! Abstract listener class for sensors.
class SensorListener
{
public:
//! Constructor.
SensorListener();
//! Destructor.
virtual ~SensorListener() = 0;
//! Callback for penetration of sensor.
/*!
\param pLayout pointer to layout from which callback is coming.
\param id is the unique id of the sensor which causes the callback.
\param amount is the value of penetration at time of callback.
*/
void virtual penetrated(Layout* pLayout, std::string id, float amount) = 0;
};
//! Abstract listener class for keyboards.
class KeyboardListener
{
public:
//! Constructor.
KeyboardListener();
//! Destructor.
virtual ~KeyboardListener() = 0;
//! Callback for pressing keys of keyboard.
/*!
\param pLayout pointer to layout from which callback is coming.
\param id is the unique id of the keyboard which causes the callback.
\param value is the u16string given by pressed key.
*/
void virtual keyPressed(Layout* pLayout, std::string id, std::u16string value) = 0;
//! Callback for pressing keys of keyboard.
/*!
\param pLayout pointer to layout from which callback is coming.
\param id is the unique id of the keyboard which causes the callback.
\param value is the string given by pressed key.
*/
void virtual keyPressed(Layout* pLayout, std::string id, std::string value) = 0;
};
//! Struct for relative values of position and size
struct RelativePositionAndSize
{
float x = 0;
float y = 0;
float width = 0;
float height = 0;
};
//! Struct for absolute pixel values of position and size
struct AbsolutePositionAndSize
{
int x = 0;
int y = 0;
int width = 0;
int height = 0;
};
//! Struct for input
struct Input
{
int gazeX = 0; //!< X position of gaze in pixels
int gazeY = 0; //!< Y position of gaze in pixels
bool gazeUsed = false; //!< Indicates usage of gaze by eyeGUI
bool instantInteraction = false; //!< Instant interaction with element beneath gaze
};
//! Builder for GUI
class GUIBuilder
{
public:
GUI* construct() const; //!< returns pointer to built GUI
int width; //!< width of GUI as integer
int height; //!< height of GUI as integer
std::string fontFilepath = ""; //!< fontFilepath is path to a .ttf font file
CharacterSet characterSet = CharacterSet::US_ENGLISH; //!< characterSet used to initialize font rendering
std::string localizationFilepath = ""; //!< localizationFilepath is path to a .leyegui file
float vectorGraphicsDPI = 96.0f; //!< dpi which are used to rasterize vector graphics
float fontTallSize = 0.1f; //!< Height of tall font in percentage of GUI height
float fontMediumSize = 0.04f; //!< Height of medium font in percentage of GUI height
float fontSmallSize = 0.0175f; //!< Height of small font in percentage of GUI height
};
//! Creates layout inside GUI and returns pointer to it. Is executed at update call.
/*!
\param pGUI pointer to GUI.
\param filepath is path to layout xml file.
\param visible shall added layout be visible.
\return pointer to added layout. Null if creation was not possible because layouts were locked.
*/
Layout* addLayout(GUI* pGUI, std::string filepath, bool visible = true);
//! Removes layout in GUI by pointer. Is executed at update call.
/*!
\param pGUI pointer to GUI.
\param pLayout is the pointer to layout which should be removed.
*/
void removeLayout(GUI* pGUI, Layout const * pLayout);
//! Update whole GUI.
/*!
\param pGUI pointer to GUI.
\param tpf passed time since last rendering in seconds as float.
\param input struct.
\return input struct with information about usage.
*/
Input updateGUI(GUI* pGUI, float tpf, const Input input);
//! Draw whole GUI.
/*!
\param pGUI pointer to GUI.
*/
void drawGUI(GUI const * pGUI);
//! Terminate GUI.
/*!
\param pGUI pointer to GUI which should be terminated.
*/
void terminateGUI(GUI* pGUI);
//! Resize GUI. Is executed at update call.
/*!
\param pGUI pointer to GUI.
\param width of GUI as integer.
\param height of GUI as integer.
*/
void resizeGUI(GUI* pGUI, int width, int height);
//! Load config. Is executed at update call.
/*!
\param pGUI pointer to GUI.
\param filepath is path to config file.
*/
void loadConfig(GUI* pGUI, std::string filepath);
//! Set gaze visualization drawing.
/*!
\param pGUI pointer to GUI.
\param draw indicates whether gaze visualization should be drawn.
*/
void setGazeVisualizationDrawing(GUI* pGUI, bool draw);
//! Toggle gaze visualization drawing.
/*!
\param pGUI pointer to GUI.
*/
void toggleGazeVisualizationDrawing(GUI* pGUI);
//! Prefetch image to avoid lags.
/*!
\param pGUI pointer to GUI.
\param filepath is path to image which should be prefetched.
*/
void prefetchImage(GUI* pGUI, std::string filepath);
//! Sets value of config attribute. Is executed at update call.
/*!
\param pLayout pointer to layout.
\param attribute is name of attribute which shall be changed.
\param value is new value of attribute.
*/
void setValueOfConfigAttribute(
GUI* pGUI,
std::string attribute,
std::string value);
//! Move layout to front. Is executed at update call.
/*!
\param pGUI pointer to GUI.
\param pLayout pointer to layout.
*/
void moveLayoutToFront(GUI* pGUI, Layout* pLayout);
//! Move layout to back. Is executed at update call.
/*!
\param pGUI pointer to GUI.
\param pLayout pointer to layout.
*/
void moveLayoutToBack(GUI* pGUI, Layout* pLayout);
//! Control layout's input usage.
/*!
\param pLayout pointer to layout.
\param useInput indicates whether layout may use input or ignore it.
*/
void setInputUsageOfLayout(Layout* pLayout, bool useInput);
//! Set visibility of layout.
/*!
\param pLayout pointer to layout.
\param visible is a bool value to set visibility.
\param reset indicates whether all elements in layout should be reset.
\param fade indicates, whether layer should fade.
*/
void setVisibilityOfLayout(
Layout* pLayout,
bool visible,
bool reset = false,
bool fade = false);
//! Getter for relative position and size of element. Values are relative in respect to layout.
/*!
\param pLayout pointer to layout.
\param id is the unique id of an element.
\return relative position and size of element. Filled with initial values if element not found.
*/
RelativePositionAndSize getRelativePositionAndSizeOfElement(
Layout* pLayout,
std::string id);
//! Getter for absolute pixel position and size of element. Values are in pixel space of GUI.
/*!
\param pLayout pointer to layout.
\param id is the unique id of an element.
\return absolute position and size of element. Filled with initial values if element not found.
*/
AbsolutePositionAndSize getAbsolutePositionAndSizeOfElement(
Layout* pLayout,
std::string id);
//! Activity of element.
/*!
\param pLayout pointer to layout.
\param id is the unique id of an element.
\param active indicates the state of acitvity.
\param fade indicates, whether activity should fade.
*/
void setElementActivity(
Layout* pLayout,
std::string id,
bool active,
bool fade = false);
//! Toggle activity of element.
/*!
\param pLayout pointer to layout.
\param id is the unique id of an element.
\param fade indicates, whether activity should fade.
*/
void toggleElementActivity(
Layout* pLayout,
std::string id,
bool fade = false);
//! Get activity of element.
/*!
\param pLayout pointer to layout.
\param id is the unique id of an element.
\return true if element with given id is active and false else
*/
bool isElementActive(Layout const * pLayout, std::string id);
//! Set whether element is dimming.
/*!
\param pLayout pointer to layout.
\param id is the unique id of an element.
\param dimming is the new choice.
*/
void setElementDimming(
Layout* pLayout,
std::string id,
bool dimming);
//! Set whether element is marking.
/*!
\param pLayout pointer to layout.
\param id is the unique id of an element.
\param marking is the new choice.
\param depth of children of this element, which are marked (or unmarked) too. Negative depth indicates, that all children are affected.
*/
void setElementMarking(
Layout* pLayout,
std::string id,
bool marking,
int depth = 0);
//! Set style of element.
/*!
\param pLayout pointer to layout.
\param id is the unique id of an element.
\param stlye is name of style in stylesheet of layout.
*/
void setStyleOfElement(
Layout* pLayout,
std::string id,
std::string style);
//! Get whether element is dimming.
/*!
\param pLayout pointer to layout.
\param id is the unique id of an element.
\return true if element with given id is dimming and false else.
*/
bool isElementDimming(Layout const * pLayout, std::string id);
//! Get whether element is marking.
/*!
\param pLayout pointer to layout.
\param id is the unique id of an element.
\return true if element with given id is marking and false else.
*/
bool isElementMarking(Layout const * pLayout, std::string id);
//! Set hiding of element.
/*!
\param pLayout pointer to layout.
\param id is the unique id of an element.
\param hidden should be true to hide element and false to unhide it.
*/
void setElementHiding(Layout* pLayout, std::string id, bool hidden);
//! Check for existence of id.
/*!
\param pLayout pointer to layout.
\param id is the unique id of an element.
\return true if element with given id is found and false else
*/
bool checkForId(Layout const * pLayout, std::string id);
//! Set interactive element as highlighted.
/*!
\param pLayout pointer to layout.
\param id is the unique id of an element.
\param doHighlight indicates, whether elemen with given id should be highlighted or not.
*/
void highlightInteractiveElement(
Layout* pLayout,
std::string id,
bool doHighlight);
//! Toggle highlighting of interactive element.
/*!
\param pLayout pointer to layout.
\param id is the unique id of an element.
*/
void toggleHighlightInteractiveElement(Layout* pLayout, std::string id);
//! Check whether interactive element is highlighted.
/*!
\param pLayout pointer to layout.
\param id is the unique id of an element.
\return true if interactive element with given id is highlighted.
*/
bool isInteractiveElementHighlighted(Layout const * pLayout, std::string id);
//! Sets value of style attribute.
/*!
\param pLayout pointer to layout.
\param styleName is name of style in used stylesheet.
\param attribute is name of attribute which shall be changed.
\param r is red color value.
\param g is green color value.
\param b is blue color value.
\param a is alpha color value.
*/
void setValueOfStyleAttribute(
Layout* pLayout,
std::string styleName,
std::string attribute,
float r,
float g,
float b,
float a);
//! Set icon of icon interactive element.
/*!
\param pLayout pointer to layout.
\param id is the unique id of an element.
\param iconFilepath path to image which should be used as icon.
*/
void setIconOfIconInteractiveElement(
Layout* pLayout,
std::string id,
std::string iconFilepath);
//! Interact with interactive element.
/*!
\param pLayout pointer to layout.
\param id is the unique id of an element.
*/
void interactWithInteractiveElement(Layout* pLayout, std::string id);
//! Select interactive element.
/*!
\param pLayout pointer to layout.
\param id is the unique id of an element.
*/
void selectInteractiveElement(Layout* pLayout, std::string id);
//! Deselect currently selected element.
/*!
\param pLayout pointer to layout.
*/
void deselectInteractiveElement(Layout* pLayout);
//! Interact with currently selected interactive element.
/*!
\param pLayout pointer to layout.
*/
void interactWithSelectedInteractiveElement(Layout* pLayout);
//! Select next interactive element, returns whether reached end of layout. If so, nothing is selected.
/*!
\param pLayout pointer to layout.
*/
bool selectNextInteractiveElement(Layout* pLayout);
//! Hit button.
/*!
\param pLayout pointer to layout.
\param id is the unique id of an element.
*/
void hitButton(Layout* pLayout, std::string id);
//! Button down.
/*!
\param pLayout pointer to layout.
\param id is the unique id of an element.
\param immediately indicates, whether animation is skipped or not.
*/
void buttonDown(Layout* pLayout, std::string id, bool immediately = false);
//! Button up.
/*!
\param pLayout pointer to layout.
\param id is the unique id of an element.
\param immediately indicates, whether animation is skipped or not.
*/
void buttonUp(Layout* pLayout, std::string id, bool immediately = false);
//! Is button a switch?
/*!
\param pLayout pointer to layout.
\param id is the unique id of an element.
\return true if element found by id exists, is a button and switch. Else false.
*/
bool isButtonSwitch(Layout const * pLayout, std::string id);
//! Penetrate sensor.
/*!
\param pLayout pointer to layout.
\param id is the unique id of an element.
\param amount is value of peneteration.
*/
void penetrateSensor(Layout* pLayout, std::string id, float amount);
//! Set content of text block. Works only if no key is used for localization.
/*!
\param pLayout pointer to layout.
\param id is the unique id of an element.
\param content is new content for text block as 16 bit string.
*/
void setContentOfTextBlock(Layout* pLayout, std::string id, std::u16string content);
//! Set content of text block. Works only if no key is used for localization.
/*!
\param pLayout pointer to layout.
\param id is the unique id of an element.
\param content is new content for text block as 8 bit string.
*/
void setContentOfTextBlock(Layout* pLayout, std::string id, std::string content);
//! Set key of text block. Works only if used localization file includes key.
/*!
\param pLayout pointer to layout.
\param id is the unique id of an element.
\param key is new key for text block.
*/
void setKeyOfTextBlock(Layout* pLayout, std::string id, std::string key);
//! Set fast typing for keyboard.
/*!
\param pLayout pointer to layout.
\param id is the unique id of an element.
\param useFastTyping indicates, whether fast typing should be used or not.
*/
void setFastTypingOfKeyboard(Layout* pLayout, std::string id, bool useFastTyping);
//! Set case of letters in keyboard.
/*!
\param pLayout pointer to layout.
\param id is the unique id of an element.
\param case indicates case of displayed letters.
*/
void setCaseOfKeyboard(Layout* pLayout, std::string id, KeyboardCase keyboardCase);
//! Get count of available keymaps in keyboard.
/*!
\param pLayout pointer to layout.
\param id is the unique id of an element.
\return count of keymaps
*/
unsigned int getCountOfKeymapsInKeyboard(Layout const * pLayout, std::string id);
//! Set keymap of keyboard by index.
/*!
\param pLayout pointer to layout.
\param id is the unique id of an element.
\param keymapIndex is index of keymap.
*/
void setKeymapOfKeyboard(Layout* pLayout, std::string id, unsigned int keymapIndex);
//! Register listener to button.
/*!
\param pLayout pointer to layout.
\param id is the unique id of an element.
\param wpListener is weak pointer to listener that should be registered.
*/
void registerButtonListener(
Layout* pLayout,
std::string id,
std::weak_ptr<ButtonListener> wpListener);
//! Register listener to sensor.
/*!
\param pLayout pointer to layout.
\param id is the unique id of an element.
\param wpListener is weak pointer to listener that should be registered.
*/
void registerSensorListener(
Layout* pLayout,
std::string id,
std::weak_ptr<SensorListener> wpListener);
//! Register listener to keyboard.
/*!
\param pLayout pointer to layout.
\param id is the unique id of an element.
\param wpListener is weak pointer to listener that should be registered.
*/
void registerKeyboardListener(
Layout* pLayout,
std::string id,
std::weak_ptr<KeyboardListener> wpListener);
//! Replace element with block.
/*!
\param pLayout pointer to layout.
\param id is the unique id of an element.
\param consumeInput indicates, whether block consumes given input.
\param backgroundFilepath is path to image rendered in background.
Use empty string to indicate no background image.
\param backgroundAlignment indicates alignment of background image.
\param fade indicates, whether replaced element should fade.
*/
void replaceElementWithBlock(
Layout* pLayout,
std::string id,
bool consumeInput,
std::string backgroundFilepath = "",
ImageAlignment backgroundAlignment = ImageAlignment::ZOOMED,
bool fade = false);
//! Replace element with picture.
/*!
\param pLayout pointer to layout.
\param id is the unique id of an element.
\param filepath is the path to the image used in the picture element.
\param alignment is the alignment of the picture.
\param fade indicates, whether replaced element should fade.
*/
void replaceElementWithPicture(
Layout* pLayout,
std::string id,
std::string filepath,
ImageAlignment alignment,
bool fade = false);
//! Replace element with blank.
/*!
\param pLayout pointer to layout.
\param id is the unique id of an element.
\param fade indicates, whether replaced element should fade.
*/
void replaceElementWithBlank(
Layout* pLayout,
std::string id,
bool fade = false);
//! Replace element with circle button.
/*!
\param pLayout pointer to layout.
\param id is the unique id of an element.
\param iconFilepath path to image which should be used as icon.
\param isSwitch indicates, whether button should be a switch.
\param fade indicates, whether replaced element should fade.
*/
void replaceElementWithCircleButton(
Layout* pLayout,
std::string id,
std::string iconFilepath,
bool isSwitch = false,
bool fade = false);
//! Replace element with box button.
/*!
\param pLayout pointer to layout.
\param id is the unique id of an element.
\param iconFilepath path to image which should be used as icon.
\param isSwitch indicates, whether button should be a switch.
\param fade indicates, whether replaced element should fade.
*/
void replaceElementWithBoxButton(
Layout* pLayout,
std::string id,
std::string iconFilepath,
bool isSwitch = false,
bool fade = false);
//! Replace element with sensor.
/*!
\param pLayout pointer to layout.
\param id is the unique id of an element.
\param iconFilepath path to image which should be used as icon.
\param fade indicates, whether replaced element should fade.
*/
void replaceElementWithSensor(
Layout* pLayout,
std::string id,
std::string iconFilepath,
bool fade = false);
//! Replace element with text block.
/*!
\param pLayout pointer to layout.
\param id is the unique id of an element.
\param consumeInput indicates, whether block consumes given input.
\param fontSize is size of used font.
\param alignment is alignment of text.
\param verticalAlignment is vertical alignment of text.
\param content is the content of the displayed text.
\param innerBorder is space between border and text.
\param textScale is scale of text.
\param key is used for localization.
\param backgroundFilepath is path to image rendered in background.
Use empty string to indicate no background image.
\param backgroundAlignment indicates alignment of background image.
\param fade indicates, whether replaced element should fade.
*/
void replaceElementWithTextBlock(
Layout* pLayout,
std::string id,
bool consumeInput,
FontSize fontSize,
TextFlowAlignment alignment,
TextFlowVerticalAlignment verticalAlignment,
std::u16string content,
float innerBorder = 0.0f,
float textScale = 1.0f,
std::string key = "",
std::string backgroundFilepath = "",
ImageAlignment backgroundAlignment = ImageAlignment::ZOOMED,
bool fade = false);
//! Replace element with brick.
/*!
\param pLayout pointer to layout.
\param id is the unique id of an element.
\param filepath is path to brick xml file.
\param fade indicates, whether replaced element should fade.
*/
void replaceElementWithBrick(
Layout* pLayout,
std::string id,
std::string filepath,
bool fade = false);
//! Replace element with brick.
/*!
\param pLayout pointer to layout.
\param id is the unique id of an element.
\param filepath is path to brick xml file.
\param idMapper changes ids inside brick to ones in map.
\param fade indicates, whether replaced element should fade.
*/
void replaceElementWithBrick(
Layout* pLayout,
std::string id,
std::string filepath,
std::map<std::string, std::string> idMapper,
bool fade = false);
//! Creates floating frame with brick inside
/*!
\param pLayout pointer to layout.
\param filepath is path to brick xml file.
\param relativePositionX initial relative x position.
\param relativePositionY initial relative y position.
\param relativeSizeX initial relative x size.
\param relativeSizeY initial relative y size.
\param visible indicates, whether frame should be visible or not.
\param fade indicates, whether frame should fade in.
\return index of created floating frame.
*/
unsigned int addFloatingFrameWithBrick(
Layout* pLayout,
std::string filepath,
float relativePositionX,
float relativePositionY,
float relativeSizeX,
float relativeSizeY,
bool visible = true,
bool fade = false);
//! Creates floating frame with brick inside
/*!
\param pLayout pointer to layout.
\param filepath is path to brick xml file.
\param relativePositionX initial relative x position.
\param relativePositionY initial relative y position.
\param relativeSizeX initial relative x size.
\param relativeSizeY initial relative y size.
\param idMapper changes ids inside brick to ones in map.
\param visible indicates, whether frame should be visible or not.
\param fade indicates, whether frame should fade in.
\return index of created floating frame.
*/
unsigned int addFloatingFrameWithBrick(
Layout* pLayout,
std::string filepath,
float relativePositionX,
float relativePositionY,
float relativeSizeX,
float relativeSizeY,
std::map<std::string, std::string> idMapper,
bool visible = true,
bool fade = false);
//! Set visibility of floating frame.
/*!
\param pLayout pointer to layout.
\param frameIndex index of frame in layout.
\param visible is a bool value to set visibility.
\param reset indicates whether all elements in layout should be reset.
\param fade indicates, whether frame should fade.
*/
void setVisibilityOFloatingfFrame(
Layout* pLayout,
unsigned int frameIndex,
bool visible,
bool reset = false,
bool fade = false);
//! Removes floating frame from layout.
/*!
\param pLayout pointer to layout.
\param frameIndex index of frame in layout.
\param fade indicates, whether floating frame should fade out.
*/
void removeFloatingFrame(
Layout* pLayout,
unsigned int frameIndex,
bool fade = false);
//! Translates floating frame
/*!
\param pLayout pointer to layout.
\param frameIndex index of frame in layout.
\param translateX amount of translation in x direction.
\param translateY amount of translation in y direction.
*/
void translateFloatingFrame(
Layout* pLayout,
unsigned int frameIndex,
float translateX,
float translateY);
//! Scales floating frame
/*!
\param pLayout pointer to layout.
\param frameIndex index of frame in layout.
\param scaleX scaling in x direction.
\param scaleY scaling in y direction.
*/
void scaleFloatingFrame(
Layout* pLayout,
unsigned int frameIndex,
float scaleX,
float scaleY);
//! Set relative position of floating frame
/*!
\param pLayout pointer to layout.
\param frameIndex index of frame in layout.
\param relativePositionX relative x position.
\param relativePositionY relative y position.
*/
void setPositionOfFloatingFrame(
Layout* pLayout,
unsigned int frameIndex,
float relativePositionX,
float relativePositionY);
//! Set relative size of floating frame
/*!
\param pLayout pointer to layout.
\param frameIndex index of frame in layout.
\param relativeSizeX relative x size.
\param relativeSizeY relative y size.
*/
void setSizeOfFloatingFrame(
Layout* pLayout,
unsigned int frameIndex,
float relativeSizeX,
float relativeSizeY);
//! Move frame to front.
/*!
\param pLayout pointer to layout.
\param frameIndex index of frame in layout.
*/
void moveFloatingFrameToFront(Layout* pLayout, unsigned int frameIndex);
//! Move frame to back.
/*!
\param pLayout pointer to layout.
\param frameIndex index of frame in layout.
*/
void moveFloatingFrameToBack(Layout* pLayout, unsigned int frameIndex);
//! Getter for relative position and size of floating frame. Values are relative in respect to layout.
/*!
\param pLayout pointer to layout.
\param frameIndex index of frame in layout.
\return relative position and size of floating frame. Filled with initial values if not found.
*/
RelativePositionAndSize getRelativePositionAndSizeOfFloatingFrame(
Layout* pLayout,
unsigned int frameIndex);
//! Getter for absolute pixel position and size of floating frame. Values are in pixel space of GUI.
/*!
\param pLayout pointer to layout.
\param id is the unique id of an element.
\return absolute position and size of floating frame. Filled with initial values if not found.
*/
AbsolutePositionAndSize getAbsolutePositionAndSizeOfFloatingFrame(
Layout* pLayout,
unsigned int frameIndex);
//! Set error callback function.
/*!
\param pCallbackFunction is function pointer to function which should be called back.
*/
void setErrorCallback(void(*pCallbackFunction)(std::string));
//! Set warning callback function.
/*!
\param pCallbackFunction is function pointer to function which should be called back.
*/
void setWarningCallback(void(*pCallbackFunction)(std::string));
//! Return string describing the version of the linked library.
/*!
\return version given as string.
*/
std::string getLibraryVersion();
//! Root filepath is the prefix used globally for ALL filepaths as prefix.
/*!
\param rootFilepath is used as prefix for used filepaths.
*/
void setRootFilepath(std::string rootFilepath);
}
#endif // EYE_GUI_H_