Content¶
Documentation¶
-
class
Gui
¶ Public Functions
-
Gui
()¶
-
void
Close
()¶ Close the gui.
Private Functions
-
void
m_Init
()¶
-
Data¶
Vec¶
-
template<typename
T
>
structVec2
¶
-
template<typename
T
>
structVec3
¶
-
template<typename
T
>
structVec4
¶
ui¶
-
class
RightClickMenu
: public ComponentFrame¶ Right click menu class, uses a
ComponentFrame
to display aMenu
in a separateWindow
.Public Functions
-
void
Close
()¶ Close the right click menu.
Public Static Functions
-
RightClickMenu &
Get
()¶ Get the instance (Singleton).
- Return
instance
-
void
Components¶
-
class
Component
¶ Subclassed by Container, Div, MenuAccessories::Divider, MenuAccessories::VerticalDivider, ScrollbarBase
Public Functions
-
Component
()¶ Constructor
-
void
Position
(const Vec2<int> &pos)¶ Set the position of the
Component
.- Parameters
pos
: the position
-
void
MinSize
(const Vec2<int> &size)¶ Set the minimum size of the
Component
.- Parameters
size
: the minimum size
-
void
MaxSize
(const Vec2<int> &size)¶ Set the maximum size of the
Component
.- Parameters
size
: the maximum size
-
void
LayoutHint
(Layout::Hint h)¶ Set a
Layout::Hint
for theComponent
.
-
int
Cursor
() const¶ Get the cursor that will be used when hovering over the
Component
- Return
cursor id
-
Layout::Hint
LayoutHint
() const¶ Get the
Layout::Hint
of theComponent
- Return
-
bool
NeedsRedraw
()¶ Returns true when this
Component
needs a redraw- Return
true when a redraw is needed
-
bool
WithinBounds
(const Vec2<int> &pos) const¶ Returns true when the given
pos
is inside theComponent
- Return
true when
pos
is inside of the bounds of thisComponent
- Parameters
pos
: position to check
-
void
Render
(CommandCollection &d)¶ Render the
Component
- Parameters
d
: theCommandCollection
to append draw instructions to
-
-
class
Container
: public Component¶ Subclassed by ButtonBase, MenuBase, Panel, TreeItemBase, WindowBase
Public Functions
-
template<typename
T
, typename ...Args
>
T &Emplace
(Args&&... args)¶ Emplace a component to this container,
- Return
reference to the emplaced component.
- Template Parameters
T
: type
- Parameters
...args
: constructor arguments forT
-
template<typename
T
, typename ...Args
>
T &Emplace
(Layout::Hint h, Args&&... args)¶ Emplace a component to this container,
- Return
reference to the emplaced component.
- Template Parameters
T
: type
- Parameters
h
: layout hint for the component...args
: constructor arguments forT
-
void
Clear
()¶ Remove all components.
-
int
Cursor
() const override¶ Get the cursor that will be used when hovering over the
Component
- Return
cursor id
-
void
Render
(CommandCollection &d) override¶ Render the
Component
- Parameters
d
: theCommandCollection
to append draw instructions to
-
void
Update
(const Vec4<int> &viewport) override¶ Update the
Component
- Parameters
viewport
: the viewport
-
void
Erase
(ComponentCollection::const_iterator &i)¶ Remove a
Component
from thisContainer
using its iterator.- Parameters
iterator
:
-
ComponentCollection &
Components
()¶ Get all components.
- Return
ComponentCollection
-
template<typename
-
struct
Layout
¶ Public Types
-
enum
Type
¶ Layout type
Values:
-
enumerator
Grid
¶ Simple grid layout with padding.
-
enumerator
Stack
¶ Vertical stack layout with padding.
-
enumerator
SidewaysStack
¶ Horizontal stack layout with padding.
-
enumerator
Border
¶ Border layout, with a North, East, South, West, and Center component.
-
enumerator
Divs
¶ Components are located inside divs, easily expandable and highly customizable.
-
enumerator
Free
¶ Free roaming layout. Practically no layout.
-
enumerator
Public Functions
-
Layout
(Type type, int p)¶ Constructor for BorderLayout
- Parameters
type
:p
: padding
-
Layout
(Type type, int p, bool r)¶ Constructor for BorderLayout
- Parameters
type
:p
: paddingr
: resizable
-
Layout
(Type type, int p, bool a, bool b, bool c, bool d)¶ Constructor for BorderLayout
- Parameters
type
:p
: paddinga
: north resizableb
: east resizablec
: south resizabled
: west resizable
-
Layout
(Type type, int p, int p2)¶ Constructor for BorderLayout
- Parameters
type
:p
: outer paddingp2
: inner padding
-
Layout
(Type type, int p, int p2, bool r)¶ Constructor for BorderLayout
- Parameters
type
:p
: outer paddingp2
: inner paddingr
: resizable
-
Layout
(Type type, int p, int p2, bool a, bool b, bool c, bool d)¶ Constructor for BorderLayout
- Parameters
type
:p
: outer paddingp2
: inner paddinga
: north resizableb
: east resizablec
: south resizabled
: west resizable
-
Layout
(Type type, int c, int r, int h, int v)¶ Constructor for GridLayout
- Parameters
type
:c
: number of columnsr
: number of rowsh
: y paddingv
: x padding
-
operator Type
() const¶ Implicit operator to Layout::Type.
-
struct
BorderLayout
¶
-
struct
GridLayout
¶
-
struct
StackLayout
¶
-
enum
-
struct
LayoutManager
¶ Each
Panel
contains an instance ofLayoutManager
and it helps with arranging the components inside thePanel
.Public Functions
-
LayoutManager
()¶ Constructor
-
void
AddEvent
(Event &e)¶ The
LayoutManager
also receives events because it also manages the resizability of some layouts, and thus needs to receive mouse events.- Parameters
e
: event
-
int
Cursor
() const¶ Requested cursor to be displayed, used when resizing.
- Return
cursor id
-
template<typename
TypeCollection
>
voidUpdate
(const Vec4<int> &dim, TypeCollection &components)¶ Update the positions and sizes of the components using the given dimensions.
- Parameters
dim
: rectangle of the available spacecomponents
: components
-
Buttons¶
-
template<typename
ButtonGraphics
, typenameButtonType
= ButtonBase>
structButton
: public ButtonBase¶ Templated
Button
class, allows fully customized behaviour and graphics.- Template Parameters
ButtonGraphics
: a class with a static Render method that takes in theButton
and theCommandCollection
.ButtonType
: the type of button, must be a class that inherits ButtonBase.
Public Functions
-
void
Render
(CommandCollection &d) override¶ Render the
Component
- Parameters
d
: theCommandCollection
to append draw instructions to
-
class
ButtonBase
: public Container¶ Basis for a
Button
Subclassed by Button< ButtonGraphics, ButtonType >, ButtonType::Hover, ButtonType::Normal, ButtonType::Textured< ButtonType >, ButtonType::Toggle
-
template<typename
Enum
, typenameGraphics
= ButtonGraphics::Normal<>, typenameMenuButtonGraphics
= ButtonGraphics::Menu>
classDropDown
: public ButtonType::Normal¶ Simple
DropDown
button, opens a menu with options out of which you can select 1.Public Functions
-
DropDown
(Callback e = [](Enum v) {})¶ Constructor
- Parameters
e
: callback
-
DropDownOption<Enum, MenuButtonGraphics> &
AddOption
(const std::string &name, Enum value, Callback e = [](Enum v) {})¶ Add an option to the
DropDown
. It will automatically select the option if it is the first one to be added.- Parameters
name
: namevalue
: valuee
: callback specific for this option
-
void
ButtonSize
(const Vec2<int> &s)¶ Set the button size for the buttons in the menu that will be opened.
- Parameters
s
: size
-
void
ButtonWidth
(int w)¶ Set the button width for the buttons in the menu that will be opened.
- Parameters
w
: width
-
void
ButtonHeight
(int h)¶ Set the button height for the buttons in the menu that will be opened.
- Parameters
h
: height
-
void
Clear
()¶ Clear all options.
-
void
Render
(CommandCollection &d) override¶ Render the
Component
- Parameters
d
: theCommandCollection
to append draw instructions to
-
namespace ButtonGraphics¶
-
template<Align
Hori
= Align::CENTER, AlignVert
= Align::CENTER>
structButtonGraphics
::
Normal
¶ Simple normal button graphics, displays name and changes color depending on state.
- Template Parameters
Hori
: horizontal text alignVert
: vertical text align
Public Static Functions
-
void
Render
(ButtonBase &b, CommandCollection &d)¶ Render
- Parameters
b
: theButton
d
: theCommandCollection
-
struct
ButtonGraphics
::
Menu
¶ Button graphics for a menu.
Public Static Functions
-
template<typename
Type
= ButtonBase>
voidRender
(Type &b, CommandCollection &d)¶ Render
- Parameters
b
: theButton
d
: theCommandCollection
-
template<typename
-
struct
ButtonGraphics
::
SubMenu
¶ Button graphics for a submenu, which is a button that, when hovered over, opens a menu.
Public Static Functions
-
template<typename
Type
= ButtonBase>
voidRender
(Type &b, CommandCollection &d)¶ Render
- Parameters
b
: theButton
d
: theCommandCollection
-
template<typename
-
template<Align
Hori
= Align::CENTER, AlignVert
= Align::CENTER>
structButtonGraphics
::
Textured
¶ Simple textured button graphics
- Template Parameters
Hori
: horizontal text alignVert
: vertical text align
Public Static Functions
-
template<typename
Type
= ButtonBase>
voidRender
(ButtonType::Textured<Type> &b, CommandCollection &d)¶ Render
- Parameters
b
: theButton
d
: theCommandCollection
-
struct
ButtonGraphics
::
TitleMenu
¶ Button graphics used for the buttons in the title bar menu.
Public Static Functions
-
void
Render
(ButtonBase &b, CommandCollection &d)¶ Render
- Parameters
b
: theButton
d
: theCommandCollection
-
void
namespace ButtonType¶
-
class
ButtonType
::
FocusToggle
: public ButtonType::Toggle¶ Works the same as Toggle, but becomes inactive when the button loses focus (i.e. mouse is clicked somewhere else)
-
class
ButtonType
::
Hover
: public ButtonBase¶ Becomes active when you hover over the button.
Public Functions
-
Hover
(const std::string &name = "Button")¶ Constructor
- Parameters
name
: namesize
: size
-
-
class
ButtonType
::
List
: public ButtonType::Normal¶ Only a single button all buttons of this type with the same
id
can be selected at a time. Works like a radio input.
-
template<typename
Graphics
, typenameMenuType
= MenuBase, typenameButtonType
= Toggle, AlignA
= Align::BOTTOM>
classButtonType
::
Menu
: public ButtonType::Toggle¶ Button that also stores a
Menu
, has template arguments for ButtonGraphics, ButtonType and MenuType- Template Parameters
Graphics
: button graphicsMenuType
: type ofMenu
ButtonType
: button behaviourA
: alignment of the menu, either Align::BOTTOM, Align::RIGHT or Align::LEFT
Public Functions
-
void
Update
(const Vec4<int> &viewport) override¶ Update the
Component
- Parameters
viewport
: the viewport
-
class
ButtonType
::
Normal
: public ButtonBase¶ Normal Button behaviour: press to run the Callback.
Subclassed by ButtonType::List, DropDown< Enum, Graphics, MenuButtonGraphics >
-
template<typename
ButtonType
= ButtonBase>
classButtonType
::
Textured
: public ButtonBase¶ Button that can take on any other ButtonType, but stores 3 textures for the ButtonGraphics::Textured graphics.
- Template Parameters
ButtonType
: button behaviour
Public Functions
-
template<typename ...
Args
>Textured
(Graphics::Texture &t1, Graphics::Texture &t2, Graphics::Texture &t3, Args&&... a)¶ Constructor
- Parameters
t1
: texture for the idle statet2
: texture for the hovering statet3
: texture for the pressed statea
: arguments for the constructor of template argumentButtonType
-
class
ButtonType
::
Toggle
: public ButtonBase¶ Toggle Button behaviour, click to toggle the state.
Subclassed by ButtonType::FocusToggle, ButtonType::Menu< Graphics, MenuType, ButtonType, A >
Public Functions
-
Toggle
(bool *a, const std::string &name = "Button", Key key = Key::NONE)¶ Constructor
- Parameters
a
: pointer to a bool, this button will actively read for a change in value, and when clicked change the state of this bool.name
: namesize
: sizekey
: keycombo
-
Toggle
(ToggleCallback a = [](bool &state) {}, const std::string &name = "Button", Key key = Key::NONE)¶ Constructor
- Parameters
a
: pointer to a bool, this button will actively read for a change in value, and when clicked change the state of this bool.name
: namesize
: sizekey
: keycombo
-
Toggle
(const std::string &name = "Button", Key key = Key::NONE)¶ Constructor
- Parameters
name
: namesize
: sizekey
: keycombo
-
Panels¶
-
class
Panel
: public Container¶ A crucial building block, this component contains a layout which let’s you arrange other panels or components.
Subclassed by ComponentFramePanel, ScrollPanel, TextBox, TextDisplayer, TreePanel
Public Functions
-
void
SmartPanel
(bool s)¶ A smart panel only redraws whenever a component inside this panel requests a redraw. !!This feature is still a BETA and does not work entirely as intended yet!!
- Parameters
s
: enable smart panel
-
void
Background
(const Color &c)¶ Set the background color of this panel
- Parameters
c
: color
-
int
Cursor
() const override¶ Get the cursor that will be used when hovering over the
Component
- Return
cursor id
-
void
Update
(const Vec4<int> &viewport) override¶ Update the
Component
- Parameters
viewport
: the viewport
-
void
Render
(CommandCollection &d) override¶ Render the
Component
- Parameters
d
: theCommandCollection
to append draw instructions to
-
void
Background
(CommandCollection &d)¶ Overrideable method for rendering a background.
- Parameters
d
: theCommandCollection
to append draw instructions to
-
template<Layout::Type
T
, typename ...Args
>
voidLayout
(Args&&... args)¶ Set the layout of this
Panel
- Template Parameters
T
:Layout::Type
- Parameters
...args
: arguments for the layout type
-
void
AutoResize
(bool rx, bool ry)¶ Enable autoresizing of this panel in the x and y direction. When enabled, this Panel will retrieve the highest x and y position from its
LayoutManager
and automatically resize to that size.- Parameters
rx
: auto resize in the x-axisty
: auto resize in the y-axis
-
Vec2<bool>
AutoResize
() const¶ Retrieve the current state of the AutoResize.
- Return
state of the AutoResize
-
bool
NeedsRedraw
() override¶ Returns true when this
Component
needs a redraw- Return
true when a redraw is needed
-
LayoutManager &
LayoutManager
()¶ Get the
LayoutManager
of thisPanel
- Return
layout manager
-
Div &
Div
()¶ Get the
Div
of thisPanel
. Only used when the layout is set toLayout::Divs
- Return
div
-
void
-
class
ScrollPanel
: public Panel¶ Simple scroll panel, contains another Panel which is translated.
Subclassed by TextArea
Public Functions
-
ScrollPanel
()¶ Constructor
-
void
Update
(const Vec4<int> &viewport) override¶ Update the
Component
- Parameters
viewport
: the viewport
-
void
Render
(CommandCollection &d) override¶ Render the
Component
- Parameters
d
: theCommandCollection
to append draw instructions to
-
void
EnableScrollbars
(bool x, bool y)¶ Enable scrolling on the x and y axis.
- Parameters
x
: enable scroll in x-axisy
: enable scroll in y-axis
-
::Panel &
Panel
() const¶ Retrieves the
Panel
inside thisScrollPanel
- Return
reference to the
Panel
-
template<typename
T
, typename ...Args
>
T &Panel
(Args&&... args)¶ Set the
Panel
in thisScrollPanel
. This is templated to allow for differentPanel
types to be used inside aScrollPanel
.- Return
reference to the emplaced panel
- Template Parameters
T
: panel type
- Parameters
...args
: constructor arguments forT
-
Scrollbars¶
-
template<typename
ScrollbarGraphics
, typenameScrollbarType
= ScrollbarBase>
classScrollbar
: public ScrollbarBase¶ Templated
Scrollbar
class, allows fully customized behaviour and graphics.- Template Parameters
ScrollbarGraphics
: a class with a static Render method that takes in theScrollbar
and theCommandCollection
.ScrollbarType
: the type of scrollbar, must be a class that inherits ScrollbarBase.
-
class
ScrollbarBase
: public Component¶ Basis for
Scrollbar
Subclassed by Scrollbar< ScrollbarGraphics, ScrollbarType >, ScrollbarType::Horizontal, ScrollbarType::Vertical
Public Functions
-
ScrollbarBase
()¶ Constructor
-
void
Scroll
(int s)¶ Scroll by
s
amount.- Parameters
s
: amount
-
void
Value
(int v)¶ Set absolute scroll value.
- Parameters
v
: value to scroll to
-
void
VisibleRange
(int v)¶ Set the visible range on the screen. This is used to calculate the size of the scrollbar.
- Parameters
v
: visible range
-
int
MinBarSize
() const¶ The minimun scrollbar size, this value is used to limit the scrollbar size to not become infinitely small with big scrollareas.
- Return
minimum bar size
-
int
Mouse
() const¶ This is used by the
ScrollbarGraphics
and returns the x or y (depending on what type of scrollbar it is) of the mouse when it started dragging the scrollbar.- Return
x or y of mouse (depending on type of scrollbar)
-
int
VisibleRange
() const¶ Returns the visible range.
- Return
visible range
-
bool
NotNecessary
() const¶ Returns true when the scrollbar is not necessary, i.e. when the visible range is lower than the range of the scrollbar.
-
bool
Hovering
() const¶ Returns true when the mouse is hovering over the scrollbar.
- Return
true when mouse over scrollbar
-
bool
Dragging
() const = 0¶ Returns true when the mouse is dragging the scrollbar.
- Return
true when mouse dragging
-
namespace ScrollbarGraphics¶
-
struct
ScrollbarGraphics
::
Normal
¶ Simple normal scrollbar graphics.
Public Static Functions
-
template<typename
ScrollbarType
>
voidRender
(Scrollbar<Normal, ScrollbarType> &b, CommandCollection &d)¶ Render
- Parameters
b
: theScrollbar
d
: theCommandCollection
-
template<typename
namespace ScrollbarType¶
-
class
ScrollbarType
::
Vertical
: public ScrollbarBase¶ Vertical scrollbar.
-
class
ScrollbarType
::
Horizontal
: public ScrollbarBase¶ Horizontal scrollbar.
Text¶
-
class
Selection
: public Vec2<int>¶ Simple Selection class, practically just a
Vec2<int>
but with aLowest()
andHighest()
method to retrieve the lowest/highest index.
-
class
TextContainer
¶ Contains text, used in TextDisplayer. Tracks typing location and text selection.
Public Functions
-
TextContainer
(const std::string &c = "", bool editable = true)¶ Constructor
- Parameters
c
: contenteditable
: editable
-
bool
Editable
() const¶ Returns true when this text container is editable.
- Return
true if editable
-
void
Editable
(bool e)¶ Set if this container is editable.
- Parameters
a
: editable
-
int
Length
() const¶ Get the length of the content in this container.
- Return
length
-
auto
SelectionString
() -> std::string_view¶ Get the selection as a
std::string_view
.- Return
selection
-
bool
Selected
() const¶ Returns true when there is text selected (selection.start != selection.end).
- Return
true if selection
-
void
Select
(const ::Selection &s)¶ Set a selection. This selection is automatically constrained to (0, Length()).
- Parameters
s
: selection
-
void
Select
(int pos)¶ Set a selection. This selection is automatically constrained to (0, Length()).
- Parameters
pos
: selection
-
auto
Content
() -> std::string&¶ Get the entire content of this container as a string.
- Return
content
-
void
Content
(const std::string &c)¶ Set the content of this container.
- Parameters
c
: content
-
void
Insert
(const std::string &add)¶ Insert a string at the current selection, removes the selection (if there is one) and then inserts the string in its place.
- Parameters
add
: insertion
-
void
Insert
(const char &add)¶ Insert a characer at the current selection, removes the selection (if there is one) and then inserts the character in its place.
- Parameters
add
: insertion
-
void
Delete
()¶ Normal delete operation, if there is a selection it gets removed, otherwise the character that comes after the current typing index gets removed.
-
void
Backspace
()¶ Backspace operation, if there is a selection it gets removed, otherwise the character before the current typing index gets removed.
-
void
RemoveSelection
()¶ Removes the selection from the content. Automatically adjusts the typing index.
-
void
Remove
(const ::Selection &s)¶ Removes the given selection from the content. Does not adjust the typing index.
- Parameters
s
: selection
-
int
CtrlLeft
()¶ Get the index in the content 1 word to the left of the current typing index.
- Return
index
-
int
CtrlLeft
(int start)¶ Get the index in the content 1 word to the left of the given index.
- Return
index
- Parameters
start
: start index
-
int
CtrlRight
()¶ Get the index in the content 1 word to the right of the current typing index.
- Return
index
-
int
CtrlRight
(int start)¶ Get the index in the content 1 word to the right of the given index.
- Return
index
- Parameters
start
: start index
-
-
class
TextDisplayer
: public Panel¶ TextDisplayer displays text (wow surprising).
Public Types
Public Functions
-
TextDisplayer
()¶ Constructor
-
void
Render
(CommandCollection &d) override¶ Render the
Component
- Parameters
d
: theCommandCollection
to append draw instructions to
-
auto
Container
() -> TextContainer&¶ Get the TextContainer.
- Return
-
bool
Dragging
()¶ Returns true if the mouse is dragging.
- Return
true if dragging
-
bool
Focused
()¶ Returns true if this component is focused.
- Return
true if focused
-
int
PositionToIndex
(const Vec2<int> &pos)¶ Converts an (x, y) position on this TextDisplayer to an index in the content of the TextContainer.
- Return
index
-
Vec2<int>
IndexToPosition
(int index)¶ Converts an index in the TextContainer to an (x, y) position on this TextDisplayer.
- Return
position
-
void
AlignLines
(Align a)¶ Set the horizontal alignment of the lines in this TextDisplayer.
- Parameters
a
: alignment
-
void
Content
(const std::string &c)¶ Set the content of this container.
- Parameters
c
: content
-
void
Editable
(bool e)¶ Set if this container is editable.
- Parameters
a
: editable
-
void
TextColor
(Color c)¶ Set the text color.
- Parameters
c
: color
-
void
SelectColor
(Color c)¶ Set the selection color.
- Parameters
c
: color
-
void
LineHeight
(int h)¶ Set the line height.
- Parameters
h
: line height
-
void
Font
(int f, float size)¶ Set the font and font size.
- Parameters
f
: fontsize
: font size
-
void
Padding
(int p)¶ Set the padding around the text.
- Parameters
p
: padding
-
auto
AlignLines
() const -> Align¶ Get the current horizontal alignment of the text.
- Return
text alignment
-
auto
Content
() -> std::string&¶ Get the entire content of this container as a string.
- Return
content
-
bool
Editable
() const¶ Returns true when this text container is editable.
- Return
true if editable
-
auto
TextColor
() const -> Color¶ Get the text color.
- Return
text color
-
auto
SelectColor
() const -> Color¶ Get the selection color.
- Return
selection color
-
int
LineHeight
() const¶ Get the current line height.
- Return
line height
-
int
Font
() const¶ Get the current font.
- Return
font
-
float
FontSize
() const¶ Get the current font size.
- Return
font size
-
int
Padding
() const¶ Get the current padding around the text.
- Return
padding
-
void
Placeholder
(const std::string &p)¶ Set a placeholder string.
- Parameters
p
: placeholder
-
auto
Placeholder
() -> std::string&¶ Get the placeholder string.
- Return
placeholder
-
-
class
TextComponent
: public TextBox¶ Simple TextComponent for displaying a single line of non-editable text.
Public Functions
-
TextComponent
(const std::string &t, int f = Graphics::Fonts::Gidole14, float fsize = 14)¶ Constructor.
- Parameters
t
: contentf
: fontfsize
: font size
-
void
Content
(const std::string &c)¶ Set the content.
- Parameters
c
: content
-
auto
Content
() -> std::string&¶ Get the content.
- Return
content
-
void
Font
(int f, float size)¶ Set the font and font size.
- Parameters
f
: fontsize
: font size
-
int
Font
() const¶ Get the font.
- Return
font
-
-
class
TextBox
: public Panel¶ Single line TextBox.
Subclassed by TextComponent
Public Functions
-
TextBox
()¶ Constructor.
-
void
Render
(CommandCollection &d) override¶ Render the
Component
- Parameters
d
: theCommandCollection
to append draw instructions to
-
void
AlignLines
(Align a)¶ Set the horizontal alignment of the lines in this TextDisplayer.
- Parameters
a
: alignment
-
void
Content
(const std::string &c)¶ Set the content of this container.
- Parameters
c
: content
-
void
Editable
(bool e)¶ Set if this container is editable.
- Parameters
a
: editable
-
void
TextColor
(Color c)¶ Set the text color.
- Parameters
c
: color
-
void
SelectColor
(Color c)¶ Set the selection color.
- Parameters
c
: color
-
void
TextWrap
(TextDisplayer::Wrap wrap)¶ Set the text wrap mode.
- Parameters
wrap
: wrap mode
-
void
LineHeight
(int h)¶ Set the line height.
- Parameters
h
: line height
-
void
Font
(int f, float size)¶ Set the font and font size.
- Parameters
f
: fontsize
: font size
-
void
Padding
(int p)¶ Set the padding around the text.
- Parameters
p
: padding
-
auto
AlignLines
() -> Align¶ Get the current horizontal alignment of the text.
- Return
text alignment
-
auto
Content
() -> std::string&¶ Get the entire content of this container as a string.
- Return
content
-
bool
Editable
()¶ Returns true when this text container is editable.
- Return
true if editable
-
auto
TextColor
() const -> Color¶ Get the text color.
- Return
text color
-
auto
SelectColor
() const -> Color¶ Get the selection color.
- Return
selection color
-
auto
TextWrap
() const -> TextDisplayer::Wrap¶ Get the current wrap mode.
- Return
wrap
-
int
LineHeight
() const¶ Get the current line height.
- Return
line height
-
int
Font
() const¶ Get the current font.
- Return
font
-
float
FontSize
() const¶ Get the current font size.
- Return
font size
-
int
Padding
() const¶ Get the current padding around the text.
- Return
padding
-
void
Placeholder
(const std::string &p)¶ Set a placeholder string.
- Parameters
p
: placeholder
-
auto
Placeholder
() -> std::string&¶ Get the placeholder string.
- Return
placeholder
-
-
class
TextArea
: public ScrollPanel¶ Multiline text area with scrollbars.
Public Functions
-
TextArea
()¶ Constructor.
-
void
AlignLines
(Align a)¶ Set the horizontal alignment of the lines in this TextDisplayer.
- Parameters
a
: alignment
-
void
Content
(const std::string &c)¶ Set the content of this container.
- Parameters
c
: content
-
void
Editable
(bool e)¶ Set if this container is editable.
- Parameters
a
: editable
-
void
TextColor
(Color c)¶ Set the text color.
- Parameters
c
: color
-
void
SelectColor
(Color c)¶ Set the selection color.
- Parameters
c
: color
-
void
TextWrap
(TextDisplayer::Wrap wrap)¶ Set the text wrap mode.
- Parameters
wrap
: wrap mode
-
void
LineHeight
(int h)¶ Set the line height.
- Parameters
h
: line height
-
void
Font
(int f, float size)¶ Set the font and font size.
- Parameters
f
: fontsize
: font size
-
void
Padding
(int p)¶ Set the padding around the text.
- Parameters
p
: padding
-
auto
AlignLines
() const -> Align¶ Get the current horizontal alignment of the text.
- Return
text alignment
-
auto
Content
() -> std::string&¶ Get the entire content of this container as a string.
- Return
content
-
bool
Editable
() const¶ Returns true when this text container is editable.
- Return
true if editable
-
auto
TextColor
() const -> Color¶ Get the text color.
- Return
text color
-
auto
SelectColor
() const -> Color¶ Get the selection color.
- Return
selection color
-
auto
TextWrap
() const -> TextDisplayer::Wrap¶ Get the current wrap mode.
- Return
wrap
-
int
LineHeight
() const¶ Get the current line height.
- Return
line height
-
int
Font
() const¶ Get the current font.
- Return
font
-
float
FontSize
() const¶ Get the current font size.
- Return
font size
-
int
Padding
() const¶ Get the current padding around the text.
- Return
padding
-
void
Placeholder
(const std::string &p)¶ Set a placeholder string.
- Parameters
p
: placeholder
-
auto
Placeholder
() -> std::string&¶ Get the placeholder string.
- Return
placeholder
-
TreeItems¶
-
template<typename
TreeItemGraphics
, typenameTreeItemType
= TreeItemBase>
structTreeItem
: public TreeItemBase¶ Templated
TreeItem
class, allows fully customized behaviour and graphics.- Template Parameters
TreeItemGraphics
: a class with a static Render method that takes in theTreeItem
and theCommandCollection
.TreeItemType
: the type of tree item, must be a class that inherits TreeItemBase.
Public Functions
-
void
Render
(CommandCollection &d) override¶ Render the
Component
- Parameters
d
: theCommandCollection
to append draw instructions to
-
class
TreeItemBase
: public Container¶ Basis for a
TreeItem
Subclassed by TreeItem< TreeItemGraphics, TreeItemType >, TreeItemType::Folder, TreeItemType::Normal
Public Functions
-
bool
Hovering
() const¶ Returns true if the mouse is hovering over this TreeItem.
- Return
true when mouse over
-
const std::string &
Name
() const¶ File/Folder name.
- Return
name
-
const std::string &
Extension
() const¶ If it’s a file it returns the extension as an
std::string
.- Return
file extension
-
const std::filesystem::path &
Path
() const¶ Returns the path to the file/folder as an
std::filesystem::path
.- Return
path
-
bool
namespace TreeItemGraphics¶
-
struct
TreeItemGraphics
::
Normal
¶ Simple normal tree item graphics
Public Static Functions
-
template<typename
TreeItemType
>
voidRender
(TreeItem<Normal, TreeItemType> &b, CommandCollection &d)¶ Render
- Parameters
b
: theTreeItem
d
: theCommandCollection
-
template<typename
namespace TreeItemType¶
-
class
TreeItemType
::
Normal
: public TreeItemBase¶ Normal tree item.
-
class
TreeItemType
::
Folder
: public TreeItemBase¶ Folder tree item. Contains a sub-
TreePanel
for more folder and files.Public Functions
-
Folder
(const std::filesystem::path &path, Vec2<int> size = {250, 22})¶ Constructor
- Parameters
path
: path to filesize
: size
-
auto
Size
(const Vec2<int> &size) -> void override¶ Set the size of the
Component
.- Parameters
size
: the size
-
int
ActualHeight
() const¶ Height is slightly adjust, this returns the actual height.
- Return
actual height
-
bool
Expanded
() const¶ Is this folder expanded?
- Return
true when folder is expanded
-
Events¶
-
struct
Event
¶ Public Types
-
enum
Type
¶ Event type.
Values:
-
enumerator
KeyTyped
¶
-
enumerator
KeyPressed
¶
-
enumerator
KeyReleased
¶
-
enumerator
MousePressed
¶
-
enumerator
MouseReleased
¶
-
enumerator
MouseClicked
¶
-
enumerator
MouseMoved
¶
-
enumerator
MouseDragged
¶
-
enumerator
MouseWheel
¶
-
enumerator
MouseExited
¶
-
enumerator
MouseEntered
¶
-
enumerator
Focused
¶
-
enumerator
Unfocused
¶
-
enumerator
Public Functions
-
Event
(Type t, int x, int y)¶ Constructor for
MouseMoved
,MouseEntered
,MouseExited
, andKeyReleased
events.- Parameters
t
: typex
: x or keyy
: y or keymod
-
Event
(Type t, int key, int keymod, int repeat)¶ Constructor for
KeyPressed
events.- Parameters
t
: typekey
: keykeymod
: keymodrepeat
: repeat
-
Event
(Type t, char c, int keymod, int coded)¶ Constructor for
KeyTyped
events.- Parameters
t
: typec
: charkeymod
: keymod
-
Event
(Type t, int x, int y, MouseButton b)¶ Constructor for
MouseDragged
events.- Parameters
t
: typex
: xy
: yb
: mouse button
-
Event
(Type t, int x, int y, MouseButton b, int m)¶ Constructor for
MousePressed
,MouseReleased
, andMouseClicked
events.- Parameters
t
: typex
: xy
: yb
: mouse buttonm
: event mods
-
Event
(Type t, int x, int y, int a, int m)¶ Constructor for
MouseWheel
events.- Parameters
t
: typex
: xy
: ya
: amount scrolledm
: event mods
-
struct
Focused
¶
-
struct
KeyPressed
¶
-
struct
KeyReleased
¶
-
struct
KeyTyped
¶
-
struct
MouseClicked
¶
-
struct
MouseDragged
¶
-
struct
MouseEntered
¶
-
struct
MouseExited
¶
-
struct
MouseMoved
¶
-
struct
MousePressed
¶
-
struct
MouseReleased
¶
-
struct
MouseWheel
¶
-
struct
Unfocused
¶
-
enum
-
class
Key
¶ Public Types
-
enum
Value
¶ Type of key combo
Values:
-
enumerator
NONE
¶
-
enumerator
CTRL_A
¶
-
enumerator
CTRL_B
¶
-
enumerator
CTRL_C
¶
-
enumerator
CTRL_D
¶
-
enumerator
CTRL_E
¶
-
enumerator
CTRL_F
¶
-
enumerator
CTRL_G
¶
-
enumerator
CTRL_H
¶
-
enumerator
CTRL_I
¶
-
enumerator
CTRL_J
¶
-
enumerator
CTRL_K
¶
-
enumerator
CTRL_L
¶
-
enumerator
CTRL_M
¶
-
enumerator
CTRL_N
¶
-
enumerator
CTRL_O
¶
-
enumerator
CTRL_P
¶
-
enumerator
CTRL_Q
¶
-
enumerator
CTRL_R
¶
-
enumerator
CTRL_S
¶
-
enumerator
CTRL_T
¶
-
enumerator
CTRL_U
¶
-
enumerator
CTRL_V
¶
-
enumerator
CTRL_W
¶
-
enumerator
CTRL_X
¶
-
enumerator
CTRL_Y
¶
-
enumerator
CTRL_Z
¶
-
enumerator
CTRL_COMMA
¶
-
enumerator
CTRL_SHIFT_S
¶
-
enumerator
CTRL_SHIFT_W
¶
-
enumerator
ALT_F4
¶
-
enumerator
CTRL_F4
¶
-
enumerator
BACKSPACE
¶
-
enumerator
TAB
¶
-
enumerator
DEL
¶
-
enumerator
ENTER
¶
-
enumerator
LEFT
¶
-
enumerator
RIGHT
¶
-
enumerator
UP
¶
-
enumerator
DOWN
¶
-
enumerator
SHIFT
¶
-
enumerator
-
enum
-
class
EventListener
¶ -
Public Functions
-
void
AddCallback
(Callback<Event::KeyPressed> c)¶
-
void
AddCallback
(Callback<Event::KeyReleased> c)¶
-
void
AddCallback
(Callback<Event::MousePressed> c)¶
-
void
AddCallback
(Callback<Event::MouseReleased> c)¶
-
void
AddCallback
(Callback<Event::MouseClicked> c)¶
-
void
AddCallback
(Callback<Event::MouseMoved> c)¶
-
void
AddCallback
(Callback<Event::MouseDragged> c)¶
-
void
AddCallback
(Callback<Event::MouseWheel> c)¶
-
void
AddCallback
(Callback<Event::MouseEntered> c)¶
-
void
AddCallback
(Callback<Event::MouseExited> c)¶
-
void
AddEvent
(Event::KeyPressed &e)¶
-
void
AddEvent
(Event::KeyReleased &e)¶
-
void
AddEvent
(Event::MousePressed &e)¶
-
void
AddEvent
(Event::MouseReleased &e)¶
-
void
AddEvent
(Event::MouseClicked &e)¶
-
void
AddEvent
(Event::MouseMoved &e)¶
-
void
AddEvent
(Event::MouseDragged &e)¶
-
void
AddEvent
(Event::MouseWheel &e)¶
-
void
AddEvent
(Event::MouseEntered &e)¶
-
void
AddEvent
(Event::MouseExited &e)¶
-
void
Clear
()¶
-
void
Graphics¶
-
namespace
Graphics
¶ Enums
-
enum
Type
¶ Command Type.
Values:
-
enumerator
Fill
¶
-
enumerator
Stroke
¶
-
enumerator
StrokeWeight
¶
-
enumerator
FontSize
¶
-
enumerator
Font
¶
-
enumerator
TextAlign
¶
-
enumerator
Clip
¶
-
enumerator
PopClip
¶
-
enumerator
ClearClip
¶
-
enumerator
Translate
¶
-
enumerator
PushMatrix
¶
-
enumerator
PopMatrix
¶
-
enumerator
Scale
¶
-
enumerator
Viewport
¶
-
enumerator
Text
¶
-
enumerator
TextView
¶
-
enumerator
Line
¶
-
enumerator
Quad
¶
-
enumerator
TexturedQuad
¶
-
enumerator
Ellipse
¶
-
enumerator
Triangle
¶
-
enumerator
Point
¶
-
enumerator
FrameBuffer
¶
-
enumerator
FrameBufferEnd
¶
-
enumerator
Functions
-
void
SetProjection
(const glm::mat4 &proj)¶
-
bool
WindowFocused
()¶
-
void
WindowFocused
(bool a)¶
-
void
CurrentWindow
(int a)¶
-
void
Scaling
(float scale)¶
-
void
RunCommands
(const ::CommandCollection&)¶
-
int
LoadFont
(const std::string &path)¶
-
int
LoadFont
(const std::string &path, unsigned int size)¶
-
int
StringWidth
(const std::string&, int font, int size = -1)¶
-
int
StringWidth
(const std::string_view&, int font, int size = -1)¶
-
int
CharWidth
(const char&, int font, int size = -1)¶
-
void
Init
()¶
-
struct
CommandBase
¶ - #include <Command.hpp>
Basis for a
Command
.Subclassed by Graphics::Command< T >
-
template<Type
T
>
structCommand
: public Graphics::CommandBase¶
-
struct
Image
¶
-
struct
Texture
¶
-
struct
Textures
¶
-
namespace
Fonts
¶
-
enum
-
class
CommandCollection
¶ A collection of
Graphics::Command
.Public Functions
-
template<Graphics::Type
T
, typename ...Args
>
voidCommand
(Args... args)¶ Emplace a
Graphics::Command
.- Template Parameters
T
: type
- Parameters
...args
: arguments for the constructor ofT
-
const std::vector<Graphics::CommandBase> &
Get
() const¶ Returns the vector of
Graphics::CommandBase
.- Return
all commands
-
void
Clear
()¶ Empties the collection.
-
template<Graphics::Type
-
class
Shader
¶ Public Functions
-
Shader
(const std::string &vertex, const std::string &frag, const std::string &geo = "")¶
-
void
Clean
() const¶
-
void
Use
() const¶
-
void
SetBool
(const char *n, bool v) const¶
-
void
SetInt
(const char *n, int v) const¶
-
void
SetFloat
(const char *n, float v) const¶
-
void
SetFloatA
(const char *n, const float *v, const unsigned int a) const¶
-
void
SetIntA
(const char *n, const int *v, const unsigned int a) const¶
-
void
SetVec2
(const char *n, const glm::vec2 &v) const¶
-
void
SetVec3
(const char *n, const glm::vec3 &v) const¶
-
void
SetVec4
(const char *n, const glm::vec4 &v) const¶
-
void
SetVec4
(const char *n, const Color &v) const¶
-
void
SetMat2
(const char *n, const glm::mat2 &m) const¶
-
void
SetMat3
(const char *n, const glm::mat3 &m) const¶
-
void
SetMat4
(const char *n, const glm::mat4 &m) const¶
Public Members
-
unsigned int
ID
¶
-
Windows¶
-
struct
Window
: public WindowType¶ Basic window, inherits a WindowType depending on OS.
Subclassed by ComponentFrame, Frame, SmallFrame
Public Functions
-
Window
(const std::string &name, int width, int height, bool hideonclose = false, bool show = true, bool resizable = true, bool decorated = true)¶ Constructor
- Parameters
name
: namewidth
: widthheight
: heightresizable
: resizabledecorated
: decorated
-
-
class
WindowBase
: protected Container¶ Base for a window
Subclassed by WindowsWindow
Public Functions
-
WindowBase
(const std::string &name, int width, int height, bool hideonclose = false)¶ Constructor
- Parameters
name
: namewidth
: widthheight
: height
-
auto
Size
(int w, int h) -> void¶
-
auto
Maximize
() -> void = 0¶
-
auto
Restore
() -> void = 0¶
-
auto
Iconify
() -> void = 0¶
-
auto
Close
() -> void = 0¶
-
auto
ShouldClose
(bool b) -> void = 0¶
-
auto
Loop
() -> void = 0¶
-
auto
Scale
(float) -> void = 0¶
-
bool
Maximized
() const = 0¶
-
bool
ShouldClose
() const = 0¶
-
bool
HideOnClose
() const¶
-
-
class
Frame
: public Window¶ A window with a menu and standard close/maximize/minimize buttons. Also has a base
Panel
to put content on.Public Functions
-
Frame
(const std::string &name, const int width, const int height, bool hideonclose = false, bool show = true, bool r = true)¶ Constructor
- Parameters
name
: namewidth
: widthheight
: heighthideonclose
: when true this window will not exit the program but simply hide the window when closed.r
: resizeable
-
-
class
SmallFrame
: public Window¶ Smaller version of
Frame
, only has a close button and no menu.Public Functions
-
SmallFrame
(const std::string &name, const int width, const int height, bool hideonclose = false, bool show = false, bool r = true)¶ Constructor
- Parameters
name
: namewidth
: widthheight
: heighthideonclose
: when true this window will not exit the program but simply hide the window when closed.r
: resizeable
-
-
class
ComponentFramePanel
: public Panel¶ Panel used by the
ComponentFrame
.Public Functions
-
ComponentFramePanel
()¶ Constructor
-
void
Update
(const Vec4<int> &viewport) override¶ Update the
Component
- Parameters
viewport
: the viewport
-
void
Render
(CommandCollection &d) override¶ Render the
Component
- Parameters
d
: theCommandCollection
to append draw instructions to
-
auto
Component
(::Component *c) -> void¶ Set the component of this
ComponentFramePanel
.- Parameters
c
: component
-
-
class
ComponentFrame
: public Window¶ A frame to display a single component, used by the RightClickMenu.
Subclassed by Dragging, RightClickMenu
Public Functions
-
ComponentFrame
(const std::string &name, const int width, const int height)¶ Constructor
- Parameters
name
: namewidth
: widthheight
: height
-
void
Component
(::Component *c)¶ Set the component of this
ComponentFrame
.- Parameters
c
: component
-
Examples¶
Form with Text Boxes¶
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 | #include <GuiCode/Gui.hpp>
#include <GuiCode/ui/window/Frame.hpp>
#include <GuiCode/ui/components/buttons/Button.hpp>
#include <GuiCode/ui/components/buttons/ButtonType.hpp>
#include <GuiCode/ui/components/buttons/ButtonGraphics.hpp>
#include <GuiCode/ui/components/text/TextDisplayer.hpp>
#include <GuiCode/ui/components/text/TextArea.hpp>
#include <GuiCode/ui/components/text/TextBox.hpp>
#include <GuiCode/ui/components/text/TextComponent.hpp>
#include <GuiCode/ui/components/buttons/DropDown.hpp>
int main()
{
// Create a Gui instance, this will take care of all the looping.
Gui _gui;
// Add a window to the gui.
auto& _frame = _gui.AddWindow<Frame>("Frame Name", 400, 400);
// Retrieve the panel from the frame.
auto& _panel = _frame.Panel();
// Set the layout to Divs for fully custom layout. Also set divider color.
_panel.Layout<Layout::Divs>();
_panel.LayoutManager().DividerColor({ 128, 128, 128, 255 });
auto& _div = _panel.Div();
// Some colors
Color _textColor{ 255, 255, 255, 255 }, _fieldColor{ 255, 255, 255, 10 },
_selectColor{ 128, 128, 128, 50 };
// Emplace all the components to the panel:
// The title of the page
auto& _titleText = _panel.Emplace<TextComponent>("Order Pizza", Graphics::Fonts::Gidole, 24.0f);
// Name field
auto& _nameText = _panel.Emplace<TextComponent>("Name", Graphics::Fonts::Gidole14, 14.0f);
auto& _nameField = _panel.Emplace<TextBox>();
_nameField.Placeholder("Name");
_nameField.TextColor(_textColor);
_nameField.SelectColor(_selectColor);
_nameField.Background(_fieldColor);
// Address field
auto& _addressText = _panel.Emplace<TextComponent>("Address", Graphics::Fonts::Gidole14, 14.0f);
auto& _addressField = _panel.Emplace<TextBox>();
_addressField.Placeholder("Address");
_addressField.TextColor(_textColor);
_addressField.SelectColor(_selectColor);
_addressField.Background(_fieldColor);
// Pizza sizing: 3 radio buttons with text besides them
using ListButton = Button<ButtonGraphics::Menu, ButtonType::List>;
auto& _sizeText = _panel.Emplace<TextComponent>("Size");
auto key = ButtonType::List::NewKey();
auto& _size1Box = _panel.Emplace<ListButton>([] {}, "", key);
_size1Box.Size({ 16, 16 });
_size1Box.Selected(true);
auto& _size1Text = _panel.Emplace<TextComponent>("8-inch");
auto& _size2Box = _panel.Emplace<ListButton>([] {}, "", key);
_size2Box.Size({ 16, 16 });
auto& _size2Text = _panel.Emplace<TextComponent>("10-inch");
auto& _size3Box = _panel.Emplace<ListButton>([] {}, "", key);
_size3Box.Size({ 16, 16 });
auto& _size3Text = _panel.Emplace<TextComponent>("12-inch");
// Pizza type: DropDown
enum class PizzaTopping { Margarita, FourCheese, Vegetarian, Hawaiian, Length };
std::string _topName[]{ "Margarita", "Four Cheese", "Vegetarian", "Hawaiian"};
auto& _topText = _panel.Emplace<TextComponent>("Topping", Graphics::Fonts::Gidole14, 14.0f);
auto& _topDrop = _panel.Emplace<DropDown<PizzaTopping, ButtonGraphics::Dropdown>>();
for (int i = 0; i < (int)PizzaTopping::Length; i++)
_topDrop.AddOption(_topName[i], (PizzaTopping)i);
// Additional instructions: TextArea
auto& _instrText = _panel.Emplace<TextComponent>("Additional Instructions");
auto& _instrField = _panel.Emplace<TextArea>();
_instrField.TextColor(_textColor);
_instrField.SelectColor(_selectColor);
_instrField.Background(_fieldColor);
// The layout for the page:
// Divide main div in 2 divs, vertically aligned, with 16 pixels of padding, and dividers.
_div = { 2, Div::Alignment::Vertical, 16, true };
// First div contains the title text
_div[1] = { _titleText, Div::Alignment::Center, 48 };
// The 2nd div divides into 5 vertically aligned divs with 2 pixels padding, no dividers.
auto& _form = _div[0] = { 5, Div::Alignment::Vertical, 2, false };
// The top one contains the name field, horizontally aligned, 0 padding, no
// dividers and the div height is 28 (height because parent div is vertical)
// The _nameField has size: Div::AUTO, meaning the div will equally divide
// the space, or in this case just give the remaining space to the field. And the
// last 'true' means the object inside the div will be resized to the div size.
auto& _name = _form[4] = { 2, Div::Alignment::Horizontal, 0, false, 28 };
_name[0] = { _nameText, Div::Alignment::Left, 70, true };
_name[1] = { _nameField, Div::Alignment::Left, Div::AUTO, true };
// The end one contains the address field, horizontally aligned, 0 padding, no
// dividers and the div height is 28 (height because parent div is vertical)
auto& _addr = _form[3] = { 2, Div::Alignment::Horizontal, 0, false, 28 };
_addr[0] = { _addressText, Div::Alignment::Left, 70, true };
_addr[1] = { _addressField, Div::Alignment::Left, Div::AUTO, true };
// Below that are the size radio buttons, first divide horizontally like the
// previous 2, height also 28 pixels and no dividers/padding
auto& _size = _form[2] = { 2, Div::Alignment::Horizontal, 0, false, 28 };
_size[0] = { _sizeText, Div::Alignment::Left, 70, true };
// Then divide the left div in 3 horizontal divs with 0 padding and no divider
auto& _sizeBoxes = _size[1] = { 3, Div::Alignment::Horizontal, 0, false };
// For each size button/text divide the div in 2 and but the radio button
// of the left, and immediately besides it the text. All divs are Div::AUTO
// so all 3 will be equally spaced out.
_sizeBoxes[0] = { 2, Div::Alignment::Horizontal, 0, false, Div::AUTO };
_sizeBoxes[0][0] = { _size1Box, Div::Alignment::Left, 20, false };
_sizeBoxes[0][1] = { _size1Text, Div::Alignment::Left, Div::AUTO, true };
_sizeBoxes[1] = { 2, Div::Alignment::Horizontal, 0, false, Div::AUTO };
_sizeBoxes[1][0] = { _size2Box, Div::Alignment::Left, 20, false };
_sizeBoxes[1][1] = { _size2Text, Div::Alignment::Left, Div::AUTO, true };
_sizeBoxes[2] = { 2, Div::Alignment::Horizontal, 0, false, Div::AUTO };
_sizeBoxes[2][0] = { _size3Box, Div::Alignment::Left, 20, false };
_sizeBoxes[2][1] = { _size3Text, Div::Alignment::Left, Div::AUTO, true };
// Then the next one is the topping dropdown, works the same as the name/address
// ones, except now it's a dropdown button instead of a textbox
auto& _topping = _form[1] = { 2, Div::Alignment::Horizontal, 0, false, 28 };
_topping[0] = { _topText, Div::Alignment::Left, 70, true };
_topping[1] = { _topDrop, Div::Alignment::Left, Div::AUTO, true };
// For the final one we will give it the remaining space (Div::AUTO) and put the
// text on top (vertical alignment) with height 28, and the textarea below that
// with auto resize enabled, meaning the textarea will fill the remaining space.
auto& _instr = _form[0] = { 2, Div::Alignment::Vertical, 0, false, Div::AUTO };
_instr[1] = { _instrText, Div::Alignment::Left, 28, true };
_instr[0] = { _instrField, Div::Alignment::Left, Div::AUTO, true };
// Infinite loop, this will automatically stop when the gui closes.
while (_gui.Loop());
}
|