Marcel Taeumel uploaded a new version of Morphic to project The Trunk:
http://source.squeak.org/trunk/Morphic-mt.1524.mcz ==================== Summary ==================== Name: Morphic-mt.1524 Author: mt Time: 19 September 2019, 4:47:08.121125 pm UUID: 883ea759-a904-dd42-8549-8f2c64cae163 Ancestors: Morphic-mt.1523 Layout fixes and layout-configuration robustness: - Makes ScrollPane compatible with #shrinkWrap - Adds checks for common layout properties to guard against common mistakes such as "shrinkWrap" vs. "srinkWrap" and "spaceFill" vs. "spaceFIll". - Adds missing #layoutChanged calls to ScrollPane - Better commentary in TransformMorph >> #layoutBounds - Makes the ScrollPane's TransformMorph (i.e. scroller) have the resizing properties (#shrinkWrap/#spaceFill) as applied in ScrollPane >> #doLayoutIn:, which is a custom layout strategy - not a policy. =============== Diff against Morphic-mt.1523 =============== Item was changed: ----- Method: Morph>>cellSpacing: (in category 'layout-properties') ----- cellSpacing: aSymbol "Layout specific. This property describes how the cell size for each element in a list should be computed. #globalRect - globally equal rectangular cells #globalSquare - globally equal square cells #localRect - locally (e.g., per row/column) equal rectangular cells #localSquare - locally (e.g., per row/column) equal square cells #none - cells are sized based on available row/column constraints " + self checkCellSpacingProperty: aSymbol. - self assert: aSymbol isSymbol. "Guard against a common mistake." self assureTableProperties cellSpacing: aSymbol. self layoutChanged.! Item was added: + ----- Method: Morph>>checkCellSpacingProperty: (in category 'layout') ----- + checkCellSpacingProperty: aSymbol + + aSymbol == #none ifTrue: [^ self]. + + aSymbol == #globalRect ifTrue: [^ self]. + aSymbol == #globalSquare ifTrue: [^ self]. + aSymbol == #localRect ifTrue: [^ self]. + aSymbol == #localSquare ifTrue: [^ self]. + + Error signal: 'Invalid cell-spacing property. Use #none, #globalRect, #globalSquare, #localRect, or #localSquare.'.! Item was added: + ----- Method: Morph>>checkListSpacingProperty: (in category 'layout') ----- + checkListSpacingProperty: aSymbol + + aSymbol == #none ifTrue: [^ self]. + aSymbol == #equal ifTrue: [^ self]. + + Error signal: 'Invalid value for list-spacing property. Use #none or #equal.'.! Item was added: + ----- Method: Morph>>checkResizingProperty: (in category 'layout') ----- + checkResizingProperty: aSymbol + + aSymbol == #rigid ifTrue: [^ self]. + aSymbol == #shrinkWrap ifTrue: [^ self]. + aSymbol == #spaceFill ifTrue: [^ self]. + + Error signal: 'Invalid value for resizing property. Use #rigid, #shrinkWrap, or #spaceFill.'.! Item was changed: ----- Method: Morph>>hResizing: (in category 'layout-properties') ----- hResizing: aSymbol "Layout specific. This property describes how the receiver should be resized with respect to its owner and its children. Possible values are: #rigid - do not resize the receiver #spaceFill - resize to fill owner's available space #shrinkWrap - resize to fit children " + self checkResizingProperty: aSymbol. self assureLayoutProperties hResizing: aSymbol. self layoutChanged. ! Item was changed: ----- Method: Morph>>listSpacing: (in category 'layout-properties') ----- listSpacing: aSymbol "Layout specific. This property describes how the heights for different rows in a table layout should be handled. #equal - all rows have the same height #none - all rows may have different heights " + self checkListSpacingProperty: aSymbol. - self assert: aSymbol isSymbol. "Guard against a common mistake." self assureTableProperties listSpacing: aSymbol. self layoutChanged.! Item was changed: ----- Method: Morph>>vResizing: (in category 'layout-properties') ----- vResizing: aSymbol "Layout specific. This property describes how the receiver should be resized with respect to its owner and its children. Possible values are: #rigid - do not resize the receiver #spaceFill - resize to fill owner's available space #shrinkWrap - resize to fit children " + self checkResizingProperty: aSymbol. self assureLayoutProperties vResizing: aSymbol. self layoutChanged. ! Item was changed: ----- Method: ScrollPane>>alwaysShowHScrollBar (in category 'accessing options') ----- alwaysShowHScrollBar self hScrollBarPolicy: #always. - self hHideOrShowScrollBar. ! Item was changed: ----- Method: ScrollPane>>alwaysShowVScrollBar (in category 'accessing options') ----- alwaysShowVScrollBar self vScrollBarPolicy: #always. - self vHideOrShowScrollBar. ! Item was added: + ----- Method: ScrollPane>>checkScrollBarPolicy: (in category 'layout') ----- + checkScrollBarPolicy: aSymbol + + aSymbol == #never ifTrue: [^ self]. + aSymbol == #whenNeeded ifTrue: [^ self]. + aSymbol == #always ifTrue: [^ self]. + + Error signal: 'Invalid value for scrollbar policy. Use #never, #whenNeeded, or #always.'.! Item was changed: ----- Method: ScrollPane>>doLayoutIn: (in category 'layout') ----- doLayoutIn: layoutBounds "Manually layout my submorphs. Maybe we can find a proper layout policy in the future." + "1) Let submorph's #shrinkWrap first if they want to." + self submorphsDo: [:m | m fullBounds]. + self removeProperty: #doLayoutAgain. self updateLayout. + super doLayoutIn: layoutBounds. - - "Do one additional run if required." - (self hasProperty: #doLayoutAgain) - ifTrue: [self updateLayout]. + "Do one additional run if required." + (self hasProperty: #doLayoutAgain) ifTrue: [ + self updateLayout. + super doLayoutIn: layoutBounds].! - super doLayoutIn: layoutBounds.! Item was changed: ----- Method: ScrollPane>>extentToFit (in category 'geometry') ----- extentToFit "Resize scroll pane to exactly fit its contents." | offset | offset := 0@0. (retractableScrollBar not and: [self vScrollBarPolicy == #always]) ifTrue: [offset := (self scrollBarThickness - self borderWidth) @ offset y]. (retractableScrollBar not and: [self hScrollBarPolicy == #always]) ifTrue: [offset := offset x @ (self scrollBarThickness - self borderWidth)]. + ^ scroller submorphBounds extent + offset + (2* (self borderWidth @ self borderWidth))! - ^ scroller submorphBoundsForShrinkWrap extent + offset + (2* (self borderWidth @ self borderWidth))! Item was added: + ----- Method: ScrollPane>>hResizing: (in category 'layout') ----- + hResizing: aSymbol + "Pass #shrinkWrap property to scroller to make this scroll pane's layout work. See #doLayoutIn:." + + super hResizing: aSymbol. + + scroller hResizing: (aSymbol == #shrinkWrap + ifTrue: [#shrinkWrap] + ifFalse: [#spaceFill]).! Item was changed: ----- Method: ScrollPane>>hScrollBarPolicy: (in category 'accessing') ----- hScrollBarPolicy: aSymbol "#always, #never, #whenNeeded" + hScrollBarPolicy = aSymbol ifTrue: [^ self]. + self checkScrollBarPolicy: aSymbol. + + hScrollBarPolicy := aSymbol. + self layoutChanged.! - hScrollBarPolicy := aSymbol.! Item was changed: ----- Method: ScrollPane>>initializeScrollBars (in category 'initialization') ----- initializeScrollBars "Initialize vertical and horizontal scroll bars." (scrollBar := ScrollBar on: self getValue: nil setValue: #vScrollBarValue:) menuSelector: #vScrollBarMenuButtonPressed:; orientation: #vertical; extent: 1@1. (hScrollBar := ScrollBar on: self getValue: nil setValue: #hScrollBarValue:) menuSelector: #hScrollBarMenuButtonPressed:; orientation: #horizontal; extent: 1@1. "" + scroller := TransformMorph new + color: Color transparent; + hResizing: #spaceFill; + vResizing: #spaceFill. - scroller := TransformMorph new color: Color transparent. scroller offset: 0 @ 0. self addMorph: scroller. "" retractableScrollBar ifFalse: [self addMorph: scrollBar; addMorph: hScrollBar]. self updateMinimumExtent.! Item was added: + ----- Method: ScrollPane>>submorphBoundsForShrinkWrap (in category 'layout') ----- + submorphBoundsForShrinkWrap + "No need to consider scrollbars because those are placed outside the #innerBounds like a border. See #resizeScroller." + + ^ scroller bounds! Item was changed: ----- Method: ScrollPane>>updateLayout (in category 'layout') ----- updateLayout "Manually layout my submorphs. Maybe we can find a proper layout policy in the future." + "If the scroller happens to have a layout policy, we should compute its layout before updating the scroll bars" + self resizeScroller. + self scroller fullBounds. + self resizeScrollBars; - resizeScroller; adjustOffset; setScrollDeltas. + + + ! - - "If the scroller happens to have a layout policy, we should compute its layout before any additional run." - self scroller fullBounds.! Item was added: + ----- Method: ScrollPane>>vResizing: (in category 'layout') ----- + vResizing: aSymbol + "Pass #shrinkWrap property to scroller to make this scroll pane's layout work. See #doLayoutIn:." + + super vResizing: aSymbol. + + scroller vResizing: (aSymbol == #shrinkWrap + ifTrue: [#shrinkWrap] + ifFalse: [#spaceFill]).! Item was changed: ----- Method: ScrollPane>>vScrollBarPolicy: (in category 'accessing') ----- vScrollBarPolicy: aSymbol "#always, #never, #whenNeeded" + vScrollBarPolicy = aSymbol ifTrue: [^ self]. + self checkScrollBarPolicy: aSymbol. + + vScrollBarPolicy := aSymbol. + self layoutChanged.! - vScrollBarPolicy := aSymbol.! Item was changed: ----- Method: TransformMorph>>layoutBounds (in category 'layout') ----- layoutBounds + "Ignore scaling and offset but move to local origin for my children as reference point. Note that we do not have to adapt #submorphBoundsForShrinkWrap because those are already in local coordinates." - "Ignore scaling and offset but move to local origin for my children as reference point." ^ super layoutBounds translateBy: self topLeft negated! |
Free forum by Nabble | Edit this page |