[squeak-dev] The Inbox: Morphic-dtl.578.mcz

commits at source.squeak.org commits at source.squeak.org
Wed Sep 28 01:24:21 UTC 2011


A new version of Morphic was added to project The Inbox:
http://source.squeak.org/inbox/Morphic-dtl.578.mcz

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

Name: Morphic-dtl.578
Author: dtl
Time: 27 September 2011, 9:17:23.611 pm
UUID: 971e10f9-55bf-4d02-9e08-873e797f6e04
Ancestors: Morphic-laza.577

Provide updating button for "what to show" button on CodeHolder, similar to Squeak 3.8 behavior. This button activates a menu, and displays the resulting menu selection. For the default look, normal buttons are rounded and the menu activation button is square (vice versa if the "Rounded Button Corners" preference is disabled). When menu selection is changed, the button label displays the selected mode ('source', 'decompile', 'bytecodes' etc).

Changes are in four packages.

ToolBuilder-Kernel:
- Add PluggableButtonSpec>>style to provide style hint. Used to suggest that a button should be rendered differently, in this case rounded versus square corners.
- Add changeLableWhen: to connect pluggable button with change notification, in this case to allow update: #contents to result in a label update in the dependent button.

ToolBuilder-Morphic:
- Add #whenChanged:update: as a mechanism for hooking change events to button updates, allowing an individual button to respond to e.g. self changed: #contents in the model.
- Update MorphicToolBuilder>>buildPluggableButton to make use of style and changeLabelWhen in the widget spec.

Tools:
 - Update CodeHolder>>buildCodeProvenanceButtonWith: to add style hint for round/ square corners and changeLableWhen: for change notification to the widget spec.

Note: ToolBuilder has PluggableDropDownListSpec which is presumably intended to describe a drop-down list widget. This is currently unused in the image, but in future might provide a better approach than the current action button with menu approach.

Morphic:
- Let style hint control rounded versus square corners for a PluggableButtonMorph. May be used as a visual cue to distinguish simple action buttons from buttons that invoke a selection menu (e.g. "what to show" button for a CodeHolder).

=============== Diff against Morphic-laza.577 ===============

Item was changed:
  AlignmentMorph subclass: #PluggableButtonMorph
+ 	instanceVariableNames: 'model label getStateSelector actionSelector getLabelSelector getMenuSelector shortcutCharacter askBeforeChanging triggerOnMouseDown offColor onColor feedbackColor showSelectionFeedback allButtons arguments argumentsProvider argumentsSelector style'
- 	instanceVariableNames: 'model label getStateSelector actionSelector getLabelSelector getMenuSelector shortcutCharacter askBeforeChanging triggerOnMouseDown offColor onColor feedbackColor showSelectionFeedback allButtons arguments argumentsProvider argumentsSelector'
  	classVariableNames: 'RoundedButtonCorners'
  	poolDictionaries: ''
  	category: 'Morphic-Pluggable Widgets'!
  
  !PluggableButtonMorph commentStamp: '<historical>' prior: 0!
  A PluggableButtonMorph is a combination of an indicator for a boolean value stored in its model and an action button. The action of a button is often, but not always, to toggle the boolean value that it shows. Its pluggable selectors are:
  
  		getStateSelector		fetch a boolean value from the model
  		actionSelector		invoke this button's action on the model
  		getLabelSelector		fetch this button's lable from the model
  		getMenuSelector		fetch a pop-up menu for this button from the model
  
  Any of the above selectors can be nil, meaning that the model does not supply behavior for the given action, and the default behavior should be used. For example, if getStateSelector is nil, then this button shows the state of a read-only boolean that is always false.
  
  The model informs its view(s) of changes by sending #changed: to itself with getStateSelector as a parameter. The view tells the model when the button is pressed by sending actionSelector.
  
  If the actionSelector takes one or more arguments, then the following are relevant:
  		arguments			A list of arguments to provide when the actionSelector is called.
  		argumentsProvider	The object that is sent the argumentSelector to obtain arguments, if dynamic
  		argumentsSelector	The message sent to the argumentProvider to obtain the arguments.
  
  Options:
  	askBeforeChanging		have model ask user before allowing a change that could lose edits
  	triggerOnMouseDown	do this button's action on mouse down (vs. up) transition
  	shortcutCharacter		a place to record an optional shortcut key
  !

Item was changed:
  ----- Method: PluggableButtonMorph>>drawOn: (in category 'drawing') -----
  drawOn: aCanvas 
  	| cc gradient borderColor |
  	cc := self color.
  	cc isTransparent ifTrue:[cc := Color gray: 0.9].
  	self enabled ifFalse:[cc := Color lightGray].
  	cc brightness > 0.9 ifTrue:[cc := cc adjustBrightness: 0.9 - cc brightness].
  	showSelectionFeedback ifTrue:[
  		borderColor := cc muchDarker.
  		gradient := GradientFillStyle ramp: {
  			0.0 -> cc muchDarker.
  			0.1-> (cc adjustBrightness: -0.2).
  			0.5 -> cc.
  			0.9-> (cc adjustBrightness: -0.1).
  			1 -> cc muchDarker.
  		}.
  	] ifFalse:[
  		borderColor := Color lightGray.
  		gradient := GradientFillStyle ramp: {
  			0.0 -> Color white.
  			0.1-> (cc adjustBrightness: 0.05).
  			0.6 -> (cc darker).
  		}
  	].
  	gradient origin: bounds topLeft.
  	gradient direction: 0 at self height.
+ 	^ self roundedButtonCorners
- 	^ self class roundedButtonCorners
  		ifTrue: [aCanvas 
  				frameAndFillRoundRect: bounds 
  				radius: 8 
  				fillStyle: gradient 
  				borderWidth: 1 
  				borderColor: borderColor]
  		ifFalse: [aCanvas 
  				frameAndFillRectangle: self innerBounds 
  				fillColor: gradient asColor 
  				borderWidth: 1 
  				borderColor: borderColor darker;
  				fillRectangle: (self innerBounds insetBy: 1) 
  				fillStyle: gradient]!

Item was added:
+ ----- Method: PluggableButtonMorph>>roundedButtonCorners (in category 'drawing') -----
+ roundedButtonCorners
+ 	"If the button is intended to invoke a menu for selection, provide a visual
+ 	distinction by inverting the rounded corners attribute."
+ 	^self class roundedButtonCorners
+ 		xor: style == #menuButton!

Item was added:
+ ----- Method: PluggableButtonMorph>>style (in category 'accessing') -----
+ style
+ 	"Treat aSymbol as a hint to modify the button appearance."
+ 	^style
+ !

Item was added:
+ ----- Method: PluggableButtonMorph>>style: (in category 'accessing') -----
+ style: aSymbol
+ 	"Use aSymbol as a hint to modify the button appearance."
+ 	style := aSymbol
+ !




More information about the Squeak-dev mailing list