mirror of
https://github.com/vsariola/sointu.git
synced 2025-11-12 21:02:52 -05:00
drafting preset explorer
This commit is contained in:
parent
3f365707c2
commit
57aef3bed3
@ -73,6 +73,13 @@ type (
|
||||
Button
|
||||
}
|
||||
|
||||
// TabButton is a button used in a tab bar.
|
||||
TabButton struct {
|
||||
IndicatorHeight unit.Dp
|
||||
IndicatorColor color.NRGBA
|
||||
ToggleButton
|
||||
}
|
||||
|
||||
// IconButton is a button with an icon.
|
||||
IconButton struct {
|
||||
Theme *Theme
|
||||
@ -126,6 +133,19 @@ func ToggleBtn(b tracker.Bool, th *Theme, c *Clickable, text string, tip string)
|
||||
}
|
||||
}
|
||||
|
||||
func TabBtn(b tracker.Bool, th *Theme, c *Clickable, text string, tip string) TabButton {
|
||||
return TabButton{
|
||||
IndicatorHeight: th.Button.Tab.IndicatorHeight,
|
||||
IndicatorColor: th.Button.Tab.IndicatorColor,
|
||||
ToggleButton: ToggleButton{
|
||||
Bool: b,
|
||||
DisabledStyle: &th.Button.Disabled,
|
||||
OffStyle: &th.Button.Tab.Inactive,
|
||||
Button: Btn(th, &th.Button.Tab.Active, c, text, tip),
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func IconBtn(th *Theme, st *IconButtonStyle, c *Clickable, icon []byte, tip string) IconButton {
|
||||
return IconButton{
|
||||
Theme: th,
|
||||
@ -288,6 +308,26 @@ func (b *ToggleIconButton) Layout(gtx C) D {
|
||||
return b.IconButton.Layout(gtx)
|
||||
}
|
||||
|
||||
func (b *TabButton) Layout(gtx C) D {
|
||||
return layout.Stack{Alignment: layout.S}.Layout(gtx,
|
||||
layout.Stacked(b.ToggleButton.Layout),
|
||||
layout.Expanded(func(gtx C) D {
|
||||
if !b.ToggleButton.Bool.Value() {
|
||||
return D{}
|
||||
}
|
||||
w := gtx.Constraints.Min.X
|
||||
h := gtx.Dp(b.IndicatorHeight)
|
||||
r := clip.RRect{
|
||||
Rect: image.Rect(0, 0, w, h),
|
||||
NE: h, NW: h, SE: 0, SW: 0,
|
||||
}
|
||||
defer r.Push(gtx.Ops).Pop()
|
||||
paint.Fill(gtx.Ops, b.IndicatorColor)
|
||||
return layout.Dimensions{Size: image.Pt(w, h)}
|
||||
}),
|
||||
)
|
||||
}
|
||||
|
||||
// Click executes a simple programmatic click.
|
||||
func (b *Clickable) Click() {
|
||||
b.requestClicks++
|
||||
|
||||
Reference in New Issue
Block a user