24 lines
718 B
Go
24 lines
718 B
Go
package core
|
|
|
|
import (
|
|
"github.com/egoist/mygo/ui"
|
|
|
|
"git.zacharyzhang.com/ZacharyZhang-NY/MujicaUI/internal"
|
|
"git.zacharyzhang.com/ZacharyZhang-NY/MujicaUI/theme"
|
|
)
|
|
|
|
// IconAction is a square, borderless button showing icon, named label.
|
|
func IconAction(c *ui.Context, icon *ui.SVG, label string) *ui.Element {
|
|
k := Tokens(c)
|
|
b := ui.ButtonBase(c).Size(theme.MinHitSize, theme.MinHitSize).Radius(theme.ControlRadius).Label(label).TextColor(k.TextMuted)
|
|
internal.Ring(b, k.Focus, theme.ControlRadius)
|
|
switch {
|
|
case b.Pressed():
|
|
b.Background(k.Selection).TextColor(k.Text)
|
|
case b.Hovered():
|
|
b.Background(k.SurfaceHover).TextColor(k.Text)
|
|
}
|
|
b.Children(func() { ui.Icon(c, icon).Size(16, 16) })
|
|
return b
|
|
}
|