Add add button
This commit is contained in:
parent
b6cbc975cb
commit
a27da83c46
@ -6,6 +6,8 @@ import {
|
|||||||
property
|
property
|
||||||
} from "lit-element";
|
} from "lit-element";
|
||||||
|
|
||||||
|
import { mdiPlus } from "@mdi/js";
|
||||||
|
|
||||||
const SIZE = 35;
|
const SIZE = 35;
|
||||||
const DIST = 20;
|
const DIST = 20;
|
||||||
|
|
||||||
@ -39,6 +41,19 @@ class ScriptGraph2 extends LitElement {
|
|||||||
`;
|
`;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private _draw_new_node(x, y, node) {
|
||||||
|
return svg`
|
||||||
|
<circle
|
||||||
|
cx="${x}"
|
||||||
|
cy="${y + this.nodeSize/4}"
|
||||||
|
r="${this.nodeSize/4}"
|
||||||
|
class="newnode"
|
||||||
|
@click=${node.addCallback}
|
||||||
|
/>
|
||||||
|
`;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
private _draw_connector(x1, y1, x2, y2) {
|
private _draw_connector(x1, y1, x2, y2) {
|
||||||
return svg`
|
return svg`
|
||||||
<line
|
<line
|
||||||
@ -108,6 +123,19 @@ class ScriptGraph2 extends LitElement {
|
|||||||
height += this.nodeSize + this.nodeSeparation;
|
height += this.nodeSize + this.nodeSeparation;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
if(tree.addCallback) {
|
||||||
|
pieces.push(this._draw_connector(
|
||||||
|
0,
|
||||||
|
height,
|
||||||
|
0,
|
||||||
|
height + this.nodeSeparation
|
||||||
|
));
|
||||||
|
pieces.push(this._draw_new_node(
|
||||||
|
0, height + this.nodeSeparation,
|
||||||
|
tree
|
||||||
|
));
|
||||||
|
height += this.nodeSeparation + this.nodeSize/2;
|
||||||
|
}
|
||||||
if(tree.end !== false) {
|
if(tree.end !== false) {
|
||||||
// Draw bottom connector
|
// Draw bottom connector
|
||||||
pieces.push(this._draw_connector(
|
pieces.push(this._draw_connector(
|
||||||
@ -154,6 +182,9 @@ class ScriptGraph2 extends LitElement {
|
|||||||
stroke-width: 5;
|
stroke-width: 5;
|
||||||
fill: white;
|
fill: white;
|
||||||
}
|
}
|
||||||
|
.newnode:hover {
|
||||||
|
stroke: rgb(255, 152, 0);
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
<svg width=${tree.width + 32} height=${tree.height + 32}>
|
<svg width=${tree.width + 32} height=${tree.height + 32}>
|
||||||
<g transform="translate(${tree.width/2 + 16} 16)">
|
<g transform="translate(${tree.width/2 + 16} 16)">
|
||||||
|
Loading…
x
Reference in New Issue
Block a user