[squeak-dev] The Inbox: ToolBuilder-Morphic-cbc.271.mcz
commits at source.squeak.org
commits at source.squeak.org
Mon Jan 11 19:45:18 UTC 2021
A new version of ToolBuilder-Morphic was added to project The Inbox:
http://source.squeak.org/inbox/ToolBuilder-Morphic-cbc.271.mcz
==================== Summary ====================
Name: ToolBuilder-Morphic-cbc.271
Author: cbc
Time: 11 January 2021, 11:45:17.6054 am
UUID: e3ae199a-f7cd-504e-9905-2afcf36dbdb1
Ancestors: ToolBuilder-Morphic-mt.270
Better estimated size:
- includes default cellInsert for listMorph
- includes boundary line size
Also tries to size for width of strings - at least, the first 15 samples.
=============== Diff against ToolBuilder-Morphic-mt.270 ===============
Item was changed:
----- Method: ListChooser>>buildWith: (in category 'building') -----
buildWith: builder
| dialogSpec searchBarHeight listSpec fieldSpec |
searchBarHeight := self searchBarHeight.
dialogSpec := builder pluggableDialogSpec new
model: self;
title: #title;
closeAction: #closed;
extent: self initialExtent;
autoCancel: true; "Behave like a pop-up menu. Historical reasons."
children: OrderedCollection new;
buttons: OrderedCollection new;
yourself.
listSpec := builder pluggableListSpec new.
listSpec
model: self;
list: #items;
getIndex: #selectedIndex;
setIndex: #selectedIndex:;
doubleClick: #accept;
"keystrokePreview: #keyStrokeFromList:;"
autoDeselect: false;
filterableList: true;
clearFilterAutomatically: false;
name: #list;
+ frame: (LayoutFrame fractions: (0 at 0 corner: 1 at 1) offsets: (0 at searchBarHeight corner: 0 at 0));
+ hScrollBarPolicy: #whenNeeded.
- frame: (LayoutFrame fractions: (0 at 0 corner: 1 at 1) offsets: (0 at searchBarHeight corner: 0 at 0)).
dialogSpec children add: listSpec.
fieldSpec := builder pluggableInputFieldSpec new.
fieldSpec
model: self;
name: #searchText ;
getText: #searchText;
editText: #searchText:;
setText: #acceptText:;
selection: #textSelection;
menu: nil;
indicateUnacceptedChanges: false;
askBeforeDiscardingEdits: false;
help: (self addAllowed ifTrue: ['Type new or filter existing...' translated] ifFalse: ['Type to filter existing...' translated]);
frame: (LayoutFrame fractions: (0 at 0 corner: 1 at 0) offsets: (0 at 0 corner: 0 at searchBarHeight)).
dialogSpec children add: fieldSpec.
"Buttons"
dialogSpec buttons add: (
builder pluggableButtonSpec new
model: self;
label: #acceptLabel;
action: #accept;
enabled: #canAcceptOrAdd;
color: #acceptColor).
dialogSpec buttons add: (
builder pluggableButtonSpec new
model: self;
label: 'Cancel';
action: #cancel;
color: #cancelColor).
dialogMorph := builder build: dialogSpec.
dialogMorph addKeyboardCaptureFilter: self ; positionOverWidgetNamed: #searchText.
listMorph := builder widgetAt: #list.
listMorph allowEmptyFilterResult: true.
^ dialogMorph!
Item was changed:
----- Method: ListChooser>>initialExtent (in category 'building') -----
initialExtent
+ | listFont itemCount width listBoxBoundaryLineSize defaultCellWidthIndex |
-
- | listFont itemCount maxItemSize cellSize |
listFont := Preferences standardListFont.
itemCount := items size.
+ listBoxBoundaryLineSize := 2.
+ defaultCellWidthIndex := 6. "3 before, 3 after, no height insert - taken from LazyListMorph, the underlying list morph"
+ width := ((items take: 15) collect: [:item| listFont widthOfString: item]) max.
+ width := width + listBoxBoundaryLineSize + defaultCellWidthIndex.
+ ^ (width min: (self currentWorld extent x * 0.75) asInteger max: ((listFont widthOf: $m) * 12))
+ @ ((itemCount min: 15 max: 5) * listFont height + self searchBarHeight + listBoxBoundaryLineSize)
+ !
- maxItemSize := items inject: 0 into: [:max :item | max max: item size].
- cellSize := (listFont widthOf: $m) @ listFont height.
-
- ^ ((maxItemSize + 1 "breathing space" min: 20 max: 10)
- @ (itemCount + 1 "breathing space" min: 15 max: 5)
- * cellSize) + (0@ self searchBarHeight)!
More information about the Squeak-dev
mailing list
|