[squeak-dev] The Inbox: Morphic-cmm.1408.mcz

Chris Muller asqueaker at gmail.com
Mon Apr 2 23:43:41 UTC 2018


>From only 2 minutes of testing, this updated version appears to fix
the issues I found in "take 2" (both caused by the same problem).

If we don't find any other issues over the next week or so, let's put
it in trunk, it's a nice fix.

 - Chris

On Mon, Apr 2, 2018 at 6:35 PM,  <commits at source.squeak.org> wrote:
> Chris Muller uploaded a new version of Morphic to project The Inbox:
> http://source.squeak.org/inbox/Morphic-cmm.1408.mcz
>
> ==================== Summary ====================
>
> Name: Morphic-cmm.1408
> Author: cmm
> Time: 2 April 2018, 6:34:32.944359 pm
> UUID: 1b84680b-ad85-4d86-a6d4-29fb3c2f8193
> Ancestors: Morphic-cmm.1407
>
> Integrate fix from Stéphane Rollandin that keeps ProportionalSplitter bars in their proportionally-assigned place after resizing windows.
>
> =============== Diff against Morphic-cmm.1407 ===============
>
> Item was added:
> + ----- Method: ProportionalSplitterMorph>>balanceOffsets (in category 'layout') -----
> + balanceOffsets
> +
> +       self layoutFrame hasFixedHeight ifTrue: [
> +               | otop obot ctop cbot topf |
> +
> +               otop := (owner submorphs detect: [:m |
> +                                       m layoutFrame topFraction isZero] ifNone: [^ self]) in: [:tm |
> +                                               tm top - (tm layoutFrame topOffset ifNil: [0])].
> +
> +               obot := (owner submorphs detect: [:m |
> +                                       m layoutFrame bottomFraction = 1] ifNone: [^ self]) in: [:tm |
> +                                               tm bottom - (tm layoutFrame bottomOffset ifNil: [0])].
> +
> +               ctop := (self layoutFrame topFraction * (obot - otop)) rounded
> +                                       + otop + (self layoutFrame topOffset ifNil: [0]).
> +               cbot := (self layoutFrame bottomFraction * (obot - otop)) rounded
> +                                       + otop + (self layoutFrame bottomOffset ifNil: [0]).
> +
> +               topf := self layoutFrame topFraction.
> +               self layoutFrame topFraction:  ((ctop + cbot) * 0.5 - otop) / (obot - otop) asFloat.
> +               self layoutFrame bottomFraction: self layoutFrame topFraction.
> +               self layoutFrame topOffset: ctop -
> +                       (self layoutFrame topFraction * (obot - otop) + otop) rounded.
> +               self layoutFrame bottomOffset: cbot -
> +                       (self layoutFrame bottomFraction * (obot - otop) + otop) rounded..
> +
> +               (leftOrTop copy union: rightOrBottom) do: [:m |
> +                       (m layoutFrame topFraction closeTo: topf) ifTrue: [
> +                               m layoutFrame topFraction: self layoutFrame topFraction.
> +                               m layoutFrame topOffset:
> +                                       m layoutFrame topOffset - (self valueOfProperty: #fullDelta) y].
> +                       (m layoutFrame bottomFraction closeTo: topf) ifTrue: [
> +                               m layoutFrame bottomFraction: self layoutFrame topFraction.
> +                               m layoutFrame bottomOffset:
> +                                       m layoutFrame bottomOffset - (self valueOfProperty: #fullDelta) y.]]] .
> +
> +       self layoutFrame hasFixedWidth ifTrue: [
> +               | oleft oright cleft cright leftf |
> +
> +               oleft := (owner submorphs detect: [:m |
> +                       m layoutFrame leftFraction isZero] ifNone: [^ self]) in: [:tm |
> +                               tm left - (tm layoutFrame leftOffset ifNil: [0])].
> +
> +               oright := (owner submorphs detect: [:m |
> +                       m layoutFrame rightFraction = 1] ifNone: [^ self]) in: [:tm |
> +                               tm right - (tm layoutFrame rightOffset ifNil: [0])].
> +
> +               cleft := (self layoutFrame leftFraction * (oright - oleft)) rounded
> +                                       + oleft + (self layoutFrame leftOffset ifNil: [0]).
> +               cright := (self layoutFrame rightFraction * (oright - oleft)) rounded
> +                                       + oleft + (self layoutFrame rightOffset ifNil: [0]).
> +
> +               leftf := self layoutFrame leftFraction.
> +               self layoutFrame leftFraction: ((cleft + cright) * 0.5 - oleft) / (oright - oleft) asFloat.
> +               self layoutFrame rightFraction: self layoutFrame leftFraction.
> +
> +               self layoutFrame leftOffset: cleft -
> +                       (self layoutFrame leftFraction * (oright - oleft) + oleft) rounded.
> +               self layoutFrame rightOffset: cright -
> +                       (self layoutFrame rightFraction * (oright - oleft) + oleft) rounded.
> +
> +               (leftOrTop copy union: rightOrBottom) do: [:m |
> +                       (m layoutFrame leftFraction closeTo: leftf) ifTrue: [
> +                               m layoutFrame leftFraction: self layoutFrame leftFraction.
> +                               m layoutFrame leftOffset:
> +                                       m layoutFrame leftOffset - (self valueOfProperty: #fullDelta) x].
> +                       (m layoutFrame rightFraction closeTo: leftf) ifTrue: [
> +                               m layoutFrame rightFraction: self layoutFrame leftFraction.
> +                               m layoutFrame rightOffset:
> +                                       m layoutFrame rightOffset - (self valueOfProperty: #fullDelta) x.]]] .
> +
> +       self removeProperty: #fullDelta.
> +       owner layoutChanged
> + !
>
> Item was changed:
>   ----- Method: ProportionalSplitterMorph>>mouseDown: (in category 'events') -----
>   mouseDown: anEvent
>         "If the user manually drags me, don't override him with auto positioning."
>
> +       self setProperty: #fullDelta toValue: 0 at 0.
> +
>         anEvent redButtonChanged
>                 ifTrue: [ self withSiblingSplittersDo: [ : each | each stopStepping ] ]
>                 ifFalse:
>                         [ anEvent shiftPressed
>                                 ifTrue: [ self startStepping ]
>                                 ifFalse:
>                                         [ self startStepping.
>                                         self withSiblingSplittersDo: [ : each | each startStepping ] ] ].
>         (self class showSplitterHandles not and: [ self bounds containsPoint: anEvent cursorPoint ]) ifTrue:
>                 [ oldColor := self color.
>                 self color: Color black ].
>         ^ super mouseDown: anEvent!
>
> Item was changed:
>   ----- Method: ProportionalSplitterMorph>>mouseUp: (in category 'events') -----
>   mouseUp: anEvent
>         (self bounds containsPoint: anEvent cursorPoint)
>                 ifFalse: [anEvent hand showTemporaryCursor: nil].
>         self class fastSplitterResize
>                 ifTrue: [self updateFromEvent: anEvent].
>         traceMorph ifNotNil: [traceMorph delete. traceMorph := nil].
> +       self color: self getOldColor.
> +
> +       self balanceOffsets!
> -       self color: self getOldColor!
>
> Item was changed:
>   ----- Method: ProportionalSplitterMorph>>reduceLeftRightImbalance (in category 'layout') -----
>   reduceLeftRightImbalance
>         | correction |
>         correction := self leftRightImbalance.
>         correction abs > 1
>                 ifTrue:
>                         [ (self proposedCorrectionWouldCauseFocusChange: correction) ifFalse:
>                                 [ self repositionBy:
>                                         (correction abs > 4
>                                                 ifTrue: [ correction sign * 2 @ 0 ]
>                                                 ifFalse: [ correction sign @ 0 ]) ] ]
>                 ifFalse:
> +                       [ self class smartVerticalSplitters ifFalse:
> +                               [ self
> +                                        stopStepping ;
> +                                        balanceOffsets ] ].
> -                       [ self class smartVerticalSplitters ifFalse: [ self stopStepping ] ].
>         ^ correction!
>
> Item was changed:
>   ----- Method: ProportionalSplitterMorph>>reduceTopBottomImbalance (in category 'layout') -----
>   reduceTopBottomImbalance
>         | correction |
>         (correction := self topBottomCorrection) isZero
>                 ifTrue:
> +                       [ self class smartHorizontalSplitters ifFalse:
> +                               [ self
> +                                        stopStepping ;
> +                                        balanceOffsets ] ]
> -                       [ self class smartHorizontalSplitters ifFalse: [ self stopStepping ] ]
>                 ifFalse:
>                         [ (self proposedCorrectionWouldCauseFocusChange: correction) ifFalse: [ self repositionBy: 0 @ correction ] ].
>         ^ correction!
>
> Item was changed:
>   ----- Method: ProportionalSplitterMorph>>repositionBy: (in category 'layout') -----
>   repositionBy: delta
>         | selfTop selfBottom selfLeft selfRight |
> +
> +       self setProperty: #fullDelta toValue: ((self valueOfProperty: #fullDelta) ifNil: [0 at 0]) + delta.
> +
>         leftOrTop do:
>                 [ : each | | firstRight firstBottom firstLeft firstTop |
>                 firstRight := each layoutFrame rightOffset ifNil: [ 0 ].
>                 firstBottom := each layoutFrame bottomOffset ifNil: [ 0 ].
>                 each layoutFrame rightOffset: firstRight + delta x.
>                 each layoutFrame bottomOffset: firstBottom + delta y.
>                 each layoutFrame hasFixedHeight ifTrue: [
>                         firstTop := each layoutFrame topOffset ifNil: [ 0 ].
>                         each layoutFrame topOffset: firstTop + delta y ].
>                 each layoutFrame hasFixedWidth ifTrue: [
>                         firstLeft := each layoutFrame leftOffset ifNil: [ 0 ].
>                         each layoutFrame leftOffset: firstLeft + delta x. ] ].
>         rightOrBottom do:
>                 [ : each | | secondLeft secondTop secondRight secondBottom |
>                 secondLeft := each layoutFrame leftOffset ifNil: [ 0 ].
>                 secondTop := each layoutFrame topOffset ifNil: [ 0 ].
>                 each layoutFrame leftOffset: secondLeft + delta x.
>                 each layoutFrame topOffset: secondTop + delta y.
>                 each layoutFrame hasFixedHeight ifTrue: [
>                         secondBottom := each layoutFrame bottomOffset ifNil: [ 0 ].
>                         each layoutFrame bottomOffset: secondBottom + delta y. ].
>                 each layoutFrame hasFixedWidth ifTrue: [
>                         secondRight := each layoutFrame rightOffset ifNil: [ 0 ].
>                         each layoutFrame rightOffset: secondRight + delta x. ] ].
>
>         selfTop := self layoutFrame topOffset ifNil: [ 0 ].
>         selfBottom := self layoutFrame bottomOffset ifNil: [ 0 ].
>         selfLeft := self layoutFrame leftOffset ifNil: [ 0 ].
>         selfRight := self layoutFrame rightOffset ifNil: [ 0 ].
>         self layoutFrame
>                  topOffset: selfTop + delta y ;
>                  bottomOffset: selfBottom + delta y ;
>                  leftOffset: selfLeft + delta x ;
>                  rightOffset: selfRight + delta x.
>         self owner layoutChanged.
>         self movements removeFirst; add: (splitsTopAndBottom ifTrue: [ delta y sign ] ifFalse: [ delta x sign ])!
>
>
>
>


More information about the Squeak-dev mailing list