-
areaActivity [control activities]
| aModel startPoint shapeCollection endPoint aRectangle |
aModel := self model.
aModel multiSelections ifFalse: [^nil].
self sensor shiftDown ifFalse: [aModel selections: Array new].
startPoint := self sensor cursorPoint.
JunCursors crossCursor showWhile:
[[self sensor anyButtonPressed] whileTrue:
[[self sensor anyButtonPressed and: [self viewHasCursor]] whileTrue:
[shapeCollection := self areaToShapes: startPoint.
shapeCollection isEmpty
ifFalse:
[shapeCollection do:
[:shape |
Screen default
displayShape: shape
lineWidth: 2
at: Point zero
forMilliseconds: 40.
Processor yield]]].
self scrollActivity.
shapeCollection := self areaToShapes: startPoint.
shapeCollection isEmpty
ifFalse:
[shapeCollection do:
[:shape |
Screen default
displayShape: shape
lineWidth: 2
at: Point zero
forMilliseconds: 40.
Processor yield]]]].
endPoint := self sensor cursorPoint.
aRectangle := Rectangle vertex: startPoint vertex: endPoint.
aModel elements do:
[:element |
(element bounds intersects: aRectangle)
ifTrue: [aModel addSelection: element]].
aModel redisplay
-
areaToShapes: startPoint [private]
| originPoint cursorPoint areaBox viewBox intersectBox lines pointsCollection shapes |
originPoint := (self view localPointToGlobal: Point zero)
+ self view topComponent globalOrigin.
cursorPoint := self sensor cursorPoint.
areaBox := Rectangle vertex: startPoint vertex: cursorPoint.
viewBox := self view bounds.
intersectBox := areaBox intersect: viewBox.
lines := Dictionary new: 4.
lines
at: #topLine
put: (Jun2dLine from: intersectBox topLeft to: intersectBox topRight);
at: #rightLine
put: (Jun2dLine from: intersectBox topRight to: intersectBox bottomRight);
at: #bottomLine
put: (Jun2dLine from: intersectBox bottomRight to: intersectBox bottomLeft);
at: #leftLine
put: (Jun2dLine from: intersectBox bottomLeft to: intersectBox topLeft).
areaBox top < viewBox top
ifTrue: [lines removeKey: #topLine ifAbsent: [nil]].
areaBox bottom > viewBox bottom
ifTrue: [lines removeKey: #bottomLine ifAbsent: [nil]].
areaBox left < viewBox left
ifTrue: [lines removeKey: #leftLine ifAbsent: [nil]].
areaBox right > viewBox right
ifTrue: [lines removeKey: #rightLine ifAbsent: [nil]].
pointsCollection := OrderedCollection new: lines size.
#(#topLine #rightLine #bottomLine #leftLine) do:
[:key |
| line |
line := lines at: key ifAbsent: [nil].
line ifNotNil:
[| fromPoint toPoint |
fromPoint := line from.
toPoint := line to.
pointsCollection isEmpty
ifTrue:
[pointsCollection add: (OrderedCollection with: fromPoint with: toPoint)]
ifFalse:
[| thePoints |
thePoints := pointsCollection detect: [:points | points last = fromPoint]
ifNone: [nil].
thePoints ifNil:
[pointsCollection add: (OrderedCollection with: line from with: line to)]
ifNotNil: [thePoints addLast: toPoint]]]].
pointsCollection size >= 2
ifTrue:
[| firstPoints lastPoints firstPoint lastPoint |
firstPoints := pointsCollection first.
lastPoints := pointsCollection last.
firstPoint := firstPoints first.
lastPoint := lastPoints last.
firstPoint = lastPoint
ifTrue:
[lastPoints addAllLast: (firstPoints copyFrom: 2 to: firstPoints size).
pointsCollection removeFirst]].
shapes := pointsCollection
collect: [:points | points collect: [:point | point asPoint translatedBy: originPoint]].
^shapes
-
doubleClickActivity [control activities]
| aModel aPoint |
aModel := self model.
aPoint := self sensor cursorPoint.
(aModel which: aPoint)
ifNotNil: [:element | aModel openCatalogueElement: element]
-
dropActivity [control activities]
| aModel aWindow aView aBox |
aModel := self model dropTargetCatalogue.
aModel ifNil: [^nil].
aWindow := aModel getWindow.
aWindow ifNil: [^nil].
aView := aModel getView.
aView ifNil: [^nil].
aBox := aView bounds
translatedBy: aWindow globalOrigin + (aView localPointToGlobal: Point zero).
Screen default
displayShape: aBox asPointArray
lineWidth: 2
at: Point zero
forMilliseconds: 100.
^aModel
-
grabActivity [control activities]
| aModel aPoint |
aModel := self model.
aPoint := self sensor cursorPoint.
(aModel which: aPoint) ifNil: [self areaActivity]
ifNotNil: [self moveActivity]
-
moveActivity [control activities]
| aModel aPoint |
aModel := self model.
aPoint := self sensor cursorPoint.
(aModel which: aPoint) ifNotNil:
[:element |
| anImage |
JunCursorAnimator handCursor0 showWhile:
[self do:
[(aModel selections includes: element)
ifTrue:
[aModel removeSelection: element.
aModel addSelection: element]
ifFalse: [aModel selection: element].
aModel redisplay.
anImage := aModel
asImageOfElements: aModel selections
selectionColor: ColorValue blue
backgroundColor: aModel backgroundColor]
forMilliseconds: 300].
JunCursorAnimator handCursor5 showWhile:
[[self sensor anyButtonPressed] whileTrue:
[(JunVisualTransporter load: anImage)
follow:
[self sensor cursorPoint
- ((anImage bounds width - (aModel pixmapExtent x // 2))
@ (aModel pixmapExtent y // 2))]
while: [self sensor anyButtonPressed and: [self viewHasCursor]]
on: self view graphicsContext.
self dropActivity.
self scrollActivity]].
aPoint := self sensor cursorPoint.
(aModel where: aPoint)
ifNil: [aModel dropElements: aModel selections toCatalogue: self dropActivity]
ifNotNil:
[:target |
element = target
ifFalse: [aModel moveElements: aModel selections toElement: target]]]
-
redButtonActivity [control defaults]
| aSymbol |
aSymbol := JunSensorUtility checkRedButton.
aSymbol = #single ifTrue: [self singleClickActivity].
aSymbol = #double ifTrue: [self doubleClickActivity].
aSymbol = #grab ifTrue: [self grabActivity].
self sensor waitNoButton
-
scrollActivity [control activities]
| point box amount |
self viewHasCursor ifTrue: [^nil].
point := self sensor cursorPoint.
box := self view bounds.
amount := Point zero.
point x < box left ifTrue: [amount x: box left - point x].
point x > box right ifTrue: [amount x: box right - point x].
point y < box top ifTrue: [amount y: box top - point y].
point y > box bottom ifTrue: [amount y: box bottom - point y].
amount = Point zero ifTrue: [^nil].
self do:
[self view scrollBy: amount.
self model redisplay]
forMilliseconds: 50
-
singleClickActivity [control activities]
| aModel aPoint shiftDown |
aModel := self model.
aPoint := self sensor cursorPoint.
shiftDown := JunSensorUtility shiftDown.
(aModel where: aPoint) ifNil: [aModel clearSelections]
ifNotNil:
[:element |
element isVoid
ifTrue: [aModel clearSelections]
ifFalse:
[aModel multiSelections
ifTrue:
[shiftDown
ifTrue:
[(aModel selections includes: element)
ifTrue: [aModel removeSelection: element]
ifFalse: [aModel addSelection: element]]
ifFalse:
[(aModel selections includes: element)
ifTrue:
[aModel selections size <= 1
ifTrue: [aModel clearSelections]
ifFalse: [aModel selection: element]]
ifFalse: [aModel selection: element]]]
ifFalse:
[aModel selection = element
ifTrue: [aModel selection: nil]
ifFalse: [aModel selection: element]]]].
aModel redisplay
-
yellowButtonActivity [control defaults]
| aModel aPoint |
aModel := self model.
aPoint := self sensor cursorPoint.
(aModel which: aPoint) ifNotNil:
[:element |
(aModel selections includes: element)
ifFalse:
[aModel selection: element.
aModel redisplay]].
super yellowButtonActivity