Fix pin colors, input refactoring

This commit is contained in:
barsdeveloper
2023-01-08 15:34:00 +01:00
parent 55f9719fa9
commit bb84b31b07
20 changed files with 245 additions and 259 deletions

View File

@@ -5,11 +5,6 @@ import Utility from "../../Utility"
/** @typedef {import("lit").PropertyValues} PropertyValues */
/**
* @template T
* @typedef {import("../../element/PinElement").default<T>} PinElement
*/
/**
* @template T
* @extends PinTemplate<T>
@@ -104,7 +99,7 @@ export default class IInputPinTemplate extends PinTemplate {
return html`
<div class="ueb-pin-input">
<ueb-input .singleLine="${singleLine}" .selectOnFocus="${selectOnFocus}"
.innerText="${IInputPinTemplate.stringFromUEToInput(this.element.entity.DefaultValue.toString())}">
.innerText="${IInputPinTemplate.stringFromUEToInput(this.element.getDefaultValue()?.toString() ?? "")}">
</ueb-input>
</div>
`

View File

@@ -11,13 +11,16 @@ export default class InputTemplate extends ITemplate {
getSelection().selectAllChildren(this.element)
}
}
#focusoutHandler = () => {
this.blueprint.acknowledgeEditText(false)
getSelection().removeAllRanges() // Deselect eventually selected text inside the input
}
/** @param {InputEvent} e */
#inputSingleLineHandler = e =>
/** @type {HTMLElement} */(e.target).querySelectorAll("br").forEach(br => br.remove())
/** @param {KeyboardEvent} e */
#onKeydownBlurOnEnterHandler = e => {
if (e.code == "Enter" && !e.shiftKey) {

View File

@@ -1,4 +1,4 @@
import { html } from "lit"
import { html, nothing } from "lit"
import ColorPickerWindowTemplate from "../ColorPickerWindowTemplate"
import Configuration from "../../Configuration"
import ElementFactory from "../../element/ElementFactory"
@@ -48,9 +48,9 @@ export default class LinearColorPinTemplate extends PinTemplate {
renderInput() {
return html`
<span class="ueb-pin-input" data-linear-color="${this.element.defaultValue.toString()}"
<span class="ueb-pin-input" data-linear-color="${this.element.getDefaultValue()?.toString() ?? nothing}"
@click="${this.#launchColorPickerWindow}"
style="--ueb-linear-color: rgba(${this.element.defaultValue.toString()})">
style="--ueb-linear-color: rgba(${this.element.getDefaultValue()?.toString() ?? nothing})">
</span>
`
}

View File

@@ -1,5 +1,4 @@
import { html } from "lit"
import IInputPinTemplate from "./IInputPinTemplate"
import INumericPinTemplate from "./INumericPinTemplate"
import Utility from "../../Utility"
@@ -17,7 +16,7 @@ export default class RealPinTemplate extends INumericPinTemplate {
return html`
<div class="ueb-pin-input">
<ueb-input .singleLine="${true}"
.innerText="${IInputPinTemplate.stringFromUEToInput(Utility.minDecimals(this.element.getDefaultValue() ?? 0))}">
.innerText="${Utility.minDecimals(this.element.getDefaultValue() ?? 0)}">
</ueb-input>
</div>
`

View File

@@ -1,5 +1,4 @@
import { html } from "lit"
import IInputPinTemplate from "./IInputPinTemplate"
import INumericPinTemplate from "./INumericPinTemplate"
import RotatorEntity from "../../entity/RotatorEntity"
import Utility from "../../Utility"
@@ -10,15 +9,15 @@ import Utility from "../../Utility"
export default class RotatorPinTemplate extends INumericPinTemplate {
#getR() {
return IInputPinTemplate.stringFromUEToInput(Utility.minDecimals(this.element.getDefaultValue()?.R ?? 0))
return Utility.minDecimals(this.element.getDefaultValue()?.R ?? 0)
}
#getP() {
return IInputPinTemplate.stringFromUEToInput(Utility.minDecimals(this.element.getDefaultValue()?.P ?? 0))
return Utility.minDecimals(this.element.getDefaultValue()?.P ?? 0)
}
#getY() {
return IInputPinTemplate.stringFromUEToInput(Utility.minDecimals(this.element.getDefaultValue()?.Y ?? 0))
return Utility.minDecimals(this.element.getDefaultValue()?.Y ?? 0)
}
setDefaultValue(values = [], rawValues = values) {

View File

@@ -1,22 +1,19 @@
import { html } from "lit"
import IInputPinTemplate from "./IInputPinTemplate"
import INumericPinTemplate from "./INumericPinTemplate"
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))
return Utility.minDecimals(this.element.getDefaultValue()?.X ?? 0)
}
#getY() {
return IInputPinTemplate.stringFromUEToInput(Utility.minDecimals(this.element.getDefaultValue()?.Y ?? 0))
return Utility.minDecimals(this.element.getDefaultValue()?.Y ?? 0)
}
/**

View File

@@ -1,26 +1,23 @@
import { html } from "lit"
import IInputPinTemplate from "./IInputPinTemplate"
import INumericPinTemplate from "./INumericPinTemplate"
import Utility from "../../Utility"
import VectorEntity from "../../entity/VectorEntity"
/** @typedef {import("../../entity/LinearColorEntity").default} LinearColorEntity */
/**
* @extends INumericPinTemplate<VectorEntity>
*/
export default class VectorPinTemplate extends INumericPinTemplate {
#getX() {
return IInputPinTemplate.stringFromUEToInput(Utility.minDecimals(this.element.getDefaultValue()?.X ?? 0))
return Utility.minDecimals(this.element.getDefaultValue()?.X ?? 0)
}
#getY() {
return IInputPinTemplate.stringFromUEToInput(Utility.minDecimals(this.element.getDefaultValue()?.Y ?? 0))
return Utility.minDecimals(this.element.getDefaultValue()?.Y ?? 0)
}
#getZ() {
return IInputPinTemplate.stringFromUEToInput(Utility.minDecimals(this.element.getDefaultValue()?.Z ?? 0))
return Utility.minDecimals(this.element.getDefaultValue()?.Z ?? 0)
}
/**