Update code for objects

This commit is contained in:
2024-07-25 12:58:38 -04:00
parent 25a59d888c
commit 85fbe9c996
17 changed files with 247 additions and 163 deletions

View File

@@ -73,7 +73,7 @@ func NewScrollContainer (sides ScrollSide) *ScrollContainer {
this.OnKeyUp(this.handleKeyUp)
this.SetRole(tomo.R("objects", "ScrollContainer"))
this.SetTag(sides.String(), true)
this.SetLayout(layouts.NewGrid(true, false)(true, false))
this.SetAttr(tomo.ALayout(layouts.NewGrid(true, false)(true, false)))
return this
}
@@ -172,46 +172,46 @@ func (this *ScrollContainer) handleValueChange () {
this.on.valueChange.Broadcast()
}
func (this *ScrollContainer) handleScroll (catch func (), x, y float64) {
catch()
if this.root == nil { return }
this.scrollBy(image.Pt(int(x), int(y)))
}
func (this *ScrollContainer) scrollBy (vector image.Point) {
if this.root == nil { return }
if this.root == nil { return }
if vector == (image.Point { }) { return }
this.root.ScrollTo (
this.root.ContentBounds().Min.
Sub(vector))
}
func (this *ScrollContainer) handleKeyDown (catch func (), key input.Key, numpad bool) {
func (this *ScrollContainer) handleScroll (x, y float64) bool {
if this.root == nil { return false }
this.scrollBy(image.Pt(int(x), int(y)))
return true
}
func (this *ScrollContainer) handleKeyDown (key input.Key, numpad bool) bool {
modifiers := this.Window().Modifiers()
vector := image.Point { }
switch key {
case input.KeyPageUp:
catch()
if modifiers.Shift {
vector.X -= this.PageSize().X
} else {
vector.Y -= this.PageSize().Y
}
return true
case input.KeyPageDown:
catch()
if modifiers.Shift {
vector.X += this.PageSize().X
} else {
vector.Y += this.PageSize().Y
}
return true
}
if vector != (image.Point { }) {
this.scrollBy(vector)
}
return false
}
func (this *ScrollContainer) handleKeyUp (catch func (), key input.Key, numpad bool) {
func (this *ScrollContainer) handleKeyUp (key input.Key, numpad bool) bool {
switch key {
case input.KeyPageUp: catch()
case input.KeyPageDown: catch()
case input.KeyPageUp: return true
case input.KeyPageDown: return true
}
return false
}