Removed a bunch of redundant draw calls

Most were related to a but with the keynav api
This commit is contained in:
2023-02-09 01:30:14 -05:00
parent ce20b7d02c
commit 16a0e76145
5 changed files with 37 additions and 20 deletions

View File

@@ -1,6 +1,7 @@
package basicElements
import "image"
// import "runtime/debug"
import "git.tebibyte.media/sashakoshka/tomo/input"
import "git.tebibyte.media/sashakoshka/tomo/theme"
import "git.tebibyte.media/sashakoshka/tomo/config"
@@ -36,7 +37,7 @@ func NewButton (text string) (element *Button) {
}
func (element *Button) HandleMouseDown (x, y int, button input.Button) {
if !element.Enabled() { return }
if !element.Enabled() { return }
if !element.Focused() { element.Focus() }
if button != input.ButtonLeft { return }
element.pressed = true
@@ -45,16 +46,15 @@ func (element *Button) HandleMouseDown (x, y int, button input.Button) {
func (element *Button) HandleMouseUp (x, y int, button input.Button) {
if button != input.ButtonLeft { return }
// println("handling mouse up")
element.pressed = false
element.redo()
within := image.Point { x, y }.
In(element.Bounds())
if !element.Enabled() { return }
if within && element.onClick != nil {
if element.Enabled() && within && element.onClick != nil {
element.onClick()
}
element.redo()
// println("done handling mouse up")
}
func (element *Button) HandleMouseMove (x, y int) { }
@@ -133,6 +133,8 @@ func (element *Button) redo () {
func (element *Button) draw () {
bounds := element.Bounds()
// println(bounds.String(), element.text)
// debug.PrintStack()
state := theme.PatternState {
Disabled: !element.Enabled(),

View File

@@ -64,7 +64,10 @@ func (element *Container) Adopt (child elements.Element, expand bool) {
child.OnDamage (func (region canvas.Canvas) {
element.core.DamageRegion(region.Bounds())
})
child.OnMinimumSizeChange(element.updateMinimumSize)
child.OnMinimumSizeChange (func () {
element.updateMinimumSize()
element.redoAll()
})
if child0, ok := child.(elements.Flexible); ok {
child0.OnFlexibleHeightChange(element.updateMinimumSize)
}
@@ -209,6 +212,7 @@ func (element *Container) childPosition (child elements.Element) (position image
}
func (element *Container) redoAll () {
if !element.core.HasImage() { return }
// do a layout
element.recalculate()
@@ -496,7 +500,6 @@ func (element *Container) childFocusRequestCallback (
child.HandleUnfocus()
return true
})
child.HandleFocus(input.KeynavDirectionNeutral)
return true
} else {
return false