- 좌측 패널 · 아래 단추 넷 · 종단도 · 구조물 배치 폼을 페이지에 한 번만 만듦(design_shared) — 두 보기가 같은 노드 - 보기는 가운데 위 칸만: 종단 보기 = 3D(design_view_profile) · 횡단 보기 = 횡단 카드(design_view_cross · 처음 보일 때 그림) - 옛 B05_Profile_UI_Page · B06_Section_UI_Page 삭제 · 한 벌이 받은 조작은 지금 보기로, 관 목록 · 횡단 재계산 알림은 두 보기 모두로 - 진행 단계 종단설계 · 횡단설계 두 칸이 보기를 따라 켜짐 · 누르면 주소만 바꿈 · 제목도 따라감(setTitle · setActiveStep) - [저장] · [확정] 한 벌 — 두 보기 몫을 모아 saveDesign 한 번 · 종단 보기 [확정] 켬(횡단 보기를 숨긴 채 세워 횡단 자료를 얻음) - [초기화] · 계획노선 편집은 같은 페이지라도 다시 세움(remountRoute) - 덧붙임: 방향키는 초점 있는 쪽만(조정창 ↔ 종단도 계획고) · 횡단 보기 계획고 편집에도 [3D 업데이트] 대기 표시 · 종단 보기 폼 관 옵션을 횡단 캐시에도 얹음 · 종단 보기에서 횡단 조정 칸 가림 - 나눔: Cross_View 756→658(_Cross_View_Frame) · Page_Structures_Panel 700→547(_Structures_Spec) · 옛 B05 Page 786 → design_view_profile 638(_Page_Latest · _Page_Stations) - 시험: test_design_view_parity 한 벌 기준(한 패널 · 보기 오가도 같은 노드) · page_single · profile_single · save_channels · save_recompute 등 옮긴 자리로 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01KmELpdXFDRZHhfbGuRhSmL
133 lines
5.3 KiB
TypeScript
133 lines
5.3 KiB
TypeScript
/* =============================================================================
|
|
* B06_Section_UI_Cross_Panel_Base.ts
|
|
* 구조물 조정 오버레이 창 **공용 부품**(2026-08-25 사용자: 세월교·BOX암거 창을
|
|
* 기슭막이 창(`_Cross_Structure_Panel.ts`)과 같은 템플릿으로 일원화).
|
|
*
|
|
* 템플릿 규약:
|
|
* · 머리줄(`__head`) = 제목 + ✕ 닫기.
|
|
* · 항목 행 = 1행 이름 라벨 + 2행 값 조작(2026-08-22 확정 2행 구조).
|
|
* · **십자(D-pad)·9키 조작 세트는 항상 창 맨 아래**(2026-08-24·08-25 사용자).
|
|
* · 키보드 방향키 = 십자 버튼(2026-08-23) — 셀렉트·입력 포커스 중엔 양보.
|
|
* ========================================================================== */
|
|
|
|
/** 조작 버튼 하나 — 클릭이 카드 선택·팬으로 번지지 않게 막는다. */
|
|
export function makeButton(label: string, title: string, onClick: () => void): HTMLButtonElement {
|
|
const button = document.createElement("button");
|
|
button.type = "button";
|
|
button.className = "b06-structure-panel__btn";
|
|
button.textContent = label;
|
|
button.title = title;
|
|
button.addEventListener("click", (event) => {
|
|
// 카드 선택·팬으로 번지면 도면이 다시 그려져 맞춰 둔 배율이 날아간다.
|
|
event.stopPropagation();
|
|
onClick();
|
|
});
|
|
return button;
|
|
}
|
|
|
|
/** 항목 행 — 1행 이름 라벨 + 2행 값 조작. */
|
|
export function makeRow(labelText: string): { row: HTMLElement; controls: HTMLElement } {
|
|
const row = document.createElement("div");
|
|
row.className = "b06-structure-panel__struct";
|
|
const label = document.createElement("span");
|
|
label.className = "b06-structure-panel__label";
|
|
label.textContent = labelText;
|
|
const controls = document.createElement("div");
|
|
controls.className = "b06-structure-panel__controls";
|
|
row.append(label, controls);
|
|
return { row, controls };
|
|
}
|
|
|
|
/** D-pad 슬롯 버튼 — 방향키 바인딩이 슬롯 클래스로 버튼을 찾는다. */
|
|
export function dpadButton(
|
|
label: string,
|
|
slot: "up" | "down" | "left" | "right" | "reset" | "equal",
|
|
title: string,
|
|
onClick: () => void,
|
|
): HTMLButtonElement {
|
|
const button = makeButton(label, title, onClick);
|
|
button.classList.add(`b06-structure-panel__btn--${slot}`);
|
|
return button;
|
|
}
|
|
|
|
/** 창 뼈대 — root(.b06-structure-panel, 숨김 시작) + 머리줄(제목·닫기). */
|
|
export function buildPanelShell(onClose: () => void): {
|
|
root: HTMLElement;
|
|
head: HTMLElement;
|
|
title: HTMLSpanElement;
|
|
} {
|
|
const root = document.createElement("div");
|
|
root.className = "b06-structure-panel is-hidden";
|
|
root.addEventListener("click", (event) => event.stopPropagation());
|
|
const title = document.createElement("span");
|
|
title.className = "b06-structure-panel__title";
|
|
const closeButton = makeButton("✕", "닫기", onClose);
|
|
closeButton.classList.add("b06-structure-panel__close");
|
|
const head = document.createElement("div");
|
|
head.className = "b06-structure-panel__head";
|
|
head.append(title, closeButton);
|
|
root.append(head);
|
|
return { root, head, title };
|
|
}
|
|
|
|
/** 마지막으로 누른 자리 — 방향키는 **초점 있는 쪽만** 받는다(계획서 24-3b). 횡단 보기에서 조정창과
|
|
* 종단도(▲▼ 계획고)가 한 화면에 함께 있어, 종단도를 누른 뒤에는 조정창이 방향키를 넘긴다. */
|
|
let lastPointer: Element | null = null;
|
|
document.addEventListener(
|
|
"pointerdown",
|
|
(event) => {
|
|
lastPointer = event.target instanceof Element ? event.target : null;
|
|
},
|
|
true,
|
|
);
|
|
|
|
/** 방향키가 종단도 몫인가 — 마지막으로 누른 자리가 종단도 안이면 참. */
|
|
export function arrowsBelongToProfile(): boolean {
|
|
return !!lastPointer?.closest(".b05-route-profile");
|
|
}
|
|
|
|
const ARROW_SLOT: Record<string, string> = {
|
|
ArrowUp: "up",
|
|
ArrowDown: "down",
|
|
ArrowLeft: "left",
|
|
ArrowRight: "right",
|
|
};
|
|
|
|
/**
|
|
* 키보드 방향키 = 십자 버튼. `containers` 중 숨겨지지 않은 첫 행의 슬롯 버튼을
|
|
* 누른다. 창이 숨겨지면 리스너를 떼고, 카드가 통째로 사라지면 스스로 해제한다.
|
|
* 반환: show/hide 때 부를 (attach)와 (detach).
|
|
*/
|
|
export function bindArrowKeys(
|
|
root: HTMLElement,
|
|
containers: () => HTMLElement[],
|
|
): { attach: () => void; detach: () => void } {
|
|
const onArrowKey = (event: KeyboardEvent): void => {
|
|
if (!root.isConnected) {
|
|
document.removeEventListener("keydown", onArrowKey);
|
|
return;
|
|
}
|
|
const slot = ARROW_SLOT[event.key];
|
|
// 보기가 숨었으면(한 페이지 두 보기 · 계획서 24-3a) 다른 보기의 방향키를 먹지 않는다.
|
|
if (!slot || root.classList.contains("is-hidden") || !root.getClientRects().length) return;
|
|
if (arrowsBelongToProfile()) return;
|
|
const focus = event.target as HTMLElement | null;
|
|
if (focus && (focus.tagName === "SELECT" || focus.tagName === "INPUT")) return;
|
|
for (const container of containers()) {
|
|
if (container.classList.contains("is-hidden")) continue;
|
|
const button = container.querySelector<HTMLButtonElement>(
|
|
`.b06-structure-panel__btn--${slot}`,
|
|
);
|
|
if (button) {
|
|
event.preventDefault();
|
|
button.click();
|
|
return;
|
|
}
|
|
}
|
|
};
|
|
return {
|
|
attach: () => document.addEventListener("keydown", onArrowKey),
|
|
detach: () => document.removeEventListener("keydown", onArrowKey),
|
|
};
|
|
}
|