From 459dd3d3048fb459c79a7af93f8e7d1327f4243e Mon Sep 17 00:00:00 2001 From: John Lewin Date: Tue, 23 May 2017 21:27:28 -0700 Subject: [PATCH 1/3] Sync tab styling - Fix temperature widget flow orientation for toolbar - Create reusable constructor function for tabcontrols - Conditional printer tab title of "Printer" or [PrinterName] --- ActionBar/PrintStatusRow.cs | 2 +- ApplicationView/AdvancedControlsPanel.cs | 49 +++++++------- ApplicationView/ApplicationController.cs | 11 ++++ PartPreviewWindow/PartPreviewContent.cs | 81 +++++++++++++++--------- 4 files changed, 85 insertions(+), 58 deletions(-) diff --git a/ActionBar/PrintStatusRow.cs b/ActionBar/PrintStatusRow.cs index 7fffbc808..faba5e784 100644 --- a/ActionBar/PrintStatusRow.cs +++ b/ActionBar/PrintStatusRow.cs @@ -84,7 +84,7 @@ namespace MatterHackers.MatterControl.ActionBar private void AddChildElements() { - FlowLayoutWidget temperatureWidgets = new FlowLayoutWidget(FlowDirection.TopToBottom); + var temperatureWidgets = new FlowLayoutWidget(); { extruderTemperatureWidget = new TemperatureWidgetExtruder(); temperatureWidgets.AddChild(extruderTemperatureWidget); diff --git a/ApplicationView/AdvancedControlsPanel.cs b/ApplicationView/AdvancedControlsPanel.cs index e74a933cd..15229e322 100644 --- a/ApplicationView/AdvancedControlsPanel.cs +++ b/ApplicationView/AdvancedControlsPanel.cs @@ -47,12 +47,14 @@ namespace MatterHackers.MatterControl private GuiWidget sliceSettingsWidget; - private TabControl advancedTab; + private TabControl tabControl; public AdvancedControlsPanel() { - advancedTab = CreateAdvancedControlsTab(); - AddChild(advancedTab); + BackgroundColor = ActiveTheme.Instance.PrimaryBackgroundColor; + + tabControl = CreateTabControl(); + AddChild(tabControl); AnchorAll(); ApplicationController.Instance.AdvancedControlsPanelReloading.RegisterEvent((s, e) => UiThread.RunOnIdle(ReloadSliceSettings), ref unregisterEvents); @@ -65,19 +67,19 @@ namespace MatterHackers.MatterControl public void ReloadSliceSettings() { WidescreenPanel.PreChangePanels.CallEvents(null, null); - if (advancedTab.HasBeenClosed) + if (tabControl.HasBeenClosed) { return; } PopOutManager.SaveIfClosed = false; // remove the advance control and replace it with new ones built for the selected printer - int advancedControlsIndex = GetChildIndex(advancedTab); + int advancedControlsIndex = GetChildIndex(tabControl); RemoveChild(advancedControlsIndex); - advancedTab.Close(); + tabControl.Close(); - advancedTab = CreateAdvancedControlsTab(); - AddChild(advancedTab, advancedControlsIndex); + tabControl = CreateTabControl(); + AddChild(tabControl, advancedControlsIndex); PopOutManager.SaveIfClosed = true; } @@ -87,24 +89,17 @@ namespace MatterHackers.MatterControl base.OnClosed(e); } - private TabControl CreateAdvancedControlsTab() + private TabControl CreateTabControl() { - BackgroundColor = ActiveTheme.Instance.PrimaryBackgroundColor; - - var advancedControls = new TabControl(separator: new HorizontalLine(alpha: 50)); - advancedControls.TabBar.BorderColor = RGBA_Bytes.Transparent; // ActiveTheme.Instance.SecondaryTextColor; - advancedControls.TabBar.Margin = 0; - advancedControls.TabBar.Padding = 0; - - int textSize = 14; + var newTabControl = ApplicationController.Instance.Theme.CreateTabControl(); RGBA_Bytes unselectedTextColor = ActiveTheme.Instance.TabLabelUnselected; var libraryTabPage = new TabPage(new PrintLibraryWidget(), "Library".Localize().ToUpper()); - advancedControls.AddTab(new SimpleTextTabWidget( + newTabControl.AddTab(new SimpleTextTabWidget( libraryTabPage, "Library Tab", - textSize, + newTabControl.TextPointSize, ActiveTheme.Instance.TabLabelSelected, new RGBA_Bytes(), unselectedTextColor, @@ -123,16 +118,16 @@ namespace MatterHackers.MatterControl new TabPage(sliceSettingsWidget, "Settings".Localize().ToUpper()), SliceSettingsTabName, new Vector2(590, 400), - textSize); + newTabControl.TextPointSize); var controlsPopOut = new PopOutTextTabWidget( new TabPage(new ManualPrinterControls(), "Controls".Localize().ToUpper()), ControlsTabName, new Vector2(400, 300), - textSize); + newTabControl.TextPointSize); - advancedControls.AddTab(sliceSettingPopOut); - advancedControls.AddTab(controlsPopOut); + newTabControl.AddTab(sliceSettingPopOut); + newTabControl.AddTab(controlsPopOut); #if !__ANDROID__ if (!UserSettings.Instance.IsTouchScreen) @@ -142,17 +137,17 @@ namespace MatterHackers.MatterControl } #endif - advancedControls.AddTab( + newTabControl.AddTab( new SimpleTextTabWidget( new TabPage(new PrinterConfigurationScrollWidget(), "Options".Localize().ToUpper()), "Options Tab", - textSize, + newTabControl.TextPointSize, ActiveTheme.Instance.PrimaryTextColor, new RGBA_Bytes(), unselectedTextColor, new RGBA_Bytes())); // MatterControl historically started with the queue selected, force to 0 to remain consistent - advancedControls.SelectedTabIndex = 0; + newTabControl.SelectedTabIndex = 0; - return advancedControls; + return newTabControl; } } } \ No newline at end of file diff --git a/ApplicationView/ApplicationController.cs b/ApplicationView/ApplicationController.cs index 830d0a0a4..e4b25a80b 100644 --- a/ApplicationView/ApplicationController.cs +++ b/ApplicationView/ApplicationController.cs @@ -127,6 +127,17 @@ namespace MatterHackers.MatterControl borderWidth = 1 }; } + + internal TabControl CreateTabControl() + { + var advancedControls = new TabControl(separator: new HorizontalLine(alpha: 50)); + advancedControls.TabBar.BorderColor = RGBA_Bytes.Transparent; // ActiveTheme.Instance.SecondaryTextColor; + advancedControls.TabBar.Margin = 0; + advancedControls.TabBar.Padding = 0; + advancedControls.TextPointSize = 14; + + return advancedControls; + } } public ThemeConfig Theme { get; set; } = new ThemeConfig(); diff --git a/PartPreviewWindow/PartPreviewContent.cs b/PartPreviewWindow/PartPreviewContent.cs index ffc411ba1..204118413 100644 --- a/PartPreviewWindow/PartPreviewContent.cs +++ b/PartPreviewWindow/PartPreviewContent.cs @@ -98,10 +98,8 @@ namespace MatterHackers.MatterControl.PartPreviewWindow private void LoadPrintItem(PrintItemWrapper printItem) { - tabControl = new TabControl(); - tabControl.TabBar.BorderColor = RGBA_Bytes.Transparent; - - tabControl.TabBar.Padding = new BorderDouble(top: 6); + var activeSettings = ActiveSliceSettings.Instance; + tabControl = ApplicationController.Instance.Theme.CreateTabControl(); RGBA_Bytes selectedTabColor; if (!UserSettings.Instance.IsTouchScreen) @@ -115,18 +113,20 @@ namespace MatterHackers.MatterControl.PartPreviewWindow selectedTabColor = ActiveTheme.Instance.SecondaryAccentColor; } - double buildHeight = ActiveSliceSettings.Instance.GetValue(SettingsKey.build_height); + double buildHeight = activeSettings.GetValue(SettingsKey.build_height); // put in the 3D view partPreviewView = new View3DWidget(printItem, - new Vector3(ActiveSliceSettings.Instance.GetValue(SettingsKey.bed_size), buildHeight), - ActiveSliceSettings.Instance.GetValue(SettingsKey.print_center), - ActiveSliceSettings.Instance.GetValue(SettingsKey.bed_shape), + new Vector3(activeSettings.GetValue(SettingsKey.bed_size), buildHeight), + activeSettings.GetValue(SettingsKey.print_center), + activeSettings.GetValue(SettingsKey.bed_shape), windowMode, autoRotate3DView, openMode); - TabPage partPreview3DView = new TabPage(partPreviewView, string.Format("3D {0} ", "View".Localize()).ToUpper()); + string tabTitle = !activeSettings.PrinterSelected ? "Printer".Localize() : activeSettings.GetValue(SettingsKey.printer_name); + + TabPage partPreview3DView = new TabPage(partPreviewView, tabTitle.ToUpper()); // put in the gcode view ViewGcodeBasic.WindowMode gcodeWindowMode = ViewGcodeBasic.WindowMode.Embeded; @@ -136,9 +136,9 @@ namespace MatterHackers.MatterControl.PartPreviewWindow } viewGcodeBasic = new ViewGcodeBasic( - new Vector3(ActiveSliceSettings.Instance.GetValue(SettingsKey.bed_size), buildHeight), - ActiveSliceSettings.Instance.GetValue(SettingsKey.print_center), - ActiveSliceSettings.Instance.GetValue(SettingsKey.bed_shape), gcodeWindowMode); + new Vector3(activeSettings.GetValue(SettingsKey.bed_size), buildHeight), + activeSettings.GetValue(SettingsKey.print_center), + activeSettings.GetValue(SettingsKey.bed_shape), gcodeWindowMode); if (windowMode == View3DWidget.WindowMode.StandAlone) { @@ -146,32 +146,53 @@ namespace MatterHackers.MatterControl.PartPreviewWindow viewGcodeBasic.Closed += (s, e) => Close(); } - TabPage layerView = new TabPage(viewGcodeBasic, "Layer View".Localize().ToUpper()); + Tab printerTab; + var layerView = new TabPage(viewGcodeBasic, "Layer View".Localize().ToUpper()); - int tabPointSize = 16; - // add the correct tabs based on whether we are stand alone or embedded - Tab threeDViewTab; - if (windowMode == View3DWidget.WindowMode.StandAlone || UserSettings.Instance.IsTouchScreen) + // add the correct tabs based on whether we are stand alone or embedded + if (windowMode == View3DWidget.WindowMode.StandAlone || UserSettings.Instance.IsTouchScreen) { - threeDViewTab = new SimpleTextTabWidget(partPreview3DView, "3D View Tab", tabPointSize, - selectedTabColor, new RGBA_Bytes(), ActiveTheme.Instance.TabLabelUnselected, new RGBA_Bytes()); - tabControl.AddTab(threeDViewTab); - layerViewTab = new SimpleTextTabWidget(layerView, "Layer View Tab", tabPointSize, - selectedTabColor, new RGBA_Bytes(), ActiveTheme.Instance.TabLabelUnselected, new RGBA_Bytes()); - tabControl.AddTab(layerViewTab); + printerTab = new SimpleTextTabWidget( + partPreview3DView, + "3D View Tab", + tabControl.TextPointSize, + selectedTabColor, + new RGBA_Bytes(), + ActiveTheme.Instance.TabLabelUnselected, + new RGBA_Bytes()); + + + layerViewTab = new SimpleTextTabWidget( + layerView, + "Layer View Tab", + tabControl.TextPointSize, + selectedTabColor, + new RGBA_Bytes(), + ActiveTheme.Instance.TabLabelUnselected, + new RGBA_Bytes()); } else { - threeDViewTab = new PopOutTextTabWidget(partPreview3DView, "3D View Tab", new Vector2(590, 400), tabPointSize); - tabControl.AddTab(threeDViewTab); - layerViewTab = new PopOutTextTabWidget(layerView, "Layer View Tab", new Vector2(590, 400), tabPointSize); - tabControl.AddTab(layerViewTab); + printerTab = new PopOutTextTabWidget( + partPreview3DView, + "3D View Tab", + new Vector2(590, 400), + tabControl.TextPointSize); + + layerViewTab = new PopOutTextTabWidget( + layerView, + "Layer View Tab", + new Vector2(590, 400), + tabControl.TextPointSize); } - threeDViewTab.ToolTipText = "Preview 3D Design".Localize(); - layerViewTab.ToolTipText = "Preview layer Tool Paths".Localize(); + printerTab.ToolTipText = "Preview 3D Design".Localize(); + layerViewTab.ToolTipText = "Preview layer Tool Paths".Localize(); - this.AddChild(tabControl); + tabControl.AddTab(printerTab); + tabControl.AddTab(layerViewTab); + + this.AddChild(tabControl); } public override void OnLoad(EventArgs args) From de20dea82d62d190f5e83d84d320ea75031993f8 Mon Sep 17 00:00:00 2001 From: John Lewin Date: Tue, 23 May 2017 23:24:38 -0700 Subject: [PATCH 2/3] Latest agg-sharp --- Submodules/agg-sharp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Submodules/agg-sharp b/Submodules/agg-sharp index 13a3198ab..2f9dae6bf 160000 --- a/Submodules/agg-sharp +++ b/Submodules/agg-sharp @@ -1 +1 @@ -Subproject commit 13a3198ab50b5b316a03cddc7252703913b0f936 +Subproject commit 2f9dae6bfe229b4870b36b8d163374237cb99a64 From 45590732376660102653fe802af15cffc5e919ae Mon Sep 17 00:00:00 2001 From: John Lewin Date: Wed, 24 May 2017 14:19:02 -0700 Subject: [PATCH 3/3] Move more widgets to printer action bar - Extract elements in PrinterConnectAndSelectControl to components - Use new components in printer action bar - Extract more factories to shared components - Move shared color to ThemeConfig - Add support for widget generation during ShowPopup --- ActionBar/ActionBarPlus.cs | 2 +- ActionBar/PrinterConnectAndSelectControl.cs | 438 +++++++++++------- ApplicationView/ApplicationController.cs | 59 ++- ConfigurationPage/PrinterConfigurationPage.cs | 2 +- .../LibrarySelector/FolderBreadCrumbWidget.cs | 21 +- Library/Widgets/PrintLibraryWidget.cs | 2 +- PartPreviewWindow/OverflowDropdown.cs | 15 +- PartPreviewWindow/View3D/PrinterActionsBar.cs | 33 +- PartPreviewWindow/View3D/View3DWidget.cs | 16 +- PartPreviewWindow/ViewControls3D.cs | 12 +- PrinterControls/ManualPrinterControls.cs | 2 +- SlicerConfiguration/SliceSettingsWidget.cs | 2 +- 12 files changed, 383 insertions(+), 221 deletions(-) diff --git a/ActionBar/ActionBarPlus.cs b/ActionBar/ActionBarPlus.cs index 67e08b713..1b1d24a37 100644 --- a/ActionBar/ActionBarPlus.cs +++ b/ActionBar/ActionBarPlus.cs @@ -47,7 +47,7 @@ namespace MatterHackers.MatterControl } else { - this.AddChild(new PrinterConnectAndSelectControl()); + this.AddChild(new PrinterConnectButton(ApplicationController.Instance.Theme.BreadCrumbButtonFactory)); this.AddChild(new PrintStatusRow()); } diff --git a/ActionBar/PrinterConnectAndSelectControl.cs b/ActionBar/PrinterConnectAndSelectControl.cs index cbd489898..b2b4ce5d6 100644 --- a/ActionBar/PrinterConnectAndSelectControl.cs +++ b/ActionBar/PrinterConnectAndSelectControl.cs @@ -1,5 +1,5 @@ /* -Copyright (c) 2016, Lars Brubaker +Copyright (c) 2017, Lars Brubaker, John Lewin All rights reserved. Redistribution and use in source and binary forms, with or without @@ -30,37 +30,49 @@ either expressed or implied, of the FreeBSD Project. using System; using MatterHackers.Agg; using MatterHackers.Agg.Image; -using MatterHackers.Agg.ImageProcessing; using MatterHackers.Agg.PlatformAbstract; using MatterHackers.Agg.UI; -using MatterHackers.ImageProcessing; +using MatterHackers.Agg.VertexSource; using MatterHackers.Localizations; using MatterHackers.MatterControl.PrinterCommunication; using MatterHackers.MatterControl.SlicerConfiguration; -using MatterHackers.VectorMath; namespace MatterHackers.MatterControl.ActionBar { - public class PrinterConnectAndSelectControl : FlowLayoutWidget + public class PrinterSelectEditDropdown : FlowLayoutWidget { - private Button connectPrinterButton; - private Button editPrinterButton; - private string disconnectAndCancelTitle = "Disconnect and stop the current print?".Localize(); - private string disconnectAndCancelMessage = "WARNING: Disconnecting will stop the current print.\n\nAre you sure you want to disconnect?".Localize(); - private Button disconnectPrinterButton; private PrinterSelector printerSelector; - GuiWidget printerSelectorAndEditOverlay; - + private GuiWidget printerSelectorAndEditOverlay; + private Button editPrinterButton; private EventHandler unregisterEvents; - static EventHandler staticUnregisterEvents; - public PrinterConnectAndSelectControl() + public PrinterSelectEditDropdown() { - this.HAnchor = HAnchor.ParentLeftRight; + printerSelector = new PrinterSelector() + { + HAnchor = HAnchor.ParentLeftRight, + Cursor = Cursors.Hand, + Margin = new BorderDouble(0, 6, 0, 3) + }; + printerSelector.AddPrinter += (s, e) => WizardWindow.ShowPrinterSetup(true); + this.AddChild(printerSelector); - this.BackgroundColor = ActiveTheme.Instance.PrimaryBackgroundColor; + editPrinterButton = TextImageButtonFactory.GetThemedEditButton(); + editPrinterButton.Name = "Edit Printer Button"; + editPrinterButton.VAnchor = VAnchor.ParentCenter; + editPrinterButton.Click += UiNavigation.OpenEditPrinterWizard_Click; + this.AddChild(editPrinterButton); - AddChildElements(); + printerSelectorAndEditOverlay = new GuiWidget() + { + HAnchor = HAnchor.ParentLeftRight, + VAnchor = VAnchor.ParentBottomTop, + Selectable = false, + }; + this.AddChild(printerSelectorAndEditOverlay); + + PrinterConnectionAndCommunication.Instance.EnableChanged.RegisterEvent(SetVisibleStates, ref unregisterEvents); + PrinterConnectionAndCommunication.Instance.CommunicationStateChanged.RegisterEvent(SetVisibleStates, ref unregisterEvents); } public override void OnClosed(ClosedEventArgs e) @@ -69,188 +81,276 @@ namespace MatterHackers.MatterControl.ActionBar base.OnClosed(e); } - protected void AddChildElements() + private void SetVisibleStates(object sender, EventArgs e) { - var buttonFactory = ApplicationController.Instance.Theme.PrinterConnectButtonFactory; - // connect and disconnect buttons + UiThread.RunOnIdle(() => { - var normalImage = StaticData.Instance.LoadIcon("connect.png", 32, 32); + bool printerIsPrintingOrPaused = PrinterConnectionAndCommunication.Instance.PrinterIsPrinting + || PrinterConnectionAndCommunication.Instance.PrinterIsPaused; + editPrinterButton.Enabled = ActiveSliceSettings.Instance.PrinterSelected && !printerIsPrintingOrPaused; + printerSelector.Enabled = !printerIsPrintingOrPaused; + if (printerIsPrintingOrPaused) + { + printerSelectorAndEditOverlay.BackgroundColor = new RGBA_Bytes(ActiveTheme.Instance.PrimaryBackgroundColor, 150); + } + else + { + printerSelectorAndEditOverlay.BackgroundColor = new RGBA_Bytes(0, 0, 0, 0); + } + }); + } + } + + public class ResetButton : GuiWidget + { + private readonly string resetConnectionText = "Reset\nConnection".Localize().ToUpper(); + private EventHandler unregisterEvents; + + public ResetButton(TextImageButtonFactory buttonFactory) + { + this.HAnchor = HAnchor.ParentLeftRight | HAnchor.FitToChildren; + this.VAnchor = VAnchor.FitToChildren; + this.BackgroundColor = ActiveTheme.Instance.PrimaryBackgroundColor; + + Button resetConnectionButton = buttonFactory.Generate(resetConnectionText, "e_stop4.png"); + resetConnectionButton.Visible = ActiveSliceSettings.Instance.GetValue(SettingsKey.show_reset_connection); + resetConnectionButton.Click += (s, e) => + { + UiThread.RunOnIdle(PrinterConnectionAndCommunication.Instance.RebootBoard); + }; + this.AddChild(resetConnectionButton); + + ActiveSliceSettings.SettingChanged.RegisterEvent((s, e) => + { + var stringEvent = e as StringEventArgs; + if (stringEvent?.Data == SettingsKey.show_reset_connection) + { + resetConnectionButton.Visible = ActiveSliceSettings.Instance.GetValue(SettingsKey.show_reset_connection); + } + }, ref unregisterEvents); + } + } + + public class SimpleButton : FlowLayoutWidget + { + public ImageBuffer Image { get; set; } + public BorderDouble ImageMargin { get; set; } + public BorderDouble ImagePadding { get; set; } + public double FontSize { get; set; } = 12; + + public int BorderWidth { get; set; } + + public RGBA_Bytes BorderColor { get; set; } = RGBA_Bytes.Transparent; + + private int borderRadius = 0; + + public SimpleButton(string text, ImageBuffer image = null) + { + this.HAnchor = HAnchor.ParentLeft | HAnchor.FitToChildren; + this.VAnchor = VAnchor.ParentTop | VAnchor.FitToChildren; + + this.Text = text; + this.Image = image; + + this.AddChild(new GuiWidget() { BackgroundColor = RGBA_Bytes.Green, Height = 10, Width = 20 }); + + UiThread.RunOnIdle(() => + { + if (this.Image != null) + { + this.AddChild( + new ImageWidget(this.Image) + { + Margin = ImageMargin, + Padding = ImagePadding, + VAnchor = VAnchor.ParentBottomTop, + }); + } + + if (!string.IsNullOrEmpty(this.Text)) + { + this.AddChild(new TextWidget(this.Text, pointSize: this.FontSize)); + } + + this.AddChild(new GuiWidget() { BackgroundColor = RGBA_Bytes.Red, Height = 10, Width = 20 }); + }); + } + + public override void OnLayout(LayoutEventArgs layoutEventArgs) + { + base.OnLayout(layoutEventArgs); + } + + /* + public override void OnLoad(EventArgs args) + { + if (this.Image != null) + { + this.AddChild(new ImageWidget(this.Image) + { + Margin = ImageMargin + }); + } + + if (!string.IsNullOrEmpty(this.Text)) + { + this.AddChild(new TextWidget(this.Text, pointSize: this.FontSize)); + } + + base.OnLoad(args); + }*/ + + public override void OnDraw(Graphics2D graphics2D) + { + if (this.BorderColor.Alpha0To255 > 0) + { + RectangleDouble borderRectangle = LocalBounds; + + if (BorderWidth > 0) + { + if (BorderWidth == 1) + { + graphics2D.Rectangle(borderRectangle, this.BorderColor); + } + else + { + graphics2D.Render( + new Stroke( + new RoundedRect(borderRectangle, this.borderRadius), + BorderWidth), + this.BorderColor); + } + } + } + + base.OnDraw(graphics2D); + } + } + + public class PrinterConnectButton : GuiWidget + { + private readonly string disconnectAndCancelTitle = "Disconnect and stop the current print?".Localize(); + private readonly string disconnectAndCancelMessage = "WARNING: Disconnecting will stop the current print.\n\nAre you sure you want to disconnect?".Localize(); + + private GuiWidget connectButton; + private Button disconnectButton; + + private EventHandler unregisterEvents; + + public PrinterConnectButton(TextImageButtonFactory buttonFactory) + { + this.HAnchor = HAnchor.ParentLeft | HAnchor.FitToChildren; + this.VAnchor = VAnchor.FitToChildren; + this.BackgroundColor = ActiveTheme.Instance.PrimaryBackgroundColor; + + if (false) + { // Create the image button with the normal and disabled ImageBuffers - connectPrinterButton = buttonFactory.Generate("Connect".Localize().ToUpper(), normalImage); - connectPrinterButton.Name = "Connect to printer button"; - connectPrinterButton.ToolTipText = "Connect to the currently selected printer".Localize(); - connectPrinterButton.Margin = new BorderDouble(0, 0, 3, 3); - - connectPrinterButton.VAnchor = VAnchor.ParentTop; - connectPrinterButton.Cursor = Cursors.Hand; - connectPrinterButton.Click += (s, e) => + connectButton = new SimpleButton("Connect".Localize().ToUpper(), StaticData.Instance.LoadIcon("connect.png", 16, 16)) { - Button buttonClicked = ((Button)s); - if (buttonClicked.Enabled) - { - if (ActiveSliceSettings.Instance.PrinterSelected) - { - UserRequestedConnectToActivePrinter(); - } - } + Name = "Connect to printer button", + ToolTipText = "Connect to the currently selected printer".Localize(), + ImageMargin = 6, + Margin = 6, + MinimumSize = new VectorMath.Vector2(100, 0) }; - - disconnectPrinterButton = buttonFactory.Generate("Disconnect".Localize().ToUpper(), StaticData.Instance.LoadIcon("connect.png", 32, 32)); - disconnectPrinterButton.Name = "Disconnect from printer button"; - disconnectPrinterButton.ToolTipText = "Disconnect from current printer".Localize(); - disconnectPrinterButton.Margin = new BorderDouble(6, 0, 3, 3); - disconnectPrinterButton.VAnchor = VAnchor.ParentTop; - disconnectPrinterButton.Cursor = Cursors.Hand; - disconnectPrinterButton.Click += (s, e) => UiThread.RunOnIdle(OnIdleDisconnect); - - this.AddChild(connectPrinterButton); - this.AddChild(disconnectPrinterButton); } - - // printer selector and edit button + else { - GuiWidget container = new GuiWidget() - { - HAnchor = HAnchor.ParentLeftRight, - VAnchor = VAnchor.FitToChildren, - }; - - FlowLayoutWidget printerSelectorAndEditButton = new FlowLayoutWidget() - { - HAnchor = HAnchor.ParentLeftRight, - }; - - printerSelector = new PrinterSelector() - { - HAnchor = HAnchor.ParentLeftRight, - Cursor = Cursors.Hand, - Margin = new BorderDouble(0, 6, 0, 3) - }; - printerSelector.AddPrinter += (s, e) => WizardWindow.ShowPrinterSetup(true); - // make sure the control can get smaller but maintains its height - printerSelector.MinimumSize = new Vector2(0, connectPrinterButton.MinimumSize.y); - printerSelectorAndEditButton.AddChild(printerSelector); - - editPrinterButton = TextImageButtonFactory.GetThemedEditButton(); - editPrinterButton.Name = "Edit Printer Button"; - editPrinterButton.VAnchor = VAnchor.ParentCenter; - editPrinterButton.Click += UiNavigation.OpenEditPrinterWizard_Click; - printerSelectorAndEditButton.AddChild(editPrinterButton); - - container.AddChild(printerSelectorAndEditButton); - printerSelectorAndEditOverlay = new GuiWidget() - { - HAnchor = HAnchor.ParentLeftRight, - VAnchor = VAnchor.ParentBottomTop, - Selectable = false, - }; - container.AddChild(printerSelectorAndEditOverlay); - - this.AddChild(container); + connectButton = buttonFactory.Generate("Connect".Localize().ToUpper(), StaticData.Instance.LoadIcon("connect.png", 16, 16)); } - - // reset connection button + connectButton.Click += (s, e) => { - string resetConnectionText = "Reset\nConnection".Localize().ToUpper(); - Button resetConnectionButton = buttonFactory.Generate(resetConnectionText, "e_stop4.png"); - resetConnectionButton.Margin = new BorderDouble(6, 0, 3, 3); - this.AddChild(resetConnectionButton); - - resetConnectionButton.Click += (s, e) => + if (connectButton.Enabled) { - UiThread.RunOnIdle(PrinterConnectionAndCommunication.Instance.RebootBoard); - }; - resetConnectionButton.Visible = ActiveSliceSettings.Instance.GetValue(SettingsKey.show_reset_connection); - - ActiveSliceSettings.SettingChanged.RegisterEvent((sender, e) => - { - StringEventArgs stringEvent = e as StringEventArgs; - if (stringEvent != null) + if (ActiveSliceSettings.Instance.PrinterSelected) { - if (stringEvent.Data == SettingsKey.show_reset_connection) - { - resetConnectionButton.Visible = ActiveSliceSettings.Instance.GetValue(SettingsKey.show_reset_connection); - } + UserRequestedConnectToActivePrinter(); } - }, ref unregisterEvents); + } + }; + this.AddChild(connectButton); + + disconnectButton = buttonFactory.Generate("Disconnect".Localize().ToUpper(), StaticData.Instance.LoadIcon("connect.png", 16, 16)); + disconnectButton.Name = "Disconnect from printer button"; + disconnectButton.Visible = false; + disconnectButton.ToolTipText = "Disconnect from current printer".Localize(); + disconnectButton.Click += (s, e) => UiThread.RunOnIdle(() => + { + if (PrinterConnectionAndCommunication.Instance.PrinterIsPrinting) + { + StyledMessageBox.ShowMessageBox( + (bool disconnectCancel) => + { + if (disconnectCancel) + { + PrinterConnectionAndCommunication.Instance.Stop(false); + PrinterConnectionAndCommunication.Instance.Disable(); + } + }, + disconnectAndCancelMessage, + disconnectAndCancelTitle, + StyledMessageBox.MessageType.YES_NO, + "Disconnect".Localize(), + "Stay Connected".Localize()); + } + else + { + PrinterConnectionAndCommunication.Instance.Disable(); + } + }); + //this.AddChild(disconnectButton); + + foreach (var child in Children) + { + child.VAnchor = VAnchor.ParentTop; + child.HAnchor = HAnchor.ParentLeft; + child.Cursor = Cursors.Hand; } // Bind connect button states to active printer state - this.SetConnectionButtonVisibleState(); + this.SetVisibleStates(null, null); - PrinterConnectionAndCommunication.Instance.EnableChanged.RegisterEvent(onPrinterStatusChanged, ref unregisterEvents); - PrinterConnectionAndCommunication.Instance.CommunicationStateChanged.RegisterEvent(onPrinterStatusChanged, ref unregisterEvents); + PrinterConnectionAndCommunication.Instance.EnableChanged.RegisterEvent(SetVisibleStates, ref unregisterEvents); + PrinterConnectionAndCommunication.Instance.CommunicationStateChanged.RegisterEvent(SetVisibleStates, ref unregisterEvents); + } + + public override void OnClosed(ClosedEventArgs e) + { + unregisterEvents?.Invoke(this, null); + base.OnClosed(e); } static public void UserRequestedConnectToActivePrinter() { - if (staticUnregisterEvents != null) - { - staticUnregisterEvents(null, null); - staticUnregisterEvents = null; - } PrinterConnectionAndCommunication.Instance.HaltConnectionThread(); PrinterConnectionAndCommunication.Instance.ConnectToActivePrinter(true); } - private void onConfirmStopPrint(bool messageBoxResponse) + private void SetVisibleStates(object sender, EventArgs e) { - if (messageBoxResponse) + UiThread.RunOnIdle(() => { - PrinterConnectionAndCommunication.Instance.Stop(false); - PrinterConnectionAndCommunication.Instance.Disable(); - printerSelector.Invalidate(); - } - } + if (PrinterConnectionAndCommunication.Instance.PrinterIsConnected) + { + disconnectButton.Visible = true; + connectButton.Visible = false; + } + else + { + disconnectButton.Visible = false; + connectButton.Visible = true; + } - private void OnIdleDisconnect() - { - if (PrinterConnectionAndCommunication.Instance.PrinterIsPrinting) - { - StyledMessageBox.ShowMessageBox(onConfirmStopPrint, disconnectAndCancelMessage, disconnectAndCancelTitle, StyledMessageBox.MessageType.YES_NO, "Disconnect".Localize(), "Stay Connected".Localize()); - } - else - { - PrinterConnectionAndCommunication.Instance.Disable(); - printerSelector.Invalidate(); - } - } + var communicationState = PrinterConnectionAndCommunication.Instance.CommunicationState; - private void onPrinterStatusChanged(object sender, EventArgs e) - { - UiThread.RunOnIdle(SetConnectionButtonVisibleState); - } + // Ensure connect buttons are locked while long running processes are executing to prevent duplicate calls into said actions + connectButton.Enabled = ActiveSliceSettings.Instance.PrinterSelected + && communicationState != PrinterConnectionAndCommunication.CommunicationStates.AttemptingToConnect; - private void SetConnectionButtonVisibleState() - { - if (PrinterConnectionAndCommunication.Instance.PrinterIsConnected) - { - disconnectPrinterButton.Visible = true; - connectPrinterButton.Visible = false; - } - else - { - disconnectPrinterButton.Visible = false; - connectPrinterButton.Visible = true; - } - - var communicationState = PrinterConnectionAndCommunication.Instance.CommunicationState; - - // Ensure connect buttons are locked while long running processes are executing to prevent duplicate calls into said actions - connectPrinterButton.Enabled = communicationState != PrinterConnectionAndCommunication.CommunicationStates.AttemptingToConnect && ActiveSliceSettings.Instance.PrinterSelected; - bool printerIsPrintigOrPause = PrinterConnectionAndCommunication.Instance.PrinterIsPrinting || PrinterConnectionAndCommunication.Instance.PrinterIsPaused; - editPrinterButton.Enabled = ActiveSliceSettings.Instance.PrinterSelected && !printerIsPrintigOrPause; - printerSelector.Enabled = !printerIsPrintigOrPause; - if(printerIsPrintigOrPause) - { - printerSelectorAndEditOverlay.BackgroundColor = new RGBA_Bytes(ActiveTheme.Instance.PrimaryBackgroundColor, 150); - } - else - { - printerSelectorAndEditOverlay.BackgroundColor = new RGBA_Bytes(0, 0, 0, 0); - } - disconnectPrinterButton.Enabled = communicationState != PrinterConnectionAndCommunication.CommunicationStates.Disconnecting; + disconnectButton.Enabled = communicationState != PrinterConnectionAndCommunication.CommunicationStates.Disconnecting; + }); } } } \ No newline at end of file diff --git a/ApplicationView/ApplicationController.cs b/ApplicationView/ApplicationController.cs index e4b25a80b..afaadd531 100644 --- a/ApplicationView/ApplicationController.cs +++ b/ApplicationView/ApplicationController.cs @@ -70,6 +70,10 @@ namespace MatterHackers.MatterControl public TextImageButtonFactory ImageButtonFactory { get; private set; } public TextImageButtonFactory ActionRowButtonFactory { get; private set; } public TextImageButtonFactory PrinterConnectButtonFactory { get; private set; } + public TextImageButtonFactory BreadCrumbButtonFactory { get; internal set; } + public TextImageButtonFactory BreadCrumbButtonFactorySmallMargins { get; internal set; } + + public RGBA_Bytes TabBodyBackground => new RGBA_Bytes(ActiveTheme.Instance.TertiaryBackgroundColor, 160); TextImageButtonFactory textImageButtonFactory = new TextImageButtonFactory(); private EventHandler unregisterEvents; @@ -82,17 +86,18 @@ namespace MatterHackers.MatterControl public void RebuildTheme() { + var theme = ActiveTheme.Instance; this.ImageButtonFactory = new TextImageButtonFactory() { normalFillColor = RGBA_Bytes.Transparent, normalBorderColor = new RGBA_Bytes(ActiveTheme.Instance.PrimaryTextColor, 200), - normalTextColor = ActiveTheme.Instance.SecondaryTextColor, - pressedTextColor = ActiveTheme.Instance.PrimaryTextColor, - hoverTextColor = ActiveTheme.Instance.PrimaryTextColor, - hoverBorderColor = new RGBA_Bytes(ActiveTheme.Instance.PrimaryTextColor, 200), + normalTextColor = theme.SecondaryTextColor, + pressedTextColor = theme.PrimaryTextColor, + hoverTextColor = theme.PrimaryTextColor, + hoverBorderColor = new RGBA_Bytes(theme.PrimaryTextColor, 200), disabledFillColor = RGBA_Bytes.Transparent, - disabledBorderColor = new RGBA_Bytes(ActiveTheme.Instance.PrimaryTextColor, 100), - disabledTextColor = new RGBA_Bytes(ActiveTheme.Instance.PrimaryTextColor, 100), + disabledBorderColor = new RGBA_Bytes(theme.PrimaryTextColor, 100), + disabledTextColor = new RGBA_Bytes(theme.PrimaryTextColor, 100), FixedHeight = fizedHeightA, fontSize = fontSizeA, borderWidth = borderWidth @@ -114,24 +119,46 @@ namespace MatterHackers.MatterControl this.PrinterConnectButtonFactory = new TextImageButtonFactory() { - normalTextColor = ActiveTheme.Instance.PrimaryTextColor, - normalBorderColor = (ActiveTheme.Instance.IsDarkTheme) ? new RGBA_Bytes(77, 77, 77) : new RGBA_Bytes(190, 190, 190), - hoverTextColor = ActiveTheme.Instance.PrimaryTextColor, - pressedTextColor = ActiveTheme.Instance.PrimaryTextColor, - disabledTextColor = ActiveTheme.Instance.TabLabelUnselected, - disabledFillColor = ActiveTheme.Instance.PrimaryBackgroundColor, - disabledBorderColor = ActiveTheme.Instance.SecondaryBackgroundColor, - hoverFillColor = ActiveTheme.Instance.PrimaryBackgroundColor, + normalTextColor = theme.PrimaryTextColor, + normalBorderColor = (theme.IsDarkTheme) ? new RGBA_Bytes(77, 77, 77) : new RGBA_Bytes(190, 190, 190), + hoverTextColor = theme.PrimaryTextColor, + pressedTextColor = theme.PrimaryTextColor, + disabledTextColor = theme.TabLabelUnselected, + disabledFillColor = theme.PrimaryBackgroundColor, + disabledBorderColor = theme.SecondaryBackgroundColor, + hoverFillColor = theme.PrimaryBackgroundColor, hoverBorderColor = new RGBA_Bytes(128, 128, 128), invertImageLocation = false, borderWidth = 1 }; + + this.BreadCrumbButtonFactory = new TextImageButtonFactory() + { + normalTextColor = theme.PrimaryTextColor, + hoverTextColor = theme.PrimaryTextColor, + pressedTextColor = theme.PrimaryTextColor, + disabledTextColor = theme.TertiaryBackgroundColor, + Margin = new BorderDouble(16, 0), + borderWidth = 0, + FixedHeight = 32, + }; + + this.BreadCrumbButtonFactorySmallMargins = new TextImageButtonFactory() + { + normalTextColor = theme.PrimaryTextColor, + hoverTextColor = theme.PrimaryTextColor, + pressedTextColor = theme.PrimaryTextColor, + disabledTextColor = theme.TertiaryBackgroundColor, + Margin = new BorderDouble(8, 0), + borderWidth = 0, + FixedHeight = 32, + }; } internal TabControl CreateTabControl() { var advancedControls = new TabControl(separator: new HorizontalLine(alpha: 50)); - advancedControls.TabBar.BorderColor = RGBA_Bytes.Transparent; // ActiveTheme.Instance.SecondaryTextColor; + advancedControls.TabBar.BorderColor = RGBA_Bytes.Transparent; // theme.SecondaryTextColor; advancedControls.TabBar.Margin = 0; advancedControls.TabBar.Padding = 0; advancedControls.TextPointSize = 14; @@ -633,8 +660,6 @@ namespace MatterHackers.MatterControl } } - public RGBA_Bytes TabBodyBackground => new RGBA_Bytes(ActiveTheme.Instance.TertiaryBackgroundColor, 160); - public string CachePath(ILibraryItem libraryItem) { // TODO: Use content SHA diff --git a/ConfigurationPage/PrinterConfigurationPage.cs b/ConfigurationPage/PrinterConfigurationPage.cs index 8186ba5c8..76cf18cbb 100644 --- a/ConfigurationPage/PrinterConfigurationPage.cs +++ b/ConfigurationPage/PrinterConfigurationPage.cs @@ -46,7 +46,7 @@ namespace MatterHackers.MatterControl : base(true) { ScrollArea.HAnchor |= Agg.UI.HAnchor.ParentLeftRight; - this.BackgroundColor = ApplicationController.Instance.TabBodyBackground; + this.BackgroundColor = ApplicationController.Instance.Theme.TabBodyBackground; AnchorAll(); AddChild(new PrinterConfigurationWidget()); } diff --git a/CustomWidgets/LibrarySelector/FolderBreadCrumbWidget.cs b/CustomWidgets/LibrarySelector/FolderBreadCrumbWidget.cs index b8d925d00..79e1a6fa0 100644 --- a/CustomWidgets/LibrarySelector/FolderBreadCrumbWidget.cs +++ b/CustomWidgets/LibrarySelector/FolderBreadCrumbWidget.cs @@ -39,16 +39,6 @@ namespace MatterHackers.MatterControl.CustomWidgets public class FolderBreadCrumbWidget : FlowLayoutWidget { private ListView listView; - private TextImageButtonFactory navigationButtonFactory = new TextImageButtonFactory() - { - normalTextColor = ActiveTheme.Instance.PrimaryTextColor, - hoverTextColor = ActiveTheme.Instance.PrimaryTextColor, - pressedTextColor = ActiveTheme.Instance.PrimaryTextColor, - disabledTextColor = ActiveTheme.Instance.PrimaryTextColor, - Margin = new BorderDouble(10, 0), - borderWidth = 0, - FixedHeight = 30 - }; public FolderBreadCrumbWidget(ListView listView) { @@ -56,8 +46,6 @@ namespace MatterHackers.MatterControl.CustomWidgets this.Name = "FolderBreadCrumbWidget"; UiThread.RunOnIdle(() => SetBreadCrumbs(listView.ActiveContainer)); HAnchor = HAnchor.ParentLeftRight; - - navigationButtonFactory.disabledFillColor = navigationButtonFactory.normalFillColor; } public static IEnumerable ItemAndParents(ILibraryContainer item) @@ -72,6 +60,7 @@ namespace MatterHackers.MatterControl.CustomWidgets public void SetBreadCrumbs(ILibraryContainer currentContainer) { + var buttonFactory = ApplicationController.Instance.Theme.BreadCrumbButtonFactory; this.CloseAllChildren(); bool haveFilterRunning = !string.IsNullOrEmpty(currentContainer.KeywordFilter); @@ -79,7 +68,7 @@ namespace MatterHackers.MatterControl.CustomWidgets var icon = LibraryProviderHelpers.LoadInvertIcon("FileDialog", "up_folder_20.png"); //icon = LibraryProviderHelpers.ResizeImage(icon, 20, 20); - Button upbutton = navigationButtonFactory.Generate("", icon); + Button upbutton = buttonFactory.Generate("", icon); upbutton.Name = "Library Up Button"; upbutton.Margin = 0; upbutton.Click += (s, e) => @@ -106,7 +95,7 @@ namespace MatterHackers.MatterControl.CustomWidgets }); } - Button gotoProviderButton = navigationButtonFactory.Generate(container.Name); + Button gotoProviderButton = buttonFactory.Generate(container.Name); gotoProviderButton.Name = "Bread Crumb Button " + container.Name; gotoProviderButton.Margin = new BorderDouble(firstItem ? 0 : 3, 0, 3, 0); gotoProviderButton.Click += (s, e) => @@ -128,11 +117,11 @@ namespace MatterHackers.MatterControl.CustomWidgets Button searchResultsButton = null; if (UserSettings.Instance.IsTouchScreen) { - searchResultsButton = navigationButtonFactory.Generate("Search Results".Localize(), "icon_search_32x32.png"); + searchResultsButton = buttonFactory.Generate("Search Results".Localize(), "icon_search_32x32.png"); } else { - searchResultsButton = navigationButtonFactory.Generate("Search Results".Localize(), "icon_search_24x24.png"); + searchResultsButton = buttonFactory.Generate("Search Results".Localize(), "icon_search_24x24.png"); } searchResultsButton.Name = "Bread Crumb Button " + "Search Results"; searchResultsButton.Margin = new BorderDouble(3, 0); diff --git a/Library/Widgets/PrintLibraryWidget.cs b/Library/Widgets/PrintLibraryWidget.cs index 92070c72b..e7bb47fd7 100644 --- a/Library/Widgets/PrintLibraryWidget.cs +++ b/Library/Widgets/PrintLibraryWidget.cs @@ -74,7 +74,7 @@ namespace MatterHackers.MatterControl.PrintLibrary public PrintLibraryWidget() { this.Padding = new BorderDouble(3); - this.BackgroundColor = ApplicationController.Instance.TabBodyBackground; + this.BackgroundColor = ApplicationController.Instance.Theme.TabBodyBackground; this.AnchorAll(); textImageButtonFactory = new TextImageButtonFactory() diff --git a/PartPreviewWindow/OverflowDropdown.cs b/PartPreviewWindow/OverflowDropdown.cs index 96ee23cef..e18d041ae 100644 --- a/PartPreviewWindow/OverflowDropdown.cs +++ b/PartPreviewWindow/OverflowDropdown.cs @@ -35,6 +35,7 @@ using MatterHackers.Localizations; using MatterHackers.Agg.PlatformAbstract; using MatterHackers.Agg.Image; using MatterHackers.Agg.ImageProcessing; +using System; namespace MatterHackers.MatterControl.PartPreviewWindow { @@ -65,6 +66,8 @@ namespace MatterHackers.MatterControl.PartPreviewWindow public GuiWidget PopupContent { get; set; } + public Func DynamicPopupContent { get; set; } + public bool AlignToRightEdge { get; set; } public override void OnMouseDown(MouseEventArgs mouseEvent) @@ -88,7 +91,17 @@ namespace MatterHackers.MatterControl.PartPreviewWindow { overflowMenuActive = true; - this.PopupContent.ClearRemovedFlag(); + this.PopupContent?.ClearRemovedFlag(); + + if (this.DynamicPopupContent != null) + { + this.PopupContent = this.DynamicPopupContent(); + } + + if (this.PopupContent == null) + { + return; + } var popupWidget = new PopupWidget(this.PopupContent, this, Vector2.Zero, Direction.Down, 0, this.AlignToRightEdge) { diff --git a/PartPreviewWindow/View3D/PrinterActionsBar.cs b/PartPreviewWindow/View3D/PrinterActionsBar.cs index 98ecfaa15..0754f619b 100644 --- a/PartPreviewWindow/View3D/PrinterActionsBar.cs +++ b/PartPreviewWindow/View3D/PrinterActionsBar.cs @@ -31,12 +31,12 @@ using MatterHackers.Agg; using MatterHackers.Agg.UI; using MatterHackers.Localizations; using MatterHackers.MatterControl.ActionBar; +using MatterHackers.MatterControl.CustomWidgets; using MatterHackers.MatterControl.EeProm; using MatterHackers.MatterControl.PrinterCommunication; namespace MatterHackers.MatterControl.PartPreviewWindow { - public partial class View3DWidget : PartPreview3DWidget { public class PrinterActionsBar : FlowLayoutWidget @@ -48,12 +48,14 @@ namespace MatterHackers.MatterControl.PartPreviewWindow public PrinterActionsBar() { - this.Padding = new BorderDouble(0, 0, 10, 0); - this.BackgroundColor = ActiveTheme.Instance.PrimaryBackgroundColor; + this.Padding = new BorderDouble(0, 5); this.HAnchor = HAnchor.ParentLeftRight; this.VAnchor = VAnchor.FitToChildren; - var buttonFactory = ApplicationController.Instance.Theme.PrinterConnectButtonFactory; + var buttonFactory = ApplicationController.Instance.Theme.BreadCrumbButtonFactory; + + this.AddChild(new PrinterConnectButton(buttonFactory)); + //this.AddChild(new ResetButton(buttonFactory)); //ImageBuffer terminalSettingsImage = StaticData.Instance.LoadIcon("terminal-24x24.png", 24, 24).InvertLightness(); var terminalButton = buttonFactory.Generate("Terminal".Localize().ToUpper()); @@ -67,13 +69,32 @@ namespace MatterHackers.MatterControl.PartPreviewWindow { levelingImage.InvertLightness(); }*/ + Button configureEePromButton = buttonFactory.Generate("EEProm".Localize().ToUpper()); configureEePromButton.Click += configureEePromButton_Click; this.AddChild(configureEePromButton); - this.AddChild(new PrinterConnectAndSelectControl()); + //this.AddChild(new PrintStatusRow()); - this.AddChild(new PrintStatusRow()); + this.AddChild(new HorizontalSpacer()); + + var overflowDropdown = new OverflowDropdown(allowLightnessInvert: true) + { + AlignToRightEdge = true, + DynamicPopupContent = GeneratePopupContent + }; + this.AddChild(overflowDropdown); + } + + private GuiWidget GeneratePopupContent() + { + var widgetToPop = new FlowLayoutWidget(); + + widgetToPop.AddChild(new PrinterSelectEditDropdown()); + + //widgetToPop.AddChild("more stuff..."); + + return widgetToPop; } private void configureEePromButton_Click(object sender, EventArgs mouseEvent) diff --git a/PartPreviewWindow/View3D/View3DWidget.cs b/PartPreviewWindow/View3D/View3DWidget.cs index 3f6da0b27..8f7878d49 100644 --- a/PartPreviewWindow/View3D/View3DWidget.cs +++ b/PartPreviewWindow/View3D/View3DWidget.cs @@ -249,6 +249,8 @@ namespace MatterHackers.MatterControl.PartPreviewWindow this.printItemWrapper = printItemWrapper; this.Name = "View3DWidget"; + this.BackgroundColor = ApplicationController.Instance.Theme.TabBodyBackground; + FlowLayoutWidget mainContainerTopToBottom = new FlowLayoutWidget(FlowDirection.TopToBottom); mainContainerTopToBottom.HAnchor = Agg.UI.HAnchor.Max_FitToChildren_ParentWidth; mainContainerTopToBottom.VAnchor = Agg.UI.VAnchor.Max_FitToChildren_ParentHeight; @@ -257,7 +259,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow centerPartPreviewAndControls.Name = "centerPartPreviewAndControls"; centerPartPreviewAndControls.AnchorAll(); - var textImageButtonFactory = ApplicationController.Instance.Theme.ImageButtonFactory; + var textImageButtonFactory = ApplicationController.Instance.Theme.BreadCrumbButtonFactorySmallMargins; mainContainerTopToBottom.AddChild(new PrinterActionsBar()); @@ -1579,6 +1581,18 @@ namespace MatterHackers.MatterControl.PartPreviewWindow return true; }); + + /* + DynamicDropDownMenu menu = CreateMenu(direction); + + for (int index = 1; index < buttonList.Count; index++) + { + menu.addItem(buttonList[index].Item1, buttonList[index].Item2); + } + + SplitButton splitButton = new SplitButton(button, menu); + */ + SplitButtonFactory splitButtonFactory = new SplitButtonFactory(); splitButtonFactory.FixedHeight = 40 * GuiWidget.DeviceScale; diff --git a/PartPreviewWindow/ViewControls3D.cs b/PartPreviewWindow/ViewControls3D.cs index 873d10ef6..ee6ba6619 100644 --- a/PartPreviewWindow/ViewControls3D.cs +++ b/PartPreviewWindow/ViewControls3D.cs @@ -203,9 +203,9 @@ namespace MatterHackers.MatterControl.PartPreviewWindow public GuiWidget ShowOverflowMenu() { - var topToBottom = new FlowLayoutWidget(FlowDirection.TopToBottom); + var popupContainer = new FlowLayoutWidget(FlowDirection.TopToBottom); - topToBottom.AddChild( + popupContainer.AddChild( AddCheckbox( "Show Print Bed".Localize(), "Show Help Checkbox", @@ -223,7 +223,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow double buildHeight = ActiveSliceSettings.Instance.GetValue(SettingsKey.build_height); if (buildHeight > 0) { - topToBottom.AddChild( + popupContainer.AddChild( AddCheckbox( "Show Print Area".Localize(), "Show Help Checkbox", @@ -245,12 +245,12 @@ namespace MatterHackers.MatterControl.PartPreviewWindow Margin = new BorderDouble(5, 5, 5, 0) }; - topToBottom.AddChild(new HorizontalLine()); + popupContainer.AddChild(new HorizontalLine()); CreateRenderTypeRadioButtons(widget); - topToBottom.AddChild(widget); + popupContainer.AddChild(widget); - return topToBottom; + return popupContainer; } private void CreateRenderTypeRadioButtons(GuiWidget parentContainer) diff --git a/PrinterControls/ManualPrinterControls.cs b/PrinterControls/ManualPrinterControls.cs index cc8048bf5..f11479a68 100644 --- a/PrinterControls/ManualPrinterControls.cs +++ b/PrinterControls/ManualPrinterControls.cs @@ -52,7 +52,7 @@ namespace MatterHackers.MatterControl public ManualPrinterControls() { - this.BackgroundColor = ApplicationController.Instance.TabBodyBackground; + this.BackgroundColor = ApplicationController.Instance.Theme.TabBodyBackground; AnchorAll(); if (UserSettings.Instance.IsTouchScreen) { diff --git a/SlicerConfiguration/SliceSettingsWidget.cs b/SlicerConfiguration/SliceSettingsWidget.cs index f576853b3..e1659003e 100644 --- a/SlicerConfiguration/SliceSettingsWidget.cs +++ b/SlicerConfiguration/SliceSettingsWidget.cs @@ -108,7 +108,7 @@ namespace MatterHackers.MatterControl.SlicerConfiguration public SliceSettingsWidget(List layerCascade = null, NamedSettingsLayers viewFilter = NamedSettingsLayers.All) { - this.BackgroundColor = ApplicationController.Instance.TabBodyBackground; + this.BackgroundColor = ApplicationController.Instance.Theme.TabBodyBackground; this.layerCascade = layerCascade; this.viewFilter = viewFilter;