It compiles

This commit is contained in:
Sasha Koshka 2023-03-15 23:47:13 -04:00
parent ef325d5161
commit c1b3562d10
3 changed files with 28 additions and 29 deletions

View File

@ -94,6 +94,30 @@ func (window *window) NotifyMinimumSizeChange (child elements.Element) {
window.childMinimumSizeChangeCallback(child.MinimumSize()) window.childMinimumSizeChangeCallback(child.MinimumSize())
} }
func (window *window) RequestFocus (
child elements.Focusable,
) (
granted bool,
) {
return true
}
func (window *window) RequestFocusNext (child elements.Focusable) {
if child, ok := window.child.(elements.Focusable); ok {
if !child.HandleFocus(input.KeynavDirectionForward) {
child.HandleUnfocus()
}
}
}
func (window *window) RequestFocusPrevious (child elements.Focusable) {
if child, ok := window.child.(elements.Focusable); ok {
if !child.HandleFocus(input.KeynavDirectionBackward) {
child.HandleUnfocus()
}
}
}
func (window *window) Adopt (child elements.Element) { func (window *window) Adopt (child elements.Element) {
// disown previous child // disown previous child
if window.child != nil { if window.child != nil {
@ -305,27 +329,6 @@ func (window *window) childMinimumSizeChangeCallback (width, height int) (resize
return false return false
} }
func (window *window) childSelectionRequestCallback () (granted bool) {
if _, ok := window.child.(elements.Focusable); ok {
return true
}
return false
}
func (window *window) childSelectionMotionRequestCallback (
direction input.KeynavDirection,
) (
granted bool,
) {
if child, ok := window.child.(elements.Focusable); ok {
if !child.HandleFocus(direction) {
child.HandleUnfocus()
}
return true
}
return true
}
func (window *window) pushRegion (region image.Rectangle) { func (window *window) pushRegion (region image.Rectangle) {
if window.xCanvas == nil { panic("whoopsie!!!!!!!!!!!!!!") } if window.xCanvas == nil { panic("whoopsie!!!!!!!!!!!!!!") }
image, ok := window.xCanvas.SubImage(region).(*xgraphics.Image) image, ok := window.xCanvas.SubImage(region).(*xgraphics.Image)

View File

@ -1,7 +1,5 @@
package elements package elements
import "git.tebibyte.media/sashakoshka/tomo/input"
// Parent represents a type capable of containing child elements. // Parent represents a type capable of containing child elements.
type Parent interface { type Parent interface {
// NotifyMinimumSizeChange notifies the container that a child element's // NotifyMinimumSizeChange notifies the container that a child element's

View File

@ -51,8 +51,7 @@ func (propagator *Propagator) Focus () {
parent := propagator.core.Parent() parent := propagator.core.Parent()
if parent, ok := parent.(elements.FocusableParent); ok && parent != nil { if parent, ok := parent.(elements.FocusableParent); ok && parent != nil {
propagator.focused = parent.RequestFocus ( propagator.focused = parent.RequestFocus (
propagator.core.Outer().(elements.Focusable), propagator.core.Outer().(elements.Focusable))
input.KeynavDirectionNeutral)
} }
} }
@ -131,9 +130,8 @@ func (propagator *Propagator) RequestFocus (
) ( ) (
granted bool, granted bool,
) { ) {
// TODO implement this, and also implement it for the x backend window
if parent, ok := propagator.core.Parent().(elements.FocusableParent); ok { if parent, ok := propagator.core.Parent().(elements.FocusableParent); ok {
if parent.RequestFocus(propagator) { if parent.RequestFocus(propagator.core.Outer().(elements.Focusable)) {
propagator.focused = true propagator.focused = true
granted = true granted = true
} }
@ -146,7 +144,7 @@ func (propagator *Propagator) RequestFocus (
func (propagator *Propagator) RequestFocusNext (child elements.Focusable) { func (propagator *Propagator) RequestFocusNext (child elements.Focusable) {
if !propagator.focused { return } if !propagator.focused { return }
if parent, ok := propagator.core.Parent().(elements.FocusableParent); ok { if parent, ok := propagator.core.Parent().(elements.FocusableParent); ok {
parent.RequestFocusNext(propagator) parent.RequestFocusNext(propagator.core.Outer().(elements.Focusable))
} }
} }
@ -155,7 +153,7 @@ func (propagator *Propagator) RequestFocusNext (child elements.Focusable) {
func (propagator *Propagator) RequestFocusPrevious (child elements.Focusable) { func (propagator *Propagator) RequestFocusPrevious (child elements.Focusable) {
if !propagator.focused { return } if !propagator.focused { return }
if parent, ok := propagator.core.Parent().(elements.FocusableParent); ok { if parent, ok := propagator.core.Parent().(elements.FocusableParent); ok {
parent.RequestFocusPrevious(propagator) parent.RequestFocusPrevious(propagator.core.Outer().(elements.Focusable))
} }
} }