[squeak-dev] The Trunk: ToolBuilder-Morphic-mt.297.mcz
commits at source.squeak.org
commits at source.squeak.org
Wed Feb 9 13:29:11 UTC 2022
Marcel Taeumel uploaded a new version of ToolBuilder-Morphic to project The Trunk:
http://source.squeak.org/trunk/ToolBuilder-Morphic-mt.297.mcz
==================== Summary ====================
Name: ToolBuilder-Morphic-mt.297
Author: mt
Time: 9 February 2022, 2:29:10.566754 pm
UUID: 257013f4-a906-5140-a1f9-49a7e14a7d63
Ancestors: ToolBuilder-Morphic-mt.296
Fixes a regression when constructing panels and windows through the tool builder. Splitters should go behind edge grips. Since all that extra stuff does "addMorphBack:" by default, splitters must be added last during construction.
Fixes preferred extent and the user of non-string objects in ListChooser and ListMultipleChooser. Also cleans up some code around #defaultTitle.
=============== Diff against ToolBuilder-Morphic-mt.296 ===============
Item was changed:
+ ----- Method: ListChooser class>>chooseFrom: (in category 'instance creation') -----
- ----- Method: ListChooser class>>chooseFrom: (in category 'ChooserTool compatibility') -----
chooseFrom: aList
+
^ self
chooseFrom: aList
title: self defaultTitle!
Item was changed:
+ ----- Method: ListChooser class>>chooseFrom:title: (in category 'instance creation') -----
- ----- Method: ListChooser class>>chooseFrom:title: (in category 'ChooserTool compatibility') -----
chooseFrom: aList title: aString
^ self
chooseIndexFrom: aList
title: aString
addAllowed: false!
Item was changed:
----- Method: ListChooser class>>chooseIndexFrom: (in category 'instance creation') -----
chooseIndexFrom: aList
+
^ self
chooseIndexFrom: aList
title: self defaultTitle!
Item was changed:
----- Method: ListChooser class>>chooseIndexFrom:title: (in category 'instance creation') -----
chooseIndexFrom: aList title: aString
+
^ self
chooseIndexFrom: aList
+ title: aString
- title: (aString isEmptyOrNil ifTrue: [ self defaultTitle ] ifFalse: [ aString ])
addAllowed: false!
Item was changed:
----- Method: ListChooser class>>chooseIndexFrom:title:addAllowed: (in category 'instance creation') -----
chooseIndexFrom: aList title: aString addAllowed: aBoolean
+
^ self new
chooseIndexFrom: aList
+ title: aString
- title: (aString isEmptyOrNil ifTrue: [ self defaultTitle ] ifFalse: [ aString ])
addAllowed: aBoolean!
Item was changed:
----- Method: ListChooser class>>chooseItemFrom: (in category 'instance creation') -----
chooseItemFrom: aList
+
^ self
chooseItemFrom: aList
title: self defaultTitle!
Item was changed:
----- Method: ListChooser class>>chooseItemFrom:title:addAllowed: (in category 'instance creation') -----
chooseItemFrom: aList title: aString addAllowed: aBoolean
+
^ self new
chooseItemFrom: aList
+ title: aString
- title: (aString isEmptyOrNil ifTrue: [ self defaultTitle ] ifFalse: [ aString ])
addAllowed: aBoolean!
Item was changed:
----- Method: ListChooser class>>defaultTitle (in category 'instance creation') -----
defaultTitle
+
+ ^ 'Please choose' translated!
- ^ 'Please choose:'!
Item was changed:
----- Method: ListChooser>>initialExtent (in category 'building') -----
initialExtent
| listFont itemCount maxItemSize cellSize |
listFont := Preferences standardListFont.
itemCount := items size.
maxItemSize := items inject: 0 into: [:max :item | max max: item asString size].
cellSize := (listFont widthOf: $m) @ listFont height.
+
+ ^ ((maxItemSize min: 20 max: 10) * (listFont widthOf: $m))
+ @ ((ToolBuilder default listHeightFor: (itemCount min: 15 max: 5))
+ + self searchBarHeight
+ + ToolBuilder default dialogSpacing)!
-
- ^ ((maxItemSize min: 20 max: 10)
- @ (itemCount min: 15 max: 5)
- * cellSize) + (0@ self searchBarHeight)!
Item was changed:
----- Method: ListChooser>>preferredExtent (in category 'building') -----
preferredExtent
| listFont cellSize |
listFont := Preferences standardListFont.
+ cellSize := (listFont widthOf: $x) @ listFont lineGridForMorphs.
- cellSize := (listFont widthOf: $m) @ listFont height.
+ ^ ((items inject: 0 into: [:max :item | max max: (listFont widthOfString: item asString)]) + cellSize x "breathing space")
+ @ ((ToolBuilder default listHeightFor: items size)
+ + self searchBarHeight
+ + ToolBuilder default dialogSpacing)!
- ^ ((items inject: 0 into: [:max :item | max max: (listFont widthOfString: item)])
- @ (items size * listFont height))
- + (0@ self searchBarHeight)!
Item was changed:
----- Method: ListChooser>>title (in category 'accessing') -----
title
+
+ ^ (title isNil or: [ title isEmpty ])
+ ifTrue: [ title := self class defaultTitle ]
+ ifFalse: [ title ]!
- ^ title ifNil: [ title := 'Please choose' translated ]!
Item was changed:
+ ----- Method: ListMultipleChooser class>>chooseFrom:title: (in category 'instance creation') -----
- ----- Method: ListMultipleChooser class>>chooseFrom:title: (in category 'ui requests') -----
chooseFrom: someLabels title: aString
^ self chooseIndexListFrom: someLabels title: aString!
Item was changed:
+ ----- Method: ListMultipleChooser class>>chooseIndexListFrom:title: (in category 'instance creation') -----
- ----- Method: ListMultipleChooser class>>chooseIndexListFrom:title: (in category 'ui requests') -----
chooseIndexListFrom: someObjects title: aString
^ self new
title: aString;
labels: (someObjects collect: [:ea | ea asString]);
choose!
Item was changed:
+ ----- Method: ListMultipleChooser class>>chooseItemListFrom:title: (in category 'instance creation') -----
- ----- Method: ListMultipleChooser class>>chooseItemListFrom:title: (in category 'ui requests') -----
chooseItemListFrom: someObjects title: aString
^ self new
title: aString;
labels: (someObjects collect: [:ea | ea asString]);
values: someObjects;
choose!
Item was added:
+ ----- Method: ListMultipleChooser class>>defaultTitle (in category 'instance creation') -----
+ defaultTitle
+
+ ^ 'Please choose multiple' translated!
Item was changed:
----- Method: ListMultipleChooser>>initialExtent (in category 'toolbuilder') -----
initialExtent
+ | listFont itemCount maxItemSize |
- | listFont itemCount maxItemSize cellSize |
listFont := Preferences standardListFont.
itemCount := labels size.
maxItemSize := labels inject: 0 into: [:max :item | max max: item asString size].
- cellSize := (listFont widthOf: $m) @ listFont height.
+ ^ ((maxItemSize min: 20 max: 10) * (listFont widthOf: $m))
+ @ (ToolBuilder default listHeightFor: (itemCount min: 15 max: 5))!
- ^ ((maxItemSize min: 20 max: 10)
- @ (itemCount min: 15 max: 5)
- * cellSize)!
Item was changed:
----- Method: ListMultipleChooser>>preferredExtent (in category 'toolbuilder') -----
preferredExtent
| listFont cellSize |
listFont := Preferences standardListFont.
+ cellSize := (listFont widthOf: $x) @ listFont lineGridForMorphs.
- cellSize := (listFont widthOf: $m) @ listFont height.
+ ^ ((labels inject: 0 into: [:max :item | max max: (listFont widthOfString: item asString)]) + cellSize x "breathing space")
+ @ (ToolBuilder default listHeightFor: labels size)!
- ^ ((labels inject: 0 into: [:max :item | max max: (listFont widthOfString: item)])
- @ (labels size * listFont height))!
Item was changed:
----- Method: ListMultipleChooser>>title (in category 'accessing') -----
title
+ ^ (title isNil or: [ title isEmpty ])
+ ifTrue: [ title := self class defaultTitle ]
+ ifFalse: [ title ]!
- ^ (title isNil or: [title isEmpty])
- ifFalse: [title]
- ifTrue: ['Choose multiple:']!
Item was changed:
----- Method: MorphicToolBuilder>>buildPluggablePanel: (in category 'widgets required') -----
buildPluggablePanel: aSpec
| widget |
widget := self panelClass new.
self register: widget id: aSpec name.
widget model: aSpec model.
"Set child dependent layout properties."
self setLayoutHintsFor: widget spec: aSpec.
widget layoutInset: (aSpec padding ifNil: [self panelPadding]).
"Flip the #wantsPaneSplitters flag only after all children where added."
widget cellGap: 0.
widget wantsPaneSplitters: false; wantsGrips: false.
widget removePaneSplitters; removeGrips.
"Now create the children."
aSpec children isSymbol
ifTrue: [
widget getChildrenSelector: aSpec children.
widget update: aSpec children]
ifFalse: [
self buildAll: aSpec children in: widget].
"Now that we have all children, let's add those splitters if necessary."
+ widget wantsPaneSplitters: (aSpec wantsResizeHandles ifNil: [false]).
widget cellGap: (aSpec spacing ifNil: [
+ widget wantsPaneSplitters
- (aSpec wantsResizeHandles ifNil: [false])
ifTrue: [self windowSpacing]
ifFalse: [self panelSpacing]]).
- widget wantsPaneSplitters: (aSpec wantsResizeHandles ifNil: [true]).
widget wantsPaneSplitters ifTrue: [widget addPaneSplitters].
"widget wantsGrips: true; addGrips."
self setFrame: aSpec frame in: widget.
self setLayout: aSpec layout in: widget.
parent ifNotNil:[self add: widget to: parent].
widget borderWidth: 0.
self buildHelpFor: widget spec: aSpec.
widget color: Color transparent.
^ widget!
Item was changed:
----- Method: MorphicToolBuilder>>buildPluggableWindow: (in category 'widgets required') -----
buildPluggableWindow: aSpec
| widget |
aSpec layout == #proportional ifFalse:[
"This needs to be implemented - probably by adding a single pane and then the rest"
^self error: 'Not implemented'.
].
widget := (self windowClassFor: aSpec) new.
self register: widget id: aSpec name.
widget model: aSpec model.
"Set child dependent layout properties."
MorphicProject worldGridEnabled ifTrue: [
"Snap both #position and #extent to grid."
aSpec horizontalResizing ifNil: [aSpec horizontalResizing: #spaceFill].
aSpec verticalResizing ifNil: [aSpec verticalResizing: #spaceFill]].
self setLayoutHintsFor: widget spec: aSpec.
widget layoutInset: (aSpec padding ifNil: [self windowPadding]).
widget morphicLayerNumber: widget class windowLayer.
"Performance. Flip the #wantsPaneSplitters flag only after all children where added."
widget cellGap: 0.
widget wantsPaneSplitters: false; wantsGrips: false.
widget removePaneSplitters; removeGrips.
"Now create the children."
panes := OrderedCollection new.
aSpec children isSymbol
ifTrue: [
widget getChildrenSelector: aSpec children.
widget update: aSpec children]
ifFalse: [
self buildAll: aSpec children in: widget].
widget setUpdatablePanesFrom: panes.
"Now that we have all children, let's add those splitters if necessary."
widget cellGap: (aSpec spacing ifNil: [self windowSpacing]).
+ widget wantsGrips: true; addGrips.
widget wantsPaneSplitters: (aSpec wantsResizeHandles ifNil: [true]).
widget wantsPaneSplitters ifTrue: [widget addPaneSplitters].
- widget wantsGrips: true; addGrips.
aSpec defaultFocus ifNotNil: [:name |
widget defaultFocusMorph: name].
aSpec label ifNotNil: [:label|
label isSymbol
ifTrue:[widget getLabelSelector: label]
ifFalse:[widget setLabel: label]].
aSpec multiWindowStyle notNil ifTrue:
[widget savedMultiWindowState: (SavedMultiWindowState on: aSpec model)].
widget closeWindowSelector: aSpec closeAction.
self buildHelpFor: widget spec: aSpec.
widget bounds: (RealEstateAgent
initialFrameFor: widget
initialExtent: (aSpec extent ifNil:[widget initialExtent])
world: self currentWorld).
widget refreshWindowColor.
^ widget!
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. Cancel value is 0.
There are several (historical) reasons for building a button dialog instead of a list chooser for small lists:
1) Unfortunately, there is existing code that uses this call to create simple confirmation dialogs with a list of #(yes no cancel).
2) Unfortunately, there is existing code that uses this call to mimick a drop-down menu with a (compact) pop-up menu."
self askForProvidedAnswerTo: aString ifSupplied: [:answer |
(answer = #cancel or: [answer isNil]) ifTrue: [^ 0].
^ aList indexOf: answer].
aList ifEmpty: [^ 0].
aList size <= 7 ifTrue: [
| dialog |
dialog := DialogWindow new
+ title: ListChooser defaultTitle;
- title: 'Please Choose' translated;
message: aString;
filterEnabled: true;
autoCancel: true; "Like a pop-up menu, click anywhere to dismiss."
yourself.
aList withIndexDo: [:ea :index |
dialog createButton: ea value: index].
dialog selectedButtonIndex: 1.
^ dialog getUserResponseAtHand ifNil: [0]].
^ ListChooser chooseFrom: aList title: aString!
More information about the Squeak-dev
mailing list
|