mirror of
https://github.com/vsariola/sointu.git
synced 2025-07-18 21:14:31 -04:00
feat(tracker/gioui): add tooltips
Currently, only iconbtns and numeric updowns have tooltips. Closes #84
This commit is contained in:
parent
cafb43f8c8
commit
5884a8d195
@ -5,10 +5,28 @@ import (
|
||||
"gioui.org/unit"
|
||||
"gioui.org/widget"
|
||||
"gioui.org/widget/material"
|
||||
"gioui.org/x/component"
|
||||
)
|
||||
|
||||
func IconButton(th *material.Theme, w *widget.Clickable, icon []byte, enabled bool) material.IconButtonStyle {
|
||||
ret := material.IconButton(th, w, widgetForIcon(icon), "")
|
||||
type TipClickable struct {
|
||||
Clickable widget.Clickable
|
||||
TipArea component.TipArea
|
||||
}
|
||||
|
||||
type TipIconButtonStyle struct {
|
||||
IconButtonStyle material.IconButtonStyle
|
||||
Tooltip component.Tooltip
|
||||
tipArea *component.TipArea
|
||||
}
|
||||
|
||||
func Tooltip(th *material.Theme, tip string) component.Tooltip {
|
||||
tooltip := component.PlatformTooltip(th, tip)
|
||||
tooltip.Bg = black
|
||||
return tooltip
|
||||
}
|
||||
|
||||
func IconButton(th *material.Theme, w *TipClickable, icon []byte, enabled bool, tip string) TipIconButtonStyle {
|
||||
ret := material.IconButton(th, &w.Clickable, widgetForIcon(icon), "")
|
||||
ret.Background = transparent
|
||||
ret.Inset = layout.UniformInset(unit.Dp(6))
|
||||
if enabled {
|
||||
@ -16,7 +34,15 @@ func IconButton(th *material.Theme, w *widget.Clickable, icon []byte, enabled bo
|
||||
} else {
|
||||
ret.Color = disabledTextColor
|
||||
}
|
||||
return ret
|
||||
return TipIconButtonStyle{
|
||||
IconButtonStyle: ret,
|
||||
Tooltip: Tooltip(th, tip),
|
||||
tipArea: &w.TipArea,
|
||||
}
|
||||
}
|
||||
|
||||
func (t *TipIconButtonStyle) Layout(gtx C) D {
|
||||
return t.tipArea.Layout(gtx, t.Tooltip, t.IconButtonStyle.Layout)
|
||||
}
|
||||
|
||||
func LowEmphasisButton(th *material.Theme, w *widget.Clickable, text string) material.ButtonStyle {
|
||||
|
Reference in New Issue
Block a user