Fixed wierd inconsistency with element core
This commit is contained in:
@@ -121,7 +121,7 @@ func (element *Button) SetText (text string) {
|
||||
}
|
||||
|
||||
func (element *Button) draw () {
|
||||
bounds := element.core.Bounds()
|
||||
bounds := element.Bounds()
|
||||
|
||||
pattern, inset := theme.ButtonPattern(theme.PatternState {
|
||||
Case: buttonCase,
|
||||
@@ -130,7 +130,7 @@ func (element *Button) draw () {
|
||||
Pressed: element.pressed,
|
||||
})
|
||||
|
||||
artist.FillRectangle(element.core, pattern, bounds)
|
||||
artist.FillRectangle(element, pattern, bounds)
|
||||
|
||||
innerBounds := inset.Apply(bounds)
|
||||
|
||||
@@ -149,5 +149,5 @@ func (element *Button) draw () {
|
||||
Case: buttonCase,
|
||||
Disabled: !element.Enabled(),
|
||||
})
|
||||
element.drawer.Draw(element.core, foreground, offset)
|
||||
element.drawer.Draw(element, foreground, offset)
|
||||
}
|
||||
|
||||
@@ -133,13 +133,13 @@ func (element *Checkbox) SetText (text string) {
|
||||
}
|
||||
|
||||
func (element *Checkbox) draw () {
|
||||
bounds := element.core.Bounds()
|
||||
bounds := element.Bounds()
|
||||
boxBounds := image.Rect(0, 0, bounds.Dy(), bounds.Dy())
|
||||
|
||||
backgroundPattern, _ := theme.BackgroundPattern(theme.PatternState {
|
||||
Case: checkboxCase,
|
||||
})
|
||||
artist.FillRectangle ( element.core, backgroundPattern, bounds)
|
||||
artist.FillRectangle(element, backgroundPattern, bounds)
|
||||
|
||||
pattern, inset := theme.ButtonPattern(theme.PatternState {
|
||||
Case: checkboxCase,
|
||||
@@ -147,7 +147,7 @@ func (element *Checkbox) draw () {
|
||||
Focused: element.Focused(),
|
||||
Pressed: element.pressed,
|
||||
})
|
||||
artist.FillRectangle(element.core, pattern, boxBounds)
|
||||
artist.FillRectangle(element, pattern, boxBounds)
|
||||
|
||||
textBounds := element.drawer.LayoutBounds()
|
||||
offset := image.Point {
|
||||
@@ -161,10 +161,10 @@ func (element *Checkbox) draw () {
|
||||
Case: checkboxCase,
|
||||
Disabled: !element.Enabled(),
|
||||
})
|
||||
element.drawer.Draw(element.core, foreground, offset)
|
||||
element.drawer.Draw(element, foreground, offset)
|
||||
|
||||
if element.checked {
|
||||
checkBounds := inset.Apply(boxBounds).Inset(2)
|
||||
artist.FillRectangle(element.core, foreground, checkBounds)
|
||||
artist.FillRectangle(element, foreground, checkBounds)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -201,11 +201,11 @@ func (element *Container) redoAll () {
|
||||
element.recalculate()
|
||||
|
||||
// draw a background
|
||||
bounds := element.core.Bounds()
|
||||
bounds := element.Bounds()
|
||||
pattern, _ := theme.BackgroundPattern (theme.PatternState {
|
||||
Case: containerCase,
|
||||
})
|
||||
artist.FillRectangle(element.core, pattern, bounds)
|
||||
artist.FillRectangle(element, pattern, bounds)
|
||||
|
||||
// resize all elements, having them draw onto us
|
||||
for _, entry := range element.children {
|
||||
|
||||
@@ -107,19 +107,19 @@ func (element *Label) updateMinimumSize () {
|
||||
}
|
||||
|
||||
func (element *Label) draw () {
|
||||
bounds := element.core.Bounds()
|
||||
bounds := element.Bounds()
|
||||
|
||||
pattern, _ := theme.BackgroundPattern(theme.PatternState {
|
||||
Case: labelCase,
|
||||
})
|
||||
artist.FillRectangle(element.core, pattern, bounds)
|
||||
artist.FillRectangle(element, pattern, bounds)
|
||||
|
||||
textBounds := element.drawer.LayoutBounds()
|
||||
|
||||
foreground, _ := theme.ForegroundPattern (theme.PatternState {
|
||||
Case: labelCase,
|
||||
})
|
||||
element.drawer.Draw (element.core, foreground, image.Point {
|
||||
element.drawer.Draw (element, foreground, image.Point {
|
||||
X: 0 - textBounds.Min.X,
|
||||
Y: 0 - textBounds.Min.Y,
|
||||
})
|
||||
|
||||
@@ -376,7 +376,7 @@ func (element *List) draw () {
|
||||
Disabled: !element.Enabled(),
|
||||
Focused: element.Focused(),
|
||||
})
|
||||
artist.FillRectangle(element.core, pattern, bounds)
|
||||
artist.FillRectangle(element, pattern, bounds)
|
||||
|
||||
bounds = inset.Apply(bounds)
|
||||
dot := image.Point {
|
||||
|
||||
@@ -32,15 +32,15 @@ func (element *ProgressBar) SetProgress (progress float64) {
|
||||
}
|
||||
|
||||
func (element *ProgressBar) draw () {
|
||||
bounds := element.core.Bounds()
|
||||
bounds := element.Bounds()
|
||||
|
||||
pattern, inset := theme.SunkenPattern(theme.PatternState { })
|
||||
artist.FillRectangle(element.core, pattern, bounds)
|
||||
artist.FillRectangle(element, pattern, bounds)
|
||||
bounds = inset.Apply(bounds)
|
||||
meterBounds := image.Rect (
|
||||
bounds.Min.X, bounds.Min.Y,
|
||||
bounds.Min.X + int(float64(bounds.Dx()) * element.progress),
|
||||
bounds.Max.Y)
|
||||
accent, _ := theme.AccentPattern(theme.PatternState { })
|
||||
artist.FillRectangle(element.core, accent, meterBounds)
|
||||
artist.FillRectangle(element, accent, meterBounds)
|
||||
}
|
||||
|
||||
@@ -358,7 +358,7 @@ func (element *ScrollContainer) recalculate () {
|
||||
}
|
||||
|
||||
func (element *ScrollContainer) draw () {
|
||||
artist.Paste(element.core, element.child, image.Point { })
|
||||
artist.Paste(element, element.child, image.Point { })
|
||||
deadPattern, _ := theme.DeadPattern(theme.PatternState {
|
||||
Case: scrollContainerCase,
|
||||
})
|
||||
|
||||
@@ -34,19 +34,19 @@ func (element *Spacer) SetLine (line bool) {
|
||||
}
|
||||
|
||||
func (element *Spacer) draw () {
|
||||
bounds := element.core.Bounds()
|
||||
bounds := element.Bounds()
|
||||
|
||||
if element.line {
|
||||
pattern, _ := theme.ForegroundPattern(theme.PatternState {
|
||||
Case: spacerCase,
|
||||
Disabled: true,
|
||||
})
|
||||
artist.FillRectangle(element.core, pattern, bounds)
|
||||
artist.FillRectangle(element, pattern, bounds)
|
||||
} else {
|
||||
pattern, _ := theme.BackgroundPattern(theme.PatternState {
|
||||
Case: spacerCase,
|
||||
Disabled: true,
|
||||
})
|
||||
artist.FillRectangle(element.core, pattern, bounds)
|
||||
artist.FillRectangle(element, pattern, bounds)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -140,13 +140,13 @@ func (element *Switch) calculateMinimumSize () {
|
||||
}
|
||||
|
||||
func (element *Switch) draw () {
|
||||
bounds := element.core.Bounds()
|
||||
bounds := element.Bounds()
|
||||
handleBounds := image.Rect(0, 0, bounds.Dy(), bounds.Dy())
|
||||
gutterBounds := image.Rect(0, 0, bounds.Dy() * 2, bounds.Dy())
|
||||
backgroundPattern, _ := theme.BackgroundPattern(theme.PatternState {
|
||||
Case: switchCase,
|
||||
})
|
||||
artist.FillRectangle ( element.core, backgroundPattern, bounds)
|
||||
artist.FillRectangle (element, backgroundPattern, bounds)
|
||||
|
||||
if element.checked {
|
||||
handleBounds.Min.X += bounds.Dy()
|
||||
@@ -168,7 +168,7 @@ func (element *Switch) draw () {
|
||||
Focused: element.Focused(),
|
||||
Pressed: element.pressed,
|
||||
})
|
||||
artist.FillRectangle(element.core, gutterPattern, gutterBounds)
|
||||
artist.FillRectangle(element, gutterPattern, gutterBounds)
|
||||
|
||||
handlePattern, _ := theme.HandlePattern(theme.PatternState {
|
||||
Case: switchCase,
|
||||
@@ -176,7 +176,7 @@ func (element *Switch) draw () {
|
||||
Focused: element.Focused(),
|
||||
Pressed: element.pressed,
|
||||
})
|
||||
artist.FillRectangle(element.core, handlePattern, handleBounds)
|
||||
artist.FillRectangle(element, handlePattern, handleBounds)
|
||||
|
||||
textBounds := element.drawer.LayoutBounds()
|
||||
offset := image.Point {
|
||||
@@ -190,5 +190,5 @@ func (element *Switch) draw () {
|
||||
Case: switchCase,
|
||||
Disabled: !element.Enabled(),
|
||||
})
|
||||
element.drawer.Draw(element.core, foreground, offset)
|
||||
element.drawer.Draw(element, foreground, offset)
|
||||
}
|
||||
|
||||
@@ -257,7 +257,7 @@ func (element *TextBox) runOnChange () {
|
||||
func (element *TextBox) scrollToCursor () {
|
||||
if !element.core.HasImage() { return }
|
||||
|
||||
bounds := element.core.Bounds().Inset(theme.Padding())
|
||||
bounds := element.Bounds().Inset(theme.Padding())
|
||||
bounds.Max.X -= element.valueDrawer.Em().Round()
|
||||
cursorPosition := element.valueDrawer.PositionOf(element.cursor)
|
||||
cursorPosition.X -= element.scroll
|
||||
@@ -272,7 +272,7 @@ func (element *TextBox) scrollToCursor () {
|
||||
}
|
||||
|
||||
func (element *TextBox) draw () {
|
||||
bounds := element.core.Bounds()
|
||||
bounds := element.Bounds()
|
||||
|
||||
// FIXME: take index into account
|
||||
pattern, inset := theme.InputPattern(theme.PatternState {
|
||||
@@ -280,7 +280,7 @@ func (element *TextBox) draw () {
|
||||
Disabled: !element.Enabled(),
|
||||
Focused: element.Focused(),
|
||||
})
|
||||
artist.FillRectangle(element.core, pattern, bounds)
|
||||
artist.FillRectangle(element, pattern, bounds)
|
||||
|
||||
if len(element.text) == 0 && !element.Focused() {
|
||||
// draw placeholder
|
||||
@@ -294,7 +294,7 @@ func (element *TextBox) draw () {
|
||||
Disabled: true,
|
||||
})
|
||||
element.placeholderDrawer.Draw (
|
||||
element.core,
|
||||
element,
|
||||
foreground,
|
||||
offset.Sub(textBounds.Min))
|
||||
} else {
|
||||
@@ -309,7 +309,7 @@ func (element *TextBox) draw () {
|
||||
Disabled: !element.Enabled(),
|
||||
})
|
||||
element.valueDrawer.Draw (
|
||||
element.core,
|
||||
element,
|
||||
foreground,
|
||||
offset.Sub(textBounds.Min))
|
||||
|
||||
@@ -321,7 +321,7 @@ func (element *TextBox) draw () {
|
||||
Case: textBoxCase,
|
||||
})
|
||||
artist.Line (
|
||||
element.core,
|
||||
element,
|
||||
foreground, 1,
|
||||
cursorPosition.Add(offset),
|
||||
image.Pt (
|
||||
|
||||
Reference in New Issue
Block a user