From df32d49b11d805752dc43489fe6d5e7d6fc93828 Mon Sep 17 00:00:00 2001 From: Michael Becker Date: Wed, 11 Aug 2021 23:34:47 -0400 Subject: [PATCH] preliminary implementation of Editor Panels - CRASHES when switching back after adding a panel though --- .../Scene/Panels/MotionTestPanel.glade | 975 ++++++++++++++++++ .../Scene/Panels/MotionTestPanel.uexml | 10 + ...lEditor.Content.PlatformIndependent.csproj | 2 + .../Common/Reflection.cs | 18 + .../EditorApplication.cs | 33 + .../EditorContext.cs | 5 + .../EditorReference.cs | 2 +- .../IHostApplicationWindow.cs | 3 + .../MainWindow.cs | 60 +- .../Editors/Scene/Panels/MotionTestPanel.cs | 11 + .../Editors/Scene/SceneEditor.cs | 50 + ....Plugins.Multimedia3D.UserInterface.csproj | 4 + 12 files changed, 1155 insertions(+), 18 deletions(-) create mode 100644 Content/UniversalEditor.Content.PlatformIndependent/Editors/Multimedia3D/Scene/Panels/MotionTestPanel.glade create mode 100644 Content/UniversalEditor.Content.PlatformIndependent/Editors/Multimedia3D/Scene/Panels/MotionTestPanel.uexml create mode 100644 Plugins.UserInterface/UniversalEditor.Plugins.Multimedia3D.UserInterface/Editors/Scene/Panels/MotionTestPanel.cs create mode 100644 Plugins.UserInterface/UniversalEditor.Plugins.Multimedia3D.UserInterface/Editors/Scene/SceneEditor.cs diff --git a/Content/UniversalEditor.Content.PlatformIndependent/Editors/Multimedia3D/Scene/Panels/MotionTestPanel.glade b/Content/UniversalEditor.Content.PlatformIndependent/Editors/Multimedia3D/Scene/Panels/MotionTestPanel.glade new file mode 100644 index 00000000..04296560 --- /dev/null +++ b/Content/UniversalEditor.Content.PlatformIndependent/Editors/Multimedia3D/Scene/Panels/MotionTestPanel.glade @@ -0,0 +1,975 @@ + + + + + + 100 + 1 + 10 + + + 100 + 1 + 10 + + + 100 + 1 + 10 + + + 100 + 1 + 10 + + + 100 + 1 + 10 + + + 100 + 1 + 10 + + + 100 + 1 + 10 + + + -100 + 100 + 1 + 10 + + + -360 + 360 + 1 + 10 + + + 100 + 1 + 10 + + + 100 + 1 + 10 + + + 100 + 1 + 10 + + + 100 + 1 + 10 + + + 100 + 1 + 10 + + + 100 + 1 + 10 + + + 100 + 1 + 10 + + + 1.5 + 1 + 1 + 10 + + + False + Motion Test + 400 + + + True + True + adjScrollWindowHorizontal + adjScrollWindowVertical + always + in + + + True + False + adjScrollViewportHorizontal + adjScrollViewportVertical + + + + True + False + 16 + 16 + 16 + 16 + True + 4 + 4 + + + True + False + Character + 0 + + + 0 + 0 + + + + + True + False + + + 1 + 0 + + + + + True + False + + + 0 + 1 + 3 + + + + + True + False + Set + 0 + + + 0 + 2 + + + + + True + False + + + 1 + 2 + + + + + True + False + Animation + 0 + + + 0 + 3 + + + + + True + False + + + 1 + 3 + + + + + True + False + 8 + 8 + Rotate + 0.5 + + + 0 + 4 + 3 + + + + + True + False + Y + 0 + + + 0 + 5 + + + + + True + True + 0 + adjRotateY + + + 1 + 5 + + + + + True + True + True + adjRotateY + False + 0 + False + False + + + 2 + 5 + + + + + True + False + 8 + 8 + Position + 0.5 + + + 0 + 6 + 3 + + + + + True + False + X + 0 + + + 0 + 7 + + + + + True + True + 0.00 + adjPositionX + 2 + + + 1 + 7 + + + + + True + True + adjPositionX + False + 0 + False + False + + + 2 + 7 + + + + + True + False + 8 + 8 + Offset + 0.5 + + + 0 + 8 + 3 + + + + + True + False + Pre Offset + 0 + + + 0 + 9 + + + + + True + False + Post Offset + 0 + + + 0 + 10 + + + + + True + True + adjOffsetPost + False + 0 + False + False + + + 2 + 10 + + + + + True + True + adjOffsetPre + False + 0 + False + False + + + 2 + 9 + + + + + True + True + 0 + adjOffsetPre + + + 1 + 9 + + + + + True + True + 0 + adjOffsetPost + + + 1 + 10 + + + + + True + False + 8 + 8 + Divide + 0.5 + + + 0 + 11 + 3 + + + + + True + True + 0 + adjDivide00 + + + 1 + 12 + + + + + True + True + 0 + adjDivide01 + + + 1 + 13 + + + + + True + True + 0 + adjDivide02 + + + 1 + 14 + + + + + True + True + adjDivide00 + False + 0 + False + False + + + 2 + 12 + + + + + True + True + adjDivide01 + False + 0 + False + False + + + 2 + 13 + + + + + True + True + adjDivide02 + False + 0 + False + False + + + 2 + 14 + + + + + True + False + Divide 00 + 0 + + + 0 + 12 + + + + + True + False + Divide 01 + 0 + + + 0 + 13 + + + + + True + False + Divide 02 + 0 + + + 0 + 14 + + + + + True + False + 8 + 8 + Step + 0.5 + + + 0 + 15 + 3 + + + + + True + False + Step 00 + 0 + + + 0 + 16 + + + + + True + False + Step 01 + 0 + + + 0 + 17 + + + + + True + False + Step 02 + 0 + + + 0 + 18 + + + + + True + False + Step 03 + 0 + + + 0 + 19 + + + + + True + True + adjStep00 + 4 + + + 1 + 16 + + + + + True + True + adjStep01 + 4 + + + 1 + 17 + + + + + True + True + adjStep02 + 4 + + + 1 + 18 + + + + + True + True + adjStep03 + 4 + + + 1 + 19 + + + + + True + True + adjStep00 + False + 0 + 1 + False + False + + + 2 + 16 + + + + + True + True + adjStep01 + False + 0 + 1 + False + False + + + 2 + 17 + + + + + True + True + adjStep02 + False + 0 + 1 + False + False + + + 2 + 18 + + + + + True + True + adjStep03 + False + 0 + 1 + False + False + + + 2 + 19 + + + + + True + False + 8 + 8 + Frame + 0.5 + + + 0 + 20 + 3 + + + + + True + False + Current + 0 + + + 0 + 21 + + + + + True + False + Start + 0 + + + 0 + 22 + + + + + True + True + adjFrameCurrent + False + 0 + 1 + False + False + + + 2 + 21 + + + + + True + True + adjFrameStart + False + 0 + 1 + False + False + + + 2 + 22 + + + + + True + True + adjFrameCurrent + + + 1 + 21 + + + + + True + True + adjFrameStart + + + 1 + 22 + + + + + True + False + 8 + 8 + Information + 0.5 + + + 0 + 23 + 3 + + + + + True + False + Private Frame + 0 + + + 0 + 24 + + + + + True + False + Global Frame + 0 + + + 0 + 25 + + + + + True + False + Max Frame + 0 + + + 0 + 26 + + + + + True + False + 8 + 8 + 0.00000 + 0 + + + 1 + 24 + 2 + + + + + True + False + 8 + 8 + 0.00000 + 0 + + + 1 + 25 + 2 + + + + + True + False + 8 + 8 + 0.00000 + 0 + + + 1 + 26 + 2 + + + + + _Display + True + True + False + True + True + + + 0 + 27 + 3 + + + + + _Set Change + True + True + False + True + True + + + 0 + 28 + 3 + + + + + _Partial Motion + True + True + False + True + True + + + 0 + 30 + 3 + + + + + Use _Osage Play Data + True + True + False + True + True + + + 0 + 29 + 3 + + + + + + + + + + + + + + + + + + + diff --git a/Content/UniversalEditor.Content.PlatformIndependent/Editors/Multimedia3D/Scene/Panels/MotionTestPanel.uexml b/Content/UniversalEditor.Content.PlatformIndependent/Editors/Multimedia3D/Scene/Panels/MotionTestPanel.uexml new file mode 100644 index 00000000..1f003d40 --- /dev/null +++ b/Content/UniversalEditor.Content.PlatformIndependent/Editors/Multimedia3D/Scene/Panels/MotionTestPanel.uexml @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/Content/UniversalEditor.Content.PlatformIndependent/UniversalEditor.Content.PlatformIndependent.csproj b/Content/UniversalEditor.Content.PlatformIndependent/UniversalEditor.Content.PlatformIndependent.csproj index 64a39a39..61990d1e 100644 --- a/Content/UniversalEditor.Content.PlatformIndependent/UniversalEditor.Content.PlatformIndependent.csproj +++ b/Content/UniversalEditor.Content.PlatformIndependent/UniversalEditor.Content.PlatformIndependent.csproj @@ -321,6 +321,8 @@ + + diff --git a/Libraries/UniversalEditor.UserInterface/Common/Reflection.cs b/Libraries/UniversalEditor.UserInterface/Common/Reflection.cs index 977bc65f..ec94f3f7 100644 --- a/Libraries/UniversalEditor.UserInterface/Common/Reflection.cs +++ b/Libraries/UniversalEditor.UserInterface/Common/Reflection.cs @@ -257,6 +257,24 @@ namespace UniversalEditor.UserInterface.Common } } } + + MarkupTagElement tagPanels = (tagEditor.Elements["Panels"] as MarkupTagElement); + if (tagPanels != null) + { + foreach (MarkupElement elPanel in tagPanels.Elements) + { + MarkupTagElement tagPanel = (elPanel as MarkupTagElement); + if (tagPanel == null) continue; + + PanelReference pr = new PanelReference(new Guid(tagPanel.Attributes["ID"].Value)); + pr.Title = tagPanel.Attributes["Title"]?.Value; + pr.ControlTypeName = tagPanel.Attributes["ControlTypeName"]?.Value; + pr.LayoutFileName = tagPanel.Attributes["LayoutFileName"]?.Value; + + er.Panels.Add(pr); + } + } + MarkupTagElement tagVariables = (tagEditor.Elements["Variables"] as MarkupTagElement); if (tagVariables != null) { diff --git a/Libraries/UniversalEditor.UserInterface/EditorApplication.cs b/Libraries/UniversalEditor.UserInterface/EditorApplication.cs index c5bf4116..f2804265 100644 --- a/Libraries/UniversalEditor.UserInterface/EditorApplication.cs +++ b/Libraries/UniversalEditor.UserInterface/EditorApplication.cs @@ -81,6 +81,39 @@ namespace UniversalEditor.UserInterface public PanelReference.PanelReferenceCollection Panels { get; } = new PanelReference.PanelReferenceCollection(); + protected override void OnContextAdded(ContextChangedEventArgs e) + { + base.OnContextAdded(e); + + EditorContext ec = (e.Context as EditorContext); + if (ec != null) + { + foreach (PanelReference panel in ec.Panels) + { + foreach (IHostApplicationWindow mw in Windows) + { + mw.AddPanel(panel); + } + } + } + } + protected override void OnContextRemoved(ContextChangedEventArgs e) + { + base.OnContextRemoved(e); + + EditorContext ec = (e.Context as EditorContext); + if (ec != null) + { + foreach (PanelReference panel in ec.Panels) + { + foreach (IHostApplicationWindow mw in Windows) + { + mw.RemovePanel(panel); + } + } + } + } + protected override void OnStartup(EventArgs e) { base.OnStartup(e); diff --git a/Libraries/UniversalEditor.UserInterface/EditorContext.cs b/Libraries/UniversalEditor.UserInterface/EditorContext.cs index 2b73e758..266231c8 100644 --- a/Libraries/UniversalEditor.UserInterface/EditorContext.cs +++ b/Libraries/UniversalEditor.UserInterface/EditorContext.cs @@ -29,6 +29,7 @@ namespace UniversalEditor.UserInterface public class EditorContext : UIContext { public EditorReference Reference { get; private set; } = null; + public PanelReference.PanelReferenceCollection Panels { get; } = new PanelReference.PanelReferenceCollection(); public override string ToString() { @@ -48,6 +49,10 @@ namespace UniversalEditor.UserInterface { MenuItems.Add(reference.MenuBar.Items[i]); } + for (int i = 0; i < reference.Panels.Count; i++) + { + Panels.Add(reference.Panels[i]); + } } } } diff --git a/Libraries/UniversalEditor.UserInterface/EditorReference.cs b/Libraries/UniversalEditor.UserInterface/EditorReference.cs index 752cb750..29a31aed 100644 --- a/Libraries/UniversalEditor.UserInterface/EditorReference.cs +++ b/Libraries/UniversalEditor.UserInterface/EditorReference.cs @@ -31,7 +31,7 @@ namespace UniversalEditor.UserInterface public CommandBar MenuBar { get; } = new CommandBar(); public Command.CommandCollection Commands { get; } = new Command.CommandCollection(); - + public PanelReference.PanelReferenceCollection Panels { get; } = new PanelReference.PanelReferenceCollection(); public EditorView.EditorViewCollection Views { get; } = new EditorView.EditorViewCollection(); public Variable.VariableCollection Variables { get; } = new Variable.VariableCollection(); public Toolbox Toolbox { get; } = new Toolbox(); diff --git a/Libraries/UniversalEditor.UserInterface/IHostApplicationWindow.cs b/Libraries/UniversalEditor.UserInterface/IHostApplicationWindow.cs index 01cd59c1..81721c63 100644 --- a/Libraries/UniversalEditor.UserInterface/IHostApplicationWindow.cs +++ b/Libraries/UniversalEditor.UserInterface/IHostApplicationWindow.cs @@ -87,6 +87,9 @@ namespace UniversalEditor.UserInterface Document.ReadOnlyDocumentCollection Documents { get; } Editor.ReadOnlyEditorCollection Editors { get; } + + bool AddPanel(PanelReference panelReference); + bool RemovePanel(PanelReference panelReference); } public class IHostApplicationWindowCollection : System.Collections.ObjectModel.Collection diff --git a/Libraries/UniversalEditor.UserInterface/MainWindow.cs b/Libraries/UniversalEditor.UserInterface/MainWindow.cs index 4446bfd7..ee0dd231 100644 --- a/Libraries/UniversalEditor.UserInterface/MainWindow.cs +++ b/Libraries/UniversalEditor.UserInterface/MainWindow.cs @@ -95,6 +95,11 @@ namespace UniversalEditor.UserInterface return tab; } + public void UnregisterPanel(PanelReference panelReference, Panel panel) + { + _MyPanels.Remove(panelReference); + _MyPanels_ID.Remove(panelReference.ID); + } public void RegisterPanel(PanelReference panelReference, Panel panel) { _MyPanels[panelReference] = panel; @@ -244,23 +249,7 @@ namespace UniversalEditor.UserInterface { foreach (PanelReference panel in ((EditorApplication)Application.Instance).Panels) { - Panel p = null; - if (panel.Control != null) - { - p = panel.Control; - } - else if (panel.ControlTypeName != null) - { - p = MBS.Framework.Reflection.CreateType(panel.ControlTypeName); - } - else - { - Console.Error.WriteLine("ue: MainWindow.InitializePanels() - could not create panel '{0}'; neither Control nor ControlTypeName were specified", panel.Title); - continue; - } - - RegisterPanel(panel, p); - AddPanel(panel.Title, panel.Placement, p); + AddPanel(panel); } } @@ -602,6 +591,35 @@ namespace UniversalEditor.UserInterface } } + public bool AddPanel(PanelReference panelReference) + { + Panel p = null; + if (panelReference.Control != null) + { + p = panelReference.Control; + } + else if (panelReference.ControlTypeName != null) + { + p = MBS.Framework.Reflection.CreateType(panelReference.ControlTypeName); + } + else + { + Console.Error.WriteLine("ue: MainWindow.InitializePanels() - could not create panel '{0}'; neither Control nor ControlTypeName were specified", panelReference.Title); + return false; + } + + RegisterPanel(panelReference, p); + AddPanel(panelReference.Title, panelReference.Placement, p); + return true; + } + public bool RemovePanel(PanelReference panelReference) + { + Panel panel = FindPanel(panelReference.ID); + RemovePanel(panel); + UnregisterPanel(panelReference, panel); + return true; + } + private DockingContainer AddPanelContainer(DockingItemPlacement placement, DockingContainer parent = null) { DockingContainer dc = new DockingContainer(); @@ -616,6 +634,8 @@ namespace UniversalEditor.UserInterface } return dc; } + + private Dictionary dockingWindowsForPanel = new Dictionary(); private void AddPanel(string title, DockingItemPlacement placement, Control control = null, DockingContainer parent = null) { if (control == null) @@ -635,6 +655,12 @@ namespace UniversalEditor.UserInterface { dckContainer.Items.Add(dw); } + dockingWindowsForPanel[control] = dw; + } + private void RemovePanel(Panel panel) + { + DockingWindow dw = dockingWindowsForPanel[panel]; + dw.Parent.Items.Remove(dw); } private void InitEditorPage(Document doc) diff --git a/Plugins.UserInterface/UniversalEditor.Plugins.Multimedia3D.UserInterface/Editors/Scene/Panels/MotionTestPanel.cs b/Plugins.UserInterface/UniversalEditor.Plugins.Multimedia3D.UserInterface/Editors/Scene/Panels/MotionTestPanel.cs new file mode 100644 index 00000000..f5b9f650 --- /dev/null +++ b/Plugins.UserInterface/UniversalEditor.Plugins.Multimedia3D.UserInterface/Editors/Scene/Panels/MotionTestPanel.cs @@ -0,0 +1,11 @@ +using System; +using UniversalEditor.UserInterface; + +namespace UniversalEditor.Plugins.Multimedia3D.UserInterface.Editors.Scene.Panels +{ + [ContainerLayout("~/Editors/Multimedia3D/Scene/Panels/MotionTestPanel.glade")] + public class MotionTestPanel : Panel + { + public static readonly Guid ID = new Guid("{a94821d1-9bcb-4396-908a-33ce757436b8}"); + } +} diff --git a/Plugins.UserInterface/UniversalEditor.Plugins.Multimedia3D.UserInterface/Editors/Scene/SceneEditor.cs b/Plugins.UserInterface/UniversalEditor.Plugins.Multimedia3D.UserInterface/Editors/Scene/SceneEditor.cs new file mode 100644 index 00000000..fd088c90 --- /dev/null +++ b/Plugins.UserInterface/UniversalEditor.Plugins.Multimedia3D.UserInterface/Editors/Scene/SceneEditor.cs @@ -0,0 +1,50 @@ +// +// StageEditor.cs +// +// Author: +// Michael Becker +// +// Copyright (c) 2021 Mike Becker's Software +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . +using System; +using UniversalEditor.ObjectModels.Multimedia3D.Scene; +using UniversalEditor.UserInterface; + +namespace UniversalEditor.Plugins.Multimedia3D.UserInterface.Editors.Scene +{ + public class SceneEditor : Editor + { + private static EditorReference _er = null; + public override EditorReference MakeReference() + { + if (_er == null) + { + _er = base.MakeReference(); + _er.ID = new Guid("{6dbe6294-681b-4d1f-8249-d04a1a3ef4a2}"); + _er.SupportedObjectModels.Add(typeof(SceneObjectModel)); + } + return _er; + } + + public override void UpdateSelections() + { + } + + protected override Selection CreateSelectionInternal(object content) + { + return null; + } + } +} diff --git a/Plugins.UserInterface/UniversalEditor.Plugins.Multimedia3D.UserInterface/UniversalEditor.Plugins.Multimedia3D.UserInterface.csproj b/Plugins.UserInterface/UniversalEditor.Plugins.Multimedia3D.UserInterface/UniversalEditor.Plugins.Multimedia3D.UserInterface.csproj index 6165ecdc..9797927f 100644 --- a/Plugins.UserInterface/UniversalEditor.Plugins.Multimedia3D.UserInterface/UniversalEditor.Plugins.Multimedia3D.UserInterface.csproj +++ b/Plugins.UserInterface/UniversalEditor.Plugins.Multimedia3D.UserInterface/UniversalEditor.Plugins.Multimedia3D.UserInterface.csproj @@ -32,6 +32,8 @@ + + @@ -70,6 +72,8 @@ + +