From 2597347f9c99ec1bd031534767b2393ad41e9ecd Mon Sep 17 00:00:00 2001 From: Lars Brubaker Date: Thu, 16 Jun 2022 13:11:26 -0700 Subject: [PATCH] adding in re-arrange item support --- .../ApplicationView/ApplicationController.cs | 23 +++++------------ .../Interfaces/EditorButtonData.cs | 18 +++++++++++++ .../Primitives/ComponentObject3D.cs | 25 ++++++++++++++++++- .../View3D/Actions/CombineObject3D_2.cs | 2 +- Submodules/agg-sharp | 2 +- 5 files changed, 50 insertions(+), 20 deletions(-) diff --git a/MatterControlLib/ApplicationView/ApplicationController.cs b/MatterControlLib/ApplicationView/ApplicationController.cs index beaf71761..1ee1b6f43 100644 --- a/MatterControlLib/ApplicationView/ApplicationController.cs +++ b/MatterControlLib/ApplicationView/ApplicationController.cs @@ -209,25 +209,14 @@ namespace MatterHackers.MatterControl menuTheme.CreateMenuItems(popupMenu, actions); - if (selectedItem is ComponentObject3D componentObject) + if (selectedItem is IRightClickMenuProvider menuProvider) { - popupMenu.CreateSeparator(); + menuProvider.AddRightClickMenuItemsItems(popupMenu); + } - string componentID = componentObject.ComponentID; - - var helpItem = popupMenu.CreateMenuItem("Help".Localize()); - helpItem.Enabled = !string.IsNullOrEmpty(componentID) && this.HelpArticlesByID.ContainsKey(componentID); - helpItem.Click += (s, e) => - { - var helpTab = ApplicationController.Instance.ActivateHelpTab("Docs"); - if (helpTab.TabContent is HelpTreePanel helpTreePanel) - { - if (this.HelpArticlesByID.TryGetValue(componentID, out HelpArticle helpArticle)) - { - helpTreePanel.ActiveNodePath = componentID; - } - } - }; + if (selectedItem.Parent is IParentRightClickMenuProvider parentMenuProvider) + { + parentMenuProvider.AddRightClickMenuItemsItems(popupMenu, selectedItem); } return popupMenu; diff --git a/MatterControlLib/DesignTools/Interfaces/EditorButtonData.cs b/MatterControlLib/DesignTools/Interfaces/EditorButtonData.cs index a00f8b28e..a731a8e1f 100644 --- a/MatterControlLib/DesignTools/Interfaces/EditorButtonData.cs +++ b/MatterControlLib/DesignTools/Interfaces/EditorButtonData.cs @@ -28,6 +28,8 @@ either expressed or implied, of the FreeBSD Project. */ using MatterHackers.Agg.UI; +using MatterHackers.DataConverters3D; +using MatterHackers.MatterControl.PartPreviewWindow; using System; using System.Collections.Generic; @@ -53,4 +55,20 @@ namespace MatterHackers.MatterControl.DesignTools { IEnumerable GetEditorButtonsData(); } + + /// + /// Whene this item is right clicked it will append menu items to the right click menu + /// + public interface IRightClickMenuProvider + { + void AddRightClickMenuItemsItems(PopupMenu popupMenu); + } + + /// + /// When a child of this item is right clicked, it will add menu items + /// + public interface IParentRightClickMenuProvider + { + void AddRightClickMenuItemsItems(PopupMenu popupMenu, IObject3D itemRightClicked); + } } \ No newline at end of file diff --git a/MatterControlLib/DesignTools/Primitives/ComponentObject3D.cs b/MatterControlLib/DesignTools/Primitives/ComponentObject3D.cs index 39f91107e..42c5fc958 100644 --- a/MatterControlLib/DesignTools/Primitives/ComponentObject3D.cs +++ b/MatterControlLib/DesignTools/Primitives/ComponentObject3D.cs @@ -36,11 +36,12 @@ using MatterHackers.DataConverters3D; using MatterHackers.DataConverters3D.UndoCommands; using MatterHackers.Localizations; using MatterHackers.MatterControl.DesignTools.Operations; +using MatterHackers.MatterControl.PartPreviewWindow; namespace MatterHackers.MatterControl.DesignTools { [HideChildrenFromTreeView] - public class ComponentObject3D : Object3D + public class ComponentObject3D : Object3D, IRightClickMenuProvider { private const string ImageConverterComponentID = "4D9BD8DB-C544-4294-9C08-4195A409217A"; @@ -293,5 +294,27 @@ namespace MatterHackers.MatterControl.DesignTools } } } + + public void AddRightClickMenuItemsItems(PopupMenu popupMenu) + { + popupMenu.CreateSeparator(); + + string componentID = this.ComponentID; + + var helpItem = popupMenu.CreateMenuItem("Help".Localize()); + var helpArticlesByID = ApplicationController.Instance.HelpArticlesByID; + helpItem.Enabled = !string.IsNullOrEmpty(componentID) && helpArticlesByID.ContainsKey(componentID); + helpItem.Click += (s, e) => + { + var helpTab = ApplicationController.Instance.ActivateHelpTab("Docs"); + if (helpTab.TabContent is HelpTreePanel helpTreePanel) + { + if (helpArticlesByID.TryGetValue(componentID, out HelpArticle helpArticle)) + { + helpTreePanel.ActiveNodePath = componentID; + } + } + }; + } } } \ No newline at end of file diff --git a/MatterControlLib/PartPreviewWindow/View3D/Actions/CombineObject3D_2.cs b/MatterControlLib/PartPreviewWindow/View3D/Actions/CombineObject3D_2.cs index fc455bd39..f3e1d139f 100644 --- a/MatterControlLib/PartPreviewWindow/View3D/Actions/CombineObject3D_2.cs +++ b/MatterControlLib/PartPreviewWindow/View3D/Actions/CombineObject3D_2.cs @@ -142,7 +142,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow.View3D } else { - resultsMesh = Object3D.CombineParticipants(SourceContainer, participants, cancellationToken, reporter); + resultsMesh = Object3D.CombineParticipants(SourceContainer, participants, cancellationToken, reporter, Processing, InputResolution, OutputResolution); } var resultsItem = new Object3D() diff --git a/Submodules/agg-sharp b/Submodules/agg-sharp index 895408eb6..238b25271 160000 --- a/Submodules/agg-sharp +++ b/Submodules/agg-sharp @@ -1 +1 @@ -Subproject commit 895408eb6799d006137c9bb8824f6b950064d0eb +Subproject commit 238b25271497943ece9ab855b119810abe2c9809