diff --git a/ActionBar/PrinterConnectAndSelectControl.cs b/ActionBar/PrinterConnectAndSelectControl.cs
index 5d6328707..7b5d474ee 100644
--- a/ActionBar/PrinterConnectAndSelectControl.cs
+++ b/ActionBar/PrinterConnectAndSelectControl.cs
@@ -39,7 +39,7 @@ using MatterHackers.MatterControl.SlicerConfiguration;
namespace MatterHackers.MatterControl.ActionBar
{
- public class PrinterSelectEditDropdown : FlowLayoutWidget
+ public class PrinterSelectEditDropdown : FlowLayoutWidget, IIgnoredPopupChild
{
private PrinterSelector printerSelector;
private GuiWidget printerSelectorAndEditOverlay;
@@ -50,7 +50,7 @@ namespace MatterHackers.MatterControl.ActionBar
{
printerSelector = new PrinterSelector()
{
- HAnchor = HAnchor.ParentLeftRight,
+ HAnchor = HAnchor.FitToChildren,
Cursor = Cursors.Hand,
Margin = 0
};
diff --git a/MatterControl.csproj b/MatterControl.csproj
index bfc7ef6b6..5d7fd0e4a 100644
--- a/MatterControl.csproj
+++ b/MatterControl.csproj
@@ -205,7 +205,9 @@
+
+
diff --git a/MatterControlApplication.cs b/MatterControlApplication.cs
index 1fb296df2..6fccb289c 100644
--- a/MatterControlApplication.cs
+++ b/MatterControlApplication.cs
@@ -915,7 +915,7 @@ namespace MatterHackers.MatterControl
if (showNamesUnderMouse)
{
List namedChildren = new List();
- this.FindNamedChildrenRecursive("", namedChildren, new RectangleDouble(mousePosition.x, mousePosition.y, mousePosition.x + 1 , mousePosition.y + 1), SearchType.Partial, allowInvalidItems: false);
+ this.FindNamedChildrenRecursive("", namedChildren, new RectangleDouble(mousePosition.x, mousePosition.y, mousePosition.x + 1 , mousePosition.y + 1), SearchType.Partial, allowDisabledOrHidden: false);
Vector2 start = new Vector2(10, 50);
int lineHeight = 20;
e.graphics2D.FillRectangle(start, start + new Vector2(500, namedChildren.Count * lineHeight), new RGBA_Bytes(RGBA_Bytes.Black, 120));
diff --git a/PartPreviewWindow/OverflowDropdown.cs b/PartPreviewWindow/OverflowDropdown.cs
index e18d041ae..5d45f23d8 100644
--- a/PartPreviewWindow/OverflowDropdown.cs
+++ b/PartPreviewWindow/OverflowDropdown.cs
@@ -27,33 +27,28 @@ of the authors and should not be interpreted as representing official policies,
either expressed or implied, of the FreeBSD Project.
*/
-using MatterHackers.Agg;
-using MatterHackers.Agg.UI;
-using MatterHackers.VectorMath;
-using System.IO;
-using MatterHackers.Localizations;
-using MatterHackers.Agg.PlatformAbstract;
-using MatterHackers.Agg.Image;
-using MatterHackers.Agg.ImageProcessing;
using System;
+using System.Collections.Generic;
+using System.IO;
+using MatterHackers.Agg;
+using MatterHackers.Agg.ImageProcessing;
+using MatterHackers.Agg.PlatformAbstract;
+using MatterHackers.Agg.UI;
+using MatterHackers.Localizations;
+using MatterHackers.VectorMath;
namespace MatterHackers.MatterControl.PartPreviewWindow
{
- public class OverflowDropdown : ImageWidget
+
+ public class OverflowDropdown : PopupButton
{
- private static readonly RGBA_Bytes slightShade = new RGBA_Bytes(0, 0, 0, 40);
-
- private bool menuInitiallyActive = false;
- private bool overflowMenuActive = false;
-
public OverflowDropdown(bool allowLightnessInvert)
: base(LoadThemedIcon(allowLightnessInvert))
{
this.ToolTipText = "More...".Localize();
- this.Margin = 3;
}
- public static ImageBuffer LoadThemedIcon(bool allowLightnessInvert)
+ public static ImageWidget LoadThemedIcon(bool allowLightnessInvert)
{
var imageBuffer = StaticData.Instance.LoadIcon(Path.Combine("ViewTransformControls", "overflow.png"), 32, 32);
if (!ActiveTheme.Instance.IsDarkTheme && allowLightnessInvert)
@@ -61,8 +56,51 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
imageBuffer.InvertLightness();
}
- return imageBuffer;
+ return new ImageWidget(imageBuffer);
}
+ }
+
+ public class PopupButton : GuiWidget
+ {
+ private static readonly RGBA_Bytes slightShade = new RGBA_Bytes(0, 0, 0, 40);
+
+ private bool menuVisible = false;
+ private bool menuVisibileAtMouseDown = false;
+
+ private PopupWidget popupWidget;
+
+ //private GuiWidget buttonView;
+
+ private GuiWidget buttonView;
+
+ public PopupButton(GuiWidget buttonView)
+ {
+ this.Margin = 3;
+ this.HAnchor = HAnchor.FitToChildren;
+ this.VAnchor = VAnchor.FitToChildren;
+ this.buttonView = buttonView;
+
+ this.AddChild(buttonView);
+
+ // After the buttonView looses focus, wait a moment for the mouse to arrive at the target and if not found, close the menu
+ buttonView.MouseLeaveBounds += (s, e) =>
+ {
+ if (menuVisible)
+ {
+ UiThread.RunOnIdle(() =>
+ {
+ if (this.PopupContent?.UnderMouseState != UnderMouseState.NotUnderMouse)
+ {
+ return;
+ }
+
+ popupWidget?.CloseMenu();
+ }, 0.1);
+ }
+ };
+ }
+
+ public Direction PopDirection { get; set; } = Direction.Down;
public GuiWidget PopupContent { get; set; }
@@ -72,24 +110,26 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
public override void OnMouseDown(MouseEventArgs mouseEvent)
{
- menuInitiallyActive = overflowMenuActive;
+ // Store the menu state at the time of mousedown
+ menuVisibileAtMouseDown = menuVisible;
base.OnMouseDown(mouseEvent);
}
- public override void OnClick(MouseEventArgs mouseEvent)
+ public override void OnMouseUp(MouseEventArgs mouseEvent)
{
- if (!menuInitiallyActive)
+ // Only show the popup if the menu was hidden as the mouse events started
+ if (buttonView.MouseCaptured && !menuVisibileAtMouseDown)
{
ShowPopup();
this.BackgroundColor = slightShade;
}
- base.OnClick(mouseEvent);
+ base.OnMouseUp(mouseEvent);
}
public void ShowPopup()
{
- overflowMenuActive = true;
+ menuVisible = true;
this.PopupContent?.ClearRemovedFlag();
@@ -103,16 +143,17 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
return;
}
- var popupWidget = new PopupWidget(this.PopupContent, this, Vector2.Zero, Direction.Down, 0, this.AlignToRightEdge)
+ popupWidget = new PopupWidget(this.PopupContent, this, Vector2.Zero, this.PopDirection, 0, this.AlignToRightEdge)
{
BorderWidth = 1,
BorderColor = RGBA_Bytes.Gray,
- BackgroundColor = RGBA_Bytes.White,
};
+
popupWidget.Closed += (s, e) =>
{
this.BackgroundColor = RGBA_Bytes.Transparent;
- overflowMenuActive = false;
+ menuVisible = false;
+ popupWidget = null;
};
popupWidget.Focus();
}
diff --git a/PartPreviewWindow/PartPreviewContent.cs b/PartPreviewWindow/PartPreviewContent.cs
index e832045c5..d8c01c06c 100644
--- a/PartPreviewWindow/PartPreviewContent.cs
+++ b/PartPreviewWindow/PartPreviewContent.cs
@@ -151,7 +151,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
this.AddChild(topToBottom);
// Must come after we have an instance of View3DWidget an its undo buffer
- topToBottom.AddChild(new PrinterActionsBar(modelViewer.UndoBuffer));
+ topToBottom.AddChild(new PrinterActionsBar(modelViewer));
topToBottom.AddChild(modelViewer);
// The slice layers view
diff --git a/PartPreviewWindow/View3D/GridOptionsPanel.cs b/PartPreviewWindow/View3D/GridOptionsPanel.cs
new file mode 100644
index 000000000..845906af9
--- /dev/null
+++ b/PartPreviewWindow/View3D/GridOptionsPanel.cs
@@ -0,0 +1,82 @@
+/*
+Copyright (c) 2017, Lars Brubaker, John Lewin
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+1. Redistributions of source code must retain the above copyright notice, this
+ list of conditions and the following disclaimer.
+2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
+ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+The views and conclusions contained in the software and documentation are those
+of the authors and should not be interpreted as representing official policies,
+either expressed or implied, of the FreeBSD Project.
+*/
+using System.Collections.Generic;
+using MatterHackers.Agg;
+using MatterHackers.Agg.UI;
+using MatterHackers.Localizations;
+using MatterHackers.MeshVisualizer;
+
+namespace MatterHackers.MatterControl.PartPreviewWindow
+{
+ public class GridOptionsPanel : FlowLayoutWidget, IIgnoredPopupChild
+ {
+ public GridOptionsPanel(MeshViewerWidget meshViewerWidget) : base(FlowDirection.TopToBottom)
+ {
+ this.HAnchor = HAnchor.ParentLeftRight;
+ this.Padding = 10;
+
+ this.AddChild(new TextWidget("Snap Grid".Localize())
+ {
+ TextColor = RGBA_Bytes.Black,
+ Margin = new BorderDouble(0, 0, 0, 10)
+ });
+
+ var snapSettings = new Dictionary()
+ {
+ { 0, "Off" },
+ { .1, "0.1" },
+ { .25, "0.25" },
+ { .5, "0.5" },
+ { 1, "1" },
+ { 2, "2" },
+ { 5, "5" },
+ };
+
+ var dropDownList = new DropDownList("Custom", Direction.Down)
+ {
+ TextColor = RGBA_Bytes.Black
+ };
+
+ foreach (var snapSetting in snapSettings)
+ {
+ MenuItem newItem = dropDownList.AddItem(snapSetting.Value);
+ if (meshViewerWidget.SnapGridDistance == snapSetting.Key)
+ {
+ dropDownList.SelectedLabel = snapSetting.Value;
+ }
+
+ newItem.Selected += (sender, e) =>
+ {
+ meshViewerWidget.SnapGridDistance = snapSetting.Key;
+ };
+ }
+ this.AddChild(dropDownList);
+ }
+ }
+}
\ No newline at end of file
diff --git a/PartPreviewWindow/View3D/PrinterActionsBar.cs b/PartPreviewWindow/View3D/PrinterActionsBar.cs
index a3d26186a..7c4d523bb 100644
--- a/PartPreviewWindow/View3D/PrinterActionsBar.cs
+++ b/PartPreviewWindow/View3D/PrinterActionsBar.cs
@@ -46,8 +46,12 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
private string noEepromMappingMessage = "Oops! There is no eeprom mapping for your printer's firmware.".Localize() + "\n\n" + "You may need to wait a minute for your printer to finish initializing.".Localize();
private string noEepromMappingTitle = "Warning - No EEProm Mapping".Localize();
- public PrinterActionsBar(UndoBuffer undoBuffer)
+ private OverflowDropdown overflowDropdown;
+
+ public PrinterActionsBar(View3DWidget modelViewer)
{
+ UndoBuffer undoBuffer = modelViewer.UndoBuffer;
+
this.Padding = new BorderDouble(0, 5);
this.HAnchor = HAnchor.ParentLeftRight;
this.VAnchor = VAnchor.FitToChildren;
@@ -79,7 +83,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
this.AddChild(new HorizontalSpacer());
- this.AddChild(GeneratePopupContent());
+ //this.AddChild(GeneratePopupContent());
Button undoButton = buttonFactory.Generate("Undo".Localize(), centerText: true);
undoButton.Name = "3D View Undo";
@@ -106,7 +110,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
redoButton.Enabled = undoBuffer.RedoCount > 0;
};
- var overflowDropdown = new OverflowDropdown(allowLightnessInvert: true)
+ overflowDropdown = new OverflowDropdown(allowLightnessInvert: true)
{
AlignToRightEdge = true,
};
@@ -123,12 +127,17 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
private GuiWidget GeneratePopupContent()
{
- var widgetToPop = new FlowLayoutWidget();
- widgetToPop.MaximumSize = new VectorMath.Vector2(280, 35);
+ var widgetToPop = new FlowLayoutWidget()
+ {
+ HAnchor = HAnchor.FitToChildren,
+ VAnchor = VAnchor.FitToChildren,
+ BackgroundColor = ActiveTheme.Instance.PrimaryBackgroundColor
+ };
- widgetToPop.AddChild(new PrinterSelectEditDropdown());
-
- //widgetToPop.AddChild("more stuff...");
+ widgetToPop.AddChild(new PrinterSelectEditDropdown()
+ {
+ Margin = 10
+ });
return widgetToPop;
}
diff --git a/PartPreviewWindow/View3D/SideBar/MirrorControls.cs b/PartPreviewWindow/View3D/SideBar/MirrorControls.cs
index cbf27f91c..432a510e3 100644
--- a/PartPreviewWindow/View3D/SideBar/MirrorControls.cs
+++ b/PartPreviewWindow/View3D/SideBar/MirrorControls.cs
@@ -32,29 +32,20 @@ using MatterHackers.Agg.UI;
namespace MatterHackers.MatterControl.PartPreviewWindow
{
- public partial class MirrorControls : FlowLayoutWidget
+ public partial class MirrorControls : PopupActionPanel
{
private View3DWidget view3DWidget;
- public MirrorControls(View3DWidget view3DWidget)
- : base(FlowDirection.TopToBottom)
+ public MirrorControls(View3DWidget view3DWidget, TextImageButtonFactory buttonFactory)
{
this.view3DWidget = view3DWidget;
- AddMirrorControls(this);
- }
-
- private void AddMirrorControls(FlowLayoutWidget buttonPanel)
- {
List mirrorControls = new List();
- double oldFixedWidth = view3DWidget.textImageButtonFactory.FixedWidth;
- view3DWidget.textImageButtonFactory.FixedWidth = view3DWidget.EditButtonHeight;
-
FlowLayoutWidget buttonContainer = new FlowLayoutWidget(FlowDirection.LeftToRight);
buttonContainer.HAnchor = HAnchor.FitToChildren;
- Button mirrorXButton = view3DWidget.textImageButtonFactory.Generate("X", centerText: true);
+ Button mirrorXButton = buttonFactory.Generate("X", centerText: true);
buttonContainer.AddChild(mirrorXButton);
mirrorControls.Add(mirrorXButton);
mirrorXButton.Click += (s, e) =>
@@ -74,7 +65,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
}
};
- Button mirrorYButton = view3DWidget.textImageButtonFactory.Generate("Y", centerText: true);
+ Button mirrorYButton = buttonFactory.Generate("Y", centerText: true);
buttonContainer.AddChild(mirrorYButton);
mirrorControls.Add(mirrorYButton);
mirrorYButton.Click += (s, e) =>
@@ -94,7 +85,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
}
};
- Button mirrorZButton = view3DWidget.textImageButtonFactory.Generate("Z", centerText: true);
+ Button mirrorZButton = buttonFactory.Generate("Z", centerText: true);
buttonContainer.AddChild(mirrorZButton);
mirrorControls.Add(mirrorZButton);
mirrorZButton.Click += (s, e) =>
@@ -113,9 +104,8 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
Invalidate(); */
}
};
- buttonPanel.AddChild(buttonContainer);
- buttonPanel.AddChild(view3DWidget.GenerateHorizontalRule());
- view3DWidget.textImageButtonFactory.FixedWidth = oldFixedWidth;
+
+ this.AddChild(buttonContainer);
}
private void MirrorOnAxis(int axisIndex)
diff --git a/PartPreviewWindow/View3D/SideBar/RotateControls.cs b/PartPreviewWindow/View3D/SideBar/RotateControls.cs
new file mode 100644
index 000000000..bc21a290f
--- /dev/null
+++ b/PartPreviewWindow/View3D/SideBar/RotateControls.cs
@@ -0,0 +1,165 @@
+/*
+Copyright (c) 2017, Lars Brubaker, John Lewin
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+1. Redistributions of source code must retain the above copyright notice, this
+ list of conditions and the following disclaimer.
+2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
+ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+The views and conclusions contained in the software and documentation are those
+of the authors and should not be interpreted as representing official policies,
+either expressed or implied, of the FreeBSD Project.
+*/
+
+using System.Collections.Generic;
+using MatterHackers.Agg;
+using MatterHackers.Agg.Image;
+using MatterHackers.Agg.PlatformAbstract;
+using MatterHackers.Agg.UI;
+using MatterHackers.Localizations;
+using MatterHackers.MatterControl.CustomWidgets;
+using MatterHackers.VectorMath;
+
+namespace MatterHackers.MatterControl.PartPreviewWindow
+{
+ public class RotateControls : PopupActionPanel
+ {
+ private View3DWidget view3DWidget;
+
+ public RotateControls(View3DWidget view3DWidget, TextImageButtonFactory buttonFactory, TextImageButtonFactory smallMarginButtonFactory)
+ {
+ this.view3DWidget = view3DWidget;
+ this.HAnchor = HAnchor.FitToChildren;
+
+ var degreesContainer = new FlowLayoutWidget(FlowDirection.LeftToRight);
+ degreesContainer.HAnchor = HAnchor.ParentLeftRight;
+ degreesContainer.Padding = new BorderDouble(5);
+
+ var degreesLabel = new TextWidget("Degrees".Localize() + ":", textColor: ActiveTheme.Instance.PrimaryTextColor);
+ degreesContainer.AddChild(degreesLabel);
+ degreesContainer.AddChild(new HorizontalSpacer());
+
+ var degreesControl = new MHNumberEdit(45, pixelWidth: 40, allowNegatives: true, allowDecimals: true, increment: 5, minValue: -360, maxValue: 360);
+ degreesControl.VAnchor = Agg.UI.VAnchor.ParentTop;
+ degreesContainer.AddChild(degreesControl);
+
+ this.AddChild(degreesContainer);
+
+ var rotateButtonContainer = new FlowLayoutWidget(FlowDirection.LeftToRight)
+ {
+ HAnchor = HAnchor.FitToChildren
+ };
+
+ // Reused on each button below
+ var rotateIcon = StaticData.Instance.LoadIcon("icon_rotate_32x32.png", 32, 32);
+
+ var initialMargin = smallMarginButtonFactory.Margin;
+
+ smallMarginButtonFactory.Margin = 0;
+
+ //smallMarginButtonFactory.Margin = 0;
+
+ Button rotateXButton = CreateAxisButton("X", smallMarginButtonFactory.Generate("", rotateIcon));
+ rotateXButton.Click += (s, e) =>
+ {
+ var scene = view3DWidget.Scene;
+ if (scene.HasSelection)
+ {
+ double radians = MathHelper.DegreesToRadians(degreesControl.ActuallNumberEdit.Value);
+ Matrix4X4 rotation = Matrix4X4.CreateRotationX(radians);
+ Matrix4X4 undoTransform = scene.SelectedItem.Matrix;
+ scene.SelectedItem.Matrix = PlatingHelper.ApplyAtCenter(scene.SelectedItem, rotation);
+ view3DWidget.UndoBuffer.Add(new TransformUndoCommand(view3DWidget, scene.SelectedItem, undoTransform, scene.SelectedItem.Matrix));
+ view3DWidget.PartHasBeenChanged();
+ Invalidate();
+ }
+ };
+ rotateButtonContainer.AddChild(rotateXButton);
+
+ Button rotateYButton = CreateAxisButton("Y", smallMarginButtonFactory.Generate("", rotateIcon));
+ rotateYButton.Click += (s, e) =>
+ {
+ var scene = view3DWidget.Scene;
+ if (scene.HasSelection)
+ {
+ double radians = MathHelper.DegreesToRadians(degreesControl.ActuallNumberEdit.Value);
+ Matrix4X4 rotation = Matrix4X4.CreateRotationY(radians);
+ Matrix4X4 undoTransform = scene.SelectedItem.Matrix;
+ scene.SelectedItem.Matrix = PlatingHelper.ApplyAtCenter(scene.SelectedItem, rotation);
+ view3DWidget.UndoBuffer.Add(new TransformUndoCommand(view3DWidget, scene.SelectedItem, undoTransform, scene.SelectedItem.Matrix));
+ view3DWidget.PartHasBeenChanged();
+ Invalidate();
+ }
+ };
+ rotateButtonContainer.AddChild(rotateYButton);
+
+ Button rotateZButton = CreateAxisButton("Z", smallMarginButtonFactory.Generate("", rotateIcon));
+ rotateZButton.Click += (s, e) =>
+ {
+ var scene = view3DWidget.Scene;
+ if (scene.HasSelection)
+ {
+ double radians = MathHelper.DegreesToRadians(degreesControl.ActuallNumberEdit.Value);
+ Matrix4X4 rotation = Matrix4X4.CreateRotationZ(radians);
+ Matrix4X4 undoTransform = scene.SelectedItem.Matrix;
+ scene.SelectedItem.Matrix = PlatingHelper.ApplyAtCenter(scene.SelectedItem, rotation);
+ view3DWidget.UndoBuffer.Add(new TransformUndoCommand(view3DWidget, scene.SelectedItem, undoTransform, scene.SelectedItem.Matrix));
+ view3DWidget.PartHasBeenChanged();
+ Invalidate();
+ }
+ };
+ rotateButtonContainer.AddChild(rotateZButton);
+
+ this.AddChild(rotateButtonContainer);
+
+ Button layFlatButton = buttonFactory.Generate("Align to Bed".Localize(), centerText: true);
+ layFlatButton.HAnchor = HAnchor.ParentCenter;
+ layFlatButton.Margin = new BorderDouble(0, 0, 0, 8);
+ layFlatButton.Cursor = Cursors.Hand;
+ layFlatButton.Click += (s, e) =>
+ {
+ var scene = view3DWidget.Scene;
+
+ if (scene.HasSelection)
+ {
+ Matrix4X4 undoTransform = scene.SelectedItem.Matrix;
+ view3DWidget.MakeLowestFaceFlat(scene.SelectedItem);
+ view3DWidget.UndoBuffer.Add(new TransformUndoCommand(view3DWidget, scene.SelectedItem, undoTransform, scene.SelectedItem.Matrix));
+ view3DWidget.PartHasBeenChanged();
+ Invalidate();
+ }
+ };
+ this.AddChild(layFlatButton);
+
+ smallMarginButtonFactory.Margin = initialMargin;
+ }
+
+ private static Button CreateAxisButton(string axis, Button button)
+ {
+ var textWidget = new TextWidget(axis, pointSize: 10, textColor: ActiveTheme.Instance.PrimaryTextColor);
+ textWidget.Margin = new BorderDouble(3, 0, 0, 0);
+ textWidget.AnchorCenter();
+
+ button.Margin = new BorderDouble(0, 0, 12, 0);
+ button.AddChild(textWidget);
+
+ return button;
+ }
+ }
+}
\ No newline at end of file
diff --git a/PartPreviewWindow/View3D/SideBar/ScaleControls.cs b/PartPreviewWindow/View3D/SideBar/ScaleControls.cs
index 417207017..195be62d1 100644
--- a/PartPreviewWindow/View3D/SideBar/ScaleControls.cs
+++ b/PartPreviewWindow/View3D/SideBar/ScaleControls.cs
@@ -1,5 +1,5 @@
/*
-Copyright (c) 2014, Lars Brubaker
+Copyright (c) 2017, Lars Brubaker, John Lewin
All rights reserved.
Redistribution and use in source and binary forms, with or without
@@ -27,19 +27,26 @@ of the authors and should not be interpreted as representing official policies,
either expressed or implied, of the FreeBSD Project.
*/
+using System;
+using System.Collections.Generic;
using MatterHackers.Agg;
-using MatterHackers.Agg.ImageProcessing;
-using MatterHackers.Agg.PlatformAbstract;
using MatterHackers.Agg.UI;
using MatterHackers.Localizations;
using MatterHackers.MatterControl.CustomWidgets;
using MatterHackers.VectorMath;
-using System;
-using System.Collections.Generic;
namespace MatterHackers.MatterControl.PartPreviewWindow
{
- public partial class ScaleControls : FlowLayoutWidget
+ public class PopupActionPanel : FlowLayoutWidget, IIgnoredPopupChild
+ {
+ public PopupActionPanel() : base(FlowDirection.TopToBottom)
+ {
+ this.Padding = 15;
+ this.BackgroundColor = ActiveTheme.Instance.SecondaryBackgroundColor;
+ }
+ }
+
+ public class ScaleControls : PopupActionPanel
{
private Button applyScaleButton;
private MHNumberEdit scaleRatioControl;
@@ -47,28 +54,19 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
private CheckBox uniformScale;
private View3DWidget view3DWidget;
- public ScaleControls(View3DWidget view3DWidget)
- : base(FlowDirection.TopToBottom)
+ public ScaleControls(View3DWidget view3DWidget, TextImageButtonFactory buttonFactory)
{
this.view3DWidget = view3DWidget;
- AddScaleControls(this);
- view3DWidget.SelectedTransformChanged += OnSelectedTransformChanged;
- }
-
- private void AddScaleControls(FlowLayoutWidget buttonPanel)
- {
List scaleControls = new List();
// Put in the scale ratio edit field
{
- FlowLayoutWidget scaleRatioContainer = new FlowLayoutWidget(FlowDirection.LeftToRight);
+ var scaleRatioContainer = new FlowLayoutWidget(FlowDirection.LeftToRight);
scaleRatioContainer.HAnchor = HAnchor.ParentLeftRight;
scaleRatioContainer.Padding = new BorderDouble(5);
- string scaleRatioLabelText = "Ratio".Localize();
- string scaleRatioLabelTextFull = "{0}:".FormatWith(scaleRatioLabelText);
- TextWidget scaleRatioLabel = new TextWidget(scaleRatioLabelTextFull, textColor: ActiveTheme.Instance.PrimaryTextColor);
+ var scaleRatioLabel = new TextWidget("Ratio".Localize() + ":", textColor: ActiveTheme.Instance.PrimaryTextColor);
scaleRatioLabel.Margin = new BorderDouble(0, 0, 3, 0);
scaleRatioLabel.VAnchor = VAnchor.ParentCenter;
scaleRatioContainer.AddChild(scaleRatioLabel);
@@ -96,14 +94,14 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
scaleRatioContainer.AddChild(CreateScaleDropDownMenu());
- buttonPanel.AddChild(scaleRatioContainer);
+ this.AddChild(scaleRatioContainer);
scaleControls.Add(scaleRatioControl);
}
- applyScaleButton = view3DWidget.WhiteButtonFactory.Generate("Apply Scale".Localize(), centerText: true);
+ applyScaleButton = buttonFactory.Generate("Apply Scale".Localize(), centerText: true);
applyScaleButton.Cursor = Cursors.Hand;
- buttonPanel.AddChild(applyScaleButton);
+ this.AddChild(applyScaleButton);
scaleControls.Add(applyScaleButton);
applyScaleButton.Click += (s, e) =>
@@ -113,9 +111,9 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
// add in the dimensions
{
- buttonPanel.AddChild(CreateAxisScalingControl("x".ToUpper(), 0));
- buttonPanel.AddChild(CreateAxisScalingControl("y".ToUpper(), 1));
- buttonPanel.AddChild(CreateAxisScalingControl("z".ToUpper(), 2));
+ this.AddChild(CreateAxisScalingControl("x".ToUpper(), 0, buttonFactory));
+ this.AddChild(CreateAxisScalingControl("y".ToUpper(), 1, buttonFactory));
+ this.AddChild(CreateAxisScalingControl("z".ToUpper(), 2, buttonFactory));
uniformScale = new CheckBox("Lock Ratio".Localize(), textColor: ActiveTheme.Instance.PrimaryTextColor);
uniformScale.Checked = true;
@@ -124,10 +122,10 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
leftToRight.Padding = new BorderDouble(5, 3);
leftToRight.AddChild(uniformScale);
- buttonPanel.AddChild(leftToRight);
+ this.AddChild(leftToRight);
}
- buttonPanel.AddChild(view3DWidget.GenerateHorizontalRule());
+ view3DWidget.SelectedTransformChanged += OnSelectedTransformChanged;
}
private void ApplyScaleFromEditField()
@@ -154,16 +152,18 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
}
}
- private GuiWidget CreateAxisScalingControl(string axis, int axisIndex)
+ private GuiWidget CreateAxisScalingControl(string axis, int axisIndex, TextImageButtonFactory buttonFactory)
{
- FlowLayoutWidget leftToRight = new FlowLayoutWidget();
- leftToRight.Padding = new BorderDouble(5, 3);
+ var leftToRight = new FlowLayoutWidget()
+ {
+ Padding = new BorderDouble(5, 3)
+ };
- TextWidget sizeDescription = new TextWidget("{0}:".FormatWith(axis), textColor: ActiveTheme.Instance.PrimaryTextColor);
- sizeDescription.VAnchor = Agg.UI.VAnchor.ParentCenter;
+ var sizeDescription = new TextWidget("{0}:".FormatWith(axis), textColor: ActiveTheme.Instance.PrimaryTextColor);
+ sizeDescription.VAnchor = VAnchor.ParentCenter;
leftToRight.AddChild(sizeDescription);
- sizeDisplay[axisIndex] = new EditableNumberDisplay(view3DWidget.textImageButtonFactory, "100", "1000.00");
+ sizeDisplay[axisIndex] = new EditableNumberDisplay(buttonFactory, "100", "1000.00");
sizeDisplay[axisIndex].EditComplete += (sender, e) =>
{
if (view3DWidget.Scene.HasSelection)
@@ -187,16 +187,18 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
private DropDownMenu CreateScaleDropDownMenu()
{
- DropDownMenu presetScaleMenu = new DropDownMenu("", Direction.Down);
- presetScaleMenu.NormalArrowColor = ActiveTheme.Instance.PrimaryTextColor;
- presetScaleMenu.HoverArrowColor = ActiveTheme.Instance.PrimaryTextColor;
- presetScaleMenu.MenuAsWideAsItems = false;
- presetScaleMenu.AlignToRightEdge = true;
- //presetScaleMenu.OpenOffset = new Vector2(-50, 0);
- presetScaleMenu.HAnchor = HAnchor.AbsolutePosition;
- presetScaleMenu.VAnchor = VAnchor.AbsolutePosition;
- presetScaleMenu.Width = 25;
- presetScaleMenu.Height = scaleRatioControl.Height + 2;
+ var presetScaleMenu = new DropDownMenu("", Direction.Down)
+ {
+ NormalArrowColor = ActiveTheme.Instance.PrimaryTextColor,
+ HoverArrowColor = ActiveTheme.Instance.PrimaryTextColor,
+ MenuAsWideAsItems = false,
+ AlignToRightEdge = true,
+ //presetScaleMenu.OpenOffset = new Vector2(-50, 0);
+ HAnchor = HAnchor.AbsolutePosition,
+ VAnchor = VAnchor.AbsolutePosition,
+ Width = 25,
+ Height = scaleRatioControl.Height + 2
+ };
presetScaleMenu.AddItem("mm to in (.0393)");
presetScaleMenu.AddItem("in to mm (25.4)");
diff --git a/PartPreviewWindow/View3D/View3DWidget.cs b/PartPreviewWindow/View3D/View3DWidget.cs
index 0955ee483..847270be0 100644
--- a/PartPreviewWindow/View3D/View3DWidget.cs
+++ b/PartPreviewWindow/View3D/View3DWidget.cs
@@ -1,5 +1,5 @@
/*
-Copyright (c) 2014, Lars Brubaker
+Copyright (c) 2017, Lars Brubaker, John Lewin
All rights reserved.
Redistribution and use in source and binary forms, with or without
@@ -261,7 +261,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
centerPartPreviewAndControls.Name = "centerPartPreviewAndControls";
centerPartPreviewAndControls.AnchorAll();
- var textImageButtonFactory = ApplicationController.Instance.Theme.BreadCrumbButtonFactorySmallMargins;
+ var smallMarginButtonFactory = ApplicationController.Instance.Theme.BreadCrumbButtonFactorySmallMargins;
GuiWidget viewArea = new GuiWidget();
viewArea.AnchorAll();
@@ -321,7 +321,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
doEdittingButtonsContainer.Visible = false;
{
- Button addButton = textImageButtonFactory.Generate("Insert".Localize(), "icon_insert_32x32.png");
+ Button addButton = smallMarginButtonFactory.Generate("Insert".Localize(), "icon_insert_32x32.png");
addButton.Margin = new BorderDouble(right: 10);
doEdittingButtonsContainer.AddChild(addButton);
addButton.Click += (sender, e) =>
@@ -343,7 +343,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
separator.VAnchor = VAnchor.ParentBottomTop;
doEdittingButtonsContainer.AddChild(separator);
- Button ungroupButton = textImageButtonFactory.Generate("Ungroup".Localize());
+ Button ungroupButton = smallMarginButtonFactory.Generate("Ungroup".Localize());
ungroupButton.Name = "3D View Ungroup";
doEdittingButtonsContainer.AddChild(ungroupButton);
ungroupButton.Click += (sender, e) =>
@@ -351,7 +351,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
UngroupSelectedMeshGroup();
};
- Button groupButton = textImageButtonFactory.Generate("Group".Localize());
+ Button groupButton = smallMarginButtonFactory.Generate("Group".Localize());
groupButton.Name = "3D View Group";
doEdittingButtonsContainer.AddChild(groupButton);
groupButton.Click += (sender, e) =>
@@ -359,14 +359,14 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
GroupSelectedMeshs();
};
- Button alignButton = textImageButtonFactory.Generate("Align".Localize());
+ Button alignButton = smallMarginButtonFactory.Generate("Align".Localize());
doEdittingButtonsContainer.AddChild(alignButton);
alignButton.Click += (sender, e) =>
{
AlignToSelectedMeshGroup();
};
- Button arrangeButton = textImageButtonFactory.Generate("Arrange".Localize());
+ Button arrangeButton = smallMarginButtonFactory.Generate("Arrange".Localize());
doEdittingButtonsContainer.AddChild(arrangeButton);
arrangeButton.Click += (sender, e) =>
{
@@ -379,7 +379,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
separatorTwo.VAnchor = VAnchor.ParentBottomTop;
doEdittingButtonsContainer.AddChild(separatorTwo);
- Button copyButton = textImageButtonFactory.Generate("Copy".Localize());
+ Button copyButton = smallMarginButtonFactory.Generate("Copy".Localize());
copyButton.Name = "3D View Copy";
doEdittingButtonsContainer.AddChild(copyButton);
copyButton.Click += (sender, e) =>
@@ -387,7 +387,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
MakeCopyOfGroup();
};
- Button deleteButton = textImageButtonFactory.Generate("Remove".Localize());
+ Button deleteButton = smallMarginButtonFactory.Generate("Remove".Localize());
deleteButton.Name = "3D View Remove";
doEdittingButtonsContainer.AddChild(deleteButton);
deleteButton.Click += (sender, e) =>
@@ -401,7 +401,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
separatorThree.VAnchor = VAnchor.ParentBottomTop;
doEdittingButtonsContainer.AddChild(separatorThree);
- Button exportButton = textImageButtonFactory.Generate("Export".Localize() + "...");
+ Button exportButton = smallMarginButtonFactory.Generate("Export".Localize() + "...");
exportButton.Margin = new BorderDouble(right: 10);
exportButton.Click += (sender, e) =>
@@ -415,35 +415,27 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
// put in the save button
AddSaveAndSaveAs(doEdittingButtonsContainer);
- var rotateButton = textImageButtonFactory.Generate("Rotate".Localize());
- rotateButton.Click += (s, e) =>
+ // Normal margin factory
+ var normalMarginButtonFactory = ApplicationController.Instance.Theme.BreadCrumbButtonFactory;
+
+ var rotateButton = new PopupButton(smallMarginButtonFactory.Generate("Rotate".Localize()))
{
- var popup = new PopupWidget(this.CreateRotateControls(), rotateButton, Vector2.Zero, Direction.Up, 0, true);
- popup.Focus();
+ PopDirection = Direction.Up,
+ PopupContent = new RotateControls(this, normalMarginButtonFactory, smallMarginButtonFactory)
};
doEdittingButtonsContainer.AddChild(rotateButton);
- var scaleButton = textImageButtonFactory.Generate("Scale".Localize());
- scaleButton.Click += (s, e) =>
+ var scaleButton = new PopupButton(smallMarginButtonFactory.Generate("Scale".Localize()))
{
- var popup = new PopupWidget(new ScaleControls(this)
- {
- BackgroundColor = ActiveTheme.Instance.SecondaryBackgroundColor,
- Padding = 15
- }, scaleButton, Vector2.Zero, Direction.Up, 0, true);
- popup.Focus();
+ PopDirection = Direction.Up,
+ PopupContent = new ScaleControls(this, normalMarginButtonFactory)
};
doEdittingButtonsContainer.AddChild(scaleButton);
- var mirrorButton = textImageButtonFactory.Generate("Mirror".Localize());
- mirrorButton.Click += (s, e) =>
+ var mirrorButton = new PopupButton(smallMarginButtonFactory.Generate("Mirror".Localize()))
{
- var popup = new PopupWidget(new MirrorControls(this)
- {
- BackgroundColor = ActiveTheme.Instance.SecondaryBackgroundColor,
- Padding = 15
- }, mirrorButton, Vector2.Zero, Direction.Up, 0, true);
- popup.Focus();
+ PopDirection = Direction.Up,
+ PopupContent = new MirrorControls(this, normalMarginButtonFactory)
};
doEdittingButtonsContainer.AddChild(mirrorButton);
@@ -451,11 +443,10 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
int numberOfExtruders = ActiveSliceSettings.Instance.GetValue(SettingsKey.extruder_count);
if (numberOfExtruders > 1)
{
- var materialsButton = textImageButtonFactory.Generate("Materials".Localize());
- materialsButton.Click += (s, e) =>
+ var materialsButton = new PopupButton(smallMarginButtonFactory.Generate("Materials".Localize()))
{
- var popup = new PopupWidget(this.AddMaterialControls(), materialsButton, Vector2.Zero, Direction.Up, 0, true);
- popup.Focus();
+ PopDirection = Direction.Up,
+ PopupContent = this.AddMaterialControls()
};
doEdittingButtonsContainer.AddChild(materialsButton);
}
@@ -489,7 +480,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
if (windowType == WindowMode.StandAlone)
{
- Button closeButton = textImageButtonFactory.Generate("Close".Localize());
+ Button closeButton = smallMarginButtonFactory.Generate("Close".Localize());
buttonBottomPanel.AddChild(closeButton);
closeButton.Click += (sender, e) =>
{
@@ -1454,116 +1445,6 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
return buttonPanel;
}
- internal GuiWidget CreateRotateControls()
- {
- var buttonPanel = new FlowLayoutWidget(FlowDirection.TopToBottom)
- {
- BackgroundColor = ActiveTheme.Instance.SecondaryBackgroundColor,
- Padding = 15
- };
- List rotateControls = new List();
-
- textImageButtonFactory.FixedWidth = EditButtonHeight;
-
- FlowLayoutWidget degreesContainer = new FlowLayoutWidget(FlowDirection.LeftToRight);
- degreesContainer.HAnchor = HAnchor.ParentLeftRight;
- degreesContainer.Padding = new BorderDouble(5);
-
- string degreesLabelText = "Degrees".Localize();
- string degreesLabelTextFull = "{0}:".FormatWith(degreesLabelText);
- TextWidget degreesLabel = new TextWidget(degreesLabelText, textColor: ActiveTheme.Instance.PrimaryTextColor);
- degreesContainer.AddChild(degreesLabel);
- degreesContainer.AddChild(new HorizontalSpacer());
-
- MHNumberEdit degreesControl = new MHNumberEdit(45, pixelWidth: 40, allowNegatives: true, allowDecimals: true, increment: 5, minValue: -360, maxValue: 360);
- degreesControl.VAnchor = Agg.UI.VAnchor.ParentTop;
- degreesContainer.AddChild(degreesControl);
- rotateControls.Add(degreesControl);
-
- buttonPanel.AddChild(degreesContainer);
-
- FlowLayoutWidget rotateButtonContainer = new FlowLayoutWidget(FlowDirection.LeftToRight);
- rotateButtonContainer.HAnchor = HAnchor.ParentLeftRight;
-
- ImageBuffer rotateImage = StaticData.Instance.LoadIcon("icon_rotate_32x32.png", 32, 32);
- Button rotateXButton = textImageButtonFactory.Generate("", rotateImage);
- TextWidget centeredX = new TextWidget("X", pointSize: 10, textColor: ActiveTheme.Instance.PrimaryTextColor); centeredX.Margin = new BorderDouble(3, 0, 0, 0); centeredX.AnchorCenter(); rotateXButton.AddChild(centeredX);
- rotateButtonContainer.AddChild(rotateXButton);
- rotateControls.Add(rotateXButton);
- rotateXButton.Click += (s, e) =>
- {
- if (Scene.HasSelection)
- {
- double radians = MathHelper.DegreesToRadians(degreesControl.ActuallNumberEdit.Value);
- Matrix4X4 rotation = Matrix4X4.CreateRotationX(radians);
- Matrix4X4 undoTransform = Scene.SelectedItem.Matrix;
- Scene.SelectedItem.Matrix = PlatingHelper.ApplyAtCenter(Scene.SelectedItem, rotation);
- UndoBuffer.Add(new TransformUndoCommand(this, Scene.SelectedItem, undoTransform, Scene.SelectedItem.Matrix));
- PartHasBeenChanged();
- Invalidate();
- }
- };
-
- Button rotateYButton = textImageButtonFactory.Generate("", rotateImage);
- TextWidget centeredY = new TextWidget("Y", pointSize: 10, textColor: ActiveTheme.Instance.PrimaryTextColor); centeredY.Margin = new BorderDouble(3, 0, 0, 0); centeredY.AnchorCenter(); rotateYButton.AddChild(centeredY);
- rotateButtonContainer.AddChild(rotateYButton);
- rotateControls.Add(rotateYButton);
- rotateYButton.Click += (s, e) =>
- {
- if (Scene.HasSelection)
- {
- double radians = MathHelper.DegreesToRadians(degreesControl.ActuallNumberEdit.Value);
- Matrix4X4 rotation = Matrix4X4.CreateRotationY(radians);
- Matrix4X4 undoTransform = Scene.SelectedItem.Matrix;
- Scene.SelectedItem.Matrix = PlatingHelper.ApplyAtCenter(Scene.SelectedItem, rotation);
- UndoBuffer.Add(new TransformUndoCommand(this, Scene.SelectedItem, undoTransform, Scene.SelectedItem.Matrix));
- PartHasBeenChanged();
- Invalidate();
- }
- };
-
- Button rotateZButton = textImageButtonFactory.Generate("", rotateImage);
- TextWidget centeredZ = new TextWidget("Z", pointSize: 10, textColor: ActiveTheme.Instance.PrimaryTextColor); centeredZ.Margin = new BorderDouble(3, 0, 0, 0); centeredZ.AnchorCenter(); rotateZButton.AddChild(centeredZ);
- rotateButtonContainer.AddChild(rotateZButton);
- rotateControls.Add(rotateZButton);
- rotateZButton.Click += (s, e) =>
- {
- if (Scene.HasSelection)
- {
- double radians = MathHelper.DegreesToRadians(degreesControl.ActuallNumberEdit.Value);
- Matrix4X4 rotation = Matrix4X4.CreateRotationZ(radians);
- Matrix4X4 undoTransform = Scene.SelectedItem.Matrix;
- Scene.SelectedItem.Matrix = PlatingHelper.ApplyAtCenter(Scene.SelectedItem, rotation);
- UndoBuffer.Add(new TransformUndoCommand(this, Scene.SelectedItem, undoTransform, Scene.SelectedItem.Matrix));
- PartHasBeenChanged();
- Invalidate();
- }
- };
-
- buttonPanel.AddChild(rotateButtonContainer);
-
- Button layFlatButton = WhiteButtonFactory.Generate("Align to Bed".Localize(), centerText: true);
- layFlatButton.Cursor = Cursors.Hand;
- buttonPanel.AddChild(layFlatButton);
-
- layFlatButton.Click += (s, e) =>
- {
- if (Scene.HasSelection)
- {
- Matrix4X4 undoTransform = Scene.SelectedItem.Matrix;
- MakeLowestFaceFlat(Scene.SelectedItem);
- UndoBuffer.Add(new TransformUndoCommand(this, Scene.SelectedItem, undoTransform, Scene.SelectedItem.Matrix));
- PartHasBeenChanged();
- Invalidate();
- }
- };
-
- buttonPanel.AddChild(GenerateHorizontalRule());
- textImageButtonFactory.FixedWidth = 0;
-
- return buttonPanel;
- }
-
private void AddSaveAndSaveAs(FlowLayoutWidget flowToAddTo)
{
TupleList> buttonList = new TupleList>();
@@ -1964,7 +1845,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
}
}
- private void MakeLowestFaceFlat(IObject3D objectToLayFlatGroup)
+ internal void MakeLowestFaceFlat(IObject3D objectToLayFlatGroup)
{
Matrix4X4 objectToWold = objectToLayFlatGroup.Matrix;
IObject3D objectToLayFlat = objectToLayFlatGroup.Children[0];
@@ -2352,7 +2233,11 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
// ViewControls3D {{
internal GuiWidget ShowOverflowMenu()
{
- var popupContainer = new FlowLayoutWidget(FlowDirection.TopToBottom);
+ var popupContainer = new FlowLayoutWidget(FlowDirection.TopToBottom)
+ {
+ Padding = 12,
+ BackgroundColor = RGBA_Bytes.White
+ };
var meshViewer = meshViewerWidget;
@@ -2389,23 +2274,25 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
}
}));
}
+
+ popupContainer.AddChild(new HorizontalLine());
- var widget = new FlowLayoutWidget(FlowDirection.TopToBottom)
+ var renderOptions = CreateRenderTypeRadioButtons();
+ popupContainer.AddChild(renderOptions);
+
+ popupContainer.AddChild(new GridOptionsPanel(meshViewer));
+
+ return popupContainer;
+ }
+
+ private GuiWidget CreateRenderTypeRadioButtons()
+ {
+ var container = new FlowLayoutWidget(FlowDirection.TopToBottom)
{
HAnchor = HAnchor.ParentLeftRight,
Margin = new BorderDouble(5, 5, 5, 0)
};
- popupContainer.AddChild(new HorizontalLine());
- CreateRenderTypeRadioButtons(widget);
-
- popupContainer.AddChild(widget);
-
- return popupContainer;
- }
-
- private void CreateRenderTypeRadioButtons(GuiWidget parentContainer)
- {
string renderTypeString = UserSettings.Instance.get(UserSettingsKey.defaultRenderSetting);
if (renderTypeString == null)
{
@@ -2442,7 +2329,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
UserSettings.Instance.set(UserSettingsKey.defaultRenderSetting, meshViewerWidget.RenderType.ToString());
}
};
- parentContainer.AddChild(renderTypeCheckBox);
+ container.AddChild(renderTypeCheckBox);
}
{
@@ -2456,7 +2343,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
UserSettings.Instance.set(UserSettingsKey.defaultRenderSetting, meshViewerWidget.RenderType.ToString());
}
};
- parentContainer.AddChild(renderTypeCheckBox);
+ container.AddChild(renderTypeCheckBox);
}
{
@@ -2470,7 +2357,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
UserSettings.Instance.set(UserSettingsKey.defaultRenderSetting, meshViewerWidget.RenderType.ToString());
}
};
- parentContainer.AddChild(renderTypeCheckBox);
+ container.AddChild(renderTypeCheckBox);
}
{
@@ -2525,54 +2412,12 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
}
};
- parentContainer.AddChild(renderTypeCheckBox);
+ container.AddChild(renderTypeCheckBox);
- AddGridSnapSettings(parentContainer);
+ return container;
}
}
- private void AddGridSnapSettings(GuiWidget widgetToAddTo)
- {
- TextWidget snapGridLabel = new TextWidget("Snap Grid".Localize())
- {
- TextColor = ActiveTheme.Instance.PrimaryBackgroundColor,
- Margin = new BorderDouble(0, 0, 0, 10)
- };
- widgetToAddTo.AddChild(snapGridLabel);
-
- var selectableOptions = new DropDownList("Custom", Direction.Down);
-
- Dictionary snapSettings = new Dictionary()
- {
- { 0, "Off" },
- { .1, "0.1" },
- { .25, "0.25" },
- { .5, "0.5" },
- { 1, "1" },
- { 2, "2" },
- { 5, "5" },
- };
-
- foreach (KeyValuePair snapSetting in snapSettings)
- {
- double valueLocal = snapSetting.Key;
-
- MenuItem newItem = selectableOptions.AddItem(snapSetting.Value);
- if (meshViewerWidget.SnapGridDistance == valueLocal)
- {
- selectableOptions.SelectedLabel = snapSetting.Value;
- }
-
- newItem.Selected += (sender, e) =>
- {
- meshViewerWidget.SnapGridDistance = snapSetting.Key;
- };
- }
-
- widgetToAddTo.AddChild(selectableOptions);
- }
-
-
private static MenuItem AddCheckbox(string text, string itemValue, bool itemChecked, BorderDouble padding, EventHandler eventHandler)
{
var checkbox = new CheckBox(text)
@@ -2587,7 +2432,6 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
};
}
// ViewControls3D }}
-
}
public enum HitQuadrant { LB, LT, RB, RT }
diff --git a/PartPreviewWindow/ViewGcodeBasic.cs b/PartPreviewWindow/ViewGcodeBasic.cs
index 611743542..31e4bd8a0 100644
--- a/PartPreviewWindow/ViewGcodeBasic.cs
+++ b/PartPreviewWindow/ViewGcodeBasic.cs
@@ -329,11 +329,17 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
switch (e.TransformMode)
{
case ViewControls3DButtons.Translate:
- gcodeViewWidget.TransformState = ViewGcodeWidget.ETransformState.Move;
+ if (gcodeViewWidget != null)
+ {
+ gcodeViewWidget.TransformState = ViewGcodeWidget.ETransformState.Move;
+ }
meshViewerWidget.TrackballTumbleWidget.TransformState = TrackBallController.MouseDownType.Translation;
break;
case ViewControls3DButtons.Scale:
- gcodeViewWidget.TransformState = ViewGcodeWidget.ETransformState.Scale;
+ if (gcodeViewWidget != null)
+ {
+ gcodeViewWidget.TransformState = ViewGcodeWidget.ETransformState.Scale;
+ }
meshViewerWidget.TrackballTumbleWidget.TransformState = TrackBallController.MouseDownType.Scale;
break;
case ViewControls3DButtons.Rotate:
diff --git a/Submodules/agg-sharp b/Submodules/agg-sharp
index ae970cfbb..13f48c412 160000
--- a/Submodules/agg-sharp
+++ b/Submodules/agg-sharp
@@ -1 +1 @@
-Subproject commit ae970cfbb150b27c195cbbc9d862297c540402d4
+Subproject commit 13f48c412eabc8b71f807e9b322eb8ea3c869fb7