From f78aaa0920b52a075323a1cfa0e36af682e5a85a Mon Sep 17 00:00:00 2001 From: John Lewin Date: Mon, 8 Jan 2018 13:13:32 -0800 Subject: [PATCH 1/5] Revise SliceSettings subtabs - Issue MatterHackers/MCCentral#2605 Overflow menu clips - Issue MatterHackers/MCCentral#2606 Revise Chrome tabs for reuse --- PartPreviewWindow/MainTab.cs | 173 ++++++++++++--------- PartPreviewWindow/NewTabButton.cs | 2 +- PartPreviewWindow/PartPreviewContent.cs | 12 +- PartPreviewWindow/Toolbar.cs | 22 ++- SlicerConfiguration/SliceSettingsWidget.cs | 68 ++++---- 5 files changed, 160 insertions(+), 117 deletions(-) diff --git a/PartPreviewWindow/MainTab.cs b/PartPreviewWindow/MainTab.cs index bc1ae48f8..e0c5bc2c1 100644 --- a/PartPreviewWindow/MainTab.cs +++ b/PartPreviewWindow/MainTab.cs @@ -37,13 +37,19 @@ using MatterHackers.Localizations; namespace MatterHackers.MatterControl.PartPreviewWindow { - public class MainTab : GuiWidget, ITab + public class SimpleTab : GuiWidget, ITab { public event EventHandler CloseClicked; - private SimpleTabs parentTabControl; + protected SimpleTabs parentTabControl; - public MainTab(string tabLabel, SimpleTabs parentTabControl, GuiWidget tabContent, ThemeConfig theme, string tabImageUrl = null) + protected ThemeConfig theme; + + protected TabPill tabPill; + + public GuiWidget TabContent { get; protected set; } + + public SimpleTab(string tabLabel, SimpleTabs parentTabControl, GuiWidget tabContent, ThemeConfig theme, string tabImageUrl = null, bool hasClose = true, double pointSize = 12) { this.HAnchor = HAnchor.Fit; this.VAnchor = VAnchor.Fit | VAnchor.Bottom; @@ -55,44 +61,119 @@ namespace MatterHackers.MatterControl.PartPreviewWindow this.parentTabControl = parentTabControl; this.AddChild( - new TabPill(tabLabel, ActiveTheme.Instance.PrimaryTextColor, tabImageUrl) + tabPill = new TabPill(tabLabel, ActiveTheme.Instance.PrimaryTextColor, tabImageUrl, pointSize) { - Margin = new BorderDouble(right: 16) + Margin = (hasClose) ? new BorderDouble(right: 16) : 0 }); - var closeButton = ApplicationController.Instance.Theme.CreateSmallResetButton(); - closeButton.HAnchor = HAnchor.Right; - closeButton.Margin = new BorderDouble(right: 7, top: 1); - closeButton.Name = "Close Tab Button"; - closeButton.ToolTipText = "Close".Localize(); - closeButton.Click += (sender, e) => + if (hasClose) { - UiThread.RunOnIdle(() => + var closeButton = ApplicationController.Instance.Theme.CreateSmallResetButton(); + closeButton.HAnchor = HAnchor.Right; + closeButton.Margin = new BorderDouble(right: 7, top: 1); + closeButton.Name = "Close Tab Button"; + closeButton.ToolTipText = "Close".Localize(); + closeButton.Click += (sender, e) => { - this.parentTabControl.RemoveTab(this); - this.CloseClicked?.Invoke(this, null); - }); - }; + UiThread.RunOnIdle(() => + { + this.parentTabControl.RemoveTab(this); + this.CloseClicked?.Invoke(this, null); + }); + }; - this.AddChild(closeButton); + this.AddChild(closeButton); + } } - private ThemeConfig theme; + protected class TabPill : FlowLayoutWidget + { + private TextWidget label; - public GuiWidget TabContent { get; } + public TabPill(string tabTitle, Color textColor, string imageUrl = null, double pointSize = 12) + { + this.Selectable = false; + this.Padding = new BorderDouble(10, 5, 10, 4); + + if (!string.IsNullOrEmpty(imageUrl)) + { + var imageWidget = new ImageWidget(new ImageBuffer(16, 16)) + { + Margin = new BorderDouble(right: 6, bottom: 2), + VAnchor = VAnchor.Center + }; + this.AddChild(imageWidget); + + // Attempt to load image + try + { + // TODO: Must use caching + ApplicationController.Instance.DownloadToImageAsync(imageWidget.Image, imageUrl, false); + } + catch { } + } + + label = new TextWidget(tabTitle, pointSize: pointSize) + { + TextColor = textColor, + VAnchor = VAnchor.Center + }; + this.AddChild(label); + } + + public Color TextColor + { + get => label.TextColor; + set => label.TextColor = value; + } + + public override string Text + { + get => label.Text; + set => label.Text = value; + } + } + } + + public class ToolTab : SimpleTab + { + public Color InactiveTabColor { get; set; } + public Color ActiveTabColor { get; set; } + public ToolTab(string tabLabel, SimpleTabs parentTabControl, GuiWidget tabContent, ThemeConfig theme, string tabImageUrl = null, bool hasClose = true) + : base(tabLabel, parentTabControl, tabContent, theme, tabImageUrl, hasClose, theme.FontSize10) + { + tabPill.Padding = tabPill.Padding.Clone(top: 9, bottom: 10); + } + + public override void OnDraw(Graphics2D graphics2D) + { + graphics2D.Render( + new RoundedRect(this.LocalBounds, 0), + (this == parentTabControl.ActiveTab) ? this.ActiveTabColor : this.InactiveTabColor); + + base.OnDraw(graphics2D); + } + } + + public class ChromeTab : SimpleTab + { + public ChromeTab(string tabLabel, SimpleTabs parentTabControl, GuiWidget tabContent, ThemeConfig theme, string tabImageUrl = null) + : base (tabLabel, parentTabControl, tabContent, theme, tabImageUrl) + { + } private static int tabInsetDistance = 14 / 2; - internal MainTab NextTab { get; set; } + internal ChromeTab NextTab { get; set; } - internal MainTab PreviousTab { get; set; } + internal ChromeTab PreviousTab { get; set; } public override void OnDraw(Graphics2D graphics2D) { var rect = LocalBounds; var centerY = rect.YCenter; - var siblings = this.Parent.Children.OfType().ToList(); + var siblings = this.Parent.Children.OfType().ToList(); int position = siblings.IndexOf(this); @@ -165,53 +246,5 @@ namespace MatterHackers.MatterControl.PartPreviewWindow graphics2D.Render(tabLeft, color); } - - private class TabPill : FlowLayoutWidget - { - private TextWidget label; - - public TabPill(string tabTitle, Color textColor, string imageUrl = null) - { - this.Selectable = false; - this.Padding = new BorderDouble(10, 5, 10, 4); - - if (!string.IsNullOrEmpty(imageUrl)) - { - var imageWidget = new ImageWidget(new ImageBuffer(16, 16)) - { - Margin = new BorderDouble(right: 6, bottom: 2), - VAnchor = VAnchor.Center - }; - this.AddChild(imageWidget); - - // Attempt to load image - try - { - // TODO: Must use caching - ApplicationController.Instance.DownloadToImageAsync(imageWidget.Image, imageUrl, false); - } - catch { } - } - - label = new TextWidget(tabTitle) - { - TextColor = textColor, - VAnchor = VAnchor.Center - }; - this.AddChild(label); - } - - public Color TextColor - { - get => label.TextColor; - set => label.TextColor = value; - } - - public override string Text - { - get => label.Text; - set => label.Text = value; - } - } } } diff --git a/PartPreviewWindow/NewTabButton.cs b/PartPreviewWindow/NewTabButton.cs index cc324df59..636827df7 100644 --- a/PartPreviewWindow/NewTabButton.cs +++ b/PartPreviewWindow/NewTabButton.cs @@ -64,7 +64,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow public override void OnDraw(Graphics2D graphics2D) { - MainTab.DrawTabLowerLeft( + ChromeTab.DrawTabLowerLeft( graphics2D, this.LocalBounds, (parentTabControl.ActiveTab == this.LastTab) ? theme.ActiveTabColor : theme.InactiveTabColor); diff --git a/PartPreviewWindow/PartPreviewContent.cs b/PartPreviewWindow/PartPreviewContent.cs index 6e5a77aa1..31c85e524 100644 --- a/PartPreviewWindow/PartPreviewContent.cs +++ b/PartPreviewWindow/PartPreviewContent.cs @@ -46,7 +46,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow public class PartPreviewContent : FlowLayoutWidget { private EventHandler unregisterEvents; - private MainTab printerTab = null; + private ChromeTab printerTab = null; private ChromeTabs tabControl; public PartPreviewContent() @@ -168,7 +168,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow if (false && AppContext.IsLoading) { tabControl.AddTab( - new MainTab("New Tab".Localize(), tabControl, tabControl.NewTabPage(), theme) + new ChromeTab("New Tab".Localize(), tabControl, tabControl.NewTabPage(), theme) { MinimumSize = new Vector2(0, theme.shortButtonHeight) }); @@ -183,13 +183,13 @@ namespace MatterHackers.MatterControl.PartPreviewWindow }, ref unregisterEvents); } - private MainTab CreatePrinterTab(PrinterConfig printer, ThemeConfig theme, string tabTitle) + private ChromeTab CreatePrinterTab(PrinterConfig printer, ThemeConfig theme, string tabTitle) { string oemName = printer.Settings.GetValue(SettingsKey.make); OemSettings.Instance.OemUrls.TryGetValue(oemName, out string oemUrl); - return new MainTab( + return new ChromeTab( tabTitle, tabControl, new PrinterTabPage(printer, theme, tabTitle.ToUpper()), @@ -201,9 +201,9 @@ namespace MatterHackers.MatterControl.PartPreviewWindow }; } - public MainTab CreatePartTab(string tabTitle, BedConfig sceneContext, ThemeConfig theme) + public ChromeTab CreatePartTab(string tabTitle, BedConfig sceneContext, ThemeConfig theme) { - var partTab = new MainTab( + var partTab = new ChromeTab( tabTitle, tabControl, new PartTabPage(null, sceneContext, theme, "xxxxx"), diff --git a/PartPreviewWindow/Toolbar.cs b/PartPreviewWindow/Toolbar.cs index 5faee850b..6080e0391 100644 --- a/PartPreviewWindow/Toolbar.cs +++ b/PartPreviewWindow/Toolbar.cs @@ -108,6 +108,8 @@ namespace MatterHackers.MatterControl.PartPreviewWindow public IEnumerable AllTabs => _allTabs; + public int TabCount => _allTabs.Count; + public void AddTab(GuiWidget tabWidget, int position) { var iTab = tabWidget as ITab; @@ -124,6 +126,16 @@ namespace MatterHackers.MatterControl.PartPreviewWindow private void TabWidget_Click(object sender, MouseEventArgs e) { this.ActiveTab = sender as ITab; + //this.SelectedTabIndex = this.Children.IndexOf(sender as GuiWidget); + } + + public int SelectedTabIndex + { + get => _allTabs.IndexOf(this.ActiveTab); + set + { + this.ActiveTab = _allTabs[value]; + } } internal void RemoveTab(ITab tab) @@ -179,8 +191,8 @@ namespace MatterHackers.MatterControl.PartPreviewWindow }; leadingTabAdornment.AfterDraw += (s, e) => { - var firstItem = this.AllTabs.OfType().FirstOrDefault(); - MainTab.DrawTabLowerRight(e.graphics2D, leadingTabAdornment.LocalBounds, (firstItem == this.ActiveTab) ? theme.ActiveTabColor : theme.InactiveTabColor); + var firstItem = this.AllTabs.OfType().FirstOrDefault(); + ChromeTab.DrawTabLowerRight(e.graphics2D, leadingTabAdornment.LocalBounds, (firstItem == this.ActiveTab) ? theme.ActiveTabColor : theme.InactiveTabColor); }; this.TabBar.ActionArea.AddChild(leadingTabAdornment); @@ -197,7 +209,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow plusTabButton.IconButton.Click += (s, e) => { this.AddTab( - new MainTab("New Tab".Localize(), this, this.NewTabPage(), theme) + new ChromeTab("New Tab".Localize(), this, this.NewTabPage(), theme) { MinimumSize = new Vector2(0, theme.shortButtonHeight) }); @@ -210,9 +222,9 @@ namespace MatterHackers.MatterControl.PartPreviewWindow { var position = this.TabBar.ActionArea.GetChildIndex(plusTabButton); - if (tab is MainTab mainTab) + if (tab is ChromeTab mainTab) { - mainTab.PreviousTab = this.AllTabs.OfType().LastOrDefault(); + mainTab.PreviousTab = this.AllTabs.OfType().LastOrDefault(); if (mainTab.PreviousTab != null) { mainTab.PreviousTab.NextTab = mainTab; diff --git a/SlicerConfiguration/SliceSettingsWidget.cs b/SlicerConfiguration/SliceSettingsWidget.cs index 52a86271a..580589488 100644 --- a/SlicerConfiguration/SliceSettingsWidget.cs +++ b/SlicerConfiguration/SliceSettingsWidget.cs @@ -34,13 +34,14 @@ using MatterHackers.Agg; using MatterHackers.Agg.UI; using MatterHackers.Localizations; using MatterHackers.MatterControl.CustomWidgets; +using MatterHackers.MatterControl.PartPreviewWindow; using MatterHackers.VectorMath; namespace MatterHackers.MatterControl.SlicerConfiguration { public class SliceSettingsWidget : FlowLayoutWidget { - private TabControl primaryTabControl; + private SimpleTabs primaryTabControl; internal PresetsToolbar settingsControlBar; internal SettingsContext settingsContext; @@ -101,63 +102,60 @@ namespace MatterHackers.MatterControl.SlicerConfiguration // Close and remove children primaryTabControl?.Close(); - primaryTabControl = new TabControl(); - primaryTabControl.TabBar.BorderColor = ActiveTheme.Instance.PrimaryTextColor; - primaryTabControl.Margin = new BorderDouble(top: 8); - primaryTabControl.AnchorAll(); + var rightItem = (settingsContext.IsPrimarySettingsView) ? new SliceSettingsOverflowMenu(printer, this) : new GuiWidget(); + primaryTabControl = new SimpleTabs(rightItem, theme) + { + Margin = new BorderDouble(top: 8), + VAnchor = VAnchor.Stretch, + HAnchor = HAnchor.Stretch, + MinimumSize = new Vector2(200, 200) + }; + primaryTabControl.TabBar.BackgroundColor = theme.ActiveTabColor.AdjustLightness(0.85).ToColor(); for (int topCategoryIndex = 0; topCategoryIndex < SliceSettingsOrganizer.Instance.UserLevels[UserLevel].CategoriesList.Count; topCategoryIndex++) { OrganizerCategory category = SliceSettingsOrganizer.Instance.UserLevels[UserLevel].CategoriesList[topCategoryIndex]; - if (category.Name == "Printer" && (settingsContext.ViewFilter == NamedSettingsLayers.Material || settingsContext.ViewFilter == NamedSettingsLayers.Quality)) { continue; } - var categoryPage = new TabPage(category.Name.Localize()); - categoryPage.AnchorAll(); + var content = CreateSideTabsAndPages(category, this.ShowHelpControls); + content.BackgroundColor = theme.ActiveTabColor; - primaryTabControl.AddTab(new TextTab( - categoryPage, - category.Name + " Tab", - theme.FontSize11, // TODO: Short term workaround for tests until new tabs and overflow menu come in - ActiveTheme.Instance.TabLabelSelected, - new Color(), - ActiveTheme.Instance.TabLabelUnselected, - new Color(), - useUnderlineStyling: true)); - - var sideTabs = CreateSideTabsAndPages(category, this.ShowHelpControls); - sideTabs.MinimumSize = new Vector2(200, 200); - categoryPage.AddChild(sideTabs); + primaryTabControl.AddTab( + new ToolTab(category.Name.Localize(), + primaryTabControl, + content, + theme, + hasClose: false) + { + Name = category.Name + " Tab", + InactiveTabColor = Color.Transparent, + ActiveTabColor = theme.ActiveTabColor + }); } primaryTabControl.TabBar.AddChild(new HorizontalSpacer()); - if (settingsContext.IsPrimarySettingsView) - { - // Add the Overflow menu - primaryTabControl.TabBar.AddChild(new SliceSettingsOverflowMenu(printer, this) - { - Margin = new BorderDouble(right: theme.ToolbarPadding.Right) - }); - } - this.AddChild(primaryTabControl); // Restore the last selected tab - primaryTabControl.SelectTab(UserSettings.Instance.get(UserSettingsKey.SliceSettingsWidget_CurrentTab)); + if (int.TryParse(UserSettings.Instance.get(UserSettingsKey.SliceSettingsWidget_CurrentTab), out int tabIndex) + && tabIndex >= 0 + && tabIndex < primaryTabControl.TabCount - 1) + { + primaryTabControl.SelectedTabIndex = tabIndex; + } // Store the last selected tab on change - primaryTabControl.TabBar.TabIndexChanged += (s, e) => + primaryTabControl.ActiveTabChanged += (s, e) => { - if (!string.IsNullOrEmpty(primaryTabControl.TabBar.SelectedTabName) - && settingsContext.IsPrimarySettingsView) + if (settingsContext.IsPrimarySettingsView) { - UserSettings.Instance.set(UserSettingsKey.SliceSettingsWidget_CurrentTab, primaryTabControl.TabBar.SelectedTabName); + UserSettings.Instance.set(UserSettingsKey.SliceSettingsWidget_CurrentTab, primaryTabControl.SelectedTabIndex.ToString()); } }; } From a4f86cccda9c868db30f7bb0a37f46d09e00f60c Mon Sep 17 00:00:00 2001 From: John Lewin Date: Mon, 8 Jan 2018 13:38:47 -0800 Subject: [PATCH 2/5] Use new tab styling - Issue MatterHackers/MCCentral#2607 Use new tab styling for DockingTabs --- CustomWidgets/DockingTabControl.cs | 49 ++++++++++++---------- PartPreviewWindow/MainTab.cs | 4 +- PartPreviewWindow/Toolbar.cs | 2 +- SlicerConfiguration/SliceSettingsWidget.cs | 2 +- 4 files changed, 30 insertions(+), 27 deletions(-) diff --git a/CustomWidgets/DockingTabControl.cs b/CustomWidgets/DockingTabControl.cs index ade35159c..fa67cb16e 100644 --- a/CustomWidgets/DockingTabControl.cs +++ b/CustomWidgets/DockingTabControl.cs @@ -157,7 +157,7 @@ namespace MatterHackers.MatterControl.CustomWidgets this.RemoveAllChildren(); - TabControl tabControl = null; + SimpleTabs tabControl = null; if (this.ControlIsPinned) { var resizePage = new ResizeContainer(this) @@ -168,7 +168,18 @@ namespace MatterHackers.MatterControl.CustomWidgets SplitterWidth = theme.SplitterWidth, }; - tabControl = theme.CreateTabControl(); + tabControl = new SimpleTabs(this.CreatePinButton(), theme) + { + VAnchor = VAnchor.Stretch, + HAnchor = HAnchor.Stretch, + }; + tabControl.TabBar.BackgroundColor = theme.ActiveTabColor.AdjustLightness(0.9).ToColor(); + + tabControl.ActiveTabChanged += (s, e) => + { + printer.ViewState.SliceSettingsTabIndex = tabControl.SelectedTabIndex; + }; + resizePage.AddChild(tabControl); this.AddChild(resizePage); @@ -183,24 +194,19 @@ namespace MatterHackers.MatterControl.CustomWidgets { var content = new DockingWindowContent(this, nameWidget.Value, tabTitle); - var tabPage = new TabPage(content, tabTitle); - var textTab = new TextTab( - tabPage, - tabTitle + " Tab", - 12, - ActiveTheme.Instance.TabLabelSelected, - Color.Transparent, - ActiveTheme.Instance.TabLabelUnselected, - Color.Transparent, - useUnderlineStyling: true); - - tabControl.AddTab(textTab); - - int localTabIndex = tabIndex; - textTab.Click += (s, e) => - { - printer.ViewState.SliceSettingsTabIndex = localTabIndex; - }; + tabControl.AddTab( + new ToolTab( + tabTitle, + tabControl, + content, + theme, + hasClose: false, + pointSize: theme.FontSize11) + { + Name = tabTitle + " Tab", + InactiveTabColor = Color.Transparent, + ActiveTabColor = theme.TabBodyBackground + }); } else // control is floating { @@ -291,9 +297,6 @@ namespace MatterHackers.MatterControl.CustomWidgets if (this.ControlIsPinned) { - tabControl.TabBar.AddChild(new HorizontalSpacer()); - tabControl.TabBar.AddChild(this.CreatePinButton()); - tabControl.TabBar.Padding = new BorderDouble(right: theme.ToolbarPadding.Right); if (printer.ViewState.SliceSettingsTabIndex < tabControl.TabCount) diff --git a/PartPreviewWindow/MainTab.cs b/PartPreviewWindow/MainTab.cs index e0c5bc2c1..9cdf4452c 100644 --- a/PartPreviewWindow/MainTab.cs +++ b/PartPreviewWindow/MainTab.cs @@ -139,8 +139,8 @@ namespace MatterHackers.MatterControl.PartPreviewWindow { public Color InactiveTabColor { get; set; } public Color ActiveTabColor { get; set; } - public ToolTab(string tabLabel, SimpleTabs parentTabControl, GuiWidget tabContent, ThemeConfig theme, string tabImageUrl = null, bool hasClose = true) - : base(tabLabel, parentTabControl, tabContent, theme, tabImageUrl, hasClose, theme.FontSize10) + public ToolTab(string tabLabel, SimpleTabs parentTabControl, GuiWidget tabContent, ThemeConfig theme, string tabImageUrl = null, bool hasClose = true, int pointSize = -1) + : base(tabLabel, parentTabControl, tabContent, theme, tabImageUrl, hasClose, pointSize: (pointSize == -1) ? theme.FontSize10 : pointSize) { tabPill.Padding = tabPill.Padding.Clone(top: 9, bottom: 10); } diff --git a/PartPreviewWindow/Toolbar.cs b/PartPreviewWindow/Toolbar.cs index 6080e0391..d60228286 100644 --- a/PartPreviewWindow/Toolbar.cs +++ b/PartPreviewWindow/Toolbar.cs @@ -110,7 +110,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow public int TabCount => _allTabs.Count; - public void AddTab(GuiWidget tabWidget, int position) + public void AddTab(GuiWidget tabWidget, int position = -1) { var iTab = tabWidget as ITab; diff --git a/SlicerConfiguration/SliceSettingsWidget.cs b/SlicerConfiguration/SliceSettingsWidget.cs index 580589488..149c43e20 100644 --- a/SlicerConfiguration/SliceSettingsWidget.cs +++ b/SlicerConfiguration/SliceSettingsWidget.cs @@ -111,7 +111,7 @@ namespace MatterHackers.MatterControl.SlicerConfiguration HAnchor = HAnchor.Stretch, MinimumSize = new Vector2(200, 200) }; - primaryTabControl.TabBar.BackgroundColor = theme.ActiveTabColor.AdjustLightness(0.85).ToColor(); + primaryTabControl.TabBar.BackgroundColor = theme.ActiveTabColor.AdjustLightness(0.9).ToColor(); for (int topCategoryIndex = 0; topCategoryIndex < SliceSettingsOrganizer.Instance.UserLevels[UserLevel].CategoriesList.Count; topCategoryIndex++) { From 5b520e880e7a9d949fe1766248659d3dc5eeddef Mon Sep 17 00:00:00 2001 From: John Lewin Date: Mon, 8 Jan 2018 14:28:52 -0800 Subject: [PATCH 3/5] Revise tab bar background colors --- ApplicationView/ThemeConfig.cs | 6 ++++-- ApplicationView/WidescreenPanel.cs | 15 +++++++++------ CustomWidgets/DockingTabControl.cs | 4 ++-- PartPreviewWindow/MainTab.cs | 15 +++++++++++++-- PartPreviewWindow/PartPreviewContent.cs | 18 ++++-------------- PartPreviewWindow/Toolbar.cs | 10 +++++----- .../View3D/PrinterBar/OverflowBar.cs | 1 - SlicerConfiguration/SliceSettingsWidget.cs | 8 ++++++-- 8 files changed, 43 insertions(+), 34 deletions(-) diff --git a/ApplicationView/ThemeConfig.cs b/ApplicationView/ThemeConfig.cs index d75f0bced..b99143c64 100644 --- a/ApplicationView/ThemeConfig.cs +++ b/ApplicationView/ThemeConfig.cs @@ -108,6 +108,7 @@ namespace MatterHackers.MatterControl public Color ActiveTabColor { get; set; } public Color InactiveTabColor { get; set; } + public Color ActiveTabBarBackground { get; set; } public TextImageButtonFactory DisableableControlBase { get; private set; } public TextImageButtonFactory HomingButtons { get; private set; } @@ -165,14 +166,15 @@ namespace MatterHackers.MatterControl commonOptions.BorderWidth = 0; commonOptions.FixedHeight = 32; - this.ActiveTabColor = ResolveColor(theme.PrimaryBackgroundColor, new Color(Color.Black, this.SlightShade.alpha)); - this.TabBodyBackground = this.ResolveColor( ActiveTheme.Instance.TertiaryBackgroundColor, new Color( Color.White, (ActiveTheme.Instance.IsDarkTheme) ? 3 : 25)); + this.ActiveTabColor = this.TabBodyBackground; + this.ActiveTabBarBackground = this.ActiveTabColor.AdjustLightness(0.85).ToColor(); + // Active tab color with slight transparency this.InteractionLayerOverlayColor = new Color(this.ActiveTabColor, 200); diff --git a/ApplicationView/WidescreenPanel.cs b/ApplicationView/WidescreenPanel.cs index 1aeccdfde..8f65a3dce 100644 --- a/ApplicationView/WidescreenPanel.cs +++ b/ApplicationView/WidescreenPanel.cs @@ -73,19 +73,22 @@ namespace MatterHackers.MatterControl var leftNav = new FlowLayoutWidget(FlowDirection.TopToBottom); leftNav.AnchorAll(); - var toolbar = new Toolbar(null, theme) + var toolbar = new Toolbar() { HAnchor = HAnchor.Stretch, VAnchor = VAnchor.Fit, - MinimumSize = new Vector2(16, 16) + MinimumSize = new Vector2(16, 16), + BackgroundColor = theme.ActiveTabBarBackground, + BorderColor = theme.ActiveTabColor, + Border = 0 //new BorderDouble(bottom: 2), }; - toolbar.BorderColor = ApplicationController.Instance.Theme.SlightShade; - toolbar.Border = new BorderDouble(bottom: 2); toolbar.ActionArea.AddChild(new BrandMenuButton(theme) { - MinimumSize = new VectorMath.Vector2(0, 34), + MinimumSize = new Vector2(0, 34), HAnchor = HAnchor.Stretch, - VAnchor = VAnchor.Fit + VAnchor = VAnchor.Fit, + Border = new BorderDouble(right: 1), + BorderColor = theme.MinimalShade }); leftNav.AddChild(toolbar); diff --git a/CustomWidgets/DockingTabControl.cs b/CustomWidgets/DockingTabControl.cs index fa67cb16e..ccd11cd6d 100644 --- a/CustomWidgets/DockingTabControl.cs +++ b/CustomWidgets/DockingTabControl.cs @@ -168,12 +168,12 @@ namespace MatterHackers.MatterControl.CustomWidgets SplitterWidth = theme.SplitterWidth, }; - tabControl = new SimpleTabs(this.CreatePinButton(), theme) + tabControl = new SimpleTabs(this.CreatePinButton()) { VAnchor = VAnchor.Stretch, HAnchor = HAnchor.Stretch, }; - tabControl.TabBar.BackgroundColor = theme.ActiveTabColor.AdjustLightness(0.9).ToColor(); + tabControl.TabBar.BackgroundColor = theme.ActiveTabBarBackground; tabControl.ActiveTabChanged += (s, e) => { diff --git a/PartPreviewWindow/MainTab.cs b/PartPreviewWindow/MainTab.cs index 9cdf4452c..59618e734 100644 --- a/PartPreviewWindow/MainTab.cs +++ b/PartPreviewWindow/MainTab.cs @@ -139,17 +139,28 @@ namespace MatterHackers.MatterControl.PartPreviewWindow { public Color InactiveTabColor { get; set; } public Color ActiveTabColor { get; set; } + + public override Color BorderColor + { + get => (this.IsActiveTab) ? ActiveTheme.Instance.PrimaryAccentColor : base.BorderColor; + set => base.BorderColor = value; + } + public ToolTab(string tabLabel, SimpleTabs parentTabControl, GuiWidget tabContent, ThemeConfig theme, string tabImageUrl = null, bool hasClose = true, int pointSize = -1) : base(tabLabel, parentTabControl, tabContent, theme, tabImageUrl, hasClose, pointSize: (pointSize == -1) ? theme.FontSize10 : pointSize) { - tabPill.Padding = tabPill.Padding.Clone(top: 9, bottom: 10); + this.Border = new BorderDouble(top: 1); + + tabPill.Padding = tabPill.Padding.Clone(top: 8, bottom: 10); } + private bool IsActiveTab => this == parentTabControl.ActiveTab; + public override void OnDraw(Graphics2D graphics2D) { graphics2D.Render( new RoundedRect(this.LocalBounds, 0), - (this == parentTabControl.ActiveTab) ? this.ActiveTabColor : this.InactiveTabColor); + (this.IsActiveTab) ? this.ActiveTabColor : this.InactiveTabColor); base.OnDraw(graphics2D); } diff --git a/PartPreviewWindow/PartPreviewContent.cs b/PartPreviewWindow/PartPreviewContent.cs index 31c85e524..77a03e1cf 100644 --- a/PartPreviewWindow/PartPreviewContent.cs +++ b/PartPreviewWindow/PartPreviewContent.cs @@ -64,11 +64,14 @@ namespace MatterHackers.MatterControl.PartPreviewWindow VAnchor = VAnchor.Stretch, HAnchor = HAnchor.Stretch, BackgroundColor = ActiveTheme.Instance.PrimaryBackgroundColor, + BorderColor = theme.MinimalShade, + Border = new BorderDouble(left: 1), NewTabPage = () => { return new PlusTabPage(this, tabControl, theme); } }; + tabControl.TabBar.BackgroundColor = theme.ActiveTabBarBackground; tabControl.ActiveTabChanged += (s, e) => { @@ -84,7 +87,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow tabControl.TabBar.BorderColor = theme.ActiveTabColor; tabControl.TabBar.Padding = new BorderDouble(top: 4); - tabControl.TabBar.Border = new BorderDouble(bottom: 2); + //tabControl.TabBar.Border = new BorderDouble(bottom: 2); Color selectedTabColor = ActiveTheme.Instance.TabLabelSelected; @@ -135,19 +138,6 @@ namespace MatterHackers.MatterControl.PartPreviewWindow updateAvailableButton.Visible = UpdateControlData.Instance.UpdateStatus == UpdateControlData.UpdateStatusStates.UpdateAvailable; }, ref unregisterEvents); - // this causes the update button to be centered - //tabControl.TabBar.AddChild(new HorizontalSpacer()); - - //rightPanelArea.AddChild( - // new ImageWidget( - // AggContext.StaticData.LoadImage(Path.Combine("Images", "minimize.png"))) - // { - // VAnchor = VAnchor.Top, - // DebugShowBounds = true - // }); - - //this.AddChild(tabControl); - this.AddChild(tabControl); ActiveSliceSettings.SettingChanged.RegisterEvent((s, e) => diff --git a/PartPreviewWindow/Toolbar.cs b/PartPreviewWindow/Toolbar.cs index d60228286..6aa09a8f9 100644 --- a/PartPreviewWindow/Toolbar.cs +++ b/PartPreviewWindow/Toolbar.cs @@ -46,7 +46,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow { public FlowLayoutWidget ActionArea { get; } - public Toolbar(GuiWidget rightAnchorItem, ThemeConfig theme, bool bottomBorder = true) + public Toolbar(GuiWidget rightAnchorItem = null) { this.ActionArea = new FlowLayoutWidget() { @@ -86,10 +86,10 @@ namespace MatterHackers.MatterControl.PartPreviewWindow private GuiWidget body; - public SimpleTabs(GuiWidget rightAnchorItem, ThemeConfig theme, bool bottomBorder = true) + public SimpleTabs(GuiWidget rightAnchorItem) : base(FlowDirection.TopToBottom) { - this.AddChild(TabBar = new Toolbar(rightAnchorItem, theme, bottomBorder) + this.AddChild(TabBar = new Toolbar(rightAnchorItem) { HAnchor = HAnchor.Stretch, VAnchor = VAnchor.Fit @@ -181,12 +181,12 @@ namespace MatterHackers.MatterControl.PartPreviewWindow private NewTabButton plusTabButton; public ChromeTabs(GuiWidget rightAnchorItem, ThemeConfig theme) - : base(rightAnchorItem, theme) + : base(rightAnchorItem) { // TODO: add in the printers and designs that are currently open (or were open last run). var leadingTabAdornment = new GuiWidget() { - MinimumSize = new VectorMath.Vector2(16, theme.shortButtonHeight), + MinimumSize = new Vector2(16, theme.shortButtonHeight), VAnchor = VAnchor.Bottom }; leadingTabAdornment.AfterDraw += (s, e) => diff --git a/PartPreviewWindow/View3D/PrinterBar/OverflowBar.cs b/PartPreviewWindow/View3D/PrinterBar/OverflowBar.cs index 128fada8e..5dffa1ab4 100644 --- a/PartPreviewWindow/View3D/PrinterBar/OverflowBar.cs +++ b/PartPreviewWindow/View3D/PrinterBar/OverflowBar.cs @@ -38,7 +38,6 @@ namespace MatterHackers.MatterControl.PartPreviewWindow public class OverflowBar : Toolbar { public OverflowBar(ThemeConfig theme, GuiWidget viewWidget = null) - : base(null, theme) { this.Padding = theme.ToolbarPadding.Clone(left: 0); diff --git a/SlicerConfiguration/SliceSettingsWidget.cs b/SlicerConfiguration/SliceSettingsWidget.cs index 149c43e20..b8257734c 100644 --- a/SlicerConfiguration/SliceSettingsWidget.cs +++ b/SlicerConfiguration/SliceSettingsWidget.cs @@ -104,14 +104,14 @@ namespace MatterHackers.MatterControl.SlicerConfiguration var rightItem = (settingsContext.IsPrimarySettingsView) ? new SliceSettingsOverflowMenu(printer, this) : new GuiWidget(); - primaryTabControl = new SimpleTabs(rightItem, theme) + primaryTabControl = new SimpleTabs(rightItem) { Margin = new BorderDouble(top: 8), VAnchor = VAnchor.Stretch, HAnchor = HAnchor.Stretch, MinimumSize = new Vector2(200, 200) }; - primaryTabControl.TabBar.BackgroundColor = theme.ActiveTabColor.AdjustLightness(0.9).ToColor(); + primaryTabControl.TabBar.BackgroundColor = theme.ActiveTabBarBackground; for (int topCategoryIndex = 0; topCategoryIndex < SliceSettingsOrganizer.Instance.UserLevels[UserLevel].CategoriesList.Count; topCategoryIndex++) { @@ -149,6 +149,10 @@ namespace MatterHackers.MatterControl.SlicerConfiguration { primaryTabControl.SelectedTabIndex = tabIndex; } + else + { + primaryTabControl.SelectedTabIndex = 0; + } // Store the last selected tab on change primaryTabControl.ActiveTabChanged += (s, e) => From dea37667add4e34f179fbc78c7e5d57eebb4a6a5 Mon Sep 17 00:00:00 2001 From: John Lewin Date: Mon, 8 Jan 2018 15:45:15 -0800 Subject: [PATCH 4/5] Remove network image - Issue MatterHackers/MCCentral#2609 Remove network linked image --- PartPreviewWindow/MainTab.cs | 52 +++++++++++++++++-------- PartPreviewWindow/PartPreviewContent.cs | 2 +- 2 files changed, 37 insertions(+), 17 deletions(-) diff --git a/PartPreviewWindow/MainTab.cs b/PartPreviewWindow/MainTab.cs index 59618e734..4fac1a836 100644 --- a/PartPreviewWindow/MainTab.cs +++ b/PartPreviewWindow/MainTab.cs @@ -49,7 +49,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow public GuiWidget TabContent { get; protected set; } - public SimpleTab(string tabLabel, SimpleTabs parentTabControl, GuiWidget tabContent, ThemeConfig theme, string tabImageUrl = null, bool hasClose = true, double pointSize = 12) + public SimpleTab(string tabLabel, SimpleTabs parentTabControl, GuiWidget tabContent, ThemeConfig theme, string tabImageUrl = null, bool hasClose = true, double pointSize = 12, ImageBuffer iconImage = null) { this.HAnchor = HAnchor.Fit; this.VAnchor = VAnchor.Fit | VAnchor.Bottom; @@ -60,11 +60,17 @@ namespace MatterHackers.MatterControl.PartPreviewWindow this.TabContent = tabContent; this.parentTabControl = parentTabControl; - this.AddChild( - tabPill = new TabPill(tabLabel, ActiveTheme.Instance.PrimaryTextColor, tabImageUrl, pointSize) - { - Margin = (hasClose) ? new BorderDouble(right: 16) : 0 - }); + if (iconImage != null) + { + tabPill = new TabPill(tabLabel, ActiveTheme.Instance.PrimaryTextColor, iconImage, pointSize); + } + else + { + tabPill = new TabPill(tabLabel, ActiveTheme.Instance.PrimaryTextColor, tabImageUrl, pointSize); + } + tabPill.Margin = (hasClose) ? new BorderDouble(right: 16) : 0; + + this.AddChild(tabPill); if (hasClose) { @@ -89,28 +95,37 @@ namespace MatterHackers.MatterControl.PartPreviewWindow protected class TabPill : FlowLayoutWidget { private TextWidget label; + private ImageWidget imageWidget; public TabPill(string tabTitle, Color textColor, string imageUrl = null, double pointSize = 12) + : this (tabTitle, textColor, string.IsNullOrEmpty(imageUrl) ? null : new ImageBuffer(16, 16), pointSize) + { + if (imageWidget != null + && !string.IsNullOrEmpty(imageUrl)) + { + try + { + // TODO: Use caching + // Attempt to load image + ApplicationController.Instance.DownloadToImageAsync(imageWidget.Image, imageUrl, false); + } + catch { } + } + } + + public TabPill(string tabTitle, Color textColor, ImageBuffer imageBuffer = null, double pointSize = 12) { this.Selectable = false; this.Padding = new BorderDouble(10, 5, 10, 4); - if (!string.IsNullOrEmpty(imageUrl)) + if (imageBuffer != null) { - var imageWidget = new ImageWidget(new ImageBuffer(16, 16)) + imageWidget = new ImageWidget(imageBuffer) { Margin = new BorderDouble(right: 6, bottom: 2), VAnchor = VAnchor.Center }; this.AddChild(imageWidget); - - // Attempt to load image - try - { - // TODO: Must use caching - ApplicationController.Instance.DownloadToImageAsync(imageWidget.Image, imageUrl, false); - } - catch { } } label = new TextWidget(tabTitle, pointSize: pointSize) @@ -173,6 +188,11 @@ namespace MatterHackers.MatterControl.PartPreviewWindow { } + public ChromeTab(string tabLabel, SimpleTabs parentTabControl, GuiWidget tabContent, ThemeConfig theme, ImageBuffer imageBuffer) + : base(tabLabel, parentTabControl, tabContent, theme, iconImage: imageBuffer) + { + } + private static int tabInsetDistance = 14 / 2; internal ChromeTab NextTab { get; set; } diff --git a/PartPreviewWindow/PartPreviewContent.cs b/PartPreviewWindow/PartPreviewContent.cs index 77a03e1cf..df951a2f4 100644 --- a/PartPreviewWindow/PartPreviewContent.cs +++ b/PartPreviewWindow/PartPreviewContent.cs @@ -198,7 +198,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow tabControl, new PartTabPage(null, sceneContext, theme, "xxxxx"), theme, - "https://i.imgur.com/nkeYgfU.png") + AggContext.StaticData.LoadIcon("part.png")) { Name = "newPart" + tabControl.AllTabs.Count(), MinimumSize = new Vector2(120, theme.shortButtonHeight) From 01221d9d9564669d09569fde6043728d6858362c Mon Sep 17 00:00:00 2001 From: John Lewin Date: Mon, 8 Jan 2018 16:13:57 -0800 Subject: [PATCH 5/5] Add close x to Configure -> Printer - Issue MatterHackers/MCCentral#2572 --- CustomWidgets/DockingTabControl.cs | 29 +++++++++++++++++++++-------- PartPreviewWindow/MainTab.cs | 2 +- StaticData/Icons/part.png | Bin 0 -> 1089 bytes 3 files changed, 22 insertions(+), 9 deletions(-) create mode 100644 StaticData/Icons/part.png diff --git a/CustomWidgets/DockingTabControl.cs b/CustomWidgets/DockingTabControl.cs index ccd11cd6d..7859b0114 100644 --- a/CustomWidgets/DockingTabControl.cs +++ b/CustomWidgets/DockingTabControl.cs @@ -186,27 +186,36 @@ namespace MatterHackers.MatterControl.CustomWidgets } int tabIndex = 0; - foreach (var nameWidget in allTabs) + foreach (var kvp in allTabs) { - string tabTitle = nameWidget.Key; + string tabTitle = kvp.Key; if (this.ControlIsPinned) { - var content = new DockingWindowContent(this, nameWidget.Value, tabTitle); + var content = new DockingWindowContent(this, kvp.Value, tabTitle); - tabControl.AddTab( - new ToolTab( + var tab = new ToolTab( tabTitle, tabControl, content, theme, - hasClose: false, + hasClose: kvp.Value is ConfigurePrinterWidget, pointSize: theme.FontSize11) { Name = tabTitle + " Tab", InactiveTabColor = Color.Transparent, ActiveTabColor = theme.TabBodyBackground - }); + }; + + tab.CloseClicked += (s, e) => + { + if (tab.Name == "Printer Tab") + { + printer.ViewState.ConfigurePrinterVisible = false; + } + }; + + tabControl.AddTab(tab); } else // control is floating { @@ -247,7 +256,7 @@ namespace MatterHackers.MatterControl.CustomWidgets SpliterBarColor = spliterColor, SplitterWidth = ApplicationController.Instance.Theme.SplitterWidth, }; - resizeContainer.AddChild(new DockingWindowContent(this, nameWidget.Value, tabTitle) + resizeContainer.AddChild(new DockingWindowContent(this, kvp.Value, tabTitle) { BackgroundColor = ActiveTheme.Instance.PrimaryBackgroundColor, Width = PageWidth @@ -303,6 +312,10 @@ namespace MatterHackers.MatterControl.CustomWidgets { tabControl.SelectedTabIndex = printer.ViewState.SliceSettingsTabIndex; } + else + { + tabControl.SelectedTabIndex = 0; + } } } diff --git a/PartPreviewWindow/MainTab.cs b/PartPreviewWindow/MainTab.cs index 4fac1a836..adee6b5e2 100644 --- a/PartPreviewWindow/MainTab.cs +++ b/PartPreviewWindow/MainTab.cs @@ -166,7 +166,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow { this.Border = new BorderDouble(top: 1); - tabPill.Padding = tabPill.Padding.Clone(top: 8, bottom: 10); + tabPill.Padding = tabPill.Padding.Clone(top: 10, bottom: 10); } private bool IsActiveTab => this == parentTabControl.ActiveTab; diff --git a/StaticData/Icons/part.png b/StaticData/Icons/part.png new file mode 100644 index 0000000000000000000000000000000000000000..7c09c5d9569c0f79de9780566af9f4cc59afb424 GIT binary patch literal 1089 zcmeAS@N?(olHy`uVBq!ia0y~yU=RRd4mJh`2Kmqb6B!s7r87e!N+NuHtdjF{^%7I^ zlT!66atjzhz{b9!ATc>RwL~E)H9a%WR_Xoj{Yna%DYi=CroINg16w1-Ypui3%0DIeEoa6}C!XbFK1lpi<;HsXMd|v6mX?*7iAWdWaj57fXqxx$}cUkRZ`LiS)vaT z3373>d^5JbI{r61SGzE_k!|&d8H=(i zA9_A~xphz0r@n&ele*S%%;(%~x^uyYxhs#K`jb_(>CAn#?1upiI_%%FS-S4uv`yA45L|c{#VEzaYFn%`NT= zKC?wlKV`dmPVpy(howJPW#72nUe~!@|35=>Li*>Gb3g56U|`@Z@Q5sCVBk9f!i-b3 z`J@>b7;QaW978O6*IwT5JvC9{*vIp$8)qlT{AXs%18}@f}eCBg#6RDW!%WP@W y8n`A&O{wqytjEiOylhYPmv*E_^mpvldT&~1>0S13$@KN0obT!C=d#Wzp$Py~wa}UX literal 0 HcmV?d00001