Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 05f3ebc9e5 | |||
| 996d747d45 | |||
| cd72ae5bdd |
@@ -227,12 +227,6 @@ func (this *containerBox) notifyMinimumSizeChange (child anyBox) {
|
||||
}
|
||||
}
|
||||
|
||||
func (this *containerBox) boundedLayoutHints () tomo.LayoutHints {
|
||||
hints := this.layoutHints()
|
||||
hints.Bounds = this.ContentBounds().Add(this.InnerBounds().Min)
|
||||
return hints
|
||||
}
|
||||
|
||||
func (this *containerBox) layoutHints () tomo.LayoutHints {
|
||||
return tomo.LayoutHints {
|
||||
OverflowX: this.hOverflow,
|
||||
@@ -247,7 +241,7 @@ func (this *containerBox) contentMinimum () image.Point {
|
||||
minimum := this.box.contentMinimum()
|
||||
if this.layout != nil {
|
||||
layoutMinimum := this.layout.MinimumSize (
|
||||
this.boundedLayoutHints(),
|
||||
this.layoutHints(),
|
||||
this.children)
|
||||
if this.hOverflow { layoutMinimum.X = 0 }
|
||||
if this.vOverflow { layoutMinimum.Y = 0 }
|
||||
@@ -260,8 +254,8 @@ func (this *containerBox) doLayout () {
|
||||
this.box.doLayout()
|
||||
previousContentBounds := this.contentBounds
|
||||
|
||||
// by default, use innerBounds for contentBounds. if a direction
|
||||
// overflows, use the layout's minimum size for it.
|
||||
// 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 this.layout != nil {
|
||||
minimum = this.layout.MinimumSize (
|
||||
@@ -269,19 +263,33 @@ func (this *containerBox) doLayout () {
|
||||
this.children)
|
||||
}
|
||||
innerBounds := this.InnerBounds()
|
||||
this.contentBounds = innerBounds
|
||||
this.contentBounds = innerBounds.Sub(innerBounds.Min)
|
||||
if this.hOverflow { this.contentBounds.Max.X = this.contentBounds.Min.X + minimum.X }
|
||||
if this.vOverflow { this.contentBounds.Max.Y = this.contentBounds.Min.Y + minimum.Y }
|
||||
|
||||
// offset the content bounds by the scroll so children can be positioned
|
||||
// accordingly.
|
||||
this.constrainScroll()
|
||||
this.contentBounds = this.contentBounds.Add(this.scroll).Sub(innerBounds.Min)
|
||||
|
||||
// arrange children
|
||||
if this.layout != nil {
|
||||
this.layout.Arrange(this.boundedLayoutHints(), this.children)
|
||||
layoutHints := this.layoutHints()
|
||||
layoutHints.Bounds = this.contentBounds
|
||||
this.layout.Arrange(layoutHints, this.children)
|
||||
}
|
||||
|
||||
// build an accurate contentBounds by unioning the bounds of all child
|
||||
// boxes
|
||||
this.contentBounds = image.Rectangle { }
|
||||
for _, box := range this.children {
|
||||
bounds := box.Bounds()
|
||||
this.contentBounds = this.contentBounds.Union(bounds)
|
||||
}
|
||||
|
||||
// constrain the scroll
|
||||
this.constrainScroll()
|
||||
|
||||
// offset children and contentBounds by scroll
|
||||
for _, box := range this.children {
|
||||
box.SetBounds(box.Bounds().Add(this.scroll).Add(innerBounds.Min))
|
||||
}
|
||||
this.contentBounds = this.contentBounds.Add(this.scroll)
|
||||
|
||||
if previousContentBounds != this.contentBounds {
|
||||
this.on.contentBoundsChange.Broadcast()
|
||||
@@ -321,6 +329,8 @@ func (this *containerBox) recursiveRedo () {
|
||||
}
|
||||
|
||||
func (this *containerBox) boxUnder (point image.Point, category eventCategory) anyBox {
|
||||
if !point.In(this.bounds) { return nil }
|
||||
|
||||
if !this.capture[category] {
|
||||
for _, box := range this.children {
|
||||
candidate := box.(anyBox).boxUnder(point, category)
|
||||
@@ -328,7 +338,7 @@ func (this *containerBox) boxUnder (point image.Point, category eventCategory) a
|
||||
}
|
||||
}
|
||||
|
||||
return this.box.boxUnder(point, category)
|
||||
return this
|
||||
}
|
||||
|
||||
func (this *containerBox) propagate (callback func (anyBox) bool) bool {
|
||||
|
||||
13
event.go
13
event.go
@@ -161,16 +161,17 @@ func (window *window) handleConfigureNotify (
|
||||
if window.root == nil { return }
|
||||
|
||||
configureEvent := *event.ConfigureNotifyEvent
|
||||
configureEvent = window.compressConfigureNotify(configureEvent)
|
||||
|
||||
newWidth := int(configureEvent.Width)
|
||||
newHeight := int(configureEvent.Height)
|
||||
sizeChanged :=
|
||||
window.metrics.bounds.Dx() != newWidth ||
|
||||
window.metrics.bounds.Dy() != newHeight
|
||||
oldBounds := window.metrics.bounds
|
||||
window.updateBounds()
|
||||
newBounds := window.metrics.bounds
|
||||
|
||||
sizeChanged :=
|
||||
oldBounds.Dx() != newBounds.Dx() ||
|
||||
oldBounds.Dy() != newBounds.Dy()
|
||||
|
||||
if sizeChanged {
|
||||
configureEvent = window.compressConfigureNotify(configureEvent)
|
||||
window.reallocateCanvas()
|
||||
|
||||
// TODO figure out what to do with this
|
||||
|
||||
Reference in New Issue
Block a user