On 16-07-15 11:41, Alain Plantec via Pharo-dev wrote:
>i think  it is better as specific feature of the pane event listener

It feels a bit like feature envy.
Too much poking around.


BlWellPanelFlowEventListener>>PaneldropAccepted: anEvent
        |wellPanelFlow droppedMorph localPosition found|
        wellPanelFlow := anEvent handler.
        droppedMorph := anEvent contents asDragWell.
        localPosition := wellPanelFlow globalPointToLocal: anEvent position.
wellPanelFlow hasSubmorphs ifFalse: [ wellPanelFlow addMorph: droppedMorph ].
        found := wellPanelFlow morphsAt: localPosition.
found ifNotNil: [ "We found at least one. The deepest is first, that's the one we want"
                found := found first.
found bounds center x < localPosition x ifTrue: [ "to the right of its center, so after it?"
                        wellPanelFlow addMorph: droppedMorph after: found ]
                ifFalse: [
                        wellPanelFlow addMorph: droppedMorph inFrontOf: found ] 
]
        ifNil: [
                found := self precedingMorphIn: wellPanelFlow submorphs at: 
localPosition.
                found ifNil: [ wellPanelFlow addMorphFront: droppedMorph ]
                ifNotNil: [ wellPanelFlow addMorph: droppedMorph after: found ]
                 ]
                


BlWellPanelFlowEventListener>>precedingMorphIn: aCollection at: localPosition
        |precedingMorph|
        precedingMorph := nil.
        aCollection do: [ :aMorph |
                aMorph bounds bottom < localPosition y ifTrue: [ "wrong row"
                        precedingMorph := aMorph ]
                ifFalse: [
                        aMorph bounds right < localPosition x ifTrue: [
                                precedingMorph := aMorph]
                        ifFalse: [ ^aMorph ]]
                 ].
        ^precedingMorph



Reply via email to