diff --git a/src/bim/drawing.ts b/src/bim/drawing.ts index 8bcb70e..5eefb11 100644 --- a/src/bim/drawing.ts +++ b/src/bim/drawing.ts @@ -400,6 +400,32 @@ export async function openDrawing(app: AppContext, which?: string): Promise("[data-ann]"))) { + for (const tx of Array.from(g.querySelectorAll("text"))) { + let b: DOMRect; + try { + b = tx.getBBox(); + } catch { + continue; + } + if (!b.width && !b.height) continue; + const r = document.createElementNS("http://www.w3.org/2000/svg", "rect"); + r.setAttribute("x", String(b.x - pad)); + r.setAttribute("y", String(b.y - pad)); + r.setAttribute("width", String(b.width + pad * 2)); + r.setAttribute("height", String(b.height + pad * 2)); + r.setAttribute("fill", "transparent"); + r.setAttribute("class", "bim-ann-pad"); + const tf = tx.getAttribute("transform"); + if (tf) r.setAttribute("transform", tf); + tx.before(r); + } + } + } if (s) s.insertAdjacentHTML("beforeend", picksSVG()); hoverKey = ""; drawHover(); @@ -462,7 +488,7 @@ export async function openDrawing(app: AppContext, which?: string): Promise(); let pinch: { d: number; mid: [number, number] } | null = null; @@ -505,6 +531,15 @@ export async function openDrawing(app: AppContext, which?: string): Promise W || q[1] > H) return; @@ -573,6 +608,13 @@ export async function openDrawing(app: AppContext, which?: string): Promise putDrawing(doc, current, d)); + else if (tap && tool) useTool(tap.q, tap.e); else render(); }; paper.addEventListener("pointerup", endDrag); @@ -1223,8 +1267,12 @@ export async function openDrawing(app: AppContext, which?: string): Promise void, on = false) => { @@ -1511,6 +1559,26 @@ export async function openDrawing(app: AppContext, which?: string): Promise n.id === id); + const img = o.images.find((m) => m.id === id); + const dim = dimsOf(o).find((d) => d.id === id); + if (note) set({ notes: o.notes.map((n) => (n === note ? { ...n, x: note.x + dx, y: note.y + dy } : n)) }); + else if (img) set({ images: o.images.map((m) => (m === img ? { ...m, x: img.x + dx, y: img.y + dy } : m)) }); + else if (dim) { + const out = dx - dy; + const far = Math.max(1, Math.abs(dim.offset) + out); + set(withDim(o, { ...dim, offset: (Math.sign(dim.offset) || 1) * far })); + } } else if (!e.ctrlKey && !e.metaKey && !e.altKey && ["+", "=", "-", "_", "f", "F", "0"].includes(e.key)) { // Zoom in / out, all of the sheet. e.preventDefault(); @@ -1543,7 +1611,13 @@ export async function openDrawing(app: AppContext, which?: string): Promise button(label, icon, () => startTool(tool === t ? null : t), { on: tool === t, sub: true }); + // (A phone: a group's tools are listed by name over the sheet; one picked, the list folds away and the sheet is + // clear to tap - the bar at the top says which tool is on.) + const pick = (t: ToolId, label: string, icon: IconName) => + button(label, icon, () => { + if (document.documentElement.dataset.screen === "phone" && tool !== t) open = null; + startTool(tool === t ? null : t); + }, { on: tool === t, sub: true }); button("Views", "views", () => ((open = open === "views" ? null : "views"), renderTools()), { on: open === "views" || tool === "section" || tool === "detail" || tool === "base" || tool === "projection" }); if (open === "views") { const toggle = (k: "front" | "top" | "side" | "iso", label: string) => diff --git a/src/style.css b/src/style.css index f954510..e3db11d 100644 --- a/src/style.css +++ b/src/style.css @@ -6925,3 +6925,48 @@ html[data-screen="phone"] body.sentence-ui #toast { #popover .pop-note { margin-top: 6px; } + +/* A drawing: what can be dragged says so under the pointer - a dimension, a note or a picture lights up (no tool on), + and the see-through pad round its text is part of it. */ +.bim-drawing-paper:not(.picking) .bim-drawing-svg [data-ann]:hover { + filter: drop-shadow(0 0 0.5px #3d8bff) drop-shadow(0 0 0.5px #3d8bff); +} +.bim-drawing-svg .bim-ann-pad { + pointer-events: all; +} +.bim-idle-hint { + color: var(--muted); + font-size: 12.5px; +} + +/* A drawing on a phone: the tools are a strip of pictures - with a group open (Views, Dimensions, Centrelines) the + strip comes out over the sheet with every tool's name beside its picture (ten dimension tools were ten pictures, + two pairs of them the same). The sheet keeps its place under it. */ +html[data-screen="phone"] .bim-dwork { + position: relative; +} +html[data-screen="phone"] .bim-dwork:has(.bim-dtools .bim-dtool.sub) { + padding-left: calc(52px + var(--safe-l)); +} +html[data-screen="phone"] .bim-dtools:has(.bim-dtool.sub) { + position: absolute; + left: 0; + top: 0; + bottom: 0; + width: min(230px, 72vw); + z-index: 6; + background: var(--chrome-solid, #1c1e22); + box-shadow: 12px 0 28px rgba(0, 0, 0, 0.45); +} +html[data-screen="phone"] .bim-dtools:has(.bim-dtool.sub) .bim-dtool { + justify-content: flex-start; + padding: 10px 10px; + gap: 10px; +} +html[data-screen="phone"] .bim-dtools:has(.bim-dtool.sub) .bim-dtool span { + display: inline; + font-size: 13.5px; +} +html[data-screen="phone"] .bim-dtools:has(.bim-dtool.sub) .bim-dtool.sub { + padding-left: 22px; +}