Dialog class
#include <Jazz2/UI/Windows/Dialogs.h>
Window shown over the interface with a title, content and buttons.
The window is moved by dragging its title, the cross next to the title cancels it as Escape does. A window that is Resizable is resized by its edges and the corner with the dots.
Base classes
- class Panel
- A stack with a background.
Derived classes
- class FileDialog
- Picks a file to open or to save to.
Constructors, destructors, conversion operators
- Dialog(StringView title, bool scrollContent = false) explicit
- Creates a new instance.
Public functions
- auto GetContent() const -> Stack*
- Returns the area for the content.
- auto AddButton(StringView text, Function<void()>&& onClick, bool accent = false) -> Button*
- Adds a button.
- void Close()
- Closes the dialog.
- void Cancel()
- Cancels the dialog as Escape does, by OnCancel, by the last button, or closes it if it has none.
- auto GetTitle() const -> StringView override
- Returns the title of the element as a window, the system shows it on the taskbar while it's in a window of its own.
- auto Measure(const Context& context, Vector2f available) -> Vector2f override
- Returns the size the element wants, in pixels.
- void Arrange(const Context& context, const Rectf& bounds) override
- Places the element and its children.
- void Draw(Painter& painter) override
- Draws the element and its children.
- void Update(float timeMult) override
- Advances animations of the element and its children.
- auto HitTest(Vector2f pos) -> Element* override
- Returns the element under a position that takes the pointer, or
nullptr. - auto GetHitBounds() const -> Rectf override
- With the edges a window that is Resizable is grabbed by, which reach a little outside of it.
- auto OnPointerDown(const PointerEvent& event) -> bool override
- Called when the pointer is pressed over the element, returns
trueto keep getting it until released. - void OnPointerMove(const PointerEvent& event) override
- Called when the pointer moves while pressed over the element.
- void OnPointerUp(const PointerEvent& event, bool inside) override
- Called when the pointer is released,
insidetells whether it's still over the element. - auto OnKeyPressed(const KeyboardEvent& event) -> bool override
- Called when a key is pressed while the element has the focus, returns
trueif it was used.
Public variables
- Function<void()> OnCancel
- Called instead of the last button when the dialog is cancelled by Escape or the cross.
- float MaxScreenHeightFraction
- Part of the height of the screen the dialog takes at most, 1 for all of it.
- float MinScreenWidthFraction
- Part of the width of the screen the dialog takes if its content is narrower, 0 for as wide as its content.
- float MaxStretchedWidth
- Width in units MinScreenWidthFraction makes the dialog at most, 0 for no limit, its content can still make it wider.
- bool Resizable
- Whether the window can be resized by its edges.
- Vector2f MinResizeSize
- Smallest size in units the window can be resized to.
Protected variables
Function documentation
Jazz2:: UI:: Windows:: Dialog:: Dialog(StringView title,
bool scrollContent = false) explicit
Creates a new instance.
With scrollContent, a dialog taller than the screen is made as tall as the screen and its content scrolls, the title and the buttons stay. It's left to the dialog, as a list in the content that has no height of its own would be as tall as all of its rows then, and the whole content would scroll instead of the list.
Button* Jazz2:: UI:: Windows:: Dialog:: AddButton(StringView text,
Function<void()>&& onClick,
bool accent = false)
Adds a button.
Enter chooses the first accented button, or the first one if none is accented and OnCancel isn't set. Escape and the cross choose the last one, it should be the one that closes the dialog, unless OnCancel is set. A window closed only by its cross has no button that closes it — with no buttons at all, Escape and the cross close it, and the row of buttons isn't shown.
Variable documentation
float Jazz2:: UI:: Windows:: Dialog:: MaxScreenHeightFraction
Part of the height of the screen the dialog takes at most, 1 for all of it.
A list in the content that should use the room is given Element::
float Jazz2:: UI:: Windows:: Dialog:: MinScreenWidthFraction
Part of the width of the screen the dialog takes if its content is narrower, 0 for as wide as its content.
A dialog is never narrower than its content, unless the screen is.
bool Jazz2:: UI:: Windows:: Dialog:: Resizable
Whether the window can be resized by its edges.
Its size is then its Width and Height, set by the resizing, the size it starts with if they're set before, and the content should fill it by Element::