Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 11 additions & 24 deletions src/components/GroupAnchorOffsetOverlay/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,31 +50,18 @@ export const GroupAnchorOffsetOverlay = ({
const hoveredElement = (hoveredPrimitive._parent_pcb_component ||
hoveredPrimitive._element) as PcbComponent | undefined

if (!hoveredElement) return null

let parentGroup: PcbGroup | undefined
let targetCenter: Point | undefined

if (
hoveredElement.type === "pcb_component" &&
hoveredElement.position_mode === "relative_to_group_anchor"
) {
parentGroup = elements
.filter((el): el is PcbGroup => el.type === "pcb_group")
.find(
(group) =>
group.pcb_group_id ===
hoveredElement.positioned_relative_to_pcb_group_id,
)
targetCenter = hoveredElement.center
} else if ("pcb_group_id" in hoveredElement) {
parentGroup = elements
.filter((el): el is PcbGroup => el.type === "pcb_group")
.find((group) => group.pcb_group_id === hoveredElement.pcb_group_id)
targetCenter = hoveredElement.center
}
if (!hoveredElement?.pcb_group_id) return null

const parentGroup = elements
.filter((el): el is PcbGroup => el.type === "pcb_group")
.find((group) => group.pcb_group_id === hoveredElement.pcb_group_id)

if (!parentGroup?.anchor_position || !targetCenter) return null
if (!parentGroup?.anchor_position) return null

const targetCenter: Point = hoveredElement.center || {
x: hoveredPrimitive.x,
y: hoveredPrimitive.y,
}

const groupComponents = elements
.filter((el): el is PcbComponent => el.type === "pcb_component")
Expand Down
10 changes: 5 additions & 5 deletions src/components/ToolbarOverlay.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -266,10 +266,10 @@ export const ToolbarOverlay = ({ children, elements }: Props) => {
numLayers <= 2
? ["top", "bottom"]
: [
"top",
...Array.from({ length: numLayers - 2 }, (_, i) => `inner${i + 1}`),
"bottom",
]
"top",
...Array.from({ length: numLayers - 2 }, (_, i) => `inner${i + 1}`),
"bottom",
]

const processedLayers = availableLayers

Expand Down Expand Up @@ -719,7 +719,7 @@ export const ToolbarOverlay = ({ children, elements }: Props) => {
}}
/>
<CheckboxMenuItem
label="Show Group Anchor Offsets"
label="Anchor Offsets on Hover"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

both these options should be available, they do different things

checked={viewSettings.is_showing_group_anchor_offsets}
onClick={() => {
setIsShowingGroupAnchorOffsets(
Expand Down
2 changes: 1 addition & 1 deletion src/global-store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ export const createStore = (
: getStoredBoolean(STORAGE_KEYS.IS_SHOWING_PCB_GROUPS, true),
is_showing_group_anchor_offsets: getStoredBoolean(
STORAGE_KEYS.IS_SHOWING_GROUP_ANCHOR_OFFSETS,
process.env.NODE_ENV !== "production",
true,
),
is_showing_solder_mask: getStoredBoolean(
STORAGE_KEYS.IS_SHOWING_SOLDER_MASK,
Expand Down