Elements are no longer images

This commit is contained in:
2023-02-13 01:49:33 -05:00
parent 7f0462d588
commit 8ac5108211
18 changed files with 117 additions and 112 deletions

View File

@@ -143,7 +143,7 @@ func (element *Button) draw () {
pattern := element.theme.Pattern(theme.PatternButton, state)
artist.FillRectangle(element, pattern, bounds)
artist.FillRectangle(element.core, pattern, bounds)
textBounds := element.drawer.LayoutBounds()
offset := image.Point {
@@ -161,5 +161,5 @@ func (element *Button) draw () {
}
foreground := element.theme.Pattern(theme.PatternForeground, state)
element.drawer.Draw(element, foreground, offset)
element.drawer.Draw(element.core, foreground, offset)
}

View File

@@ -171,10 +171,10 @@ func (element *Checkbox) draw () {
backgroundPattern := element.theme.Pattern (
theme.PatternBackground, state)
artist.FillRectangle(element, backgroundPattern, bounds)
artist.FillRectangle(element.core, backgroundPattern, bounds)
pattern := element.theme.Pattern(theme.PatternButton, state)
artist.FillRectangle(element, pattern, boxBounds)
artist.FillRectangle(element.core, pattern, boxBounds)
textBounds := element.drawer.LayoutBounds()
offset := bounds.Min.Add(image.Point {
@@ -185,5 +185,5 @@ func (element *Checkbox) draw () {
offset.X -= textBounds.Min.X
foreground := element.theme.Pattern(theme.PatternForeground, state)
element.drawer.Draw(element, foreground, offset)
element.drawer.Draw(element.core, foreground, offset)
}

View File

@@ -230,12 +230,12 @@ func (element *Container) redoAll () {
theme.PatternBackground,
theme.PatternState { })
for _, tile := range tiles {
artist.FillRectangle(element, pattern, tile)
artist.FillRectangle(element.core, pattern, tile)
}
// cut our canvas up and give peices to child elements
for _, entry := range element.children {
entry.DrawTo(canvas.Cut(element, entry.Bounds))
entry.DrawTo(canvas.Cut(element.core, entry.Bounds))
}
}

View File

@@ -19,5 +19,5 @@ func NewImage (image image.Image) (element *Image) {
}
func (element *Image) draw () {
artist.FillRectangle(element, element.buffer, element.Bounds())
artist.FillRectangle(element.core, element.buffer, element.Bounds())
}

View File

@@ -154,12 +154,12 @@ func (element *Label) draw () {
pattern := element.theme.Pattern (
theme.PatternBackground,
theme.PatternState { })
artist.FillRectangle(element, pattern, bounds)
artist.FillRectangle(element.core, pattern, bounds)
textBounds := element.drawer.LayoutBounds()
foreground := element.theme.Pattern (
theme.PatternForeground,
theme.PatternState { })
element.drawer.Draw(element, foreground, bounds.Min.Sub(textBounds.Min))
element.drawer.Draw(element.core, foreground, bounds.Min.Sub(textBounds.Min))
}

View File

@@ -439,14 +439,14 @@ func (element *List) draw () {
Disabled: !element.Enabled(),
Focused: element.Focused(),
})
artist.FillRectangle(element, pattern, bounds)
artist.FillRectangle(element.core, pattern, bounds)
bounds = inset.Apply(bounds)
dot := image.Point {
bounds.Min.X,
bounds.Min.Y - element.scroll,
}
innerCanvas := canvas.Cut(element, bounds)
innerCanvas := canvas.Cut(element.core, bounds)
for index, entry := range element.entries {
entryPosition := dot
dot.Y += entry.Bounds().Dy()

View File

@@ -71,7 +71,7 @@ func (element *ProgressBar) draw () {
theme.PatternSunken,
theme.PatternState { })
inset := element.theme.Inset(theme.PatternSunken)
artist.FillRectangle(element, pattern, bounds)
artist.FillRectangle(element.core, pattern, bounds)
bounds = inset.Apply(bounds)
meterBounds := image.Rect (
bounds.Min.X, bounds.Min.Y,
@@ -80,5 +80,5 @@ func (element *ProgressBar) draw () {
accent := element.theme.Pattern (
theme.PatternAccent,
theme.PatternState { })
artist.FillRectangle(element, accent, meterBounds)
artist.FillRectangle(element.core, accent, meterBounds)
}

View File

@@ -302,7 +302,7 @@ func (element *ScrollContainer) OnFocusMotionRequest (
}
func (element *ScrollContainer) childDamageCallback (region canvas.Canvas) {
element.core.DamageRegion(artist.Paste(element, region, image.Point { }))
element.core.DamageRegion(artist.Paste(element.core, region, image.Point { }))
}
func (element *ScrollContainer) childFocusRequestCallback () (granted bool) {
@@ -345,7 +345,7 @@ func (element *ScrollContainer) resizeChildToFit () {
0, 0,
element.childWidth,
element.childHeight).Add(element.Bounds().Min)
element.child.DrawTo(canvas.Cut(element, childBounds))
element.child.DrawTo(canvas.Cut(element.core, childBounds))
}
func (element *ScrollContainer) recalculate () {
@@ -437,11 +437,10 @@ func (element *ScrollContainer) recalculate () {
}
func (element *ScrollContainer) draw () {
artist.Paste(element, element.child, image.Point { })
deadPattern := element.theme.Pattern (
theme.PatternDead, theme.PatternState { })
artist.FillRectangle (
element, deadPattern,
element.core, deadPattern,
image.Rect (
element.vertical.gutter.Min.X,
element.horizontal.gutter.Min.Y,
@@ -457,10 +456,10 @@ func (element *ScrollContainer) drawHorizontalBar () {
Pressed: element.horizontal.dragging,
}
gutterPattern := element.horizontal.theme.Pattern(theme.PatternGutter, state)
artist.FillRectangle(element, gutterPattern, element.horizontal.gutter)
artist.FillRectangle(element.core, gutterPattern, element.horizontal.gutter)
handlePattern := element.horizontal.theme.Pattern(theme.PatternHandle, state)
artist.FillRectangle(element, handlePattern, element.horizontal.bar)
artist.FillRectangle(element.core, handlePattern, element.horizontal.bar)
}
func (element *ScrollContainer) drawVerticalBar () {
@@ -469,10 +468,10 @@ func (element *ScrollContainer) drawVerticalBar () {
Pressed: element.vertical.dragging,
}
gutterPattern := element.vertical.theme.Pattern(theme.PatternGutter, state)
artist.FillRectangle(element, gutterPattern, element.vertical.gutter)
artist.FillRectangle(element.core, gutterPattern, element.vertical.gutter)
handlePattern := element.vertical.theme.Pattern(theme.PatternHandle, state)
artist.FillRectangle(element, handlePattern, element.vertical.bar)
artist.FillRectangle(element.core, handlePattern, element.vertical.bar)
}
func (element *ScrollContainer) dragHorizontalBar (mousePosition image.Point) {

View File

@@ -196,11 +196,11 @@ func (element *Slider) draw () {
Pressed: element.dragging,
}
artist.FillRectangle (
element,
element.core,
element.theme.Pattern(theme.PatternGutter, state),
bounds)
artist.FillRectangle (
element,
element.core,
element.theme.Pattern(theme.PatternHandle, state),
element.bar)
}

View File

@@ -64,11 +64,11 @@ func (element *Spacer) draw () {
pattern := element.theme.Pattern (
theme.PatternForeground,
theme.PatternState { })
artist.FillRectangle(element, pattern, bounds)
artist.FillRectangle(element.core, pattern, bounds)
} else {
pattern := element.theme.Pattern (
theme.PatternBackground,
theme.PatternState { })
artist.FillRectangle(element, pattern, bounds)
artist.FillRectangle(element.core, pattern, bounds)
}
}

View File

@@ -166,7 +166,7 @@ func (element *Switch) draw () {
}
backgroundPattern := element.theme.Pattern (
theme.PatternBackground, state)
artist.FillRectangle (element, backgroundPattern, bounds)
artist.FillRectangle (element.core, backgroundPattern, bounds)
if element.checked {
handleBounds.Min.X += bounds.Dy()
@@ -184,11 +184,11 @@ func (element *Switch) draw () {
gutterPattern := element.theme.Pattern (
theme.PatternGutter, state)
artist.FillRectangle(element, gutterPattern, gutterBounds)
artist.FillRectangle(element.core, gutterPattern, gutterBounds)
handlePattern := element.theme.Pattern (
theme.PatternHandle, state)
artist.FillRectangle(element, handlePattern, handleBounds)
artist.FillRectangle(element.core, handlePattern, handleBounds)
textBounds := element.drawer.LayoutBounds()
offset := bounds.Min.Add(image.Point {
@@ -200,5 +200,5 @@ func (element *Switch) draw () {
foreground := element.theme.Pattern (
theme.PatternForeground, state)
element.drawer.Draw(element, foreground, offset)
element.drawer.Draw(element.core, foreground, offset)
}

View File

@@ -296,7 +296,7 @@ func (element *TextBox) draw () {
Focused: element.Focused(),
}
pattern := element.theme.Pattern(theme.PatternSunken, state)
artist.FillRectangle(element, pattern, bounds)
artist.FillRectangle(element.core, pattern, bounds)
if len(element.text) == 0 && !element.Focused() {
// draw placeholder
@@ -309,7 +309,7 @@ func (element *TextBox) draw () {
theme.PatternForeground,
theme.PatternState { Disabled: true })
element.placeholderDrawer.Draw (
element,
element.core,
foreground,
offset.Sub(textBounds.Min))
} else {
@@ -322,7 +322,7 @@ func (element *TextBox) draw () {
foreground := element.theme.Pattern (
theme.PatternForeground, state)
element.valueDrawer.Draw (
element,
element.core,
foreground,
offset.Sub(textBounds.Min))
@@ -331,7 +331,7 @@ func (element *TextBox) draw () {
cursorPosition := element.valueDrawer.PositionOf (
element.cursor)
artist.Line (
element,
element.core,
foreground, 1,
cursorPosition.Add(offset),
image.Pt (