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

+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 */