From aa830241334845b807a2b9ef1349cae90014f9a3 Mon Sep 17 00:00:00 2001 From: LarsBrubaker Date: Sun, 17 Dec 2017 11:30:37 -0800 Subject: [PATCH] Fixed copy to work with groups and multi select Deleting dead code around InverImageLocation issue: MatterHackers/MCCentral#2432 Copy does not work if more than one item selected --- ControlElements/TextImageButtonFactory.cs | 64 +++++++------------ .../PrintingWindow/PrintingWindow.cs | 1 - PartPreviewWindow/View3D/SceneActions.cs | 37 ++++++++--- Submodules/MatterSlice | 2 +- Submodules/agg-sharp | 2 +- 5 files changed, 52 insertions(+), 54 deletions(-) diff --git a/ControlElements/TextImageButtonFactory.cs b/ControlElements/TextImageButtonFactory.cs index d48ec65a0..d82ea85ad 100644 --- a/ControlElements/TextImageButtonFactory.cs +++ b/ControlElements/TextImageButtonFactory.cs @@ -71,8 +71,6 @@ namespace MatterHackers.MatterControl private double fontSize => Options.FontSize; private double borderWidth => Options.BorderWidth; - private bool invertImageLocation => Options.InvertImageLocation; - private FlowDirection flowDirection => Options.FlowDirection; private double FixedWidth => Options.FixedWidth; private double FixedHeight => Options.FixedHeight; private double ImageSpacing => Options.ImageSpacing; @@ -140,10 +138,10 @@ namespace MatterHackers.MatterControl { // Create button based on view container widget var buttonViewWidget = new ButtonViewStates( - new TextImageWidget(label, normalFillColor, normalBorderColor, normalTextColor, borderWidth, Margin, null, flowDirection: flowDirection, fontSize: this.fontSize, height: this.FixedHeight, imageSpacing: ImageSpacing), - new TextImageWidget(label, hoverFillColor, hoverBorderColor, hoverTextColor, borderWidth, Margin, null, flowDirection: flowDirection, fontSize: this.fontSize, height: this.FixedHeight, imageSpacing: ImageSpacing), - new TextImageWidget(label, pressedFillColor, pressedBorderColor, pressedTextColor, borderWidth, Margin, null, flowDirection: flowDirection, fontSize: this.fontSize, height: this.FixedHeight, imageSpacing: ImageSpacing), - new TextImageWidget(label, disabledFillColor, disabledBorderColor, disabledTextColor, borderWidth, Margin, null, flowDirection: flowDirection, fontSize: this.fontSize, height: this.FixedHeight, imageSpacing: ImageSpacing) + new TextImageWidget(label, normalFillColor, normalBorderColor, normalTextColor, borderWidth, Margin, null, fontSize: this.fontSize, height: this.FixedHeight, imageSpacing: ImageSpacing), + new TextImageWidget(label, hoverFillColor, hoverBorderColor, hoverTextColor, borderWidth, Margin, null, fontSize: this.fontSize, height: this.FixedHeight, imageSpacing: ImageSpacing), + new TextImageWidget(label, pressedFillColor, pressedBorderColor, pressedTextColor, borderWidth, Margin, null, fontSize: this.fontSize, height: this.FixedHeight, imageSpacing: ImageSpacing), + new TextImageWidget(label, disabledFillColor, disabledBorderColor, disabledTextColor, borderWidth, Margin, null, fontSize: this.fontSize, height: this.FixedHeight, imageSpacing: ImageSpacing) ); var textImageButton = new Button(0, 0, buttonViewWidget) @@ -188,22 +186,14 @@ namespace MatterHackers.MatterControl disabledImage = normalImage.Multiply(new Color(255, 255, 255, 150)); } - // TODO: This overrides users settings in a way that's completely unclear - if (invertImageLocation) - { - Options.FlowDirection = FlowDirection.RightToLeft; - } - else - { - Options.FlowDirection = FlowDirection.LeftToRight; - } + Options.FlowDirection = FlowDirection.LeftToRight; //Create the multi-state button view return new ButtonViewStates( - new TextImageWidget(label, normalFillColor, normalBorderColor, normalTextColor, borderWidth, Margin, normalImage, flowDirection: flowDirection, fontSize: this.fontSize, height: this.FixedHeight, imageSpacing: ImageSpacing), - new TextImageWidget(label, hoverFillColor, hoverBorderColor, hoverTextColor, borderWidth, Margin, hoverImage, flowDirection: flowDirection, fontSize: this.fontSize, height: this.FixedHeight, imageSpacing: ImageSpacing), - new TextImageWidget(label, pressedFillColor, pressedBorderColor, pressedTextColor, borderWidth, Margin, pressedImage, flowDirection: flowDirection, fontSize: this.fontSize, height: this.FixedHeight, imageSpacing: ImageSpacing), - new TextImageWidget(label, disabledFillColor, disabledBorderColor, disabledTextColor, borderWidth, Margin, disabledImage, flowDirection: flowDirection, fontSize: this.fontSize, height: this.FixedHeight, imageSpacing: ImageSpacing) + new TextImageWidget(label, normalFillColor, normalBorderColor, normalTextColor, borderWidth, Margin, normalImage, fontSize: this.fontSize, height: this.FixedHeight, imageSpacing: ImageSpacing), + new TextImageWidget(label, hoverFillColor, hoverBorderColor, hoverTextColor, borderWidth, Margin, hoverImage, fontSize: this.fontSize, height: this.FixedHeight, imageSpacing: ImageSpacing), + new TextImageWidget(label, pressedFillColor, pressedBorderColor, pressedTextColor, borderWidth, Margin, pressedImage, fontSize: this.fontSize, height: this.FixedHeight, imageSpacing: ImageSpacing), + new TextImageWidget(label, disabledFillColor, disabledBorderColor, disabledTextColor, borderWidth, Margin, disabledImage, fontSize: this.fontSize, height: this.FixedHeight, imageSpacing: ImageSpacing) ); } @@ -221,24 +211,16 @@ namespace MatterHackers.MatterControl pressedText = label; } - // TODO: This overrides users settings in a way that's completely unclear - if (invertImageLocation) - { - Options.FlowDirection = FlowDirection.RightToLeft; - } - else - { - Options.FlowDirection = FlowDirection.LeftToRight; - } + Options.FlowDirection = FlowDirection.LeftToRight; //Create the multi-state button view - GuiWidget normal = new TextImageWidget(label, normalFillColor, normalBorderColor, normalTextColor, borderWidth, Margin, normalImage, flowDirection: flowDirection, fontSize: this.fontSize, height: this.FixedHeight); - GuiWidget normalHover = new TextImageWidget(label, hoverFillColor, normalBorderColor, hoverTextColor, borderWidth, Margin, normalImage, flowDirection: flowDirection, fontSize: this.fontSize, height: this.FixedHeight); - GuiWidget switchNormalToPressed = new TextImageWidget(label, pressedFillColor, normalBorderColor, pressedTextColor, borderWidth, Margin, normalToPressedImage, flowDirection: flowDirection, fontSize: this.fontSize, height: this.FixedHeight); - GuiWidget pressed = new TextImageWidget(pressedText, pressedFillColor, pressedBorderColor, pressedTextColor, borderWidth, Margin, pressedImage, flowDirection: flowDirection, fontSize: this.fontSize, height: this.FixedHeight); - GuiWidget pressedHover = new TextImageWidget(label, hoverFillColor, pressedBorderColor, hoverTextColor, borderWidth, Margin, pressedImage, flowDirection: flowDirection, fontSize: this.fontSize, height: this.FixedHeight); - GuiWidget switchPressedToNormal = new TextImageWidget(label, normalFillColor, pressedBorderColor, normalTextColor, borderWidth, Margin, pressedToNormalImage, flowDirection: flowDirection, fontSize: this.fontSize, height: this.FixedHeight); - GuiWidget disabled = new TextImageWidget(label, disabledFillColor, disabledBorderColor, disabledTextColor, borderWidth, Margin, normalImage, flowDirection: flowDirection, fontSize: this.fontSize, height: this.FixedHeight); + GuiWidget normal = new TextImageWidget(label, normalFillColor, normalBorderColor, normalTextColor, borderWidth, Margin, normalImage, fontSize: this.fontSize, height: this.FixedHeight); + GuiWidget normalHover = new TextImageWidget(label, hoverFillColor, normalBorderColor, hoverTextColor, borderWidth, Margin, normalImage, fontSize: this.fontSize, height: this.FixedHeight); + GuiWidget switchNormalToPressed = new TextImageWidget(label, pressedFillColor, normalBorderColor, pressedTextColor, borderWidth, Margin, normalToPressedImage, fontSize: this.fontSize, height: this.FixedHeight); + GuiWidget pressed = new TextImageWidget(pressedText, pressedFillColor, pressedBorderColor, pressedTextColor, borderWidth, Margin, pressedImage, fontSize: this.fontSize, height: this.FixedHeight); + GuiWidget pressedHover = new TextImageWidget(label, hoverFillColor, pressedBorderColor, hoverTextColor, borderWidth, Margin, pressedImage, fontSize: this.fontSize, height: this.FixedHeight); + GuiWidget switchPressedToNormal = new TextImageWidget(label, normalFillColor, pressedBorderColor, normalTextColor, borderWidth, Margin, pressedToNormalImage, fontSize: this.fontSize, height: this.FixedHeight); + GuiWidget disabled = new TextImageWidget(label, disabledFillColor, disabledBorderColor, disabledTextColor, borderWidth, Margin, normalImage, fontSize: this.fontSize, height: this.FixedHeight); return new CheckBoxViewStates(normal, normalHover, switchNormalToPressed, pressed, pressedHover, switchPressedToNormal, disabled); } @@ -247,11 +229,11 @@ namespace MatterHackers.MatterControl { BorderDouble internalMargin = 0; - var nomalState = new TextImageWidget(label, normalFillColor, normalBorderColor, normalTextColor, borderWidth, internalMargin, iconImage, flowDirection: flowDirection, fontSize: this.fontSize, height: this.FixedHeight, width: this.FixedWidth); - var hoverState = new TextImageWidget(label, hoverFillColor, hoverBorderColor, hoverTextColor, borderWidth, internalMargin, iconImage, flowDirection: flowDirection, fontSize: this.fontSize, height: this.FixedHeight, width: this.FixedWidth); - var checkingState = new TextImageWidget(label, hoverFillColor, checkedBorderColor, hoverTextColor, borderWidth, internalMargin, iconImage, flowDirection: flowDirection, fontSize: this.fontSize, height: this.FixedHeight, width: this.FixedWidth); - var checkedState = new TextImageWidget(label, pressedFillColor, checkedBorderColor, pressedTextColor, borderWidth, internalMargin, iconImage, flowDirection: flowDirection, fontSize: this.fontSize, height: this.FixedHeight, width: this.FixedWidth); - var disabledState = new TextImageWidget(label, disabledFillColor, disabledBorderColor, disabledTextColor, borderWidth, internalMargin, iconImage, flowDirection: flowDirection, fontSize: this.fontSize, height: this.FixedHeight, width: this.FixedWidth); + var nomalState = new TextImageWidget(label, normalFillColor, normalBorderColor, normalTextColor, borderWidth, internalMargin, iconImage, fontSize: this.fontSize, height: this.FixedHeight, width: this.FixedWidth); + var hoverState = new TextImageWidget(label, hoverFillColor, hoverBorderColor, hoverTextColor, borderWidth, internalMargin, iconImage, fontSize: this.fontSize, height: this.FixedHeight, width: this.FixedWidth); + var checkingState = new TextImageWidget(label, hoverFillColor, checkedBorderColor, hoverTextColor, borderWidth, internalMargin, iconImage, fontSize: this.fontSize, height: this.FixedHeight, width: this.FixedWidth); + var checkedState = new TextImageWidget(label, pressedFillColor, checkedBorderColor, pressedTextColor, borderWidth, internalMargin, iconImage, fontSize: this.fontSize, height: this.FixedHeight, width: this.FixedWidth); + var disabledState = new TextImageWidget(label, disabledFillColor, disabledBorderColor, disabledTextColor, borderWidth, internalMargin, iconImage, fontSize: this.fontSize, height: this.FixedHeight, width: this.FixedWidth); var buttonView = new RadioButtonViewStates(nomalState, hoverState, checkingState, checkedState, disabledState); @@ -292,7 +274,6 @@ namespace MatterHackers.MatterControl public double FontSize { get; set; } = 12; public double BorderWidth { get; set; } = 1; - public bool InvertImageLocation { get; set; } = false; public bool AllowThemeToAdjustImage { get; set; } = true; public double FixedWidth { get; set; } = 0; @@ -334,7 +315,6 @@ namespace MatterHackers.MatterControl this.FlowDirection = cloneSource.FlowDirection; this.FontSize = cloneSource.FontSize; this.ImageSpacing = cloneSource.ImageSpacing; - this.InvertImageLocation = cloneSource.InvertImageLocation; this.Margin = cloneSource.Margin; this.NormalTextColor = cloneSource.NormalTextColor; diff --git a/CustomWidgets/PrintingWindow/PrintingWindow.cs b/CustomWidgets/PrintingWindow/PrintingWindow.cs index 5c90e6fad..00cb8bd04 100644 --- a/CustomWidgets/PrintingWindow/PrintingWindow.cs +++ b/CustomWidgets/PrintingWindow/PrintingWindow.cs @@ -49,7 +49,6 @@ namespace MatterHackers.MatterControl.CustomWidgets private TextImageButtonFactory buttonFactory = new TextImageButtonFactory(new ButtonFactoryOptions() { FontSize = 15, - InvertImageLocation = false, NormalTextColor = ActiveTheme.Instance.PrimaryTextColor, HoverTextColor = ActiveTheme.Instance.PrimaryTextColor, DisabledTextColor = new Color(ActiveTheme.Instance.PrimaryTextColor, 100), diff --git a/PartPreviewWindow/View3D/SceneActions.cs b/PartPreviewWindow/View3D/SceneActions.cs index 92418708b..d255a35b0 100644 --- a/PartPreviewWindow/View3D/SceneActions.cs +++ b/PartPreviewWindow/View3D/SceneActions.cs @@ -162,18 +162,37 @@ namespace MatterHackers.MatterControl.PartPreviewWindow var originalItem = Scene.SelectedItem; if (originalItem != null) { - // new item can be null by the time this task kicks off - var clonedItem = originalItem.Clone(); + if (originalItem.ItemType == Object3DTypes.SelectionGroup) + { + // the selection is a group of obects that need to be copied + var copyList = originalItem.Children.ToList(); + Scene.SelectedItem = null; + foreach(var item in copyList) + { + var clonedItem = item.Clone(); + // make the name unique + var newName = agg_basics.GetNonCollidingName(item.Name, Scene.Descendants().Select((d) => d.Name)); + clonedItem.Name = newName; + // add it to the scene + Scene.Children.Add(clonedItem); + // add it to the selection + Scene.AddToSelection(clonedItem); + } + } + else // the selection can be cloned easily + { + var clonedItem = originalItem.Clone(); - // make the name unique - var newName = agg_basics.GetNonCollidingName(originalItem.Name, Scene.Descendants().Select((d) => d.Name)); - clonedItem.Name = newName; + // make the name unique + var newName = agg_basics.GetNonCollidingName(originalItem.Name, Scene.Descendants().Select((d) => d.Name)); + clonedItem.Name = newName; - // More usefull if it creates the part in the exact positon and then the user can move it. - // Consistent with othre software as well. LBB 2017-12-02 - //PlatingHelper.MoveToOpenPositionRelativeGroup(clonedItem, Scene.Children); + // More usefull if it creates the part in the exact positon and then the user can move it. + // Consistent with othre software as well. LBB 2017-12-02 + //PlatingHelper.MoveToOpenPositionRelativeGroup(clonedItem, Scene.Children); - return clonedItem; + return clonedItem; + } } return null; diff --git a/Submodules/MatterSlice b/Submodules/MatterSlice index 49b66b511..6d2c85513 160000 --- a/Submodules/MatterSlice +++ b/Submodules/MatterSlice @@ -1 +1 @@ -Subproject commit 49b66b511e49046b42283716739f1068c14c211b +Subproject commit 6d2c85513425184f85da43f25e207b01d8cbca74 diff --git a/Submodules/agg-sharp b/Submodules/agg-sharp index 8362de08f..5b171e446 160000 --- a/Submodules/agg-sharp +++ b/Submodules/agg-sharp @@ -1 +1 @@ -Subproject commit 8362de08f6ea3c08ef493bd8c3f90c12d6d8e7d4 +Subproject commit 5b171e44631031cf36b8c983d6d9cedc1c95167d