Mayo commited on
fix: manual textbox modification should lock box
Browse files
koharu-app/src/renderer.rs
CHANGED
|
@@ -1084,6 +1084,21 @@ mod tests {
|
|
| 1084 |
assert_eq!(layout_boxes[0].bubble_id, Some(1));
|
| 1085 |
}
|
| 1086 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1087 |
#[test]
|
| 1088 |
fn mask_collision_detects_alpha_outside_matched_bubble() {
|
| 1089 |
let mut mask = GrayImage::from_pixel(10, 10, Luma([0u8]));
|
|
|
|
| 1084 |
assert_eq!(layout_boxes[0].bubble_id, Some(1));
|
| 1085 |
}
|
| 1086 |
|
| 1087 |
+
#[test]
|
| 1088 |
+
fn locked_block_keeps_manual_layout_box_inside_bubble() {
|
| 1089 |
+
let mut mask = GrayImage::from_pixel(200, 200, Luma([0u8]));
|
| 1090 |
+
paint_rect(&mut mask, 20, 20, 180, 180, 1);
|
| 1091 |
+
let index = BubbleIndex::new(mask);
|
| 1092 |
+
let mut locked = block(70.0, 70.0, 20.0, 30.0, "hello");
|
| 1093 |
+
locked.lock_layout_box = true;
|
| 1094 |
+
let blocks = vec![locked];
|
| 1095 |
+
|
| 1096 |
+
let layout_boxes = resolve_layout_boxes(&blocks, Some(&index));
|
| 1097 |
+
|
| 1098 |
+
assert_eq!(layout_boxes[0].layout_box, seed_layout_box(&blocks[0]));
|
| 1099 |
+
assert_eq!(layout_boxes[0].bubble_id, None);
|
| 1100 |
+
}
|
| 1101 |
+
|
| 1102 |
#[test]
|
| 1103 |
fn mask_collision_detects_alpha_outside_matched_bubble() {
|
| 1104 |
let mut mask = GrayImage::from_pixel(10, 10, Luma([0u8]));
|
ui/components/canvas/TextBlockLayer.tsx
CHANGED
|
@@ -6,7 +6,7 @@ import { useHotkeys } from 'react-hotkeys-hook'
|
|
| 6 |
|
| 7 |
import { useBlobImage } from '@/hooks/useBlobData'
|
| 8 |
import { useCurrentPage, useTextNodes, type TextNodeEntry } from '@/hooks/useCurrentPage'
|
| 9 |
-
import type { Transform } from '@/lib/api/schemas'
|
| 10 |
import { applyOp, queueAutoRender } from '@/lib/io/scene'
|
| 11 |
import { ops } from '@/lib/ops'
|
| 12 |
import { useEditorUiStore } from '@/lib/stores/editorUiStore'
|
|
@@ -57,7 +57,12 @@ export function TextBlockLayer({ showSprites, scale, style }: TextBlockLayerProp
|
|
| 57 |
|
| 58 |
const updateTransform = async (id: string, t: Transform) => {
|
| 59 |
if (!page) return
|
| 60 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 61 |
queueAutoRender(page.id)
|
| 62 |
}
|
| 63 |
|
|
|
|
| 6 |
|
| 7 |
import { useBlobImage } from '@/hooks/useBlobData'
|
| 8 |
import { useCurrentPage, useTextNodes, type TextNodeEntry } from '@/hooks/useCurrentPage'
|
| 9 |
+
import type { NodeDataPatch, Transform } from '@/lib/api/schemas'
|
| 10 |
import { applyOp, queueAutoRender } from '@/lib/io/scene'
|
| 11 |
import { ops } from '@/lib/ops'
|
| 12 |
import { useEditorUiStore } from '@/lib/stores/editorUiStore'
|
|
|
|
| 57 |
|
| 58 |
const updateTransform = async (id: string, t: Transform) => {
|
| 59 |
if (!page) return
|
| 60 |
+
const data: NodeDataPatch = {
|
| 61 |
+
text: {
|
| 62 |
+
lockLayoutBox: true,
|
| 63 |
+
},
|
| 64 |
+
}
|
| 65 |
+
await applyOp(ops.updateNode(page.id, id, { transform: t, data }))
|
| 66 |
queueAutoRender(page.id)
|
| 67 |
}
|
| 68 |
|
ui/components/canvas/Workspace.tsx
CHANGED
|
@@ -128,7 +128,7 @@ export function Workspace() {
|
|
| 128 |
id: nodeId,
|
| 129 |
transform,
|
| 130 |
visible: true,
|
| 131 |
-
kind: { text: {} },
|
| 132 |
}
|
| 133 |
await applyOp(ops.addNode(page.id, at, node))
|
| 134 |
useSelectionStore.getState().selectMany([nodeId])
|
|
|
|
| 128 |
id: nodeId,
|
| 129 |
transform,
|
| 130 |
visible: true,
|
| 131 |
+
kind: { text: { lockLayoutBox: true } },
|
| 132 |
}
|
| 133 |
await applyOp(ops.addNode(page.id, at, node))
|
| 134 |
useSelectionStore.getState().selectMany([nodeId])
|