FabGL
ESP32 Display 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 "displaycontroller.h"
44 #include "canvas.h"
45 #include "fabfonts.h"
46 
47 
48 
49 /*
50 
51  *uiObject
52  *uiEvtHandler
53  *uiApp
54  *uiWindow
55  *uiFrame
56  *uiControl
57  *uiButton
58  *uiLabel
59  *uiImage
60  *uiPanel
61  *uiTextEdit
62  *uiScrollableControl
63  *uiPaintBox
64  *uiCustomListBox
65  *uiListBox
66  *uiFileBrowser
67  uiMemoEdit
68  *uiCheckBox
69  *uiComboBox
70  uiMenu
71  uiGauge
72  *uiSlider
73  uiSpinButton
74 
75 */
76 
77 
78 namespace fabgl {
79 
80 
81 
82 // increase in case of garbage between windows!
83 #define FABGLIB_UI_EVENTS_QUEUE_SIZE 256
84 
85 
86 
88 // uiEvent
89 
90 enum uiEventID {
91  UIEVT_NULL,
92  UIEVT_DEBUGMSG,
93  UIEVT_APPINIT,
94  UIEVT_GENPAINTEVENTS,
95  UIEVT_PAINT,
96  UIEVT_ACTIVATE,
97  UIEVT_DEACTIVATE,
98  UIEVT_MOUSEMOVE,
99  UIEVT_MOUSEWHEEL,
100  UIEVT_MOUSEBUTTONDOWN,
101  UIEVT_MOUSEBUTTONUP,
102  UIEVT_SETPOS,
103  UIEVT_SETSIZE,
104  UIEVT_RESHAPEWINDOW,
105  UIEVT_MOUSEENTER,
106  UIEVT_MOUSELEAVE,
107  UIEVT_MAXIMIZE, // Request for maximize
108  UIEVT_MINIMIZE, // Request for minimize
109  UIEVT_RESTORE, // Restore from UIEVT_MAXIMIZE or UIEVT_MINIMIZE
110  UIEVT_SHOW,
111  UIEVT_HIDE,
112  UIEVT_SETFOCUS,
113  UIEVT_KILLFOCUS,
114  UIEVT_KEYDOWN,
115  UIEVT_KEYUP,
116  UIEVT_TIMER,
117  UIEVT_CLICK,
118  UIEVT_DBLCLICK,
119  UIEVT_EXITMODAL,
120  UIEVT_DESTROY,
121  UIEVT_CLOSE, // Request to close (frame Close button)
122  UIEVT_QUIT, // Quit the application
123 };
124 
125 
126 class uiEvtHandler;
127 class uiApp;
128 class uiWindow;
129 
130 
131 typedef void * uiTimerHandle;
132 
133 
137  uint8_t LALT : 1;
138  uint8_t RALT : 1;
139  uint8_t CTRL : 1;
140  uint8_t SHIFT : 1;
141  uint8_t GUI : 1;
142 };
143 
144 
148  uint8_t changedButton;
149 };
150 
151 
152 struct uiEvent {
153  uiEvtHandler * dest;
154  uiEventID id;
155 
156  union uiEventParams {
157  // event: UIEVT_MOUSEMOVE, UIEVT_MOUSEWHEEL, UIEVT_MOUSEBUTTONDOWN, UIEVT_MOUSEBUTTONUP, UIEVT_CLICK, UIEVT_DBLCLICK
158  uiMouseEventInfo mouse;
159  // event: UIEVT_PAINT, UIEVT_GENPAINTEVENTS, UIEVT_RESHAPEWINDOW
160  Rect rect;
161  // event: UIEVT_SETPOS
162  Point pos;
163  // event: UIEVT_SETSIZE
164  Size size;
165  // event: UIEVT_DEBUGMSG
166  char const * debugMsg;
167  // event: UIEVT_KEYDOWN, UIEVT_KEYUP
168  uiKeyEventInfo key;
169  // event: UIEVT_TIMER
170  uiTimerHandle timerHandle;
171  // event: UIEVT_EXITMODAL
172  int modalResult;
173  // event: UIEVT_SETFOCUS
174  uiWindow * oldFocused;
175  // event: UIEVT_KILLFOCUS
176  uiWindow * newFocused;
177  // event: UIEVT_QUIT
178  int exitCode;
179 
180  uiEventParams() { }
181  } params;
182 
183  uiEvent() : dest(nullptr), id(UIEVT_NULL) { }
184  uiEvent(uiEvent const & e) { dest = e.dest; id = e.id; params = e.params; }
185  uiEvent(uiEvtHandler * dest_, uiEventID id_) : dest(dest_), id(id_) { }
186 };
187 
188 
189 
193 enum class uiOrientation {
194  Vertical,
195  Horizontal,
196 };
197 
198 
199 
201 // uiObject
202 
203 
205 struct uiObjectType {
206  uint32_t uiApp : 1;
207  uint32_t uiEvtHandler : 1;
208  uint32_t uiWindow : 1;
209  uint32_t uiFrame : 1;
210  uint32_t uiControl : 1;
211  uint32_t uiScrollableControl : 1;
212  uint32_t uiButton : 1;
213  uint32_t uiTextEdit : 1;
214  uint32_t uiLabel : 1;
215  uint32_t uiImage : 1;
216  uint32_t uiPanel : 1;
217  uint32_t uiPaintBox : 1;
218  uint32_t uiCustomListBox : 1;
219  uint32_t uiListBox : 1;
220  uint32_t uiFileBrowser : 1;
221  uint32_t uiComboBox : 1;
222  uint32_t uiCheckBox : 1;
223  uint32_t uiSlider : 1;
224 
227  { }
228 };
229 
230 
232 class uiObject {
233 
234 public:
235 
236  uiObject();
237 
238  virtual ~uiObject();
239 
245  uiObjectType & objectType() { return m_objectType; }
246 
247 private:
248  uiObjectType m_objectType;
249 };
250 
251 
252 
254 // uiEvtHandler
255 
256 
258 class uiEvtHandler : public uiObject {
259 
260 public:
261 
263 
264  virtual ~uiEvtHandler();
265 
266  virtual void processEvent(uiEvent * event);
267 
273  uiApp * app() { return m_app; }
274 
275 
276 protected:
277 
278  void setApp(uiApp * value) { m_app = value; }
279 
280 
281 private:
282 
283  uiApp * m_app;
284 };
285 
286 
287 
289 // uiWindow
290 
294 enum class uiOrigin {
295  Screen,
296  Parent,
297  Window,
298 };
299 
300 
303  uint8_t visible : 1;
304  uint8_t maximized : 1;
305  uint8_t minimized : 1;
306  uint8_t active : 1;
307 };
308 
309 
312  uint8_t activable : 1;
313  uint8_t focusable : 1;
315  uiWindowProps() :
316  activable(true),
317  focusable(false)
318  { }
319 };
320 
321 
325  RGB888 borderColor = RGB888(128, 128, 128);
326  RGB888 activeBorderColor = RGB888(128, 128, 255);
328  uint8_t borderSize = 3;
329  uint8_t focusedBorderSize = 1;
330 };
331 
332 
334 struct uiAnchors {
335  uint8_t left : 1;
336  uint8_t top : 1;
337  uint8_t right : 1;
338  uint8_t bottom : 1;
340  uiAnchors() : left(true), top(true), right(false), bottom(false) { }
341 };
342 
343 
345 class uiWindow : public uiEvtHandler {
346 
347 friend class uiApp;
348 
349 public:
350 
359  uiWindow(uiWindow * parent, const Point & pos, const Size & size, bool visible);
360 
361  virtual ~uiWindow();
362 
363  virtual void processEvent(uiEvent * event);
364 
365  void setCanvas(Canvas * canvas) { m_canvas = canvas; }
366 
374  uiWindow * next() { return m_next; }
375 
383  uiWindow * prev() { return m_prev; }
384 
390  uiWindow * firstChild() { return m_firstChild; }
391 
397  uiWindow * lastChild() { return m_lastChild; }
398 
404  bool hasChildren() { return m_firstChild != nullptr; }
405 
409  void bringOnTop();
410 
416  void bringAfter(uiWindow * insertionPoint);
417 
425  Point pos() { return m_pos; }
426 
432  Point clientPos();
433 
441  Size size() { return m_size; }
442 
448  Size clientSize();
449 
459  Rect rect(uiOrigin origin);
460 
468  virtual Rect clientRect(uiOrigin origin);
469 
477  uiWindowState state() { return m_state; }
478 
484  uiWindowProps & windowProps() { return m_windowProps; }
485 
491  uiWindowStyle & windowStyle() { return m_windowStyle; }
492 
498  uiWindow * parent() { return m_parent; }
499 
505  Point mouseDownPos() { return m_mouseDownPos; }
506 
515  Rect transformRect(Rect const & rect, uiWindow * baseWindow);
516 
522  void repaint(Rect const & rect);
523 
527  void repaint();
528 
536  bool isMouseOver() { return m_isMouseOver; }
537 
545  void exitModal(int modalResult);
546 
554  bool hasFocus();
555 
561  uiAnchors & anchors() { return m_anchors; }
562 
568  void setFocusIndex(int value) { m_focusIndex = value; }
569 
577  int focusIndex() { return m_focusIndex; }
578 
579  Canvas * canvas() { return m_canvas; }
580 
581 
582  // Delegates
583 
589  Delegate<> onClick;
590 
597  Delegate<> onDblClick;
598 
599 
600 protected:
601 
602  void addChild(uiWindow * child);
603  void insertAfter(uiWindow * child, uiWindow * underlyingChild);
604  void freeChildren();
605  void removeChild(uiWindow * child, bool freeChild = true);
606  void moveChildOnTop(uiWindow * child);
607  void moveAfter(uiWindow * child, uiWindow * underlyingChild);
608  bool isChild(uiWindow * window);
609 
610  Size sizeAtMouseDown() { return m_sizeAtMouseDown; }
611  Point posAtMouseDown() { return m_posAtMouseDown; }
612 
613  virtual Size minWindowSize() { return Size(0, 0); }
614 
615  void beginPaint(uiEvent * paintEvent, Rect const & clippingRect);
616 
617  void generatePaintEvents(Rect const & paintRect);
618  void reshape(Rect const & r);
619 
620  bool isFocusable();
621 
622 private:
623 
624  void paintWindow();
625  uiWindow * getChildWithFocusIndex(int focusIndex, int * maxIndex);
626 
627 
628  uiWindow * m_parent;
629 
630  Canvas * m_canvas;
631 
632  Point m_pos;
633  Size m_size;
634 
635  // saved screen rect before Maximize or Minimize
636  Rect m_savedScreenRect;
637 
638  uiWindowState m_state;
639 
640  uiWindowProps m_windowProps;
641 
642  uiWindowStyle m_windowStyle;
643 
644  Point m_mouseDownPos; // mouse position when mouse down event has been received
645 
646  Point m_posAtMouseDown; // used to resize
647  Size m_sizeAtMouseDown; // used to resize
648 
649  bool m_isMouseOver; // true after mouse entered, false after mouse left
650 
651  uiAnchors m_anchors;
652 
653  int16_t m_focusIndex; // -1 = doesn't partecipate to focus trip
654 
655  // double linked list, order is: bottom (first items) -> up (last items)
656  uiWindow * m_next;
657  uiWindow * m_prev;
658  uiWindow * m_firstChild;
659  uiWindow * m_lastChild;
660 };
661 
662 
663 
665 // uiFrame
666 
667 
671 struct uiFrameStyle {
672  RGB888 backgroundColor = RGB888(255, 255, 255);
673  RGB888 titleBackgroundColor = RGB888(128, 128, 128);
675  RGB888 titleColor = RGB888(0, 0, 0);
677  FontInfo const * titleFont = &FONT_std_12;
678  RGB888 buttonColor = RGB888(64, 64, 64);
681  RGB888 mouseOverButtonColor = RGB888(255, 255, 255);
682 };
683 
684 
688 struct uiFrameProps {
689  uint8_t resizeable : 1;
690  uint8_t moveable : 1;
691  uint8_t hasCloseButton : 1;
692  uint8_t hasMaximizeButton : 1;
693  uint8_t hasMinimizeButton : 1;
695  uiFrameProps() :
696  resizeable(true),
697  moveable(true),
698  hasCloseButton(true),
699  hasMaximizeButton(true),
700  hasMinimizeButton(true)
701  { }
702 };
703 
704 
705 enum class uiFrameItem : uint8_t {
706  None,
707  MoveArea,
708  TopLeftResize,
709  TopCenterResize,
710  TopRightResize,
711  CenterLeftResize,
712  CenterRightResize,
713  BottomLeftResize,
714  BottomCenterResize,
715  BottomRightResize,
716  CloseButton,
717  MaximizeButton,
718  MinimizeButton,
719 };
720 
721 
725 class uiFrame : public uiWindow {
726 
727 public:
728 
738  uiFrame(uiWindow * parent, char const * title, const Point & pos, const Size & size, bool visible = true);
739 
740  virtual ~uiFrame();
741 
742  virtual void processEvent(uiEvent * event);
743 
749  char const * title() { return m_title; }
750 
758  void setTitle(char const * value);
759 
767  void setTitleFmt(const char *format, ...);
768 
774  uiFrameStyle & frameStyle() { return m_frameStyle; }
775 
781  uiFrameProps & frameProps() { return m_frameProps; }
782 
783  Rect clientRect(uiOrigin origin);
784 
785 
786  // Delegates
787 
793  Delegate<> onShow;
794 
800  Delegate<> onHide;
801 
807  Delegate<> onResize;
808 
815  Delegate<uiTimerHandle> onTimer;
816 
820  Delegate<uiKeyEventInfo> onKeyDown;
821 
825  Delegate<uiKeyEventInfo> onKeyUp;
826 
830  Delegate<> onPaint;
831 
832 
833 protected:
834 
835  Size minWindowSize();
836  int titleBarHeight();
837  Rect titleBarRect();
838 
839 private:
840 
841  void paintFrame();
842  int paintButtons(Rect const & bkgRect);
843  void movingCapturedMouse(int mouseX, int mouseY, bool mouseIsDown);
844  void movingFreeMouse(int mouseX, int mouseY);
845  uiFrameItem getFrameItemAt(int x, int y);
846  Rect getBtnRect(int buttonIndex);
847  void handleButtonsClick(int x, int y, bool doubleClick);
848  void drawTextWithEllipsis(FontInfo const * fontInfo, int X, int Y, char const * text, int maxX);
849  void drawReshapingBox(Rect boxRect);
850 
851 
852  static constexpr int CORNERSENSE = 10;
853 
854 
855  uiFrameStyle m_frameStyle;
856 
857  uiFrameProps m_frameProps;
858 
859  char * m_title;
860  int m_titleLength;
861 
862  uiFrameItem m_mouseDownFrameItem; // frame item on mouse down
863  uiFrameItem m_mouseMoveFrameItem; // frame item on mouse move
864 
865  Rect m_lastReshapingBox; // last reshaping box painted by drawReshapingBox(), (0,0,0,0) if there isn't any
866 
867 };
868 
869 
870 
872 // uiControl
873 
874 
878 class uiControl : public uiWindow {
879 
880 public:
881 
890  uiControl(uiWindow * parent, const Point & pos, const Size & size, bool visible);
891 
892  virtual ~uiControl();
893 
894  virtual void processEvent(uiEvent * event);
895 };
896 
897 
898 
900 // uiScrollableControl
901 
902 
908  uint8_t scrollBarSize = 11;
909 };
910 
911 
912 enum class uiScrollBarItem {
913  None,
914  LeftButton,
915  RightButton,
916  TopButton,
917  BottomButton,
918  HBar,
919  VBar,
920  PageUp,
921  PageDown,
922  PageLeft,
923  PageRight,
924 };
925 
926 
931 
932 public:
933 
942  uiScrollableControl(uiWindow * parent, const Point & pos, const Size & size, bool visible = true);
943 
944  virtual ~uiScrollableControl();
945 
946  virtual void processEvent(uiEvent * event);
947 
948  Rect clientRect(uiOrigin origin);
949 
955  uiScrollableControlStyle & scrollableControlStyle() { return m_scrollableControlStyle; }
956 
965  int HScrollBarPos() { return m_HScrollBarPosition; }
966 
974  int HScrollBarVisible() { return m_HScrollBarVisible; }
975 
984  int HScrollBarRange() { return m_HScrollBarRange; }
985 
994  int VScrollBarPos() { return m_VScrollBarPosition; }
995 
1003  int VScrollBarVisible() { return m_VScrollBarVisible; }
1004 
1013  int VScrollBarRange() { return m_VScrollBarRange; }
1014 
1015 
1016  // Delegates
1017 
1022 
1027 
1028 
1029 protected:
1030 
1040  virtual void setScrollBar(uiOrientation orientation, int position, int visible, int range, bool repaintScrollbar = true);
1041 
1042 
1043 private:
1044 
1045  void paintScrollableControl();
1046  void paintScrollBars();
1047  Rect getVScrollBarRects(Rect * topButton = nullptr, Rect * bottonButton = nullptr, Rect * bar = nullptr);
1048  Rect getHScrollBarRects(Rect * leftButton = nullptr, Rect * rightButton = nullptr, Rect * bar = nullptr);
1049  uiScrollBarItem getItemAt(int x, int y);
1050  void repaintScrollBar(uiOrientation orientation);
1051  void handleFreeMouseMove(int mouseX, int mouseY);
1052  void handleCapturedMouseMove(int mouseX, int mouseY);
1053  void handleButtonsScroll();
1054  void handlePageScroll();
1055 
1056  uiScrollableControlStyle m_scrollableControlStyle;
1057 
1058  int16_t m_HScrollBarPosition;
1059  int16_t m_HScrollBarVisible; // it means the "visible" area (how big is the bar)
1060  int16_t m_HScrollBarRange;
1061  int16_t m_VScrollBarPosition;
1062  int16_t m_VScrollBarVisible; // it means the "visible" area (how big is the bar)
1063  int16_t m_VScrollBarRange;
1064 
1065  // values updated by getVScrollBarRects() and getHScrollBarRects()
1066  int16_t m_HBarArea;
1067  int16_t m_VBarArea;
1068 
1069  int16_t m_mouseDownHScrollBarPosition;
1070  int16_t m_mouseDownVScrollBarPosition;
1071 
1072  uiScrollBarItem m_mouseOverItem;
1073 
1074  // a timer is active while mouse is down and the mouse is over a button
1075  uiTimerHandle m_scrollTimer;
1076 };
1077 
1078 
1079 
1081 // uiButton
1082 
1083 
1086  RGB888 backgroundColor = RGB888(128, 128, 128);
1087  RGB888 downBackgroundColor = RGB888(128, 128, 255);
1090  RGB888 textColor = RGB888(0, 0, 0);
1091  FontInfo const * textFont = &FONT_std_14;
1092  uint8_t bitmapTextSpace = 4;
1093  Bitmap const * bitmap = nullptr;
1094  Bitmap const * downBitmap = nullptr;
1095 };
1096 
1097 
1101 enum class uiButtonKind {
1102  Button,
1103  Switch,
1104 };
1105 
1106 
1108 class uiButton : public uiControl {
1109 
1110 public:
1111 
1122  uiButton(uiWindow * parent, char const * text, const Point & pos, const Size & size, uiButtonKind kind = uiButtonKind::Button, bool visible = true);
1123 
1124  virtual ~uiButton();
1125 
1126  virtual void processEvent(uiEvent * event);
1127 
1135  void setText(char const * value);
1136 
1142  char const * text() { return m_text; }
1143 
1149  uiButtonStyle & buttonStyle() { return m_buttonStyle; }
1150 
1158  bool down() { return m_down; }
1159 
1167  void setDown(bool value);
1168 
1169 
1170  // Delegates
1171 
1177  Delegate<> onChange;
1178 
1179 
1180 private:
1181 
1182  void paintButton();
1183  void paintContent(Rect const & rect);
1184 
1185  void trigger();
1186 
1187 
1188  uiButtonStyle m_buttonStyle;
1189 
1190  char * m_text;
1191  int m_textExtent; // calculated by setText(). TODO: changing font doesn't update m_textExtent!
1192 
1193  bool m_down;
1194 
1195  uiButtonKind m_kind;
1196 
1197 };
1198 
1199 
1200 
1202 // uiTextEdit
1203 // single line text edit
1204 
1205 
1212  RGB888 backgroundColor = RGB888(128, 128, 128);
1215  RGB888 textColor = RGB888(0, 0, 0);
1216  FontInfo const * textFont = &FONT_std_14;
1217 };
1218 
1219 
1224  uint8_t hasCaret : 1;
1225  uint8_t allowEdit : 1;
1227  uiTextEditProps()
1228  : hasCaret(true),
1229  allowEdit(true)
1230  {
1231  }
1232 };
1233 
1234 
1240 class uiTextEdit : public uiControl {
1241 
1242 public:
1243 
1253  uiTextEdit(uiWindow * parent, char const * text, const Point & pos, const Size & size, bool visible = true);
1254 
1255  virtual ~uiTextEdit();
1256 
1257  virtual void processEvent(uiEvent * event);
1258 
1264  uiTextEditStyle & textEditStyle() { return m_textEditStyle; }
1265 
1271  uiTextEditProps & textEditProps() { return m_textEditProps; }
1272 
1280  void setText(char const * value);
1281 
1287  char const * text() { return m_text; }
1288 
1289 
1290  // Delegates
1291 
1295  Delegate<> onChange;
1296 
1297 
1298 protected:
1299 
1300  virtual Rect getEditRect();
1301 
1302 private:
1303 
1304  void paintTextEdit();
1305  void paintContent();
1306 
1307  uint8_t const * getCharInfo(char ch, int * width);
1308  int charColumnToWindowX(int col);
1309  void updateCaret();
1310  void moveCursor(int col, int selCol);
1311  int getColFromMouseX(int mouseX);
1312  void handleKeyDown(uiKeyEventInfo key);
1313  void checkAllocatedSpace(int requiredLength);
1314  void insert(char c);
1315  void removeSel();
1316  int getWordPosAtLeft();
1317  int getWordPosAtRight();
1318  void selectWordAt(int mouseX);
1319 
1320 
1321  uiTextEditStyle m_textEditStyle;
1322  uiTextEditProps m_textEditProps;
1323 
1324  char * m_text;
1325  int m_textLength; // text length NOT including ending zero
1326  int m_textSpace; // actual space allocated including ending zero
1327 
1328  // rectangle where text will be painted (this is also the text clipping rect)
1329  Rect m_contentRect; // updated on painting
1330 
1331  // where text starts to be painted. Values less than m_contentRect.X1 are used to show characters which do not fit in m_contentRect
1332  int m_viewX;
1333 
1334  // character index of cursor position (0 = at first char)
1335  int m_cursorCol;
1336 
1337  // character index at start of selection (not included if < m_cursorCol, included if > m_cursorCol)
1338  int m_selCursorCol;
1339 
1340 };
1341 
1342 
1343 
1345 // uiLabel
1346 
1347 
1350  FontInfo const * textFont = &FONT_std_14;
1351  RGB888 backgroundColor = RGB888(255, 255, 255);
1352  RGB888 textColor = RGB888(0, 0, 0);
1353 };
1354 
1355 
1357 class uiLabel : public uiControl {
1358 
1359 public:
1360 
1370  uiLabel(uiWindow * parent, char const * text, const Point & pos, const Size & size = Size(0, 0), bool visible = true);
1371 
1372  virtual ~uiLabel();
1373 
1374  virtual void processEvent(uiEvent * event);
1375 
1383  void setText(char const * value);
1384 
1392  void setTextFmt(const char *format, ...);
1393 
1399  char const * text() { return m_text; }
1400 
1406  uiLabelStyle & labelStyle() { return m_labelStyle; }
1407 
1413  void update();
1414 
1415 
1416 private:
1417 
1418  void paintLabel();
1419 
1420 
1421  char * m_text;
1422 
1423  uiLabelStyle m_labelStyle;
1424 
1425  uint16_t m_textExtent; // calculated by setText()
1426 
1427  uint8_t m_autoSize;
1428 
1429 };
1430 
1431 
1432 
1434 // uiImage
1435 
1436 
1439  RGB888 backgroundColor = RGB888(255, 255, 255);
1440 };
1441 
1442 
1444 class uiImage : public uiControl {
1445 
1446 public:
1447 
1457  uiImage(uiWindow * parent, Bitmap const * bitmap, const Point & pos, const Size & size = Size(0, 0), bool visible = true);
1458 
1459  virtual ~uiImage();
1460 
1461  virtual void processEvent(uiEvent * event);
1462 
1470  void setBitmap(Bitmap const * bitmap);
1471 
1477  Bitmap const * bitmap() { return m_bitmap; }
1478 
1484  uiImageStyle & imageStyle() { return m_imageStyle; }
1485 
1486 
1487 private:
1488 
1489  void paintImage();
1490 
1491 
1492  Bitmap const * m_bitmap;
1493 
1494  uiImageStyle m_imageStyle;
1495 
1496  bool m_autoSize;
1497 
1498 };
1499 
1500 
1501 
1503 // uiPanel
1504 
1505 
1508  RGB888 backgroundColor = RGB888(128, 128, 128);
1509 };
1510 
1511 
1513 class uiPanel : public uiControl {
1514 
1515 public:
1516 
1525  uiPanel(uiWindow * parent, const Point & pos, const Size & size, bool visible = true);
1526 
1527  virtual ~uiPanel();
1528 
1529  virtual void processEvent(uiEvent * event);
1530 
1536  uiPanelStyle & panelStyle() { return m_panelStyle; }
1537 
1538 
1539 private:
1540 
1541  void paintPanel();
1542 
1543 
1544  uiPanelStyle m_panelStyle;
1545 };
1546 
1547 
1548 
1550 // uiPaintBox
1551 
1552 
1555  RGB888 backgroundColor = RGB888(128, 128, 128);
1556 };
1557 
1558 
1561 
1562 public:
1563 
1572  uiPaintBox(uiWindow * parent, const Point & pos, const Size & size, bool visible = true);
1573 
1574  virtual ~uiPaintBox();
1575 
1576  virtual void processEvent(uiEvent * event);
1577 
1583  uiPaintBoxStyle & paintBoxStyle() { return m_paintBoxStyle; }
1584 
1586 
1587  // Delegates
1588 
1594  Delegate<Rect> onPaint;
1595 
1596 
1597 private:
1598 
1599  void paintPaintBox();
1600 
1601 
1602  uiPaintBoxStyle m_paintBoxStyle;
1603 };
1604 
1605 
1606 
1608 // uiCustomListBox
1609 
1610 
1613  RGB888 backgroundColor = RGB888(128, 128, 128);
1617  int itemHeight = 16;
1618  FontInfo const * textFont = &FONT_std_14;
1619  RGB888 textColor = RGB888(0, 0, 0);
1620  RGB888 selectedTextColor = RGB888(255, 255, 255);
1621 };
1622 
1623 
1626 
1627 public:
1628 
1637  uiCustomListBox(uiWindow * parent, const Point & pos, const Size & size, bool visible = true);
1638 
1639  virtual ~uiCustomListBox();
1640 
1641  virtual void processEvent(uiEvent * event);
1642 
1648  uiListBoxStyle & listBoxStyle() { return m_listBoxStyle; }
1649 
1655  int firstSelectedItem();
1656 
1662  int lastSelectedItem();
1663 
1671  void selectItem(int index, bool add = false, bool range = false);
1672 
1676  void deselectAll();
1677 
1678 
1679  // Delegates
1680 
1686  Delegate<> onChange;
1687 
1691  Delegate<> onKillFocus;
1692 
1696  Delegate<uiKeyEventInfo> onKeyUp;
1697 
1698 
1699 protected:
1700 
1701  void setScrollBar(uiOrientation orientation, int position, int visible, int range, bool repaintScrollbar);
1702 
1703  // must be implemented by inherited class
1704  virtual int items_getCount() = 0;
1705  virtual void items_deselectAll() = 0;
1706  virtual void items_select(int index, bool select) = 0;
1707  virtual bool items_selected(int index) = 0;
1708  virtual void items_draw(int index, const Rect & itemRect) = 0;
1709 
1710 private:
1711 
1712  void paintListBox();
1713  int getItemAtMousePos(int mouseX, int mouseY);
1714  void handleMouseDown(int mouseX, int mouseY);
1715  void handleKeyDown(uiKeyEventInfo key);
1716  void makeItemVisible(int index);
1717 
1718 
1719  uiListBoxStyle m_listBoxStyle;
1720  int m_firstVisibleItem; // the item on the top
1721 };
1722 
1723 
1724 
1726 // uiListBox
1727 
1729 class uiListBox : public uiCustomListBox {
1730 
1731 public:
1732 
1741  uiListBox(uiWindow * parent, const Point & pos, const Size & size, bool visible = true);
1742 
1751  StringList & items() { return m_items; }
1752 
1753 protected:
1754 
1755  virtual int items_getCount() { return m_items.count(); }
1756  virtual void items_deselectAll() { m_items.deselectAll(); }
1757  virtual void items_select(int index, bool select) { m_items.select(index, select); }
1758  virtual bool items_selected(int index) { return m_items.selected(index); }
1759  virtual void items_draw(int index, const Rect & itemRect);
1760 
1761 
1762 private:
1763 
1764  StringList m_items;
1765 };
1766 
1767 
1769 // uiFileBrowser
1770 
1773 
1774 public:
1775 
1784  uiFileBrowser(uiWindow * parent, const Point & pos, const Size & size, bool visible = true);
1785 
1793  void setDirectory(char const * path);
1794 
1800  char const * directory() { return m_dir.directory(); }
1801 
1807  int count() { return m_dir.count(); }
1808 
1814  char const * filename();
1815 
1821  bool isDirectory();
1822 
1823  void processEvent(uiEvent * event);
1824 
1828  void update();
1829 
1835  FileBrowser & content() { return m_dir; }
1836 
1837 
1838 protected:
1839 
1840  virtual int items_getCount() { return m_dir.count(); }
1841  virtual void items_deselectAll() { m_selected = -1; }
1842  virtual void items_select(int index, bool select);
1843  virtual bool items_selected(int index) { return index == m_selected; }
1844  virtual void items_draw(int index, const Rect & itemRect);
1845 
1846 private:
1847 
1848  void enterSubDir();
1849 
1850  FileBrowser m_dir;
1851  int m_selected; // -1 = no sel
1852 
1853 };
1854 
1855 
1856 
1858 // uiComboBox
1859 
1860 
1864  RGB888 buttonColor = RGB888(128, 128, 128);
1865 };
1866 
1867 
1870  uint8_t openOnFocus : 1;
1872  uiComboBoxProps()
1873  : openOnFocus(true)
1874  {
1875  }
1876 };
1877 
1878 
1880 class uiComboBox : public uiTextEdit
1881 {
1882 
1883 public:
1884 
1894  uiComboBox(uiWindow * parent, const Point & pos, const Size & size, int listHeight, bool visible = true);
1895 
1896  ~uiComboBox();
1897 
1898  virtual void processEvent(uiEvent * event);
1899 
1907  StringList & items() { return m_listBox->items(); }
1908 
1914  uiComboBoxStyle & comboBoxStyle() { return m_comboBoxStyle; }
1915 
1921  uiListBoxStyle & listBoxStyle() { return m_listBox->listBoxStyle(); }
1922 
1928  uiComboBoxProps & comboBoxProps() { return m_comboBoxProps; }
1929 
1935  int selectedItem() { return m_listBox->firstSelectedItem(); }
1936 
1942  void selectItem(int index);
1943 
1944 
1945  // Delegates
1946 
1952  Delegate<> onChange;
1953 
1954 
1955 protected:
1956 
1957  virtual Rect getEditRect();
1958 
1959 
1960 private:
1961 
1962  void paintComboBox();
1963  Rect getButtonRect();
1964  int buttonWidth();
1965  void openListBox();
1966  void closeListBox();
1967  void switchListBox();
1968  void updateTextEdit();
1969 
1970 
1971  uiListBox * m_listBox;
1972  int m_listHeight;
1973  uiComboBoxStyle m_comboBoxStyle;
1974  uiComboBoxProps m_comboBoxProps;
1975 
1976 
1977 };
1978 
1979 
1980 
1982 // uiCheckBox
1983 
1984 
1987  RGB888 backgroundColor = RGB888(128, 128, 128);
1991 };
1992 
1993 
1997 enum class uiCheckBoxKind : int8_t {
1998  CheckBox,
1999  RadioButton,
2000 };
2001 
2002 
2009 class uiCheckBox : public uiControl {
2010 
2011 public:
2012 
2022  uiCheckBox(uiWindow * parent, const Point & pos, const Size & size, uiCheckBoxKind kind = uiCheckBoxKind::CheckBox, bool visible = true);
2023 
2024  virtual ~uiCheckBox();
2025 
2026  virtual void processEvent(uiEvent * event);
2027 
2033  uiCheckBoxStyle & checkBoxStyle() { return m_checkBoxStyle; }
2034 
2040  bool checked() { return m_checked; }
2041 
2049  void setChecked(bool value);
2050 
2056  int groupIndex() { return m_groupIndex; }
2057 
2063  void setGroupIndex(int value) { m_groupIndex = value; }
2064 
2065 
2066  // Delegates
2067 
2073  Delegate<> onChange;
2074 
2075 
2076 private:
2077 
2078  void paintCheckBox();
2079  void trigger();
2080  void unCheckGroup();
2081 
2082 
2083  uiCheckBoxStyle m_checkBoxStyle;
2084  bool m_checked;
2085  uiCheckBoxKind m_kind;
2086  int16_t m_groupIndex; // -1 = no group
2087 
2088 };
2089 
2090 
2091 
2093 // uiSlider
2094 
2095 
2098  RGB888 backgroundColor = RGB888(255, 255, 255);
2099  RGB888 slideColor = RGB888(0, 128, 128);
2100  RGB888 rangeColor = RGB888(0, 128, 255);
2101  RGB888 gripColor = RGB888(0, 0, 255);
2102  RGB888 ticksColor = RGB888(255, 255, 255);
2103 };
2104 
2105 
2107 class uiSlider : public uiControl {
2108 
2109 public:
2110 
2120  uiSlider(uiWindow * parent, const Point & pos, const Size & size, uiOrientation orientation, bool visible = true);
2121 
2122  virtual ~uiSlider();
2123 
2124  virtual void processEvent(uiEvent * event);
2125 
2131  uiSliderStyle & sliderStyle() { return m_sliderStyle; }
2132 
2138  int position() { return m_position; }
2139 
2145  void setPosition(int value);
2146 
2152  int min() { return m_min; }
2153 
2159  int max() { return m_max; }
2160 
2168  void setup(int min, int max, int ticksFrequency);
2169 
2170 
2176  Delegate<> onChange;
2177 
2178 
2179 private:
2180 
2181  void paintSlider();
2182  Rect getGripRect();
2183  void moveGripTo(int x, int y);
2184  void handleKeyDown(uiKeyEventInfo key);
2185 
2186 
2187  uiSliderStyle m_sliderStyle;
2188  uiOrientation m_orientation;
2189 
2190  int16_t m_position;
2191  int16_t m_min;
2192  int16_t m_max;
2193  int16_t m_ticksFrequency;
2194 };
2195 
2196 
2197 
2198 
2199 
2201 // uiApp
2202 
2203 
2205 struct uiAppProps {
2206  uint16_t caretBlinkingTime = 500;
2207  uint16_t doubleClickTime = 250;
2208  bool realtimeReshaping = false;
2209 };
2210 
2211 
2216  Cancel,
2217  Button1,
2218  Button2,
2219  Button3,
2220 };
2221 
2222 
2226 enum class uiMessageBoxIcon {
2227  None,
2228  Question,
2229  Info,
2230  Warning,
2231  Error,
2232 };
2233 
2234 
2235 struct ModalWindowState {
2236  uiWindow * window;
2237  uiWindow * prevFocusedWindow;
2238  uiWindow * prevActiveWindow;
2239  uiWindow * prevModal;
2240  int modalResult;
2241 };
2242 
2243 
2244 class Keyboard;
2245 class Mouse;
2246 
2247 
2254 class uiApp : public uiEvtHandler {
2255 
2256 public:
2257 
2258  uiApp();
2259 
2260  virtual ~uiApp();
2261 
2271  int run(DisplayController * displayController, Keyboard * keyboard = nullptr, Mouse * mouse = nullptr);
2272 
2278  void quit(int exitCode);
2279 
2287  bool postEvent(uiEvent const * event);
2288 
2296  bool insertEvent(uiEvent const * event);
2297 
2298  void postDebugMsg(char const * msg);
2299 
2300  virtual void processEvent(uiEvent * event);
2301 
2307  void processEvents();
2308 
2317  uiFrame * rootWindow() { return m_rootWindow; }
2318 
2327  uiWindow * activeWindow() { return m_activeWindow; }
2328 
2338  uiWindow * setActiveWindow(uiWindow * value);
2339 
2352  uiWindow * focusedWindow() { return m_focusedWindow; }
2353 
2364  uiWindow * setFocusedWindow(uiWindow * value);
2365 
2376  uiWindow * moveFocus(int delta);
2377 
2378  void captureMouse(uiWindow * window);
2379 
2387  uiWindow * capturedMouseWindow() { return m_capturedMouseWindow; }
2388 
2394  void repaintWindow(uiWindow * window);
2395 
2401  void repaintRect(Rect const & rect);
2402 
2410  void moveWindow(uiWindow * window, int x, int y);
2411 
2419  void resizeWindow(uiWindow * window, int width, int height);
2420 
2427  void resizeWindow(uiWindow * window, Size size);
2428 
2435  void reshapeWindow(uiWindow * window, Rect const & rect);
2436 
2444  uiWindow * screenToWindow(Point & point);
2445 
2452  void showWindow(uiWindow * window, bool value);
2453 
2465  int showModalWindow(uiWindow * window);
2466 
2476  ModalWindowState * initModalWindow(uiWindow * window);
2477 
2488  bool processModalWindowEvents(ModalWindowState * state, int timeout);
2489 
2500  int endModalWindow(ModalWindowState * state);
2501 
2508  void maximizeWindow(uiWindow * window, bool value);
2509 
2516  void minimizeWindow(uiWindow * window, bool value);
2517 
2518  void combineMouseMoveEvents(bool value) { m_combineMouseMoveEvents = value; }
2519 
2520  void showCaret(uiWindow * window);
2521 
2522  void setCaret(bool value);
2523 
2524  void setCaret(Point const & pos);
2525 
2526  void setCaret(Rect const & rect);
2527 
2539  uiTimerHandle setTimer(uiEvtHandler * dest, int periodMS);
2540 
2548  void killTimer(uiTimerHandle handle);
2549 
2555  uiAppProps & appProps() { return m_appProps; }
2556 
2562  void destroyWindow(uiWindow * window);
2563 
2564  void cleanWindowReferences(uiWindow * window);
2565 
2573  void enableKeyboardAndMouseEvents(bool value);
2574 
2587  uiMessageBoxResult messageBox(char const * title, char const * text, char const * button1Text, char const * button2Text = nullptr, char const * button3Text = nullptr, uiMessageBoxIcon icon = uiMessageBoxIcon::Question);
2588 
2604  uiMessageBoxResult inputBox(char const * title, char const * text, char * inOutString, int maxLength, char const * button1Text, char const * button2Text = nullptr);
2605 
2609  virtual void init();
2610 
2611  // delegates
2612 
2619  Delegate<uiTimerHandle> onTimer;
2620 
2621  Keyboard * keyboard() { return m_keyboard; }
2622 
2623  Mouse * mouse() { return m_mouse; }
2624 
2625  DisplayController * displayController() { return m_displayController; }
2626 
2627  Canvas * canvas() { return m_canvas; }
2628 
2629 
2630 protected:
2631 
2632  bool getEvent(uiEvent * event, int timeOutMS);
2633  bool peekEvent(uiEvent * event, int timeOutMS);
2634 
2635 
2636 private:
2637 
2638  void preprocessEvent(uiEvent * event);
2639  void preprocessMouseEvent(uiEvent * event);
2640  void preprocessKeyboardEvent(uiEvent * event);
2641  void filterModalEvent(uiEvent * event);
2642 
2643  static void timerFunc(TimerHandle_t xTimer);
2644 
2645  void blinkCaret(bool forceOFF = false);
2646  void suspendCaret(bool value);
2647 
2648 
2649  DisplayController * m_displayController;
2650 
2651  Canvas * m_canvas;
2652 
2653  Keyboard * m_keyboard;
2654 
2655  Mouse * m_mouse;
2656 
2657  uiAppProps m_appProps;
2658 
2659  QueueHandle_t m_eventsQueue;
2660 
2661  uiFrame * m_rootWindow;
2662 
2663  uiWindow * m_activeWindow; // foreground window. Also gets keyboard events (other than focused window)
2664 
2665  uiWindow * m_focusedWindow; // window that captures keyboard events (other than active window)
2666 
2667  uiWindow * m_capturedMouseWindow; // window that has captured mouse
2668 
2669  uiWindow * m_freeMouseWindow; // window where mouse is over
2670 
2671  uiWindow * m_modalWindow; // current modal window
2672 
2673  bool m_combineMouseMoveEvents;
2674 
2675  uiWindow * m_caretWindow; // nullptr = caret is not visible
2676  Rect m_caretRect; // caret rect relative to m_caretWindow
2677  uiTimerHandle m_caretTimer;
2678  int m_caretInvertState; // -1 = suspended, 1 = rect reversed (cat visible), 0 = rect not reversed (caret invisible)
2679 
2680  int m_lastMouseUpTimeMS; // time (MS) at mouse up. Used to measure double clicks
2681  Point m_lastMouseUpPos; // screen position of last mouse up
2682 };
2683 
2684 
2685 
2686 
2687 } // end of namespace
2688 
2689 
2690 
Bitmap const * bitmap
Definition: fabui.h:1093
uiWindowStyle & windowStyle()
Sets or gets window style.
Definition: fabui.h:491
Represents a 24 bit RGB color.
Definition: displaycontroller.h:206
void update()
Reloads current directory content and repaints.
Definition: fabui.cpp:3777
uiCheckBoxKind
Specifies the combobox behaviour.
Definition: fabui.h:1997
VirtualKey VK
Definition: fabui.h:136
FontInfo const * textFont
Definition: fabui.h:1091
uint8_t SHIFT
Definition: fabui.h:140
void quit(int exitCode)
Terminates application and free resources.
Definition: fabui.cpp:295
bool hasFocus()
Determines whether this window or control has focus.
Definition: fabui.cpp:1634
uiApp * app()
Determines the app that owns this object.
Definition: fabui.h:273
char const * text()
Determines button text.
Definition: fabui.h:1142
Definition: displaycontroller.h:453
uiImageStyle & imageStyle()
Sets or gets image style.
Definition: fabui.h:1484
RGB888 backgroundColor
Definition: fabui.h:672
uint8_t hasMinimizeButton
Definition: fabui.h:693
virtual void setScrollBar(uiOrientation orientation, int position, int visible, int range, bool repaintScrollbar=true)
Sets scrollbar position, visible portion and range.
Definition: fabui.cpp:3110
RGB888 titleColor
Definition: fabui.h:675
uiPanelStyle & panelStyle()
Sets or gets panel style.
Definition: fabui.h:1536
void moveWindow(uiWindow *window, int x, int y)
Moves a window.
Definition: fabui.cpp:660
Delegate onChange
Slider changed event delegate.
Definition: fabui.h:2176
char const * filename()
Currently selected filename.
Definition: fabui.cpp:3751
uiWindow * capturedMouseWindow()
Determines which window is capturing mouse.
Definition: fabui.h:2387
A class with a set of drawing methods.
Definition: canvas.h:66
uiComboBoxStyle & comboBoxStyle()
Sets or gets combobox style.
Definition: fabui.h:1914
uiListBoxStyle & listBoxStyle()
Sets or gets listbox style.
Definition: fabui.h:1648
int VScrollBarRange()
Determines vertical scrollbar range.
Definition: fabui.h:1013
uiWindow * screenToWindow(Point &point)
Determines which window a point belongs to.
Definition: fabui.cpp:464
A frame is a window with a title bar, maximize/minimize/close buttons and that is resizeable or movea...
Definition: fabui.h:725
Contains details about the key event.
Definition: fabui.h:135
void setText(char const *value)
Sets button text.
Definition: fabui.cpp:2264
RGB888 textColor
Definition: fabui.h:1619
void setup(int min, int max, int ticksFrequency)
Sets minimum, maximum position and ticks frequency.
Definition: fabui.cpp:4174
int HScrollBarVisible()
Determines horizontal scrollbar visible portion (aka thumb size) of the scrollable content...
Definition: fabui.h:974
Delegate< uiTimerHandle > onTimer
Timer event delegate.
Definition: fabui.h:2619
RGB888 scrollBarBackgroundColor
Definition: fabui.h:905
void setPosition(int value)
Sets the slider position.
Definition: fabui.cpp:4164
void minimizeWindow(uiWindow *window, bool value)
Minimizes or restores a window.
Definition: fabui.cpp:771
uiTimerHandle setTimer(uiEvtHandler *dest, int periodMS)
Setups a timer.
Definition: fabui.cpp:788
void repaintRect(Rect const &rect)
Repaints a screen area.
Definition: fabui.cpp:651
uint8_t right
Definition: fabui.h:337
Represents the whole application base class.
Definition: fabui.h:2254
void resizeWindow(uiWindow *window, int width, int height)
Resizes a window.
Definition: fabui.cpp:666
void selectItem(int index)
Selects an item.
Definition: fabui.cpp:3857
uint8_t minimized
Definition: fabui.h:305
uiPaintBoxStyle & paintBoxStyle()
Sets or gets paintbox style.
Definition: fabui.h:1583
Bitmap const * downBitmap
Definition: fabui.h:1094
uint8_t left
Definition: fabui.h:335
virtual void init()
Method to inherit to implement an application.
Definition: fabui.cpp:483
RGB888 activeBorderColor
Definition: fabui.h:326
A scrollable control is a control with optionally vertical and/or horizontal scrollbars.
Definition: fabui.h:930
uiWindow * setFocusedWindow(uiWindow *value)
Sets the focused window (control)
Definition: fabui.cpp:585
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:488
RGB888 mouseOverBackgroundColor
Definition: fabui.h:1989
Base class for all visible UI elements (Frames and Controls)
Definition: fabui.h:345
char const * text()
Determines label text.
Definition: fabui.h:1399
uiLabelStyle & labelStyle()
Sets or gets label style.
Definition: fabui.h:1406
bool isMouseOver()
Determines whether the mouse is over this window.
Definition: fabui.h:536
Delegate onChange
Change event delegate.
Definition: fabui.h:1686
bool processModalWindowEvents(ModalWindowState *state, int timeout)
Processes all messages from modal window.
Definition: fabui.cpp:713
int lastSelectedItem()
Gets the last selected item.
Definition: fabui.cpp:3632
RGB888 backgroundColor
Definition: fabui.h:1212
ModalWindowState * initModalWindow(uiWindow *window)
Begins modal window processing.
Definition: fabui.cpp:695
RGB888 rangeColor
Definition: fabui.h:2100
Rect transformRect(Rect const &rect, uiWindow *baseWindow)
Transforms rectangle origins from current window to another one.
Definition: fabui.cpp:1281
void maximizeWindow(uiWindow *window, bool value)
Maximizes or restores a window.
Definition: fabui.cpp:764
uiWindow * lastChild()
Gets last child.
Definition: fabui.h:397
Delegate onPaint
Paint event delegate.
Definition: fabui.h:830
Delegate onChange
Change event delegate.
Definition: fabui.h:2073
RGB888 buttonBackgroundColor
Definition: fabui.h:1863
uiWindow * activeWindow()
Gets a pointer to the currently active window.
Definition: fabui.h:2327
RGB888 focusedBackgroundColor
Definition: fabui.h:1614
RGB888 mouseOverBackgroundColor
Definition: fabui.h:1213
FontInfo const * titleFont
Definition: fabui.h:677
RGB888 backgroundColor
Definition: fabui.h:1351
uiTextEditProps & textEditProps()
Sets or gets text edit properties.
Definition: fabui.h:1271
uint8_t bottom
Definition: fabui.h:338
Shows a list of selectable string items.
Definition: fabui.h:1729
uint8_t top
Definition: fabui.h:336
int endModalWindow(ModalWindowState *state)
Ends modal window processing.
Definition: fabui.cpp:743
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:2914
uint8_t focusable
Definition: fabui.h:313
Delegate onChange
Text edit event delegate.
Definition: fabui.h:1295
char const * directory()
Determines absolute path of current directory.
Definition: fabutils.h:419
void enableKeyboardAndMouseEvents(bool value)
Enables or disables mouse and keyboard events.
Definition: fabui.cpp:1106
Contains the listbox style.
Definition: fabui.h:1612
uiListBoxStyle & listBoxStyle()
Sets or gets listbox style.
Definition: fabui.h:1921
Contains the slider style.
Definition: fabui.h:2097
Point pos()
Determines the window position relative to parent window.
Definition: fabui.h:425
Delegate< uiTimerHandle > onTimer
Timer event delegate.
Definition: fabui.h:815
uiControl(uiWindow *parent, const Point &pos, const Size &size, bool visible)
Creates an instance of the object.
Definition: fabui.cpp:2209
bool isDirectory()
Determines whether currently selected item is a directory.
Definition: fabui.cpp:3757
uiWindow * parent()
Determines the parent window.
Definition: fabui.h:498
uint8_t borderSize
Definition: fabui.h:328
This file contains fabgl::DisplayController definition.
Base class of all UI elements that can receive events.
Definition: fabui.h:258
Sets or gets text edit style.
Definition: fabui.h:1211
uint8_t GUI
Definition: fabui.h:141
Contains the paintbox style.
Definition: fabui.h:1554
int HScrollBarRange()
Determines horizontal scrollbar range.
Definition: fabui.h:984
Properties of the combobox.
Definition: fabui.h:1869
uiWindow * moveFocus(int delta)
Move focus to a control with current focus index plus a delta.
Definition: fabui.cpp:619
RGB888 activeTitleColor
Definition: fabui.h:676
uiMessageBoxIcon
Icon displayed by the uiApp.messageBox() method.
Definition: fabui.h:2226
RGB888 backgroundColor
Definition: fabui.h:1439
RGB888 buttonColor
Definition: fabui.h:1864
int count()
Determines number of files in current directory.
Definition: fabui.h:1807
The PS2 Keyboard controller class.
Definition: keyboard.h:160
void setScrollBar(uiOrientation orientation, int position, int visible, int range, bool repaintScrollbar)
Sets scrollbar position, visible portion and range.
Definition: fabui.cpp:3641
FontInfo const * textFont
Definition: fabui.h:1618
This file contains fabgl::Canvas definition.
A panel is used to contain and to group some controls.
Definition: fabui.h:1513
Represents a checkbox or a radiobutton.
Definition: fabui.h:2009
uint8_t resizeable
Definition: fabui.h:689
void showWindow(uiWindow *window, bool value)
Makes a window visible or invisible.
Definition: fabui.cpp:687
uint8_t hasCaret
Definition: fabui.h:1224
virtual Rect clientRect(uiOrigin origin)
Determines the client area bounding box.
Definition: fabui.cpp:1319
int VScrollBarPos()
Determines position of the vertical scrollbar thumb.
Definition: fabui.h:994
Point clientPos()
Determines position of the client area.
Definition: fabui.cpp:1332
void bringOnTop()
Brings this window on top.
Definition: fabui.cpp:1258
bool realtimeReshaping
Definition: fabui.h:2208
void reshapeWindow(uiWindow *window, Rect const &rect)
Reshapes a window.
Definition: fabui.cpp:679
Delegate onChange
Button changed event delegate.
Definition: fabui.h:1177
void setText(char const *value)
Sets label text.
Definition: fabui.cpp:2841
void destroyWindow(uiWindow *window)
Destroys a window.
Definition: fabui.cpp:879
uiTextEdit(uiWindow *parent, char const *text, const Point &pos, const Size &size, bool visible=true)
Creates an instance of the object.
Definition: fabui.cpp:2384
uiWindow * prev()
Gets previous sibling.
Definition: fabui.h:383
uiFrameProps & frameProps()
Sets or gets frame properties.
Definition: fabui.h:781
Properties of the application.
Definition: fabui.h:2205
uiFileBrowser(uiWindow *parent, const Point &pos, const Size &size, bool visible=true)
Creates an instance of the object.
Definition: fabui.cpp:3713
Contains the scrollable control style.
Definition: fabui.h:904
Represents a button control. A button can have text and optionally a bitmap.
Definition: fabui.h:1108
RGB888 selectedBackgroundColor
Definition: fabui.h:1615
uiButtonKind
Specifies the button kind.
Definition: fabui.h:1101
uiAppProps & appProps()
Sets or gets application properties.
Definition: fabui.h:2555
RGB888 textColor
Definition: fabui.h:1090
RGB888 focusedBackgroundColor
Definition: fabui.h:1214
void update()
Updates the label content.
Definition: fabui.cpp:2864
Contains the label style.
Definition: fabui.h:1349
void bringAfter(uiWindow *insertionPoint)
Brings this window after another one.
Definition: fabui.cpp:1264
Describes mouse absolute position, scroll wheel delta and buttons status.
Definition: fabutils.h:208
uint8_t moveable
Definition: fabui.h:690
Point mouseDownPos()
Determines mouse position when left button was down.
Definition: fabui.h:505
RGB888 borderColor
Definition: fabui.h:325
uint16_t caretBlinkingTime
Definition: fabui.h:2206
RGB888 mouseOverBackgroundButtonColor
Definition: fabui.h:680
int position()
Determines slider position.
Definition: fabui.h:2138
uiFrameStyle & frameStyle()
Sets or gets frame style.
Definition: fabui.h:774
int run(DisplayController *displayController, Keyboard *keyboard=nullptr, Mouse *mouse=nullptr)
Initializes application and executes the main event loop.
Definition: fabui.cpp:188
Rect rect(uiOrigin origin)
Determines the window bounding box.
Definition: fabui.cpp:1303
uiWindowState state()
Determines the window state.
Definition: fabui.h:477
int focusIndex()
Determines the focus index (aka tab-index)
Definition: fabui.h:577
VirtualKey
Represents each possible real or derived (SHIFT + real) key.
Definition: fabutils.h:534
RGB888 titleBackgroundColor
Definition: fabui.h:673
Represents the coordinate of a point.
Definition: fabutils.h:125
Represents an image.
Definition: displaycontroller.h:414
Size size()
Determines the window size.
Definition: fabui.h:441
Contains the window style.
Definition: fabui.h:323
Properties of the frame.
Definition: fabui.h:688
RGB888 buttonColor
Definition: fabui.h:678
void setFocusIndex(int value)
Sets the focus index (aka tab-index)
Definition: fabui.h:568
This file contains some utility classes and functions.
RGB888 activeButtonColor
Definition: fabui.h:679
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:2821
Definition: canvas.cpp:31
uint8_t activable
Definition: fabui.h:312
RGB888 selectedTextColor
Definition: fabui.h:1620
CursorName
This enum defines a set of predefined mouse cursors.
Definition: displaycontroller.h:451
RGB888 checkedBackgroundColor
Definition: fabui.h:1988
uiWindow * firstChild()
Gets first child.
Definition: fabui.h:390
Delegate< uiKeyEventInfo > onKeyUp
Key-up event delegate.
Definition: fabui.h:825
void repaint()
Repaints this window.
Definition: fabui.cpp:1297
Specifies the object type.
Definition: fabui.h:205
int count()
Determines number of files in current directory.
Definition: fabutils.h:426
Contains some window options.
Definition: fabui.h:311
Delegate onChangeVScrollBar
Vertical scrollbar change event delegate.
Definition: fabui.h:1026
uiPanel(uiWindow *parent, const Point &pos, const Size &size, bool visible=true)
Creates an instance of the object.
Definition: fabui.cpp:2980
uint8_t visible
Definition: fabui.h:303
void exitModal(int modalResult)
Exits from a modal window.
Definition: fabui.cpp:1626
StringList & items()
A list of strings representing the listbox content.
Definition: fabui.h:1751
uint8_t active
Definition: fabui.h:306
RGB888 activeTitleBackgroundColor
Definition: fabui.h:674
MouseStatus status
Definition: fabui.h:147
Contains the button style.
Definition: fabui.h:1085
RGB888 mouseDownBackgroundColor
Definition: fabui.h:1089
void repaintWindow(uiWindow *window)
Repaints a window.
Definition: fabui.cpp:645
uint8_t hasCloseButton
Definition: fabui.h:691
Represents a rectangle.
Definition: fabutils.h:158
void setText(char const *value)
Replaces current text.
Definition: fabui.cpp:2411
uint8_t changedButton
Definition: fabui.h:148
uiWindowProps & windowProps()
Sets or gets window properties.
Definition: fabui.h:484
uiScrollableControl(uiWindow *parent, const Point &pos, const Size &size, bool visible=true)
Creates an instance of the object.
Definition: fabui.cpp:3085
uiTextEditStyle & textEditStyle()
Sets or gets text edit style.
Definition: fabui.h:1264
uiComboBoxProps & comboBoxProps()
Sets or gets combobox properties.
Definition: fabui.h:1928
void setTitleFmt(const char *format,...)
Sets window title as formatted text.
Definition: fabui.cpp:1696
uiScrollableControlStyle & scrollableControlStyle()
Sets or gets control style.
Definition: fabui.h:955
uiSliderStyle & sliderStyle()
Sets or gets slider style.
Definition: fabui.h:2131
Represents a text edit control.
Definition: fabui.h:1240
uint8_t scrollBarSize
Definition: fabui.h:908
uiComboBox(uiWindow *parent, const Point &pos, const Size &size, int listHeight, bool visible=true)
Creates an instance of the object.
Definition: fabui.cpp:3823
uint8_t RALT
Definition: fabui.h:138
Delegate onShow
Show window event delegate.
Definition: fabui.h:793
Contains details about the mouse event.
Definition: fabui.h:146
int max()
Gets maximum position.
Definition: fabui.h:2159
void deselectAll()
Deselects all selected items.
Definition: fabui.cpp:3564
int VScrollBarVisible()
Determines vertical scrollbar visible portion (aka thumb size) of the scrollable content.
Definition: fabui.h:1003
Delegate onDblClick
Mouse double click event delegate.
Definition: fabui.h:597
StringList & items()
A list of strings representing items of the combobox.
Definition: fabui.h:1907
Delegate onKillFocus
Kill focus event delegate.
Definition: fabui.h:1691
uiWindow * focusedWindow()
Gets the focused window (control)
Definition: fabui.h:2352
int showModalWindow(uiWindow *window)
Makes a window visible and handles it has a modal window.
Definition: fabui.cpp:755
uiPaintBox(uiWindow *parent, const Point &pos, const Size &size, bool visible=true)
Creates an instance of the object.
Definition: fabui.cpp:3031
void selectItem(int index, bool add=false, bool range=false)
Selects a listbox item.
Definition: fabui.cpp:3524
uiCheckBoxStyle & checkBoxStyle()
Sets or gets checkbox style.
Definition: fabui.h:2033
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:918
void killTimer(uiTimerHandle handle)
Kills a timer.
Definition: fabui.cpp:796
uiButtonStyle & buttonStyle()
Sets or gets button style.
Definition: fabui.h:1149
RGB888 backgroundColor
Definition: fabui.h:2098
void setChecked(bool value)
Sets current checkbox or radiobutton checked status.
Definition: fabui.cpp:4105
uint8_t CTRL
Definition: fabui.h:139
Rect clientRect(uiOrigin origin)
Determines the client area bounding box.
Definition: fabui.cpp:1724
RGB888 backgroundColor
Definition: fabui.h:1613
bool hasChildren()
Determines whether this window has children.
Definition: fabui.h:404
This file contains FabGL library configuration settings, like number of supported colors...
RGB888 backgroundColor
Definition: fabui.h:1508
RGB888 focusedBorderColor
Definition: fabui.h:327
Base class of all UI elements like windows and controls.
Definition: fabui.h:232
RGB888 downBackgroundColor
Definition: fabui.h:1087
RGB888 backgroundColor
Definition: fabui.h:1987
uiObjectType & objectType()
Determines the object type.
Definition: fabui.h:245
A paintbox control allows applications to perform custom drawings providing uiPaintBox.onPaint delegate. A paintbox can have horizontal and vertical scrollbars.
Definition: fabui.h:1560
Delegate< uiKeyEventInfo > onKeyDown
Key-down event delegate.
Definition: fabui.h:820
uint8_t bitmapTextSpace
Definition: fabui.h:1092
Represents a bidimensional size.
Definition: fabutils.h:143
uiWindow * next()
Gets next sibling.
Definition: fabui.h:374
FontInfo const * textFont
Definition: fabui.h:1216
CursorName defaultCursor
Definition: fabui.h:324
char const * directory()
Determines current directory.
Definition: fabui.h:1800
Delegate onClick
Mouse click event delegate.
Definition: fabui.h:589
RGB888 backgroundColor
Definition: fabui.h:1555
int min()
Gets minimum position.
Definition: fabui.h:2152
uiListBox(uiWindow *parent, const Point &pos, const Size &size, bool visible=true)
Creates an instance of the object.
Definition: fabui.cpp:3690
int firstSelectedItem()
Gets the first selected item.
Definition: fabui.cpp:3622
Definition: fabui.h:671
uint8_t maximized
Definition: fabui.h:304
Represents the base abstract class for display controllers.
Definition: displaycontroller.h:596
uiSlider(uiWindow *parent, const Point &pos, const Size &size, uiOrientation orientation, bool visible=true)
Creates an instance of the object.
Definition: fabui.cpp:4141
RGB888 textColor
Definition: fabui.h:1352
Contains the listbox style.
Definition: fabui.h:1862
uint8_t openOnFocus
Definition: fabui.h:1870
uint8_t focusedBorderSize
Definition: fabui.h:329
Delegate onResize
Resize window event delegate.
Definition: fabui.h:807
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:3998
void setDirectory(char const *path)
Sets current directory.
Definition: fabui.cpp:3743
RGB888 backgroundColor
Definition: fabui.h:1086
A label is a static text UI element.
Definition: fabui.h:1357
uiCustomListBox(uiWindow *parent, const Point &pos, const Size &size, bool visible=true)
Creates an instance of the object.
Definition: fabui.cpp:3428
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:2238
RGB888 focusedSelectedBackgroundColor
Definition: fabui.h:1616
int itemHeight
Definition: fabui.h:1617
RGB888 mouseOverScrollBarForegroundColor
Definition: fabui.h:907
Properties of the text edit.
Definition: fabui.h:1223
RGB888 mouseOverBackgroundColor
Definition: fabui.h:1088
RGB888 slideColor
Definition: fabui.h:2099
Contains the image style.
Definition: fabui.h:1438
RGB888 gripColor
Definition: fabui.h:2101
This is the base class for all controls. A control can have focus and is not activable.
Definition: fabui.h:878
RGB888 scrollBarForegroundColor
Definition: fabui.h:906
Contains anchors enable/disable switches.
Definition: fabui.h:334
bool down()
Determines whether the switch button is down or up.
Definition: fabui.h:1158
void setTextFmt(const char *format,...)
Sets label formatted text.
Definition: fabui.cpp:2850
uiFrame * rootWindow()
Gets a pointer to the root window.
Definition: fabui.h:2317
Shows generic a list of selectable items.
Definition: fabui.h:1625
uiOrigin
Specifies window rectangle origin.
Definition: fabui.h:294
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:494
void setBitmap(Bitmap const *bitmap)
Sets image bitmap.
Definition: fabui.cpp:2932
Delegate onHide
Hide window event delegate.
Definition: fabui.h:800
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:2107
int groupIndex()
Determines radiobutton group index.
Definition: fabui.h:2056
uint16_t doubleClickTime
Definition: fabui.h:2207
Specifies current window state.
Definition: fabui.h:302
RGB888 textColor
Definition: fabui.h:1215
int selectedItem()
Represents currently selected item.
Definition: fabui.h:1935
RGB888 foregroundColor
Definition: fabui.h:1990
char const * title()
Determines the window title.
Definition: fabui.h:749
uint8_t hasMaximizeButton
Definition: fabui.h:692
Rect clientRect(uiOrigin origin)
Determines the client area bounding box.
Definition: fabui.cpp:3409
This is a combination of a listbox and a single-line editable textbox.
Definition: fabui.h:1880
int HScrollBarPos()
Determines position of the horizontal scrollbar thumb.
Definition: fabui.h:965
Shows and navigates Virtual Filesystem content.
Definition: fabui.h:1772
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:1017
FileBrowser & content()
Contains current directory representation.
Definition: fabui.h:1835
uiWindow * setActiveWindow(uiWindow *value)
Sets the active window.
Definition: fabui.cpp:541
The PS2 Mouse controller class.
Definition: mouse.h:99
Delegate< Rect > onPaint
Paint event delegate.
Definition: fabui.h:1594
uint8_t LALT
Definition: fabui.h:137
FontInfo const * textFont
Definition: fabui.h:1350
void setTitle(char const *value)
Sets window title.
Definition: fabui.cpp:1688
Contains the checkbox style.
Definition: fabui.h:1986
bool checked()
Determines whether the checkbox or radiobutton is checked.
Definition: fabui.h:2040
uint8_t allowEdit
Definition: fabui.h:1225
uiAnchors & anchors()
Allows to switch on or off anchors.
Definition: fabui.h:561
Contains the panel style.
Definition: fabui.h:1507
void processEvents()
Processes all events in queue.
Definition: fabui.cpp:282
char const * text()
Gets current content of the text edit.
Definition: fabui.h:1287
uiMessageBoxResult
Return values from uiApp.messageBox() method.
Definition: fabui.h:2215
RGB888 mouseOverButtonColor
Definition: fabui.h:681
uiWindow(uiWindow *parent, const Point &pos, const Size &size, bool visible)
Creates an instance of the object.
Definition: fabui.cpp:1129
void setDown(bool value)
Sets button state of a switch button.
Definition: fabui.cpp:2364
uiOrientation
Item direction/orientation.
Definition: fabui.h:193
Size clientSize()
Determines the client area size.
Definition: fabui.cpp:1326
Delegate< uiKeyEventInfo > onKeyUp
Key-up event delegate.
Definition: fabui.h:1696
Delegate onChange
Change event delegate.
Definition: fabui.h:1952
Bitmap const * bitmap()
Gets image bitmap.
Definition: fabui.h:1477
void setGroupIndex(int value)
Sets radiobutton group index.
Definition: fabui.h:2063
Image control to display a static bitmap.
Definition: fabui.h:1444
uiFrame(uiWindow *parent, char const *title, const Point &pos, const Size &size, bool visible=true)
Creates an instance of the object.
Definition: fabui.cpp:1669
Delegate onChangeHScrollBar
Horizontal scrollbar change event delegate.
Definition: fabui.h:1021
FileBrowser allows basic file system operations (dir, mkdir, remove and rename)
Definition: fabutils.h:389