Re-organized module structure
This commit is contained in:
@@ -1,8 +1,8 @@
|
||||
package x
|
||||
|
||||
import "image"
|
||||
import "git.tebibyte.media/sashakoshka/tomo"
|
||||
import "git.tebibyte.media/sashakoshka/tomo/input"
|
||||
import "git.tebibyte.media/sashakoshka/tomo/elements"
|
||||
|
||||
import "github.com/jezek/xgbutil"
|
||||
import "github.com/jezek/xgb/xproto"
|
||||
@@ -127,7 +127,7 @@ func (window *window) handleKeyPress (
|
||||
modifiers.NumberPad = numberPad
|
||||
|
||||
if key == input.KeyTab && modifiers.Alt {
|
||||
if child, ok := window.child.(elements.Focusable); ok {
|
||||
if child, ok := window.child.(tomo.Focusable); ok {
|
||||
direction := input.KeynavDirectionForward
|
||||
if modifiers.Shift {
|
||||
direction = input.KeynavDirectionBackward
|
||||
@@ -137,7 +137,7 @@ func (window *window) handleKeyPress (
|
||||
child.HandleUnfocus()
|
||||
}
|
||||
}
|
||||
} else if child, ok := window.child.(elements.KeyboardTarget); ok {
|
||||
} else if child, ok := window.child.(tomo.KeyboardTarget); ok {
|
||||
child.HandleKeyDown(key, modifiers)
|
||||
}
|
||||
}
|
||||
@@ -171,7 +171,7 @@ func (window *window) handleKeyRelease (
|
||||
modifiers := window.modifiersFromState(keyEvent.State)
|
||||
modifiers.NumberPad = numberPad
|
||||
|
||||
if child, ok := window.child.(elements.KeyboardTarget); ok {
|
||||
if child, ok := window.child.(tomo.KeyboardTarget); ok {
|
||||
child.HandleKeyUp(key, modifiers)
|
||||
}
|
||||
}
|
||||
@@ -185,7 +185,7 @@ func (window *window) handleButtonPress (
|
||||
|
||||
buttonEvent := *event.ButtonPressEvent
|
||||
if buttonEvent.Detail >= 4 && buttonEvent.Detail <= 7 {
|
||||
if child, ok := window.child.(elements.ScrollTarget); ok {
|
||||
if child, ok := window.child.(tomo.ScrollTarget); ok {
|
||||
sum := scrollSum { }
|
||||
sum.add(buttonEvent.Detail, window, buttonEvent.State)
|
||||
window.compressScrollSum(buttonEvent, &sum)
|
||||
@@ -195,7 +195,7 @@ func (window *window) handleButtonPress (
|
||||
float64(sum.x), float64(sum.y))
|
||||
}
|
||||
} else {
|
||||
if child, ok := window.child.(elements.MouseTarget); ok {
|
||||
if child, ok := window.child.(tomo.MouseTarget); ok {
|
||||
child.HandleMouseDown (
|
||||
int(buttonEvent.EventX),
|
||||
int(buttonEvent.EventY),
|
||||
@@ -211,7 +211,7 @@ func (window *window) handleButtonRelease (
|
||||
) {
|
||||
if window.child == nil { return }
|
||||
|
||||
if child, ok := window.child.(elements.MouseTarget); ok {
|
||||
if child, ok := window.child.(tomo.MouseTarget); ok {
|
||||
buttonEvent := *event.ButtonReleaseEvent
|
||||
if buttonEvent.Detail >= 4 && buttonEvent.Detail <= 7 { return }
|
||||
child.HandleMouseUp (
|
||||
@@ -227,7 +227,7 @@ func (window *window) handleMotionNotify (
|
||||
) {
|
||||
if window.child == nil { return }
|
||||
|
||||
if child, ok := window.child.(elements.MotionTarget); ok {
|
||||
if child, ok := window.child.(tomo.MotionTarget); ok {
|
||||
motionEvent := window.compressMotionNotify(*event.MotionNotifyEvent)
|
||||
child.HandleMotion (
|
||||
int(motionEvent.EventX),
|
||||
|
||||
@@ -9,12 +9,12 @@ import "github.com/jezek/xgbutil/xprop"
|
||||
import "github.com/jezek/xgbutil/xevent"
|
||||
import "github.com/jezek/xgbutil/xwindow"
|
||||
import "github.com/jezek/xgbutil/xgraphics"
|
||||
import "git.tebibyte.media/sashakoshka/tomo"
|
||||
import "git.tebibyte.media/sashakoshka/tomo/data"
|
||||
import "git.tebibyte.media/sashakoshka/tomo/input"
|
||||
import "git.tebibyte.media/sashakoshka/tomo/theme"
|
||||
import "git.tebibyte.media/sashakoshka/tomo/config"
|
||||
import "git.tebibyte.media/sashakoshka/tomo/canvas"
|
||||
import "git.tebibyte.media/sashakoshka/tomo/elements"
|
||||
// import "runtime/debug"
|
||||
|
||||
type mainWindow struct { *window }
|
||||
@@ -23,7 +23,7 @@ type window struct {
|
||||
xWindow *xwindow.Window
|
||||
xCanvas *xgraphics.Image
|
||||
canvas canvas.BasicCanvas
|
||||
child elements.Element
|
||||
child tomo.Element
|
||||
onClose func ()
|
||||
skipChildDrawCallback bool
|
||||
|
||||
@@ -45,7 +45,7 @@ type window struct {
|
||||
func (backend *Backend) NewWindow (
|
||||
width, height int,
|
||||
) (
|
||||
output elements.MainWindow,
|
||||
output tomo.MainWindow,
|
||||
err error,
|
||||
) {
|
||||
if backend == nil { panic("nil backend") }
|
||||
@@ -120,35 +120,35 @@ func (backend *Backend) newWindow (
|
||||
return
|
||||
}
|
||||
|
||||
func (window *window) NotifyMinimumSizeChange (child elements.Element) {
|
||||
func (window *window) NotifyMinimumSizeChange (child tomo.Element) {
|
||||
window.childMinimumSizeChangeCallback(child.MinimumSize())
|
||||
}
|
||||
|
||||
func (window *window) RequestFocus (
|
||||
child elements.Focusable,
|
||||
child tomo.Focusable,
|
||||
) (
|
||||
granted bool,
|
||||
) {
|
||||
return true
|
||||
}
|
||||
|
||||
func (window *window) RequestFocusNext (child elements.Focusable) {
|
||||
if child, ok := window.child.(elements.Focusable); ok {
|
||||
func (window *window) RequestFocusNext (child tomo.Focusable) {
|
||||
if child, ok := window.child.(tomo.Focusable); ok {
|
||||
if !child.HandleFocus(input.KeynavDirectionForward) {
|
||||
child.HandleUnfocus()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func (window *window) RequestFocusPrevious (child elements.Focusable) {
|
||||
if child, ok := window.child.(elements.Focusable); ok {
|
||||
func (window *window) RequestFocusPrevious (child tomo.Focusable) {
|
||||
if child, ok := window.child.(tomo.Focusable); ok {
|
||||
if !child.HandleFocus(input.KeynavDirectionBackward) {
|
||||
child.HandleUnfocus()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func (window *window) Adopt (child elements.Element) {
|
||||
func (window *window) Adopt (child tomo.Element) {
|
||||
// disown previous child
|
||||
if window.child != nil {
|
||||
window.child.SetParent(nil)
|
||||
@@ -159,10 +159,10 @@ func (window *window) Adopt (child elements.Element) {
|
||||
// adopt new child
|
||||
window.child = child
|
||||
child.SetParent(window)
|
||||
if newChild, ok := child.(elements.Themeable); ok {
|
||||
if newChild, ok := child.(tomo.Themeable); ok {
|
||||
newChild.SetTheme(window.theme)
|
||||
}
|
||||
if newChild, ok := child.(elements.Configurable); ok {
|
||||
if newChild, ok := child.(tomo.Configurable); ok {
|
||||
newChild.SetConfig(window.config)
|
||||
}
|
||||
if child != nil {
|
||||
@@ -174,7 +174,7 @@ func (window *window) Adopt (child elements.Element) {
|
||||
}
|
||||
}
|
||||
|
||||
func (window *window) Child () (child elements.Element) {
|
||||
func (window *window) Child () (child tomo.Element) {
|
||||
child = window.child
|
||||
return
|
||||
}
|
||||
@@ -225,7 +225,7 @@ func (window *window) SetIcon (sizes []image.Image) {
|
||||
wmIcons)
|
||||
}
|
||||
|
||||
func (window *window) NewModal (width, height int) (elements.Window, error) {
|
||||
func (window *window) NewModal (width, height int) (tomo.Window, error) {
|
||||
modal, err := window.backend.newWindow(width, height)
|
||||
icccm.WmTransientForSet (
|
||||
window.backend.connection,
|
||||
@@ -240,7 +240,7 @@ func (window *window) NewModal (width, height int) (elements.Window, error) {
|
||||
return modal, err
|
||||
}
|
||||
|
||||
func (window mainWindow) NewPanel (width, height int) (elements.Window, error) {
|
||||
func (window mainWindow) NewPanel (width, height int) (tomo.Window, error) {
|
||||
panel, err := window.backend.newWindow(width, height)
|
||||
if err != nil { return nil, err }
|
||||
panel.setClientLeader(window.window)
|
||||
@@ -336,14 +336,14 @@ func (window *window) OnClose (callback func ()) {
|
||||
|
||||
func (window *window) SetTheme (theme theme.Theme) {
|
||||
window.theme = theme
|
||||
if child, ok := window.child.(elements.Themeable); ok {
|
||||
if child, ok := window.child.(tomo.Themeable); ok {
|
||||
child.SetTheme(theme)
|
||||
}
|
||||
}
|
||||
|
||||
func (window *window) SetConfig (config config.Config) {
|
||||
window.config = config
|
||||
if child, ok := window.child.(elements.Configurable); ok {
|
||||
if child, ok := window.child.(tomo.Configurable); ok {
|
||||
child.SetConfig(config)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user