feat: add room name switches to 3D view and editor toolbars

This commit is contained in:
jhartworks committed 2026-11-10 10:41:07 +01:00
1 parent 7a9b2c0a38
commit 3f6cca056c
13 files changed
+695 -585

No files matched your search

+9 -1
View File
@@ -184,6 +184,7 @@ export class NfEditor extends LitElement {
hass: { attribute: false },
building: { attribute: false },
narrow: { type: Boolean },
roomLabels: { attribute: false },
packs: { attribute: false },
loadCardEditor: { attribute: false },
_doc: { state: true },
@@ -223,6 +224,8 @@ export class NfEditor extends LitElement {
declare hass: HomeAssistant;
declare building: Building;
declare narrow: boolean;
/** Show room names in the 3D preview; the host remembers this view preference. */
declare roomLabels: boolean;
/** Imported furniture packs (from the panel's controller). */
declare packs: FurniturePack[] | undefined;
/** Loads the card's settings dialog, for the card templates (set by the panel). */
@@ -319,6 +322,7 @@ export class NfEditor extends LitElement {
constructor() {
super();
this.narrow = false;
this.roomLabels = true;
this._floorId = null;
this._arcEdit = null;
this._routeDraft = null;
@@ -1067,7 +1071,7 @@ export class NfEditor extends LitElement {
.selectedDevice=${this.sel.device}
.quality=${"auto"}
.floorThumbs=${false}
.roomLabels=${true}
.roomLabels=${this.roomLabels}
.floorStack=${this.houseTool ? "stacked" : "single"}
.panelOpen=${false}
.alerts=${false}
@@ -3184,6 +3188,10 @@ export class NfEditor extends LitElement {
</button>`,
)}
</div>
<button class="nf-chip nf-room-names-toggle" aria-pressed=${this.roomLabels} title=${this.t("room_names_toggle_hint")} @click=${() => {
this.roomLabels = !this.roomLabels;
this.dispatchEvent(new CustomEvent("room-names-change", { detail: { value: this.roomLabels }, bubbles: true, composed: true }));
}}>${this.t("room_names_short")}</button>
<div class="nf-seg">
<button ?disabled=${!this._canUndo} @click=${() => this.undo()} title="Ctrl+Z">${this.t("undo")}</button>
<button ?disabled=${!this._canRedo} @click=${() => this.redo()} title="Ctrl+Y">${this.t("redo")}</button>
+11 -2
View File
@@ -157,6 +157,7 @@ export class NfView3d extends LitElement {
_locked: { state: true },
_now: { state: true },
roomLabels: { attribute: false },
roomNamesButton: { attribute: false },
floorStack: { attribute: false },
panelOpen: { attribute: false },
alerts: { attribute: false },
@@ -304,6 +305,8 @@ export class NfView3d extends LitElement {
private clockTimer: ReturnType<typeof setInterval> | undefined;
/** Room names in 3D (cards can switch them off). */
declare roomLabels: boolean;
/** Cards expose the room-name switch in their own 3D top bar. The designer has its toolbar switch. */
declare roomNamesButton: boolean;
/** Floors below an opened floor: dimmed, stacked (the house up to it) or hidden. */
declare floorStack: FloorStack;
private declare _thumbs: { floorId: string; url: string }[];
@@ -490,6 +493,7 @@ export class NfView3d extends LitElement {
}
})();
this.roomLabels = true;
this.roomNamesButton = false;
this.floorStack = "dim";
this._low = false;
this.panelOpen = false;
@@ -2696,7 +2700,11 @@ export class NfView3d extends LitElement {
const energy = !!e && !this.roomId && this.showEnergy && !!this.hass && !(e.consumption === null && e.grid === null && e.solar === null && e.battery === null);
const climate = this.building?.floors.some((f) => f.rooms.some((r) => r.climate_card));
const climateToggle = climate ? this.renderCardToggle() : nothing;
if (!energy) return own.length || climateToggle !== nothing ? html`<div class="nf-energy" aria-live="off">${own}${climateToggle}</div>` : nothing;
const roomNames = this.roomNamesButton ? html`<button class="nf-energy-item nf-flow-toggle nf-room-names-toggle" aria-pressed=${this.roomLabels} title=${translate(this.hass, "room_names_toggle_hint")} @click=${() => {
this.roomLabels = !this.roomLabels;
this.dispatchEvent(new CustomEvent("room-names-change", { detail: { value: this.roomLabels }, bubbles: true, composed: true }));
}}><span>${translate(this.hass, "room_names_short")}</span><b aria-hidden="true">Aa</b></button>` : nothing;
if (!energy) return own.length || climateToggle !== nothing || roomNames !== nothing ? html`<div class="nf-energy" aria-live="off">${roomNames}${own}${climateToggle}</div>` : nothing;
const t = (k: Parameters<typeof translate>[1]) => translate(this.hass, k);
const items: { cls: string; label: string; value: string }[] = [];
if (e.solar !== null) items.push({ cls: "solar", label: t("energy_solar"), value: formatPower(this.hass, e.solar) });
@@ -2713,6 +2721,7 @@ export class NfView3d extends LitElement {
if (e.tariff) items.push({ cls: "tariff", label: t("energy_tariff"), value: `${formatNumber(this.hass, e.tariff.value, 3)} ${e.tariff.unit}`.trim() });
if (this.building) for (const m of this.meterRows(this.building)) items.push({ cls: "meter", label: `${m.icon} ${m.label}`, value: m.value });
return html`<div class="nf-energy" aria-live="off">
${roomNames}
${this.liveCardsOn && this._liveCards.some((c) => c.kind === "house") ? nothing : items.map((i) => html`<div class="nf-energy-item nf-energy-${i.cls}"><span>${i.label}</span><b>${i.value}</b></div>`)}
${this.flows !== null
? nothing
@@ -3148,7 +3157,7 @@ export class NfView3d extends LitElement {
.nf-person[hidden] {
display: none;
}
.nf-no-room-names .nf-pin {
.nf-no-room-names .nf-pin[data-room] {
display: none !important;
}
/* tablet level: blur over the canvas and glowing shadows are expensive on weak GPUs */