Basic and fun elements conform to new API change
This commit is contained in:
parent
d31aee1ba8
commit
92e5822185
@ -176,7 +176,7 @@ func (element *Checkbox) draw () {
|
||||
backgroundPattern.Draw(element.core, bounds)
|
||||
|
||||
pattern := element.theme.Pattern(theme.PatternButton, state)
|
||||
artist.DrawBounds(element.core, pattern, boxBounds)
|
||||
pattern.Draw(element.core, boxBounds)
|
||||
|
||||
textBounds := element.drawer.LayoutBounds()
|
||||
margin := element.theme.Margin(theme.PatternBackground)
|
||||
|
@ -138,7 +138,7 @@ func (element *Container) Disown (child elements.Element) {
|
||||
}
|
||||
|
||||
func (element *Container) clearChildEventHandlers (child elements.Element) {
|
||||
child.DrawTo(nil)
|
||||
child.DrawTo(nil, image.Rectangle { })
|
||||
child.OnDamage(nil)
|
||||
child.OnMinimumSizeChange(nil)
|
||||
if child0, ok := child.(elements.Focusable); ok {
|
||||
@ -203,7 +203,7 @@ func (element *Container) redoAll () {
|
||||
// remove child canvasses so that any operations done in here will not
|
||||
// cause a child to draw to a wack ass canvas.
|
||||
for _, entry := range element.children {
|
||||
entry.DrawTo(nil)
|
||||
entry.DrawTo(nil, entry.Bounds)
|
||||
}
|
||||
|
||||
// do a layout
|
||||
@ -217,12 +217,13 @@ func (element *Container) redoAll () {
|
||||
pattern := element.theme.Pattern (
|
||||
theme.PatternBackground,
|
||||
theme.State { })
|
||||
artist.DrawShatter (
|
||||
element.core, pattern, rocks...)
|
||||
artist.DrawShatter(element.core, pattern, element.Bounds(), rocks...)
|
||||
|
||||
// cut our canvas up and give peices to child elements
|
||||
for _, entry := range element.children {
|
||||
entry.DrawTo(canvas.Cut(element.core, entry.Bounds))
|
||||
entry.DrawTo (
|
||||
canvas.Cut(element.core, entry.Bounds),
|
||||
entry.Bounds)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -123,7 +123,7 @@ func (element *DocumentContainer) Disown (child elements.Element) {
|
||||
}
|
||||
|
||||
func (element *DocumentContainer) clearChildEventHandlers (child elements.Element) {
|
||||
child.DrawTo(nil)
|
||||
child.DrawTo(nil, image.Rectangle { })
|
||||
child.OnDamage(nil)
|
||||
child.OnMinimumSizeChange(nil)
|
||||
if child0, ok := child.(elements.Focusable); ok {
|
||||
@ -201,8 +201,7 @@ func (element *DocumentContainer) redoAll () {
|
||||
pattern := element.theme.Pattern (
|
||||
theme.PatternBackground,
|
||||
theme.State { })
|
||||
artist.DrawShatter (
|
||||
element.core, pattern, rocks...)
|
||||
artist.DrawShatter(element.core, pattern, element.Bounds(), rocks...)
|
||||
|
||||
element.partition()
|
||||
if element.onScrollBoundsChange != nil {
|
||||
@ -212,13 +211,15 @@ func (element *DocumentContainer) redoAll () {
|
||||
|
||||
func (element *DocumentContainer) partition () {
|
||||
for _, entry := range element.children {
|
||||
entry.DrawTo(nil)
|
||||
entry.DrawTo(nil, entry.Bounds)
|
||||
}
|
||||
|
||||
// cut our canvas up and give peices to child elements
|
||||
for _, entry := range element.children {
|
||||
if entry.Bounds.Overlaps(element.Bounds()) {
|
||||
entry.DrawTo(canvas.Cut(element.core, entry.Bounds))
|
||||
entry.DrawTo (
|
||||
canvas.Cut(element.core, entry.Bounds),
|
||||
entry.Bounds)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -70,7 +70,7 @@ func (entry *ListEntry) Draw (
|
||||
pattern := entry.theme.Pattern(theme.PatternRaised, state)
|
||||
padding := entry.theme.Padding(theme.PatternRaised)
|
||||
bounds := entry.Bounds().Add(offset)
|
||||
artist.DrawBounds(destination, pattern, bounds)
|
||||
pattern.Draw(destination, bounds)
|
||||
|
||||
foreground := entry.theme.Color (theme.ColorForeground, state)
|
||||
return entry.drawer.Draw (
|
||||
|
@ -78,5 +78,5 @@ func (element *ProgressBar) draw () {
|
||||
bounds.Min.X + int(float64(bounds.Dx()) * element.progress),
|
||||
bounds.Max.Y)
|
||||
mercury := element.theme.Pattern(theme.PatternMercury, theme.State { })
|
||||
artist.DrawBounds(element.core, mercury, meterBounds)
|
||||
mercury.Draw(element.core, meterBounds)
|
||||
}
|
||||
|
@ -315,12 +315,10 @@ func (element *ScrollBar) draw () {
|
||||
Disabled: !element.Enabled(),
|
||||
Pressed: element.dragging,
|
||||
}
|
||||
artist.DrawBounds (
|
||||
element.theme.Pattern(theme.PatternGutter, state).Draw (
|
||||
element.core,
|
||||
element.theme.Pattern(theme.PatternGutter, state),
|
||||
bounds)
|
||||
artist.DrawBounds (
|
||||
element.theme.Pattern(theme.PatternHandle, state).Draw (
|
||||
element.core,
|
||||
element.theme.Pattern(theme.PatternHandle, state),
|
||||
element.bar)
|
||||
}
|
||||
|
@ -120,7 +120,7 @@ func (element *ScrollContainer) setChildEventHandlers (child elements.Element) {
|
||||
}
|
||||
|
||||
func (element *ScrollContainer) clearChildEventHandlers (child elements.Scrollable) {
|
||||
child.DrawTo(nil)
|
||||
child.DrawTo(nil, image.Rectangle { })
|
||||
child.OnDamage(nil)
|
||||
child.OnMinimumSizeChange(nil)
|
||||
child.OnScrollBoundsChange(nil)
|
||||
@ -198,19 +198,26 @@ func (element *ScrollContainer) Child (index int) (child elements.Element) {
|
||||
func (element *ScrollContainer) redoAll () {
|
||||
if !element.core.HasImage() { return }
|
||||
|
||||
if element.child != nil { element.child.DrawTo(nil) }
|
||||
if element.horizontal != nil { element.horizontal.DrawTo(nil) }
|
||||
if element.vertical != nil { element.vertical.DrawTo(nil) }
|
||||
zr := image.Rectangle { }
|
||||
if element.child != nil { element.child.DrawTo(nil, zr) }
|
||||
if element.horizontal != nil { element.horizontal.DrawTo(nil, zr) }
|
||||
if element.vertical != nil { element.vertical.DrawTo(nil, zr) }
|
||||
|
||||
childBounds, horizontalBounds, verticalBounds := element.layout()
|
||||
if element.child != nil {
|
||||
element.child.DrawTo(canvas.Cut(element.core, childBounds))
|
||||
element.child.DrawTo (
|
||||
canvas.Cut(element.core, childBounds),
|
||||
childBounds)
|
||||
}
|
||||
if element.horizontal != nil {
|
||||
element.horizontal.DrawTo(canvas.Cut(element.core, horizontalBounds))
|
||||
element.horizontal.DrawTo (
|
||||
canvas.Cut(element.core, horizontalBounds),
|
||||
horizontalBounds)
|
||||
}
|
||||
if element.vertical != nil {
|
||||
element.vertical.DrawTo(canvas.Cut(element.core, verticalBounds))
|
||||
element.vertical.DrawTo (
|
||||
canvas.Cut(element.core, verticalBounds),
|
||||
verticalBounds)
|
||||
}
|
||||
element.draw()
|
||||
}
|
||||
|
@ -4,7 +4,6 @@ import "image"
|
||||
import "git.tebibyte.media/sashakoshka/tomo/input"
|
||||
import "git.tebibyte.media/sashakoshka/tomo/theme"
|
||||
import "git.tebibyte.media/sashakoshka/tomo/config"
|
||||
import "git.tebibyte.media/sashakoshka/tomo/artist"
|
||||
import "git.tebibyte.media/sashakoshka/tomo/elements/core"
|
||||
|
||||
// Slider is a slider control with a floating point value between zero and one.
|
||||
@ -229,12 +228,10 @@ func (element *Slider) draw () {
|
||||
Disabled: !element.Enabled(),
|
||||
Pressed: element.dragging,
|
||||
}
|
||||
artist.DrawBounds (
|
||||
element.theme.Pattern(theme.PatternGutter, state).Draw (
|
||||
element.core,
|
||||
element.theme.Pattern(theme.PatternGutter, state),
|
||||
bounds)
|
||||
artist.DrawBounds (
|
||||
element.theme.Pattern(theme.PatternHandle, state).Draw (
|
||||
element.core,
|
||||
element.theme.Pattern(theme.PatternHandle, state),
|
||||
element.bar)
|
||||
}
|
||||
|
@ -4,7 +4,6 @@ import "image"
|
||||
import "git.tebibyte.media/sashakoshka/tomo/input"
|
||||
import "git.tebibyte.media/sashakoshka/tomo/theme"
|
||||
import "git.tebibyte.media/sashakoshka/tomo/config"
|
||||
import "git.tebibyte.media/sashakoshka/tomo/artist"
|
||||
import "git.tebibyte.media/sashakoshka/tomo/textdraw"
|
||||
import "git.tebibyte.media/sashakoshka/tomo/elements/core"
|
||||
|
||||
@ -185,11 +184,11 @@ func (element *Switch) draw () {
|
||||
|
||||
gutterPattern := element.theme.Pattern (
|
||||
theme.PatternGutter, state)
|
||||
artist.DrawBounds(element.core, gutterPattern, gutterBounds)
|
||||
gutterPattern.Draw(element.core, gutterBounds)
|
||||
|
||||
handlePattern := element.theme.Pattern (
|
||||
theme.PatternHandle, state)
|
||||
artist.DrawBounds(element.core, handlePattern, handleBounds)
|
||||
handlePattern.Draw(element.core, handleBounds)
|
||||
|
||||
textBounds := element.drawer.LayoutBounds()
|
||||
offset := bounds.Min.Add(image.Point {
|
||||
|
@ -316,7 +316,7 @@ func (element *Piano) drawFlat (
|
||||
state.Pressed = pressed
|
||||
pattern := element.theme.Theme.Pattern (
|
||||
theme.PatternButton, state, theme.C("fun", "flatKey"))
|
||||
artist.DrawBounds(element.core, pattern, bounds)
|
||||
pattern.Draw(element.core, bounds)
|
||||
}
|
||||
|
||||
func (element *Piano) drawSharp (
|
||||
@ -327,5 +327,5 @@ func (element *Piano) drawSharp (
|
||||
state.Pressed = pressed
|
||||
pattern := element.theme.Theme.Pattern (
|
||||
theme.PatternButton, state, theme.C("fun", "sharpKey"))
|
||||
artist.DrawBounds(element.core, pattern, bounds)
|
||||
pattern.Draw(element.core, bounds)
|
||||
}
|
||||
|
Reference in New Issue
Block a user