[Pkg] The Trunk: ToolBuilder-Morphic-dtl.81.mcz

commits at source.squeak.org commits at source.squeak.org
Wed Sep 28 23:46:21 UTC 2011

David T. Lewis uploaded a new version of ToolBuilder-Morphic to project The Trunk:

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

Name: ToolBuilder-Morphic-dtl.81
Author: dtl
Time: 28 September 2011, 7:45:59.81 pm
UUID: fabb7fd0-be16-4540-a80e-6234dfc664b0
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 four packages.

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

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

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

- 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).
- Instance var #style was added to PluggableButtonMorph, so must also update #veryDeepInner: to match (problem detected by DeepCopier>>checkClass: called from ChangeSet>>fileOutClassDefinition:on:).

=============== 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].

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 Packages mailing list