From a03aee76f335e7299f10301683a171d764473cc8 Mon Sep 17 00:00:00 2001 From: Kevin Pope Date: Mon, 13 Oct 2014 15:25:27 -0700 Subject: [PATCH] Adjusted touchscreen layout reload behavior. --- ApplicationView/CompactTabView.cs | 105 +++++++++++++++--- ApplicationView/ThirdPanelTabView.cs | 2 +- ConfigurationPage/PrinterConfigurationPage.cs | 6 +- SlicerConfiguration/SliceSettingsWidget.cs | 1 + 4 files changed, 93 insertions(+), 21 deletions(-) diff --git a/ApplicationView/CompactTabView.cs b/ApplicationView/CompactTabView.cs index 2ae089ef7..630e7e525 100644 --- a/ApplicationView/CompactTabView.cs +++ b/ApplicationView/CompactTabView.cs @@ -61,16 +61,22 @@ namespace MatterHackers.MatterControl TabPage LibraryTabPage; TabPage HistoryTabPage; TabPage AboutTabPage; - SimpleTextTabWidget AboutTabView; RGBA_Bytes unselectedTextColor = ActiveTheme.Instance.TabLabelUnselected; GuiWidget addedUpdateMark = null; QueueDataView queueDataView; event EventHandler unregisterEvents; - SliceSettingsWidget sliceSettingsWidget; GuiWidget part3DViewContainer; View3DTransformPart part3DView; GuiWidget partGcodeViewContainer; ViewGcodeBasic partGcodeView; + SimpleTextTabWidget aboutTabWidget; + SliceSettingsWidget sliceSettingsWidget; + + TabPage sliceTabPage; + TabPage manualControlsPage; + TabPage configurationPage; + + int TabTextSize; public CompactTabView(QueueDataView queueDataView) @@ -85,6 +91,10 @@ namespace MatterHackers.MatterControl this.Margin = new BorderDouble(top: 4); this.TabTextSize = 15; + ActivePrinterProfile.Instance.ActivePrinterChanged.RegisterEvent(LoadSettingsOnPrinterChanged, ref unregisterEvents); + PrinterConnectionAndCommunication.Instance.ActivePrintItemChanged.RegisterEvent(onActivePrintItemChanged, ref unregisterEvents); + ApplicationController.Instance.ReloadAdvancedControlsPanelTrigger.RegisterEvent(ReloadAdvancedControlsPanelTrigger, ref unregisterEvents); + PrinterConnectionAndCommunication.Instance.ActivePrintItemChanged.RegisterEvent(onActivePrintItemChanged, ref unregisterEvents); QueueTabPage = new TabPage(new QueueBottomToolbar(queueDataView), LocalizedString.Get("Queue").ToUpper()); @@ -102,10 +112,10 @@ namespace MatterHackers.MatterControl GuiWidget manualPrinterControls = new ManualPrinterControls(); - ScrollableWidget manualPrinterControlsScrollArea = new ScrollableWidget(true); - manualPrinterControlsScrollArea.ScrollArea.HAnchor |= Agg.UI.HAnchor.ParentLeftRight; - manualPrinterControlsScrollArea.AnchorAll(); - manualPrinterControlsScrollArea.AddChild(manualPrinterControls); + ScrollableWidget manualPrinterControlsWidget = new ScrollableWidget(true); + manualPrinterControlsWidget.ScrollArea.HAnchor |= Agg.UI.HAnchor.ParentLeftRight; + manualPrinterControlsWidget.AnchorAll(); + manualPrinterControlsWidget.AddChild(manualPrinterControls); part3DViewContainer = new GuiWidget(); part3DViewContainer.AnchorAll(); @@ -116,6 +126,7 @@ namespace MatterHackers.MatterControl GeneratePartViews(); string partPreviewLabel = LocalizedString.Get("Part Preview").ToUpper(); + this.AddTab(new SimpleTextTabWidget(new TabPage(part3DViewContainer, partPreviewLabel), "Part Preview Tab", TabTextSize, ActiveTheme.Instance.SecondaryAccentColor, new RGBA_Bytes(), unselectedTextColor, new RGBA_Bytes())); @@ -125,23 +136,27 @@ namespace MatterHackers.MatterControl //Add the tab contents for 'Advanced Controls' string printerControlsLabel = LocalizedString.Get("Controls").ToUpper(); - this.AddTab(new SimpleTextTabWidget(new TabPage(manualPrinterControlsScrollArea, printerControlsLabel), "Controls Tab", TabTextSize, + manualControlsPage = new TabPage(manualPrinterControlsWidget, printerControlsLabel); + this.AddTab(new SimpleTextTabWidget(manualControlsPage, "Controls Tab", TabTextSize, ActiveTheme.Instance.SecondaryAccentColor, new RGBA_Bytes(), unselectedTextColor, new RGBA_Bytes())); - string sliceSettingsLabel = LocalizedString.Get("Slice Settings").ToUpper(); - sliceSettingsWidget = new SliceSettingsWidget(sliceSettingsUiState); - this.AddTab(new SimpleTextTabWidget(new TabPage(sliceSettingsWidget, sliceSettingsLabel), "Slice Settings Tab", TabTextSize, - ActiveTheme.Instance.SecondaryAccentColor, new RGBA_Bytes(), unselectedTextColor, new RGBA_Bytes())); + string sliceSettingsLabel = LocalizedString.Get("Slice Settings").ToUpper(); + sliceSettingsWidget = new SliceSettingsWidget(sliceSettingsUiState); + sliceTabPage = new TabPage(sliceSettingsWidget, sliceSettingsLabel); + + this.AddTab(new SimpleTextTabWidget(sliceTabPage, "Slice Settings Tab", TabTextSize, + ActiveTheme.Instance.SecondaryAccentColor, new RGBA_Bytes(), unselectedTextColor, new RGBA_Bytes())); string configurationLabel = LocalizedString.Get("Configuration").ToUpper(); - ScrollableWidget configurationControls = new PrinterConfigurationPage(); - this.AddTab(new SimpleTextTabWidget(new TabPage(configurationControls, configurationLabel), "Configuration Tab", TabTextSize, + PrinterConfigurationScrollWidget printerConfigurationWidget = new PrinterConfigurationScrollWidget(); + configurationPage = new TabPage(printerConfigurationWidget, configurationLabel); + this.AddTab(new SimpleTextTabWidget(configurationPage, "Configuration Tab", TabTextSize, ActiveTheme.Instance.SecondaryAccentColor, new RGBA_Bytes(), unselectedTextColor, new RGBA_Bytes())); AboutTabPage = new TabPage(new AboutPage(), LocalizedString.Get("About").ToUpper()); - AboutTabView = new SimpleTextTabWidget(AboutTabPage, "About Tab", TabTextSize, + aboutTabWidget = new SimpleTextTabWidget(AboutTabPage, "About Tab", TabTextSize, ActiveTheme.Instance.SecondaryAccentColor, new RGBA_Bytes(), unselectedTextColor, new RGBA_Bytes()); - this.AddTab(AboutTabView); + this.AddTab(aboutTabWidget); NumQueueItemsChanged(this, null); SetUpdateNotification(this, null); @@ -160,6 +175,43 @@ namespace MatterHackers.MatterControl UiThread.RunOnIdle(GeneratePartViews); } + public void ReloadAdvancedControlsPanelTrigger(object sender, EventArgs e) + { + UiThread.RunOnIdle(ReloadAdvancedControlsPanel); + } + + + + void reloadSliceSettingsWidget() + { + //Store the UI state from the current display + sliceSettingsUiState = new SliceSettingsWidgetUiState(sliceSettingsWidget); + + sliceTabPage.RemoveAllChildren(); + sliceSettingsWidget = new SliceSettingsWidget(sliceSettingsUiState); + sliceSettingsWidget.AnchorAll(); + sliceTabPage.AddChild(sliceSettingsWidget); + } + + void reloadControlsWidget() + { + + GuiWidget manualPrinterControls = new ManualPrinterControls(); + ScrollableWidget manualPrinterControlsWidget = new ScrollableWidget(true); + manualPrinterControlsWidget.ScrollArea.HAnchor |= Agg.UI.HAnchor.ParentLeftRight; + manualPrinterControlsWidget.AnchorAll(); + manualPrinterControlsWidget.AddChild(manualPrinterControls); + + manualControlsPage.RemoveAllChildren(); + manualControlsPage.AddChild(manualPrinterControlsWidget); + } + + void reloadConfigurationWidget() + { + configurationPage.RemoveAllChildren(); + configurationPage.AddChild(new PrinterConfigurationScrollWidget()); + } + void GeneratePartViews(object state = null) { double buildHeight = ActiveSliceSettings.Instance.BuildHeight; @@ -219,6 +271,25 @@ namespace MatterHackers.MatterControl } } + public void ReloadAdvancedControlsPanel(object state) + { + UiThread.RunOnIdle(LoadAdvancedControls); + } + + void LoadAdvancedControls(object state = null) + { + reloadControlsWidget(); + reloadConfigurationWidget(); + reloadSliceSettingsWidget(); + this.Invalidate(); + } + + public void LoadSettingsOnPrinterChanged(object sender, EventArgs e) + { + ActiveSliceSettings.Instance.LoadAllSettings(); + ApplicationController.Instance.ReloadAdvancedControlsPanel(); + } + public void SetUpdateNotification(object sender, EventArgs widgetEvent) { switch (UpdateControlData.Instance.UpdateStatus) @@ -230,8 +301,8 @@ namespace MatterHackers.MatterControl if (addedUpdateMark == null) { addedUpdateMark = new NotificationWidget(); - addedUpdateMark.OriginRelativeParent = new Vector2(AboutTabView.tabTitle.Width + 3, 7); - AboutTabView.AddChild(addedUpdateMark); + addedUpdateMark.OriginRelativeParent = new Vector2(aboutTabWidget.tabTitle.Width + 3, 7); + aboutTabWidget.AddChild(addedUpdateMark); } addedUpdateMark.Visible = true; break; diff --git a/ApplicationView/ThirdPanelTabView.cs b/ApplicationView/ThirdPanelTabView.cs index dee428801..65377ceb2 100644 --- a/ApplicationView/ThirdPanelTabView.cs +++ b/ApplicationView/ThirdPanelTabView.cs @@ -159,7 +159,7 @@ namespace MatterHackers.MatterControl ActiveTheme.Instance.PrimaryTextColor, new RGBA_Bytes(), unselectedTextColor, new RGBA_Bytes())); string configurationLabel = LocalizedString.Get("Configuration").ToUpper(); - ScrollableWidget configurationControls = new PrinterConfigurationPage(); + ScrollableWidget configurationControls = new PrinterConfigurationScrollWidget(); advancedControls.AddTab(new SimpleTextTabWidget(new TabPage(configurationControls, configurationLabel), "Configuration Tab", textSize, ActiveTheme.Instance.PrimaryTextColor, new RGBA_Bytes(), unselectedTextColor, new RGBA_Bytes())); diff --git a/ConfigurationPage/PrinterConfigurationPage.cs b/ConfigurationPage/PrinterConfigurationPage.cs index 4bf7bf379..9dfd69531 100644 --- a/ConfigurationPage/PrinterConfigurationPage.cs +++ b/ConfigurationPage/PrinterConfigurationPage.cs @@ -45,14 +45,14 @@ using MatterHackers.VectorMath; namespace MatterHackers.MatterControl { - public class PrinterConfigurationPage : ScrollableWidget + public class PrinterConfigurationScrollWidget : ScrollableWidget { - public PrinterConfigurationPage() + public PrinterConfigurationScrollWidget() : base(true) { ScrollArea.HAnchor |= Agg.UI.HAnchor.ParentLeftRight; AnchorAll(); - AddChild(new PrinterConfigurationWidget()); + AddChild(new PrinterConfigurationWidget()); } } diff --git a/SlicerConfiguration/SliceSettingsWidget.cs b/SlicerConfiguration/SliceSettingsWidget.cs index d24486229..13fb63776 100644 --- a/SlicerConfiguration/SliceSettingsWidget.cs +++ b/SlicerConfiguration/SliceSettingsWidget.cs @@ -180,6 +180,7 @@ namespace MatterHackers.MatterControl.SlicerConfiguration { categoryTabs.SelectTab(uiState.selectedCategory.index); } + this.AnchorAll(); } public bool ShowingHelp