Make elements default constructible, testing wip

This commit is contained in:
barsdeveloper
2022-12-24 15:29:12 +01:00
parent 7ed36f21e5
commit c3ab6478b0
53 changed files with 992 additions and 712 deletions

View File

@@ -6,6 +6,7 @@ import LinearColorEntity from "../../entity/LinearColorEntity"
/**
* @typedef {import("../../element/NodeElement").default} NodeElement
* @typedef {import("../../element/PinElement").default} PinElement
* @typedef {import("lit").PropertyValues} PropertyValues
*/
export default class CommentNodeTemplate extends IResizeableTemplate {
@@ -14,15 +15,19 @@ export default class CommentNodeTemplate extends IResizeableTemplate {
#selectableAreaHeight = 0
/** @param {NodeElement} element */
constructed(element) {
initialize(element) {
if (element.entity.CommentColor) {
this.#color.setFromRGBANumber(element.entity.CommentColor.toNumber())
this.#color.setFromHSVA(this.#color.H.value, this.#color.S.value, Math.pow(this.#color.V.value, 0.45) * 0.67)
this.#color.setFromHSVA(
this.#color.H.value,
this.#color.S.value,
Math.pow(this.#color.V.value, 0.45) * 0.67
)
}
element.classList.add("ueb-node-style-comment", "ueb-node-resizeable")
element.sizeX ??= 25 * Configuration.gridSize
element.sizeY ??= 6 * Configuration.gridSize
super.constructed(element) // Keep it at the end because it calls this.getColor() where this.#color must be initialized
super.initialize(element) // Keep it at the end because it calls this.getColor() where this.#color must be initialized
}
getColor() {
@@ -45,7 +50,7 @@ export default class CommentNodeTemplate extends IResizeableTemplate {
`
}
/** @param {Map} changedProperties */
/** @param {PropertyValues} changedProperties */
firstUpdated(changedProperties) {
super.firstUpdated(changedProperties)
const bounding = this.getDraggableElement().getBoundingClientRect()