630 endLineDrag |
630 endLineDrag |
631 "cleanup after line drag; select them. Find the origin and destination |
631 "cleanup after line drag; select them. Find the origin and destination |
632 views and relative offsets, then dispatch to one of the endLineDrag methods. |
632 views and relative offsets, then dispatch to one of the endLineDrag methods. |
633 These can be redefined in subclasses to allow connect between views." |
633 These can be redefined in subclasses to allow connect between views." |
634 |
634 |
635 |rootPoint viewId offs |
635 |rootPoint viewId offs transformation2 |
636 lastViewId destinationId destinationView destinationPoint inMySelf| |
636 lastViewId destinationId destinationView destinationPoint |
|
637 inMySelf dragOrigin| |
637 |
638 |
638 self invertDragLine. |
639 self invertDragLine. |
639 |
640 |
640 self cursor:oldCursor. |
641 self cursor:oldCursor. |
641 |
642 |
646 get device coordinates |
647 get device coordinates |
647 " |
648 " |
648 transformation notNil ifTrue:[ |
649 transformation notNil ifTrue:[ |
649 rootPoint := transformation applyTo:rootPoint. |
650 rootPoint := transformation applyTo:rootPoint. |
650 ]. |
651 ]. |
651 viewId := rootView id. |
|
652 |
652 |
653 " |
653 " |
654 translate to screen |
654 translate to screen |
655 " |
655 " |
656 offs := device translatePoint:0@0 from:(self id) to:viewId. |
656 offs := device translatePoint:0@0 fromView:self toView:rootView. |
657 rootPoint := rootPoint + offs. |
657 rootPoint := rootPoint + offs. |
658 |
658 |
659 "search view the drop is in" |
659 "search view the drop is in" |
660 |
660 viewId := rootView id. |
661 [viewId notNil] whileTrue:[ |
661 [viewId notNil] whileTrue:[ |
662 destinationId := device viewIdFromPoint:rootPoint in:viewId. |
662 destinationId := device viewIdFromPoint:rootPoint in:viewId. |
663 lastViewId := viewId. |
663 lastViewId := viewId. |
664 viewId := destinationId |
664 viewId := destinationId |
665 ]. |
665 ]. |
669 rootMotion := false |
669 rootMotion := false |
670 ] ifFalse:[ |
670 ] ifFalse:[ |
671 inMySelf := true |
671 inMySelf := true |
672 ]. |
672 ]. |
673 |
673 |
|
674 dragOrigin := dragObject origin. |
674 inMySelf ifTrue:[ |
675 inMySelf ifTrue:[ |
675 "a simple line within myself" |
676 "a simple line within myself" |
676 self lineDragFrom:dragObject origin to:dragObject corner |
677 self lineDragFrom:dragOrigin to:dragObject corner |
677 ] ifFalse:[ |
678 ] ifFalse:[ |
678 "into another one" |
679 "into another one" |
679 destinationView notNil ifTrue:[ |
680 destinationView notNil ifTrue:[ |
680 destinationPoint := device translatePoint:rootPoint from:(rootView id) to:(destinationView id). |
681 destinationPoint := device translatePoint:rootPoint fromView:rootView toView:destinationView. |
681 destinationView transformation notNil ifTrue:[ |
682 (transformation2 := destinationView transformation) notNil ifTrue:[ |
682 destinationPoint := destinationView transformation applyInverseTo:destinationPoint |
683 destinationPoint := transformation2 applyInverseTo:destinationPoint |
683 ]. |
684 ]. |
684 " |
685 " |
685 move into another smalltalk view |
686 move into another smalltalk view |
686 " |
687 " |
687 self lineDragFrom:dragObject origin to:destinationPoint in:destinationView |
688 self lineDragFrom:dragOrigin to:destinationPoint in:destinationView |
688 ] ifFalse:[ |
689 ] ifFalse:[ |
689 " |
690 " |
690 not one of my views |
691 not one of my views |
691 " |
692 " |
692 self lineDragFrom:dragObject origin |
693 self lineDragFrom:dragOrigin to:destinationPoint inAlienViewId:destinationId |
693 to:destinationPoint |
|
694 inAlienViewId:destinationId |
|
695 ] |
694 ] |
696 ]. |
695 ]. |
697 self setDefaultActions. |
696 self setDefaultActions. |
698 dragObject := nil |
697 dragObject := nil |
|
698 |
|
699 "Modified: / 10.10.2001 / 14:41:52 / cg" |
699 ! |
700 ! |
700 |
701 |
701 invertDragLine |
702 invertDragLine |
702 "helper for line dragging - invert the dragged line. |
703 "helper for line dragging - invert the dragged line. |
703 Extracted for easier redefinition in subclasses |
704 Extracted for easier redefinition in subclasses |
837 "cleanup after object move - called when the object move ends. |
838 "cleanup after object move - called when the object move ends. |
838 Find the destination view and position and dispatch to |
839 Find the destination view and position and dispatch to |
839 one of the moveObjectXXX-methods which should do the real move. |
840 one of the moveObjectXXX-methods which should do the real move. |
840 These can be redefined in subclasses." |
841 These can be redefined in subclasses." |
841 |
842 |
842 |inMySelf rootPoint destinationPoint p |
843 |inMySelf rootPoint destinationPoint p transformation2 |
843 viewId destinationView destinationId lastViewId| |
844 viewId destinationView destinationId lastViewId| |
844 |
845 |
845 movedObject notNil ifTrue:[ |
846 movedObject notNil ifTrue:[ |
846 self invertDragObject:movedObject delta:moveDelta. |
847 self invertDragObject:movedObject delta:moveDelta. |
847 |
848 |
848 "check if object is to be put into another view" |
849 "check if object is to be put into another view" |
849 rootMotion ifTrue:[ |
850 rootMotion ifTrue:[ |
850 p := lastButt. |
851 p := lastButt. |
851 " |
852 " |
852 get device coordinates |
853 get device coordinates |
853 " |
854 " |
854 transformation notNil ifTrue:[ |
855 transformation notNil ifTrue:[ |
855 p := transformation applyTo:p. |
856 p := transformation applyTo:p. |
856 ]. |
857 ]. |
857 viewId := rootView id. |
858 " |
858 " |
859 translate to screen |
859 translate to screen |
860 " |
860 " |
861 rootPoint := p + (device translatePoint:0@0 fromView:self toView:rootView). |
861 rootPoint := p + (device translatePoint:0@0 from:(self id) to:viewId). |
862 |
862 |
863 "search view the drop is in" |
863 "search view the drop is in" |
864 viewId := rootView id. |
864 [viewId notNil] whileTrue:[ |
865 [viewId notNil] whileTrue:[ |
865 destinationId := device viewIdFromPoint:rootPoint in:viewId. |
866 destinationId := device viewIdFromPoint:rootPoint in:viewId. |
866 lastViewId := viewId. |
867 lastViewId := viewId. |
867 viewId := destinationId |
868 viewId := destinationId |
868 ]. |
869 ]. |
869 destinationView := device viewFromId:lastViewId. |
870 destinationView := device viewFromId:lastViewId. |
870 destinationId := lastViewId. |
871 destinationId := lastViewId. |
871 inMySelf := (destinationView == self). |
872 inMySelf := (destinationView == self). |
872 rootMotion := false |
873 rootMotion := false |
873 ] ifFalse:[ |
874 ] ifFalse:[ |
874 inMySelf := true |
875 inMySelf := true |
875 ]. |
876 ]. |
876 |
877 |
877 inMySelf ifTrue:[ |
878 inMySelf ifTrue:[ |
878 "simple move" |
879 "simple move" |
879 self move:movedObject by:moveDelta |
880 self move:movedObject by:moveDelta |
880 ] ifFalse:[ |
881 ] ifFalse:[ |
881 destinationPoint := device translatePoint:rootPoint |
882 destinationPoint := device translatePoint:rootPoint "/ use id here - could be alian view |
882 from:(rootView id) |
883 from:(rootView id) |
883 to:destinationId. |
884 to:destinationId. |
884 destinationView notNil ifTrue:[ |
885 destinationView notNil ifTrue:[ |
885 destinationView transformation notNil ifTrue:[ |
886 (transformation2 := destinationView transformation) notNil ifTrue:[ |
886 destinationPoint := destinationView transformation applyInverseTo:destinationPoint |
887 destinationPoint := transformation2 applyInverseTo:destinationPoint |
887 ]. |
888 ]. |
888 " |
889 " |
889 move into another smalltalk view |
890 move into another smalltalk view |
890 " |
891 " |
891 self move:movedObject to:destinationPoint in:destinationView |
892 self move:movedObject to:destinationPoint in:destinationView |
892 ] ifFalse:[ |
893 ] ifFalse:[ |
893 " |
894 " |
894 not one of my views |
895 not one of my views |
895 " |
896 " |
896 self move:movedObject to:destinationPoint inAlienViewId:destinationId |
897 self move:movedObject to:destinationPoint inAlienViewId:destinationId |
897 ] |
898 ] |
898 ]. |
899 ]. |
899 self setDefaultActions. |
900 self setDefaultActions. |
900 movedObject := nil |
901 movedObject := nil |
901 ] |
902 ] |
|
903 |
|
904 "Modified: / 10.10.2001 / 14:43:09 / cg" |
902 ! |
905 ! |
903 |
906 |
904 invertDragObject:movedObject delta:moveDelta |
907 invertDragObject:movedObject delta:moveDelta |
905 "draw inverting for an object move" |
908 "draw inverting for an object move" |
906 |
909 |