Start implementing link dragging

This commit is contained in:
barsdeveloper
2021-11-16 22:12:41 +01:00
parent 7ec75e1ce8
commit ffe50c2be5
8 changed files with 92 additions and 32 deletions

57
dist/ueblueprint.js vendored
View File

@@ -550,10 +550,11 @@ class Grammar {
Object = r => P.seqMap(
P.seq(P.string("Begin"), P.whitespace, P.string("Object"), P.whitespace),
P.alt(
r.CustomProperties,
Grammar.CreateAttributeGrammar(r, r.AttributeName, attributeKey => Utility.objectGet(ObjectEntity.attributes, attributeKey))
)
P
.alt(
r.CustomProperties,
Grammar.CreateAttributeGrammar(r, r.AttributeName, attributeKey => Utility.objectGet(ObjectEntity.attributes, attributeKey))
)
.sepBy1(P.whitespace),
P.seq(r.WhitespaceNewline, P.string("End"), P.whitespace, P.string("Object")),
(_, attributes, __) => {
@@ -1518,7 +1519,7 @@ class SelectableDraggable extends GraphElement {
connectedCallback() {
super.connectedCallback();
this.dragObject = new Drag(this, this.blueprint, { // UDrag doesn't need blueprint
this.dragObject = new Drag(this, this.blueprint, {
looseTarget: true
});
}
@@ -1569,6 +1570,25 @@ class SelectableDraggable extends GraphElement {
}
}
class DragLink extends MouseClickDrag {
constructor(target, blueprint, options) {
super(target, blueprint, options);
}
startDrag() {
//this.selectorElement.startSelecting(this.clickedPosition)
}
dragTo(location, movement) {
//this.selectorElement.doSelecting(location)
}
endDrag() {
if (this.started) ;
}
}
class GraphNode extends SelectableDraggable {
static fromSerializedObject(str) {
@@ -1582,21 +1602,30 @@ class GraphNode extends SelectableDraggable {
*/
constructor(entity) {
super(entity, new NodeTemplate());
this.graphNodeName = 'n/a';
this.inputs = [];
this.outputs = [];
this.graphNodeName = "n/a";
this.dragLinkObjects = Array();
super.setLocation([this.entity.NodePosX, this.entity.NodePosY]);
}
connectedCallback() {
this.getAttribute('type')?.trim();
this.getAttribute("type")?.trim();
super.connectedCallback();
this.classList.add('ueb-node');
this.classList.add("ueb-node");
if (this.selected) {
this.classList.add('ueb-selected');
this.classList.add("ueb-selected");
}
this.style.setProperty('--ueb-position-x', this.location[0]);
this.style.setProperty('--ueb-position-y', this.location[1]);
this.style.setProperty("--ueb-position-x", this.location[0]);
this.style.setProperty("--ueb-position-y", this.location[1]);
this.querySelectorAll(".ueb-node-input, .ueb-node-output").forEach(element => {
this.dragLinkObjects.push(
new DragLink(element, this.blueprint, {
clickButton: 0,
moveEverywhere: true,
exitAnyButton: true,
looseTarget: true
})
);
});
}
setLocation(value = [0, 0]) {
@@ -1651,8 +1680,6 @@ class Select extends MouseClickDrag {
constructor(target, blueprint, options) {
super(target, blueprint, options);
this.stepSize = options?.stepSize;
this.mousePosition = [0, 0];
this.selectorElement = this.blueprint.selectorElement;
}

View File

@@ -1,4 +1,4 @@
import Primitive from "./Primitive";
import Primitive from "./Primitive"
export default class PathSymbol extends Primitive {

View File

@@ -2,6 +2,7 @@ import NodeTemplate from "../template/NodeTemplate"
import ObjectEntity from "../entity/ObjectEntity"
import SelectableDraggable from "./SelectableDraggable"
import SerializerFactory from "../serialization/SerializerFactory"
import DragLink from "../input/DragLink"
export default class GraphNode extends SelectableDraggable {
@@ -16,21 +17,30 @@ export default class GraphNode extends SelectableDraggable {
*/
constructor(entity) {
super(entity, new NodeTemplate())
this.graphNodeName = 'n/a'
this.inputs = []
this.outputs = []
this.graphNodeName = "n/a"
this.dragLinkObjects = Array()
super.setLocation([this.entity.NodePosX, this.entity.NodePosY])
}
connectedCallback() {
const type = this.getAttribute('type')?.trim()
const type = this.getAttribute("type")?.trim()
super.connectedCallback()
this.classList.add('ueb-node')
this.classList.add("ueb-node")
if (this.selected) {
this.classList.add('ueb-selected')
this.classList.add("ueb-selected")
}
this.style.setProperty('--ueb-position-x', this.location[0])
this.style.setProperty('--ueb-position-y', this.location[1])
this.style.setProperty("--ueb-position-x", this.location[0])
this.style.setProperty("--ueb-position-y", this.location[1])
this.querySelectorAll(".ueb-node-input, .ueb-node-output").forEach(element => {
this.dragLinkObjects.push(
new DragLink(element, this.blueprint, {
clickButton: 0,
moveEverywhere: true,
exitAnyButton: true,
looseTarget: true
})
)
})
}
setLocation(value = [0, 0]) {

View File

@@ -17,7 +17,7 @@ export default class SelectableDraggable extends GraphElement {
connectedCallback() {
super.connectedCallback()
this.dragObject = new Drag(this, this.blueprint, { // UDrag doesn't need blueprint
this.dragObject = new Drag(this, this.blueprint, {
looseTarget: true
})
}

24
js/input/DragLink.js Executable file
View File

@@ -0,0 +1,24 @@
import MouseClickDrag from "./MouseClickDrag"
export default class DragLink extends MouseClickDrag {
constructor(target, blueprint, options) {
super(target, blueprint, options)
}
startDrag() {
//this.selectorElement.startSelecting(this.clickedPosition)
}
dragTo(location, movement) {
//this.selectorElement.doSelecting(location)
}
endDrag() {
if (this.started) {
//this.selectorElement.finishSelecting()
} else {
// this.blueprint.unselectAll()
}
}
}

View File

@@ -4,8 +4,6 @@ export default class Select extends MouseClickDrag {
constructor(target, blueprint, options) {
super(target, blueprint, options)
this.stepSize = options?.stepSize
this.mousePosition = [0, 0]
this.selectorElement = this.blueprint.selectorElement
}

View File

@@ -1,4 +1,4 @@
import Context from "./Context";
import Context from "./Context"
export default class Unfocus extends Context {

View File

@@ -166,10 +166,11 @@ export default class Grammar {
Object = r => P.seqMap(
P.seq(P.string("Begin"), P.whitespace, P.string("Object"), P.whitespace),
P.alt(
r.CustomProperties,
Grammar.CreateAttributeGrammar(r, r.AttributeName, attributeKey => Utility.objectGet(ObjectEntity.attributes, attributeKey))
)
P
.alt(
r.CustomProperties,
Grammar.CreateAttributeGrammar(r, r.AttributeName, attributeKey => Utility.objectGet(ObjectEntity.attributes, attributeKey))
)
.sepBy1(P.whitespace),
P.seq(r.WhitespaceNewline, P.string("End"), P.whitespace, P.string("Object")),
(_, attributes, __) => {