The Trunk: Morphic-mt.1722.mcz

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

The Trunk: Morphic-mt.1722.mcz

commits-2
Marcel Taeumel uploaded a new version of Morphic to project The Trunk:
http://source.squeak.org/trunk/Morphic-mt.1722.mcz

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

Name: Morphic-mt.1722
Author: mt
Time: 16 February 2021, 10:10:46.500005 am
UUID: 5d63cf8f-7e43-4f77-8ab3-fb3239223af2
Ancestors: Morphic-eem.1721

Minor tweaks to icon cache in LazyList:
- Flag missing icons with #none to avoid repeated model access
- Support no-icon separator items, thus avoiding minor visual glitch (e.g., in Git Browser's list of branches)

Note that it felt right to format #iconExtent this way to emphasize the ordered variations of lazy init. =)

=============== Diff against Morphic-eem.1721 ===============

Item was changed:
  ----- Method: LazyListMorph>>icon: (in category 'list access - cached') -----
  icon: row
+ "Answer a cached form from the model at a specific row. By flagging nil-icons with #none, only try to fetch an icon once from the model until next #listChanged. Also do inst-var access on listIcons here to initialize it as late as possible."
- "Do inst-var access on listIcons here to initialize it as late as possible."
 
  self listSource canHaveIcons ifFalse: [^ nil].
 
  listIcons ifNil: [listIcons := Array new: self getListSize].
+
+ ^ (listIcons at: row)
+ ifNotNil: [:iconOrNone | iconOrNone == #none ifFalse: [iconOrNone]]
+ ifNil: [
+ | icon |
+ icon := (self getListIcon: row) ifNotNil: [:form | form scaleIconToDisplay].
+ "Update cache for uniform icon extent."
+ iconExtent ifNil: [iconExtent := icon ifNotNil: [icon extent]].
+ listIcons at: row put: (icon ifNil: [#none]).
+ icon]!
-
- ^ (listIcons at: row) ifNil: [
- | icon |
- icon := (self getListIcon: row) ifNotNil: [:form | form scaleIconToDisplay].
- "Update cache for uniform icon extent."
- iconExtent ifNil: [iconExtent := icon ifNotNil: [icon extent]].
- listIcons at: row put: icon.
- icon]!

Item was changed:
  ----- Method: LazyListMorph>>iconExtent (in category 'layout') -----
  iconExtent
+ "Answers the uniform icon extent for this lazy list based on sample icons from the list source."
 
+ | listSize |
+ iconExtent ifNil: [
+
+ self listSource canHaveIcons
+ ifFalse: [^ iconExtent := 0@0].
+
+ (listSize := self getListSize) = 0
+ ifTrue: [^ iconExtent := ((14@14) * RealEstateAgent scaleFactor) truncated].
+
+ (self icon: (2 min: listSize)) "mt: Use second item bc. first one might be visual separator w/o icon."
+ ifNil: [^ iconExtent := 0@0]
+ ifNotNil: [:form | ^ iconExtent := form extent]].
+
+ ^ iconExtent!
- ^ iconExtent ifNil: [
- self getListSize = 0
- ifTrue: [((14@14) * RealEstateAgent scaleFactor) truncated]
- ifFalse: [(self icon: 1) ifNil: [0@0] ifNotNil: [:form | form extent]]]!