From 763fca1f29cd70489842ec8d5276c56ed16b8e1e Mon Sep 17 00:00:00 2001 From: Elias Naur Date: Tue, 30 Nov 2021 16:49:04 +0100 Subject: [PATCH] widget/material: [API] add description argument to IconButton Icons have no inherent semantic meaning such as a label, so this change adds another argument to the IconButton constructor for the client to provide a description. This is an API change, because it seems best to force every client to provide semantic descriptions for icon buttons. Signed-off-by: Elias Naur --- widget/material/button.go | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/widget/material/button.go b/widget/material/button.go index 0136344b..4be69479 100644 --- a/widget/material/button.go +++ b/widget/material/button.go @@ -43,9 +43,10 @@ type IconButtonStyle struct { Color color.NRGBA Icon *widget.Icon // Size is the icon size. - Size unit.Value - Inset layout.Inset - Button *widget.Clickable + Size unit.Value + Inset layout.Inset + Button *widget.Clickable + Description string } func Button(th *Theme, button *widget.Clickable, txt string) ButtonStyle { @@ -72,14 +73,15 @@ func ButtonLayout(th *Theme, button *widget.Clickable) ButtonLayoutStyle { } } -func IconButton(th *Theme, button *widget.Clickable, icon *widget.Icon) IconButtonStyle { +func IconButton(th *Theme, button *widget.Clickable, icon *widget.Icon, description string) IconButtonStyle { return IconButtonStyle{ - Background: th.Palette.ContrastBg, - Color: th.Palette.ContrastFg, - Icon: icon, - Size: unit.Dp(24), - Inset: layout.UniformInset(unit.Dp(12)), - Button: button, + Background: th.Palette.ContrastBg, + Color: th.Palette.ContrastFg, + Icon: icon, + Size: unit.Dp(24), + Inset: layout.UniformInset(unit.Dp(12)), + Button: button, + Description: description, } }