|
| | Button () |
| | Default constructor.
|
| |
| void | activate (Context &ctx) override |
| | Calls on_click.
|
| |
| void | draw (Context &ctx) override |
| | Draw the button.
|
| |
| const ButtonStyle & | get_style (const Context &ctx) const |
| | Get the style this button draws with.
|
| |
| void | set_texture (const asw::Texture &tex, bool auto_size=false) |
| | Set the texture, optionally resizing the button to match.
|
| |
| void | set_images (const asw::Texture &normal, const asw::Texture &hover=nullptr, const asw::Texture &pressed=nullptr, const asw::Texture &disabled=nullptr, bool auto_size=true) |
| | Make an image button: set the state textures, turn off the background, and optionally size the button to the normal texture.
|
| |
| void | set_text (const std::string &t, bool auto_size=false) |
| | Set the text, optionally resizing the button to match.
|
| |
| void | measure (Context &ctx) override |
| | Size to the text if set_text asked for it.
|
| |
| void | layout (Context &ctx) override |
| | Measure, in case the parent did not, then lay out the children.
|
| |
| | Widget () |
| | Default constructor for Widget.
|
| |
| virtual | ~Widget ()=default |
| | Default virtual destructor.
|
| |
| | Widget (Widget &&other) noexcept |
| | Move constructor. The children move over and point to the new widget as their parent. The new widget gets its own id and no parent, since it is not in the old parent's children. Removed children stay with the old widget, which is where Root finds and frees them.
|
| |
| Widget & | operator= (Widget &&other) noexcept |
| | Move assignment operator. The children move over and point to this widget as their parent. This widget keeps its place in the tree: its parent, id and state. Its old children are removed as by clear_children. Removed children of the other widget stay with it.
|
| |
| | Widget (const Widget &)=delete |
| |
| Widget & | operator= (const Widget &)=delete |
| |
| WidgetId | id () const |
| | Get the unique identifier for this widget.
|
| |
| const std::vector< std::unique_ptr< Widget > > & | children () const |
| | Get the child widgets. Change them with add_child, remove_child and clear_children, which keep removed widgets alive until Root is done with them.
|
| |
| virtual bool | on_event (Context &ctx, const UIEvent &e) |
| | Handle a UI event.
|
| |
| virtual void | on_focus_changed (Context &ctx, bool focused) |
| | Called when focus state changes.
|
| |
| template<class T , class... Args> |
| T & | add_child (Args &&... args) |
| | Add a child widget.
|
| |
| bool | remove_child (const Widget &child) |
| | Remove a child widget. It leaves the tree now and is destroyed at the next Root::update, so a callback can remove any widget, even the one it runs in.
|
| |
| void | clear_children () |
| | Remove every child widget, destroyed as for remove_child.
|
| |
| bool | is_hovered () const |
| | Whether the pointer is currently over this widget.
|
| |
| bool | is_pressed () const |
| | Whether this widget is currently being pressed.
|
| |
| bool | is_focused () const |
| | Whether this widget currently holds focus.
|
| |
| bool | is_captured () const |
| | Whether this widget was pressed and the pointer is still held, even if it has moved off the widget.
|
| |
| bool | is_highlighted (const Context &ctx) const |
| | Whether to draw the hover look: hovered, pressed, or focused while focus is shown.
|
| |
|
| std::function< void()> | on_click |
| | Callback invoked when the button is clicked.
|
| |
| float | padding = 0.0f |
| | Padding applied inside the button on all sides.
|
| |
| asw::Font | font |
| | The font for the text. Uses the theme font when empty.
|
| |
| std::string | text |
| | The button text.
|
| |
| asw::Texture | texture |
| | The texture to display on the button.
|
| |
| asw::Texture | texture_hover |
| | Texture shown while hovered or focused. Falls back to texture.
|
| |
| asw::Texture | texture_pressed |
| | Texture shown while pressed. Falls back to texture_hover, then texture.
|
| |
| asw::Texture | texture_disabled |
| | Texture shown while disabled. Falls back to texture.
|
| |
| bool | draw_background = true |
| | Fill the button with the theme background. Turn off for buttons that are only an image.
|
| |
| std::optional< ButtonStyle > | style |
| | Style for this button only. Uses the theme button style when empty.
|
| |
| bool | visible = true |
| | Whether the widget is visible.
|
| |
| bool | enabled = true |
| | Whether the widget is enabled.
|
| |
| bool | focusable = false |
| | Whether the widget can receive focus. Focusable widgets are also the ones the pointer can press.
|
| |
| Widget * | nav_up = nullptr |
| | Widget to focus on up, instead of the nearest one. Optional.
|
| |
| Widget * | nav_down = nullptr |
| | Widget to focus on down, instead of the nearest one. Optional.
|
| |
| Widget * | nav_left = nullptr |
| | Widget to focus on left, instead of the nearest one. Optional.
|
| |
| Widget * | nav_right = nullptr |
| | Widget to focus on right, instead of the nearest one. Optional.
|
| |
| bool | focus_ring = true |
| | Draw the theme focus ring around this widget while it has visible focus. Turn off for widgets that show focus themselves.
|
| |
| Widget * | parent = nullptr |
| | Pointer to the parent widget.
|
| |
| asw::Quad< float > | transform |
| | The transform (position and size) of the widget.
|
| |
| Anchor | anchor = Anchor::None |
| | Pin this widget to a point of its parent, e.g. BottomRight for a corner button. The parent places it on every layout, so it stays in place when the screen or its own size changes. Stack and Grid place their children themselves and ignore it.
|
| |
| asw::Vec2< float > | anchor_margin { 0.0F, 0.0F } |
| | Space between an anchored widget and the parent's edges.
|
| |
An interactive button widget.
Definition at line 24 of file button.h.