[squeak-dev] The Inbox: ToolBuilder-Morphic-cbc.270.mcz
marcel.taeumel at hpi.de
Mon Jan 11 10:27:13 UTC 2021
>From my experience with the codebase in Squeak 3 and 4, any magic buffers such as "20" and "40" should be avoided for the sake of HI-DPI and hard-to-debug UI glitches. Deriving such buffers from the current font metrics seems to be more robust. Note that, in general, I am not opposed to giving content "more space to breathe" :-)
Having to iterate over all items in a list is too costly for larger lists. The LazyListMorph attempt to only consider a sample proved to entail annoying UI glitches such as shaky UI elements while scrolling.
Here are some numbers:
font := TextStyle defaultFont.
items := SystemNavigation default allClasses collect: [:class | class name].
[items do: [:item | font widthOfString: item]] bench.
'718 per second. 1.39 milliseconds per run. 0 % GC time.'
[(20 * (font widthOf: $m))@(15 * font height)] bench.
'22,000,000 per second. 45.4 nanoseconds per run. 2.47901 % GC time.'
Having milliseconds for a simple thing such as #initialExtent is really an issue for snappy GUIs because, for example, there are only 25 milliseconds for a frame in 40 FPS.
All in all, you are oppsed to always make room for 15 items and (roughly) 20 characters per item. So, I suggest that we could make the 15 derived from the actual number of items ... plus 1-2 if you want to leave more whitespace. For the 20, I would suggest to only count the number of characters and multiply with that width-of-$m. For performance reasons:
[items inject: 0 into: [:max :item | max max: item size]] bench.
'30,200 per second. 33.1 microseconds per run. 0.05999 % GC time.'
Yes, we could watch out for the size of #currentWorld, as you suggested. But this already happens via RealEstateAgent class >> maximumUsableAreaInWorld: as well as sends of #translatedToBeWithin: to a world's bounds. No need to duplicate and scatter those constraints all over the code base. :-) ... That said ... I think there is a bug in DialogWindow >> #moveToPreferredPosition and also in its initial extent. DialogWindow does not talk to RealEstateAgent at all ...
P.S.: How can you know that "item" is something that works with #widthOfString:? :-) Could be an instance of Text, for example.
Am 08.01.2021 20:27:56 schrieb commits at source.squeak.org <commits at source.squeak.org>:
A new version of ToolBuilder-Morphic was added to project The Inbox:
==================== Summary ====================
Time: 8 January 2021, 11:27:47.8204 am
Set the initial extent of the ListChooser to not require resizing the dialog for reasonable sized lists (i.e., expand it so you can see all of the list).
At the small end, still object MT's suggested size; at the large end, will not take up more the 3/4ths of the world size.
=============== Diff against ToolBuilder-Morphic-mt.269 ===============
Item was changed:
----- Method: ListChooser>>initialExtent (in category 'building') -----
+ | listFont width height |
- | listFont |
listFont := Preferences standardListFont.
+ width := (items collect: [:item| listFont widthOfString: item]) max + 20 "Acutal size of items plus dialog buffer left/right"
+ max: (20 * (listFont widthOf: $m)). "but we want a not-too-small box as well"
+ height := ((items size max: 15) * listFont height) + 40. "for various other stuff in dialog above/below list"
+ "But, don't use the whole world."
+ width := width min: (self currentWorld extent x * 0.75) asInteger.
+ height := height min: (self currentWorld extent y * 0.75) asInteger.
+ ^ width at height!
- ^ (20 * (listFont widthOf: $m))@(15 * listFont height)!
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Squeak-dev