Move Undo operations to ViewControls3D
This commit is contained in:
parent
54ff6c5bff
commit
580312f05d
5 changed files with 47 additions and 42 deletions
|
|
@ -94,14 +94,14 @@ namespace MatterHackers.MatterControl
|
||||||
return groupLableAndEditControl;
|
return groupLableAndEditControl;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Button GenerateIconButton(ImageBuffer icon)
|
public Button GenerateIconButton(ImageBuffer icon, bool forceWhite = false)
|
||||||
{
|
{
|
||||||
if (ActiveTheme.Instance.IsDarkTheme)
|
if (ActiveTheme.Instance.IsDarkTheme || forceWhite)
|
||||||
{
|
{
|
||||||
icon.InvertLightness();
|
icon.InvertLightness();
|
||||||
}
|
}
|
||||||
|
|
||||||
return new Button(0, 0,
|
return new Button(0, 0,
|
||||||
new ButtonViewThreeImage(
|
new ButtonViewThreeImage(
|
||||||
icon.AjustAlpha(.7),
|
icon.AjustAlpha(.7),
|
||||||
icon.AjustAlpha(.9),
|
icon.AjustAlpha(.9),
|
||||||
|
|
|
||||||
|
|
@ -80,7 +80,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
|
||||||
|
|
||||||
double buildHeight = activeSettings.GetValue<double>(SettingsKey.build_height);
|
double buildHeight = activeSettings.GetValue<double>(SettingsKey.build_height);
|
||||||
|
|
||||||
viewControls3D = new ViewControls3D(ApplicationController.Instance.Theme)
|
viewControls3D = new ViewControls3D(ApplicationController.Instance.Theme, printer.BedPlate.Scene.UndoBuffer)
|
||||||
{
|
{
|
||||||
PartSelectVisible = false,
|
PartSelectVisible = false,
|
||||||
VAnchor = VAnchor.Top | VAnchor.Fit | VAnchor.Absolute,
|
VAnchor = VAnchor.Top | VAnchor.Fit | VAnchor.Absolute,
|
||||||
|
|
|
||||||
|
|
@ -160,41 +160,6 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
|
||||||
this.AddChild(new TemperatureWidgetBed());
|
this.AddChild(new TemperatureWidgetBed());
|
||||||
}
|
}
|
||||||
|
|
||||||
var theme = ApplicationController.Instance.Theme;
|
|
||||||
double height = theme.ButtonFactory.FixedHeight;
|
|
||||||
|
|
||||||
Button undoButton = buttonFactory.GenerateIconButton(StaticData.Instance.LoadIcon("Undo_grey_16x.png", 16, 16));
|
|
||||||
undoButton.Name = "3D View Undo";
|
|
||||||
undoButton.ToolTipText = "Undo";
|
|
||||||
undoButton.Enabled = false;
|
|
||||||
undoButton.MinimumSize = new Vector2(height, height);
|
|
||||||
undoButton.Margin = defaultMargin;
|
|
||||||
undoButton.Click += (sender, e) =>
|
|
||||||
{
|
|
||||||
undoBuffer.Undo();
|
|
||||||
};
|
|
||||||
this.AddChild(undoButton);
|
|
||||||
undoButton.VAnchor = VAnchor.Center;
|
|
||||||
|
|
||||||
Button redoButton = buttonFactory.GenerateIconButton(StaticData.Instance.LoadIcon("Redo_grey_16x.png", 16, 16));
|
|
||||||
redoButton.Name = "3D View Redo";
|
|
||||||
redoButton.Margin = defaultMargin;
|
|
||||||
redoButton.MinimumSize = new Vector2(height, height);
|
|
||||||
redoButton.ToolTipText = "Redo";
|
|
||||||
redoButton.Enabled = false;
|
|
||||||
redoButton.VAnchor = VAnchor.Center;
|
|
||||||
redoButton.Click += (sender, e) =>
|
|
||||||
{
|
|
||||||
undoBuffer.Redo();
|
|
||||||
};
|
|
||||||
this.AddChild(redoButton);
|
|
||||||
|
|
||||||
undoBuffer.Changed += (sender, e) =>
|
|
||||||
{
|
|
||||||
undoButton.Enabled = undoBuffer.UndoCount > 0;
|
|
||||||
redoButton.Enabled = undoBuffer.RedoCount > 0;
|
|
||||||
};
|
|
||||||
|
|
||||||
overflowDropdown = new OverflowDropdown(allowLightnessInvert: true)
|
overflowDropdown = new OverflowDropdown(allowLightnessInvert: true)
|
||||||
{
|
{
|
||||||
AlignToRightEdge = true,
|
AlignToRightEdge = true,
|
||||||
|
|
|
||||||
|
|
@ -36,6 +36,8 @@ using MatterHackers.Agg.ImageProcessing;
|
||||||
using MatterHackers.Agg.PlatformAbstract;
|
using MatterHackers.Agg.PlatformAbstract;
|
||||||
using MatterHackers.Agg.UI;
|
using MatterHackers.Agg.UI;
|
||||||
using MatterHackers.Localizations;
|
using MatterHackers.Localizations;
|
||||||
|
using MatterHackers.MatterControl.CustomWidgets;
|
||||||
|
using MatterHackers.VectorMath;
|
||||||
|
|
||||||
namespace MatterHackers.MatterControl.PartPreviewWindow
|
namespace MatterHackers.MatterControl.PartPreviewWindow
|
||||||
{
|
{
|
||||||
|
|
@ -132,7 +134,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public ViewControls3D(ThemeConfig theme)
|
public ViewControls3D(ThemeConfig theme, UndoBuffer undoBuffer)
|
||||||
{
|
{
|
||||||
this.BackgroundColor = new RGBA_Bytes(0, 0, 0, overlayAlpha);
|
this.BackgroundColor = new RGBA_Bytes(0, 0, 0, overlayAlpha);
|
||||||
this.HAnchor |= HAnchor.Left;
|
this.HAnchor |= HAnchor.Left;
|
||||||
|
|
@ -140,10 +142,48 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
|
||||||
|
|
||||||
string iconPath;
|
string iconPath;
|
||||||
|
|
||||||
var commonMargin = ApplicationController.Instance.Theme.ButtonSpacing;
|
var commonMargin = theme.ButtonSpacing;
|
||||||
|
|
||||||
var buttonFactory = theme.RadioButtons;
|
var buttonFactory = theme.RadioButtons;
|
||||||
|
|
||||||
|
double height = theme.ButtonFactory.FixedHeight;
|
||||||
|
|
||||||
|
Button undoButton = buttonFactory.GenerateIconButton(StaticData.Instance.LoadIcon("Undo_grey_16x.png", 16, 16), forceWhite: true);
|
||||||
|
undoButton.Name = "3D View Undo";
|
||||||
|
undoButton.ToolTipText = "Undo";
|
||||||
|
undoButton.Enabled = false;
|
||||||
|
undoButton.MinimumSize = new Vector2(height, height);
|
||||||
|
undoButton.Margin = commonMargin;
|
||||||
|
undoButton.Click += (sender, e) =>
|
||||||
|
{
|
||||||
|
undoBuffer.Undo();
|
||||||
|
};
|
||||||
|
this.AddChild(undoButton);
|
||||||
|
undoButton.VAnchor = VAnchor.Center;
|
||||||
|
|
||||||
|
Button redoButton = buttonFactory.GenerateIconButton(StaticData.Instance.LoadIcon("Redo_grey_16x.png", 16, 16), forceWhite: true);
|
||||||
|
redoButton.Name = "3D View Redo";
|
||||||
|
redoButton.Margin = commonMargin;
|
||||||
|
redoButton.MinimumSize = new Vector2(height, height);
|
||||||
|
redoButton.ToolTipText = "Redo";
|
||||||
|
redoButton.Enabled = false;
|
||||||
|
redoButton.VAnchor = VAnchor.Center;
|
||||||
|
redoButton.Click += (sender, e) =>
|
||||||
|
{
|
||||||
|
undoBuffer.Redo();
|
||||||
|
};
|
||||||
|
this.AddChild(redoButton);
|
||||||
|
|
||||||
|
this.AddChild(new VerticalLine(50)
|
||||||
|
{
|
||||||
|
Margin = 4
|
||||||
|
});
|
||||||
|
|
||||||
|
undoBuffer.Changed += (sender, e) =>
|
||||||
|
{
|
||||||
|
undoButton.Enabled = undoBuffer.UndoCount > 0;
|
||||||
|
redoButton.Enabled = undoBuffer.RedoCount > 0;
|
||||||
|
};
|
||||||
iconPath = Path.Combine("ViewTransformControls", "reset.png");
|
iconPath = Path.Combine("ViewTransformControls", "reset.png");
|
||||||
resetViewButton = theme.NoMarginWhite.Generate("", StaticData.Instance.LoadIcon(iconPath,32,32).InvertLightness());
|
resetViewButton = theme.NoMarginWhite.Generate("", StaticData.Instance.LoadIcon(iconPath,32,32).InvertLightness());
|
||||||
resetViewButton.ToolTipText = "Reset View".Localize();
|
resetViewButton.ToolTipText = "Reset View".Localize();
|
||||||
|
|
|
||||||
|
|
@ -113,7 +113,7 @@ namespace MatterHackers.PolygonMesh.UnitTests
|
||||||
MeshVisualizer.BedShape.Rectangular,
|
MeshVisualizer.BedShape.Rectangular,
|
||||||
View3DWidget.WindowMode.Embeded,
|
View3DWidget.WindowMode.Embeded,
|
||||||
View3DWidget.AutoRotate.Disabled,
|
View3DWidget.AutoRotate.Disabled,
|
||||||
new ViewControls3D(ApplicationController.Instance.Theme),
|
new ViewControls3D(ApplicationController.Instance.Theme, new Agg.UI.UndoBuffer()),
|
||||||
new MatterControl.ThemeConfig(),
|
new MatterControl.ThemeConfig(),
|
||||||
View3DWidget.OpenMode.Editing);
|
View3DWidget.OpenMode.Editing);
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue