Vector2D support

This commit is contained in:
barsdeveloper
2022-12-24 18:46:49 +01:00
parent c3ab6478b0
commit 3df33bfe05
14 changed files with 230 additions and 16 deletions

View File

@@ -25,8 +25,8 @@ export default class CommentNodeTemplate extends IResizeableTemplate {
)
}
element.classList.add("ueb-node-style-comment", "ueb-node-resizeable")
element.sizeX ??= 25 * Configuration.gridSize
element.sizeY ??= 6 * Configuration.gridSize
element.sizeX = 25 * Configuration.gridSize
element.sizeY = 6 * Configuration.gridSize
super.initialize(element) // Keep it at the end because it calls this.getColor() where this.#color must be initialized
}

View File

@@ -84,7 +84,7 @@ export default class PinTemplate extends ITemplate {
firstUpdated(changedProperties) {
super.firstUpdated(changedProperties)
this.element.style.setProperty("--ueb-pin-color-rgb", Configuration.getPinColor(this.element).cssText)
this.#iconElement = this.element.querySelector(".ueb-pin-icon") ?? this.element
this.#iconElement = this.element.querySelector(".ueb-pin-icon svg") ?? this.element
}
getLinkLocation() {

View File

@@ -0,0 +1,50 @@
import { html } from "lit"
import IInputPinTemplate from "./IInputPinTemplate"
import INumericPinTemplate from "./INumericInputPinTemplate"
import Utility from "../../Utility"
import Vector2DEntity from "../../entity/Vector2DEntity"
/** @typedef {import("../../entity/LinearColorEntity").default} LinearColorEntity */
/**
* @extends INumericPinTemplate<Vector2DEntity>
*/
export default class VectorInputPinTemplate extends INumericPinTemplate {
#getX() {
return IInputPinTemplate.stringFromUEToInput(Utility.minDecimals(this.element.getDefaultValue()?.X ?? 0))
}
#getY() {
return IInputPinTemplate.stringFromUEToInput(Utility.minDecimals(this.element.getDefaultValue()?.Y ?? 0))
}
/**
* @param {Number[]} values
* @param {String[]} rawValues
*/
setDefaultValue(values, rawValues) {
const vector = this.element.getDefaultValue(true)
if (!(vector instanceof Vector2DEntity)) {
throw new TypeError("Expected DefaultValue to be a Vector2DEntity")
}
vector.X = values[0]
vector.Y = values[1]
this.element.requestUpdate("DefaultValue", vector)
}
renderInput() {
return html`
<div class="ueb-pin-input-wrapper">
<span class="ueb-pin-input-label">X</span>
<div class="ueb-pin-input">
<ueb-input .singleLine="${true}" .innerText="${this.#getX()}"></ueb-input>
</div>
<span class="ueb-pin-input-label">Y</span>
<div class="ueb-pin-input">
<ueb-input .singleLine="${true}" .innerText="${this.#getY()}"></ueb-input>
</div>
</div>
`
}
}

View File

@@ -9,7 +9,7 @@ import VectorEntity from "../../entity/VectorEntity"
/**
* @extends INumericPinTemplate<VectorEntity>
*/
export default class VectorInputPinTemplate extends INumericPinTemplate {
export default class VectorPinTemplate extends INumericPinTemplate {
#getX() {
return IInputPinTemplate.stringFromUEToInput(Utility.minDecimals(this.element.getDefaultValue()?.X ?? 0))