From b4c60871ad76baaa57d897ddb60178dff30ecefc Mon Sep 17 00:00:00 2001 From: John Lewin Date: Thu, 3 Aug 2017 07:19:27 -0700 Subject: [PATCH 1/6] Revise 'Solid' button view construction --- PartPreviewWindow/View3D/GeneralObject3DEditor.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/PartPreviewWindow/View3D/GeneralObject3DEditor.cs b/PartPreviewWindow/View3D/GeneralObject3DEditor.cs index 8a20bed4f..3ee66ac7c 100644 --- a/PartPreviewWindow/View3D/GeneralObject3DEditor.cs +++ b/PartPreviewWindow/View3D/GeneralObject3DEditor.cs @@ -59,8 +59,8 @@ namespace MatterHackers.MatterControl.PartPreviewWindow mainContainer.AddChild(behavior3DTypeButtons); // put in the button for making the behavior solid - Button createdButton; - var solidBehaviorButton = new PopupButton(createdButton = theme.ButtonFactory.Generate("Solid".Localize())) + Button solidButtonView = theme.ButtonFactory.Generate("Solid".Localize()); + var solidBehaviorButton = new PopupButton(solidButtonView) { Name = "Solid Colors", AlignToRightEdge = true, @@ -72,7 +72,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow }, Margin = new BorderDouble(0, 5) }; - createdButton.Click += (s, e) => + solidButtonView.Click += (s, e) => { item.OutputType = PrintOutputTypes.Solid; }; From 77daf0ff50f05df7ad359e0addfe84b244387cfe Mon Sep 17 00:00:00 2001 From: John Lewin Date: Thu, 3 Aug 2017 07:28:22 -0700 Subject: [PATCH 2/6] Remove unused button factory --- ApplicationView/ThemeConfig.cs | 20 -------------------- 1 file changed, 20 deletions(-) diff --git a/ApplicationView/ThemeConfig.cs b/ApplicationView/ThemeConfig.cs index f71584fe4..595fb7d22 100644 --- a/ApplicationView/ThemeConfig.cs +++ b/ApplicationView/ThemeConfig.cs @@ -59,7 +59,6 @@ namespace MatterHackers.MatterControl public LinkButtonFactory LinkButtonFactory { get; private set; } public LinkButtonFactory HelpLinkFactory { get; private set; } - private TextImageButtonFactory checkboxButtonFactory; public TextImageButtonFactory ExpandMenuOptionFactory; public TextImageButtonFactory WhiteButtonFactory; @@ -233,25 +232,6 @@ namespace MatterHackers.MatterControl disabledFillColor = new RGBA_Bytes(255, 255, 255, 50) }; - checkboxButtonFactory = new TextImageButtonFactory() - { - fontSize = 11, - FixedWidth = sideBarButtonWidth, - borderWidth = 3, - - normalTextColor = ActiveTheme.Instance.PrimaryTextColor, - normalBorderColor = new RGBA_Bytes(0, 0, 0, 0), - normalFillColor = ActiveTheme.Instance.PrimaryBackgroundColor, - - hoverTextColor = ActiveTheme.Instance.PrimaryTextColor, - hoverBorderColor = new RGBA_Bytes(0, 0, 0, 50), - hoverFillColor = new RGBA_Bytes(0, 0, 0, 50), - - pressedTextColor = ActiveTheme.Instance.PrimaryTextColor, - pressedBorderColor = new RGBA_Bytes(0, 0, 0, 50), - - disabledTextColor = ActiveTheme.Instance.PrimaryTextColor - }; #endregion #region ImageConverter From b47d99fa7d605583946885cd8f7db9fc000f475a Mon Sep 17 00:00:00 2001 From: John Lewin Date: Thu, 3 Aug 2017 07:41:19 -0700 Subject: [PATCH 3/6] Switch factory setters to private accessor --- ApplicationView/ThemeConfig.cs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/ApplicationView/ThemeConfig.cs b/ApplicationView/ThemeConfig.cs index 595fb7d22..9209f439a 100644 --- a/ApplicationView/ThemeConfig.cs +++ b/ApplicationView/ThemeConfig.cs @@ -64,30 +64,30 @@ namespace MatterHackers.MatterControl private readonly int borderWidth = 1; - public TextImageButtonFactory ButtonFactory { get; internal set; } - public TextImageButtonFactory SmallMarginButtonFactory { get; internal set; } + public TextImageButtonFactory ButtonFactory { get; private set; } + public TextImageButtonFactory SmallMarginButtonFactory { get; private set; } /// /// Used to make buttons in menu rows where the background color is consistently white /// - public TextImageButtonFactory MenuButtonFactory { get; internal set; } + public TextImageButtonFactory MenuButtonFactory { get; private set; } /// /// Used in the Update wizard to show high contrast, primary action buttons /// - public TextImageButtonFactory GrayButtonFactory { get; internal set; } + public TextImageButtonFactory GrayButtonFactory { get; private set; } public TextImageButtonFactory imageConverterExpandMenuOptionFactory; public TextImageButtonFactory imageConverterButtonFactory; public RGBA_Bytes TabBodyBackground => new RGBA_Bytes(ActiveTheme.Instance.TertiaryBackgroundColor, 175); - public TextImageButtonFactory ViewControlsButtonFactory { get; internal set; } - public RGBA_Bytes SplitterBackground { get; internal set; } = new RGBA_Bytes(0, 0, 0, 60); + public TextImageButtonFactory ViewControlsButtonFactory { get; private set; } + public RGBA_Bytes SplitterBackground { get; private set; } = new RGBA_Bytes(0, 0, 0, 60); public int SplitterWidth => (int)(7 * (GuiWidget.DeviceScale <= 1 ? GuiWidget.DeviceScale : GuiWidget.DeviceScale * 1.4)); public RGBA_Bytes SlightShade { get; } = new RGBA_Bytes(0, 0, 0, 40); - public TextImageButtonFactory GCodeLayerButtons { get; internal set; } + public TextImageButtonFactory GCodeLayerButtons { get; private set; } private EventHandler unregisterEvents; From bedcf47d7dfa49d7f975ded396927f96490859a5 Mon Sep 17 00:00:00 2001 From: John Lewin Date: Thu, 3 Aug 2017 07:55:29 -0700 Subject: [PATCH 4/6] Remove unused button factory --- ApplicationView/ThemeConfig.cs | 9 --------- 1 file changed, 9 deletions(-) diff --git a/ApplicationView/ThemeConfig.cs b/ApplicationView/ThemeConfig.cs index 9209f439a..e304717f8 100644 --- a/ApplicationView/ThemeConfig.cs +++ b/ApplicationView/ThemeConfig.cs @@ -87,7 +87,6 @@ namespace MatterHackers.MatterControl public int SplitterWidth => (int)(7 * (GuiWidget.DeviceScale <= 1 ? GuiWidget.DeviceScale : GuiWidget.DeviceScale * 1.4)); public RGBA_Bytes SlightShade { get; } = new RGBA_Bytes(0, 0, 0, 40); - public TextImageButtonFactory GCodeLayerButtons { get; private set; } private EventHandler unregisterEvents; @@ -183,14 +182,6 @@ namespace MatterHackers.MatterControl checkedBorderColor = RGBA_Bytes.White }; - this.GCodeLayerButtons = new TextImageButtonFactory() - { - normalTextColor = ActiveTheme.Instance.PrimaryTextColor, - hoverTextColor = ActiveTheme.Instance.PrimaryTextColor, - disabledTextColor = ActiveTheme.Instance.PrimaryTextColor, - pressedTextColor = ActiveTheme.Instance.PrimaryTextColor - }; - #region PartPreviewWidget if (UserSettings.Instance.IsTouchScreen) { From 19448dac4348550b647322919cb2851f9405a00a Mon Sep 17 00:00:00 2001 From: John Lewin Date: Thu, 3 Aug 2017 07:58:25 -0700 Subject: [PATCH 5/6] Use local theme variable --- ApplicationView/ThemeConfig.cs | 40 +++++++++++++++++----------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/ApplicationView/ThemeConfig.cs b/ApplicationView/ThemeConfig.cs index e304717f8..eaae59b26 100644 --- a/ApplicationView/ThemeConfig.cs +++ b/ApplicationView/ThemeConfig.cs @@ -117,7 +117,7 @@ namespace MatterHackers.MatterControl { var theme = ActiveTheme.Instance; - DefaultThumbView.ThumbColor = new RGBA_Bytes(ActiveTheme.Instance.PrimaryTextColor, 30); + DefaultThumbView.ThumbColor = new RGBA_Bytes(theme.PrimaryTextColor, 30); this.ButtonFactory = new TextImageButtonFactory() { @@ -157,7 +157,7 @@ namespace MatterHackers.MatterControl this.GrayButtonFactory = new TextImageButtonFactory() { normalFillColor = RGBA_Bytes.Gray, - normalTextColor = ActiveTheme.Instance.PrimaryTextColor + normalTextColor = theme.PrimaryTextColor }; int buttonHeight; @@ -172,10 +172,10 @@ namespace MatterHackers.MatterControl this.ViewControlsButtonFactory = new TextImageButtonFactory() { - normalTextColor = ActiveTheme.Instance.PrimaryTextColor, - hoverTextColor = ActiveTheme.Instance.PrimaryTextColor, - disabledTextColor = ActiveTheme.Instance.PrimaryTextColor, - pressedTextColor = ActiveTheme.Instance.PrimaryTextColor, + normalTextColor = theme.PrimaryTextColor, + hoverTextColor = theme.PrimaryTextColor, + disabledTextColor = theme.PrimaryTextColor, + pressedTextColor = theme.PrimaryTextColor, FixedHeight = buttonHeight, FixedWidth = buttonHeight, AllowThemeToAdjustImage = false, @@ -206,17 +206,17 @@ namespace MatterHackers.MatterControl hoverFillColor = new RGBA_Bytes(255, 255, 255, 200), borderWidth = 1, - normalBorderColor = new RGBA_Bytes(ActiveTheme.Instance.PrimaryTextColor, 200), - hoverBorderColor = new RGBA_Bytes(ActiveTheme.Instance.PrimaryTextColor, 200) + normalBorderColor = new RGBA_Bytes(theme.PrimaryTextColor, 200), + hoverBorderColor = new RGBA_Bytes(theme.PrimaryTextColor, 200) }; ExpandMenuOptionFactory = new TextImageButtonFactory() { FixedWidth = sideBarButtonWidth, - normalTextColor = ActiveTheme.Instance.PrimaryTextColor, - hoverTextColor = ActiveTheme.Instance.PrimaryTextColor, - disabledTextColor = ActiveTheme.Instance.PrimaryTextColor, - pressedTextColor = ActiveTheme.Instance.PrimaryTextColor, + normalTextColor = theme.PrimaryTextColor, + hoverTextColor = theme.PrimaryTextColor, + disabledTextColor = theme.PrimaryTextColor, + pressedTextColor = theme.PrimaryTextColor, hoverFillColor = new RGBA_Bytes(255, 255, 255, 50), pressedFillColor = new RGBA_Bytes(255, 255, 255, 50), @@ -238,17 +238,17 @@ namespace MatterHackers.MatterControl hoverFillColor = new RGBA_Bytes(255, 255, 255, 200), borderWidth = 1, - normalBorderColor = new RGBA_Bytes(ActiveTheme.Instance.PrimaryTextColor, 200), - hoverBorderColor = new RGBA_Bytes(ActiveTheme.Instance.PrimaryTextColor, 200) + normalBorderColor = new RGBA_Bytes(theme.PrimaryTextColor, 200), + hoverBorderColor = new RGBA_Bytes(theme.PrimaryTextColor, 200) }; imageConverterExpandMenuOptionFactory = new TextImageButtonFactory() { FixedWidth = 200, - normalTextColor = ActiveTheme.Instance.PrimaryTextColor, - hoverTextColor = ActiveTheme.Instance.PrimaryTextColor, - disabledTextColor = ActiveTheme.Instance.PrimaryTextColor, - pressedTextColor = ActiveTheme.Instance.PrimaryTextColor, + normalTextColor = theme.PrimaryTextColor, + hoverTextColor = theme.PrimaryTextColor, + disabledTextColor = theme.PrimaryTextColor, + pressedTextColor = theme.PrimaryTextColor, hoverFillColor = new RGBA_Bytes(255, 255, 255, 50), pressedFillColor = new RGBA_Bytes(255, 255, 255, 50), @@ -259,13 +259,13 @@ namespace MatterHackers.MatterControl this.LinkButtonFactory = new LinkButtonFactory() { fontSize = fontSize11, - textColor = ActiveTheme.Instance.PrimaryTextColor + textColor = theme.PrimaryTextColor }; this.HelpLinkFactory = new LinkButtonFactory() { fontSize = fontSize10, - textColor = ActiveTheme.Instance.SecondaryAccentColor + textColor = theme.SecondaryAccentColor }; } From 1533c568999bb5ba8f217c40d6b73095937f6395 Mon Sep 17 00:00:00 2001 From: John Lewin Date: Thu, 3 Aug 2017 08:09:10 -0700 Subject: [PATCH 6/6] Sort out common versus custom button factory styles --- ApplicationView/ThemeConfig.cs | 45 ++++++++++++++++++++-------------- 1 file changed, 26 insertions(+), 19 deletions(-) diff --git a/ApplicationView/ThemeConfig.cs b/ApplicationView/ThemeConfig.cs index eaae59b26..5b7924f83 100644 --- a/ApplicationView/ThemeConfig.cs +++ b/ApplicationView/ThemeConfig.cs @@ -121,6 +121,7 @@ namespace MatterHackers.MatterControl this.ButtonFactory = new TextImageButtonFactory() { + // Common normalTextColor = theme.PrimaryTextColor, hoverTextColor = theme.PrimaryTextColor, pressedTextColor = theme.PrimaryTextColor, @@ -132,52 +133,54 @@ namespace MatterHackers.MatterControl this.SmallMarginButtonFactory = new TextImageButtonFactory() { + // Common normalTextColor = theme.PrimaryTextColor, hoverTextColor = theme.PrimaryTextColor, pressedTextColor = theme.PrimaryTextColor, disabledTextColor = theme.TertiaryBackgroundColor, - Margin = new BorderDouble(8, 0), borderWidth = 0, FixedHeight = 32, + + // Exceptions + Margin = new BorderDouble(8, 0), }; this.MenuButtonFactory = new TextImageButtonFactory() { + // Common + disabledTextColor = theme.TertiaryBackgroundColor, + borderWidth = 0, + FixedHeight = 32, + + // Exceptions normalTextColor = RGBA_Bytes.Black, hoverTextColor = RGBA_Bytes.Black, pressedTextColor = RGBA_Bytes.Black, - disabledTextColor = theme.TertiaryBackgroundColor, normalFillColor = RGBA_Bytes.LightGray, pressedFillColor = RGBA_Bytes.LightGray, Margin = new BorderDouble(8, 0), - borderWidth = 0, - FixedHeight = 32, }; this.GrayButtonFactory = new TextImageButtonFactory() { + // Exceptions normalFillColor = RGBA_Bytes.Gray, normalTextColor = theme.PrimaryTextColor }; - int buttonHeight; - if (UserSettings.Instance.IsTouchScreen) - { - buttonHeight = 40; - } - else - { - buttonHeight = 0; - } + int viewControlsButtonHeight = (UserSettings.Instance.IsTouchScreen) ? 40 : 0; this.ViewControlsButtonFactory = new TextImageButtonFactory() { + // Common normalTextColor = theme.PrimaryTextColor, hoverTextColor = theme.PrimaryTextColor, - disabledTextColor = theme.PrimaryTextColor, pressedTextColor = theme.PrimaryTextColor, - FixedHeight = buttonHeight, - FixedWidth = buttonHeight, + + // Exceptions + disabledTextColor = theme.PrimaryTextColor, + FixedHeight = viewControlsButtonHeight, + FixedWidth = viewControlsButtonHeight, AllowThemeToAdjustImage = false, checkedBorderColor = RGBA_Bytes.White }; @@ -196,6 +199,7 @@ namespace MatterHackers.MatterControl WhiteButtonFactory = new TextImageButtonFactory() { + // Exceptions FixedWidth = sideBarButtonWidth, FixedHeight = shortButtonHeight, @@ -212,15 +216,17 @@ namespace MatterHackers.MatterControl ExpandMenuOptionFactory = new TextImageButtonFactory() { - FixedWidth = sideBarButtonWidth, + // Common normalTextColor = theme.PrimaryTextColor, hoverTextColor = theme.PrimaryTextColor, - disabledTextColor = theme.PrimaryTextColor, pressedTextColor = theme.PrimaryTextColor, + // Exceptions + disabledTextColor = theme.PrimaryTextColor, hoverFillColor = new RGBA_Bytes(255, 255, 255, 50), pressedFillColor = new RGBA_Bytes(255, 255, 255, 50), - disabledFillColor = new RGBA_Bytes(255, 255, 255, 50) + disabledFillColor = new RGBA_Bytes(255, 255, 255, 50), + FixedWidth = sideBarButtonWidth, }; #endregion @@ -228,6 +234,7 @@ namespace MatterHackers.MatterControl #region ImageConverter imageConverterButtonFactory = new TextImageButtonFactory() { + // Exceptions FixedWidth = 185, FixedHeight = 30,