[Pkg] The Trunk: Morphic-cmm.523.mcz

commits at source.squeak.org commits at source.squeak.org
Sat Mar 5 19:57:22 UTC 2011


Chris Muller uploaded a new version of Morphic to project The Trunk:
http://source.squeak.org/trunk/Morphic-cmm.523.mcz

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

Name: Morphic-cmm.523
Author: cmm
Time: 5 March 2011, 1:56:18.722 pm
UUID: b7b0e4f4-5789-4ce8-85ba-4b58529dea75
Ancestors: Morphic-dtl.522

- Set HandMorph class>>'DragThreshold' back to 10 pixels.
- Allow LazyListMorphs to be populated with first-class Objects rather than just Strings.

=============== Diff against Morphic-dtl.522 ===============

Item was changed:
  ----- Method: HandMorph class>>initialize (in category 'class initialization') -----
  initialize
  	"HandMorph initialize"
- 
  	PasteBuffer := nil.
+ 	DoubleClickTime := 350 "milliseconds".
+ 	DragThreshold := 10 "pixels".
+ 	NormalCursor := CursorWithMask normal asCursorForm!
- 	DoubleClickTime := 350.
- 	DragThreshold := 0.
- 	NormalCursor := CursorWithMask normal asCursorForm.
- !

Item was changed:
  ----- Method: LazyListMorph>>drawOn: (in category 'drawing') -----
  drawOn: aCanvas
  	| |
  	listItems size = 0 ifTrue: [ ^self ].
   
  	self drawSelectionOn: aCanvas.
  
  	(self topVisibleRowForCanvas: aCanvas) to: (self bottomVisibleRowForCanvas: aCanvas) do: [ :row |
  		(listSource itemSelectedAmongMultiple:  row) ifTrue: [
  			self drawBackgroundForMulti: row on: aCanvas. ].
+ 		self display: (self item: row) asStringOrText atRow: row on: aCanvas.
- 		self display: (self item: row) atRow: row on: aCanvas.
  	].
  
  	listSource potentialDropRow > 0 ifTrue: [
  		self highlightPotentialDropRow: listSource potentialDropRow on: aCanvas ].!

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 asStringOrText contents).
- 		maxWidth := maxWidth max: (self widthToDisplayItem: item 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 asStringOrText contents.
- 			itemWidth := self widthToDisplayItem: newItem contents.
  			itemWidth > maxWidth ifTrue:[
  				maxWidth := itemWidth.
  				self adjustWidth.
  			]].
  		listItems at: index put: newItem ].
  	^listItems at: index!

Item was changed:
  ----- Method: LazyListMorph>>widthToDisplayItem: (in category 'scroll range') -----
+ widthToDisplayItem: item 
+ 	^ self font widthOfStringOrText: item asStringOrText!
- widthToDisplayItem: item
- 	^self font widthOfStringOrText: item
- 	!

Item was changed:
  ----- Method: PluggableListMorph>>getList (in category 'model access') -----
  getList
  	"Answer the list to be displayed.  Caches the returned list in the 'list' ivar"
+ 	getListSelector == nil ifTrue: [ ^ #() ].
- 	getListSelector == nil ifTrue: [^ #()].
  	list := model perform: getListSelector.
+ 	^ list ifNil: [ Array empty ]!
- 	list == nil ifTrue: [^ #()].
- 	list := list collect: [ :item | item asStringOrText ].
- 	^ list!

Item was changed:
  ----- Method: PluggableListMorph>>getListSelector: (in category 'initialization') -----
+ getListSelector: sel 
- getListSelector: sel
  	"Set the receiver's getListSelector as indicated, and trigger a recomputation of the list"
+ 	self
+ 		 setGetListSelector: sel ;
+ 		 changed ;
+ 		 updateList!
- 
- 	getListSelector := sel.
- 	self changed.
- 	self updateList.!

Item was changed:
  ----- Method: PluggableListMorph>>list: (in category 'initialization') -----
  list: listOfStrings  
  	"lex doesn't think this is used any longer, but is not yet brave enough to remove it.  It should be removed eventually"
  	
  	
  	"Set the receiver's list as specified"
  
  	| morphList h index converter aSelector textColor font loc |
+ self isThisEverCalled.
  	scroller removeAllMorphs.
  	list := listOfStrings ifNil: [Array new].
  	list isEmpty ifTrue: [self setScrollDeltas.  ^ self selectedMorph: nil].
  	"NOTE: we will want a quick StringMorph init message, possibly even
  		combined with event install and positioning"
  	font ifNil: [font := Preferences standardListFont].
  	converter := self valueOfProperty: #itemConversionMethod.
  	converter ifNil: [converter := #asStringOrText].
  	textColor := self valueOfProperty: #textColor.
  	morphList := list collect: [:each | | stringMorph item |
  		item := each.
  		item := item perform: converter.
  		stringMorph := item isText
  			ifTrue: [StringMorph contents: item font: font emphasis: (item emphasisAt: 1)]
  			ifFalse: [StringMorph contents: item font: font].
  		textColor ifNotNil: [ stringMorph color: textColor ].
  		stringMorph
  	].
  	
  	(aSelector := self valueOfProperty: #balloonTextSelectorForSubMorphs)
  		ifNotNil:
  			[morphList do: [:m | m balloonTextSelector: aSelector]].
  
  	self highlightSelector ifNotNil:
  		[model perform: self highlightSelector with: list with: morphList].
  
  	"Lay items out vertically and install them in the scroller"
  	h := morphList first height "self listItemHeight".
  	loc := 0 at 0.
  	morphList do: [:m | m bounds: (loc extent: 9999 at h).  loc := loc + (0 at h)].
  	scroller addAllMorphs: morphList.
  
  	index := self getCurrentSelectionIndex.
  	self selectedMorph: ((index = 0 or: [index > morphList size]) ifTrue: [nil] ifFalse: [morphList at: index]).
  	self setScrollDeltas.
  	scrollBar setValue: 0.0!



More information about the Packages mailing list