The Trunk: Morphic-kb.652.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-kb.652.mcz

commits-2
Balázs Kósi uploaded a new version of Morphic to project The Trunk:
http://source.squeak.org/trunk/Morphic-kb.652.mcz

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

Name: Morphic-kb.652
Author: kb
Time: 22 May 2013, 4:50:12.27 pm
UUID: 73334963-ccc3-4f41-8fec-fc64d40db333
Ancestors: Morphic-fbs.651

Implementation of pre selection highlight in PluggableListMorph. See the discussion here: http://lists.squeakfoundation.org/pipermail/squeak-dev/2013-May/171143.html

=============== Diff against Morphic-fbs.651 ===============

Item was changed:
  Morph subclass: #LazyListMorph
+ instanceVariableNames: 'listItems listIcons font selectedRow selectedRows preSelectedRow listSource maxWidth'
+ classVariableNames: 'ListPreSelectionColor ListSelectionColor ListSelectionTextColor'
- instanceVariableNames: 'listItems listIcons font selectedRow selectedRows listSource maxWidth'
- classVariableNames: 'ListSelectionColor ListSelectionTextColor'
  poolDictionaries: ''
  category: 'Morphic-Widgets'!
 
  !LazyListMorph commentStamp: 'efc 8/6/2005 11:34' prior: 0!
  The morph that displays the list in a PluggableListMorph.  It is "lazy" because it will only request the list items that it actually needs to display.
 
  I will cache the maximum width of my items in maxWidth to avoid this potentially expensive and frequent computation.!

Item was added:
+ ----- Method: LazyListMorph class>>listPreSelectionColor (in category 'preferences') -----
+ listPreSelectionColor
+ <preference: 'List Pre Selection Color'
+ category: 'colors'
+ description: 'Governs the color of pre selection highlight in lists'
+ type: #Color>
+ ^ ListPreSelectionColor ifNil: [Color r: 0.9 g: 0.9 b: 0.9]!

Item was changed:
  ----- Method: LazyListMorph>>drawOn: (in category 'drawing') -----
  drawOn: aCanvas
  | |
  listItems size = 0 ifTrue: [ ^self ].
   
+ self
+ drawPreSelectionOn: aCanvas;
+ drawSelectionOn: aCanvas.
- 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) atRow: row on: aCanvas.
  ].
 
  listSource potentialDropRow > 0 ifTrue: [
  self highlightPotentialDropRow: listSource potentialDropRow on: aCanvas ].!

Item was added:
+ ----- Method: LazyListMorph>>drawPreSelectionOn: (in category 'drawing') -----
+ drawPreSelectionOn: aCanvas
+
+ self
+ drawSelectionFor: preSelectedRow
+ withColor: self class listPreSelectionColor
+ on: aCanvas!

Item was added:
+ ----- Method: LazyListMorph>>drawSelectionFor:withColor:on: (in category 'drawing') -----
+ drawSelectionFor: index withColor: color on: aCanvas
+
+ | selectionDrawBounds |
+ index ifNil: [ ^self ].
+ index = 0 ifTrue: [ ^self ].
+ selectionDrawBounds := self drawBoundsForRow: index.
+ selectionDrawBounds := selectionDrawBounds intersect: self bounds.
+ aCanvas fillRectangle: selectionDrawBounds color: color.!

Item was changed:
  ----- Method: LazyListMorph>>drawSelectionOn: (in category 'drawing') -----
  drawSelectionOn: aCanvas
 
+ self
+ drawSelectionFor: selectedRow
+ withColor: self class listSelectionColor
+ on: aCanvas!
- | selectionDrawBounds |
- selectedRow ifNil: [ ^self ].
- selectedRow = 0 ifTrue: [ ^self ].
- selectionDrawBounds := self drawBoundsForRow: selectedRow.
- selectionDrawBounds := selectionDrawBounds intersect: self bounds.
- aCanvas fillRectangle: selectionDrawBounds color: self class listSelectionColor.!

Item was changed:
  ----- Method: LazyListMorph>>initialize (in category 'initialization') -----
  initialize
  super initialize.
  self color: Color black.
  font := Preferences standardListFont.
  listItems := #().
  listIcons := #().
  selectedRow := nil.
  selectedRows := PluggableSet integerSet.
+ preSelectedRow := nil.
  self adjustHeight.!

Item was changed:
  ----- Method: LazyListMorph>>listChanged (in category 'list management') -----
  listChanged
  "set newList to be the list of strings to display"
  | size |
  size := self getListSize.
  listItems := Array new: size withAll: nil.
  listIcons := Array new: size withAll: nil.
  maxWidth := nil.
  selectedRow := nil.
  selectedRows := PluggableSet integerSet.
+ preSelectedRow := nil.
  self adjustHeight.
  self adjustWidth.
  self changed.
  !

Item was added:
+ ----- Method: LazyListMorph>>preSelectedRow: (in category 'list management') -----
+ preSelectedRow: index
+ " Show the user which row is about to become selected, thus providing feedback if there is a delay between the selection gesture and the actual selection of the row. "
+
+ preSelectedRow := index.
+ self changed.!

Item was changed:
  ----- Method: LazyListMorph>>selectRow: (in category 'list management') -----
  selectRow: index
+ " Select the index-th row. Clear the pre selection highlight. "
- "select the index-th row"
  selectedRows add: index.
+ preSelectedRow := nil.
  self changed.!

Item was changed:
  ----- Method: LazyListMorph>>selectedRow: (in category 'list management') -----
  selectedRow: index
+ " Select the index-th row. Clear the pre selection highlight. If nil, remove the current selection. "
- "select the index-th row.  if nil, remove the current selection"
  selectedRow := index.
+ preSelectedRow := nil.
  self changed.!

Item was changed:
  ----- Method: LazyListMorph>>unselectRow: (in category 'list management') -----
  unselectRow: index
  "unselect the index-th row"
  selectedRows remove: index ifAbsent: [].
+ preSelectedRow := nil.
  self changed.!

Item was changed:
  ----- Method: PluggableListMorph>>changeModelSelection: (in category 'model access') -----
  changeModelSelection: anInteger
+ " Change the model's selected item index to be anInteger. Enable the pre selection highlight. Deferring the model's selection action, to let the pre selection highlight take effect. "
- "Change the model's selected item index to be anInteger."
 
+ self rowAboutToBecomeSelected: (self uiIndexFor: anInteger).
+ setIndexSelector ifNotNil: [
+ ([ model perform: setIndexSelector with: anInteger ] future: 1) value ].!
- setIndexSelector ifNotNil:
- [model perform: setIndexSelector with: anInteger].!

Item was added:
+ ----- Method: PluggableListMorph>>rowAboutToBecomeSelected: (in category 'selection') -----
+ rowAboutToBecomeSelected: anInteger
+
+ self listMorph preSelectedRow: anInteger!