Browse Source

Fixed show active viewport on close

Krzysztof Krysiński 4 months ago
parent
commit
b56036691e

+ 1 - 1
src/PixiDocks

@@ -1 +1 @@
-Subproject commit 71c3120eda7a644c7da88885504a9e30de68161d
+Subproject commit d4e89ae9349cb7329eb98866541893e1a8510094

+ 18 - 1
src/PixiEditor/ViewModels/Dock/LayoutManager.cs

@@ -101,7 +101,8 @@ internal class LayoutManager
                     SplitDirection = DockingDirection.Bottom,
                     Second = new DockableArea
                     {
-                        Id = "DocumentPreviewArea", ActiveDockable = DockContext.CreateDockable(documentPreviewDockViewModel)
+                        Id = "DocumentPreviewArea",
+                        ActiveDockable = DockContext.CreateDockable(documentPreviewDockViewModel)
                     }
                 }
             }
@@ -155,6 +156,22 @@ internal class LayoutManager
         }
     }
 
+    public void ShowViewport(ViewportWindowViewModel viewport)
+    {
+        foreach (var element in ActiveLayout.Root)
+        {
+            if (element is IDockableHost dockableHost)
+            {
+                var dockable = dockableHost.Dockables.FirstOrDefault(x => x.Id == viewport.Id);
+                if (dockable != null)
+                {
+                    dockableHost.ActiveDockable = dockable;
+                    return;
+                }
+            }
+        }
+    }
+
     private DockableArea? TryFindArea(string name)
     {
         DockableArea? result = null;

+ 3 - 0
src/PixiEditor/ViewModels/SubViewModels/WindowViewModel.cs

@@ -46,7 +46,10 @@ internal class WindowViewModel : SubViewModel<ViewModelMain>
             activeWindow = value;
             OnPropertyChanged(nameof(ActiveWindow));
             if (activeWindow is ViewportWindowViewModel viewport)
+            {
+                Owner.LayoutSubViewModel.LayoutManager.ShowViewport(viewport);
                 ActiveViewportChanged?.Invoke(this, viewport);
+            }
         }
     }
 

+ 0 - 1
src/PixiEditor/ViewModels/ViewModelMain.cs

@@ -307,7 +307,6 @@ internal partial class ViewModelMain : ViewModelBase, ICommandsHandler
         const string ConfirmationDialogTitle = "UNSAVED_CHANGES";
         const string ConfirmationDialogMessage = "DOCUMENT_MODIFIED_SAVE";
 
-
         ConfirmationType result = ConfirmationType.No;
         bool saved = false;
         if (!document.AllChangesSaved)