레이어 패널: 컨트롤 이름 병기 + 더블클릭으로 캔버스 이동
레이어 목록이 Text 만 보여줘서 chkOrientation1~5 처럼 문구가 같은 컨트롤들이 전부 같은 줄로 보였다. 두 줄로 나눠 아래에 Id 를 병기한다 (Text 가 없어 LayerName 이 곧 Id 인 경우는 중복이라 숨긴다). 그리고 컨트롤이 수백 개인 서식에서는 목록에서 이름을 찾아도 종이 어디에 있는지 알 수 없었다 — 더블클릭하면 해당 페이지로 전환 + 선택 + 캔버스 스크롤. 이미 전부 보이면 스크롤하지 않는다. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5
parent
e18ad87100
commit
d09bd90c8e
@@ -40,16 +40,60 @@ public partial class DesignerCanvasView : UserControl
|
||||
if (subscribedDesigner is not null)
|
||||
{
|
||||
subscribedDesigner.InlineEditRequested -= ShowInlineEditor;
|
||||
subscribedDesigner.ScrollToRequested -= ScrollToControl;
|
||||
}
|
||||
CloseInlineEditor(commit: false);
|
||||
subscribedDesigner = e.NewValue as DesignerViewModel;
|
||||
if (subscribedDesigner is not null)
|
||||
{
|
||||
subscribedDesigner.InlineEditRequested += ShowInlineEditor;
|
||||
subscribedDesigner.ScrollToRequested += ScrollToControl;
|
||||
subscribedDesigner.ReportViewport(Scroll.ViewportWidth, Scroll.ViewportHeight);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 컨트롤이 화면 가운데 오도록 스크롤 — 레이어 목록 더블클릭 경로.
|
||||
///
|
||||
/// 월드 좌표 → 화면 좌표 변환은 World 그리드의 LayoutTransform(줌)과 감싸는 Border 의
|
||||
/// Padding 24 를 모두 반영해야 한다. 이미 보이는 컨트롤은 건드리지 않는다 —
|
||||
/// 목록을 훑을 때마다 화면이 튀면 오히려 방향 감각을 잃는다.
|
||||
/// </summary>
|
||||
private void ScrollToControl(ControlViewModel target)
|
||||
{
|
||||
if (subscribedDesigner is null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
// 페이지 전환·선택 변경이 레이아웃에 반영된 뒤 계산해야 오프셋이 맞는다
|
||||
Dispatcher.BeginInvoke(new Action(() =>
|
||||
{
|
||||
var bounds = subscribedDesigner.WorldBoundsOf(target);
|
||||
var zoom = subscribedDesigner.Zoom;
|
||||
const double CanvasPad = 24; // DesignerCanvasView.xaml 의 Border Padding
|
||||
|
||||
var left = bounds.X * zoom + CanvasPad;
|
||||
var top = bounds.Y * zoom + CanvasPad;
|
||||
var width = bounds.Width * zoom;
|
||||
var height = bounds.Height * zoom;
|
||||
|
||||
var visibleLeft = Scroll.HorizontalOffset;
|
||||
var visibleTop = Scroll.VerticalOffset;
|
||||
var visibleRight = visibleLeft + Scroll.ViewportWidth;
|
||||
var visibleBottom = visibleTop + Scroll.ViewportHeight;
|
||||
|
||||
var fullyVisible = left >= visibleLeft && top >= visibleTop
|
||||
&& left + width <= visibleRight && top + height <= visibleBottom;
|
||||
if (fullyVisible)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Scroll.ScrollToHorizontalOffset(left + (width / 2) - (Scroll.ViewportWidth / 2));
|
||||
Scroll.ScrollToVerticalOffset(top + (height / 2) - (Scroll.ViewportHeight / 2));
|
||||
}), System.Windows.Threading.DispatcherPriority.Loaded);
|
||||
}
|
||||
|
||||
/// <summary>뷰포트 크기를 VM 에 전달 — 화면 맞춤(ZoomFit)이 시각 트리를 몰라도 되게 한다</summary>
|
||||
private void OnScrollSizeChanged(object sender, SizeChangedEventArgs e)
|
||||
=> subscribedDesigner?.ReportViewport(Scroll.ViewportWidth, Scroll.ViewportHeight);
|
||||
|
||||
Reference in New Issue
Block a user