Compare commits

..

No commits in common. "7809aac72f5611c70ea3736dbf1a09c6c8ae3f39" and "e4cba4a7c9847a0bfb80242cc9c38b6caa402f42" have entirely different histories.

3 changed files with 24 additions and 26 deletions

View File

@ -484,6 +484,9 @@ func (this *box) calculateMinimumSize () image.Point {
minSize.Y = userMinSize.Y
}
if this.parent != nil {
this.parent.notifyMinimumSizeChange(this)
}
return minSize
}
@ -561,9 +564,6 @@ func (this *box) invalidateDraw () {
func (this *box) invalidateMinimum () {
this.minSize.Invalidate()
if this.parent != nil {
this.parent.notifyMinimumSizeChange(this)
}
}
func (this *box) recursiveReApply () {

View File

@ -20,6 +20,7 @@ type containerBox struct {
attrLayout attrHierarchy[tomo.AttrLayout]
children []anyBox
layout tomo.Layout
on struct {
contentBoundsChange event.FuncBroadcaster
@ -186,21 +187,19 @@ func (this *containerBox) setAttr (attr tomo.Attr, user bool) {
}
func (this *containerBox) recommendedHeight (width int) int {
layout := this.attrLayout.Value().Layout
if layout == nil || this.attrOverflow.Value().Y {
if this.layout == nil || this.attrOverflow.Value().Y {
return this.minSize.Value().Y
} else {
return layout.RecommendedHeight(this.layoutHints(), this.boxQuerier(), width) +
return this.layout.RecommendedHeight(this.layoutHints(), this.boxQuerier(), width) +
this.borderAndPaddingSum().Vertical()
}
}
func (this *containerBox) recommendedWidth (height int) int {
layout := this.attrLayout.Value().Layout
if layout == nil || this.attrOverflow.Value().X {
if this.layout == nil || this.attrOverflow.Value().X {
return this.minSize.Value().X
} else {
return layout.RecommendedWidth(this.layoutHints(), this.boxQuerier(), height) +
return this.layout.RecommendedWidth(this.layoutHints(), this.boxQuerier(), height) +
this.borderAndPaddingSum().Horizontal()
}
}
@ -275,9 +274,8 @@ func (this *containerBox) layoutHints () tomo.LayoutHints {
func (this *containerBox) contentMinimum () image.Point {
overflow := this.attrOverflow.Value()
minimum := this.box.contentMinimum()
layout := this.attrLayout.Value().Layout
if layout != nil {
layoutMinimum := layout.MinimumSize (
if this.layout != nil {
layoutMinimum := this.layout.MinimumSize (
this.layoutHints(),
this.boxQuerier())
if overflow.X { layoutMinimum.X = 0 }
@ -290,13 +288,12 @@ func (this *containerBox) contentMinimum () image.Point {
func (this *containerBox) doLayout () {
this.box.doLayout()
previousContentBounds := this.contentBounds
layout := this.attrLayout.Value().Layout
// by default, use innerBounds (translated to 0, 0) for contentBounds.
// if a direction overflows, use the layout's minimum size for it.
var minimum image.Point
if layout != nil {
minimum = layout.MinimumSize (
if this.layout != nil {
minimum = this.layout.MinimumSize (
this.layoutHints(),
this.boxQuerier())
}
@ -307,10 +304,10 @@ func (this *containerBox) doLayout () {
if overflow.Y { this.contentBounds.Max.Y = this.contentBounds.Min.Y + minimum.Y }
// arrange children
if layout != nil {
if this.layout != nil {
layoutHints := this.layoutHints()
layoutHints.Bounds = this.contentBounds
layout.Arrange(layoutHints, this.boxArranger())
this.layout.Arrange(layoutHints, this.boxArranger())
}
// build an accurate contentBounds by unioning the bounds of all child
@ -326,7 +323,7 @@ func (this *containerBox) doLayout () {
// offset children and contentBounds by scroll
for _, box := range this.children {
box.setBounds(box.Bounds().Add(this.scroll).Add(innerBounds.Min))
assertAnyBox(box).setBounds(box.Bounds().Add(this.scroll).Add(innerBounds.Min))
}
this.contentBounds = this.contentBounds.Add(this.scroll)

View File

@ -5,21 +5,20 @@ import "git.tebibyte.media/tomo/tomo"
type styleApplicator struct {
style *tomo.Style
role tomo.Role
rules []tomo.Rule
rules []*tomo.Rule
}
func (this *styleApplicator) apply (box anyBox) {
if box.Role() != this.role {
this.role = box.Role()
// the role has changed, so re-cache the list of rules
this.rules = nil
this.rules = make([]*tomo.Rule, 0, 4)
for _, rule := range this.style.Rules {
role := box.Role()
// blank fields match anything
if rule.Role.Package == "" { role.Package = "" }
if rule.Role.Object == "" { role.Object = "" }
if rule.Role == role {
this.rules = append(this.rules, rule)
this.rules = append(this.rules, &rule)
}
}
}
@ -28,10 +27,12 @@ func (this *styleApplicator) apply (box anyBox) {
attrs := make(tomo.AttrSet)
for _, rule := range this.rules {
satisifed := true
for _, tag := range rule.Tags {
if !box.Tag(tag) {
satisifed = false
break
if rule.Tags != nil {
for _, tag := range rule.Tags {
if !box.Tag(tag) {
satisifed = false
break
}
}
}