mirror of
https://github.com/bancika/diy-layout-creator
synced 2026-11-10 17:22:09 +10:00
improve drag&drop
This commit is contained in:
@@ -1156,7 +1156,7 @@ public class Presenter implements IPlugInPort {
|
|||||||
return true;
|
return true;
|
||||||
|
|
||||||
previousDragPoint.translate(actualD.x, actualD.y);
|
previousDragPoint.translate(actualD.x, actualD.y);
|
||||||
} else if (selectedComponents.isEmpty() && instantiationManager.getComponentTypeSlot() == null) {
|
} else if (selectedComponents.isEmpty() && instantiationManager.getComponentTypeSlot() == null && previousDragPoint != null) {
|
||||||
// If there's no selection, the only thing to do is update the
|
// If there's no selection, the only thing to do is update the
|
||||||
// selection rectangle and refresh.
|
// selection rectangle and refresh.
|
||||||
Rectangle oldSelectionRect = selectionRect == null ? null : new Rectangle(selectionRect);
|
Rectangle oldSelectionRect = selectionRect == null ? null : new Rectangle(selectionRect);
|
||||||
@@ -2135,10 +2135,10 @@ public class Presenter implements IPlugInPort {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (componentType == null) {
|
// if (componentType == null) {
|
||||||
controlPointMap.clear();
|
// controlPointMap.clear();
|
||||||
updateSelection(EMPTY_SELECTION);
|
// updateSelection(EMPTY_SELECTION);
|
||||||
}
|
// }
|
||||||
|
|
||||||
// try to find a default template if none is provided
|
// try to find a default template if none is provided
|
||||||
if (componentType != null && template == null) {
|
if (componentType != null && template == null) {
|
||||||
|
|||||||
Binary file not shown.
Binary file not shown.
@@ -25,6 +25,7 @@ import javax.swing.JTree;
|
|||||||
import javax.swing.tree.DefaultMutableTreeNode;
|
import javax.swing.tree.DefaultMutableTreeNode;
|
||||||
import javax.swing.tree.TreePath;
|
import javax.swing.tree.TreePath;
|
||||||
|
|
||||||
|
import org.diylc.common.ComponentType;
|
||||||
import org.diylc.common.IPlugInPort;
|
import org.diylc.common.IPlugInPort;
|
||||||
import org.diylc.swing.plugins.canvas.EmptyTransferable;
|
import org.diylc.swing.plugins.canvas.EmptyTransferable;
|
||||||
import org.diylc.swing.plugins.tree.TreePanel.Payload;
|
import org.diylc.swing.plugins.tree.TreePanel.Payload;
|
||||||
@@ -45,20 +46,37 @@ class TreeGestureListener implements DragGestureListener {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void dragGestureRecognized(DragGestureEvent dge) {
|
public void dragGestureRecognized(DragGestureEvent dge) {
|
||||||
|
ComponentType type = null;
|
||||||
|
Payload payload = null;
|
||||||
|
if (presenter.getNewComponentTypeSlot() == null) {
|
||||||
JTree tree = (JTree) dge.getComponent();
|
JTree tree = (JTree) dge.getComponent();
|
||||||
Point p = dge.getDragOrigin();
|
Point p = dge.getDragOrigin();
|
||||||
TreePath path = tree.getClosestPathForLocation(p.x, p.y);
|
TreePath path = tree.getClosestPathForLocation(p.x, p.y);
|
||||||
if (path != null && path.getLastPathComponent() instanceof DefaultMutableTreeNode) {
|
if (path != null && path.getLastPathComponent() instanceof DefaultMutableTreeNode) {
|
||||||
DefaultMutableTreeNode leaf = (DefaultMutableTreeNode) path.getLastPathComponent();
|
DefaultMutableTreeNode leaf = (DefaultMutableTreeNode) path.getLastPathComponent();
|
||||||
Payload payload = (Payload) leaf.getUserObject();
|
payload = (Payload) leaf.getUserObject();
|
||||||
if (payload != null && (payload.getComponentType() != null || payload.getClickListener() != null)) {
|
if (payload != null && (payload.getComponentType() != null || payload.getClickListener() != null))
|
||||||
if (payload.getComponentType() != null)
|
type = payload.getComponentType();
|
||||||
presenter.setNewComponentTypeSlot(payload.getComponentType(), null, true);
|
}
|
||||||
else
|
} else {
|
||||||
|
type = presenter.getNewComponentTypeSlot();
|
||||||
|
}
|
||||||
|
|
||||||
|
boolean start = false;
|
||||||
|
if (type == null)
|
||||||
|
{
|
||||||
|
if (payload != null && payload.getClickListener() != null) {
|
||||||
payload.getClickListener().mouseClicked(null);
|
payload.getClickListener().mouseClicked(null);
|
||||||
dge.startDrag(presenter.getCursorAt(dge.getDragOrigin()), new EmptyTransferable(), new TreeSourceListener(
|
start = true;
|
||||||
presenter));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
presenter.setNewComponentTypeSlot(type, null, true);
|
||||||
|
start = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (start)
|
||||||
|
dge.startDrag(presenter.getCursorAt(dge.getDragOrigin()), new EmptyTransferable(),
|
||||||
|
new TreeSourceListener(presenter));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2398,6 +2398,14 @@
|
|||||||
<changeType>IMPROVEMENT</changeType>
|
<changeType>IMPROVEMENT</changeType>
|
||||||
<description>Create a backup of config file when there is an issue with loading (cross-version)</description>
|
<description>Create a backup of config file when there is an issue with loading (cross-version)</description>
|
||||||
</org.diylc.appframework.update.Change>
|
</org.diylc.appframework.update.Change>
|
||||||
|
<org.diylc.appframework.update.Change>
|
||||||
|
<changeType>IMPROVEMENT</changeType>
|
||||||
|
<description>Automatically select dropped components from the component tree after they get placed</description>
|
||||||
|
</org.diylc.appframework.update.Change>
|
||||||
|
<org.diylc.appframework.update.Change>
|
||||||
|
<changeType>BUG_FIX</changeType>
|
||||||
|
<description>Drag&Drop from the tree sometimes picks up a wrong component type</description>
|
||||||
|
</org.diylc.appframework.update.Change>
|
||||||
</changes>
|
</changes>
|
||||||
<url>https://github.com/bancika/diy-layout-creator/releases</url>
|
<url>https://github.com/bancika/diy-layout-creator/releases</url>
|
||||||
</org.diylc.appframework.update.Version>
|
</org.diylc.appframework.update.Version>
|
||||||
|
|||||||
Reference in New Issue
Block a user