From c8bc2fe40dd669857cb0f0a5d9f1e78270815afe Mon Sep 17 00:00:00 2001 From: John Lewin Date: Mon, 10 Sep 2018 12:02:20 -0700 Subject: [PATCH] Move view controls into new View3DWidget toolbar --- .../ApplicationView/ApplicationController.cs | 27 +++++------ .../CustomWidgets/DockingTabControl.cs | 5 ++ .../PartPreviewWindow/GCode3DWidget.cs | 3 +- .../View3D/TumbleCubeControl.cs | 4 +- .../PartPreviewWindow/View3D/View3DWidget.cs | 46 +++++++++++-------- .../PartPreviewWindow/ViewControls3D.cs | 13 ++---- 6 files changed, 51 insertions(+), 47 deletions(-) diff --git a/MatterControlLib/ApplicationView/ApplicationController.cs b/MatterControlLib/ApplicationView/ApplicationController.cs index f49879a79..a5047ea1d 100644 --- a/MatterControlLib/ApplicationView/ApplicationController.cs +++ b/MatterControlLib/ApplicationView/ApplicationController.cs @@ -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() }; bedButton.CheckedStateChanged += (s, e) => { sceneContext.RendererOptions.RenderBed = bedButton.Checked; }; - container.AddChild(bedButton); + parent.AddChild(bedButton); Func 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() }; 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) diff --git a/MatterControlLib/CustomWidgets/DockingTabControl.cs b/MatterControlLib/CustomWidgets/DockingTabControl.cs index 775c62df4..7cdf62dd4 100644 --- a/MatterControlLib/CustomWidgets/DockingTabControl.cs +++ b/MatterControlLib/CustomWidgets/DockingTabControl.cs @@ -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) { diff --git a/MatterControlLib/PartPreviewWindow/GCode3DWidget.cs b/MatterControlLib/PartPreviewWindow/GCode3DWidget.cs index 70a3cf3e3..68f078036 100644 --- a/MatterControlLib/PartPreviewWindow/GCode3DWidget.cs +++ b/MatterControlLib/PartPreviewWindow/GCode3DWidget.cs @@ -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, diff --git a/MatterControlLib/PartPreviewWindow/View3D/TumbleCubeControl.cs b/MatterControlLib/PartPreviewWindow/View3D/TumbleCubeControl.cs index 9bd2c697c..43a587829 100644 --- a/MatterControlLib/PartPreviewWindow/View3D/TumbleCubeControl.cs +++ b/MatterControlLib/PartPreviewWindow/View3D/TumbleCubeControl.cs @@ -160,8 +160,8 @@ namespace MatterHackers.MatterControl.PartPreviewWindow private bool mouseOver = false; private List textureDatas = new List(); private WorldView world; - ThemeConfig theme; - List connections = new List(); + private ThemeConfig theme; + private List connections = new List(); public TumbleCubeControl(InteractionLayer interactionLayer, ThemeConfig theme) : base(100 * GuiWidget.DeviceScale, 100 * GuiWidget.DeviceScale) diff --git a/MatterControlLib/PartPreviewWindow/View3D/View3DWidget.cs b/MatterControlLib/PartPreviewWindow/View3D/View3DWidget.cs index 936494a4c..0d2c5c8f6 100644 --- a/MatterControlLib/PartPreviewWindow/View3D/View3DWidget.cs +++ b/MatterControlLib/PartPreviewWindow/View3D/View3DWidget.cs @@ -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); diff --git a/MatterControlLib/PartPreviewWindow/ViewControls3D.cs b/MatterControlLib/PartPreviewWindow/ViewControls3D.cs index bb15e5bc4..7fe745561 100644 --- a/MatterControlLib/PartPreviewWindow/ViewControls3D.cs +++ b/MatterControlLib/PartPreviewWindow/ViewControls3D.cs @@ -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",