[Pkg] The Trunk: Morphic-mt.1639.mcz

commits at source.squeak.org commits at source.squeak.org
Thu Apr 2 07:57:06 UTC 2020


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

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

Name: Morphic-mt.1639
Author: mt
Time: 2 April 2020, 9:57:01.627769 am
UUID: f6179063-73e6-7d47-b156-db672067b49a
Ancestors: Morphic-eem.1638

Fixes some unnecessary visual updates in lists, which caused extra (maybe expensive) model access:

(1) Menu invocation for list items should first check whether to update the selection and then ask the model #okToChange.
(2) Avoid scrolling to the selection to be visible if there is no change in the selection index.  Only make users aware of changes. Models can still force such scrolling with de-selecting and immediately selecting an item. --- If list contents changed, the list filter got updated and tried to re-select the same element in the (maybe filtered) list. That caused the redunant updates and scrolling.
(3) To make (2) work, the must not clear the selectedRow in LazyListMorph because PluggableListMorph has no own tracking of the selected row.

=============== Diff against Morphic-eem.1638 ===============

Item was changed:
  ----- Method: LazyListMorph>>listChanged (in category 'layout') -----
  listChanged
  	"set newList to be the list of strings to display"
  
  	listItems := nil.
  	listIcons := nil.
  	listFilterOffsets := nil.
  
  	maxWidth := nil.
  		
+ 	"selectedRow := nil. --- avoid reset to keep UI stable. See PluggableListMorph >> #selectionIndex and #selectionIndex:."
- 	selectedRow := nil.
  	selectedRows := PluggableSet integerSet.
  	preSelectedRow := nil.
  	
  	self layoutChanged.
  	self changed.
  !

Item was changed:
  ----- Method: PluggableListMorph>>mouseDown: (in category 'event handling') -----
  mouseDown: evt
  	| selectors row |
  	row := self rowAtLocation: evt position.
  
  	evt yellowButtonPressed  "First check for option (menu) click"
  		ifTrue: [
+ 			((self selectionIndex ~= row
+ 				and: [self class menuRequestUpdatesSelection])
+ 				and: [model okToChange]) ifTrue: [
+ 					"Models depend on the correct selection:"
+ 					self changeModelSelection: (self modelIndexFor: row)].
- 			(self class menuRequestUpdatesSelection and: [model okToChange]) ifTrue: [
- 				"Models depend on the correct selection:"
- 				self selectionIndex = row
- 					ifFalse: [self changeModelSelection: (self modelIndexFor: row)]].
  			
  			^ self yellowButtonActivity: evt shiftPressed].
  	row = 0  ifTrue: [^super mouseDown: evt].
  	"self dragEnabled ifTrue: [aMorph highlightForMouseDown]."
  	selectors := Array 
  		with: #click:
  		with: (doubleClickSelector ifNotNil:[#doubleClick:])
  		with: nil
  		with: (self dragEnabled ifTrue:[#startDrag:] ifFalse:[nil]).
  	evt hand waitForClicksOrDrag: self event: evt selectors: selectors threshold: HandMorph dragThreshold "pixels".!

Item was changed:
  ----- Method: PluggableListMorph>>selectionIndex: (in category 'selection') -----
  selectionIndex: viewIndex
  	"Called internally to select the index-th item."
  
+ 	self selectionIndex = viewIndex ifTrue: [^ self].
+ 
  	self unhighlightSelection.
  	self listMorph selectedRow: (viewIndex min: self listSize).
  	self highlightSelection.
  	
  	self scrollSelectionIntoView.!



More information about the Packages mailing list