Marcel Taeumel uploaded a new version of Morphic to project The Trunk:
http://source.squeak.org/trunk/Morphic-nice.1625.mcz ==================== Summary ==================== Name: Morphic-nice.1625 Author: nice Time: 17 February 2020, 5:06:10.606532 pm UUID: 094e2566-ddfe-2340-8fab-2338d255e164 Ancestors: Morphic-mt.1624 Free our mind from un-initialized LayoutFrame. There should not be any such thing. Require Graphics-nice.425 =============== Diff against Morphic-mt.1624 =============== Item was changed: ----- Method: BorderedMorph>>addMorph:fullFrame: (in category 'resize handling') ----- addMorph: aMorph fullFrame: aLayoutFrame "Add aMorph according to aLayoutFrame." self cellGap > 0 ifTrue: [ | left right bottom top spacing | spacing := self cellGap. + left := aLayoutFrame leftOffset. + right := aLayoutFrame rightOffset. - left := aLayoutFrame leftOffset ifNil: [0]. - right := aLayoutFrame rightOffset ifNil: [0]. + bottom := aLayoutFrame bottomOffset. + top := aLayoutFrame topOffset. - bottom := aLayoutFrame bottomOffset ifNil: [0]. - top := aLayoutFrame topOffset ifNil: [0]. "Add a spacing to the frame if it is not top or leftmost." aLayoutFrame leftFraction = 0 ifFalse: [left := left + spacing] ifTrue: [ "Expect another, resizable widget besides me if I have a fixed width." aLayoutFrame hasFixedWidth ifTrue: [right := right - spacing]]. aLayoutFrame topFraction = 0 ifFalse: [top := top + spacing] ifTrue: [ "Expect another, resizable widget besides me if I have a fixed height." aLayoutFrame hasFixedHeight ifTrue: [bottom := bottom - spacing]]. aLayoutFrame topOffset: top; bottomOffset: bottom; leftOffset: left; rightOffset: right]. super addMorph: aMorph fullFrame: aLayoutFrame. self wantsPaneSplitters ifTrue: [self addPaneSplitters].! Item was changed: ----- Method: BorderedMorph>>addPaneHSplitterAtBottomOfRow: (in category 'resize handling') ----- addPaneHSplitterAtBottomOfRow: someMorphs | targetY minX maxX splitter | targetY := someMorphs first layoutFrame bottomFraction. minX := (someMorphs detectMin: [:each | each layoutFrame leftFraction]) layoutFrame leftFraction. maxX := (someMorphs detectMax: [:each | each layoutFrame rightFraction]) layoutFrame rightFraction. splitter := ProportionalSplitterMorph new beSplitsTopAndBottom; yourself. splitter layoutFrame: (LayoutFrame fractions: (minX @ targetY corner: maxX @ targetY) + offsets: (someMorphs first layoutFrame leftOffset @ 0 + corner: someMorphs first layoutFrame rightOffset @ AbstractResizerMorph gripThickness)). - offsets: ((someMorphs first layoutFrame leftOffset ifNil: [0]) @ 0 - corner: (someMorphs first layoutFrame rightOffset ifNil: [0]) @ AbstractResizerMorph gripThickness)). self addMorphBack: (splitter position: self position).! Item was changed: ----- Method: BorderedMorph>>addPaneVSplitterAtRightOfColumn: (in category 'resize handling') ----- addPaneVSplitterAtRightOfColumn: someMorphs | targetX minY maxY splitter | targetX := someMorphs first layoutFrame rightFraction. minY := (someMorphs detectMin: [:each | each layoutFrame topFraction]) layoutFrame topFraction. maxY := (someMorphs detectMax: [:each | each layoutFrame bottomFraction]) layoutFrame bottomFraction. splitter := ProportionalSplitterMorph new beSplitsLeftAndRight; yourself. splitter layoutFrame: (LayoutFrame fractions: (targetX @ minY corner: targetX @ maxY) + offsets: (0 @ (someMorphs first layoutFrame topOffset) + corner: (AbstractResizerMorph gripThickness@ (someMorphs first layoutFrame bottomOffset)))). - offsets: (0 @ (someMorphs first layoutFrame topOffset ifNil: [0]) - corner: (AbstractResizerMorph gripThickness@ (someMorphs first layoutFrame bottomOffset ifNil: [0])))). self addMorphBack: (splitter position: self position).! Item was changed: ----- Method: BorderedMorph>>linkSubmorphsToSplitters (in category 'resize handling') ----- linkSubmorphsToSplitters self splitters do: [:splitter | splitter splitsTopAndBottom ifTrue: [ self submorphsDo: [:morph | ((morph ~= splitter and: [morph layoutFrame bottomFraction = splitter layoutFrame topFraction]) and: [morph layoutFrame hasFixedHeight not + or: [(morph layoutFrame topOffset) < 0]]) - or: [(morph layoutFrame topOffset ifNil: [0]) < 0]]) ifTrue: [splitter addLeftOrTop: morph]. ((morph ~= splitter and: [morph layoutFrame topFraction = splitter layoutFrame bottomFraction]) and: [morph layoutFrame hasFixedHeight not + or: [(morph layoutFrame bottomOffset) > 0]]) - or: [(morph layoutFrame bottomOffset ifNil: [0]) > 0]]) ifTrue: [splitter addRightOrBottom: morph]]]. splitter splitsLeftAndRight ifTrue: [ self submorphsDo: [:morph | ((morph ~= splitter and: [morph layoutFrame rightFraction = splitter layoutFrame leftFraction]) and: [morph layoutFrame hasFixedWidth not + or: [(morph layoutFrame leftOffset) < 0]]) - or: [(morph layoutFrame leftOffset ifNil: [0]) < 0]]) ifTrue: [splitter addLeftOrTop: morph]. ((morph ~= splitter and: [morph layoutFrame leftFraction = splitter layoutFrame rightFraction]) and: [morph layoutFrame hasFixedWidth not + or: [(morph layoutFrame rightOffset) > 0]]) - or: [(morph layoutFrame rightOffset ifNil: [0]) > 0]]) ifTrue: [splitter addRightOrBottom: morph]]]]! Item was changed: ----- Method: ProportionalSplitterMorph>>balanceOffsets (in category 'events') ----- balanceOffsets | fdx fdy | (self hasProperty: #fullDelta) ifFalse: [^ self]. fdx := (self valueOfProperty: #fullDelta) x. fdy := (self valueOfProperty: #fullDelta) y. 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)]. - 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)]. - tm bottom - (tm layoutFrame bottomOffset ifNil: [0])]. ctop := (self layoutFrame topFraction * (obot - otop)) rounded + + otop + (self layoutFrame topOffset). - + otop + (self layoutFrame topOffset ifNil: [0]). cbot := (self layoutFrame bottomFraction * (obot - otop)) rounded + + otop + (self layoutFrame bottomOffset). - + 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: self layoutFrame topOffset - fdy. self layoutFrame bottomOffset: self layoutFrame bottomOffset - fdy. (leftOrTop copy union: rightOrBottom) do: [:m | (m layoutFrame topFraction closeTo: topf) ifTrue: [ m layoutFrame topFraction: self layoutFrame topFraction. m layoutFrame topOffset: m layoutFrame topOffset - fdy]. (m layoutFrame bottomFraction closeTo: topf) ifTrue: [ m layoutFrame bottomFraction: self layoutFrame topFraction. m layoutFrame bottomOffset: m layoutFrame bottomOffset - fdy]]] . 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)]. - 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)]. - tm right - (tm layoutFrame rightOffset ifNil: [0])]. cleft := (self layoutFrame leftFraction * (oright - oleft)) rounded + + oleft + (self layoutFrame leftOffset). - + oleft + (self layoutFrame leftOffset ifNil: [0]). cright := (self layoutFrame rightFraction * (oright - oleft)) rounded + + oleft + (self layoutFrame rightOffset). - + 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: self layoutFrame leftOffset - fdx. self layoutFrame rightOffset: self layoutFrame rightOffset - fdx. (leftOrTop copy union: rightOrBottom) do: [:m | (m layoutFrame leftFraction closeTo: leftf) ifTrue: [ m layoutFrame leftFraction: self layoutFrame leftFraction. m layoutFrame leftOffset: m layoutFrame leftOffset - fdx]. (m layoutFrame rightFraction closeTo: leftf) ifTrue: [ m layoutFrame rightFraction: self layoutFrame leftFraction. m layoutFrame rightOffset: m layoutFrame rightOffset - fdx.]]] . self removeProperty: #fullDelta. owner layoutChanged ! Item was changed: ----- Method: ProportionalSplitterMorph>>repositionBy: (in category 'events') ----- repositionBy: delta | selfTop selfBottom selfLeft selfRight | self setProperty: #fullDelta toValue: ((self valueOfProperty: #fullDelta) ifNil: [0@0]) + delta. leftOrTop do: [ : each | | firstRight firstBottom firstLeft firstTop | + firstRight := each layoutFrame rightOffset. + firstBottom := each layoutFrame bottomOffset. - 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. - firstTop := each layoutFrame topOffset ifNil: [ 0 ]. each layoutFrame topOffset: firstTop + delta y ]. each layoutFrame hasFixedWidth ifTrue: [ + firstLeft := each layoutFrame leftOffset. - firstLeft := each layoutFrame leftOffset ifNil: [ 0 ]. each layoutFrame leftOffset: firstLeft + delta x. ] ]. rightOrBottom do: [ : each | | secondLeft secondTop secondRight secondBottom | + secondLeft := each layoutFrame leftOffset. + secondTop := each layoutFrame topOffset. - 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. - secondBottom := each layoutFrame bottomOffset ifNil: [ 0 ]. each layoutFrame bottomOffset: secondBottom + delta y. ]. each layoutFrame hasFixedWidth ifTrue: [ + secondRight := each layoutFrame rightOffset. - secondRight := each layoutFrame rightOffset ifNil: [ 0 ]. each layoutFrame rightOffset: secondRight + delta x. ] ]. + selfTop := self layoutFrame topOffset. + selfBottom := self layoutFrame bottomOffset. + selfLeft := self layoutFrame leftOffset. + selfRight := self layoutFrame rightOffset. - 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 ])! Item was changed: ----- Method: SystemWindow>>convertAlignment (in category 'layout') ----- convertAlignment "Primarily Jesse Welton's code to convert old system windows to ones with modern layout scheme" self layoutPolicy: ProportionalLayout new. (paneMorphs isNil or: [paneRects isNil or: [paneMorphs size ~= paneRects size]]) ifFalse: [self addLabelArea. self putLabelItemsInLabelArea. self setFramesForLabelArea. paneMorphs with: paneRects do: [:m :r | | frame | frame := LayoutFrame new. frame leftFraction: r left; rightFraction: r right; topFraction: r top; bottomFraction: r bottom. m layoutFrame: frame. m hResizing: #spaceFill; vResizing: #spaceFill]]. labelArea isNil ifTrue: [self addLabelArea. self putLabelItemsInLabelArea. self setFramesForLabelArea. paneMorphs ifNotNil: [paneMorphs do: [:m | | frame | frame := m layoutFrame ifNil: [LayoutFrame new]. + frame topOffset: (frame topOffset) - self labelHeight. - frame topOffset: (frame topOffset ifNil: [0]) - self labelHeight. frame bottomFraction ~= 1.0 ifTrue: + [frame bottomOffset: (frame bottomOffset) - self labelHeight]]]]. - [frame bottomOffset: (frame bottomOffset ifNil: [0]) - self labelHeight]]]]. label ifNotNil: [| frame | frame := LayoutFrame new. frame leftFraction: 0.5; topFraction: 0; leftOffset: label width negated // 2. label layoutFrame: frame]. collapseBox ifNotNil: [| frame | frame := LayoutFrame new. frame rightFraction: 1; topFraction: 0; rightOffset: -1; topOffset: 1. collapseBox layoutFrame: frame]. stripes ifNotNil: [| frame | frame := LayoutFrame new. frame leftFraction: 0; topFraction: 0; rightFraction: 1; leftOffset: 1; topOffset: 1; rightOffset: -1. stripes first layoutFrame: frame. stripes first height: self labelHeight - 2. stripes first hResizing: #spaceFill. frame := LayoutFrame new. frame leftFraction: 0; topFraction: 0; rightFraction: 1; leftOffset: 3; topOffset: 3; rightOffset: -3. stripes last layoutFrame: frame. stripes last height: self labelHeight - 6. stripes last hResizing: #spaceFill]. menuBox ifNotNil: [| frame | frame := LayoutFrame new. frame leftFraction: 0; leftOffset: 19; topFraction: 0; topOffset: 1. menuBox layoutFrame: frame]. closeBox ifNotNil: [| frame | frame := LayoutFrame new. frame leftFraction: 0; leftOffset: 4; topFraction: 0; topOffset: 1. closeBox layoutFrame: frame]! Item was changed: ----- Method: SystemWindow>>setPaneRectsFromBounds (in category 'geometry') ----- setPaneRectsFromBounds "Reset proportional specs from actual bounds, eg, after reframing panes" | layoutBounds | layoutBounds := self layoutBounds. paneMorphs do:[:m| | box left bottom top frame right | frame := m layoutFrame. box := m bounds. frame ifNotNil:[ + left := box left - layoutBounds left - frame leftOffset. + right := box right - layoutBounds left - frame rightOffset. + top := box top - layoutBounds top - frame topOffset. + bottom := box bottom - layoutBounds top - frame bottomOffset. - left := box left - layoutBounds left - (frame leftOffset ifNil:[0]). - right := box right - layoutBounds left - (frame rightOffset ifNil:[0]). - top := box top - layoutBounds top - (frame topOffset ifNil:[0]). - bottom := box bottom - layoutBounds top - (frame bottomOffset ifNil:[0]). frame leftFraction: (left / layoutBounds width asFloat). frame rightFraction: (right / layoutBounds width asFloat). frame topFraction: (top / layoutBounds height asFloat). frame bottomFraction: (bottom / layoutBounds height asFloat). ]. ].! |
Free forum by Nabble | Edit this page |