-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ToAlbumEditsFeedbackLayer: + ToAlbumEditsFeedbackElement and ToAlbumE…
…ditsFeedbackElementSkin + example_ListWithSelectionTrace to illustrate the use of a specific list primary selection element skin (example from Thales)
- Loading branch information
Showing
15 changed files
with
380 additions
and
129 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
79 changes: 79 additions & 0 deletions
79
src/Toplo-Examples/ToListSelectionTraceExampleEventHandler.class.st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
" | ||
I'm part of a larger example. I'm not expected to be used as a standalone. | ||
" | ||
Class { | ||
#name : #ToListSelectionTraceExampleEventHandler, | ||
#superclass : #BlCustomEventHandler, | ||
#instVars : [ | ||
'currentTarget', | ||
'traceSelectionModel' | ||
], | ||
#category : #'Toplo-Examples-Parts' | ||
} | ||
|
||
{ #category : #'event handling' } | ||
ToListSelectionTraceExampleEventHandler >> addIndexesSelectionCommand: aCommand [ | ||
|
||
|
||
aCommand operation deselectAllBefore ifTrue: [ | ||
traceSelectionModel deselectAll ]. | ||
traceSelectionModel selectIndexes: aCommand indexes. | ||
traceSelectionModel deselectIndex: aCommand indexes last | ||
] | ||
|
||
{ #category : #'event handling' } | ||
ToListSelectionTraceExampleEventHandler >> addIntervalSelectionCommand: aCommand [ | ||
aCommand operation deselectAllBefore ifTrue: [ | ||
traceSelectionModel deselectAll ]. | ||
traceSelectionModel selectIndexes: currentTarget selectionModel selectedIndexes. | ||
traceSelectionModel deselectIndex: aCommand to | ||
] | ||
|
||
{ #category : #'event handling' } | ||
ToListSelectionTraceExampleEventHandler >> addWholeSelectionCommand: aCommand [ | ||
|
||
traceSelectionModel | ||
selectIndex: 1 | ||
to: currentTarget selectionModel itemCount - 1 | ||
] | ||
|
||
{ #category : #'api - accessing' } | ||
ToListSelectionTraceExampleEventHandler >> eventsToHandle [ | ||
|
||
^ { ToListSelectionCommandAppliedEvent } | ||
] | ||
|
||
{ #category : #'event handling' } | ||
ToListSelectionTraceExampleEventHandler >> listSelectionCommandAppliedEvent: aCommandAppliedEvent [ | ||
|
||
currentTarget := aCommandAppliedEvent currentTarget. | ||
|
||
" check that the command is applied on the primary selection model " | ||
aCommandAppliedEvent selectionModel = currentTarget selectionModel | ||
ifFalse: [ ^ self ]. | ||
|
||
traceSelectionModel := currentTarget userData at: #traceSelectionModel. | ||
|
||
aCommandAppliedEvent command applyWithOperator: self. | ||
|
||
currentTarget := nil. | ||
traceSelectionModel := nil | ||
] | ||
|
||
{ #category : #'event handling' } | ||
ToListSelectionTraceExampleEventHandler >> removeIndexesSelectionCommand: aCommand [ | ||
|
||
traceSelectionModel deselectIndex: aCommand indexes | ||
] | ||
|
||
{ #category : #'event handling' } | ||
ToListSelectionTraceExampleEventHandler >> removeIntervalSelectionCommand: aCommand [ | ||
|
||
traceSelectionModel deselectIndex: aCommand from to: aCommand to | ||
] | ||
|
||
{ #category : #'event handling' } | ||
ToListSelectionTraceExampleEventHandler >> removeWholeSelectionCommand: aCommand [ | ||
|
||
traceSelectionModel deselectAll | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
src/Toplo-Examples/ToTraceListPrimarySelectionElementSkin.class.st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
Class { | ||
#name : #ToTraceListPrimarySelectionElementSkin, | ||
#superclass : #ToListBasicSelectionElementSkin, | ||
#category : #'Toplo-Examples-Parts' | ||
} | ||
|
||
{ #category : #'event handling' } | ||
ToTraceListPrimarySelectionElementSkin >> installSkinEvent: anEvent [ | ||
|
||
super installSkinEvent: anEvent. | ||
anEvent elementDo: [ :e | | ||
| color traceSelectionModel | | ||
e geometry: (BlRoundedRectangleGeometry cornerRadius: | ||
(e valueOfTokenNamed: #'border-radius-SM')). | ||
e border: BlBorder empty. | ||
traceSelectionModel := e listElement userData at: | ||
#traceSelectionModel. | ||
" since the selection option is separate, e nodes size is always 1 " | ||
(traceSelectionModel containsIndex: e nodes anyOne holder position) | ||
ifTrue: [ color := Color red ] | ||
ifFalse: [ | ||
color := e valueOfTokenNamed: #'color-primary-selection-focused' ]. | ||
e background: color ] | ||
] |
21 changes: 21 additions & 0 deletions
21
src/Toplo-Widget-Album/ToAlbumEditsFeedbackElement.class.st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
Class { | ||
#name : #ToAlbumEditsFeedbackElement, | ||
#superclass : #ToElement, | ||
#category : #'Toplo-Widget-Album-TextPane' | ||
} | ||
|
||
{ #category : #initialization } | ||
ToAlbumEditsFeedbackElement >> initialize [ | ||
|
||
super initialize. | ||
self size: 25 @ 25. | ||
self constraintsDo: [ :c | | ||
c frame horizontal alignRight. | ||
c frame vertical alignTop ] | ||
] | ||
|
||
{ #category : #'instance creation' } | ||
ToAlbumEditsFeedbackElement >> newRawSkin [ | ||
|
||
^ ToAlbumEditsFeedbackElementSkin new | ||
] |
Oops, something went wrong.