Skip to content

Commit

Permalink
fix: from review
Browse files Browse the repository at this point in the history
  • Loading branch information
qm210 committed Nov 22, 2024
1 parent ad690c7 commit a1787f3
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 14 deletions.
5 changes: 1 addition & 4 deletions tracker/gioui/buttons.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import (
"gioui.org/widget"
"gioui.org/widget/material"
"gioui.org/x/component"

"github.com/vsariola/sointu/tracker"
)

Expand Down Expand Up @@ -298,7 +299,6 @@ type ButtonStyle struct {
Inset layout.Inset
Button *Clickable
shaper *text.Shaper
Hidden bool
}

type ButtonLayoutStyle struct {
Expand Down Expand Up @@ -363,9 +363,6 @@ func (b ButtonStyle) Layout(gtx layout.Context) layout.Dimensions {
CornerRadius: b.CornerRadius,
Button: b.Button,
}.Layout(gtx, func(gtx layout.Context) layout.Dimensions {
if b.Hidden {
return layout.Dimensions{}
}
return b.Inset.Layout(gtx, func(gtx layout.Context) layout.Dimensions {
colMacro := op.Record(gtx.Ops)
paint.ColorOp{Color: b.Color}.Add(gtx.Ops)
Expand Down
16 changes: 16 additions & 0 deletions tracker/gioui/layout.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package gioui

import "gioui.org/layout"

// general helpers for layout that do not belong to any specific widget

func EmptyWidget() layout.Spacer {
return layout.Spacer{}
}

func onlyShowIf(condition bool, widget any) any {
if condition {
return widget
}
return layout.Spacer{}
}
3 changes: 2 additions & 1 deletion tracker/gioui/note_editor.go
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,8 @@ func (te *NoteEditor) layoutButtons(gtx C, t *Tracker) D {
deleteTrackBtnStyle := ActionIcon(gtx, t.Theme, te.DeleteTrackBtn, icons.ActionDelete, te.deleteTrackHint)
splitTrackBtnStyle := ActionIcon(gtx, t.Theme, te.SplitTrackBtn, icons.CommunicationCallSplit, te.splitTrackHint)
newTrackBtnStyle := ActionIcon(gtx, t.Theme, te.NewTrackBtn, icons.ContentAdd, te.addTrackHint)
voiceUpDown := NumericUpDownPadded(t.Theme, te.TrackVoices, "Number of voices for this track", 1)
voiceUpDown := NumericUpDown(t.Theme, te.TrackVoices, "Number of voices for this track")
voiceUpDown.Padding = unit.Dp(1)
effectBtnStyle := ToggleButton(gtx, t.Theme, te.EffectBtn, "Hex")
uniqueBtnStyle := ToggleIcon(gtx, t.Theme, te.UniqueBtn, icons.ToggleStarBorder, icons.ToggleStar, te.uniqueOffTip, te.uniqueOnTip)
midiInBtnStyle := ToggleButton(gtx, t.Theme, te.TrackMidiInBtn, "MIDI")
Expand Down
10 changes: 1 addition & 9 deletions tracker/gioui/numericupdown.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,18 +50,13 @@ type NumericUpDownStyle struct {
Height unit.Dp
Padding unit.Dp
shaper text.Shaper
Hidden bool
}

func NewNumberInput(v tracker.Int) *NumberInput {
return &NumberInput{Int: v}
}

func NumericUpDown(th *material.Theme, number *NumberInput, tooltip string) NumericUpDownStyle {
return NumericUpDownPadded(th, number, tooltip, 0)
}

func NumericUpDownPadded(th *material.Theme, number *NumberInput, tooltip string, padding int) NumericUpDownStyle {
bgColor := th.Palette.Fg
bgColor.R /= 4
bgColor.G /= 4
Expand All @@ -80,15 +75,12 @@ func NumericUpDownPadded(th *material.Theme, number *NumberInput, tooltip string
Tooltip: Tooltip(th, tooltip),
Width: unit.Dp(70),
Height: unit.Dp(20),
Padding: unit.Dp(padding),
Padding: unit.Dp(0),
shaper: *th.Shaper,
}
}

func (s *NumericUpDownStyle) Layout(gtx C) D {
if s.Hidden {
return D{}
}
if s.Padding <= 0 {
return s.layoutWithTooltip(gtx)
}
Expand Down

0 comments on commit a1787f3

Please sign in to comment.