[Pkg] The Trunk: ToolBuilder-MVC-dtl.31.mcz
commits at source.squeak.org
commits at source.squeak.org
Wed Feb 20 03:58:09 UTC 2013
David T. Lewis uploaded a new version of ToolBuilder-MVC to project The Trunk:
http://source.squeak.org/trunk/ToolBuilder-MVC-dtl.31.mcz
==================== Summary ====================
Name: ToolBuilder-MVC-dtl.31
Author: dtl
Time: 19 February 2013, 10:51:13.557 pm
UUID: 96dcb7a3-1c37-4703-b421-a64778703082
Ancestors: ToolBuilder-MVC-dtl.30
Make proportionally spaced buttons work in MVC. Fixes missing buttons on the debug notifier.
If the spec for a widget has a frame that is a LayoutFrame rather than a Rectangle, then it is intended to be scaled within the boundaries of a containing widget. The spec does not contain size hints in this case. Subviews (e.g. buttons in a horizontal layout) are created with initial window size matching the superview. Resize the subview windows such that the subviews are contained within the superview window.
Also allow for a pluggable button to have an initial label (evaluate label selector at view creation) to serve as a size hint in view construction.
=============== Diff against ToolBuilder-MVC-dtl.30 ===============
Item was changed:
----- Method: MVCToolBuilder>>buildPluggableButton: (in category 'pluggable widgets') -----
buildPluggableButton: aSpec
| widget label state |
label := aSpec label.
state := aSpec state.
widget := PluggableButtonView on: aSpec model
getState: (state isSymbol ifTrue:[state])
action: aSpec action
label: (label isSymbol ifTrue:[label]).
self register: widget id: aSpec name.
+ label isSymbol
+ ifTrue: [widget label: (aSpec model perform: label)]
+ ifFalse: [widget label: label].
- (label isSymbol or:[label == nil]) ifFalse:[widget label: label].
self setFrame: aSpec frame in: widget.
parent ifNotNil:[parent addSubView: widget].
^widget!
Item was added:
+ ----- Method: MVCToolBuilder>>positionSubviewsWithin: (in category 'private') -----
+ positionSubviewsWithin: widget
+ "Translate subviews to position the viewport of each subView relative to
+ the widget window origin. If subviews are repositioned, as in a row of button
+ views arranged within a view, then the transformations will later be rescaled
+ to fit the subviews within the widget window."
+
+ widget subViews ifNotNilDo: [:subViews |
+ subViews isEmpty ifFalse: [ | translation |
+ translation := widget window origin - subViews first window origin.
+ subViews do: [:v |
+ v setTransformation: (v transformation translateBy: translation)]]].
+ !
Item was changed:
----- Method: MVCToolBuilder>>setLayout:in: (in category 'private') -----
setLayout: layout in: widget
+ "Arrange subview horizontally or vertically according to layout directive.
+ If the subview dimensions were specified with layout frames rather than explicit
+ rectangle sizes, then their window horizontal or vertical dimensions will be resized
+ as needed to fit within the widget extent."
+ self positionSubviewsWithin: widget.
- "translate subviews to position viewport"
- widget subViews ifNotNilDo: [:subViews |
- subViews isEmpty ifFalse: [ | translation |
- translation := widget window origin - subViews first window origin.
- subViews do: [:v |
- v setTransformation: (v transformation translateBy: translation)]]].
-
layout == #proportional ifTrue:[^self].
layout == #horizontal ifTrue:[
+ | prev subViewWidth widgetWidth xScale |
+ subViewWidth := (widget subViews collect: [:e | e window extent x]) sum.
+ widgetWidth := widget window extent x.
+ xScale := widgetWidth / subViewWidth. "to adjust corner of prev prior to align:"
- | prev |
prev := nil.
+ widget subViews do:[:next| | newWindowWidth newCorner |
+ prev ifNotNil:[ "resize prev window prior to aligning next"
+ xScale < 1 ifTrue: [ "proportional placement spec requires resizing"
+ newWindowWidth := (prev window extent x * xScale) truncated.
+ newCorner := (prev window origin x + newWindowWidth)@(prev window corner y).
+ prev setWindow: (prev window origin corner: newCorner)].
- widget subViews do:[:next|
- prev ifNotNil:[
next align: next viewport topLeft with: prev viewport topRight.
].
prev := next.
].
^self].
layout == #vertical ifTrue:[
+ | prev subViewHeight widgetHeight yScale |
+ subViewHeight := (widget subViews collect: [:e | e window extent y]) sum.
+ widgetHeight := widget window extent y.
+ yScale := widgetHeight / subViewHeight. "to adjust corner of prev prior to align:"
- | prev |
prev := nil.
+ widget subViews do:[:next| | newWindowHeight newCorner |
+ prev ifNotNil:[ "resize prev window prior to aligning next"
+ yScale < 1 ifTrue: [ "proportional placement spec requires resizing"
+ newWindowHeight := (prev window extent y * yScale) truncated.
+ newCorner := (prev window corner x)@(prev window origin y + newWindowHeight).
+ prev setWindow: (prev window origin corner: newCorner)].
- widget subViews do:[:next|
- prev ifNotNil:[
next align: next viewport topLeft with: prev viewport bottomLeft.
].
prev := next.
].
^self].
^self error: 'Unknown layout: ', layout.!
More information about the Packages
mailing list