this piano is DOPE and PHAT and WAY COOL
This commit is contained in:
parent
ee45b2fa60
commit
b1d15fb4ec
@ -2,7 +2,6 @@ package basicElements
|
|||||||
|
|
||||||
import "git.tebibyte.media/sashakoshka/tomo/theme"
|
import "git.tebibyte.media/sashakoshka/tomo/theme"
|
||||||
import "git.tebibyte.media/sashakoshka/tomo/config"
|
import "git.tebibyte.media/sashakoshka/tomo/config"
|
||||||
import "git.tebibyte.media/sashakoshka/tomo/artist/shapes"
|
|
||||||
import "git.tebibyte.media/sashakoshka/tomo/elements/core"
|
import "git.tebibyte.media/sashakoshka/tomo/elements/core"
|
||||||
|
|
||||||
// Spacer can be used to put space between two elements..
|
// Spacer can be used to put space between two elements..
|
||||||
@ -22,7 +21,7 @@ func NewSpacer (line bool) (element *Spacer) {
|
|||||||
element = &Spacer { line: line }
|
element = &Spacer { line: line }
|
||||||
element.theme.Case = theme.C("basic", "spacer")
|
element.theme.Case = theme.C("basic", "spacer")
|
||||||
element.Core, element.core = core.NewCore(element.draw)
|
element.Core, element.core = core.NewCore(element.draw)
|
||||||
element.core.SetMinimumSize(1, 1)
|
element.updateMinimumSize()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -30,6 +29,7 @@ func NewSpacer (line bool) (element *Spacer) {
|
|||||||
func (element *Spacer) SetLine (line bool) {
|
func (element *Spacer) SetLine (line bool) {
|
||||||
if element.line == line { return }
|
if element.line == line { return }
|
||||||
element.line = line
|
element.line = line
|
||||||
|
element.updateMinimumSize()
|
||||||
if element.core.HasImage() {
|
if element.core.HasImage() {
|
||||||
element.draw()
|
element.draw()
|
||||||
element.core.DamageAll()
|
element.core.DamageAll()
|
||||||
@ -50,6 +50,17 @@ func (element *Spacer) SetConfig (new config.Config) {
|
|||||||
element.redo()
|
element.redo()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (element *Spacer) updateMinimumSize () {
|
||||||
|
if element.line {
|
||||||
|
padding := element.theme.Padding(theme.PatternLine)
|
||||||
|
element.core.SetMinimumSize (
|
||||||
|
padding.Horizontal(),
|
||||||
|
padding.Vertical())
|
||||||
|
} else {
|
||||||
|
element.core.SetMinimumSize(1, 1)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func (element *Spacer) redo () {
|
func (element *Spacer) redo () {
|
||||||
if !element.core.HasImage() {
|
if !element.core.HasImage() {
|
||||||
element.draw()
|
element.draw()
|
||||||
@ -61,10 +72,10 @@ func (element *Spacer) draw () {
|
|||||||
bounds := element.Bounds()
|
bounds := element.Bounds()
|
||||||
|
|
||||||
if element.line {
|
if element.line {
|
||||||
color := element.theme.Color (
|
pattern := element.theme.Pattern (
|
||||||
theme.ColorForeground,
|
theme.PatternLine,
|
||||||
theme.State { })
|
theme.State { })
|
||||||
shapes.FillColorRectangle(element.core, color, bounds)
|
pattern.Draw(element.core, bounds)
|
||||||
} else {
|
} else {
|
||||||
pattern := element.theme.Pattern (
|
pattern := element.theme.Pattern (
|
||||||
theme.PatternBackground,
|
theme.PatternBackground,
|
||||||
|
@ -218,11 +218,11 @@ func (element *Piano) SetConfig (new config.Config) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (element *Piano) updateMinimumSize () {
|
func (element *Piano) updateMinimumSize () {
|
||||||
padding := element.theme.Padding(theme.PatternSunken)
|
padding := element.theme.Padding(theme.PatternPinboard)
|
||||||
element.core.SetMinimumSize (
|
element.core.SetMinimumSize (
|
||||||
pianoKeyWidth * 7 * element.countOctaves() +
|
pianoKeyWidth * 7 * element.countOctaves() +
|
||||||
padding[1] + padding[3],
|
padding.Horizontal(),
|
||||||
64 + padding[0] + padding[2])
|
64 + padding.Vertical())
|
||||||
}
|
}
|
||||||
|
|
||||||
func (element *Piano) countOctaves () int {
|
func (element *Piano) countOctaves () int {
|
||||||
|
Binary file not shown.
Before Width: | Height: | Size: 2.2 KiB After Width: | Height: | Size: 3.0 KiB |
@ -14,7 +14,7 @@ import "git.tebibyte.media/sashakoshka/tomo/artist/patterns"
|
|||||||
//go:embed assets/wintergreen.png
|
//go:embed assets/wintergreen.png
|
||||||
var defaultAtlasBytes []byte
|
var defaultAtlasBytes []byte
|
||||||
var defaultAtlas canvas.Canvas
|
var defaultAtlas canvas.Canvas
|
||||||
var defaultTextures [8][10]artist.Pattern
|
var defaultTextures [13][10]artist.Pattern
|
||||||
|
|
||||||
func atlasCell (col, row int, border artist.Inset) {
|
func atlasCell (col, row int, border artist.Inset) {
|
||||||
bounds := image.Rect(0, 0, 16, 16).Add(image.Pt(col, row).Mul(16))
|
bounds := image.Rect(0, 0, 16, 16).Add(image.Pt(col, row).Mul(16))
|
||||||
@ -37,19 +37,30 @@ func init () {
|
|||||||
// PatternDead
|
// PatternDead
|
||||||
atlasCol(0, artist.Inset { })
|
atlasCol(0, artist.Inset { })
|
||||||
// PatternRaised
|
// PatternRaised
|
||||||
atlasCol(1, artist.Inset { 6, 6, 6, 6 }) // broken
|
atlasCol(1, artist.Inset { 6, 6, 6, 6 })
|
||||||
// PatternSunken
|
// PatternSunken
|
||||||
atlasCol(2, artist.Inset { 4, 4, 4, 4 })
|
atlasCol(2, artist.Inset { 4, 4, 4, 4 })
|
||||||
// PatternPinboard
|
// PatternPinboard
|
||||||
atlasCol(3, artist.Inset { 2, 2, 2, 2 })
|
atlasCol(3, artist.Inset { 2, 2, 2, 2 })
|
||||||
// PatternButton
|
// PatternButton
|
||||||
atlasCol(4, artist.Inset { 6, 6, 6, 6 }) // broken
|
atlasCol(4, artist.Inset { 6, 6, 6, 6 })
|
||||||
// PatternInput
|
// PatternInput
|
||||||
atlasCol(5, artist.Inset { 4, 4, 4, 4 })
|
atlasCol(5, artist.Inset { 4, 4, 4, 4 })
|
||||||
// PatternGutter
|
// PatternGutter
|
||||||
atlasCol(6, artist.Inset { 4, 4, 4, 4 })
|
atlasCol(6, artist.Inset { 4, 4, 4, 4 })
|
||||||
// PatternHandle
|
// PatternHandle
|
||||||
atlasCol(7, artist.Inset { 6, 6, 6, 6 }) // broken
|
atlasCol(7, artist.Inset { 6, 6, 6, 6 })
|
||||||
|
// PatternLine
|
||||||
|
atlasCol(8, artist.Inset { 1, 1, 1, 1 })
|
||||||
|
|
||||||
|
// PatternButton: basic.checkbox
|
||||||
|
atlasCol(9, artist.Inset { 3, 3, 3, 3 })
|
||||||
|
// PatternRaised: basic.listEntry
|
||||||
|
atlasCol(10, artist.Inset { 3, 3, 3, 3 })
|
||||||
|
// PatternRaised: fun.flatKey
|
||||||
|
atlasCol(11, artist.Inset { 3, 3, 5, 3 })
|
||||||
|
// PatternRaised: fun.sharpKey
|
||||||
|
atlasCol(12, artist.Inset { 3, 3, 4, 3 })
|
||||||
}
|
}
|
||||||
|
|
||||||
// Default is the default theme.
|
// Default is the default theme.
|
||||||
@ -93,13 +104,25 @@ func (Default) Pattern (id Pattern, state State, c Case) artist.Pattern {
|
|||||||
switch id {
|
switch id {
|
||||||
case PatternBackground: return patterns.Uhex(0xaaaaaaFF)
|
case PatternBackground: return patterns.Uhex(0xaaaaaaFF)
|
||||||
case PatternDead: return defaultTextures[0][offset]
|
case PatternDead: return defaultTextures[0][offset]
|
||||||
case PatternRaised: return defaultTextures[1][offset]
|
case PatternRaised:
|
||||||
|
if c == C("basic", "listEntry") {
|
||||||
|
return defaultTextures[10][offset]
|
||||||
|
} else {
|
||||||
|
return defaultTextures[1][offset]
|
||||||
|
}
|
||||||
case PatternSunken: return defaultTextures[2][offset]
|
case PatternSunken: return defaultTextures[2][offset]
|
||||||
case PatternPinboard: return defaultTextures[3][offset]
|
case PatternPinboard: return defaultTextures[3][offset]
|
||||||
case PatternButton: return defaultTextures[4][offset]
|
case PatternButton:
|
||||||
|
switch c {
|
||||||
|
case C("basic", "checkbox"): return defaultTextures[9][offset]
|
||||||
|
case C("fun", "flatKey"): return defaultTextures[11][offset]
|
||||||
|
case C("fun", "sharpKey"): return defaultTextures[12][offset]
|
||||||
|
default: return defaultTextures[4][offset]
|
||||||
|
}
|
||||||
case PatternInput: return defaultTextures[5][offset]
|
case PatternInput: return defaultTextures[5][offset]
|
||||||
case PatternGutter: return defaultTextures[6][offset]
|
case PatternGutter: return defaultTextures[6][offset]
|
||||||
case PatternHandle: return defaultTextures[7][offset]
|
case PatternHandle: return defaultTextures[7][offset]
|
||||||
|
case PatternLine: return defaultTextures[8][offset]
|
||||||
default: return patterns.Uhex(0xFF00FFFF)
|
default: return patterns.Uhex(0xFF00FFFF)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -119,13 +142,26 @@ func (Default) Color (id Color, state State, c Case) color.RGBA {
|
|||||||
// Padding returns the default padding value for the given pattern.
|
// Padding returns the default padding value for the given pattern.
|
||||||
func (Default) Padding (id Pattern, c Case) artist.Inset {
|
func (Default) Padding (id Pattern, c Case) artist.Inset {
|
||||||
switch id {
|
switch id {
|
||||||
|
case PatternRaised:
|
||||||
|
if c == C("basic", "listEntry") {
|
||||||
|
return artist.Inset { 4, 4, 4, 4 }
|
||||||
|
} else {
|
||||||
|
return artist.Inset { 8, 8, 8, 8 }
|
||||||
|
}
|
||||||
case PatternSunken:
|
case PatternSunken:
|
||||||
if c == C("basic", "list") {
|
if c == C("basic", "list") {
|
||||||
|
return artist.Inset { 3, 3, 3, 3 }
|
||||||
|
} else {
|
||||||
|
return artist.Inset { 8, 8, 8, 8 }
|
||||||
|
}
|
||||||
|
case PatternPinboard:
|
||||||
|
if c == C("fun", "piano") {
|
||||||
return artist.Inset { 2, 2, 2, 2 }
|
return artist.Inset { 2, 2, 2, 2 }
|
||||||
} else {
|
} else {
|
||||||
return artist.Inset { 8, 8, 8, 8 }
|
return artist.Inset { 8, 8, 8, 8 }
|
||||||
}
|
}
|
||||||
case PatternGutter: return artist.Inset { }
|
case PatternGutter: return artist.Inset { }
|
||||||
|
case PatternLine: return artist.Inset { 1, 1, 1, 1 }
|
||||||
default: return artist.Inset { 8, 8, 8, 8 }
|
default: return artist.Inset { 8, 8, 8, 8 }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -47,6 +47,9 @@ type Pattern int; const (
|
|||||||
|
|
||||||
// PatternHandle is a handle that slides along a gutter.
|
// PatternHandle is a handle that slides along a gutter.
|
||||||
PatternHandle
|
PatternHandle
|
||||||
|
|
||||||
|
// PatternLine is an engraved line that separates things.
|
||||||
|
PatternLine
|
||||||
)
|
)
|
||||||
|
|
||||||
type Color int; const (
|
type Color int; const (
|
||||||
|
Reference in New Issue
Block a user