MButton
- Module
- Miri
- Header
#include "Miri/Widgets/MButton.h"- Namespace
Miri
Public functions
| Returns | Name | Description |
|---|---|---|
MIRI_WIDGET_ARGS | ||
WidgetArgsType& | AnimateHover | |
MIRI_ATTR | icon, 8 px sides and a 4 px gap. | |
bool | CanCacheDesiredSize | |
bool | CanSkipArrange | |
bool | CanRetainPaint | The hover fade is a clock: while it runs, every frame's background is a different colour with nothing to invalidate on. |
MiriVec2 | ComputeDesiredSize | |
void | ArrangeChildren | |
int32_t | OnPaint | |
CReply | OnMouseButtonDown | |
CReply | OnMouseButtonUp | |
void | OnMouseEnter | |
void | OnMouseLeave | |
const char* | GetTypeName | |
EAccessibleRole | GetAccessibleRole | |
bool | IsFocusable | |
float | GetFocusRadius | |
bool | OnActivate | |
void | SetStateBrushes | Custom-variant buttons paint these instead of the style's brushes. |
EMiriBrushState | GetBrushState | The state the button is in for painting and for sounds: Disabled, then Pressed, Hovered, Focused, Selected, else Normal. |
void | SetOnStateChanged | Fires when a pointer, press, focus, selection or enabled change moves the button to another state. |
void | OnFocusReceived | |
void | OnEnabledChanged | |
void | OnFocusLost | |
void | SetOnClicked | |
void | SetOnPressedChanged | |
void | SetAnimateHover | |
EMiriButtonVariant | GetVariant | |
void | SetLabel | |
const std::string& | GetLabel | |
void | SetIcon | A Lucide glyph (MIRI_ICON_* or CMiriLucideIcons::Find). |
void | SetSelected | The latched state of an icon button (a snap toggle that is on). |
bool | IsSelected | |
float | GetHoverAmount | 0..1 progress of the hover and press transitions, timed by the MowoMotion Hover and Press tokens. |
float | GetPressAmount | |
FVariantMetrics | GetVariantMetrics |
Function details
MIRI_WIDGET_ARGS
MIRI_WIDGET_ARGS(MButton) MIRI_EVENT(COnClicked, OnClicked) MIRI_EVENT(COnBoolChanged, OnPressedChanged) bool _AnimateHover = trueAnimateHover
WidgetArgsType& AnimateHover(bool value)MIRI_ATTR
MIRI_ATTR(MiriColor, ButtonColor) MIRI_ATTR(MiriColor, HoverColor) MIRI_ATTR(MiriColor, PressColor) MIRI_ATTR(float, CornerRadius) MIRI_ATTR(MiriMargin, ContentPadding) MIRI_ARG(EMiriButtonVariant, Variant) MIRI_ARG(std::string, Label) MIRI_ARG(std::string, Icon) MIRI_ARG(bool, IsSelected) MIRI_ARG(float, Height) MIRI_ARG(bool, Dense) MIRI_CONTENT(MButton, Content) MIRI_WIDGET_ARGS_END() void Construct(const CArguments& args)icon, 8 px sides and a 4 px gap.
CanCacheDesiredSize
bool CanCacheDesiredSize() const overrideCanSkipArrange
bool CanSkipArrange() const overrideCanRetainPaint
bool CanRetainPaint() const overrideThe hover fade is a clock: while it runs, every frame's background is a different colour with nothing to invalidate on. Settled, the tint is a pure function of the press flag and the style set, both of which announce themselves. The enter/leave handlers drop the slice so the pre-hover picture cannot come back once the fade lands.
ComputeDesiredSize
MiriVec2 ComputeDesiredSize(float scale) const overrideArrangeChildren
void ArrangeChildren(const CGeometry& geo) overrideOnPaint
int32_t OnPaint(const CMiriPaintArgs& args, const CGeometry& geo, CMiriRenderer& renderer, int32_t layerId) const overrideOnMouseButtonDown
CReply OnMouseButtonDown(const CGeometry& geo, const CPointerEvent& event) overrideOnMouseButtonUp
CReply OnMouseButtonUp(const CGeometry& geo, const CPointerEvent& event) overrideOnMouseEnter
void OnMouseEnter(const CGeometry& geo, const CPointerEvent& event) overrideOnMouseLeave
void OnMouseLeave(const CPointerEvent& event) overrideGetTypeName
const char* GetTypeName() const overrideGetAccessibleRole
EAccessibleRole GetAccessibleRole() const overrideIsFocusable
bool IsFocusable() const overrideGetFocusRadius
float GetFocusRadius() const overrideOnActivate
bool OnActivate() overrideSetStateBrushes
void SetStateBrushes(const FMiriStateBrushes& brushes)Custom-variant buttons paint these instead of the style's brushes. A state with none falls back to Normal; an empty set restores the style.
GetBrushState
EMiriBrushState GetBrushState() constThe state the button is in for painting and for sounds: Disabled, then Pressed, Hovered, Focused, Selected, else Normal.
SetOnStateChanged
void SetOnStateChanged(std::function<void(EMiriBrushState)> callback)Fires when a pointer, press, focus, selection or enabled change moves the button to another state. Releasing a press back to Hovered is silent.
OnFocusReceived
void OnFocusReceived(const CFocusEvent& event) overrideOnEnabledChanged
void OnEnabledChanged() overrideOnFocusLost
void OnFocusLost(const CFocusEvent& event) overrideSetOnClicked
void SetOnClicked(std::function<void()> func)SetOnPressedChanged
void SetOnPressedChanged(std::function<void(bool)> func)SetAnimateHover
void SetAnimateHover(bool animate)GetVariant
EMiriButtonVariant GetVariant() constSetLabel
void SetLabel(const std::string& label)GetLabel
const std::string& GetLabel() constSetIcon
void SetIcon(const std::string& glyph)A Lucide glyph (MIRI_ICON_* or CMiriLucideIcons::Find).
SetSelected
void SetSelected(bool selected)The latched state of an icon button (a snap toggle that is on).
IsSelected
bool IsSelected() constGetHoverAmount
float GetHoverAmount() const0..1 progress of the hover and press transitions, timed by the MowoMotion Hover and Press tokens.
GetPressAmount
float GetPressAmount() constGetVariantMetrics
static FVariantMetrics GetVariantMetrics(EMiriButtonVariant variant)