Move view controls into new View3DWidget toolbar

This commit is contained in:
John Lewin 2018-09-10 12:02:20 -07:00
parent 449bd56aa9
commit c8bc2fe40d
6 changed files with 51 additions and 47 deletions

View file

@ -2250,29 +2250,25 @@ namespace MatterHackers.MatterControl
return (slicingSucceeded, gcodeFilePath);
}
internal GuiWidget GetViewOptionButtons(BedConfig sceneContext, PrinterConfig printer, ThemeConfig theme)
internal void GetViewOptionButtons(GuiWidget parent, BedConfig sceneContext, PrinterConfig printer, ThemeConfig theme)
{
var container = new FlowLayoutWidget()
{
VAnchor = VAnchor.Fit | VAnchor.Center
};
var bedButton = new RadioIconButton(AggContext.StaticData.LoadIcon("bed.png", theme.InvertIcons), theme)
{
Name = "Bed Button",
ToolTipText = "Show Print Bed".Localize(),
Checked = sceneContext.RendererOptions.RenderBed,
Margin = theme.ButtonSpacing,
VAnchor = VAnchor.Absolute,
ToggleButton = true,
Height = 24,
Width = 24,
Height = theme.ButtonHeight,
Width = theme.ButtonHeight,
SiblingRadioButtonList = new List<GuiWidget>()
};
bedButton.CheckedStateChanged += (s, e) =>
{
sceneContext.RendererOptions.RenderBed = bedButton.Checked;
};
container.AddChild(bedButton);
parent.AddChild(bedButton);
Func<bool> buildHeightValid = () => sceneContext.BuildHeight > 0;
@ -2282,19 +2278,20 @@ namespace MatterHackers.MatterControl
ToolTipText = (buildHeightValid()) ? "Show Print Area".Localize() : "Define printer build height to enable",
Checked = sceneContext.RendererOptions.RenderBuildVolume,
Margin = theme.ButtonSpacing,
VAnchor = VAnchor.Absolute,
ToggleButton = true,
Enabled = buildHeightValid() && printer?.ViewState.ViewMode != PartViewMode.Layers2D,
Height = 24,
Width = 24,
Height = theme.ButtonHeight,
Width = theme.ButtonHeight,
SiblingRadioButtonList = new List<GuiWidget>()
};
printAreaButton.CheckedStateChanged += (s, e) =>
{
sceneContext.RendererOptions.RenderBuildVolume = printAreaButton.Checked;
};
container.AddChild(printAreaButton);
parent.AddChild(printAreaButton);
this.BindBedOptions(container, bedButton, printAreaButton, sceneContext.RendererOptions);
this.BindBedOptions(parent, bedButton, printAreaButton, sceneContext.RendererOptions);
if (printer != null)
{
@ -2307,13 +2304,11 @@ namespace MatterHackers.MatterControl
printer.ViewState.ViewModeChanged += viewModeChanged;
container.Closed += (s, e) =>
parent.Closed += (s, e) =>
{
printer.ViewState.ViewModeChanged -= viewModeChanged;
};
}
return container;
}
public void BindBedOptions(GuiWidget container, ICheckbox bedButton, ICheckbox printAreaButton, View3DConfig renderOptions)

View file

@ -175,6 +175,7 @@ namespace MatterHackers.MatterControl.CustomWidgets
this.RemoveAllChildren();
SimpleTabs tabControl = null;
if (this.ControlIsPinned)
{
var resizePage = new LeftResizeContainer(theme)
@ -206,6 +207,10 @@ namespace MatterHackers.MatterControl.CustomWidgets
this.AddChild(resizePage);
}
else
{
this.BackgroundColor = theme.TabBarBackground;
}
foreach (var item in allTabs)
{

View file

@ -63,8 +63,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
sectionWidget = new SectionWidget(
"Options".Localize(),
new GCodeOptionsPanel(sceneContext, printer, theme),
theme,
ApplicationController.Instance.GetViewOptionButtons(sceneContext, printer, theme))
theme)
{
HAnchor = HAnchor.Stretch,
VAnchor = VAnchor.Fit,

View file

@ -160,8 +160,8 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
private bool mouseOver = false;
private List<TextureData> textureDatas = new List<TextureData>();
private WorldView world;
ThemeConfig theme;
List<ConnectedFaces> connections = new List<ConnectedFaces>();
private ThemeConfig theme;
private List<ConnectedFaces> connections = new List<ConnectedFaces>();
public TumbleCubeControl(InteractionLayer interactionLayer, ThemeConfig theme)
: base(100 * GuiWidget.DeviceScale, 100 * GuiWidget.DeviceScale)

View file

@ -33,6 +33,7 @@ using System.Linq;
using System.Text.RegularExpressions;
using MatterHackers.Agg;
using MatterHackers.Agg.Image;
using MatterHackers.Agg.Platform;
using MatterHackers.Agg.UI;
using MatterHackers.DataConverters3D;
using MatterHackers.Localizations;
@ -165,22 +166,6 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
modelViewSidePanel.Resized += ModelViewSidePanel_Resized;
var viewOptionButtons = ApplicationController.Instance.GetViewOptionButtons(sceneContext, printer, theme);
viewOptionButtons.AddChild(new ViewStyleButton(sceneContext, theme));
modelViewSidePanel.AddChild(
new SectionWidget(
"Options".Localize(),
new GuiWidget(),
theme,
viewOptionButtons,
expandingContent: false)
{
HAnchor = HAnchor.Stretch,
VAnchor = VAnchor.Fit,
BorderColor = Color.Transparent // Disable top border to produce a more flat, dark top edge
});
// add the tree view
treeView = new TreeView(theme)
{
@ -250,12 +235,35 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
historyAndProperties.Panel2.AddChild(selectedObjectPanel);
splitContainer.AddChild(modelViewSidePanel);
this.InteractionLayer.AddChild(new TumbleCubeControl(this.InteractionLayer, theme)
var tumbleCubeControl = new TumbleCubeControl(this.InteractionLayer, theme)
{
Margin = new BorderDouble(0, 0, 30, 30),
Margin = new BorderDouble(0, 0, 10, 10),
VAnchor = VAnchor.Top,
HAnchor = HAnchor.Right,
});
};
this.InteractionLayer.AddChild(tumbleCubeControl);
var viewOptionsBar = new FlowLayoutWidget(FlowDirection.TopToBottom)
{
HAnchor = HAnchor.Right | HAnchor.Fit,
VAnchor = VAnchor.Top | VAnchor.Fit,
Margin = new BorderDouble(top: tumbleCubeControl.Height + tumbleCubeControl.Margin.Height + 2)
};
this.InteractionLayer.AddChild(viewOptionsBar);
var homeButton = new IconButton(AggContext.StaticData.LoadIcon("fa-home_16.png", theme.InvertIcons), theme)
{
VAnchor = VAnchor.Absolute,
ToolTipText = "Reset View".Localize(),
Margin = theme.ButtonSpacing
};
homeButton.Click += (s, e) => viewControls3D.NotifyResetView();
viewOptionsBar.AddChild(homeButton);
viewOptionsBar.AddChild(new ViewStyleButton(sceneContext, theme));
ApplicationController.Instance.GetViewOptionButtons(viewOptionsBar, sceneContext, printer, theme);
UiThread.RunOnIdle(AutoSpin);

View file

@ -89,6 +89,11 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
public NamedAction[] MenuActions { get; private set; }
internal void NotifyResetView()
{
this.ResetView.Invoke(this, null);
}
public bool IsPrinterMode { get; }
public ViewControls3DButtons ActiveButton
@ -163,14 +168,6 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
this.AddChild(new ToolbarSeparator(theme));
var homeButton = new IconButton(AggContext.StaticData.LoadIcon("fa-home_16.png", theme.InvertIcons), theme)
{
ToolTipText = "Reset View".Localize(),
Margin = theme.ButtonSpacing
};
homeButton.Click += (s, e) => ResetView?.Invoke(this, null);
AddChild(homeButton);
var undoButton = new IconButton(AggContext.StaticData.LoadIcon("Undo_grey_16x.png", 16, 16, theme.InvertIcons), theme)
{
Name = "3D View Undo",