From e7f16645ebb7bb6c4519c73ce4c12c9749dd9a8c Mon Sep 17 00:00:00 2001 From: Sasha Koshka Date: Fri, 23 Aug 2024 12:32:46 -0400 Subject: [PATCH] Unset all attributes when the style changes Progress on #4 --- internal/system/box.go | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/internal/system/box.go b/internal/system/box.go index 3aeb777..7e5fdd8 100644 --- a/internal/system/box.go +++ b/internal/system/box.go @@ -259,6 +259,24 @@ func (this *box) unsetAttr (kind tomo.AttrKind, user bool) { } } +func (this *box) unsetAllAttrs (user bool) { + // keep this in sync with tomo.AttrKind! + this.outer.unsetAttr(tomo.AttrKindColor, user) + this.outer.unsetAttr(tomo.AttrKindTexture, user) + this.outer.unsetAttr(tomo.AttrKindTextureMode, user) + this.outer.unsetAttr(tomo.AttrKindBorder, user) + this.outer.unsetAttr(tomo.AttrKindMinimumSize, user) + this.outer.unsetAttr(tomo.AttrKindPadding, user) + this.outer.unsetAttr(tomo.AttrKindGap, user) + this.outer.unsetAttr(tomo.AttrKindTextColor, user) + this.outer.unsetAttr(tomo.AttrKindDotColor, user) + this.outer.unsetAttr(tomo.AttrKindFace, user) + this.outer.unsetAttr(tomo.AttrKindWrap, user) + this.outer.unsetAttr(tomo.AttrKindAlign, user) + this.outer.unsetAttr(tomo.AttrKindOverflow, user) + this.outer.unsetAttr(tomo.AttrKindLayout, user) +} + func (this *box) setBounds (bounds image.Rectangle) { if this.bounds == bounds { return } this.bounds = bounds @@ -624,6 +642,7 @@ func (this *box) recursiveReApply () { // applicator for every box, it's so style applicators can cache // information about the boxes they're linked to (like all rules // with a matching role). + this.unsetAllAttrs(false) this.lastStyleNonce = hierarchyStyleNonce this.styleApplicator = hierarchy.newStyleApplicator() this.invalidateStyle()