diff --git a/Svg.Skia.slnx b/Svg.Skia.slnx index 07fbd4595a..bb0c633335 100644 --- a/Svg.Skia.slnx +++ b/Svg.Skia.slnx @@ -71,6 +71,11 @@ + + + + + @@ -82,6 +87,9 @@ + + + diff --git a/docs/editor-packages.md b/docs/editor-packages.md new file mode 100644 index 0000000000..3c341717ff --- /dev/null +++ b/docs/editor-packages.md @@ -0,0 +1,23 @@ +# Svg.Editor package layout + +`samples/AvalonDraw` is now the demo host for the extracted editor stack. + +Reference `Svg.Editor.Skia.Avalonia` when you want the ready-made editor workspace and interactive canvas. +It now exposes `SvgEditorWorkspace` for the full composed editor and `SvgEditorSurface` for the canvas only. + +Reference `Svg.Editor.Avalonia` when you only need the editor dialogs and other Avalonia-specific UI pieces without the Skia editing surface. +It now contains the reusable side-panel controls: `DocumentOutlineView`, `ResourceBrowserView`, `PropertyInspectorView`, `ToolPaletteView`, and `StatusBarView`. +It also exposes the standalone editor views used by the default dialog host, including `InsertElementPickerView`, `PatternEditorView`, `GradientStopsEditorView`, `GradientMeshEditorView`, `StrokeProfileEditorView`, `TextEditorView`, `PathSegmentsEditorView`, `SwatchEditorView`, `SymbolPickerView`, `SymbolNameEditorView`, and `SettingsEditorView`. +Use `ISvgEditorDialogService` and `ISvgEditorFileDialogService` to replace the default window/file-picker flow when embedding the editor into a host application. + +Reference `Svg.Editor.Skia` when you need rendering/editing helpers and overlay logic but are composing your own UI. +It exposes the public editor-side helpers `SvgEditorOverlayRenderer`, `SvgEditorInteractionController`, `BoundsInfo`, and `PathPoint`. + +Reference `Svg.Editor.Svg` for SVG document mutation services, resource management, and property editing support. + +Reference `Svg.Editor.Core` for shared editor state types such as `SvgEditorSession`, `SvgEditorSettings`, `SvgNode`, and `ArtboardInfo`. + +`SvgEditorWorkspace` now keeps host-owned seams public: +- assign `DialogService` to customize modal presentation and inline editor hosting +- assign `FileDialogService` to customize open/save/export/image picking +- call `OpenDocumentAsync`, `SaveDocumentAsync`, `ExportSelectedElementAsync`, `ExportPdfAsync`, `ExportXpsAsync`, `PlaceImageAsync`, and `ShowSettingsAsync` from host menus or commands instead of relying on the built-in menu bar diff --git a/samples/AvalonDraw/AvalonDraw.csproj b/samples/AvalonDraw/AvalonDraw.csproj index 6ea0313ca0..bbf12b108c 100644 --- a/samples/AvalonDraw/AvalonDraw.csproj +++ b/samples/AvalonDraw/AvalonDraw.csproj @@ -25,7 +25,7 @@ - + diff --git a/samples/AvalonDraw/GradientMeshEditorWindow.axaml b/samples/AvalonDraw/GradientMeshEditorWindow.axaml deleted file mode 100644 index c355a93131..0000000000 --- a/samples/AvalonDraw/GradientMeshEditorWindow.axaml +++ /dev/null @@ -1,17 +0,0 @@ - - - - - - - - - - - diff --git a/samples/AvalonDraw/GradientMeshEditorWindow.axaml.cs b/samples/AvalonDraw/GradientMeshEditorWindow.axaml.cs deleted file mode 100644 index 8288b66785..0000000000 --- a/samples/AvalonDraw/GradientMeshEditorWindow.axaml.cs +++ /dev/null @@ -1,77 +0,0 @@ -using System.Collections.ObjectModel; -using Avalonia; -using Avalonia.Controls; -using Avalonia.Input; -using Avalonia.Markup.Xaml; -using Avalonia.Media; -using Svg.Model; - -namespace AvalonDraw; - -public partial class GradientMeshEditorWindow : Window -{ - private readonly Canvas _canvas; - private GradientMeshPoint? _dragging; - - public ObservableCollection Points { get; } = new(); - - public GradientMeshEditorWindow(GradientMesh mesh) - { - InitializeComponent(); - _canvas = this.FindControl("MeshCanvas"); - foreach (var p in mesh.Points) - Points.Add(p); - _canvas.PointerPressed += OnPointerPressed; - _canvas.PointerReleased += OnPointerReleased; - _canvas.PointerMoved += OnPointerMoved; - _canvas.DataContext = this; - } - - private void InitializeComponent() - { - AvaloniaXamlLoader.Load(this); - } - - private void OnPointerPressed(object? sender, PointerPressedEventArgs e) - { - var pos = e.GetPosition(_canvas); - foreach (var p in Points) - { - var rect = new Rect(p.Position.X - 5, p.Position.Y - 5, 10, 10); - if (rect.Contains(pos)) - { - _dragging = p; - break; - } - } - } - - private void OnPointerReleased(object? sender, PointerReleasedEventArgs e) - { - _dragging = null; - } - - private void OnPointerMoved(object? sender, PointerEventArgs e) - { - if (_dragging is null) - return; - - var pos = e.GetPosition(_canvas); - var index = Points.IndexOf(_dragging); - if (index >= 0) - { - Points[index] = _dragging with { Position = new ShimSkiaSharp.SKPoint((float)pos.X, (float)pos.Y) }; - _dragging = Points[index]; - } - } - - public GradientMesh Result - { - get - { - var mesh = new GradientMesh(); - mesh.Points.AddRange(Points); - return mesh; - } - } -} diff --git a/samples/AvalonDraw/InsertElementWindow.axaml.cs b/samples/AvalonDraw/InsertElementWindow.axaml.cs deleted file mode 100644 index eb74500603..0000000000 --- a/samples/AvalonDraw/InsertElementWindow.axaml.cs +++ /dev/null @@ -1,41 +0,0 @@ -using System; -using System.Collections.Generic; -using Avalonia; -using Avalonia.Controls; -using Avalonia.Interactivity; -using Avalonia.Markup.Xaml; - -namespace AvalonDraw; - -public partial class InsertElementWindow : Window -{ - public InsertElementWindow(IEnumerable names) - { - InitializeComponent(); - ElementList.ItemsSource = names; - } - - private void InitializeComponent() - { - AvaloniaXamlLoader.Load(this); - } - - public string? Selected { get; private set; } - - private void OkButton_OnClick(object? sender, Avalonia.Interactivity.RoutedEventArgs e) - { - Selected = ElementList.SelectedItem as string; - Close(Selected); - } - - private void CancelButton_OnClick(object? sender, Avalonia.Interactivity.RoutedEventArgs e) - { - Close(null); - } - - private void ElementList_OnGotFocus(object? sender, Avalonia.Input.GotFocusEventArgs e) - { - if (ElementList is AutoCompleteBox box) - box.IsDropDownOpen = true; - } -} diff --git a/samples/AvalonDraw/MainWindow.axaml b/samples/AvalonDraw/MainWindow.axaml index 080d63dc14..6e845707cc 100644 --- a/samples/AvalonDraw/MainWindow.axaml +++ b/samples/AvalonDraw/MainWindow.axaml @@ -1,308 +1,9 @@ - - - - - - - - - - - - - - - - - - - - - M1,8 C3,4 13,4 15,8 C13,12 3,12 1,8 Z M8,8 A3,3 0 1 1 7.99,8 Z - M1,8 C3,4 13,4 15,8 C13,12 3,12 1,8 Z M0,0 L16,16 M16,0 L0,16 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -