Task #202: 다각형 리사이즈 + 드래그 실시간 반영 + 도형 클릭시 맨 앞으로 이동#215
Conversation
- Rust: Polygon/Curve 리사이즈 시 original_width/height를 새 값으로 덮어쓰던 버그 수정 렌더러의 스케일 팩터(sx = current/original)가 올바르게 적용되도록 생성 시 값 유지 - TS: 단일 shape/image 드래그 시 실시간 크기/위치 반영 기존에는 group만 드래그 중 업데이트했으나 모든 비line 도형으로 확대 Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
- Shape/Line/Group 클릭 시 changeShapeZOrder('front') 호출
- 단일 클릭, Shift+다중 클릭 모두 지원
- 이미지/방정식은 z-order 미지원으로 제외
Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
중복되던 z-order 변경 코드를 bringShapeToFront() 함수로 추출하여 Shift+클릭, 직선 클릭, 도형 클릭 3곳에서 재사용. Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
This PR addresses shape editing UX and correctness issues in the document engine + studio by fixing polygon/curve resize scaling, enabling real-time updates during single-shape resize drags, and bringing clicked shapes to the front via z-order changes.
Changes:
- Preserve Polygon/Curve
original_width/heightso renderer scaling (current/original) works correctly during resize. - Expand resize-drag real-time updates from only
groupto most single selected objects (excludingline). - Change click behavior so
shape/line/groupselections are moved to the front and emitdocument-changed.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
src/document_core/commands/object_ops.rs |
Saves/restores polygon/curve original dimensions to keep renderer scale factor correct. |
rhwp-studio/src/engine/input-handler-picture.ts |
Updates single-selection resize drag to apply live size/position updates for non-line objects. |
rhwp-studio/src/engine/input-handler-mouse.ts |
Brings clicked shapes/lines/groups to front by calling changeShapeZOrder('front') and emitting document updates. |
Comments suppressed due to low confidence (2)
src/document_core/commands/object_ops.rs:1633
- Polygon/Curve 케이스에서 아래 블록이
original_width/height를 새 값으로 한번 덮어쓴 뒤(16261633), 이후에 다시 saved 값으로 복원하고 있습니다(17771781). 현재는 중간에 original_를 참조하는 로직이 없어서 동작하겠지만, 유지보수 관점에서 임시로 잘못된 original_ 상태가 생기지 않도록 Polygon/Curve일 때는 original_*를 아예 갱신하지 않고 current_만 갱신하는 분기로 정리하는 편이 안전합니다(그러면 saved_orig_ + 복원 블록도 제거 가능).
// ShapeComponentAttr 크기/회전/채우기 동기화
if let Some(d) = shape.drawing_mut() {
if let Some(w) = new_w {
d.shape_attr.current_width = w;
d.shape_attr.original_width = w;
}
if let Some(h) = new_h {
d.shape_attr.current_height = h;
d.shape_attr.original_height = h;
}
rhwp-studio/src/engine/input-handler-picture.ts:398
- 단일 선택 리사이즈 드래그에서 매 RAF마다
setObjectProperties+document-changed를 무조건 호출하고 있어(390~398) WASM 호출/리플로우가 불필요하게 많이 발생할 수 있습니다. 직전 프레임에 적용한 width/height/offset과 동일하면 호출을 스킵하도록 캐싱(예: state에 lastApplied 값 저장)하거나, 값이 바뀐 경우에만 emit하도록 조건을 추가하는 쪽이 성능/부하 면에서 안전합니다.
// 단일 선택 (그룹/shape/image 등): 드래그 중 실시간 크기/위치 반영
if (!state.multiRefs && state.ref.type !== 'line') {
const newW = Math.max(Math.round(newBbox.width * PX_TO_HWP), MIN_SIZE_HWP);
const newH = Math.max(Math.round(newBbox.height * PX_TO_HWP), MIN_SIZE_HWP);
const newHorzOffset = Math.round(newBbox.x * PX_TO_HWP);
const newVertOffset = Math.round(newBbox.y * PX_TO_HWP);
try {
setObjectProperties.call(this, state.ref, {
width: newW,
height: newH,
horzOffset: (newHorzOffset >>> 0),
vertOffset: (newVertOffset >>> 0),
});
this.eventBus.emit('document-changed');
} catch { /* ignore */ }
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| // Shift+클릭: 다중 선택 + 맨 앞으로 이동 | ||
| if (e.shiftKey && this.cursor.isInPictureObjectSelection()) { | ||
| if (picHit.type === 'shape' || picHit.type === 'line' || picHit.type === 'group') { | ||
| try { | ||
| this.wasm.changeShapeZOrder(picHit.sec, picHit.ppi, picHit.ci, 'front'); | ||
| this.eventBus.emit('document-changed'); | ||
| } catch { /* ignore */ } | ||
| } |
There was a problem hiding this comment.
여기 주석은 "Shift+클릭: 다중 선택 + 맨 앞으로 이동"으로 되어 있지만, 실제로는 shape/line/group에 대해서만 z-order를 변경하고(image/equation은 제외) 있습니다. 동작과 일치하도록 주석을 타입 조건까지 포함해 더 정확히 써두는 게 좋겠습니다.
| if (picHit.type === 'shape' || picHit.type === 'line' || picHit.type === 'group') { | ||
| try { | ||
| this.wasm.changeShapeZOrder(picHit.sec, picHit.ppi, picHit.ci, 'front'); | ||
| this.eventBus.emit('document-changed'); | ||
| } catch { /* ignore */ } |
There was a problem hiding this comment.
changeShapeZOrder(..., 'front') + document-changed emit 로직이 아래 try 블록과 동일한 형태로 파일 내 여러 군데(Shift+클릭/line 클릭/shape 클릭) 반복됩니다. 공통 헬퍼로 묶어두면 지원 타입/예외 처리 변경 시 중복 수정으로 인한 누락을 줄일 수 있습니다.
2026-04-20~21 사이클 정리: PR 처리 9건: - admin merge 5: #209 #214 #215 #221 #224 - cherry-pick + close 2: #213 (+중복 #210 close), #181 (+golden 재생성) - dependabot close 2: #211 #212 (devel 수동 bump + target-branch=devel 설정) - 보류 1: #165 skia (별도 사이클) 이슈 close 7: #173 #195 #202 #205 #207 #210 #222 신규 이슈 등록 1: #204 (표 Undo/Redo) Chrome Web Store / Edge Add-ons v0.2.1 심사 통과 (2026-04-21). local/task205 폐기: PR #209+#214 가 중복 처리하여 잔여 고유 기여 분리 곤란. 기여자 7명 감사 기록. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
한글판 README.md 와 영문판 README_EN.md 의 섹션 구조·내용을 1:1 일치시킴. 주요 변경: - Roadmap + Milestones 섹션을 상단(로드맵/이정표 위치) 으로 이동 - v0.5.0 ~ v0.7.x 이정표에 v0.2.1 사이클 전체 반영 (Chrome/Edge 심사 통과, PR #213/#215/#221/#169/#209/#214/#224/#181) - rhwp-firefox (v0.1.1 AMO 준비) + rhwp-safari (v0.2.1) 섹션 추가 - 기여자 감사 목록 확장: @seo-rii, @planet6897, @yl-star7 추가 (9명) - Features: OLE/Chart/EMF native rendering 항목 추가 (#221) - Project Structure: src/emf/, src/ooxml_chart/, rhwp-firefox/, rhwp-shared/ 반영 - Trademark 섹션 신규 (한글판 동일 위치) - AI 페어 프로그래밍 섹션: Git Workflow / Task Workflow / Debugging Protocol / Documentation Rules 완전 반영 - 로드맵 링크를 mydocs/eng/report/rhwp-milestone.md 로 보정 - 테스트 수치 783 → 935 Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
한글판 README.md 와 영문판 README_EN.md 의 섹션 구조·내용을 1:1 일치시킴. 주요 변경: - Roadmap + Milestones 섹션을 상단(로드맵/이정표 위치) 으로 이동 - v0.5.0 ~ v0.7.x 이정표에 v0.2.1 사이클 전체 반영 (Chrome/Edge 심사 통과, PR #213/#215/#221/#169/#209/#214/#224/#181) - rhwp-firefox (v0.1.1 AMO 준비) + rhwp-safari (v0.2.1) 섹션 추가 - 기여자 감사 목록 확장: @seo-rii, @planet6897, @yl-star7 추가 (9명) - Features: OLE/Chart/EMF native rendering 항목 추가 (#221) - Project Structure: src/emf/, src/ooxml_chart/, rhwp-firefox/, rhwp-shared/ 반영 - Trademark 섹션 신규 (한글판 동일 위치) - AI 페어 프로그래밍 섹션: Git Workflow / Task Workflow / Debugging Protocol / Documentation Rules 완전 반영 - 로드맵 링크를 mydocs/eng/report/rhwp-milestone.md 로 보정 - 테스트 수치 783 → 935 Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
변경 요약
current/original) 정상화로 리사이즈 시 점 좌표가 올바르게 적용
중 크기/위치가 실시간으로 갱신
자동으로 최상단으로 설정
중요한 점
한글과 방식이 다름: 개인적으로 리사이징을 표현하는 방식은 한글보다 워드가 깔끔하다고 생각해서 워드의 방식대로 구현했는데 문제가 있으면 한글 방식으로 구현하겠습니다!
한글
관련 이슈
closes #202
Files
src/document_core/commands/object_ops.rs: Polygon/Curveoriginal_width/height 유지 로직
rhwp-studio/src/engine/input-handler-picture.ts: 실시간 드래그업데이트 범위 확대 (group → shape)
rhwp-studio/src/engine/input-handler-mouse.ts: z-order 변경 및document-changed 이벤트 발생
버그 수정 상세
다각형 리사이즈
set_shape_properties_native에서current_width = original_width = new_w로 설정해 렌더러의 스케일 팩터sx = 1.0초래original_width/height를 생성 시 값으로유지하여
sx = current/original정상화실시간 업데이트
shape타입도 포함하여 다각형 리사이즈 중 도형이 움직이는 모습 표시맨 앞으로 이동
changeShapeZOrder('front')호출Test
cargo test통과 (858개 테스트 완료)cargo clippy -- -D warnings통과