The Trunk: ToolBuilder-Morphic-ar.42.mcz

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

The Trunk: ToolBuilder-Morphic-ar.42.mcz

commits-2
Andreas Raab uploaded a new version of ToolBuilder-Morphic to project The Trunk:
http://source.squeak.org/trunk/ToolBuilder-Morphic-ar.42.mcz

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

Name: ToolBuilder-Morphic-ar.42
Author: ar
Time: 10 December 2009, 12:27:33 pm
UUID: 8475c341-b9e6-d344-aabb-492b26a6f1ed
Ancestors: ToolBuilder-Morphic-ar.41

Use a simple chooser tool instead of menus for lists that are very long. Makes it easier to find things since scrolling is required anyway.

=============== Diff against ToolBuilder-Morphic-ar.41 ===============

Item was added:
+ ----- Method: ChooserTool>>itemList: (in category 'accessing') -----
+ itemList: aCollection
+ items := aCollection.
+ self changed: #items.!

Item was added:
+ ----- Method: ChooserTool>>itemList (in category 'accessing') -----
+ itemList
+ ^items!

Item was added:
+ ----- Method: ChooserTool>>buildWindowWith:specs: (in category 'toolbuilder') -----
+ buildWindowWith: builder specs: specs
+ | windowSpec rect action widgetSpec |
+ windowSpec := self buildWindowWith: builder.
+ specs do:[:assoc|
+ rect := assoc key.
+ action := assoc value.
+ widgetSpec := action value.
+ widgetSpec ifNotNil:[
+ widgetSpec frame: rect.
+ windowSpec children add: widgetSpec]].
+ ^windowSpec!

Item was added:
+ ----- Method: ChooserTool>>itemListIndex (in category 'accessing') -----
+ itemListIndex
+ ^index ifNil:[0]!

Item was added:
+ ----- Method: ChooserTool>>label: (in category 'accessing') -----
+ label: aString
+ label := aString.!

Item was added:
+ Model subclass: #ChooserTool
+ instanceVariableNames: 'label items index builder window'
+ classVariableNames: ''
+ poolDictionaries: ''
+ category: 'ToolBuilder-Morphic'!
+
+ !ChooserTool commentStamp: 'ar 12/9/2009 23:46' prior: 0!
+ A simple chooser tool for Morphic. Useful when menus just get too long.!

Item was changed:
  ----- Method: MorphicUIManager>>chooseFrom:values:lines:title: (in category 'ui requests') -----
  chooseFrom: labelList values: valueList lines: linesArray title: aString
  "Choose an item from the given list. Answer the selected item."
+ | index |
+ labelList size > 30 ifTrue:[
+ "No point in displaying more than 30 items as list. Use ChooserTool insted"
+ index := ChooserTool chooseFrom: labelList title: aString.
+ ^ index = 0 ifFalse:[valueList at: index].
+ ] ifFalse:[
+ ^MenuMorph chooseFrom: labelList values: valueList lines: linesArray title: aString
+ ].!
- ^MenuMorph chooseFrom: labelList values: valueList lines: linesArray title: aString!

Item was added:
+ ----- Method: ChooserTool>>canAccept (in category 'accessing') -----
+ canAccept
+ ^self itemListIndex > 0!

Item was added:
+ ----- Method: ChooserTool>>buildWith: (in category 'toolbuilder') -----
+ buildWith: aBuilder
+ | windowSpec |
+ builder := aBuilder.
+ windowSpec := self buildWindowWith: builder specs: {
+ (0@0 corner: 1@0.9) -> [self buildChooserListWith: builder].
+ (0@0.9 corner: 1@1) -> [self buildButtonsWith: builder].
+ }.
+ windowSpec closeAction: #closed.
+ windowSpec extent: 250@350.
+ ^builder build: windowSpec!

Item was added:
+ ----- Method: ChooserTool>>buildButtonsWith: (in category 'toolbuilder') -----
+ buildButtonsWith: aBuilder
+ | panel button |
+ panel := aBuilder pluggablePanelSpec new
+ model: self;
+ layout: #proportional;
+ children: OrderedCollection new.
+ button := aBuilder pluggableButtonSpec new.
+ button
+ model: self;
+ label: 'Accept';
+ action: #accept;
+ enabled: #canAccept;
+ frame: (0.0 @ 0.0 corner: 0.48@1).
+ panel children add: button.
+
+ button := aBuilder pluggableButtonSpec new.
+ button
+ model: self;
+ label: 'Cancel';
+ action: #cancel;
+ frame: (0.52 @ 0.0 corner: 1@1).
+ panel children add: button.
+ ^panel!

Item was added:
+ ----- Method: ChooserTool>>chooseFrom:title: (in category 'initialize') -----
+ chooseFrom: labelList title: aString
+ builder := ToolBuilder default.
+ self itemList: labelList.
+ self label: aString.
+ window := ToolBuilder default open: self.
+ window center: Sensor cursorPoint.
+ window setConstrainedPosition: (Sensor cursorPoint - (window fullBounds extent // 2)) hangOut: false.
+ builder runModal: window.
+ ^self itemListIndex!

Item was added:
+ ----- Method: ChooserTool>>buildChooserListWith: (in category 'toolbuilder') -----
+ buildChooserListWith: builder
+ | listSpec |
+ listSpec := builder pluggableListSpec new.
+ listSpec
+ model: self;
+ list: #itemList;
+ getIndex: #itemListIndex;
+ setIndex: #itemListIndex:;
+ autoDeselect: false.
+ ^listSpec
+ !

Item was added:
+ ----- Method: ChooserTool>>cancel (in category 'actions') -----
+ cancel
+ "Cancel the dialog and move on"
+ index := 0.
+ builder ifNotNil:[builder close: window].!

Item was added:
+ ----- Method: ChooserTool class>>chooseFrom:title: (in category 'tools') -----
+ chooseFrom: labelList title: aString
+ ^self new chooseFrom: labelList title: aString!

Item was added:
+ ----- Method: ChooserTool class>>open (in category 'opening') -----
+ open
+ ^ToolBuilder open: self!

Item was added:
+ ----- Method: ChooserTool>>accept (in category 'actions') -----
+ accept
+ "Accept current selection and move on"
+ builder ifNotNil:[:bldr|
+ builder := nil.
+ bldr close: window].!

Item was changed:
  ----- Method: MorphicUIManager>>chooseFrom:lines:title: (in category 'ui requests') -----
  chooseFrom: aList lines: linesArray title: aString
  "Choose an item from the given list. Answer the index of the selected item."
+ aList size > 30 ifTrue:[
+ "No point in displaying more than 30 items as list. Use ChooserTool insted"
+ ^ChooserTool chooseFrom: aList title: aString.
+ ] ifFalse:[
+ ^MenuMorph chooseFrom: aList lines: linesArray title: aString
+ ].!
- ^MenuMorph chooseFrom: aList lines: linesArray title: aString!

Item was added:
+ ----- Method: ChooserTool>>itemListIndex: (in category 'accessing') -----
+ itemListIndex: newIndex
+ index := newIndex.
+ self changed: #itemListIndex.
+ self changed: #canAccept.!

Item was added:
+ ----- Method: ChooserTool>>buildWindowWith: (in category 'toolbuilder') -----
+ buildWindowWith: builder
+ | windowSpec |
+ windowSpec := builder pluggableWindowSpec new.
+ windowSpec model: self.
+ windowSpec label: #labelString.
+ windowSpec children: OrderedCollection new.
+ ^windowSpec!

Item was added:
+ ----- Method: ChooserTool>>label (in category 'accessing') -----
+ label
+ ^label!

Item was added:
+ ----- Method: ChooserTool>>closed (in category 'actions') -----
+ closed
+ "Cancel the dialog and move on"
+ builder ifNotNil:[index := 0].!

Item was added:
+ ----- Method: ChooserTool>>labelString (in category 'accessing') -----
+ labelString
+ ^label!