Use FillRectangleClip in List and Container
This commit is contained in:
parent
fa42cf1f5f
commit
09f782953e
@ -56,8 +56,8 @@ func FillRectangleClip (
|
|||||||
realBounds := bounds
|
realBounds := bounds
|
||||||
bounds =
|
bounds =
|
||||||
bounds.Canon().
|
bounds.Canon().
|
||||||
Intersect(destination.Bounds()).
|
Intersect(mask.Canon()).
|
||||||
Intersect(mask)
|
Intersect(destination.Bounds())
|
||||||
if bounds.Empty() { return }
|
if bounds.Empty() { return }
|
||||||
updatedRegion = bounds
|
updatedRegion = bounds
|
||||||
|
|
||||||
|
@ -230,7 +230,8 @@ func (element *Container) redoAll () {
|
|||||||
theme.PatternBackground,
|
theme.PatternBackground,
|
||||||
theme.PatternState { })
|
theme.PatternState { })
|
||||||
for _, tile := range tiles {
|
for _, tile := range tiles {
|
||||||
artist.FillRectangle(element.core, pattern, tile)
|
artist.FillRectangleClip (
|
||||||
|
element.core, pattern, element.Bounds(), tile)
|
||||||
}
|
}
|
||||||
|
|
||||||
// cut our canvas up and give peices to child elements
|
// cut our canvas up and give peices to child elements
|
||||||
|
@ -7,6 +7,7 @@ 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/canvas"
|
import "git.tebibyte.media/sashakoshka/tomo/canvas"
|
||||||
import "git.tebibyte.media/sashakoshka/tomo/artist"
|
import "git.tebibyte.media/sashakoshka/tomo/artist"
|
||||||
|
import "git.tebibyte.media/sashakoshka/tomo/shatter"
|
||||||
import "git.tebibyte.media/sashakoshka/tomo/elements/core"
|
import "git.tebibyte.media/sashakoshka/tomo/elements/core"
|
||||||
|
|
||||||
// List is an element that contains several objects that a user can select.
|
// List is an element that contains several objects that a user can select.
|
||||||
@ -432,28 +433,39 @@ func (element *List) updateMinimumSize () {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (element *List) draw () {
|
func (element *List) draw () {
|
||||||
bounds := element.Bounds()
|
bounds := element.Bounds()
|
||||||
|
inset := element.theme.Inset(theme.PatternSunken)
|
||||||
inset := element.theme.Inset(theme.PatternSunken)
|
innerBounds := inset.Apply(bounds)
|
||||||
pattern := element.theme.Pattern (theme.PatternSunken, theme.PatternState {
|
state := theme.PatternState {
|
||||||
Disabled: !element.Enabled(),
|
Disabled: !element.Enabled(),
|
||||||
Focused: element.Focused(),
|
Focused: element.Focused(),
|
||||||
})
|
|
||||||
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.core, bounds)
|
|
||||||
|
dot := image.Point {
|
||||||
|
innerBounds.Min.X,
|
||||||
|
innerBounds.Min.Y - element.scroll,
|
||||||
|
}
|
||||||
|
innerCanvas := canvas.Cut(element.core, innerBounds)
|
||||||
for index, entry := range element.entries {
|
for index, entry := range element.entries {
|
||||||
entryPosition := dot
|
entryPosition := dot
|
||||||
dot.Y += entry.Bounds().Dy()
|
dot.Y += entry.Bounds().Dy()
|
||||||
if dot.Y < bounds.Min.Y { continue }
|
if dot.Y < innerBounds.Min.Y { continue }
|
||||||
if entryPosition.Y > bounds.Max.Y { break }
|
if entryPosition.Y > innerBounds.Max.Y { break }
|
||||||
entry.Draw (
|
entry.Draw (
|
||||||
innerCanvas, entryPosition,
|
innerCanvas, entryPosition,
|
||||||
element.Focused(), element.selectedEntry == index)
|
element.Focused(), element.selectedEntry == index)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
covered := image.Rect (
|
||||||
|
0, 0,
|
||||||
|
innerBounds.Dx(), element.contentHeight,
|
||||||
|
).Add(innerBounds.Min).Intersect(innerBounds)
|
||||||
|
println(covered.String())
|
||||||
|
|
||||||
|
pattern := element.theme.Pattern(theme.PatternSunken, state)
|
||||||
|
tiles := shatter.Shatter(bounds, covered)
|
||||||
|
for _, tile := range tiles {
|
||||||
|
artist.FillRectangleClip (
|
||||||
|
element.core, pattern, bounds, tile)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -129,18 +129,20 @@ func (element *Artist) draw () {
|
|||||||
image.Rect(80, 30, 90, 45).Add(shatterPos),
|
image.Rect(80, 30, 90, 45).Add(shatterPos),
|
||||||
}
|
}
|
||||||
tiles := shatter.Shatter(element.cellAt(4, 3), rocks...)
|
tiles := shatter.Shatter(element.cellAt(4, 3), rocks...)
|
||||||
for index, tile := range tiles {
|
for _, tile := range tiles {
|
||||||
artist.FillRectangle (
|
artist.FillRectangle (
|
||||||
element.core, []artist.Pattern {
|
element.core,
|
||||||
uhex(0xFF0000FF),
|
artist.Bordered {
|
||||||
uhex(0x00FF00FF),
|
Fill: uhex(0x888888FF),
|
||||||
uhex(0x0000FFFF),
|
Stroke: artist.Stroke {
|
||||||
uhex(0xFF00FFFF),
|
Pattern: artist.Beveled {
|
||||||
uhex(0xFFF00FFF),
|
uhex(0xCCCCCCFF),
|
||||||
uhex(0xAAAAAAFF),
|
uhex(0x444444FF),
|
||||||
uhex(0x699669FF),
|
},
|
||||||
uhex(0x077777FF),
|
Weight: 1,
|
||||||
} [index % 8], tile)
|
},
|
||||||
|
},
|
||||||
|
tile)
|
||||||
}
|
}
|
||||||
|
|
||||||
// 0, 4 - 3, 4
|
// 0, 4 - 3, 4
|
||||||
|
Reference in New Issue
Block a user