mirror of
https://github.com/vsariola/sointu.git
synced 2025-05-28 03:10:24 -04:00
fix: from review
This commit is contained in:
parent
ad690c7697
commit
243396c301
@ -19,6 +19,7 @@ import (
|
||||
"gioui.org/widget"
|
||||
"gioui.org/widget/material"
|
||||
"gioui.org/x/component"
|
||||
|
||||
"github.com/vsariola/sointu/tracker"
|
||||
)
|
||||
|
||||
@ -298,7 +299,6 @@ type ButtonStyle struct {
|
||||
Inset layout.Inset
|
||||
Button *Clickable
|
||||
shaper *text.Shaper
|
||||
Hidden bool
|
||||
}
|
||||
|
||||
type ButtonLayoutStyle struct {
|
||||
@ -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)
|
||||
|
16
tracker/gioui/layout.go
Normal file
16
tracker/gioui/layout.go
Normal file
@ -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 OnlyIf(condition bool, widget layout.Widget) layout.Widget {
|
||||
if condition {
|
||||
return widget
|
||||
}
|
||||
return EmptyWidget().Layout
|
||||
}
|
@ -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")
|
||||
@ -175,7 +176,7 @@ func (te *NoteEditor) layoutButtons(gtx C, t *Tracker) D {
|
||||
layout.Rigid(voiceUpDown.Layout),
|
||||
layout.Rigid(splitTrackBtnStyle.Layout),
|
||||
layout.Flexed(1, func(gtx C) D { return layout.Dimensions{Size: gtx.Constraints.Min} }),
|
||||
layout.Rigid(midiInBtnStyle.Layout),
|
||||
layout.Rigid(OnlyIf(t.HasAnyMidiInput(), midiInBtnStyle.Layout)),
|
||||
layout.Flexed(1, func(gtx C) D { return layout.Dimensions{Size: gtx.Constraints.Min} }),
|
||||
layout.Rigid(deleteTrackBtnStyle.Layout),
|
||||
layout.Rigid(newTrackBtnStyle.Layout))
|
||||
|
@ -50,7 +50,6 @@ type NumericUpDownStyle struct {
|
||||
Height unit.Dp
|
||||
Padding unit.Dp
|
||||
shaper text.Shaper
|
||||
Hidden bool
|
||||
}
|
||||
|
||||
func NewNumberInput(v tracker.Int) *NumberInput {
|
||||
@ -58,10 +57,6 @@ func NewNumberInput(v tracker.Int) *NumberInput {
|
||||
}
|
||||
|
||||
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
|
||||
@ -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)
|
||||
}
|
||||
|
@ -164,10 +164,7 @@ func (t *Tracker) Main() {
|
||||
func NewWindow() *app.Window {
|
||||
w := new(app.Window)
|
||||
w.Option(app.Title("Sointu Tracker"))
|
||||
w.Option(
|
||||
app.Size(unit.Dp(800), unit.Dp(600)),
|
||||
app.Fullscreen.Option(),
|
||||
)
|
||||
w.Option(app.Size(unit.Dp(800), unit.Dp(600)))
|
||||
return w
|
||||
}
|
||||
|
||||
@ -350,3 +347,10 @@ func (t *Tracker) removeFromMidiNotePlaying(note byte) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func (t *Tracker) HasAnyMidiInput() bool {
|
||||
for _ = range t.Model.MIDI.InputDevices {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user