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

commits at source.squeak.org commits at source.squeak.org
Sat Sep 24 19:52:22 UTC 2011


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

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

Name: ToolBuilder-Morphic-dtl.80
Author: dtl
Time: 24 September 2011, 3:52:18.656 pm
UUID: 77cf5284-48b0-4d47-89c2-3a34a7380e50
Ancestors: ToolBuilder-Morphic-ul.79

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 three 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.

=============== Diff against ToolBuilder-Morphic-ul.79 ===============

Item was changed:
  ----- Method: MorphicToolBuilder>>buildPluggableButton: (in category 'pluggable widgets') -----
  buildPluggableButton: aSpec
  	| widget label state action enabled |
  	label := aSpec label.
  	state := aSpec state.
  	action := aSpec action.
  	widget := self buttonClass on: aSpec model
  				getState: (state isSymbol ifTrue:[state])
  				action: nil
  				label: (label isSymbol ifTrue:[label]).
+ 	widget style: aSpec style.
+ 	aSpec changeLabelWhen
+ 		ifNotNilDo: [ :event | widget whenChanged: event update: aSpec label].
  	self register: widget id: aSpec name.
  	enabled := aSpec enabled.
  	enabled isSymbol
  		ifTrue:[widget getEnabledSelector: enabled]
  		ifFalse:[widget enabled:enabled].
  	widget action: action.
  	widget getColorSelector: aSpec color.
  	widget offColor: Color white..
  	self buildHelpFor: widget spec: aSpec. 
  	(label isSymbol or:[label == nil]) ifFalse:[widget label: label].
  	self setFrame: aSpec frame in: widget.
  	parent ifNotNil:[self add: widget to: parent].
  	^widget!

Item was changed:
  PluggableButtonMorph subclass: #PluggableButtonMorphPlus
+ 	instanceVariableNames: 'enabled action getColorSelector getEnabledSelector updateMap'
- 	instanceVariableNames: 'enabled action getColorSelector getEnabledSelector'
  	classVariableNames: ''
  	poolDictionaries: ''
  	category: 'ToolBuilder-Morphic'!
  
  !PluggableButtonMorphPlus commentStamp: 'ar 2/11/2005 21:53' prior: 0!
  An extended version of PluggableButtonMorph supporting enablement, color and block/message actions.!

Item was changed:
  ----- Method: PluggableButtonMorphPlus>>update: (in category 'updating') -----
  update: what
  	what ifNil:[^self].
  	what == getLabelSelector ifTrue: [
  		self label: (model perform: getLabelSelector)].
  	what == getEnabledSelector ifTrue:[^self enabled: (model perform: getEnabledSelector)].
  
  	getColorSelector ifNotNil: [ | cc |
  		color = (cc := model perform: getColorSelector) ifFalse:[
  			color := cc.
  			self onColor: color offColor: color.
  			self changed.
  		].
  	].
  	self getModelState
  			ifTrue: [self color: onColor]
  			ifFalse: [self color: offColor].
  	getEnabledSelector ifNotNil:[
  		self enabled: (model perform: getEnabledSelector).
  	].
+ 	updateMap ifNotNil:
+ 		[(updateMap at: what ifAbsent: [])
+ 			ifNotNilDo: [ :newTarget | ^self update: newTarget]].
  !

Item was added:
+ ----- Method: PluggableButtonMorphPlus>>updateMap (in category 'updating') -----
+ updateMap
+ 	^ updateMap ifNil: [updateMap := Dictionary new]
+ !

Item was added:
+ ----- Method: PluggableButtonMorphPlus>>whenChanged:update: (in category 'updating') -----
+ whenChanged: notification update: target
+ 	"On receipt of a notification, such as #contents notification from a CodeHolder,
+ 	invoke an update as if target had been the original notification."
+ 
+ 	self updateMap at: notification put: target!




More information about the Squeak-dev mailing list