Gamedev Framework (gf)  0.6.0
A C++11 framework for 2D games
UI.h
1 /*
2  * Gamedev Framework (gf)
3  * Copyright (C) 2016-2017 Julien Bernard
4  *
5  * This software is provided 'as-is', without any express or implied
6  * warranty. In no event will the authors be held liable for any damages
7  * arising from the use of this software.
8  *
9  * Permission is granted to anyone to use this software for any purpose,
10  * including commercial applications, and to alter it and redistribute it
11  * freely, subject to the following restrictions:
12  *
13  * 1. The origin of this software must not be misrepresented; you must not
14  * claim that you wrote the original software. If you use this software
15  * in a product, an acknowledgment in the product documentation would be
16  * appreciated but is not required.
17  * 2. Altered source versions must be plainly marked as such, and must not be
18  * misrepresented as being the original software.
19  * 3. This notice may not be removed or altered from any source distribution.
20  */
21 #ifndef GF_UI_H
22 #define GF_UI_H
23 
24 #include <cstdint>
25 #include <memory>
26 
27 #include "ArrayRef.h"
28 #include "BufferRef.h"
29 #include "Drawable.h"
30 #include "Event.h"
31 #include "Flags.h"
32 #include "Font.h"
33 #include "Path.h"
34 #include "Portability.h"
35 #include "StringRef.h"
36 #include "Types.h"
37 #include "Vector.h"
38 
39 namespace gf {
40 #ifndef DOXYGEN_SHOULD_SKIP_THIS
41 inline namespace v1 {
42 #endif
43 
44  class Texture;
45 
46  /**
47  * @ingroup graphics
48  * @brief Properties for windows and window-like elements
49  *
50  * @sa gf::UIWindowFlags
51  */
52  enum class UIWindow : uint32_t {
53  Border = 0x0001, ///< The window has a border
54  Movable = 0x0002, ///< The window can be moved by the user
55  Scalable = 0x0004, ///< The window is scalable by the user
56  Closable = 0x0008, ///< The window can be closed with an icon in the header
57  Minimizable = 0x0010, ///< The window can be minimized with an icon in the header
58  NoScrollbar = 0x0020, ///< The window has no scrollbar
59  Title = 0x0040, ///< The window has a title in the header
60  ScrollAutoHide = 0x0080, ///< The window's scrollbar can hide automatically
61  Background = 0x0100, ///< The window is in the background
62  ScaleLeft = 0x0200, ///< The window's scaler is on the left
63  NoInput = 0x0400, ///< The window can not scale, move or get focus
64  };
65 
66  /**
67  * @ingroup graphics
68  * @brief Flags composed of window properties
69  *
70  * @sa gf::UIWindow
71  */
72  using UIWindowFlags = Flags<UIWindow>;
73 
74  /**
75  * @ingroup graphics
76  * @brief Collapse property of a tree
77  */
78  enum class UICollapse : bool {
79  Minimized = false, ///< The tree is minimized
80  Maximized = true, ///< The tree is maximized
81  };
82 
83  /**
84  * @ingroup graphics
85  * @brief Layout property for rows
86  */
87  enum class UILayout {
88  Dynamic = 0, ///< The row has a dynamic layout
89  Static = 1, ///< The row has a static layout
90  };
91 
92  /**
93  * @ingroup graphics
94  * @brief The type of tree
95  */
96  enum class UITree {
97  Node = 0, ///< The tree is a node, generally an internal node of the tree
98  Tab = 1, ///< The tree is a tabulation, generally the root of the tree
99  };
100 
101  /**
102  * @ingroup graphics
103  * @brief The alignment of the text
104  *
105  * @sa gf::Alignment
106  */
107  enum class UIAlignment {
108  Left = 0x10 | 0x01, ///< Left alignment
109  Center = 0x10 | 0x02, ///< Centered alignment
110  Right = 0x10 | 0x04, ///< Right alignment
111  };
112 
113  /**
114  * @ingroup graphics
115  * @brief State for scrollbar in groups
116  */
117  using UIScroll = Vector2u;
118 
119  /**
120  * @ingroup graphics
121  * @brief Behavior for buttons
122  */
123  enum class UIButtonBehavior {
124  Default = 0, ///< The button is active once
125  Repeater = 1, ///< The button is active as long as it is pressed
126  };
127 
128  /**
129  * @ingroup graphics
130  * @brief State of the progress bar
131  */
132  enum class UIProgress : bool {
133  Fixed = false, ///< The progress bar is fixed
134  Modifyable = true, ///< The progress bar can be modified
135  };
136 
137  /**
138  * @ingroup graphics
139  * @brief A representative symbol
140  */
141  enum class UISymbol {
142  None, ///< No symbol
143  X, ///< X symbol
144  Underscore, ///< Underscore
145  CircleSolid, ///< Solid circle
146  CircleOutline, ///< Outline circle
147  RectSolid, ///< Solid rectangle
148  RectOutline, ///< Outline rectangle
149  TriangleUp, ///< Triangle up
150  TriangleDown, ///< Triangle down
151  TriangleLeft, ///< Triangle left
152  TriangleRight, ///< Triangle right
153  Plus, ///< Plus
154  Minus, ///< Minus
155  };
156 
157  /**
158  * @ingroup graphics
159  * @brief Properties for edit widgets
160  */
161  enum class UIEdit : uint32_t {
162  Default = 0x0000,
163  ReadOnly = 0x0001,
164  AutoSelect = 0x0002,
165  SigEnter = 0x0004,
166  AllowTab = 0x0008,
167  NoCursor = 0x0010,
168  Selectable = 0x0020,
169  Clipboard = 0x0040,
170  CtrlEnterNewline = 0x0080,
171  NoHorizontalScroll = 0x0100,
172  AlwaysInsertMode = 0x0200,
173  Multiline = 0x0400,
174  GotoEndOnActivate = 0x0800,
175  };
176 
177  /**
178  * @ingroup graphics
179  * @brief Flags composed of edit properties
180  *
181  * @sa gf::UIEdit
182  */
183  using UIEditFlags = Flags<UIEdit>;
184 
185  /**
186  * @ingroup graphics
187  * @brief Predefined flags for edit
188  */
190  static const UIEditFlags Simple;
191  static const UIEditFlags Field;
192  static const UIEditFlags Box;
193  static const UIEditFlags Editor;
194  };
195 
196  /**
197  * @ingroup graphics
198  * @brief Properties for edit events
199  */
200  enum class UIEditEvent : uint32_t {
201  Active = 0x0001, ///< Edit widget is currently being modified
202  Inactive = 0x0002, ///< Edit widget is not active and is not being modified
203  Activated = 0x0004, ///< Edit widget went from state inactive to state active
204  Deactivated = 0x0008, ///< Edit widget went from state active to state inactive
205  Commited = 0x0010, ///< Edit widget has received an enter and lost focus
206  };
207 
208  /**
209  * @ingroup graphics
210  * @brief Flags composed of edit events properties
211  *
212  * @sa gf::UIEditEvent
213  */
214  using UIEditEventFlags = Flags<UIEditEvent>;
215 
216  /**
217  * @ingroup graphics
218  * @brief Filters for edit
219  */
220  enum class UIEditFilter {
221  Default,
222  Ascii,
223  Float,
224  Decimal,
225  Hex,
226  Oct,
227  Binary,
228  };
229 
230  /**
231  * @ingroup graphics
232  * @brief Data for file selector
233  *
234  * @sa gf::UI::fileSelector()
235  */
236  struct UIBrowser {
237  Path currentPath; ///< The current path for searching
238  Path selectedPath; ///< The selected path
239  };
240 
241  /**
242  * @ingroup graphics
243  * @brief Type of popup
244  */
245  enum class UIPopup {
246  Static = 0, ///< The popup is static
247  Dynamic = 1, ///< The popup is dynamic
248  };
249 
250  /**
251  * @ingroup graphics
252  * @brief A predefined style
253  */
254  enum class UIPredefinedStyle {
255  Default, ///< The default style
256  White, ///< A light gray style
257  Red, ///< A red and gray style
258  Blue, ///< A blue and light gray style
259  Dark, ///< A dark gray and dark blue style
260  };
261 
262  /**
263  * @ingroup graphics
264  * @brief Context for an immediate mode graphical interface
265  *
266  * When building a graphical interfaces, you have basically two choices:
267  * either the retained mode where you build a hierarchy of widgets, or the
268  * immediate mode where widgets are built from function calls. Choosing the
269  * best mode between these two may be
270  * [controversial](http://gamedev.stackexchange.com/questions/24103/immediate-gui-yae-or-nay).
271  * gf offers an immediate mode graphical interface through this class.
272  *
273  * The immediate mode graphical interface (or imgui) of gf is based on
274  * [Nuklear](https://github.com/vurtun/nuklear), a C library with the same
275  * purpose. gf does not provide (yet?) all the features of Nuklear, but a
276  * fair amount of the main features. Nuklear is totally abstracted in gf so
277  * you won't see any interface from Nuklear and you won't be able to
278  * interact directly with Nuklear. If you need a feature that is not
279  * implemented yet, just ask.
280  *
281  * This imgui library can be used to create tools for the game developpers.
282  * It's easy and quick to build a functional interface with an imgui
283  * library. You can see some examples in gf itself. You can also use this
284  * library to build in-game interfaces, even if it's not its primary
285  * purpose. If your game is heavily based on a graphical interface, it
286  * may be a good option.
287  *
288  *
289  * # Creating a context
290  *
291  * An instance of gf::UI is a context for all the windows that will be
292  * created. You must provide a font and a character size that will be
293  * used in the interface. Generally, you create the instance of gf::UI
294  * at the beginning of your application and then you use this instance
295  * throughout your application.
296  *
297  * @snippet snippets/doc_class_ui.cc context
298  *
299  * By default, the character size is 13.
300  *
301  *
302  * # Managing events
303  *
304  * The imgui needs to know the input events that occurred in the frame time.
305  * So when polling the events in your main loop, you must pass the events
306  * to the context so that it can be updated and take the good decision. For
307  * example, if you press on a button, the mouse event will be transmitted
308  * and the library will know that you pressed a button and act accordingly.
309  *
310  * @snippet snippets/doc_class_ui.cc events
311  *
312  *
313  * # Creating a window
314  *
315  * Then, you have to create a window. The window has a title that may appear
316  * in the titlebar. It also identifies the window so two windows must have
317  * two different titles. The window also has bounds, i.e. a position and a
318  * size, that indicates where to put the window in the screen. There is no
319  * automatic placement of windows. Finally, the window can have many
320  * properties (see gf::UIWindow) that modify the interaction with the window.
321  * They are defined at the window creation.
322  *
323  * @snippet snippets/doc_class_ui.cc window
324  *
325  * For each begin(), you have to call end() to finish the window.
326  * You can create as many windows as you want as long as they have different
327  * titles.
328  *
329  *
330  * # Determining a layout
331  *
332  * Before drawing any widget, you have to define a layout. Think of it as a
333  * sort of specification for how to organize the following widgets. There
334  * are three types of layouts: rows, groups, trees.
335  *
336  * ## Rows
337  *
338  * Rows are the most common type of layout. The row layout is very flexible.
339  *
340  * A row can be either static (it does not adapt to the width of the window)
341  * of dynamic (it adapts to the width of the window). It can be fixed (all
342  * columns have the same width) or custom (columns' widths are specified,
343  * either relatively or absolutely), and in the latter case the
344  * specification can be global or in immediate mode. Here is a summary of
345  * the functions to use in each case:
346  *
347  * - dynamic row
348  * - fixed column layout: layoutRowDynamic()
349  * - custom column layout
350  * - array-based: layoutRow() with gf::UILayout::Dynamic
351  * - immediate-mode: layoutRowBegin() with gf::UILayout::Dynamic, layoutRowPush(), layoutRowEnd()
352  * - static row
353  * - fixed column layout: layoutRowStatic()
354  * - custom column layout
355  * - array-based: layoutRow() with gf::UILayout::Static
356  * - immediate-mode: layoutRowBegin() with gf::UILayout::Static, layoutRowPush(), layoutRowEnd()
357  *
358  * ## Trees
359  *
360  * A tree is a tree-like layout. It can be collapsed to hide its content
361  * except its title. There are two types of trees: tabs and nodes (see
362  * gf::UITree). A tab tree is generally put at the root of the tree, it is
363  * represented with a border around the title. A node tree is generally the
364  * son of a tab tree or another node tree. It is represented without any
365  * border.
366  *
367  * In both cases, you need a variable of type gf::UICollapse to handle the
368  * current state of the tree: minimized or maximized.
369  *
370  * @snippet snippets/doc_class_ui.cc tree
371  *
372  * ## Groups
373  *
374  * A group is a kind of window inside a window. It can have a title, a
375  * border and a scrollbar. However, a group needs to be put in a row.
376  * See groupBegin() and groupEnd().
377  *
378  * @snippet snippets/doc_class_ui.cc group
379  *
380  *
381  * # Adding widgets and more
382  *
383  * The library offers common kinds of widgets:
384  * - [labels](https://en.wikipedia.org/wiki/Label_%28control%29): label(), selectableLabel()
385  * - [buttons](https://en.wikipedia.org/wiki/Button_%28computing%29): buttonLabel(), buttonColor(), buttonSymbol(), buttonSymbolLabel()
386  * - [checkboxes](https://en.wikipedia.org/wiki/Checkbox): checkbox(), checkboxFlags()
387  * - [radio buttons](https://en.wikipedia.org/wiki/Radio_button): option(), radio()
388  * - [sliders](https://en.wikipedia.org/wiki/Slider_%28computing%29): sliderFloat(), sliderInt()
389  * - [progress bars](https://en.wikipedia.org/wiki/Progress_bar): progress()
390  * - [color pickers](https://en.wikipedia.org/wiki/Color_tool): colorPicker()
391  *
392  * Widgets often manipulate a reference to a user-provided variable that
393  * represents the state of the widget. This way, you can pass directly your
394  * model variables to the graphical interface without duplicating the data.
395  * Some widgets return a boolean that indicates a state change. For example,
396  * a button returns true if it has been pressed.
397  *
398  * The library also offers common graphical interface elements:
399  * - [popups](https://en.wikipedia.org/wiki/Popover_%28GUI%29): popupBegin(), popupEnd()
400  * - [combo boxes](https://en.wikipedia.org/wiki/Combo_box): combobox(), comboboxSeparator()
401  * - [contextuals](https://en.wikipedia.org/wiki/Context_menu): contextualBegin(), contextualEnd()
402  * - [tooltips](https://en.wikipedia.org/wiki/Tooltip): tooltip()
403  * - [menus](https://en.wikipedia.org/wiki/Menu_28computing%29): menubarBegin(), menubarEnd()
404  *
405  * Many of these elements have a begin/end API. The end part must be called
406  * if the begin part succeeded, i.e. returned true. Some elements offer a
407  * simplified version without begin/end for common cases.
408  *
409  */
410  class GF_API UI : public Drawable {
411  public:
412  /**
413  * @brief The default size for the font
414  */
415  static constexpr unsigned DefaultCharacterSize = 13;
416 
417  /**
418  * @brief Constructor
419  *
420  * @param font The font used in the interface
421  * @param characterSize The size of the font used in the interface
422  */
423  UI(Font& font, unsigned characterSize = DefaultCharacterSize);
424 
425  /**
426  * @brief Destructor
427  */
428  ~UI();
429 
430  /**
431  * @brief Deleted copy constructor
432  */
433  UI(const UI&) = delete;
434 
435  /**
436  * @brief Deleted copy assignment
437  */
438  UI& operator=(const UI&) = delete;
439 
440  /**
441  * @brief Move constructor
442  */
443  UI(UI&& other);
444 
445  /**
446  * @brief Move assignment
447  */
448  UI& operator=(UI&& other);
449 
450  /**
451  * @brief Update the internal state with an event
452  *
453  * This function must be called for every event that occur in a frame.
454  *
455  * @param event An event
456  */
457  void processEvent(const Event& event);
458 
459  /**
460  * @name Window
461  * @{
462  */
463 
464  /**
465  * @brief Create a window
466  *
467  * @snippet snippets/doc_class_ui.cc window
468  *
469  * @param title The title of the window
470  * @param bounds The area of the window
471  * @param flags The properties of the window
472  * @returns True is the content of the window is visible
473  *
474  * @sa end(), gf::UIWindow
475  */
476  bool begin(const std::string& title, const RectF& bounds, UIWindowFlags flags = None);
477 
478  /**
479  * @brief Finish a window
480  *
481  * @snippet snippets/doc_class_ui.cc window
482  *
483  * @sa begin()
484  */
485  void end();
486 
487  /**
488  * @brief Get the window bounds
489  *
490  * This function must be called between begin() and end().
491  *
492  * @returns The bounds of the current window
493  */
494  RectF windowGetBounds();
495 
496  /**
497  * @}
498  */
499 
500  /**
501  * @name Layout
502  * @{
503  */
504 
505  /**
506  * @brief Dynamic row with fixed column layout
507  *
508  * @param height The height of the row
509  * @param cols The number of columns in the row
510  *
511  * @sa layoutRowStatic()
512  */
513  void layoutRowDynamic(float height, int cols);
514 
515  /**
516  * @brief Static row with fixed column layout
517  *
518  * @param height The height of the row
519  * @param itemWidth The width of each item in the row
520  * @param cols The number of columns in the row
521  *
522  * @sa layoutRowDynamic()
523  */
524  void layoutRowStatic(float height, int itemWidth, int cols);
525 
526  /**
527  * @brief Start an immediate mode custom column layout
528  *
529  * @param format The format of the row: static or dynamic
530  * @param height The height of the row
531  * @param cols The number of columns in the row
532  *
533  * @sa layoutRowPush(), layoutRowEnd()
534  */
535  void layoutRowBegin(UILayout format, float height, int cols);
536 
537  /**
538  * @brief Specify the width of the next column
539  *
540  * @param width The width of the next column
541  *
542  * @sa layoutRowBegin(), layoutRowEnd()
543  */
544  void layoutRowPush(float width);
545 
546  /**
547  * @brief Finish an immediate mode custom column layout
548  *
549  * @sa layoutRowBegin(), layoutRowPush()
550  */
551  void layoutRowEnd();
552 
553  /**
554  * @brief Array-based custom column layout
555  *
556  * @param format The format of the row: static or dynamic
557  * @param height The height of the row
558  * @param ratio A reference to an array of ratios for the columns
559  */
560  void layoutRow(UILayout format, float height, ArrayRef<float> ratio);
561 
562  /**
563  * @brief An empty separator
564  *
565  * This function creates an empty row so you have to specify a new row.
566  *
567  * @param height The height of the row
568  */
569  void separator(float height);
570 
571  /**
572  * @}
573  */
574 
575  /**
576  * @name Layout: Group
577  * @{
578  */
579 
580  /**
581  * @brief Start a group
582  *
583  * The only allowed flags are UIWindow::Title, UIWindow::Border,
584  * UIWindow::NoScrollbar.
585  *
586  * @snippet snippets/doc_class_ui.cc group
587  *
588  * @param title The title of the group
589  * @param flags The properties of the group
590  * @returns True if the group is visible
591  *
592  * @sa groupEnd()
593  */
594  bool groupBegin(const std::string& title, UIWindowFlags flags = None);
595 
596  /**
597  * @brief Finish a group
598  *
599  * @snippet snippets/doc_class_ui.cc group
600  *
601  * @sa groupBegin()
602  */
603  void groupEnd();
604 
605  /**
606  * @brief Start a scrolled group
607  *
608  * The only allowed flags are UIWindow::Title, UIWindow::Border,
609  * UIWindow::NoScrollbar.
610  *
611  * @param scroll A state for representing the scroll
612  * @param title The title of the group
613  * @param flags The properties of the group
614  * @returns True if the group is visible
615  *
616  * @sa groupScrolledEnd()
617  */
618  bool groupScrolledBegin(UIScroll& scroll, const std::string& title, UIWindowFlags flags = None);
619 
620  /**
621  * @brief Finish a scrolled group
622  *
623  * @sa groupScrolledBegin()
624  */
625  void groupScrolledEnd();
626 
627  /**
628  * @}
629  */
630 
631  /**
632  * @name Layout: Tree
633  * @{
634  */
635 
636  /**
637  * @brief Start a tree layout
638  *
639  * @snippet snippets/doc_class_ui.cc tree
640  *
641  * @param type The type of tree: tab or node
642  * @param title The title of the tree
643  * @param state The collapse state
644  * @returns True if the tree is maximized
645  *
646  * @sa treePop()
647  */
648  bool treePush(UITree type, const std::string& title, UICollapse& state);
649 
650  /**
651  * @brief Finish a tree layout
652  *
653  * @snippet snippets/doc_class_ui.cc tree
654  *
655  * @sa treePush()
656  */
657  void treePop();
658 
659  /**
660  * @}
661  */
662 
663  /**
664  * @name Widgets: Labels
665  * @{
666  */
667 
668  /**
669  * @brief A simple label with text
670  *
671  * @param title The title of the label
672  * @param align The alignment of the text in the label
673  *
674  * @sa labelColored()
675  */
676  void label(StringRef title, UIAlignment align = UIAlignment::Left);
677 
678  /**
679  * @brief A label with colored text
680  *
681  * @param color The color of the text
682  * @param title The title of the label
683  * @param align The alignment of the text in the label
684  *
685  * @sa label()
686  */
687  void labelColored(const Color4f& color, StringRef title, UIAlignment align = UIAlignment::Left);
688 
689  /**
690  * @brief A simple label that can wrap
691  *
692  * @param title The title of the label
693  *
694  * @sa labelWrapColored()
695  */
696  void labelWrap(StringRef title);
697 
698  /**
699  * @brief A label with colored text that can wrap
700  *
701  * @param color The color of the text
702  * @param title The title of the label
703  *
704  * @sa labelWrap()
705  */
706  void labelWrapColored(const Color4f& color, StringRef title);
707 
708  /**
709  * @brief An image
710  *
711  * @param texture A texture
712  * @param textureRect A sub-rectangle of the texture to show
713  */
714  void image(const Texture& texture, const RectF& textureRect);
715 
716  /**
717  * @}
718  */
719 
720  /**
721  * @name Widgets: Buttons
722  * @{
723  */
724 
725  /**
726  * @brief Change the behavior of buttons
727  *
728  * @param behavior The new behavior of buttons
729  *
730  * @sa buttonPushBehavior(), buttonPopBehavior()
731  */
732  void buttonSetBehavior(UIButtonBehavior behavior);
733 
734  /**
735  * @brief Push a new behavior of buttons
736  *
737  * @param behavior The new behavior of buttons
738  *
739  * @sa buttonSetBehavior(), buttonPopBehavior()
740  */
741  bool buttonPushBehavior(UIButtonBehavior behavior);
742 
743  /**
744  * @brief Pop the previous behavior of buttons
745  *
746  * @sa buttonSetBehavior(), buttonPushBehavior()
747  */
748  bool buttonPopBehavior();
749 
750  /**
751  * @brief A button with a centered label
752  *
753  * @param title The title of the button
754  * @returns True if the button was pressed
755  *
756  * @sa buttonColor(), buttonSymbol(), buttonSymbolLabel()
757  */
758  bool buttonLabel(StringRef title);
759 
760  /**
761  * @brief A button with a color
762  *
763  * @param color The color of the button
764  * @returns True if the button was pressed
765  *
766  * @sa buttonLabel(), buttonSymbol(), buttonSymbolLabel()
767  */
768  bool buttonColor(const Color4f& color);
769 
770  /**
771  * @brief A button with a symbol
772  *
773  * @param symbol A symbol
774  * @returns True if the button was pressed
775  *
776  * @sa buttonLabel(), buttonColor(), buttonSymbolLabel()
777  */
778  bool buttonSymbol(UISymbol symbol);
779 
780  /**
781  * @brief A button with a symbol and a centered label
782  *
783  * @param symbol A symbol
784  * @param title The title of the button
785  * @param align The alignment of the symbol
786  * @returns True if the button was pressed
787  *
788  * @sa buttonLabel(), buttonColor(), buttonSymbol()
789  */
791 
792  /**
793  * @}
794  */
795 
796  /**
797  * @name Widgets: Checkbox
798  * @{
799  */
800 
801  /**
802  * @brief A checkbox with a title
803  *
804  * @param title The title of the checkbox
805  * @param active A reference to a boolean that indicates the state of the checkbox
806  * @returns True if the checkbox has changed its state
807  *
808  * @sa checkboxFlags()
809  */
810  bool checkbox(StringRef title, bool& active);
811 
812  /**
813  * @brief A checkbox with a title for flags
814  *
815  * @param title The title of the checkbox
816  * @param flags A reference to the state of flags
817  * @param value The flag value for this checkbox
818  * @returns True if the checkbox has changed its state
819  *
820  * @sa checkbox()
821  */
822  bool checkboxFlags(StringRef title, unsigned& flags, unsigned value);
823 
824  /**
825  * @}
826  */
827 
828  /**
829  * @name Widgets: Radio
830  * @{
831  */
832 
833  /**
834  * @brief A radio button without state
835  *
836  * @param title The title of the radio button
837  * @param active A boolean that indicates if the radio is chosen
838  * @returns True if the radio is pressed
839  *
840  * @sa radio()
841  */
842  bool option(StringRef title, bool active);
843 
844  /**
845  * @brief A radio button with a reference state
846  *
847  * @param title The title of the radio button
848  * @param active A reference to the state of the radio
849  * @returns True if the radio is pressed
850  *
851  * @sa option()
852  */
853  bool radio(StringRef title, bool& active);
854 
855  /**
856  * @}
857  */
858 
859  /**
860  * @name Widgets: Selectable
861  * @{
862  */
863 
864  /**
865  * @brief A selectable label
866  *
867  * @param title The title of the label
868  * @param align The alignment of the text in the label
869  * @param value A reference to the state of the selection
870  * @returns True if the state has changed
871  *
872  * @sa label()
873  */
874  bool selectableLabel(StringRef title, UIAlignment align, bool& value);
875 
876  /**
877  * @}
878  */
879 
880  /**
881  * @name Widgets: Slider
882  * @{
883  */
884 
885  /**
886  * @brief A slider for a float value
887  *
888  * @param min The minimum for the value
889  * @param val A reference to the value
890  * @param max The maximum for the value
891  * @param step A step when changing the value
892  * @returns True if the slider has changed
893  *
894  * @sa sliderInt()
895  */
896  bool sliderFloat(float min, float& val, float max, float step);
897 
898  /**
899  * @brief A slider for an int value
900  *
901  * @param min The minimum for the value
902  * @param val A reference to the value
903  * @param max The maximum for the value
904  * @param step A step when changing the value
905  * @returns True if the slider has changed
906  *
907  * @sa sliderFloat()
908  */
909  bool sliderInt(int min, int& val, int max, int step);
910 
911  /**
912  * @}
913  */
914 
915  /**
916  * @name Widgets: Progressbar
917  * @{
918  */
919 
920  /**
921  * @brief A progress bar
922  *
923  * @param current A reference to the state of the progress bar
924  * @param max The maximum of the progress bar (the minimum is zero)
925  * @param modifyable A property to indicate if the progress bar can be modified by the user or not
926  * @returns True if the progress bar has changed
927  */
928  bool progress(std::size_t& current, std::size_t max, UIProgress modifyable = UIProgress::Modifyable);
929 
930  /**
931  * @}
932  */
933 
934  /**
935  * @name Widgets: Color picker
936  * @{
937  */
938 
939  /**
940  * @brief A color picker
941  *
942  * @param color A reference to the state of the color picker, i.e. the current color
943  * @returns True if the color has changed
944  */
945  bool colorPicker(Color4f& color);
946 
947  /**
948  * @}
949  */
950 
951  /**
952  * @name Widgets: Property
953  * @{
954  */
955 
956  /**
957  * @brief A property for an integer
958  *
959  * @param name The name of the property
960  * @param min The minimum for the value
961  * @param val A reference to the value
962  * @param max The maximum for the value
963  * @param step A step when changing the value
964  * @param incPerPixel A step when modifying the value with the mouse
965  *
966  * @sa propertyFloat(), propertyDouble()
967  */
968  void propertyInt(const std::string& name, int min, int& val, int max, int step, float incPerPixel);
969 
970  /**
971  * @brief A property for a float
972  *
973  * @param name The name of the property
974  * @param min The minimum for the value
975  * @param val A reference to the value
976  * @param max The maximum for the value
977  * @param step A step when changing the value
978  * @param incPerPixel A step when modifying the value with the mouse
979  *
980  * @sa propertyInt(), propertyDouble()
981  */
982  void propertyFloat(const std::string& name, float min, float& val, float max, float step, float incPerPixel);
983 
984  /**
985  * @brief A property for a double
986  *
987  * @param name The name of the property
988  * @param min The minimum for the value
989  * @param val A reference to the value
990  * @param max The maximum for the value
991  * @param step A step when changing the value
992  * @param incPerPixel A step when modifying the value with the mouse
993  *
994  * @sa propertyInt(), propertyFloat()
995  */
996  void propertyDouble(const std::string& name, double min, double& val, double max, double step, float incPerPixel);
997 
998  /**
999  * @}
1000  */
1001 
1002  /**
1003  * @name Widgets: TextEdit
1004  * @{
1005  */
1006 
1007  UIEditEventFlags edit(UIEditFlags flags, BufferRef<char> buffer, std::size_t& length, UIEditFilter filter = UIEditFilter::Default);
1008 
1009  /**
1010  * @}
1011  */
1012 
1013  /**
1014  * @name Dialogs
1015  * @{
1016  */
1017 
1018  /**
1019  * @brief File selector
1020  *
1021  * @param browser State of the file selector
1022  * @param title The title of the file selector
1023  * @param bounds The area of the file selector
1024  * @returns True if the file selector is open
1025  */
1026  bool fileSelector(UIBrowser& browser, const std::string& title, const RectF& bounds);
1027 
1028  /**
1029  * @}
1030  */
1031 
1032  /**
1033  * @name Popups
1034  * @{
1035  */
1036 
1037  /**
1038  * @brief Start a popup window
1039  *
1040  * @param type The type of popup (static or dynamic)
1041  * @param title The title of the popup
1042  * @param flags The properties of the popup window
1043  * @param bounds The area of the popup window
1044  * @returns True if the popup is open
1045  *
1046  * @sa popupClose(), popupEnd()
1047  */
1048  bool popupBegin(UIPopup type, const std::string& title, UIWindowFlags flags, const RectF& bounds);
1049 
1050  /**
1051  * @brief Close a popup window
1052  *
1053  * @sa popupBegin(), popupEnd()
1054  */
1055  void popupClose();
1056 
1057  /**
1058  * @brief Finish a popup window
1059  *
1060  * @sa popupBegin(), popupClose()
1061  */
1062  void popupEnd();
1063 
1064  /**
1065  * @}
1066  */
1067 
1068  /**
1069  * @name Combo box
1070  * @{
1071  */
1072 
1073  /**
1074  * @brief A simple combo box with a list of item
1075  *
1076  * @param items The list of items in the combo box
1077  * @param selected A reference to the selected item in the combo box
1078  * @param itemHeight The height of the items in the list
1079  * @param size The size of the combo box
1080  *
1081  * @sa comboboxSeparator()
1082  */
1083  void combobox(const std::vector<std::string>& items, int& selected, int itemHeight, Vector2f size);
1084 
1085  /**
1086  * @brief A simple combo box with a string and a separator
1087  *
1088  * @param itemsSeparatedBySeparator A string with all the items separated by a separator
1089  * @param separator The separator used in the string
1090  * @param selected A reference to the selected item in the combo box
1091  * @param itemHeight The height of the items in the list
1092  * @param size The size of the combo box
1093  *
1094  * @sa combobox()
1095  */
1096  void comboboxSeparator(const std::string& itemsSeparatedBySeparator, char separator, int& selected, int itemHeight, Vector2f size);
1097 
1098  /**
1099  * @brief Start a combo box with a label
1100  *
1101  * @param selected The selected item that appears in the combo box
1102  * @param size The size of the combo box
1103  * @returns True if the combo box is open
1104  *
1105  * @sa comboClose(), comboEnd()
1106  */
1107  bool comboBeginLabel(StringRef selected, Vector2f size);
1108 
1109  /**
1110  * @brief Start a combo box with a color
1111  *
1112  * @param color The color that appears in the combo box
1113  * @param size The size of the combo box
1114  * @returns True if the combo box is open
1115  *
1116  * @sa comboClose(), comboEnd()
1117  */
1118  bool comboBeginColor(const Color4f& color, Vector2f size);
1119 
1120  /**
1121  * @brief Start a combo box with a symbol
1122  *
1123  * @param symbol The symbol that appears in the combo box
1124  * @param size The size of the combo box
1125  * @returns True if the combo box is open
1126  *
1127  * @sa comboClose(), comboEnd()
1128  */
1129  bool comboBeginSymbol(UISymbol symbol, Vector2f size);
1130 
1131  /**
1132  * @brief Start a combo box with a symbol and a label
1133  *
1134  * @param symbol The symbol that appears in the combo box
1135  * @param selected The selected item that appears in the combo box
1136  * @param size The size of the combo box
1137  * @returns True if the combo box is open
1138  *
1139  * @sa comboClose(), comboEnd()
1140  */
1141  bool comboBeginSymbolLabel(UISymbol symbol, StringRef selected, Vector2f size);
1142 
1143  /**
1144  * @brief A label inside the combo box
1145  *
1146  * @param title The title of the label
1147  * @param align The alignment of the text in the label
1148  * @returns True if the item is selected
1149  */
1151 
1152  /**
1153  * @brief A symbol and a label inside the combo box
1154  *
1155  * @param symbol The symbol of the item
1156  * @param title The title of the label
1157  * @param align The alignment of the text in the label
1158  * @returns True if the item is selected
1159  */
1161 
1162  /**
1163  * @brief Close a combo box
1164  *
1165  * @sa comboEnd()
1166  */
1167  void comboClose();
1168 
1169  /**
1170  * @brief Finish a combo box
1171  *
1172  * @sa comboBeginLabel(), comboBeginColor(), comboBeginSymbol(), comboBeginSymbolLabel()
1173  */
1174  void comboEnd();
1175 
1176  /**
1177  * @}
1178  */
1179 
1180  /**
1181  * @name Contextual
1182  * @{
1183  */
1184 
1185  /**
1186  * @brief Start a contextual window
1187  *
1188  * @param flags The properties of the contextual window
1189  * @param size The size of the contextual window
1190  * @param triggerBounds The bounds when the contextual should appear
1191  * @returns True if the contextual is open
1192  *
1193  * @sa contextualClose(), contextualEnd()
1194  */
1195  bool contextualBegin(UIWindowFlags flags, Vector2f size, const RectF& triggerBounds);
1196 
1197  /**
1198  * @brief A label inside the contextual window
1199  *
1200  * @param title The title of the label
1201  * @param align The alignment of the text in the label
1202  * @returns True if the item is selected
1203  */
1205 
1206  /**
1207  * @brief A symbol and a label inside the contextual window
1208  *
1209  * @param symbol The symbol of the item
1210  * @param title The title of the label
1211  * @param align The alignment of the text in the label
1212  * @returns True if the item is selected
1213  */
1215 
1216  /**
1217  * @brief Close the contextual window
1218  *
1219  * @sa contextualBegin(), contextualEnd()
1220  */
1221  void contextualClose();
1222 
1223  /**
1224  * @brief Finish the contextual window
1225  *
1226  * @sa contextualBegin(), contextualClose()
1227  */
1228  void contextualEnd();
1229 
1230  /**
1231  * @}
1232  */
1233 
1234  /**
1235  * @name Tooltip
1236  * @{
1237  */
1238 
1239  /**
1240  * @brief A simple tooltip with a text
1241  *
1242  * @param text The text of the tooltip
1243  */
1244  void tooltip(const std::string& text);
1245 
1246  /**
1247  * @brief Start a tooltip
1248  *
1249  * @param width The with of the tooltip
1250  * @returns True if the tooltip is open
1251  *
1252  * @sa tooltipEnd()
1253  */
1254  bool tooltipBegin(float width);
1255 
1256  /**
1257  * @brief Finish a tooltip
1258  *
1259  * @sa tooltipBegin()
1260  */
1261  void tooltipEnd();
1262 
1263  /**
1264  * @}
1265  */
1266 
1267  /**
1268  * @name Menu
1269  * @{
1270  */
1271 
1272  /**
1273  * @brief Start a menu bar
1274  *
1275  * @sa menubarEnd()
1276  */
1277  void menubarBegin();
1278 
1279  /**
1280  * @brief Finish a menu bar
1281  *
1282  * @sa menubarBegin()
1283  */
1284  void menubarEnd();
1285 
1286  /**
1287  * @brief Start a menu with a label
1288  *
1289  * @param title The title of the label
1290  * @param align The alignment of the text in the label
1291  * @param size The size of the menu
1292  * @returns True if the menu is open
1293  *
1294  * @sa menuClose(), menuEnd()
1295  */
1296  bool menuBeginLabel(StringRef title, UIAlignment align, Vector2f size);
1297 
1298  /**
1299  * @brief Start a menu with a symbol
1300  *
1301  * @param id A unique identifier for the menu
1302  * @param symbol A symbol for the menu
1303  * @param size The size of the menu
1304  * @returns True if the menu is open
1305  *
1306  * @sa menuClose(), menuEnd()
1307  */
1308  bool menuBeginSymbol(const std::string& id, UISymbol symbol, Vector2f size);
1309 
1310  /**
1311  * @brief Start a menu with a symbol and a label
1312  *
1313  * @param symbol A symbol for the menu
1314  * @param title The title of the label
1315  * @param align The alignment of the text in the label
1316  * @param size The size of the menu
1317  * @returns True if the menu is open
1318  *
1319  * @sa menuClose(), menuEnd()
1320  */
1321  bool menuBeginSymbolLabel(UISymbol symbol, StringRef title, UIAlignment align, Vector2f size);
1322 
1323  /**
1324  * @brief A label inside the menu
1325  *
1326  * @param title The title of the label
1327  * @param align The alignment of the text in the label
1328  * @returns True if the item is selected
1329  */
1331 
1332  /**
1333  * @brief A symbol and a label inside the menu
1334  *
1335  * @param symbol The symbol of the item
1336  * @param title The title of the label
1337  * @param align The alignment of the text in the label
1338  * @returns True if the item is selected
1339  */
1341 
1342  /**
1343  * @brief Close a menu
1344  *
1345  * @sa menuEnd()
1346  */
1347  void menuClose();
1348 
1349  /**
1350  * @brief Finish a menu
1351  *
1352  * @sa menuClose(), menuBeginLabel(), menuBeginSymbol(), menuBeginSymbolLabel()
1353  */
1354  void menuEnd();
1355 
1356  /**
1357  * @}
1358  */
1359 
1360  /**
1361  * @name Utilities
1362  * @{
1363  */
1364 
1365  /**
1366  * @brief Get the current widget bounds
1367  *
1368  * @returns The bounds of the widget
1369  */
1370  RectF getWidgetBounds();
1371 
1372  /**
1373  * @brief Check if the widget is hovered by the mouse
1374  *
1375  * You must do this check just after the layout specification
1376  *
1377  * @returns True if the mouse hovers the widget
1378  */
1379  bool isWidgetHovered();
1380 
1381  /**
1382  * @brief Create a horizontal spacing to fill some columns
1383  *
1384  * @param cols The number of columns.
1385  */
1386  void spacing(int cols);
1387 
1388  /**
1389  * @}
1390  */
1391 
1392  /**
1393  * @name Style
1394  * @{
1395  */
1396 
1397  /**
1398  * @brief Set a predefined style for all the windows and the widgets
1399  *
1400  * @param style The predefined style
1401  *
1402  * @sa gf::UIPredefinedStyle
1403  */
1405 
1406  /**
1407  * @}
1408  */
1409 
1410  virtual void draw(RenderTarget &target, RenderStates states) override;
1411 
1412  private:
1413  enum class State {
1414  Start,
1415  Input,
1416  Setup,
1417  Draw,
1418  };
1419 
1420  void setState(State state);
1421 
1422  private:
1423  struct UIImpl;
1424 
1425  std::unique_ptr<UIImpl> m_impl;
1426  };
1427 
1428 
1429 #ifndef DOXYGEN_SHOULD_SKIP_THIS
1430 }
1431 #endif
1432 
1433 #ifndef DOXYGEN_SHOULD_SKIP_THIS
1434 template<>
1435 struct EnableBitmaskOperators<UIWindow> {
1436  static constexpr bool value = true;
1437 };
1438 
1439 template<>
1440 struct EnableBitmaskOperators<UIEdit> {
1441  static constexpr bool value = true;
1442 };
1443 
1444 template<>
1445 struct EnableBitmaskOperators<UIEditEvent> {
1446  static constexpr bool value = true;
1447 };
1448 #endif
1449 
1450 }
1451 
1452 #endif // GF_UI_H
The window&#39;s scrollbar can hide automatically.
void setPredefinedStyle(UIPredefinedStyle style)
Set a predefined style for all the windows and the widgets.
void popupClose()
Close a popup window.
The window can be moved by the user.
The row has a dynamic layout.
UI(const UI &)=delete
Deleted copy constructor.
The tree is a node, generally an internal node of the tree.
The row has a static layout.
void labelColored(const Color4f &color, StringRef title, UIAlignment align=UIAlignment::Left)
A label with colored text.
bool isWidgetHovered()
Check if the widget is hovered by the mouse.
UILayout
Layout property for rows.
Definition: UI.h:87
bool fileSelector(UIBrowser &browser, const std::string &title, const RectF &bounds)
File selector.
void tooltipEnd()
Finish a tooltip.
Edit widget is not active and is not being modified.
void comboEnd()
Finish a combo box.
The button is active once.
bool groupScrolledBegin(UIScroll &scroll, const std::string &title, UIWindowFlags flags=None)
Start a scrolled group.
void label(StringRef title, UIAlignment align=UIAlignment::Left)
A simple label with text.
static constexpr unsigned DefaultCharacterSize
The default size for the font.
Definition: UI.h:415
Edit widget is currently being modified.
bool menuBeginSymbolLabel(UISymbol symbol, StringRef title, UIAlignment align, Vector2f size)
Start a menu with a symbol and a label.
bool comboBeginSymbol(UISymbol symbol, Vector2f size)
Start a combo box with a symbol.
UIEditEvent
Properties for edit events.
Definition: UI.h:200
void image(const Texture &texture, const RectF &textureRect)
An image.
Base class for all render targets (window, texture, ...)
Definition: RenderTarget.h:66
~UI()
Destructor.
UIPopup
Type of popup.
Definition: UI.h:245
bool contextualBegin(UIWindowFlags flags, Vector2f size, const RectF &triggerBounds)
Start a contextual window.
Define the states used for drawing to a RenderTarget.
Definition: RenderStates.h:82
void menubarBegin()
Start a menu bar.
Bitfield relying on an enumeration.
Definition: Flags.h:68
UIEditFilter
Filters for edit.
Definition: UI.h:220
UIProgress
State of the progress bar.
Definition: UI.h:132
bool buttonLabel(StringRef title)
A button with a centered label.
static const UIEditFlags Field
Definition: UI.h:191
The button is active as long as it is pressed.
RectF windowGetBounds()
Get the window bounds.
The tree is maximized.
The popup is static.
UI(Font &font, unsigned characterSize=DefaultCharacterSize)
Constructor.
UIPredefinedStyle
A predefined style.
Definition: UI.h:254
void menuEnd()
Finish a menu.
Context for an immediate mode graphical interface.
Definition: UI.h:410
bool buttonColor(const Color4f &color)
A button with a color.
void processEvent(const Event &event)
Update the internal state with an event.
void layoutRow(UILayout format, float height, ArrayRef< float > ratio)
Array-based custom column layout.
bool buttonSymbol(UISymbol symbol)
A button with a symbol.
bool checkbox(StringRef title, bool &active)
A checkbox with a title.
Path currentPath
The current path for searching.
Definition: UI.h:237
The window is scalable by the user.
bool menuItemLabel(StringRef title, UIAlignment align=UIAlignment::Left)
A label inside the menu.
bool popupBegin(UIPopup type, const std::string &title, UIWindowFlags flags, const RectF &bounds)
Start a popup window.
void combobox(const std::vector< std::string > &items, int &selected, int itemHeight, Vector2f size)
A simple combo box with a list of item.
void buttonSetBehavior(UIButtonBehavior behavior)
Change the behavior of buttons.
void spacing(int cols)
Create a horizontal spacing to fill some columns.
Centered alignment.
bool colorPicker(Color4f &color)
A color picker.
bool radio(StringRef title, bool &active)
A radio button with a reference state.
The popup is dynamic.
void layoutRowStatic(float height, int itemWidth, int cols)
Static row with fixed column layout.
A reference to a modifiable buffer and its size.
Definition: BufferRef.h:43
bool comboBeginLabel(StringRef selected, Vector2f size)
Start a combo box with a label.
Abstract base class for objects that can be drawn to a render window.
Definition: Drawable.h:79
void groupEnd()
Finish a group.
bool contextualItemLabel(StringRef title, UIAlignment align=UIAlignment::Left)
A label inside the contextual window.
bool sliderInt(int min, int &val, int max, int step)
A slider for an int value.
void labelWrapColored(const Color4f &color, StringRef title)
A label with colored text that can wrap.
The tree is a tabulation, generally the root of the tree.
bool comboBeginColor(const Color4f &color, Vector2f size)
Start a combo box with a color.
The window has a border.
A red and gray style.
Edit widget has received an enter and lost focus.
Solid rectangle.
void separator(float height)
An empty separator.
UIAlignment
The alignment of the text.
Definition: UI.h:107
A texture for colored images.
Definition: Texture.h:339
void contextualEnd()
Finish the contextual window.
UI & operator=(const UI &)=delete
Deleted copy assignment.
void menubarEnd()
Finish a menu bar.
void comboClose()
Close a combo box.
static const UIEditFlags Box
Definition: UI.h:192
bool progress(std::size_t &current, std::size_t max, UIProgress modifyable=UIProgress::Modifyable)
A progress bar.
UIButtonBehavior
Behavior for buttons.
Definition: UI.h:123
bool treePush(UITree type, const std::string &title, UICollapse &state)
Start a tree layout.
bool groupBegin(const std::string &title, UIWindowFlags flags=None)
Start a group.
bool buttonSymbolLabel(UISymbol symbol, StringRef title, UIAlignment align=UIAlignment::Left)
A button with a symbol and a centered label.
Data for file selector.
Definition: UI.h:236
The window can be closed with an icon in the header.
The window can not scale, move or get focus.
void layoutRowBegin(UILayout format, float height, int cols)
Start an immediate mode custom column layout.
The namespace for gf classes.
Definition: Action.h:34
void propertyFloat(const std::string &name, float min, float &val, float max, float step, float incPerPixel)
A property for a float.
A blue and light gray style.
X symbol.
A constant reference to an array and its size.
Definition: ArrayRef.h:42
bool menuBeginSymbol(const std::string &id, UISymbol symbol, Vector2f size)
Start a menu with a symbol.
A character font.
Definition: Font.h:130
virtual void draw(RenderTarget &target, RenderStates states) override
Draw the object to a render target.
Outline rectangle.
The progress bar can be modified.
static const UIEditFlags Simple
Definition: UI.h:190
Right alignment.
static const UIEditFlags Editor
Definition: UI.h:193
void menuClose()
Close a menu.
bool menuItemSymbolLabel(UISymbol symbol, StringRef title, UIAlignment align=UIAlignment::Left)
A symbol and a label inside the menu.
bool comboItemSymbolLabel(UISymbol symbol, StringRef title, UIAlignment align=UIAlignment::Left)
A symbol and a label inside the combo box.
UIEditEventFlags edit(UIEditFlags flags, BufferRef< char > buffer, std::size_t &length, UIEditFilter filter=UIEditFilter::Default)
UI & operator=(UI &&other)
Move assignment.
RectF getWidgetBounds()
Get the current widget bounds.
void labelWrap(StringRef title)
A simple label that can wrap.
void propertyDouble(const std::string &name, double min, double &val, double max, double step, float incPerPixel)
A property for a double.
void groupScrolledEnd()
Finish a scrolled group.
The tree is minimized.
UICollapse
Collapse property of a tree.
Definition: UI.h:78
void layoutRowPush(float width)
Specify the width of the next column.
void layoutRowEnd()
Finish an immediate mode custom column layout.
A light gray style.
UIEdit
Properties for edit widgets.
Definition: UI.h:161
UI(UI &&other)
Move constructor.
bool menuBeginLabel(StringRef title, UIAlignment align, Vector2f size)
Start a menu with a label.
Edit widget went from state inactive to state active.
bool sliderFloat(float min, float &val, float max, float step)
A slider for a float value.
The progress bar is fixed.
void comboboxSeparator(const std::string &itemsSeparatedBySeparator, char separator, int &selected, int itemHeight, Vector2f size)
A simple combo box with a string and a separator.
Predefined flags for edit.
Definition: UI.h:189
bool comboBeginSymbolLabel(UISymbol symbol, StringRef selected, Vector2f size)
Start a combo box with a symbol and a label.
bool buttonPushBehavior(UIButtonBehavior behavior)
Push a new behavior of buttons.
A constant reference to a string and its size.
Definition: StringRef.h:41
UISymbol
A representative symbol.
Definition: UI.h:141
Left alignment.
The window is in the background.
The window has no scrollbar.
bool buttonPopBehavior()
Pop the previous behavior of buttons.
void popupEnd()
Finish a popup window.
void treePop()
Finish a tree layout.
UITree
The type of tree.
Definition: UI.h:96
bool tooltipBegin(float width)
Start a tooltip.
void layoutRowDynamic(float height, int cols)
Dynamic row with fixed column layout.
bool selectableLabel(StringRef title, UIAlignment align, bool &value)
A selectable label.
bool begin(const std::string &title, const RectF &bounds, UIWindowFlags flags=None)
Create a window.
The window&#39;s scaler is on the left.
void contextualClose()
Close the contextual window.
Defines a system event and its parameters.
Definition: Event.h:118
#define GF_API
Definition: Portability.h:35
void tooltip(const std::string &text)
A simple tooltip with a text.
UIWindow
Properties for windows and window-like elements.
Definition: UI.h:52
A dark gray and dark blue style.
bool checkboxFlags(StringRef title, unsigned &flags, unsigned value)
A checkbox with a title for flags.
bool comboItemLabel(StringRef title, UIAlignment align=UIAlignment::Left)
A label inside the combo box.
The window can be minimized with an icon in the header.
void end()
Finish a window.
void propertyInt(const std::string &name, int min, int &val, int max, int step, float incPerPixel)
A property for an integer.
bool contextualItemSymbolLabel(UISymbol symbol, StringRef title, UIAlignment align=UIAlignment::Left)
A symbol and a label inside the contextual window.
Edit widget went from state active to state inactive.
Path selectedPath
The selected path.
Definition: UI.h:238
The window has a title in the header.
bool option(StringRef title, bool active)
A radio button without state.