diff --git a/src/lib/assets/layouts/layout.d.ts b/src/lib/assets/layouts/layout.d.ts
index f23cb974..232bf9b7 100644
--- a/src/lib/assets/layouts/layout.d.ts
+++ b/src/lib/assets/layouts/layout.d.ts
@@ -2,6 +2,8 @@ export interface CompiledLayout {
name: string;
size: [number, number];
keys: CompiledLayoutKey[];
+ fixedKeys: CompiledLayoutKey[];
+ rotationAnchor?: [number, number];
}
export interface CompiledLayoutKey {
diff --git a/src/lib/assets/layouts/t4g.layout.yml b/src/lib/assets/layouts/t4g.layout.yml
index 44978048..420c0604 100644
--- a/src/lib/assets/layouts/t4g.layout.yml
+++ b/src/lib/assets/layouts/t4g.layout.yml
@@ -2,6 +2,7 @@ name: T4G
col:
- row:
- switch: { e: 3, n: 5, w: 4, s: 6 }
+ rotationAnchor: true
- offset: [0.5, 0]
row:
- key: 2
diff --git a/src/lib/components/layout/GenericLayout.svelte b/src/lib/components/layout/GenericLayout.svelte
index fdd317d6..f4424e53 100644
--- a/src/lib/components/layout/GenericLayout.svelte
+++ b/src/lib/components/layout/GenericLayout.svelte
@@ -1,12 +1,12 @@
@@ -199,8 +264,58 @@
viewBox="0 0 {layoutInfo.size[0] * scale} {layoutInfo.size[1] * scale}"
bind:this={groupParent}
transition:fly={{ y: 48, easing: expoOut }}
+ onmousemove={dragRotation}
+ onmouseup={dragDisable}
>
- {#each layoutInfo.keys as key, i}
+
+ {#each layoutInfo.keys as key, i}
+ (focusKey = key)}
+ onclick={() => edit(i)}
+ onkeypress={({ key }) => {
+ if (key === "Enter") {
+ edit(i);
+ }
+ }}
+ />
+ {/each}
+ {#if rotationSetting}
+
+ {#if isDragging}
+ {rotation - 90}°
+ {/if}
+ {/if}
+
+
+ {#each layoutInfo.fixedKeys as key, i}
diff --git a/vite-plugin-layout.ts b/vite-plugin-layout.ts
index 301d9031..59a78fbf 100644
--- a/vite-plugin-layout.ts
+++ b/vite-plugin-layout.ts
@@ -29,6 +29,7 @@ export interface VisualLayoutSwitch extends Positionable {
s: number;
d: number;
};
+ rotationAnchor?: true;
}
const fileRegex = /\.(layout\.yml)$/;
@@ -53,6 +54,7 @@ export function compileLayout(layout: VisualLayout): CompiledLayout {
name: layout.name,
size: [0, 0],
keys: [],
+ fixedKeys: [],
};
let y = 0;
@@ -80,13 +82,16 @@ export function compileLayout(layout: VisualLayout): CompiledLayout {
} else if ("switch" in info) {
const cx = x + ox + 1;
const cy = y + oy + 1;
+ if (info.rotationAnchor) {
+ compiled.rotationAnchor = [cx, cy];
+ }
for (const [i, id] of [
info.switch.s,
info.switch.w,
info.switch.n,
info.switch.e,
].entries()) {
- compiled.keys.push({
+ (info.rotationAnchor ? compiled.fixedKeys : compiled.keys).push({
id,
shape: "quarter-circle",
cornerRadius: 0,
@@ -96,7 +101,7 @@ export function compileLayout(layout: VisualLayout): CompiledLayout {
});
}
if (info.switch.d !== undefined) {
- compiled.keys.push({
+ (info.rotationAnchor ? compiled.fixedKeys : compiled.keys).push({
id: info.switch.d,
shape: "square",
cornerRadius: 0.5,