[squeak-dev] The Trunk: Morphic-mt.1548.mcz

Marcel Taeumel marcel.taeumel at hpi.de
Mon Sep 30 08:46:05 UTC 2019


Am 30.09.2019 10:29:39 schrieb commits at source.squeak.org <commits at source.squeak.org>:
Marcel Taeumel uploaded a new version of Morphic to project The Trunk:
http://source.squeak.org/trunk/Morphic-mt.1548.mcz

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

Name: Morphic-mt.1548
Author: mt
Time: 30 September 2019, 10:29:19.20171 am
UUID: 0cf91407-3c2e-724d-b444-6986a9ca91a7
Ancestors: Morphic-mt.1547

Some improvements for multi-selection lists:
- hit [space] key to toggle selection
- draw the current "selection" as outline to recognize multi-selection state
- do not reset current "selection" to 0 when deselecting a row in the multi-selection state --- to better support keyboard navigation and [space]

=============== Diff against Morphic-mt.1547 ===============

Item was changed:
----- Method: LazyListMorph>>drawBackgroundForMulti:on: (in category 'drawing') -----
drawBackgroundForMulti: row on: aCanvas
"shade the background paler, if this row is selected, but not the current selected row"
| selectionDrawBounds |
- selectedRow = row ifTrue: [^ self].
selectionDrawBounds := self drawBoundsForRow: row.
selectionDrawBounds := selectionDrawBounds intersect: self bounds.
aCanvas
fillRectangle: selectionDrawBounds
color: self multiSelectionColor!

Item was changed:
----- Method: LazyListMorph>>drawOn: (in category 'drawing') -----
drawOn: aCanvas

| topRow bottomRow |
listItems ifEmpty: [ ^self ].

self drawPreSelectionOn: aCanvas.

topRow := self topVisibleRowForCanvas: aCanvas.
bottomRow := self bottomVisibleRowForCanvas: aCanvas.

"Draw multi-selection."
+ listSource hasMultiSelection ifTrue: [
+ topRow to: bottomRow do: [ :row |
+ (listSource itemSelectedAmongMultiple: row) ifTrue: [
+ self drawBackgroundForMulti: row on: aCanvas ] ] ].
- topRow to: bottomRow do: [ :row |
- (listSource itemSelectedAmongMultiple: row) ifTrue: [
- self drawBackgroundForMulti: row on: aCanvas ] ].
self drawSelectionOn: aCanvas.

"Draw hovered row if preference enabled."
PluggableListMorph highlightHoveredRow ifTrue: [
listSource hoverRow > 0 ifTrue: [
self highlightHoverRow: listSource hoverRow on: aCanvas ] ].

"Draw all visible rows."
topRow to: bottomRow do: [ :row |
self display: (self item: row) atRow: row on: aCanvas ].

"Finally, highlight drop row for drag/drop operations.."
listSource potentialDropRow > 0 ifTrue: [
self highlightPotentialDropRow: listSource potentialDropRow on: aCanvas ].!

Item was changed:
----- Method: LazyListMorph>>drawSelectionFor:withColor:on: (in category 'drawing') -----
drawSelectionFor: index withColor: color on: aCanvas

| selectionDrawBounds fill |
index ifNil: [ ^self ].
index = 0 ifTrue: [ ^self ].
selectionDrawBounds := self drawBoundsForRow: index.
selectionDrawBounds := selectionDrawBounds intersect: self bounds.

fill := color isColor
ifTrue: [SolidFillStyle color: color]
ifFalse: [color].
fill isGradientFill ifTrue: [
fill origin: selectionDrawBounds topLeft.
fill direction: 0@ selectionDrawBounds height].

+ listSource hasMultiSelection
+ ifFalse: [aCanvas fillRectangle: selectionDrawBounds fillStyle: fill]
+ ifTrue: [aCanvas frameRectangle: selectionDrawBounds color: fill asColor] .!
- aCanvas fillRectangle: selectionDrawBounds fillStyle: fill.!

Item was added:
+ ----- Method: PluggableListMorph>>hasMultiSelection (in category 'testing') -----
+ hasMultiSelection
+
+ ^ false!

Item was added:
+ ----- Method: PluggableListMorphOfMany>>basicKeyPressed: (in category 'model access') -----
+ basicKeyPressed: aCharacter
+
+ aCharacter = Character space
+ ifTrue: [self specialKeyPressed: aCharacter asciiValue]
+ ifFalse: [super basicKeyPressed: aCharacter].!

Item was added:
+ ----- Method: PluggableListMorphOfMany>>hasMultiSelection (in category 'testing') -----
+ hasMultiSelection
+
+ ^ true!

Item was changed:
----- Method: PluggableListMorphOfMany>>mouseDown: (in category 'event handling') -----
mouseDown: event
+ | row index |
- | oldIndex oldVal row index |
event yellowButtonPressed ifTrue: [^ self yellowButtonActivity: event shiftPressed].
row := self rowAtLocation: event position.

row = 0 ifTrue: [^super mouseDown: event].
index := self modelIndexFor: row.

model okToChange ifFalse: [^ self]. "No change if model is locked"

+ self changeModelSelection: index.
- "Set meaning for subsequent dragging of selection"
- dragOnOrOff := (self listSelectionAt: index) not.
- oldIndex := self getCurrentSelectionIndex.
- oldIndex ~= 0 ifTrue: [oldVal := self listSelectionAt: oldIndex].

+ "Set meaning for subsequent dragging of selection"
+ self
+ listSelectionAt: index
+ put: (dragOnOrOff := (self listSelectionAt: index) not)
- "Set or clear new primary selection (listIndex)"
- dragOnOrOff
- ifTrue: [self changeModelSelection: index]
- ifFalse: [self changeModelSelection: 0].
-
- "Need to restore the old one, due to how model works, and set new one."
- oldIndex ~= 0 ifTrue: [self listSelectionAt: oldIndex put: oldVal].
- self listSelectionAt: index put: dragOnOrOff.
- "event hand releaseMouseFocus: aMorph."
!

Item was changed:
----- Method: PluggableListMorphOfMany>>mouseMove: (in category 'event handling') -----
mouseMove: event
"The mouse has moved, as characterized by the event provided. Adjust the scrollbar, and alter the selection as appropriate"

+ | row index |
- | oldIndex oldVal row index |
event position y
ifTrue:
[scrollBar scrollUp: 1.
row := self rowAtLocation: scroller topLeft + (1 @ 1)]
ifFalse:
[row := event position y > self bottom
ifTrue:
[scrollBar scrollDown: 1.
self rowAtLocation: scroller bottomLeft + (1 @ -1)]
ifFalse: [ self rowAtLocation: event position]].
row = 0 ifTrue: [^super mouseDown: event].
index := self modelIndexFor: row.

model okToChange ifFalse: [^self]. "No change if model is locked"

+ dragOnOrOff ifNil: [
+ "Was not set at mouse down, which means the mouse must have gone down in an area where there was no list item"
+ dragOnOrOff := (self listSelectionAt: index) not].
- dragOnOrOff ifNil:
- ["Was not set at mouse down, which means the mouse must have gone down in an area where there was no list item"
- dragOnOrOff := (self listSelectionAt: index) not].

+ self changeModelSelection: index.
+ self listSelectionAt: index put: dragOnOrOff.!
- "Set meaning for subsequent dragging of selection"
- oldIndex := self getCurrentSelectionIndex.
- oldIndex ~= 0 ifTrue: [oldVal := self listSelectionAt: oldIndex].
-
- "Set or clear new primary selection (listIndex)"
- dragOnOrOff
- ifTrue: [self changeModelSelection: index]
- ifFalse: [self changeModelSelection: 0].
-
- "Need to restore the old one, due to how model works, and set new one."
- oldIndex ~= 0 ifTrue: [self listSelectionAt: oldIndex put: oldVal].
- self listSelectionAt: index put: dragOnOrOff.
- !

Item was added:
+ ----- Method: PluggableListMorphOfMany>>specialKeyPressed: (in category 'model access') -----
+ specialKeyPressed: asciiValue
+
+ asciiValue = Character space asciiValue
+ ifTrue: [ | index |
+ index := self getCurrentSelectionIndex.
+ self
+ listSelectionAt: index
+ put: ((self listSelectionAt: index) not).
+ ^ self].
+
+ super specialKeyPressed: asciiValue.!


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20190930/1908c481/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image.png
Type: image/png
Size: 31707 bytes
Desc: not available
URL: <http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20190930/1908c481/attachment.png>


More information about the Squeak-dev mailing list