Skip to content

Commit

Permalink
Merge branch 'pluggable-list' of https://github.com/hpi-swa-teaching/…
Browse files Browse the repository at this point in the history
  • Loading branch information
mschroederi committed Jul 10, 2018
2 parents 0933c8c + 98a2103 commit ddc275d
Show file tree
Hide file tree
Showing 40 changed files with 200 additions and 62 deletions.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
drawing
drawFilterFor: aMDMenuItem on: aCanvas at: aRow

| offsets |
offsets := self filterOffsets: aMDMenuItem.
offsets isEmpty ifTrue: [^ self].

offsets do: [ :offset |
aCanvas
frameAndFillRoundRect: (self filterBoundsForItem: aMDMenuItem with: offset at: aRow)
radius: 3
fillStyle: (SolidFillStyle color: self filterColor)
borderWidth: 0
borderColor: Color black]
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
drawing
drawItem: anIndex on: aCanvas

| row pos |
| row pos item |
row := (anIndex - self firstVisibleItem) + 1.
pos := self globalPositionOfItemAt: row.
aCanvas clipBy: self bounds during: [:clippedCanvas |
clippedCanvas
drawImage: (self filteredListItems at: anIndex) formCache
at: pos].

self drawFilterFor: anIndex on: aCanvas.
item := self filteredListItems at: anIndex.
self drawFilterFor: item on: aCanvas at: row.
(self showDividers and: (self dividersDrawable: row))
ifTrue: [ self drawDividersAt: pos on: aCanvas].

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
filtering
filterBoundsForItem: aMDMenuItem with: offset at: aRow

| absBounds |
absBounds := self globalBoundsOfLabelOfItem: aMDMenuItem at: aRow.

^ absBounds origin + (offset first first @ 0) corner:
(absBounds origin x + offset first last) @ (absBounds corner y)
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
filtering
filterOffsets: anIndex
filterOffsets: aMDMenuItem
"Calculate matching character indexes for the current filter term."

| label filter offsets currentIndex sub font |
filter := self filterTerm.
filter ifEmpty: [^ Array empty].

label := (self filteredListItems at: anIndex) label.
label := aMDMenuItem label.
font := label font.
label := label contents.
offsets := OrderedCollection new.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
drawing
globalBoundsOfLabelOfItem: aMDMenuItem at: aRow

| absPositionItem labelBounds |
labelBounds := aMDMenuItem labelBounds.
absPositionItem := self globalPositionOfItemAt: aRow.
^ (labelBounds origin + absPositionItem corner:
labelBounds corner + absPositionItem)

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
drawing
globalPositionOfItemAt: aNum
globalPositionOfItemAt: aRow

^ self globalPositionOfFirstVisibleItem + (self relativePositionOfItemAt: aNum)
^ self globalPositionOfFirstVisibleItem + (self relativePositionOfItemAt: aRow)
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
event handling
mouseMove: evt

| item mouseEvent |
| item mouseEvent evtCopy |
item := self globalPositionToIndex: evt position.
mouseEvent := evt position: 0 @ 0.
evtCopy := evt copy.
mouseEvent := evtCopy position: 0 @ 0.

self filteredListItems ifNotEmpty: [
self forVisibleItemIndicesDo: [:each |
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
drawing
relativePositionOfItemAt: aNum
relativePositionOfItemAt: aRow

^ (0 @ (self listItemHeight + self listItemPadding) * (aNum - 1))
^ (0 @ (self listItemHeight + self listItemPadding) * (aRow - 1))
Original file line number Diff line number Diff line change
Expand Up @@ -17,21 +17,21 @@
"divider:" : "mats 6/8/2018 14:52",
"dividersDrawable:" : "LS 6/28/2018 21:14",
"drawDividersAt:on:" : "LS 6/28/2018 09:17",
"drawFilterFor:on:" : "CG 7/1/2018 12:05",
"drawItem:on:" : "CG 7/1/2018 12:05",
"drawFilterFor:on:at:" : "LS 7/10/2018 12:13",
"drawItem:on:" : "LS 7/10/2018 12:14",
"drawItemsOn:" : "LS 6/28/2018 17:39",
"drawOn:" : "CG 7/1/2018 12:05",
"filterBoundsForItem:with:" : "LS 6/28/2018 21:13",
"filterBoundsForItem:with:at:" : "LS 7/10/2018 12:14",
"filterColor" : "LS 6/28/2018 16:55",
"filterList" : "CG 7/1/2018 12:07",
"filterList:" : "LS 6/28/2018 21:36",
"filterOffsets:" : "CG 7/1/2018 12:07",
"filterOffsets:" : "LS 7/10/2018 12:15",
"filterTerm" : "LS 6/28/2018 09:30",
"filteredListItems" : "CG 7/1/2018 12:07",
"filteredListItems:" : "CG 7/1/2018 12:07",
"firstVisibleItem" : "mats 7/10/2018 12:51",
"forVisibleItemIndicesDo:" : "LS 6/28/2018 17:37",
"globalBoundsOfLabelOfItemAt:" : "LS 6/28/2018 17:36",
"globalBoundsOfLabelOfItem:at:" : "LS 7/10/2018 12:15",
"globalPositionOfFirstVisibleItem" : "LS 6/28/2018 17:37",
"globalPositionOfItemAt:" : "LS 6/28/2018 17:36",
"globalPositionToIndex:" : "mats 7/10/2018 12:51",
Expand Down
3 changes: 1 addition & 2 deletions packages/Material-Core.package/MDList.class/properties.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@
"listItems",
"divider",
"lastKeystrokes",
"filteredListItems",
"filterOffsets" ],
"filteredListItems" ],
"name" : "MDList",
"pools" : [
],
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
event handling
mouseEnterDragging: evt

(evt hand hasSubmorphs and:[self dropEnabled]) ifFalse: ["no d&d"
^super mouseEnterDragging: evt].

(self wantsDroppedMorph: evt hand firstSubmorph event: evt )
ifTrue:[
potentialDropRow := self rowAtLocation: evt position.
evt hand newMouseFocus: self.
self changed.
"above is ugly but necessary for now"
].
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
event handling
mouseLeaveDragging: anEvent

(self dropEnabled and:[anEvent hand hasSubmorphs]) ifFalse: ["no d&d"
^ super mouseLeaveDragging: anEvent].
self resetPotentialDropRow.
anEvent hand releaseMouseFocus: self.
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
event handling
mouseMove: evt

super mouseMove: evt.

self mouseLeaveDragging: evt.
self mouseEnterDragging: evt.
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
accessing
potentialDropRow
"return the row of the item that the most recent drop hovered over, or 0 if there is no potential drop target"
^ potentialDropRow ifNil: [ 0 ].
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
as yet unclassified
resetPotentialDropRow
potentialDropRow ifNotNil: [
potentialDropRow ~= 0 ifTrue: [
potentialDropRow := 0.
self changed. ] ]
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
event handling
rowAtLocation: aPoint

^ self globalPositionToIndex: aPoint
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,6 @@
"commandKeyTypedIntoMenu:" : "mats 7/9/2018 15:31",
"doubleClickSelector" : "mats 6/26/2018 11:33",
"doubleClickSelector:" : "mats 6/26/2018 11:33",
"dragItemSelector" : "mats 6/26/2018 11:33",
"dragItemSelector:" : "mats 6/26/2018 11:33",
"dragStartedSelector" : "mats 6/26/2018 11:33",
"dragStartedSelector:" : "mats 6/26/2018 11:33",
"dropItemSelector" : "mats 6/26/2018 11:33",
"dropItemSelector:" : "mats 6/26/2018 11:33",
"filterableList" : "mats 7/9/2018 16:51",
"getCurrentSelectionIndex" : "mats 7/9/2018 16:46",
"getHelpSelector" : "mats 6/26/2018 11:33",
Expand Down Expand Up @@ -66,18 +60,22 @@
"model:" : "mats 7/10/2018 11:07",
"modifierKeyPressed:" : "mats 7/10/2018 11:07",
"mouseDown:" : "mats 7/9/2018 16:43",
"mouseEnterDragging:" : "JW 7/6/2018 17:07",
"mouseLeaveDragging:" : "JW 7/6/2018 16:31",
"mouseMove:" : "JW 7/6/2018 17:07",
"numSelectionsInView" : "mats 7/10/2018 11:33",
"potentialDropRow" : "JW 7/6/2018 15:45",
"previewKeystroke:" : "mats 7/10/2018 11:07",
"priorSelection" : "mats 7/9/2018 16:54",
"priorSelection:" : "mats 7/9/2018 16:54",
"resetPotentialDropRow" : "JW 7/6/2018 15:39",
"rowAtLocation:" : "JW 7/6/2018 16:58",
"selected" : "mats 6/26/2018 11:37",
"selected:" : "mats 7/3/2018 10:17",
"selectionIndex" : "mats 7/9/2018 16:53",
"specialKeyPressed:" : "mats 7/10/2018 11:08",
"update:" : "mats 7/10/2018 14:00",
"updateList" : "mats 7/10/2018 13:54",
"updateListMorphs" : "mats 7/3/2018 14:57",
"wantsDropSelector" : "mats 6/26/2018 11:34",
"wantsDropSelector:" : "mats 6/26/2018 11:34",
"wantsKeyboardFocus" : "mats 7/9/2018 16:45",
"yellowButtonActivity:" : "mats 7/9/2018 16:42" } }
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,12 @@
"keystroke",
"autoDeselect",
"doubleClickSelector",
"dragItemSelector",
"dragStartedSelector",
"dropItemSelector",
"getHelpSelector",
"getIconSelector",
"getListElementSelector",
"getListSizeSelector",
"keystrokePreviewSelector",
"potentialDropRow",
"wantsDropSelector",
"lastKeystrokeTime",
"priorSelection",
Expand Down
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
drag and drop
acceptDroppingMorph: aTransferMorph event: evt

dropItemSelector ifNil: [^ self].
Transcript show: potentialDropRow.
potentialDropRow ifNil: [^ self].
model
perform: dropItemSelector
withEnoughArguments: {
aTransferMorph passenger.
"self modelIndexFor: self potentialDropRow."
self potentialDropRow.
aTransferMorph shouldCopy.
aTransferMorph}.

self resetPotentialDropRow.
evt hand releaseMouseFocus: self.
Cursor normal show.
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
accessing
dragTypeSelector: anObject
dragTypeSelector := anObject
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
accessing
dragTypeSelector
^ dragTypeSelector
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
accessing
dropItemSelector: aSymbol
dropItemSelector := aSymbol.
aSymbol ifNotNil:[self dropEnabled: true].
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
drag and drop
startDrag: evt

| item itemMorph modelIndex |
dragItemSelector ifNil:[^self].
evt hand hasSubmorphs ifTrue: [^ self].
self model okToChange ifFalse: [^ self].

"Ensure selection to save additional click."
(self modelIndexFor: (self rowAtLocation: evt position)) in: [:evtIndex |
self selectionIndex = evtIndex ifFalse: [self changeModelSelection: evtIndex]].

item := self selection ifNil: [^ self].
itemMorph := StringMorph contents: item asStringOrText.
modelIndex := self modelIndexFor: self selectionIndex.

[ "Initiate drag."
(self model perform: dragItemSelector with: modelIndex) ifNotNil: [:passenger | | ddm |
ddm := (self valueOfProperty: #dragTransferClass ifAbsent: [TransferMorph]) withPassenger: passenger from: self.
ddm dragTransferType: (self dragTypeSelector ifNotNil: [:s | self model perform: s with: modelIndex]).
ddm updateFromUserInputEvent: evt.
self dragStartedSelector ifNotNil: [:s | self model perform: s with: itemMorph with: ddm].
evt hand grabMorph: ddm].
] ensure: [
Cursor normal show.
evt hand releaseMouseFocus: self]
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
drag and drop
wantsDroppedMorph: aTransferMorph event: anEvent

dropItemSelector ifNil: [^ false].
wantsDropSelector ifNil: [^ true].

(aTransferMorph isKindOf: TransferMorph) ifFalse: [^ false].

^ model perform: wantsDropSelector withEnoughArguments: {
aTransferMorph passenger.
aTransferMorph dragTransferType.
aTransferMorph source.
aTransferMorph}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"class" : {
},
"instance" : {
"acceptDroppingMorph:event:" : "JW 7/6/2018 16:40",
"dragItemSelector" : "JW 7/6/2018 15:14",
"dragItemSelector:" : "JW 7/6/2018 15:14",
"dragStartedSelector" : "JW 7/6/2018 15:15",
"dragStartedSelector:" : "JW 7/6/2018 15:15",
"dragTypeSelector" : "JW 7/6/2018 15:15",
"dragTypeSelector:" : "JW 7/6/2018 15:15",
"dropItemSelector" : "JW 7/6/2018 15:14",
"dropItemSelector:" : "JW 7/6/2018 16:50",
"startDrag:" : "JW 7/6/2018 16:32",
"wantsDropSelector" : "JW 7/6/2018 15:14",
"wantsDropSelector:" : "JW 7/6/2018 15:14",
"wantsDroppedMorph:event:" : "JW 7/6/2018 15:44" } }
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"category" : "Material-ToolBuilder",
"classinstvars" : [
],
"classvars" : [
],
"commentStamp" : "",
"instvars" : [
"dragItemSelector",
"dropItemSelector",
"wantsDropSelector",
"dragTypeSelector",
"dragStartedSelector" ],
"name" : "MDPluggableListPlus",
"pools" : [
],
"super" : "MDPluggableList",
"type" : "normal" }
Loading

0 comments on commit ddc275d

Please sign in to comment.