The Trunk: Morphic-mt.917.mcz

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

The Trunk: Morphic-mt.917.mcz

commits-2
Marcel Taeumel uploaded a new version of Morphic to project The Trunk:
http://source.squeak.org/trunk/Morphic-mt.917.mcz

==================== Summary ====================

Name: Morphic-mt.917
Author: mt
Time: 24 April 2015, 10:54:23.6 am
UUID: 5e3702bb-9618-af43-b615-01e9e637d205
Ancestors: Morphic-mt.916

Cleaned-up and fixed the interface for setting the minimum extent in morphs. That extent is now correctly honored in the proportional layout.

Lists and text fields have now a minimum extent that supports seeing at least something of their contents. (Thanks to Chris for this idea.)

=============== Diff against Morphic-mt.916 ===============

Item was changed:
  ----- Method: Morph>>layoutProportionallyIn: (in category 'layout') -----
  layoutProportionallyIn: newBounds
  "Layout specific. Apply the given bounds to the receiver."
  | box frame |
  frame := self layoutFrame ifNil:[^self].
  "compute the cell size the receiver has given its layout frame"
+
  box := frame layout: self bounds in: newBounds.
+ box := box topLeft extent: (box extent max: self minExtent).
+
  (box = self bounds) ifTrue:[^self]. "no change"
  ^self layoutInBounds: box.!

Item was changed:
  ----- Method: Morph>>minExtent (in category 'layout') -----
  minExtent
  "Layout specific. Return the minimum size the receiver can be represented in.
  Implementation note: When this message is sent from an owner trying to lay out its children it will traverse down the morph tree and recompute the minimal arrangement of the morphs based on which the minimal extent is returned. When a morph with some layout strategy is encountered, the morph will ask its strategy to compute the new arrangement. However, since the final size given to the receiver is unknown at the point of the query, the assumption is made that the current bounds of the receiver are the base on which the layout should be computed. This scheme prevents strange layout changes when for instance, a table is contained in another table. Unless the inner table has been resized manually (which means its bounds are already enlarged) the arrangement of the inner table will not change here. Thus the entire layout computation is basically an iterative process which may have different results depending on the incremental changes applied."
 
  | layout minExtent extra hFit vFit |
  hFit := self hResizing.
  vFit := self vResizing.
  (hFit == #spaceFill or: [vFit == #spaceFill])
  ifFalse:
  ["The receiver will not adjust to parents layout by growing or shrinking,
  which means that an accurate layout defines the minimum size."
 
  ^self fullBounds extent].
 
  "An exception -- a receiver with #shrinkWrap constraints but no children is being treated #rigid (the equivalent to a #spaceFill receiver in a non-layouting owner)"
  self hasSubmorphs
  ifFalse:
  [hFit == #shrinkWrap ifTrue: [hFit := #rigid].
  vFit == #shrinkWrap ifTrue: [vFit := #rigid]].
  layout := self layoutPolicy.
  layout isNil
+ ifTrue: [minExtent := 0@0]
- ifTrue: [minExtent := 0 @ 0]
  ifFalse: [minExtent := layout minExtentOf: self in: self layoutBounds].
+
  hFit == #rigid
  ifTrue: [minExtent := self fullBounds extent x @ minExtent y]
  ifFalse:
  [extra := self bounds width - self layoutBounds width.
  minExtent := (minExtent x + extra) @ minExtent y].
+ vFit == #rigid
+ ifTrue: [minExtent := minExtent x @ self fullBounds extent y]
+ ifFalse:
+ [extra := self bounds height - self layoutBounds height.
+ minExtent := minExtent x @ (minExtent y + extra)].
+
+ ^ minExtent max: self minWidth @ self minHeight!
- minExtent := vFit == #rigid
- ifTrue: [minExtent x @ self fullBounds extent y]
- ifFalse:
- [extra := self bounds height - self layoutBounds height.
- minExtent x @ (minExtent y + extra)].
- minExtent := minExtent max: self minWidth @ self minHeight.
- ^minExtent!

Item was added:
+ ----- Method: Morph>>minExtent: (in category 'layout') -----
+ minExtent: aPoint
+
+ self error: 'Use #minimumExtent: if you want to set a minimum extent. #minExtent is a layout policy-specific callback.'!

Item was changed:
  ----- Method: Morph>>minHeight (in category 'layout') -----
  minHeight
  "answer the receiver's minHeight"
  ^ self
  valueOfProperty: #minHeight
+ ifAbsent: [1]!
- ifAbsent: [2]!

Item was changed:
  ----- Method: Morph>>minWidth (in category 'layout') -----
  minWidth
  "answer the receiver's minWidth"
  ^ self
  valueOfProperty: #minWidth
+ ifAbsent: [1]!
- ifAbsent: [2]!

Item was changed:
  ----- Method: Morph>>minimumExtent (in category 'geometry') -----
  minimumExtent
+
+ ^ self minWidth @ self minHeight!
- | ext |
- "This returns the minimum extent that the morph may be shrunk to.  Not honored in too many places yet, but respected by the resizeToFit feature, at least.  copied up from SystemWindow 6/00"
- (ext := self valueOfProperty: #minimumExtent)
- ifNotNil:
- [^ ext].
- ^ 100 @ 80!

Item was changed:
  ----- Method: Morph>>minimumExtent: (in category 'geometry') -----
  minimumExtent: aPoint
+ "Do not shrink below this extent."
- "Remember a minimumExtent, for possible future use"
 
+ self
+ minWidth: aPoint x;
+ minHeight: aPoint y.!
- self setProperty: #minimumExtent toValue: aPoint
- !

Item was added:
+ ----- Method: Morph>>minimumHeight (in category 'geometry') -----
+ minimumHeight
+ "Wrapper for layout-specific function to avoid confusion."
+
+ ^ self minHeight!

Item was added:
+ ----- Method: Morph>>minimumHeight: (in category 'geometry') -----
+ minimumHeight: aNumber
+ "Wrapper for layout-specific function to avoid confusion."
+
+ self minHeight: aNumber.!

Item was added:
+ ----- Method: Morph>>minimumWidth (in category 'geometry') -----
+ minimumWidth
+ "Wrapper for layout-specific function to avoid confusion."
+
+ ^ self minWidth!

Item was added:
+ ----- Method: Morph>>minimumWidth: (in category 'geometry') -----
+ minimumWidth: aNumber
+ "Wrapper for layout-specific function to avoid confusion."
+
+ self minWidth: aNumber.!

Item was removed:
- ----- Method: PluggableButtonMorph>>minExtent (in category 'geometry') -----
- minExtent
-
- | hMin vMin |
- self label isMorph
- ifTrue: [^ super minExtent max: self label minExtent].
-
- hMin := vMin := 16.
- self hResizing == #shrinkWrap
- ifTrue: [hMin := (self font widthOfString: self label) max: self labelShrinkThreshold].
- self vResizing == #shrinkWrap
- ifTrue: [vMin := self font height].
-
- ^ super minExtent max: ((0@0 corner: hMin @ vMin) outsetBy: self layoutInset) extent!

Item was added:
+ ----- Method: PluggableButtonMorph>>minHeight (in category 'layout') -----
+ minHeight
+
+ | vMin |
+ self label isMorph
+ ifTrue: [^ super minHeight max: self label minHeight].
+
+ vMin := 16.
+ self vResizing == #shrinkWrap
+ ifTrue: [vMin := self font height].
+
+ self layoutInset isRectangle
+ ifTrue: [vMin := vMin + self layoutInset top + self layoutInset bottom]
+ ifFalse: [self layoutInset isPoint
+ ifTrue: [vMin := vMin + (2* self layoutInset y)]
+ ifFalse: [vMin := vMin + (2* self layoutInset)]].
+ ^ super minHeight max: vMin!

Item was added:
+ ----- Method: PluggableButtonMorph>>minWidth (in category 'layout') -----
+ minWidth
+
+ | hMin |
+ self label isMorph
+ ifTrue: [^ super minWidth max: self label minWidth].
+
+ hMin := 16.
+ self hResizing == #shrinkWrap
+ ifTrue: [hMin := (self font widthOfString: self label) max: self labelShrinkThreshold].
+
+ self layoutInset isRectangle
+ ifTrue: [hMin := hMin + self layoutInset left + self layoutInset right]
+ ifFalse: [self layoutInset isPoint
+ ifTrue: [hMin := hMin + (2* self layoutInset x)]
+ ifFalse: [hMin := hMin + (2* self layoutInset)]].
+ ^ super minWidth max: hMin!

Item was changed:
  ----- Method: PluggableListMorph>>font: (in category 'initialization') -----
  font: aFontOrNil
+
  self listMorph font: aFontOrNil.
+
+ self minimumWidth: (self font widthOf: $m) * 5.
  !

Item was changed:
+ ----- Method: PluggableListMorph>>initialize (in category 'initialization') -----
- ----- Method: PluggableListMorph>>initialize (in category 'geometry') -----
  initialize
  super initialize.
+
+ self minimumWidth: (self font widthOf: $m) * 5.
+ self minimumHeight: (TextStyle default lineGrid * 3). !
- self minWidth: 38!

Item was changed:
  ----- Method: PluggableTextMorph>>initialize (in category 'initialization') -----
  initialize
  "initialize the state of the receiver"
  super initialize.
  hasUnacceptedEdits := false.
  hasEditingConflicts := false.
  askBeforeDiscardingEdits := true.
+
+ self minimumWidth: (TextStyle defaultFont widthOf: $m) * 10.
+ self minimumHeight: (TextStyle default lineGrid * 4). !
- !

Item was added:
+ ----- Method: TextMorph>>minHeight (in category 'layout') -----
+ minHeight
+
+ | result |
+ textStyle ifNil: [^ 16].
+ borderWidth ifNil: [^ 16].
+
+ result := (textStyle lineGrid + 2) + (borderWidth*2).
+ margins ifNil: [^ result].
+
+ ^ margins isRectangle
+ ifTrue: [result + margins top + margins bottom]
+ ifFalse: [margins isPoint
+ ifTrue: [result + margins y + margins y]
+ ifFalse: [result + (2*margins)]]!

Item was added:
+ ----- Method: TextMorph>>minWidth (in category 'layout') -----
+ minWidth
+
+ | result |
+ textStyle ifNil: [^ 9].
+ borderWidth ifNil: [^ 9].
+
+ result := 9 + (borderWidth*2).
+ margins ifNil: [^ result].
+
+ ^ margins isRectangle
+ ifTrue: [result + margins left + margins right]
+ ifFalse: [margins isPoint
+ ifTrue: [result + margins x + margins x]
+ ifFalse: [result + (2*margins)]]!

Item was removed:
- ----- Method: TextMorph>>minimumExtent (in category 'geometry') -----
- minimumExtent
- | minExt |
- textStyle ifNil: [^ 9@16].
- borderWidth ifNil: [^ 9@16].
- minExt := (9@(textStyle lineGrid+2)) + (borderWidth*2).
- margins ifNil: [^ minExt].
- ^ ((0@0 extent: minExt) expandBy: margins) extent!