FabGL
ESP32 VGA Controller and Graphics Library
fabui.h
Go to the documentation of this file.
1 /*
2  Created by Fabrizio Di Vittorio (fdivitto2013@gmail.com) - <http://www.fabgl.com>
3  Copyright (c) 2019 Fabrizio Di Vittorio.
4  All rights reserved.
5 
6  This file is part of FabGL Library.
7 
8  FabGL is free software: you can redistribute it and/or modify
9  it under the terms of the GNU General Public License as published by
10  the Free Software Foundation, either version 3 of the License, or
11  (at your option) any later version.
12 
13  FabGL is distributed in the hope that it will be useful,
14  but WITHOUT ANY WARRANTY; without even the implied warranty of
15  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  GNU General Public License for more details.
17 
18  You should have received a copy of the GNU General Public License
19  along with FabGL. If not, see <http://www.gnu.org/licenses/>.
20  */
21 
22 
23 #pragma once
24 
25 
34 #include <stdint.h>
35 #include <stddef.h>
36 
37 #include "freertos/FreeRTOS.h"
38 #include "freertos/queue.h"
39 #include "freertos/timers.h"
40 
41 #include "fabglconf.h"
42 #include "fabutils.h"
43 #include "vgacontroller.h"
44 #include "canvas.h"
45 
46 
47 
48 /*
49 
50  *uiObject
51  *uiEvtHandler
52  *uiApp
53  *uiWindow
54  *uiFrame
55  *uiControl
56  *uiButton
57  *uiLabel
58  *uiImage
59  *uiPanel
60  *uiTextEdit
61  *uiScrollableControl
62  *uiPaintBox
63  *uiCustomListBox
64  *uiListBox
65  *uiFileBrowser
66  uiMemoEdit
67  *uiCheckBox
68  *uiComboBox
69  uiMenu
70  uiGauge
71  *uiSlider
72  uiSpinButton
73 
74 */
75 
76 
77 namespace fabgl {
78 
79 
80 
81 // increase in case of garbage between windows!
82 #define FABGLIB_UI_EVENTS_QUEUE_SIZE 256
83 
84 
85 
87 // uiEvent
88 
89 enum uiEventID {
90  UIEVT_NULL,
91  UIEVT_DEBUGMSG,
92  UIEVT_APPINIT,
93  UIEVT_GENPAINTEVENTS,
94  UIEVT_PAINT,
95  UIEVT_ACTIVATE,
96  UIEVT_DEACTIVATE,
97  UIEVT_MOUSEMOVE,
98  UIEVT_MOUSEWHEEL,
99  UIEVT_MOUSEBUTTONDOWN,
100  UIEVT_MOUSEBUTTONUP,
101  UIEVT_SETPOS,
102  UIEVT_SETSIZE,
103  UIEVT_RESHAPEWINDOW,
104  UIEVT_MOUSEENTER,
105  UIEVT_MOUSELEAVE,
106  UIEVT_MAXIMIZE, // Request for maximize
107  UIEVT_MINIMIZE, // Request for minimize
108  UIEVT_RESTORE, // Restore from UIEVT_MAXIMIZE or UIEVT_MINIMIZE
109  UIEVT_SHOW,
110  UIEVT_HIDE,
111  UIEVT_SETFOCUS,
112  UIEVT_KILLFOCUS,
113  UIEVT_KEYDOWN,
114  UIEVT_KEYUP,
115  UIEVT_TIMER,
116  UIEVT_CLICK,
117  UIEVT_DBLCLICK,
118  UIEVT_EXITMODAL,
119  UIEVT_DESTROY,
120  UIEVT_CLOSE, // Request to close (frame Close button)
121  UIEVT_QUIT, // Quit the application
122 };
123 
124 
125 class uiEvtHandler;
126 class uiApp;
127 class uiWindow;
128 
129 
130 typedef void * uiTimerHandle;
131 
132 
136  uint8_t LALT : 1;
137  uint8_t RALT : 1;
138  uint8_t CTRL : 1;
139  uint8_t SHIFT : 1;
140  uint8_t GUI : 1;
141 };
142 
143 
147  uint8_t changedButton;
148 };
149 
150 
151 struct uiEvent {
152  uiEvtHandler * dest;
153  uiEventID id;
154 
155  union uiEventParams {
156  // event: UIEVT_MOUSEMOVE, UIEVT_MOUSEWHEEL, UIEVT_MOUSEBUTTONDOWN, UIEVT_MOUSEBUTTONUP, UIEVT_CLICK, UIEVT_DBLCLICK
157  uiMouseEventInfo mouse;
158  // event: UIEVT_PAINT, UIEVT_GENPAINTEVENTS, UIEVT_RESHAPEWINDOW
159  Rect rect;
160  // event: UIEVT_SETPOS
161  Point pos;
162  // event: UIEVT_SETSIZE
163  Size size;
164  // event: UIEVT_DEBUGMSG
165  char const * debugMsg;
166  // event: UIEVT_KEYDOWN, UIEVT_KEYUP
167  uiKeyEventInfo key;
168  // event: UIEVT_TIMER
169  uiTimerHandle timerHandle;
170  // event: UIEVT_EXITMODAL
171  int modalResult;
172  // event: UIEVT_SETFOCUS
173  uiWindow * oldFocused;
174  // event: UIEVT_KILLFOCUS
175  uiWindow * newFocused;
176  // event: UIEVT_QUIT
177  int exitCode;
178 
179  uiEventParams() { }
180  } params;
181 
182  uiEvent() : dest(nullptr), id(UIEVT_NULL) { }
183  uiEvent(uiEvent const & e) { dest = e.dest; id = e.id; params = e.params; }
184  uiEvent(uiEvtHandler * dest_, uiEventID id_) : dest(dest_), id(id_) { }
185 };
186 
187 
188 
192 enum class uiOrientation {
193  Vertical,
194  Horizontal,
195 };
196 
197 
198 
200 // uiObject
201 
202 
204 struct uiObjectType {
205  uint32_t uiApp : 1;
206  uint32_t uiEvtHandler : 1;
207  uint32_t uiWindow : 1;
208  uint32_t uiFrame : 1;
209  uint32_t uiControl : 1;
210  uint32_t uiScrollableControl : 1;
211  uint32_t uiButton : 1;
212  uint32_t uiTextEdit : 1;
213  uint32_t uiLabel : 1;
214  uint32_t uiImage : 1;
215  uint32_t uiPanel : 1;
216  uint32_t uiPaintBox : 1;
217  uint32_t uiCustomListBox : 1;
218  uint32_t uiListBox : 1;
219  uint32_t uiFileBrowser : 1;
220  uint32_t uiComboBox : 1;
221  uint32_t uiCheckBox : 1;
222  uint32_t uiSlider : 1;
223 
226  { }
227 };
228 
229 
231 class uiObject {
232 
233 public:
234 
235  uiObject();
236 
237  virtual ~uiObject();
238 
244  uiObjectType & objectType() { return m_objectType; }
245 
246 private:
247  uiObjectType m_objectType;
248 };
249 
250 
251 
253 // uiEvtHandler
254 
255 
257 class uiEvtHandler : public uiObject {
258 
259 public:
260 
262 
263  virtual ~uiEvtHandler();
264 
265  virtual void processEvent(uiEvent * event);
266 
272  uiApp * app() { return m_app; }
273 
274 
275 protected:
276 
277  void setApp(uiApp * value) { m_app = value; }
278 
279 
280 private:
281 
282  uiApp * m_app;
283 };
284 
285 
286 
288 // uiWindow
289 
293 enum class uiOrigin {
294  Screen,
295  Parent,
296  Window,
297 };
298 
299 
302  uint8_t visible : 1;
303  uint8_t maximized : 1;
304  uint8_t minimized : 1;
305  uint8_t active : 1;
306 };
307 
308 
311  uint8_t activable : 1;
312  uint8_t focusable : 1;
314  uiWindowProps() :
315  activable(true),
316  focusable(false)
317  { }
318 };
319 
320 
324  RGB borderColor = RGB(2, 2, 2);
325  RGB activeBorderColor = RGB(2, 2, 3);
327  uint8_t borderSize = 3;
328  uint8_t focusedBorderSize = 1;
329 };
330 
331 
333 struct uiAnchors {
334  uint8_t left : 1;
335  uint8_t top : 1;
336  uint8_t right : 1;
337  uint8_t bottom : 1;
339  uiAnchors() : left(true), top(true), right(false), bottom(false) { }
340 };
341 
342 
344 class uiWindow : public uiEvtHandler {
345 
346 friend class uiApp;
347 
348 public:
349 
358  uiWindow(uiWindow * parent, const Point & pos, const Size & size, bool visible);
359 
360  virtual ~uiWindow();
361 
362  virtual void processEvent(uiEvent * event);
363 
371  uiWindow * next() { return m_next; }
372 
380  uiWindow * prev() { return m_prev; }
381 
387  uiWindow * firstChild() { return m_firstChild; }
388 
394  uiWindow * lastChild() { return m_lastChild; }
395 
401  bool hasChildren() { return m_firstChild != nullptr; }
402 
406  void bringOnTop();
407 
413  void bringAfter(uiWindow * insertionPoint);
414 
422  Point pos() { return m_pos; }
423 
429  Point clientPos();
430 
438  Size size() { return m_size; }
439 
445  Size clientSize();
446 
456  Rect rect(uiOrigin origin);
457 
465  virtual Rect clientRect(uiOrigin origin);
466 
474  uiWindowState state() { return m_state; }
475 
481  uiWindowProps & windowProps() { return m_windowProps; }
482 
488  uiWindowStyle & windowStyle() { return m_windowStyle; }
489 
495  uiWindow * parent() { return m_parent; }
496 
502  Point mouseDownPos() { return m_mouseDownPos; }
503 
512  Rect transformRect(Rect const & rect, uiWindow * baseWindow);
513 
519  void repaint(Rect const & rect);
520 
524  void repaint();
525 
533  bool isMouseOver() { return m_isMouseOver; }
534 
542  void exitModal(int modalResult);
543 
551  bool hasFocus();
552 
558  uiAnchors & anchors() { return m_anchors; }
559 
565  void setFocusIndex(int value) { m_focusIndex = value; }
566 
574  int focusIndex() { return m_focusIndex; }
575 
576 
577  // Delegates
578 
584  Delegate<> onClick;
585 
592  Delegate<> onDblClick;
593 
594 
595 protected:
596 
597  void addChild(uiWindow * child);
598  void insertAfter(uiWindow * child, uiWindow * underlyingChild);
599  void freeChildren();
600  void removeChild(uiWindow * child, bool freeChild = true);
601  void moveChildOnTop(uiWindow * child);
602  void moveAfter(uiWindow * child, uiWindow * underlyingChild);
603  bool isChild(uiWindow * window);
604 
605  Size sizeAtMouseDown() { return m_sizeAtMouseDown; }
606  Point posAtMouseDown() { return m_posAtMouseDown; }
607 
608  virtual Size minWindowSize() { return Size(0, 0); }
609 
610  void beginPaint(uiEvent * paintEvent, Rect const & clippingRect);
611 
612  void generatePaintEvents(Rect const & paintRect);
613  void reshape(Rect const & r);
614 
615  bool isFocusable();
616 
617 private:
618 
619  void paintWindow();
620  uiWindow * getChildWithFocusIndex(int focusIndex, int * maxIndex);
621 
622 
623  uiWindow * m_parent;
624 
625  Point m_pos;
626  Size m_size;
627 
628  // saved screen rect before Maximize or Minimize
629  Rect m_savedScreenRect;
630 
631  uiWindowState m_state;
632 
633  uiWindowProps m_windowProps;
634 
635  uiWindowStyle m_windowStyle;
636 
637  Point m_mouseDownPos; // mouse position when mouse down event has been received
638 
639  Point m_posAtMouseDown; // used to resize
640  Size m_sizeAtMouseDown; // used to resize
641 
642  bool m_isMouseOver; // true after mouse entered, false after mouse left
643 
644  uiAnchors m_anchors;
645 
646  int16_t m_focusIndex; // -1 = doesn't partecipate to focus trip
647 
648  // double linked list, order is: bottom (first items) -> up (last items)
649  uiWindow * m_next;
650  uiWindow * m_prev;
651  uiWindow * m_firstChild;
652  uiWindow * m_lastChild;
653 };
654 
655 
656 
658 // uiFrame
659 
660 
664 struct uiFrameStyle {
665  RGB backgroundColor = RGB(3, 3, 3);
668  RGB titleColor = RGB(0, 0, 0);
669  RGB activeTitleColor = RGB(0, 0, 0);
670  FontInfo const * titleFont = Canvas.getPresetFontInfoFromHeight(12, false);
671  RGB buttonColor = RGB(1, 1, 1);
672  RGB activeButtonColor = RGB(0, 0, 0);
675 };
676 
677 
681 struct uiFrameProps {
682  uint8_t resizeable : 1;
683  uint8_t moveable : 1;
684  uint8_t hasCloseButton : 1;
685  uint8_t hasMaximizeButton : 1;
686  uint8_t hasMinimizeButton : 1;
688  uiFrameProps() :
689  resizeable(true),
690  moveable(true),
691  hasCloseButton(true),
692  hasMaximizeButton(true),
693  hasMinimizeButton(true)
694  { }
695 };
696 
697 
698 enum class uiFrameItem : uint8_t {
699  None,
700  MoveArea,
701  TopLeftResize,
702  TopCenterResize,
703  TopRightResize,
704  CenterLeftResize,
705  CenterRightResize,
706  BottomLeftResize,
707  BottomCenterResize,
708  BottomRightResize,
709  CloseButton,
710  MaximizeButton,
711  MinimizeButton,
712 };
713 
714 
718 class uiFrame : public uiWindow {
719 
720 public:
721 
731  uiFrame(uiWindow * parent, char const * title, const Point & pos, const Size & size, bool visible = true);
732 
733  virtual ~uiFrame();
734 
735  virtual void processEvent(uiEvent * event);
736 
742  char const * title() { return m_title; }
743 
751  void setTitle(char const * value);
752 
760  void setTitleFmt(const char *format, ...);
761 
767  uiFrameStyle & frameStyle() { return m_frameStyle; }
768 
774  uiFrameProps & frameProps() { return m_frameProps; }
775 
776  Rect clientRect(uiOrigin origin);
777 
778 
779  // Delegates
780 
786  Delegate<> onShow;
787 
793  Delegate<> onHide;
794 
800  Delegate<> onResize;
801 
808  Delegate<uiTimerHandle> onTimer;
809 
813  Delegate<uiKeyEventInfo> onKeyDown;
814 
818  Delegate<uiKeyEventInfo> onKeyUp;
819 
823  Delegate<> onPaint;
824 
825 
826 protected:
827 
828  Size minWindowSize();
829  int titleBarHeight();
830  Rect titleBarRect();
831 
832 private:
833 
834  void paintFrame();
835  int paintButtons(Rect const & bkgRect);
836  void movingCapturedMouse(int mouseX, int mouseY, bool mouseIsDown);
837  void movingFreeMouse(int mouseX, int mouseY);
838  uiFrameItem getFrameItemAt(int x, int y);
839  Rect getBtnRect(int buttonIndex);
840  void handleButtonsClick(int x, int y, bool doubleClick);
841  void drawTextWithEllipsis(FontInfo const * fontInfo, int X, int Y, char const * text, int maxX);
842  void drawReshapingBox(Rect boxRect);
843 
844 
845  static constexpr int CORNERSENSE = 10;
846 
847 
848  uiFrameStyle m_frameStyle;
849 
850  uiFrameProps m_frameProps;
851 
852  char * m_title;
853  int m_titleLength;
854 
855  uiFrameItem m_mouseDownFrameItem; // frame item on mouse down
856  uiFrameItem m_mouseMoveFrameItem; // frame item on mouse move
857 
858  Rect m_lastReshapingBox; // last reshaping box painted by drawReshapingBox(), (0,0,0,0) if there isn't any
859 
860 };
861 
862 
863 
865 // uiControl
866 
867 
871 class uiControl : public uiWindow {
872 
873 public:
874 
883  uiControl(uiWindow * parent, const Point & pos, const Size & size, bool visible);
884 
885  virtual ~uiControl();
886 
887  virtual void processEvent(uiEvent * event);
888 };
889 
890 
891 
893 // uiScrollableControl
894 
895 
901  uint8_t scrollBarSize = 11;
902 };
903 
904 
905 enum class uiScrollBarItem {
906  None,
907  LeftButton,
908  RightButton,
909  TopButton,
910  BottomButton,
911  HBar,
912  VBar,
913  PageUp,
914  PageDown,
915  PageLeft,
916  PageRight,
917 };
918 
919 
924 
925 public:
926 
935  uiScrollableControl(uiWindow * parent, const Point & pos, const Size & size, bool visible = true);
936 
937  virtual ~uiScrollableControl();
938 
939  virtual void processEvent(uiEvent * event);
940 
941  Rect clientRect(uiOrigin origin);
942 
948  uiScrollableControlStyle & scrollableControlStyle() { return m_scrollableControlStyle; }
949 
958  int HScrollBarPos() { return m_HScrollBarPosition; }
959 
967  int HScrollBarVisible() { return m_HScrollBarVisible; }
968 
977  int HScrollBarRange() { return m_HScrollBarRange; }
978 
987  int VScrollBarPos() { return m_VScrollBarPosition; }
988 
996  int VScrollBarVisible() { return m_VScrollBarVisible; }
997 
1006  int VScrollBarRange() { return m_VScrollBarRange; }
1007 
1008 
1009  // Delegates
1010 
1015 
1020 
1021 
1022 protected:
1023 
1033  virtual void setScrollBar(uiOrientation orientation, int position, int visible, int range, bool repaintScrollbar = true);
1034 
1035 
1036 private:
1037 
1038  void paintScrollableControl();
1039  void paintScrollBars();
1040  Rect getVScrollBarRects(Rect * topButton = nullptr, Rect * bottonButton = nullptr, Rect * bar = nullptr);
1041  Rect getHScrollBarRects(Rect * leftButton = nullptr, Rect * rightButton = nullptr, Rect * bar = nullptr);
1042  uiScrollBarItem getItemAt(int x, int y);
1043  void repaintScrollBar(uiOrientation orientation);
1044  void handleFreeMouseMove(int mouseX, int mouseY);
1045  void handleCapturedMouseMove(int mouseX, int mouseY);
1046  void handleButtonsScroll();
1047  void handlePageScroll();
1048 
1049  uiScrollableControlStyle m_scrollableControlStyle;
1050 
1051  int16_t m_HScrollBarPosition;
1052  int16_t m_HScrollBarVisible; // it means the "visible" area (how big is the bar)
1053  int16_t m_HScrollBarRange;
1054  int16_t m_VScrollBarPosition;
1055  int16_t m_VScrollBarVisible; // it means the "visible" area (how big is the bar)
1056  int16_t m_VScrollBarRange;
1057 
1058  // values updated by getVScrollBarRects() and getHScrollBarRects()
1059  int16_t m_HBarArea;
1060  int16_t m_VBarArea;
1061 
1062  int16_t m_mouseDownHScrollBarPosition;
1063  int16_t m_mouseDownVScrollBarPosition;
1064 
1065  uiScrollBarItem m_mouseOverItem;
1066 
1067  // a timer is active while mouse is down and the mouse is over a button
1068  uiTimerHandle m_scrollTimer;
1069 };
1070 
1071 
1072 
1074 // uiButton
1075 
1076 
1079  RGB backgroundColor = RGB(2, 2, 2);
1083  RGB textColor = RGB(0, 0, 0);
1084  FontInfo const * textFont = Canvas.getPresetFontInfoFromHeight(14, false);
1085  uint8_t bitmapTextSpace = 4;
1086  Bitmap const * bitmap = nullptr;
1087  Bitmap const * downBitmap = nullptr;
1088 };
1089 
1090 
1094 enum class uiButtonKind {
1095  Button,
1096  Switch,
1097 };
1098 
1099 
1101 class uiButton : public uiControl {
1102 
1103 public:
1104 
1115  uiButton(uiWindow * parent, char const * text, const Point & pos, const Size & size, uiButtonKind kind = uiButtonKind::Button, bool visible = true);
1116 
1117  virtual ~uiButton();
1118 
1119  virtual void processEvent(uiEvent * event);
1120 
1128  void setText(char const * value);
1129 
1135  char const * text() { return m_text; }
1136 
1142  uiButtonStyle & buttonStyle() { return m_buttonStyle; }
1143 
1151  bool down() { return m_down; }
1152 
1160  void setDown(bool value);
1161 
1162 
1163  // Delegates
1164 
1170  Delegate<> onChange;
1171 
1172 
1173 private:
1174 
1175  void paintButton();
1176  void paintContent(Rect const & rect);
1177 
1178  void trigger();
1179 
1180 
1181  uiButtonStyle m_buttonStyle;
1182 
1183  char * m_text;
1184  int m_textExtent; // calculated by setText(). TODO: changing font doesn't update m_textExtent!
1185 
1186  bool m_down;
1187 
1188  uiButtonKind m_kind;
1189 
1190 };
1191 
1192 
1193 
1195 // uiTextEdit
1196 // single line text edit
1197 
1198 
1205  RGB backgroundColor = RGB(2, 2, 2);
1208  RGB textColor = RGB(0, 0, 0);
1209  FontInfo const * textFont = Canvas.getPresetFontInfoFromHeight(14, false);
1210 };
1211 
1212 
1217  uint8_t hasCaret : 1;
1218  uint8_t allowEdit : 1;
1220  uiTextEditProps()
1221  : hasCaret(true),
1222  allowEdit(true)
1223  {
1224  }
1225 };
1226 
1227 
1233 class uiTextEdit : public uiControl {
1234 
1235 public:
1236 
1246  uiTextEdit(uiWindow * parent, char const * text, const Point & pos, const Size & size, bool visible = true);
1247 
1248  virtual ~uiTextEdit();
1249 
1250  virtual void processEvent(uiEvent * event);
1251 
1257  uiTextEditStyle & textEditStyle() { return m_textEditStyle; }
1258 
1264  uiTextEditProps & textEditProps() { return m_textEditProps; }
1265 
1273  void setText(char const * value);
1274 
1280  char const * text() { return m_text; }
1281 
1282 
1283  // Delegates
1284 
1288  Delegate<> onChange;
1289 
1290 
1291 protected:
1292 
1293  virtual Rect getEditRect();
1294 
1295 private:
1296 
1297  void paintTextEdit();
1298  void paintContent();
1299 
1300  uint8_t const * getCharInfo(char ch, int * width);
1301  int charColumnToWindowX(int col);
1302  void updateCaret();
1303  void moveCursor(int col, int selCol);
1304  int getColFromMouseX(int mouseX);
1305  void handleKeyDown(uiKeyEventInfo key);
1306  void checkAllocatedSpace(int requiredLength);
1307  void insert(char c);
1308  void removeSel();
1309  int getWordPosAtLeft();
1310  int getWordPosAtRight();
1311  void selectWordAt(int mouseX);
1312 
1313 
1314  uiTextEditStyle m_textEditStyle;
1315  uiTextEditProps m_textEditProps;
1316 
1317  char * m_text;
1318  int m_textLength; // text length NOT including ending zero
1319  int m_textSpace; // actual space allocated including ending zero
1320 
1321  // rectangle where text will be painted (this is also the text clipping rect)
1322  Rect m_contentRect; // updated on painting
1323 
1324  // where text starts to be painted. Values less than m_contentRect.X1 are used to show characters which do not fit in m_contentRect
1325  int m_viewX;
1326 
1327  // character index of cursor position (0 = at first char)
1328  int m_cursorCol;
1329 
1330  // character index at start of selection (not included if < m_cursorCol, included if > m_cursorCol)
1331  int m_selCursorCol;
1332 
1333 };
1334 
1335 
1336 
1338 // uiLabel
1339 
1340 
1343  FontInfo const * textFont = Canvas.getPresetFontInfoFromHeight(14, false);
1344  RGB backgroundColor = RGB(3, 3, 3);
1345  RGB textColor = RGB(0, 0, 0);
1346 };
1347 
1348 
1350 class uiLabel : public uiControl {
1351 
1352 public:
1353 
1363  uiLabel(uiWindow * parent, char const * text, const Point & pos, const Size & size = Size(0, 0), bool visible = true);
1364 
1365  virtual ~uiLabel();
1366 
1367  virtual void processEvent(uiEvent * event);
1368 
1376  void setText(char const * value);
1377 
1385  void setTextFmt(const char *format, ...);
1386 
1392  char const * text() { return m_text; }
1393 
1399  uiLabelStyle & labelStyle() { return m_labelStyle; }
1400 
1406  void update();
1407 
1408 
1409 private:
1410 
1411  void paintLabel();
1412 
1413 
1414  char * m_text;
1415 
1416  uiLabelStyle m_labelStyle;
1417 
1418  uint16_t m_textExtent; // calculated by setText()
1419 
1420  uint8_t m_autoSize;
1421 
1422 };
1423 
1424 
1425 
1427 // uiImage
1428 
1429 
1432  RGB backgroundColor = RGB(3, 3, 3);
1433 };
1434 
1435 
1437 class uiImage : public uiControl {
1438 
1439 public:
1440 
1450  uiImage(uiWindow * parent, Bitmap const * bitmap, const Point & pos, const Size & size = Size(0, 0), bool visible = true);
1451 
1452  virtual ~uiImage();
1453 
1454  virtual void processEvent(uiEvent * event);
1455 
1463  void setBitmap(Bitmap const * bitmap);
1464 
1470  Bitmap const * bitmap() { return m_bitmap; }
1471 
1477  uiImageStyle & imageStyle() { return m_imageStyle; }
1478 
1479 
1480 private:
1481 
1482  void paintImage();
1483 
1484 
1485  Bitmap const * m_bitmap;
1486 
1487  uiImageStyle m_imageStyle;
1488 
1489  bool m_autoSize;
1490 
1491 };
1492 
1493 
1494 
1496 // uiPanel
1497 
1498 
1501  RGB backgroundColor = RGB(2, 2, 2);
1502 };
1503 
1504 
1506 class uiPanel : public uiControl {
1507 
1508 public:
1509 
1518  uiPanel(uiWindow * parent, const Point & pos, const Size & size, bool visible = true);
1519 
1520  virtual ~uiPanel();
1521 
1522  virtual void processEvent(uiEvent * event);
1523 
1529  uiPanelStyle & panelStyle() { return m_panelStyle; }
1530 
1531 
1532 private:
1533 
1534  void paintPanel();
1535 
1536 
1537  uiPanelStyle m_panelStyle;
1538 };
1539 
1540 
1541 
1543 // uiPaintBox
1544 
1545 
1548  RGB backgroundColor = RGB(2, 2, 2);
1549 };
1550 
1551 
1554 
1555 public:
1556 
1565  uiPaintBox(uiWindow * parent, const Point & pos, const Size & size, bool visible = true);
1566 
1567  virtual ~uiPaintBox();
1568 
1569  virtual void processEvent(uiEvent * event);
1570 
1576  uiPaintBoxStyle & paintBoxStyle() { return m_paintBoxStyle; }
1577 
1579 
1580  // Delegates
1581 
1587  Delegate<Rect> onPaint;
1588 
1589 
1590 private:
1591 
1592  void paintPaintBox();
1593 
1594 
1595  uiPaintBoxStyle m_paintBoxStyle;
1596 };
1597 
1598 
1599 
1601 // uiCustomListBox
1602 
1603 
1606  RGB backgroundColor = RGB(2, 2, 2);
1610  int itemHeight = 16;
1611  FontInfo const * textFont = Canvas.getPresetFontInfoFromHeight(14, false);
1612  RGB textColor = RGB(0, 0, 0);
1614 };
1615 
1616 
1619 
1620 public:
1621 
1630  uiCustomListBox(uiWindow * parent, const Point & pos, const Size & size, bool visible = true);
1631 
1632  virtual ~uiCustomListBox();
1633 
1634  virtual void processEvent(uiEvent * event);
1635 
1641  uiListBoxStyle & listBoxStyle() { return m_listBoxStyle; }
1642 
1648  int firstSelectedItem();
1649 
1655  int lastSelectedItem();
1656 
1664  void selectItem(int index, bool add = false, bool range = false);
1665 
1669  void deselectAll();
1670 
1671 
1672  // Delegates
1673 
1679  Delegate<> onChange;
1680 
1684  Delegate<> onKillFocus;
1685 
1689  Delegate<uiKeyEventInfo> onKeyUp;
1690 
1691 
1692 protected:
1693 
1694  void setScrollBar(uiOrientation orientation, int position, int visible, int range, bool repaintScrollbar);
1695 
1696  // must be implemented by inherited class
1697  virtual int items_getCount() = 0;
1698  virtual void items_deselectAll() = 0;
1699  virtual void items_select(int index, bool select) = 0;
1700  virtual bool items_selected(int index) = 0;
1701  virtual void items_draw(int index, const Rect & itemRect) = 0;
1702 
1703 private:
1704 
1705  void paintListBox();
1706  int getItemAtMousePos(int mouseX, int mouseY);
1707  void handleMouseDown(int mouseX, int mouseY);
1708  void handleKeyDown(uiKeyEventInfo key);
1709  void makeItemVisible(int index);
1710 
1711 
1712  uiListBoxStyle m_listBoxStyle;
1713  int m_firstVisibleItem; // the item on the top
1714 };
1715 
1716 
1717 
1719 // uiListBox
1720 
1722 class uiListBox : public uiCustomListBox {
1723 
1724 public:
1725 
1734  uiListBox(uiWindow * parent, const Point & pos, const Size & size, bool visible = true);
1735 
1744  StringList & items() { return m_items; }
1745 
1746 protected:
1747 
1748  virtual int items_getCount() { return m_items.count(); }
1749  virtual void items_deselectAll() { m_items.deselectAll(); }
1750  virtual void items_select(int index, bool select) { m_items.select(index, select); }
1751  virtual bool items_selected(int index) { return m_items.selected(index); }
1752  virtual void items_draw(int index, const Rect & itemRect);
1753 
1754 
1755 private:
1756 
1757  StringList m_items;
1758 };
1759 
1760 
1762 // uiFileBrowser
1763 
1766 
1767 public:
1768 
1777  uiFileBrowser(uiWindow * parent, const Point & pos, const Size & size, bool visible = true);
1778 
1786  void setDirectory(char const * path);
1787 
1793  char const * directory() { return m_dir.directory(); }
1794 
1800  int count() { return m_dir.count(); }
1801 
1807  char const * filename();
1808 
1814  bool isDirectory();
1815 
1816  void processEvent(uiEvent * event);
1817 
1821  void update();
1822 
1828  FileBrowser & content() { return m_dir; }
1829 
1830 
1831 protected:
1832 
1833  virtual int items_getCount() { return m_dir.count(); }
1834  virtual void items_deselectAll() { m_selected = -1; }
1835  virtual void items_select(int index, bool select);
1836  virtual bool items_selected(int index) { return index == m_selected; }
1837  virtual void items_draw(int index, const Rect & itemRect);
1838 
1839 private:
1840 
1841  void enterSubDir();
1842 
1843  FileBrowser m_dir;
1844  int m_selected; // -1 = no sel
1845 
1846 };
1847 
1848 
1849 
1851 // uiComboBox
1852 
1853 
1857  RGB buttonColor = RGB(2, 2, 2);
1858 };
1859 
1860 
1863  uint8_t openOnFocus : 1;
1865  uiComboBoxProps()
1866  : openOnFocus(true)
1867  {
1868  }
1869 };
1870 
1871 
1873 class uiComboBox : public uiTextEdit
1874 {
1875 
1876 public:
1877 
1887  uiComboBox(uiWindow * parent, const Point & pos, const Size & size, int listHeight, bool visible = true);
1888 
1889  ~uiComboBox();
1890 
1891  virtual void processEvent(uiEvent * event);
1892 
1900  StringList & items() { return m_listBox->items(); }
1901 
1907  uiComboBoxStyle & comboBoxStyle() { return m_comboBoxStyle; }
1908 
1914  uiListBoxStyle & listBoxStyle() { return m_listBox->listBoxStyle(); }
1915 
1921  uiComboBoxProps & comboBoxProps() { return m_comboBoxProps; }
1922 
1928  int selectedItem() { return m_listBox->firstSelectedItem(); }
1929 
1935  void selectItem(int index);
1936 
1937 
1938  // Delegates
1939 
1945  Delegate<> onChange;
1946 
1947 
1948 protected:
1949 
1950  virtual Rect getEditRect();
1951 
1952 
1953 private:
1954 
1955  void paintComboBox();
1956  Rect getButtonRect();
1957  int buttonWidth();
1958  void openListBox();
1959  void closeListBox();
1960  void switchListBox();
1961  void updateTextEdit();
1962 
1963 
1964  uiListBox * m_listBox;
1965  int m_listHeight;
1966  uiComboBoxStyle m_comboBoxStyle;
1967  uiComboBoxProps m_comboBoxProps;
1968 
1969 
1970 };
1971 
1972 
1973 
1975 // uiCheckBox
1976 
1977 
1980  RGB backgroundColor = RGB(2, 2, 2);
1983  RGB foregroundColor = RGB(0, 0, 0);
1984 };
1985 
1986 
1990 enum class uiCheckBoxKind : int8_t {
1991  CheckBox,
1992  RadioButton,
1993 };
1994 
1995 
2002 class uiCheckBox : public uiControl {
2003 
2004 public:
2005 
2015  uiCheckBox(uiWindow * parent, const Point & pos, const Size & size, uiCheckBoxKind kind = uiCheckBoxKind::CheckBox, bool visible = true);
2016 
2017  virtual ~uiCheckBox();
2018 
2019  virtual void processEvent(uiEvent * event);
2020 
2026  uiCheckBoxStyle & checkBoxStyle() { return m_checkBoxStyle; }
2027 
2033  bool checked() { return m_checked; }
2034 
2042  void setChecked(bool value);
2043 
2049  int groupIndex() { return m_groupIndex; }
2050 
2056  void setGroupIndex(int value) { m_groupIndex = value; }
2057 
2058 
2059  // Delegates
2060 
2066  Delegate<> onChange;
2067 
2068 
2069 private:
2070 
2071  void paintCheckBox();
2072  void trigger();
2073  void unCheckGroup();
2074 
2075 
2076  uiCheckBoxStyle m_checkBoxStyle;
2077  bool m_checked;
2078  uiCheckBoxKind m_kind;
2079  int16_t m_groupIndex; // -1 = no group
2080 
2081 };
2082 
2083 
2084 
2086 // uiSlider
2087 
2088 
2091  RGB backgroundColor = RGB(3, 3, 3);
2092  RGB slideColor = RGB(0, 2, 2);
2093  RGB rangeColor = RGB(0, 2, 3);
2094  RGB gripColor = RGB(0, 0, 3);
2095  RGB ticksColor = RGB(3, 3, 3);
2096 };
2097 
2098 
2100 class uiSlider : public uiControl {
2101 
2102 public:
2103 
2113  uiSlider(uiWindow * parent, const Point & pos, const Size & size, uiOrientation orientation, bool visible = true);
2114 
2115  virtual ~uiSlider();
2116 
2117  virtual void processEvent(uiEvent * event);
2118 
2124  uiSliderStyle & sliderStyle() { return m_sliderStyle; }
2125 
2131  int position() { return m_position; }
2132 
2138  void setPosition(int value);
2139 
2145  int min() { return m_min; }
2146 
2152  int max() { return m_max; }
2153 
2161  void setup(int min, int max, int ticksFrequency);
2162 
2163 
2169  Delegate<> onChange;
2170 
2171 
2172 private:
2173 
2174  void paintSlider();
2175  Rect getGripRect();
2176  void moveGripTo(int x, int y);
2177  void handleKeyDown(uiKeyEventInfo key);
2178 
2179 
2180  uiSliderStyle m_sliderStyle;
2181  uiOrientation m_orientation;
2182 
2183  int16_t m_position;
2184  int16_t m_min;
2185  int16_t m_max;
2186  int16_t m_ticksFrequency;
2187 };
2188 
2189 
2190 
2191 
2192 
2194 // uiApp
2195 
2196 
2198 struct uiAppProps {
2199  uint16_t caretBlinkingTime = 500;
2200  uint16_t doubleClickTime = 250;
2201  bool realtimeReshaping = false;
2202 };
2203 
2204 
2209  Cancel,
2210  Button1,
2211  Button2,
2212  Button3,
2213 };
2214 
2215 
2219 enum class uiMessageBoxIcon {
2220  None,
2221  Question,
2222  Info,
2223  Warning,
2224  Error,
2225 };
2226 
2227 
2228 struct ModalWindowState {
2229  uiWindow * window;
2230  uiWindow * prevFocusedWindow;
2231  uiWindow * prevActiveWindow;
2232  uiWindow * prevModal;
2233  int modalResult;
2234 };
2235 
2236 
2237 
2244 class uiApp : public uiEvtHandler {
2245 
2246 public:
2247 
2248  uiApp();
2249 
2250  virtual ~uiApp();
2251 
2259  int run();
2260 
2266  void quit(int exitCode);
2267 
2275  bool postEvent(uiEvent const * event);
2276 
2284  bool insertEvent(uiEvent const * event);
2285 
2286  void postDebugMsg(char const * msg);
2287 
2288  virtual void processEvent(uiEvent * event);
2289 
2295  void processEvents();
2296 
2305  uiFrame * rootWindow() { return m_rootWindow; }
2306 
2315  uiWindow * activeWindow() { return m_activeWindow; }
2316 
2326  uiWindow * setActiveWindow(uiWindow * value);
2327 
2340  uiWindow * focusedWindow() { return m_focusedWindow; }
2341 
2352  uiWindow * setFocusedWindow(uiWindow * value);
2353 
2364  uiWindow * moveFocus(int delta);
2365 
2366  void captureMouse(uiWindow * window);
2367 
2375  uiWindow * capturedMouseWindow() { return m_capturedMouseWindow; }
2376 
2382  void repaintWindow(uiWindow * window);
2383 
2389  void repaintRect(Rect const & rect);
2390 
2398  void moveWindow(uiWindow * window, int x, int y);
2399 
2407  void resizeWindow(uiWindow * window, int width, int height);
2408 
2415  void resizeWindow(uiWindow * window, Size size);
2416 
2423  void reshapeWindow(uiWindow * window, Rect const & rect);
2424 
2432  uiWindow * screenToWindow(Point & point);
2433 
2440  void showWindow(uiWindow * window, bool value);
2441 
2453  int showModalWindow(uiWindow * window);
2454 
2464  ModalWindowState * initModalWindow(uiWindow * window);
2465 
2476  bool processModalWindowEvents(ModalWindowState * state, int timeout);
2477 
2488  int endModalWindow(ModalWindowState * state);
2489 
2496  void maximizeWindow(uiWindow * window, bool value);
2497 
2504  void minimizeWindow(uiWindow * window, bool value);
2505 
2506  void combineMouseMoveEvents(bool value) { m_combineMouseMoveEvents = value; }
2507 
2508  void showCaret(uiWindow * window);
2509 
2510  void setCaret(bool value);
2511 
2512  void setCaret(Point const & pos);
2513 
2514  void setCaret(Rect const & rect);
2515 
2527  uiTimerHandle setTimer(uiEvtHandler * dest, int periodMS);
2528 
2536  void killTimer(uiTimerHandle handle);
2537 
2543  uiAppProps & appProps() { return m_appProps; }
2544 
2550  void destroyWindow(uiWindow * window);
2551 
2552  void cleanWindowReferences(uiWindow * window);
2553 
2561  void enableKeyboardAndMouseEvents(bool value);
2562 
2575  uiMessageBoxResult messageBox(char const * title, char const * text, char const * button1Text, char const * button2Text = nullptr, char const * button3Text = nullptr, uiMessageBoxIcon icon = uiMessageBoxIcon::Question);
2576 
2592  uiMessageBoxResult inputBox(char const * title, char const * text, char * inOutString, int maxLength, char const * button1Text, char const * button2Text = nullptr);
2593 
2597  virtual void init();
2598 
2599  // delegates
2600 
2607  Delegate<uiTimerHandle> onTimer;
2608 
2609 protected:
2610 
2611  bool getEvent(uiEvent * event, int timeOutMS);
2612  bool peekEvent(uiEvent * event, int timeOutMS);
2613 
2614 
2615 private:
2616 
2617  void preprocessEvent(uiEvent * event);
2618  void preprocessMouseEvent(uiEvent * event);
2619  void preprocessKeyboardEvent(uiEvent * event);
2620  void filterModalEvent(uiEvent * event);
2621 
2622  static void timerFunc(TimerHandle_t xTimer);
2623 
2624  void blinkCaret(bool forceOFF = false);
2625  void suspendCaret(bool value);
2626 
2627 
2628  uiAppProps m_appProps;
2629 
2630  QueueHandle_t m_eventsQueue;
2631 
2632  uiFrame * m_rootWindow;
2633 
2634  uiWindow * m_activeWindow; // foreground window. Also gets keyboard events (other than focused window)
2635 
2636  uiWindow * m_focusedWindow; // window that captures keyboard events (other than active window)
2637 
2638  uiWindow * m_capturedMouseWindow; // window that has captured mouse
2639 
2640  uiWindow * m_freeMouseWindow; // window where mouse is over
2641 
2642  uiWindow * m_modalWindow; // current modal window
2643 
2644  bool m_combineMouseMoveEvents;
2645 
2646  uiWindow * m_caretWindow; // nullptr = caret is not visible
2647  Rect m_caretRect; // caret rect relative to m_caretWindow
2648  uiTimerHandle m_caretTimer;
2649  int m_caretInvertState; // -1 = suspended, 1 = rect reversed (cat visible), 0 = rect not reversed (caret invisible)
2650 
2651  int m_lastMouseUpTimeMS; // time (MS) at mouse up. Used to measure double clicks
2652  Point m_lastMouseUpPos; // screen position of last mouse up
2653 };
2654 
2655 
2656 
2657 
2658 } // end of namespace
2659 
2660 
2661 
Bitmap const * bitmap
Definition: fabui.h:1086
uiWindowStyle & windowStyle()
Sets or gets window style.
Definition: fabui.h:488
void update()
Reloads current directory content and repaints.
Definition: fabui.cpp:3754
uiCheckBoxKind
Specifies the combobox behaviour.
Definition: fabui.h:1990
VirtualKey VK
Definition: fabui.h:135
FontInfo const * textFont
Definition: fabui.h:1084
uint8_t SHIFT
Definition: fabui.h:139
void quit(int exitCode)
Terminates application and free resources.
Definition: fabui.cpp:275
bool hasFocus()
Determines whether this window or control has focus.
Definition: fabui.cpp:1611
uiApp * app()
Determines the app that owns this object.
Definition: fabui.h:272
char const * text()
Determines button text.
Definition: fabui.h:1135
Definition: vgacontroller.h:412
uiImageStyle & imageStyle()
Sets or gets image style.
Definition: fabui.h:1477
RGB backgroundColor
Definition: fabui.h:1548
RGB downBackgroundColor
Definition: fabui.h:1080
uint8_t hasMinimizeButton
Definition: fabui.h:686
virtual void setScrollBar(uiOrientation orientation, int position, int visible, int range, bool repaintScrollbar=true)
Sets scrollbar position, visible portion and range.
Definition: fabui.cpp:3087
uiPanelStyle & panelStyle()
Sets or gets panel style.
Definition: fabui.h:1529
void moveWindow(uiWindow *window, int x, int y)
Moves a window.
Definition: fabui.cpp:640
Delegate onChange
Slider changed event delegate.
Definition: fabui.h:2169
char const * filename()
Currently selected filename.
Definition: fabui.cpp:3728
uiWindow * capturedMouseWindow()
Determines which window is capturing mouse.
Definition: fabui.h:2375
Represents an RGB color.
Definition: vgacontroller.h:257
uiComboBoxStyle & comboBoxStyle()
Sets or gets combobox style.
Definition: fabui.h:1907
uiListBoxStyle & listBoxStyle()
Sets or gets listbox style.
Definition: fabui.h:1641
int VScrollBarRange()
Determines vertical scrollbar range.
Definition: fabui.h:1006
uiWindow * screenToWindow(Point &point)
Determines which window a point belongs to.
Definition: fabui.cpp:444
A frame is a window with a title bar, maximize/minimize/close buttons and that is resizeable or movea...
Definition: fabui.h:718
Contains details about the key event.
Definition: fabui.h:134
void setText(char const *value)
Sets button text.
Definition: fabui.cpp:2241
void setup(int min, int max, int ticksFrequency)
Sets minimum, maximum position and ticks frequency.
Definition: fabui.cpp:4151
int HScrollBarVisible()
Determines horizontal scrollbar visible portion (aka thumb size) of the scrollable content...
Definition: fabui.h:967
Delegate< uiTimerHandle > onTimer
Timer event delegate.
Definition: fabui.h:2607
void setPosition(int value)
Sets the slider position.
Definition: fabui.cpp:4141
void minimizeWindow(uiWindow *window, bool value)
Minimizes or restores a window.
Definition: fabui.cpp:751
RGB backgroundColor
Definition: fabui.h:1432
uiTimerHandle setTimer(uiEvtHandler *dest, int periodMS)
Setups a timer.
Definition: fabui.cpp:768
RGB mouseOverBackgroundColor
Definition: fabui.h:1081
void repaintRect(Rect const &rect)
Repaints a screen area.
Definition: fabui.cpp:631
uint8_t right
Definition: fabui.h:336
Represents the whole application base class.
Definition: fabui.h:2244
void resizeWindow(uiWindow *window, int width, int height)
Resizes a window.
Definition: fabui.cpp:646
void selectItem(int index)
Selects an item.
Definition: fabui.cpp:3834
uint8_t minimized
Definition: fabui.h:304
uiPaintBoxStyle & paintBoxStyle()
Sets or gets paintbox style.
Definition: fabui.h:1576
Bitmap const * downBitmap
Definition: fabui.h:1087
uint8_t left
Definition: fabui.h:334
virtual void init()
Method to inherit to implement an application.
Definition: fabui.cpp:463
A scrollable control is a control with optionally vertical and/or horizontal scrollbars.
Definition: fabui.h:923
RGB borderColor
Definition: fabui.h:324
uiWindow * setFocusedWindow(uiWindow *value)
Sets the focused window (control)
Definition: fabui.cpp:565
bool postEvent(uiEvent const *event)
Places an event in the event queue and returns without waiting for the receiver to process the event...
Definition: fabui.cpp:468
Base class for all visible UI elements (Frames and Controls)
Definition: fabui.h:344
char const * text()
Determines label text.
Definition: fabui.h:1392
uiLabelStyle & labelStyle()
Sets or gets label style.
Definition: fabui.h:1399
bool isMouseOver()
Determines whether the mouse is over this window.
Definition: fabui.h:533
Delegate onChange
Change event delegate.
Definition: fabui.h:1679
bool processModalWindowEvents(ModalWindowState *state, int timeout)
Processes all messages from modal window.
Definition: fabui.cpp:693
int lastSelectedItem()
Gets the last selected item.
Definition: fabui.cpp:3609
ModalWindowState * initModalWindow(uiWindow *window)
Begins modal window processing.
Definition: fabui.cpp:675
RGB activeTitleBackgroundColor
Definition: fabui.h:667
RGB mouseOverScrollBarForegroundColor
Definition: fabui.h:900
Rect transformRect(Rect const &rect, uiWindow *baseWindow)
Transforms rectangle origins from current window to another one.
Definition: fabui.cpp:1258
void maximizeWindow(uiWindow *window, bool value)
Maximizes or restores a window.
Definition: fabui.cpp:744
uiWindow * lastChild()
Gets last child.
Definition: fabui.h:394
Delegate onPaint
Paint event delegate.
Definition: fabui.h:823
Delegate onChange
Change event delegate.
Definition: fabui.h:2066
uiWindow * activeWindow()
Gets a pointer to the currently active window.
Definition: fabui.h:2315
FontInfo const * titleFont
Definition: fabui.h:670
uiTextEditProps & textEditProps()
Sets or gets text edit properties.
Definition: fabui.h:1264
uint8_t bottom
Definition: fabui.h:337
Shows a list of selectable string items.
Definition: fabui.h:1722
uint8_t top
Definition: fabui.h:335
int endModalWindow(ModalWindowState *state)
Ends modal window processing.
Definition: fabui.cpp:723
uiImage(uiWindow *parent, Bitmap const *bitmap, const Point &pos, const Size &size=Size(0, 0), bool visible=true)
Creates an instance of the object.
Definition: fabui.cpp:2891
uint8_t focusable
Definition: fabui.h:312
RGB checkedBackgroundColor
Definition: fabui.h:1981
Delegate onChange
Text edit event delegate.
Definition: fabui.h:1288
char const * directory()
Determines absolute path of current directory.
Definition: fabutils.h:387
void enableKeyboardAndMouseEvents(bool value)
Enables or disables mouse and keyboard events.
Definition: fabui.cpp:1086
Contains the listbox style.
Definition: fabui.h:1605
uiListBoxStyle & listBoxStyle()
Sets or gets listbox style.
Definition: fabui.h:1914
Contains the slider style.
Definition: fabui.h:2090
RGB selectedBackgroundColor
Definition: fabui.h:1608
Point pos()
Determines the window position relative to parent window.
Definition: fabui.h:422
Delegate< uiTimerHandle > onTimer
Timer event delegate.
Definition: fabui.h:808
RGB titleColor
Definition: fabui.h:668
uiControl(uiWindow *parent, const Point &pos, const Size &size, bool visible)
Creates an instance of the object.
Definition: fabui.cpp:2186
bool isDirectory()
Determines whether currently selected item is a directory.
Definition: fabui.cpp:3734
RGB scrollBarForegroundColor
Definition: fabui.h:899
uiWindow * parent()
Determines the parent window.
Definition: fabui.h:495
RGB activeTitleColor
Definition: fabui.h:669
uint8_t borderSize
Definition: fabui.h:327
Base class of all UI elements that can receive events.
Definition: fabui.h:257
RGB focusedBackgroundColor
Definition: fabui.h:1207
Sets or gets text edit style.
Definition: fabui.h:1204
uint8_t GUI
Definition: fabui.h:140
Contains the paintbox style.
Definition: fabui.h:1547
int HScrollBarRange()
Determines horizontal scrollbar range.
Definition: fabui.h:977
Properties of the combobox.
Definition: fabui.h:1862
uiWindow * moveFocus(int delta)
Move focus to a control with current focus index plus a delta.
Definition: fabui.cpp:599
uiMessageBoxIcon
Icon displayed by the uiApp.messageBox() method.
Definition: fabui.h:2219
int count()
Determines number of files in current directory.
Definition: fabui.h:1800
void setScrollBar(uiOrientation orientation, int position, int visible, int range, bool repaintScrollbar)
Sets scrollbar position, visible portion and range.
Definition: fabui.cpp:3618
FontInfo const * textFont
Definition: fabui.h:1611
This file contains fabgl::CanvasClass definition and the related Canvas instance. ...
This file contains fabgl::VGAControllerClass definition and the VGAController instance.
A panel is used to contain and to group some controls.
Definition: fabui.h:1506
Represents a checkbox or a radiobutton.
Definition: fabui.h:2002
uint8_t resizeable
Definition: fabui.h:682
RGB mouseOverBackgroundButtonColor
Definition: fabui.h:673
void showWindow(uiWindow *window, bool value)
Makes a window visible or invisible.
Definition: fabui.cpp:667
uint8_t hasCaret
Definition: fabui.h:1217
virtual Rect clientRect(uiOrigin origin)
Determines the client area bounding box.
Definition: fabui.cpp:1296
int VScrollBarPos()
Determines position of the vertical scrollbar thumb.
Definition: fabui.h:987
Point clientPos()
Determines position of the client area.
Definition: fabui.cpp:1309
void bringOnTop()
Brings this window on top.
Definition: fabui.cpp:1235
bool realtimeReshaping
Definition: fabui.h:2201
void reshapeWindow(uiWindow *window, Rect const &rect)
Reshapes a window.
Definition: fabui.cpp:659
Delegate onChange
Button changed event delegate.
Definition: fabui.h:1170
void setText(char const *value)
Sets label text.
Definition: fabui.cpp:2818
RGB focusedSelectedBackgroundColor
Definition: fabui.h:1609
void destroyWindow(uiWindow *window)
Destroys a window.
Definition: fabui.cpp:859
uiTextEdit(uiWindow *parent, char const *text, const Point &pos, const Size &size, bool visible=true)
Creates an instance of the object.
Definition: fabui.cpp:2361
uiWindow * prev()
Gets previous sibling.
Definition: fabui.h:380
uiFrameProps & frameProps()
Sets or gets frame properties.
Definition: fabui.h:774
Properties of the application.
Definition: fabui.h:2198
uiFileBrowser(uiWindow *parent, const Point &pos, const Size &size, bool visible=true)
Creates an instance of the object.
Definition: fabui.cpp:3690
Contains the scrollable control style.
Definition: fabui.h:897
Represents a button control. A button can have text and optionally a bitmap.
Definition: fabui.h:1101
uiButtonKind
Specifies the button kind.
Definition: fabui.h:1094
uiAppProps & appProps()
Sets or gets application properties.
Definition: fabui.h:2543
void update()
Updates the label content.
Definition: fabui.cpp:2841
Contains the label style.
Definition: fabui.h:1342
void bringAfter(uiWindow *insertionPoint)
Brings this window after another one.
Definition: fabui.cpp:1241
RGB rangeColor
Definition: fabui.h:2093
Describes mouse absolute position, scroll wheel delta and buttons status.
Definition: fabutils.h:206
uint8_t moveable
Definition: fabui.h:683
Point mouseDownPos()
Determines mouse position when left button was down.
Definition: fabui.h:502
uint16_t caretBlinkingTime
Definition: fabui.h:2199
int position()
Determines slider position.
Definition: fabui.h:2131
uiFrameStyle & frameStyle()
Sets or gets frame style.
Definition: fabui.h:767
RGB backgroundColor
Definition: fabui.h:1344
Rect rect(uiOrigin origin)
Determines the window bounding box.
Definition: fabui.cpp:1280
uiWindowState state()
Determines the window state.
Definition: fabui.h:474
int focusIndex()
Determines the focus index (aka tab-index)
Definition: fabui.h:574
VirtualKey
Represents each possible real or derived (SHIFT + real) key.
Definition: fabutils.h:502
RGB backgroundColor
Definition: fabui.h:1501
Represents the coordinate of a point.
Definition: fabutils.h:125
Represents an image with 64 colors image and transparency.
Definition: vgacontroller.h:385
Size size()
Determines the window size.
Definition: fabui.h:438
Contains the window style.
Definition: fabui.h:322
Properties of the frame.
Definition: fabui.h:681
void setFocusIndex(int value)
Sets the focus index (aka tab-index)
Definition: fabui.h:565
This file contains some utility classes and functions.
RGB activeBorderColor
Definition: fabui.h:325
RGB textColor
Definition: fabui.h:1345
uiLabel(uiWindow *parent, char const *text, const Point &pos, const Size &size=Size(0, 0), bool visible=true)
Creates an instance of the object.
Definition: fabui.cpp:2798
Definition: canvas.cpp:47
RGB foregroundColor
Definition: fabui.h:1983
uint8_t activable
Definition: fabui.h:311
CursorName
This enum defines a set of predefined mouse cursors.
Definition: vgacontroller.h:410
uiWindow * firstChild()
Gets first child.
Definition: fabui.h:387
Delegate< uiKeyEventInfo > onKeyUp
Key-up event delegate.
Definition: fabui.h:818
void repaint()
Repaints this window.
Definition: fabui.cpp:1274
Specifies the object type.
Definition: fabui.h:204
int count()
Determines number of files in current directory.
Definition: fabutils.h:394
Contains some window options.
Definition: fabui.h:310
Delegate onChangeVScrollBar
Vertical scrollbar change event delegate.
Definition: fabui.h:1019
uiPanel(uiWindow *parent, const Point &pos, const Size &size, bool visible=true)
Creates an instance of the object.
Definition: fabui.cpp:2957
int run()
Initializes application and executes the main event loop.
Definition: fabui.cpp:188
uint8_t visible
Definition: fabui.h:302
void exitModal(int modalResult)
Exits from a modal window.
Definition: fabui.cpp:1603
StringList & items()
A list of strings representing the listbox content.
Definition: fabui.h:1744
uint8_t active
Definition: fabui.h:305
MouseStatus status
Definition: fabui.h:146
Contains the button style.
Definition: fabui.h:1078
RGB backgroundColor
Definition: fabui.h:1980
RGB mouseDownBackgroundColor
Definition: fabui.h:1082
RGB scrollBarBackgroundColor
Definition: fabui.h:898
void repaintWindow(uiWindow *window)
Repaints a window.
Definition: fabui.cpp:625
uint8_t hasCloseButton
Definition: fabui.h:684
Represents a rectangle.
Definition: fabutils.h:158
void setText(char const *value)
Replaces current text.
Definition: fabui.cpp:2388
uint8_t changedButton
Definition: fabui.h:147
uiWindowProps & windowProps()
Sets or gets window properties.
Definition: fabui.h:481
uiScrollableControl(uiWindow *parent, const Point &pos, const Size &size, bool visible=true)
Creates an instance of the object.
Definition: fabui.cpp:3062
uiTextEditStyle & textEditStyle()
Sets or gets text edit style.
Definition: fabui.h:1257
uiComboBoxProps & comboBoxProps()
Sets or gets combobox properties.
Definition: fabui.h:1921
void setTitleFmt(const char *format,...)
Sets window title as formatted text.
Definition: fabui.cpp:1673
uiScrollableControlStyle & scrollableControlStyle()
Sets or gets control style.
Definition: fabui.h:948
static FontInfo const * getPresetFontInfoFromHeight(int height, bool fixedWidth)
Gets the font info that best fits the specified height.
Definition: canvas.cpp:499
uiSliderStyle & sliderStyle()
Sets or gets slider style.
Definition: fabui.h:2124
Represents a text edit control.
Definition: fabui.h:1233
uint8_t scrollBarSize
Definition: fabui.h:901
uiComboBox(uiWindow *parent, const Point &pos, const Size &size, int listHeight, bool visible=true)
Creates an instance of the object.
Definition: fabui.cpp:3800
uint8_t RALT
Definition: fabui.h:137
Delegate onShow
Show window event delegate.
Definition: fabui.h:786
Contains details about the mouse event.
Definition: fabui.h:145
int max()
Gets maximum position.
Definition: fabui.h:2152
RGB buttonColor
Definition: fabui.h:671
RGB backgroundColor
Definition: fabui.h:1079
void deselectAll()
Deselects all selected items.
Definition: fabui.cpp:3541
int VScrollBarVisible()
Determines vertical scrollbar visible portion (aka thumb size) of the scrollable content.
Definition: fabui.h:996
Delegate onDblClick
Mouse double click event delegate.
Definition: fabui.h:592
StringList & items()
A list of strings representing items of the combobox.
Definition: fabui.h:1900
Delegate onKillFocus
Kill focus event delegate.
Definition: fabui.h:1684
uiWindow * focusedWindow()
Gets the focused window (control)
Definition: fabui.h:2340
int showModalWindow(uiWindow *window)
Makes a window visible and handles it has a modal window.
Definition: fabui.cpp:735
uiPaintBox(uiWindow *parent, const Point &pos, const Size &size, bool visible=true)
Creates an instance of the object.
Definition: fabui.cpp:3008
void selectItem(int index, bool add=false, bool range=false)
Selects a listbox item.
Definition: fabui.cpp:3501
RGB textColor
Definition: fabui.h:1612
uiCheckBoxStyle & checkBoxStyle()
Sets or gets checkbox style.
Definition: fabui.h:2026
uiMessageBoxResult messageBox(char const *title, char const *text, char const *button1Text, char const *button2Text=nullptr, char const *button3Text=nullptr, uiMessageBoxIcon icon=uiMessageBoxIcon::Question)
Displays a modal dialog box with an icon, text and some buttons.
Definition: fabui.cpp:898
void killTimer(uiTimerHandle handle)
Kills a timer.
Definition: fabui.cpp:776
uiButtonStyle & buttonStyle()
Sets or gets button style.
Definition: fabui.h:1142
void setChecked(bool value)
Sets current checkbox or radiobutton checked status.
Definition: fabui.cpp:4082
uint8_t CTRL
Definition: fabui.h:138
Rect clientRect(uiOrigin origin)
Determines the client area bounding box.
Definition: fabui.cpp:1701
bool hasChildren()
Determines whether this window has children.
Definition: fabui.h:401
This file contains FabGL library configuration settings, like number of supported colors...
Base class of all UI elements like windows and controls.
Definition: fabui.h:231
uiObjectType & objectType()
Determines the object type.
Definition: fabui.h:244
A paintbox control allows applications to perform custom drawings providing uiPaintBox.onPaint delegate. A paintbox can have horizontal and vertical scrollbars.
Definition: fabui.h:1553
RGB activeButtonColor
Definition: fabui.h:672
Delegate< uiKeyEventInfo > onKeyDown
Key-down event delegate.
Definition: fabui.h:813
uint8_t bitmapTextSpace
Definition: fabui.h:1085
RGB titleBackgroundColor
Definition: fabui.h:666
Represents a bidimensional size.
Definition: fabutils.h:143
uiWindow * next()
Gets next sibling.
Definition: fabui.h:371
FontInfo const * textFont
Definition: fabui.h:1209
CursorName defaultCursor
Definition: fabui.h:323
RGB textColor
Definition: fabui.h:1208
char const * directory()
Determines current directory.
Definition: fabui.h:1793
Delegate onClick
Mouse click event delegate.
Definition: fabui.h:584
int min()
Gets minimum position.
Definition: fabui.h:2145
uiListBox(uiWindow *parent, const Point &pos, const Size &size, bool visible=true)
Creates an instance of the object.
Definition: fabui.cpp:3667
RGB backgroundColor
Definition: fabui.h:665
int firstSelectedItem()
Gets the first selected item.
Definition: fabui.cpp:3599
Definition: fabui.h:664
uint8_t maximized
Definition: fabui.h:303
uiSlider(uiWindow *parent, const Point &pos, const Size &size, uiOrientation orientation, bool visible=true)
Creates an instance of the object.
Definition: fabui.cpp:4118
Contains the listbox style.
Definition: fabui.h:1855
uint8_t openOnFocus
Definition: fabui.h:1863
uint8_t focusedBorderSize
Definition: fabui.h:328
RGB buttonBackgroundColor
Definition: fabui.h:1856
RGB mouseOverButtonColor
Definition: fabui.h:674
RGB focusedBackgroundColor
Definition: fabui.h:1607
Delegate onResize
Resize window event delegate.
Definition: fabui.h:800
uiCheckBox(uiWindow *parent, const Point &pos, const Size &size, uiCheckBoxKind kind=uiCheckBoxKind::CheckBox, bool visible=true)
Creates an instance of the object.
Definition: fabui.cpp:3975
void setDirectory(char const *path)
Sets current directory.
Definition: fabui.cpp:3720
A label is a static text UI element.
Definition: fabui.h:1350
uiCustomListBox(uiWindow *parent, const Point &pos, const Size &size, bool visible=true)
Creates an instance of the object.
Definition: fabui.cpp:3405
uiButton(uiWindow *parent, char const *text, const Point &pos, const Size &size, uiButtonKind kind=uiButtonKind::Button, bool visible=true)
Creates an instance of the object.
Definition: fabui.cpp:2215
int itemHeight
Definition: fabui.h:1610
RGB gripColor
Definition: fabui.h:2094
Properties of the text edit.
Definition: fabui.h:1216
Contains the image style.
Definition: fabui.h:1431
RGB backgroundColor
Definition: fabui.h:1205
RGB textColor
Definition: fabui.h:1083
This is the base class for all controls. A control can have focus and is not activable.
Definition: fabui.h:871
RGB selectedTextColor
Definition: fabui.h:1613
Contains anchors enable/disable switches.
Definition: fabui.h:333
bool down()
Determines whether the switch button is down or up.
Definition: fabui.h:1151
void setTextFmt(const char *format,...)
Sets label formatted text.
Definition: fabui.cpp:2827
RGB buttonColor
Definition: fabui.h:1857
uiFrame * rootWindow()
Gets a pointer to the root window.
Definition: fabui.h:2305
Shows generic a list of selectable items.
Definition: fabui.h:1618
uiOrigin
Specifies window rectangle origin.
Definition: fabui.h:293
bool insertEvent(uiEvent const *event)
Inserts (first position) an event in the event queue and returns without waiting for the receiver to ...
Definition: fabui.cpp:474
void setBitmap(Bitmap const *bitmap)
Sets image bitmap.
Definition: fabui.cpp:2909
Delegate onHide
Hide window event delegate.
Definition: fabui.h:793
A slider or track bar is a graphical control element with which a user may set a value by moving an i...
Definition: fabui.h:2100
RGB backgroundColor
Definition: fabui.h:1606
int groupIndex()
Determines radiobutton group index.
Definition: fabui.h:2049
uint16_t doubleClickTime
Definition: fabui.h:2200
Specifies current window state.
Definition: fabui.h:301
int selectedItem()
Represents currently selected item.
Definition: fabui.h:1928
char const * title()
Determines the window title.
Definition: fabui.h:742
uint8_t hasMaximizeButton
Definition: fabui.h:685
Rect clientRect(uiOrigin origin)
Determines the client area bounding box.
Definition: fabui.cpp:3386
RGB backgroundColor
Definition: fabui.h:2091
This is a combination of a listbox and a single-line editable textbox.
Definition: fabui.h:1873
int HScrollBarPos()
Determines position of the horizontal scrollbar thumb.
Definition: fabui.h:958
Shows and navigates Virtual Filesystem content.
Definition: fabui.h:1765
uiMessageBoxResult inputBox(char const *title, char const *text, char *inOutString, int maxLength, char const *button1Text, char const *button2Text=nullptr)
Displays a modal dialog box with a text, a text edit and up to two buttons.
Definition: fabui.cpp:997
FileBrowser & content()
Contains current directory representation.
Definition: fabui.h:1828
uiWindow * setActiveWindow(uiWindow *value)
Sets the active window.
Definition: fabui.cpp:521
Delegate< Rect > onPaint
Paint event delegate.
Definition: fabui.h:1587
uint8_t LALT
Definition: fabui.h:136
RGB mouseOverBackgroundColor
Definition: fabui.h:1206
FontInfo const * textFont
Definition: fabui.h:1343
void setTitle(char const *value)
Sets window title.
Definition: fabui.cpp:1665
Contains the checkbox style.
Definition: fabui.h:1979
bool checked()
Determines whether the checkbox or radiobutton is checked.
Definition: fabui.h:2033
uint8_t allowEdit
Definition: fabui.h:1218
uiAnchors & anchors()
Allows to switch on or off anchors.
Definition: fabui.h:558
Contains the panel style.
Definition: fabui.h:1500
void processEvents()
Processes all events in queue.
Definition: fabui.cpp:262
char const * text()
Gets current content of the text edit.
Definition: fabui.h:1280
uiMessageBoxResult
Return values from uiApp.messageBox() method.
Definition: fabui.h:2208
uiWindow(uiWindow *parent, const Point &pos, const Size &size, bool visible)
Creates an instance of the object.
Definition: fabui.cpp:1109
void setDown(bool value)
Sets button state of a switch button.
Definition: fabui.cpp:2341
uiOrientation
Item direction/orientation.
Definition: fabui.h:192
Size clientSize()
Determines the client area size.
Definition: fabui.cpp:1303
Delegate< uiKeyEventInfo > onKeyUp
Key-up event delegate.
Definition: fabui.h:1689
Delegate onChange
Change event delegate.
Definition: fabui.h:1945
RGB mouseOverBackgroundColor
Definition: fabui.h:1982
RGB focusedBorderColor
Definition: fabui.h:326
RGB slideColor
Definition: fabui.h:2092
Bitmap const * bitmap()
Gets image bitmap.
Definition: fabui.h:1470
void setGroupIndex(int value)
Sets radiobutton group index.
Definition: fabui.h:2056
Image control to display a static bitmap.
Definition: fabui.h:1437
uiFrame(uiWindow *parent, char const *title, const Point &pos, const Size &size, bool visible=true)
Creates an instance of the object.
Definition: fabui.cpp:1646
Delegate onChangeHScrollBar
Horizontal scrollbar change event delegate.
Definition: fabui.h:1014
FileBrowser allows basic file system operations (dir, mkdir, remove and rename)
Definition: fabutils.h:357