Fixed style application
This commit is contained in:
parent
02de78c997
commit
6619987b5a
@ -479,6 +479,7 @@ func (this *box) setParent (parent parent) {
|
||||
this.SetFocused(false)
|
||||
}
|
||||
this.parent = parent
|
||||
this.recursiveReApply()
|
||||
}
|
||||
|
||||
func (this *box) getParent () parent {
|
||||
@ -527,6 +528,8 @@ func (this *box) invalidateMinimum () {
|
||||
}
|
||||
|
||||
func (this *box) recursiveReApply () {
|
||||
if this.getHierarchy() == nil { return }
|
||||
|
||||
// re-apply styling, icons *if needed*
|
||||
|
||||
// style
|
||||
|
@ -12,10 +12,6 @@ type Hierarchy struct {
|
||||
link WindowLink
|
||||
system *System
|
||||
canvas canvas.Canvas
|
||||
|
||||
style tomo.Style
|
||||
styleNonce int
|
||||
iconsNonce int
|
||||
|
||||
root anyBox
|
||||
focused anyBox
|
||||
@ -146,14 +142,11 @@ func (this *Hierarchy) Close () {
|
||||
this.system.removeHierarchy(this)
|
||||
}
|
||||
|
||||
func (this *Hierarchy) setStyle (style tomo.Style) {
|
||||
this.style = style
|
||||
this.styleNonce ++
|
||||
func (this *Hierarchy) setStyle () {
|
||||
if this.root != nil { this.root.recursiveReApply() }
|
||||
}
|
||||
|
||||
func (this *Hierarchy) setIcons (icons tomo.Icons) {
|
||||
this.iconsNonce ++
|
||||
func (this *Hierarchy) setIcons () {
|
||||
if this.root != nil { this.root.recursiveReApply() }
|
||||
}
|
||||
|
||||
@ -166,15 +159,15 @@ func (this *Hierarchy) getWindow () tomo.Window {
|
||||
}
|
||||
|
||||
func (this *Hierarchy) getStyle () tomo.Style {
|
||||
return this.style
|
||||
return this.system.style
|
||||
}
|
||||
|
||||
func (this *Hierarchy) getStyleNonce () int {
|
||||
return this.styleNonce
|
||||
return this.system.styleNonce
|
||||
}
|
||||
|
||||
func (this *Hierarchy) getIconsNonce () int {
|
||||
return this.iconsNonce
|
||||
return this.system.iconsNonce
|
||||
}
|
||||
|
||||
func (this *Hierarchy) getCanvas () canvas.Canvas {
|
||||
|
@ -9,7 +9,12 @@ import "git.tebibyte.media/tomo/backend/internal/util"
|
||||
// System is coupled to a tomo.Backend implementation, and manages Hierarchies
|
||||
// and Boxes.
|
||||
type System struct {
|
||||
link BackendLink
|
||||
link BackendLink
|
||||
|
||||
style tomo.Style
|
||||
styleNonce int
|
||||
iconsNonce int
|
||||
|
||||
hierarchies util.Set[*Hierarchy]
|
||||
}
|
||||
|
||||
@ -41,15 +46,18 @@ func New (link BackendLink) *System {
|
||||
// SetStyle sets the tomo.Style that is applied to objects, and notifies them
|
||||
// that the style has changed.
|
||||
func (this *System) SetStyle (style tomo.Style) {
|
||||
this.style = style
|
||||
this.styleNonce ++
|
||||
for hierarchy := range this.hierarchies {
|
||||
hierarchy.setStyle(style)
|
||||
hierarchy.setStyle()
|
||||
}
|
||||
}
|
||||
|
||||
// SetIcons notifies objects that the icons have changed.
|
||||
func (this *System) SetIcons (icons tomo.Icons) {
|
||||
this.iconsNonce ++
|
||||
for hierarchy := range this.hierarchies {
|
||||
hierarchy.setIcons(icons)
|
||||
hierarchy.setIcons()
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user