use of com.android.tools.idea.uibuilder.scene.target.DragDndTarget in project android by JetBrains.
the class SceneDragHandler method commit.
@Override
public void commit(@AndroidCoordinate int x, @AndroidCoordinate int y, int modifiers, @NotNull InsertType insertType) {
Scene scene = ((ViewEditorImpl) editor).getScreenView().getScene();
if (myComponent != null) {
NlComponent nlComponent = components.get(0);
NlComponent root = nlComponent.getRoot();
root.ensureNamespace(SdkConstants.SHERPA_PREFIX, SdkConstants.AUTO_URI);
SceneComponent component = scene.getSceneComponent(myComponent);
if (component != null) {
ArrayList<Target> targets = component.getTargets();
int dx = x - myComponent.w / 2;
int dy = y - myComponent.h / 2;
for (int i = 0; i < targets.size(); i++) {
if (targets.get(i) instanceof DragDndTarget) {
DragDndTarget target = (DragDndTarget) targets.get(i);
target.mouseRelease(scene.pxToDp(dx), scene.pxToDp(dy), nlComponent);
break;
}
}
}
}
insertComponents(-1, insertType);
scene.setDnDComponent(null);
scene.checkRequestLayoutStatus();
}
use of com.android.tools.idea.uibuilder.scene.target.DragDndTarget in project android by JetBrains.
the class SceneDragHandler method update.
@Nullable
@Override
public String update(@AndroidCoordinate int x, @AndroidCoordinate int y, int modifiers) {
String result = super.update(x, y, modifiers);
if (myComponent == null) {
return "undefined";
}
Scene scene = ((ViewEditorImpl) editor).getScreenView().getScene();
SceneComponent component = scene.getSceneComponent(myComponent);
int dx = x - myComponent.w / 2;
int dy = y - myComponent.h / 2;
myComponent.x = dx;
myComponent.y = dy;
if (component != null) {
ArrayList<Target> targets = component.getTargets();
for (int i = 0; i < targets.size(); i++) {
if (targets.get(i) instanceof DragDndTarget) {
DragDndTarget target = (DragDndTarget) targets.get(i);
target.mouseDrag(scene.pxToDp(dx), scene.pxToDp(dy), target);
break;
}
}
}
scene.checkRequestLayoutStatus();
return result;
}
use of com.android.tools.idea.uibuilder.scene.target.DragDndTarget in project android by JetBrains.
the class SceneDragHandler method start.
@Override
public void start(@AndroidCoordinate int x, @AndroidCoordinate int y, int modifiers) {
super.start(x, y, modifiers);
if (myComponent == null) {
return;
}
Scene scene = ((ViewEditorImpl) editor).getScreenView().getScene();
scene.needsRebuildList();
SceneComponent component = scene.getSceneComponent(myComponent);
ArrayList<Target> targets = component.getTargets();
int dx = x - myComponent.w / 2;
int dy = y - myComponent.h / 2;
for (int i = 0; i < targets.size(); i++) {
if (targets.get(i) instanceof DragDndTarget) {
DragDndTarget target = (DragDndTarget) targets.get(i);
target.mouseDown(scene.pxToDp(dx), scene.pxToDp(dy));
break;
}
}
}
Aggregations