Awesome labels
This commit is contained in:
parent
f9032a9a95
commit
a74f9809af
@ -246,7 +246,7 @@ func (element *Piano) recalculate () {
|
|||||||
element.flatKeys = make([]pianoKey, element.countFlats())
|
element.flatKeys = make([]pianoKey, element.countFlats())
|
||||||
element.sharpKeys = make([]pianoKey, element.countSharps())
|
element.sharpKeys = make([]pianoKey, element.countSharps())
|
||||||
|
|
||||||
inset := element.theme.Inset(theme.PatternSunken)
|
inset := element.theme.Inset(theme.PatternPinboard)
|
||||||
bounds := inset.Apply(element.Bounds())
|
bounds := inset.Apply(element.Bounds())
|
||||||
|
|
||||||
dot := bounds.Min
|
dot := bounds.Min
|
||||||
@ -278,7 +278,7 @@ func (element *Piano) draw () {
|
|||||||
Focused: element.Focused(),
|
Focused: element.Focused(),
|
||||||
Disabled: !element.Enabled(),
|
Disabled: !element.Enabled(),
|
||||||
}
|
}
|
||||||
pattern := element.theme.Pattern(theme.PatternSunken, state)
|
pattern := element.theme.Pattern(theme.PatternPinboard, state)
|
||||||
// inset := element.theme.Inset(theme.PatternSunken)
|
// inset := element.theme.Inset(theme.PatternSunken)
|
||||||
artist.FillRectangle(element, pattern, element.Bounds())
|
artist.FillRectangle(element, pattern, element.Bounds())
|
||||||
|
|
||||||
|
@ -33,10 +33,9 @@ func run () {
|
|||||||
window, _ := tomo.NewWindow(2, 2)
|
window, _ := tomo.NewWindow(2, 2)
|
||||||
window.SetTitle("Piano")
|
window.SetTitle("Piano")
|
||||||
container := basicElements.NewContainer(basicLayouts.Vertical { true, true })
|
container := basicElements.NewContainer(basicLayouts.Vertical { true, true })
|
||||||
|
|
||||||
controlBar := basicElements.NewContainer(basicLayouts.Horizontal { true, false })
|
controlBar := basicElements.NewContainer(basicLayouts.Horizontal { true, false })
|
||||||
// label := basicElements.NewLabel("Play a song!", false)
|
|
||||||
|
|
||||||
|
waveformColumn := basicElements.NewContainer(basicLayouts.Vertical { true, false })
|
||||||
waveformList := basicElements.NewList (
|
waveformList := basicElements.NewList (
|
||||||
basicElements.NewListEntry("Sine", func(){ waveform = 0 }),
|
basicElements.NewListEntry("Sine", func(){ waveform = 0 }),
|
||||||
basicElements.NewListEntry("Triangle", func(){ waveform = 3 }),
|
basicElements.NewListEntry("Triangle", func(){ waveform = 3 }),
|
||||||
@ -67,6 +66,7 @@ func run () {
|
|||||||
adsr.Release = releaseSlider.Value()
|
adsr.Release = releaseSlider.Value()
|
||||||
})
|
})
|
||||||
|
|
||||||
|
patchColumn := basicElements.NewContainer(basicLayouts.Vertical { true, false })
|
||||||
patch := func (w int, a, d time.Duration, s float64, r time.Duration) func () {
|
patch := func (w int, a, d time.Duration, s float64, r time.Duration) func () {
|
||||||
return func () {
|
return func () {
|
||||||
waveform = w
|
waveform = w
|
||||||
@ -87,7 +87,7 @@ func run () {
|
|||||||
basicElements.NewListEntry ("Bones", patch (
|
basicElements.NewListEntry ("Bones", patch (
|
||||||
0, 0, 100, 0.0, 0)),
|
0, 0, 100, 0.0, 0)),
|
||||||
basicElements.NewListEntry ("Staccato", patch (
|
basicElements.NewListEntry ("Staccato", patch (
|
||||||
4, 70, 0, 1.0, 400)),
|
4, 70, 500, 0, 0)),
|
||||||
basicElements.NewListEntry ("Sustain", patch (
|
basicElements.NewListEntry ("Sustain", patch (
|
||||||
4, 70, 200, 0.8, 500)),
|
4, 70, 200, 0.8, 500)),
|
||||||
basicElements.NewListEntry ("Upright", patch (
|
basicElements.NewListEntry ("Upright", patch (
|
||||||
@ -98,6 +98,8 @@ func run () {
|
|||||||
2, 0, 40, 0.0, 0)),
|
2, 0, 40, 0.0, 0)),
|
||||||
basicElements.NewListEntry ("Racer", patch (
|
basicElements.NewListEntry ("Racer", patch (
|
||||||
3, 70, 0, 0.7, 400)),
|
3, 70, 0, 0.7, 400)),
|
||||||
|
basicElements.NewListEntry ("Reverse", patch (
|
||||||
|
2, 3000, 60, 0, 0)),
|
||||||
)
|
)
|
||||||
patchList.Collapse(0, 32)
|
patchList.Collapse(0, 32)
|
||||||
patchScrollBox := basicElements.NewScrollContainer(false, true)
|
patchScrollBox := basicElements.NewScrollContainer(false, true)
|
||||||
@ -105,24 +107,38 @@ func run () {
|
|||||||
piano := fun.NewPiano(2, 5)
|
piano := fun.NewPiano(2, 5)
|
||||||
piano.OnPress(playNote)
|
piano.OnPress(playNote)
|
||||||
piano.OnRelease(stopNote)
|
piano.OnRelease(stopNote)
|
||||||
piano.Focus()
|
|
||||||
|
// honestly, if you were doing something like this for real, i'd
|
||||||
|
// encourage you to build a custom layout because this is a bit cursed.
|
||||||
|
// i need to add more layouts...
|
||||||
|
|
||||||
window.Adopt(container)
|
window.Adopt(container)
|
||||||
// controlBar.Adopt(label, true)
|
|
||||||
controlBar.Adopt(patchScrollBox, true)
|
controlBar.Adopt(patchColumn, true)
|
||||||
|
patchColumn.Adopt(basicElements.NewLabel("Presets", false), false)
|
||||||
|
patchColumn.Adopt(patchScrollBox, true)
|
||||||
patchScrollBox.Adopt(patchList)
|
patchScrollBox.Adopt(patchList)
|
||||||
controlBar.Adopt(waveformList, true)
|
|
||||||
controlBar.Adopt(basicElements.NewSpacer(true), false)
|
controlBar.Adopt(basicElements.NewSpacer(true), false)
|
||||||
|
|
||||||
|
controlBar.Adopt(waveformColumn, false)
|
||||||
|
waveformColumn.Adopt(basicElements.NewLabel("Waveform", false), false)
|
||||||
|
waveformColumn.Adopt(waveformList, true)
|
||||||
|
|
||||||
|
controlBar.Adopt(basicElements.NewSpacer(true), false)
|
||||||
|
|
||||||
adsrColumn.Adopt(basicElements.NewLabel("ADSR", false), false)
|
adsrColumn.Adopt(basicElements.NewLabel("ADSR", false), false)
|
||||||
adsrGroup.Adopt(attackSlider, false)
|
adsrGroup.Adopt(attackSlider, false)
|
||||||
adsrGroup.Adopt(decaySlider, false)
|
adsrGroup.Adopt(decaySlider, false)
|
||||||
adsrGroup.Adopt(sustainSlider, false)
|
adsrGroup.Adopt(sustainSlider, false)
|
||||||
adsrGroup.Adopt(releaseSlider, false)
|
adsrGroup.Adopt(releaseSlider, false)
|
||||||
adsrColumn.Adopt(adsrGroup, true)
|
adsrColumn.Adopt(adsrGroup, true)
|
||||||
|
|
||||||
controlBar.Adopt(adsrColumn, false)
|
controlBar.Adopt(adsrColumn, false)
|
||||||
container.Adopt(controlBar, true)
|
container.Adopt(controlBar, true)
|
||||||
container.Adopt(piano, false)
|
container.Adopt(piano, false)
|
||||||
|
|
||||||
|
piano.Focus()
|
||||||
window.OnClose(tomo.Stop)
|
window.OnClose(tomo.Stop)
|
||||||
window.Show()
|
window.Show()
|
||||||
}
|
}
|
||||||
|
@ -95,7 +95,11 @@ func (Default) Pattern (
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
case PatternPinboard:
|
case PatternPinboard:
|
||||||
|
if state.Focused {
|
||||||
|
return focusedTexturedSunkenPattern
|
||||||
|
} else {
|
||||||
return texturedSunkenPattern
|
return texturedSunkenPattern
|
||||||
|
}
|
||||||
case PatternButton:
|
case PatternButton:
|
||||||
if state.Disabled {
|
if state.Disabled {
|
||||||
return disabledButtonPattern
|
return disabledButtonPattern
|
||||||
|
@ -19,13 +19,9 @@ var sunkenPattern = artist.NewMultiBordered (
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
artist.Stroke { Pattern: artist.NewUniform(hex(0x97a09cFF)) })
|
artist.Stroke { Pattern: artist.NewUniform(hex(0x97a09cFF)) })
|
||||||
|
|
||||||
var focusedSunkenPattern = artist.NewMultiBordered (
|
var focusedSunkenPattern = artist.NewMultiBordered (
|
||||||
artist.Stroke { Weight: 1, Pattern: strokePattern },
|
artist.Stroke { Weight: 1, Pattern: strokePattern },
|
||||||
artist.Stroke {
|
artist.Stroke { Weight: 1, Pattern: accentPattern },
|
||||||
Weight: 1,
|
|
||||||
Pattern: accentPattern,
|
|
||||||
},
|
|
||||||
artist.Stroke { Pattern: artist.NewUniform(hex(0x97a09cFF)) })
|
artist.Stroke { Pattern: artist.NewUniform(hex(0x97a09cFF)) })
|
||||||
|
|
||||||
var texturedSunkenPattern = artist.NewMultiBordered (
|
var texturedSunkenPattern = artist.NewMultiBordered (
|
||||||
@ -37,21 +33,18 @@ var texturedSunkenPattern = artist.NewMultiBordered (
|
|||||||
artist.NewUniform(hex(0x97a09cFF)),
|
artist.NewUniform(hex(0x97a09cFF)),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
// artist.Stroke { Pattern: artist.Striped {
|
|
||||||
// First: artist.Stroke {
|
|
||||||
// Weight: 2,
|
|
||||||
// Pattern: artist.NewUniform(hex(0x97a09cFF)),
|
|
||||||
// },
|
|
||||||
// Second: artist.Stroke {
|
|
||||||
// Weight: 1,
|
|
||||||
// Pattern: artist.NewUniform(hex(0x6e8079FF)),
|
|
||||||
// },
|
|
||||||
// }})
|
|
||||||
|
|
||||||
artist.Stroke { Pattern: artist.Noisy {
|
artist.Stroke { Pattern: artist.Noisy {
|
||||||
Low: artist.NewUniform(hex(0x97a09cFF)),
|
Low: artist.NewUniform(hex(0x97a09cFF)),
|
||||||
High: artist.NewUniform(hex(0x6e8079FF)),
|
High: artist.NewUniform(hex(0x6e8079FF)),
|
||||||
}})
|
}})
|
||||||
|
var focusedTexturedSunkenPattern = artist.NewMultiBordered (
|
||||||
|
artist.Stroke { Weight: 1, Pattern: strokePattern },
|
||||||
|
artist.Stroke { Weight: 1, Pattern: accentPattern },
|
||||||
|
artist.Stroke { Pattern: artist.Noisy {
|
||||||
|
Low: artist.NewUniform(hex(0x97a09cFF)),
|
||||||
|
High: artist.NewUniform(hex(0x6e8079FF)),
|
||||||
|
}})
|
||||||
|
|
||||||
var raisedPattern = artist.NewMultiBordered (
|
var raisedPattern = artist.NewMultiBordered (
|
||||||
artist.Stroke { Weight: 1, Pattern: strokePattern },
|
artist.Stroke { Weight: 1, Pattern: strokePattern },
|
||||||
|
Reference in New Issue
Block a user