The Trunk: Morphic-tpr.1357.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-tpr.1357.mcz

commits-2
tim Rowledge uploaded a new version of Morphic to project The Trunk:
http://source.squeak.org/trunk/Morphic-tpr.1357.mcz

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

Name: Morphic-tpr.1357
Author: tpr
Time: 10 November 2017, 4:13:15.426389 pm
UUID: bb455ee7-dae9-458e-84bd-b99b1513e2a8
Ancestors: Morphic-mt.1356

Make the multi-column lists able to scroll horizontally

=============== Diff against Morphic-mt.1356 ===============

Item was changed:
  ----- Method: LazyListMorph>>hUnadjustedScrollRange (in category 'scroll range') -----
  hUnadjustedScrollRange
  "Ok, this is a bit messed up. We need to return the width of the widest item in the list. If we grab every item in the list, it defeats the purpose of LazyListMorph. If we don't, then we don't know the size.
 
  This is a compromise -- find the widest of the first 30 items, then double it, This width will be updated as new items are installed, so it will always be correct for the visible items. If you know a better way, please chime in."
 
  | itemsToCheck item index |
  "Check for a cached value"
  maxWidth ifNotNil:[^maxWidth].
 
  "Compute from scratch"
  itemsToCheck := 30 min: (listItems size).
  maxWidth := 0.
 
  "Check the first few items to get a representative sample of the rest of the list."
  index := 1.
  [index < itemsToCheck] whileTrue:
  [ item := self getListItem: index. "Be careful not to actually install this item"
+ maxWidth := maxWidth max: (self widthToDisplayItem: item).
- maxWidth := maxWidth max: (self widthToDisplayItem: item asStringOrText contents).
  index:= index + 1.
  ].
 
  "Add some initial fudge if we didn't check all the items."
  (itemsToCheck < listItems size) ifTrue:[maxWidth := maxWidth*2].
 
  ^maxWidth
  !

Item was changed:
  ----- Method: LazyListMorph>>item: (in category 'list access') -----
  item: index
  "return the index-th item, using the 'listItems' cache"
  | newItem itemWidth |
  (index between: 1 and: listItems size)
  ifFalse: [ "there should have been an update, but there wasn't!!"  ^self getListItem: index].
  (listItems at: index) ifNil: [
  newItem := self getListItem: index.
  "Update the width cache."
  maxWidth ifNotNil:[
+ itemWidth := self widthToDisplayItem: newItem.
- itemWidth := self widthToDisplayItem: newItem asStringOrText contents.
  itemWidth > maxWidth ifTrue:[
  maxWidth := itemWidth.
  self adjustWidth.
  ]].
  listItems at: index put: newItem ].
  ^listItems at: index!

Item was removed:
- ----- Method: MulticolumnLazyListMorph>>hUnadjustedScrollRange (in category 'scroll range') -----
- hUnadjustedScrollRange
- "multi column list morphs don't use hScrollbars"
-
- ^0
-
- !

Item was removed:
- ----- Method: PluggableMultiColumnListMorph>>itemFromPoint: (in category 'accessing') -----
- itemFromPoint: aPoint
- "Return the list element (morph) at the given point or nil if outside"
- | ptY |
- scroller hasSubmorphs ifFalse:[^nil].
- (scroller fullBounds containsPoint: aPoint) ifFalse:[^nil].
- ptY := (scroller firstSubmorph point: aPoint from: self) y.
- "note: following assumes that submorphs are vertical, non-overlapping, and ordered"
- scroller firstSubmorph top > ptY ifTrue:[^nil].
- scroller lastSubmorph bottom < ptY ifTrue:[^nil].
- "now use binary search"
- ^scroller submorphThat: [ :item | item top <= ptY and:[item bottom >= ptY] ] ifNone: [].
- !