ough
This commit is contained in:
@@ -6,6 +6,7 @@ import "git.tebibyte.media/sashakoshka/tomo/artist"
|
||||
import "git.tebibyte.media/sashakoshka/tomo/ability"
|
||||
|
||||
type entity struct {
|
||||
backend *backend
|
||||
window *window
|
||||
parent *entity
|
||||
children []*entity
|
||||
@@ -21,7 +22,7 @@ type entity struct {
|
||||
}
|
||||
|
||||
func (backend *backend) NewEntity (owner tomo.Element) tomo.Entity {
|
||||
entity := &entity { element: owner }
|
||||
entity := &entity { element: owner, backend: backend }
|
||||
entity.InvalidateLayout()
|
||||
return entity
|
||||
}
|
||||
@@ -162,7 +163,7 @@ func (entity *entity) DrawBackground (destination artist.Canvas) {
|
||||
if entity.parent != nil {
|
||||
entity.parent.element.(ability.Container).DrawBackground(destination)
|
||||
} else if entity.window != nil {
|
||||
entity.window.system.theme.Pattern (
|
||||
entity.backend.theme.Pattern (
|
||||
tomo.PatternBackground,
|
||||
tomo.State { },
|
||||
tomo.C("tomo", "window")).Draw (
|
||||
@@ -292,11 +293,11 @@ func (entity *entity) NotifyScrollBoundsChange () {
|
||||
// ----------- ThemeableEntity ----------- //
|
||||
|
||||
func (entity *entity) Theme () tomo.Theme {
|
||||
return entity.window.theme
|
||||
return entity.backend.theme
|
||||
}
|
||||
|
||||
// ----------- ConfigurableEntity ----------- //
|
||||
|
||||
func (entity *entity) Config () tomo.Config {
|
||||
return entity.window.config
|
||||
return entity.backend.config
|
||||
}
|
||||
|
||||
@@ -1,11 +1,8 @@
|
||||
package x
|
||||
|
||||
import "image"
|
||||
import "git.tebibyte.media/sashakoshka/tomo"
|
||||
import "git.tebibyte.media/sashakoshka/tomo/artist"
|
||||
import "git.tebibyte.media/sashakoshka/tomo/ability"
|
||||
import defaultTheme "git.tebibyte.media/sashakoshka/tomo/default/theme"
|
||||
import defaultConfig "git.tebibyte.media/sashakoshka/tomo/default/config"
|
||||
|
||||
type entitySet map[*entity] struct { }
|
||||
|
||||
@@ -26,10 +23,7 @@ type system struct {
|
||||
child *entity
|
||||
focused *entity
|
||||
canvas artist.BasicCanvas
|
||||
|
||||
theme tomo.Theme
|
||||
config tomo.Config
|
||||
|
||||
|
||||
invalidateIgnore bool
|
||||
drawingInvalid entitySet
|
||||
anyLayoutInvalid bool
|
||||
@@ -43,12 +37,7 @@ func (system *system) initialize () {
|
||||
system.drawingInvalid = make(entitySet)
|
||||
}
|
||||
|
||||
func (system *system) setTheme (theme tomo.Theme) {
|
||||
if theme == nil {
|
||||
system.theme = defaultTheme.Default { }
|
||||
} else {
|
||||
system.theme = theme
|
||||
}
|
||||
func (system *system) handleThemeChange () {
|
||||
system.propagate (func (entity *entity) bool {
|
||||
if child, ok := system.child.element.(ability.Themeable); ok {
|
||||
child.HandleThemeChange()
|
||||
@@ -57,12 +46,7 @@ func (system *system) setTheme (theme tomo.Theme) {
|
||||
})
|
||||
}
|
||||
|
||||
func (system *system) setConfig (config tomo.Config) {
|
||||
if config == nil {
|
||||
system.config = defaultConfig.Default { }
|
||||
} else {
|
||||
system.config = config
|
||||
}
|
||||
func (system *system) handleConfigChange () {
|
||||
system.propagate (func (entity *entity) bool {
|
||||
if child, ok := system.child.element.(ability.Configurable); ok {
|
||||
child.HandleConfigChange()
|
||||
|
||||
@@ -120,9 +120,6 @@ func (backend *backend) newWindow (
|
||||
Connect(backend.connection, window.xWindow.Id)
|
||||
xevent.SelectionRequestFun(window.handleSelectionRequest).
|
||||
Connect(backend.connection, window.xWindow.Id)
|
||||
|
||||
window.setTheme(backend.theme)
|
||||
window.setConfig(backend.config)
|
||||
|
||||
window.metrics.bounds = bounds
|
||||
window.setMinimumSize(8, 8)
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
package x
|
||||
|
||||
import "git.tebibyte.media/sashakoshka/tomo"
|
||||
import defaultTheme "git.tebibyte.media/sashakoshka/tomo/default/theme"
|
||||
import defaultConfig "git.tebibyte.media/sashakoshka/tomo/default/config"
|
||||
|
||||
import "github.com/jezek/xgbutil"
|
||||
import "github.com/jezek/xgb/xproto"
|
||||
@@ -96,17 +98,26 @@ func (backend *backend) Do (callback func ()) {
|
||||
|
||||
func (backend *backend) SetTheme (theme tomo.Theme) {
|
||||
backend.assert()
|
||||
backend.theme = theme
|
||||
if theme == nil {
|
||||
backend.theme = defaultTheme.Default { }
|
||||
} else {
|
||||
backend.theme = theme
|
||||
}
|
||||
for _, window := range backend.windows {
|
||||
window.setTheme(theme)
|
||||
window.handleThemeChange()
|
||||
}
|
||||
}
|
||||
|
||||
func (backend *backend) SetConfig (config tomo.Config) {
|
||||
backend.assert()
|
||||
if config == nil {
|
||||
backend.config = defaultConfig.Default { }
|
||||
} else {
|
||||
backend.config = config
|
||||
}
|
||||
backend.config = config
|
||||
for _, window := range backend.windows {
|
||||
window.setConfig(config)
|
||||
window.handleConfigChange()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user