[Pkg] The Trunk: Morphic-mt.1875.mcz
commits at source.squeak.org
commits at source.squeak.org
Tue Feb 8 12:37:15 UTC 2022
Marcel Taeumel uploaded a new version of Morphic to project The Trunk:
http://source.squeak.org/trunk/Morphic-mt.1875.mcz
==================== Summary ====================
Name: Morphic-mt.1875
Author: mt
Time: 8 February 2022, 1:37:10.706027 pm
UUID: b91fdd53-e5b1-fd49-a279-e117795cdea2
Ancestors: Morphic-mt.1874
Complements ToolBuilder-Kernel-mt.152
=============== Diff against Morphic-mt.1874 ===============
Item was added:
+ ----- Method: BorderedMorph>>addCellGapToLayoutFrames (in category 'resize handling') -----
+ addCellGapToLayoutFrames
+
+ self changeCellGapOfLayoutFrames: self cellGap.!
Item was added:
+ ----- Method: BorderedMorph>>addGrips (in category 'resize handling') -----
+ addGrips
+ "Always add both corner grips and edge grips."
+
+ self removeGrips.
+
+ self addCornerGrips.
+ self addEdgeGrips. !
Item was added:
+ ----- Method: BorderedMorph>>changeCellGapOfLayoutFrames: (in category 'resize handling') -----
+ changeCellGapOfLayoutFrames: delta
+ "Enumerate all submorphs' #layoutFrame and change their offsets the amount of the receiver's #cellGap to that #addPaneSplitters can work. NOTE THAT not fully general-purpose and the rules a little bit hacky, currently optimized for horizontal text fields and button rows that have a fixed height besides a resizable widget such as other text fields or lists. Most challenging layouts include MessageNames and MCOperationsBrowser (incl. variations)."
+
+ | frames |
+ delta = 0 ifTrue: [^ self].
+
+ "For robustness, only work on submorphs that have their layout frame set."
+ frames := self paneMorphs
+ select: [:ea | ea layoutFrame notNil]
+ thenCollect: [:ea | ea layoutFrame].
+
+ frames ifEmpty: [^ self].
+
+ "Sort all frames to prioritize the ones with fixed height, e.g., button rows or one-liners."
+ frames := frames sorted: [:a :b |
+ (a hasFixedHeight and: [b hasFixedHeight not])
+ or: [a hasFixedHeight = b hasFixedHeight
+ and: [a topFraction < b topFraction]] ].
+
+ "Enumerate all frames and add the gap by changing the corresponding offsets."
+ frames do: [:thisFrame |
+ | left right bottom top |
+
+ "First, the easy part. Left and right offsets."
+ left := thisFrame leftOffset.
+ right := thisFrame rightOffset.
+
+ thisFrame leftFraction = 0
+ ifFalse: [ "Add a spacing to the frame if it is not top or leftmost."
+ left := left + delta]
+ ifTrue: [ "Expect another, resizable widget besides me if I have a fixed width."
+ thisFrame hasFixedWidth ifTrue: [right := right - delta]].
+
+ "Second, the tricky part. Optimized for fixed button rows and text lines."
+ bottom := thisFrame bottomOffset.
+ top := thisFrame topOffset.
+
+ thisFrame topFraction = 0 ifTrue: [ "Special treatment for the topmost row"
+ (frames anySatisfy: [:otherFrame | otherFrame ~~ thisFrame
+ "Is there any otherFrame that hasFixedHeight with whom thisFrame shares the topFraction?"
+ and: [otherFrame hasFixedHeight
+ and: [otherFrame leftFraction <= thisFrame leftFraction
+ and: [otherFrame rightFraction >= thisFrame rightFraction
+ and: [otherFrame topFraction = thisFrame topFraction]]]] ])
+ ifTrue: [ "Okay, make room for that otherFrame."
+ top := top + delta.
+ thisFrame hasFixedHeight ifTrue: [
+ "If thisFrame happens to be fixed too, be sure to not change its height."
+ bottom := bottom + delta ]] ].
+
+ (frames anySatisfy: [:otherFrame | otherFrame ~~ thisFrame
+ "Is there any otherFrame that hasFixedHeight with whom thisFrame shares the bottomFraction?"
+ and: [otherFrame hasFixedHeight
+ and: [otherFrame leftFraction <= thisFrame leftFraction
+ and: [otherFrame rightFraction >= thisFrame rightFraction
+ and: [otherFrame bottomFraction = thisFrame bottomFraction]]]] ])
+ ifTrue: [ "Okay, make room for that otherFrame."
+ bottom := bottom - delta.
+ thisFrame hasFixedHeight ifTrue: [
+ "If thisFrame happens to be fixed too, be sure to not change its height."
+ top := top - delta ]].
+
+ thisFrame bottomFraction ~= 1 ifTrue: [ "Basic treatment for all (inner) rows"
+ (thisFrame hasFixedHeight not or: [thisFrame topFraction ~= 0])
+ ifTrue: [ "All inner frames whould make room at the bottom except for topmost fixed ones, which we already treated above."
+ bottom := bottom - delta.
+ thisFrame hasFixedHeight ifTrue: [
+ "If thisFrame happens to be fixed too, be sure to not change its height."
+ top := top - delta ]] ].
+
+ "We are finished. Remember the new offsets."
+ thisFrame
+ topOffset: top;
+ bottomOffset: bottom;
+ leftOffset: left;
+ rightOffset: right].
+
+ self layoutChanged.!
Item was added:
+ ----- Method: BorderedMorph>>cornerGrips (in category 'resize handling') -----
+ cornerGrips
+
+ ^ self submorphsSatisfying: [:each | (each isKindOf: CornerGripMorph) and: [(each isKindOf: BorderGripMorph) not]]!
Item was added:
+ ----- Method: BorderedMorph>>edgeGrips (in category 'resize handling') -----
+ edgeGrips
+
+ ^ self submorphsSatisfying: [:each | each isKindOf: BorderGripMorph]!
Item was added:
+ ----- Method: BorderedMorph>>removeCellGapFromLayoutFrames (in category 'resize handling') -----
+ removeCellGapFromLayoutFrames
+
+ self changeCellGapOfLayoutFrames: self cellGap negated.!
Item was added:
+ ----- Method: BorderedMorph>>wantsGrips (in category 'resize handling') -----
+ wantsGrips
+
+ ^ self valueOfProperty: #allowGrips ifAbsent: [true]!
Item was added:
+ ----- Method: BorderedMorph>>wantsGrips: (in category 'resize handling') -----
+ wantsGrips: aBoolean
+
+ self setProperty: #allowGrips toValue: aBoolean.!
More information about the Packages
mailing list