mirror of
https://github.com/Matysh/houseplan-card
synced 2026-10-01 04:09:17 +00:00
fix: match wall thickness hover to masonry
Issue: #303 User-Visible: yes
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
import { wallCmToUnits } from './wall-thickness';
|
||||
|
||||
/** Historical plan-cell size whose raw SVG constants define the visual baseline. */
|
||||
export const GRID_VISUAL_REFERENCE_CELL_CM = 5;
|
||||
|
||||
@@ -16,6 +18,20 @@ export function gridVisualUnits(baseUnits: number, cellCm: unknown): number {
|
||||
return baseUnits * gridVisualScale(cellCm);
|
||||
}
|
||||
|
||||
/** Half-width of the Plan-editor wall-thickness hover strip, in plan units. */
|
||||
export function wallThickHoverHalfUnits(
|
||||
cm: number, cellCm: number, gridPitch: number,
|
||||
): number {
|
||||
const thicknessCm = Number.isFinite(cm) && cm > 0 ? cm : 0;
|
||||
const normalizedCellCm = Number.isFinite(cellCm) && cellCm > 0
|
||||
? cellCm
|
||||
: GRID_VISUAL_REFERENCE_CELL_CM;
|
||||
const normalizedPitch = Number.isFinite(gridPitch) && gridPitch > 0 ? gridPitch : 0;
|
||||
return thicknessCm > 0
|
||||
? wallCmToUnits(thicknessCm, normalizedCellCm, normalizedPitch) / 2
|
||||
: gridVisualUnits(normalizedPitch * 1.5, normalizedCellCm);
|
||||
}
|
||||
|
||||
/** Default only for newly-created spaces. Read compatibility keeps its own 5 cm fallback. */
|
||||
export function newSpaceCellCm(imperial: boolean): number {
|
||||
return imperial ? GRID_IMPERIAL_CELL_CM : 1;
|
||||
|
||||
@@ -303,7 +303,8 @@ import {
|
||||
} from './opening-dimensions';
|
||||
import { safeStoredColor } from './color';
|
||||
import {
|
||||
gridCellFieldToCm, gridCellFieldValue, gridVisualScale, gridVisualUnits, newSpaceCellCm,
|
||||
gridCellFieldToCm, gridCellFieldValue, gridVisualScale, gridVisualUnits,
|
||||
newSpaceCellCm, wallThickHoverHalfUnits,
|
||||
} from './grid-scale';
|
||||
import {
|
||||
applySpaceOrder, canStartTabDrag, markersNeedingPlacement, passedDragThreshold,
|
||||
@@ -11746,13 +11747,10 @@ class HouseplanCard extends LitElement {
|
||||
if (!this._markup || this._tool !== 'wallthick' || !this._cursorPt || this._wallDialog) return null;
|
||||
const hit = this._wallThickHit(this._cursorPt);
|
||||
if (!hit) return null;
|
||||
// Whole-wall strip: real half-depth when thickness is set, else a visible
|
||||
// minimum so thin centreline walls still light up under the cursor.
|
||||
const cm = hit.cm;
|
||||
const depth = cm > 0
|
||||
? wallCmToUnits(cm, this._cellCm, this._gridPitch)
|
||||
: this._gridPitch * 3;
|
||||
const half = Math.max(depth / 2, this._gridPitch * 1.25);
|
||||
// The visible strip follows the physical wall body. Only a zero-thickness
|
||||
// centreline receives a scale-independent visual minimum; hit testing keeps
|
||||
// its deliberately generous and separate radius in _wallThickHit().
|
||||
const half = wallThickHoverHalfUnits(hit.cm, this._cellCm, this._gridPitch);
|
||||
let d = '';
|
||||
for (const sg of hit.segs) {
|
||||
d += (d ? ' ' : '') + drawWallPreviewD(
|
||||
|
||||
Reference in New Issue
Block a user