From 39e8d673278ddeda4e1fdeca9cc6b3bf3ba7fa27 Mon Sep 17 00:00:00 2001 From: John Lewin Date: Mon, 12 Jun 2017 16:09:49 -0700 Subject: [PATCH 1/4] Settings sidebar defaults to collapsed, tune library sidebar width --- ApplicationView/WidescreenPanel.cs | 2 +- CustomWidgets/DockingTabControl.cs | 6 ++---- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/ApplicationView/WidescreenPanel.cs b/ApplicationView/WidescreenPanel.cs index 463694d94..e5760e1dd 100644 --- a/ApplicationView/WidescreenPanel.cs +++ b/ApplicationView/WidescreenPanel.cs @@ -63,7 +63,7 @@ namespace MatterHackers.MatterControl var library3DViewSplitter = new Splitter() { Padding = new BorderDouble(4), - SplitterDistance = 590, + SplitterDistance = 410, SplitterWidth = 10, SplitterBackground = ApplicationController.Instance.Theme.SplitterBackground }; diff --git a/CustomWidgets/DockingTabControl.cs b/CustomWidgets/DockingTabControl.cs index 2ac19af63..0bbb50d46 100644 --- a/CustomWidgets/DockingTabControl.cs +++ b/CustomWidgets/DockingTabControl.cs @@ -42,16 +42,14 @@ namespace MatterHackers.MatterControl.CustomWidgets { public class DockingTabControl : GuiWidget { - public bool ControlIsPinned { get; set; } = true; + // TODO: Pinned state should preferably come from MCWS, default to local data if guest and be per user not printer + public bool ControlIsPinned { get; set; } = false; private GuiWidget topToBottom; Dictionary allTabs = new Dictionary(); public DockingTabControl() { - // load up the state data for this control and printer - // ActiveSliceSettings.Instance.PrinterSelected - ControlIsPinned = true; } public void AddPage(string name, GuiWidget widget) From 63894551f94dea1756ee3671b9ea9259ac33932d Mon Sep 17 00:00:00 2001 From: John Lewin Date: Mon, 12 Jun 2017 16:55:07 -0700 Subject: [PATCH 2/4] Fix null reference on PopupContent object - Make base explicitly call to virtual function after content load - Remove debugging color, switch back to expected - White --- PartPreviewWindow/OverflowDropdown.cs | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/PartPreviewWindow/OverflowDropdown.cs b/PartPreviewWindow/OverflowDropdown.cs index ab57a9b1f..fe52fd6a8 100644 --- a/PartPreviewWindow/OverflowDropdown.cs +++ b/PartPreviewWindow/OverflowDropdown.cs @@ -91,14 +91,12 @@ namespace MatterHackers.MatterControl.PartPreviewWindow }; } - public override void ShowPopup() + protected override void BeforeShowPopup() { if (this.PopupContent.BackgroundColor == RGBA_Bytes.Transparent) { - this.PopupContent.BackgroundColor = RGBA_Bytes.Blue; + this.PopupContent.BackgroundColor = RGBA_Bytes.White; } - - base.ShowPopup(); } } @@ -149,7 +147,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow base.OnMouseUp(mouseEvent); } - public virtual void ShowPopup() + public void ShowPopup() { menuVisible = true; @@ -165,6 +163,8 @@ namespace MatterHackers.MatterControl.PartPreviewWindow return; } + this.BeforeShowPopup(); + popupWidget = new PopupWidget(this.PopupContent, this, Vector2.Zero, this.PopDirection, 0, this.AlignToRightEdge) { BorderWidth = 1, @@ -178,5 +178,9 @@ namespace MatterHackers.MatterControl.PartPreviewWindow }; popupWidget.Focus(); } + + protected virtual void BeforeShowPopup() + { + } } } \ No newline at end of file From 77878d780bb707c64c7cd1de5512b3f7276e865f Mon Sep 17 00:00:00 2001 From: John Lewin Date: Mon, 12 Jun 2017 20:32:52 -0700 Subject: [PATCH 3/4] Expose pinned tabs to automation - Expose pin button to automation - Expose unpinned tabs to automation - Use tabTitle variable instead of nameWidget.Key - Hold pin state outside of widgets - Add PinStatusChanged to allow for external storing of pin state --- CustomWidgets/DockingTabControl.cs | 37 ++++++++++++++++++------- PartPreviewWindow/PartPreviewContent.cs | 9 +++++- 2 files changed, 35 insertions(+), 11 deletions(-) diff --git a/CustomWidgets/DockingTabControl.cs b/CustomWidgets/DockingTabControl.cs index 0bbb50d46..f33e33858 100644 --- a/CustomWidgets/DockingTabControl.cs +++ b/CustomWidgets/DockingTabControl.cs @@ -27,6 +27,7 @@ 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.Font; @@ -42,8 +43,19 @@ namespace MatterHackers.MatterControl.CustomWidgets { public class DockingTabControl : GuiWidget { + public event EventHandler PinStatusChanged; + // TODO: Pinned state should preferably come from MCWS, default to local data if guest and be per user not printer - public bool ControlIsPinned { get; set; } = false; + private bool isPinned; + public bool ControlIsPinned + { + get => isPinned; + set { + isPinned = value; + PinStatusChanged?.Invoke(this, null); + } + } + private GuiWidget topToBottom; Dictionary allTabs = new Dictionary(); @@ -87,15 +99,17 @@ namespace MatterHackers.MatterControl.CustomWidgets foreach (var nameWidget in allTabs) { + string tabTitle = nameWidget.Key; + if (ControlIsPinned) { - var content = new DockWindowContent(this, nameWidget.Value, nameWidget.Key, ControlIsPinned); + var content = new DockWindowContent(this, nameWidget.Value, tabTitle, ControlIsPinned); - var tabPage = new TabPage(content, nameWidget.Key); + var tabPage = new TabPage(content, tabTitle); tabControl.AddTab(new SimpleTextTabWidget( tabPage, - nameWidget.Key + " Tab", + tabTitle + " Tab", 12, ActiveTheme.Instance.TabLabelSelected, RGBA_Bytes.Transparent, @@ -105,7 +119,7 @@ namespace MatterHackers.MatterControl.CustomWidgets else // control is floating { var rotatedLabel = new VertexSourceApplyTransform( - new TypeFacePrinter(nameWidget.Key, 12), + new TypeFacePrinter(tabTitle, 12), Affine.NewRotation(MathHelper.DegreesToRadians(-90))); var bounds = rotatedLabel.Bounds(); @@ -123,8 +137,9 @@ namespace MatterHackers.MatterControl.CustomWidgets var settingsButton = new PopupButton(optionsText) { AlignToRightEdge = true, + Name = $"{tabTitle} Sidebar" }; - settingsButton.PopupContent = new DockWindowContent(this, nameWidget.Value, nameWidget.Key, ControlIsPinned) + settingsButton.PopupContent = new DockWindowContent(this, nameWidget.Value, tabTitle, ControlIsPinned) { BackgroundColor = ActiveTheme.Instance.PrimaryBackgroundColor }; @@ -142,7 +157,6 @@ namespace MatterHackers.MatterControl.CustomWidgets VAnchor = VAnchor.ParentCenter }; imageWidget.Margin = new BorderDouble(right: 25, top: 6); - imageWidget.DebugShowBounds = true; imageWidget.MinimumSize = new Vector2(16, 16); imageWidget.Click += (s, e) => { @@ -246,9 +260,12 @@ namespace MatterHackers.MatterControl.CustomWidgets titleBar.AddChild(new HorizontalSpacer() { Height = 5, DebugShowBounds = false }); var icon = StaticData.Instance.LoadIcon((isDocked) ? "Pushpin_16x.png" : "PushpinUnpin_16x.png", 16, 16).InvertLightness(); - var imageWidget = new ImageWidget(icon); - imageWidget.Margin = new BorderDouble(right: 25, top: 6); - imageWidget.MinimumSize = new Vector2(16, 16); + var imageWidget = new ImageWidget(icon) + { + Name = "Pin Settings Button", + Margin = new BorderDouble(right: 25, top: 6), + MinimumSize = new Vector2(16, 16) + }; imageWidget.Click += (s, e) => { parent.ControlIsPinned = !parent.ControlIsPinned; diff --git a/PartPreviewWindow/PartPreviewContent.cs b/PartPreviewWindow/PartPreviewContent.cs index 746a84ac5..9359e6e4a 100644 --- a/PartPreviewWindow/PartPreviewContent.cs +++ b/PartPreviewWindow/PartPreviewContent.cs @@ -208,7 +208,14 @@ namespace MatterHackers.MatterControl.PartPreviewWindow private void AddSettingsTabBar(GuiWidget parent) { - var sideBar = new DockingTabControl(); + var sideBar = new DockingTabControl() + { + ControlIsPinned = ApplicationController.Instance.PrintSettingsPinned + }; + sideBar.PinStatusChanged += (s, e) => + { + ApplicationController.Instance.PrintSettingsPinned = sideBar.ControlIsPinned; + }; parent.AddChild(sideBar); if (ActiveSliceSettings.Instance.PrinterSelected) From 604d131a1b9986ea5eaa63cacf20c681a89661ac Mon Sep 17 00:00:00 2001 From: John Lewin Date: Mon, 12 Jun 2017 20:35:48 -0700 Subject: [PATCH 4/4] Make helper method pin SliceSettings tab as needed - Use "Slice Settings" tab name expected by tests --- ApplicationView/ApplicationController.cs | 2 ++ PartPreviewWindow/PartPreviewContent.cs | 5 +++-- Tests/MatterControl.AutomationTests/PrintingTests.cs | 4 +--- .../MatterControl/MatterControlUtilities.cs | 8 +++++++- 4 files changed, 13 insertions(+), 6 deletions(-) diff --git a/ApplicationView/ApplicationController.cs b/ApplicationView/ApplicationController.cs index 251bd5453..0e78ec419 100644 --- a/ApplicationView/ApplicationController.cs +++ b/ApplicationView/ApplicationController.cs @@ -771,6 +771,8 @@ namespace MatterHackers.MatterControl public View3DWidget ActiveView3DWidget { get; internal set; } public int ActiveAdvancedControlsTab { get; internal set; } + public bool PrintSettingsPinned { get; internal set; } + public string CachePath(ILibraryItem libraryItem) { // TODO: Use content SHA diff --git a/PartPreviewWindow/PartPreviewContent.cs b/PartPreviewWindow/PartPreviewContent.cs index 9359e6e4a..106168092 100644 --- a/PartPreviewWindow/PartPreviewContent.cs +++ b/PartPreviewWindow/PartPreviewContent.cs @@ -220,12 +220,13 @@ namespace MatterHackers.MatterControl.PartPreviewWindow if (ActiveSliceSettings.Instance.PrinterSelected) { - sideBar.AddPage("Settings", new SliceSettingsWidget()); + sideBar.AddPage("Slice Settings".Localize(), new SliceSettingsWidget()); } else { - sideBar.AddPage("Settings".Localize(), new SliceSettingsWidget()); + sideBar.AddPage("Slice Settings".Localize(), new NoSettingsWidget()); } + sideBar.AddPage("Controls".Localize(), new ManualPrinterControls()); var terminalControls = new TerminalControls(); diff --git a/Tests/MatterControl.AutomationTests/PrintingTests.cs b/Tests/MatterControl.AutomationTests/PrintingTests.cs index 224f5eb3e..87a6eb81d 100644 --- a/Tests/MatterControl.AutomationTests/PrintingTests.cs +++ b/Tests/MatterControl.AutomationTests/PrintingTests.cs @@ -355,8 +355,6 @@ namespace MatterHackers.MatterControl.Tests.Automation await MatterControlUtilities.RunTest((testRunner) => { - SystemWindow systemWindow; - testRunner.WaitForName("Cancel Wizard Button", 1); // Set custom adjustment values @@ -377,7 +375,7 @@ namespace MatterHackers.MatterControl.Tests.Automation testRunner.ClickByName("Start Print Button", 1); - var container = testRunner.GetWidgetByName("ManualPrinterControls.ControlsContainer", out systemWindow, 5); + var container = testRunner.GetWidgetByName("ManualPrinterControls.ControlsContainer", out _, 5); // Scroll the widget into view var scrollable = container.Parents().First().Children().First(); diff --git a/Tests/MatterControl.Tests/MatterControl/MatterControlUtilities.cs b/Tests/MatterControl.Tests/MatterControl/MatterControlUtilities.cs index ff9669690..4aa1b5fd6 100644 --- a/Tests/MatterControl.Tests/MatterControl/MatterControlUtilities.cs +++ b/Tests/MatterControl.Tests/MatterControl/MatterControlUtilities.cs @@ -548,8 +548,14 @@ namespace MatterHackers.MatterControl.Tests.Automation public static void SwitchToAdvancedSliceSettings(this AutomationRunner testRunner) { + testRunner.ClickByName("Slice Settings Sidebar"); + + testRunner.ClickByName("Pin Settings Button"); + + testRunner.Delay(1); + // Switch to Slice Settings Tab - testRunner.ClickByName("Slice Settings Tab"); + //testRunner.ClickByName("Slice Settings Tab"); // Show the overflow menu testRunner.ClickByName("Slice Settings Overflow Menu");