From 267f683e9c6c7e2a2bc69e2c957af15f0f56f407 Mon Sep 17 00:00:00 2001 From: John Lewin Date: Mon, 16 Apr 2018 20:31:46 -0700 Subject: [PATCH 1/3] Consolidate differing widget colors into single shared instance - Issue MatterHackers/MCCentral#3150 Indicator colors differ --- ApplicationView/ThemeConfig.cs | 8 ++++++++ .../ControlWidgets/MovementControls.cs | 6 ++++-- SlicerConfiguration/PresetsToolbar.cs | 4 ++-- SlicerConfiguration/SliceSettingsRow.cs | 19 +++++++------------ 4 files changed, 21 insertions(+), 16 deletions(-) diff --git a/ApplicationView/ThemeConfig.cs b/ApplicationView/ThemeConfig.cs index e900f341c..3e0714ea7 100644 --- a/ApplicationView/ThemeConfig.cs +++ b/ApplicationView/ThemeConfig.cs @@ -83,6 +83,7 @@ namespace MatterHackers.MatterControl public int SplitterWidth => (int)(6 * (GuiWidget.DeviceScale <= 1 ? GuiWidget.DeviceScale : GuiWidget.DeviceScale * 1.4)); public IThemeColors Colors { get; set; } + public PresetColors PresetColors { get; set; } = new PresetColors(); public Color SlightShade { get; } = new Color(0, 0, 0, 40); public Color MinimalShade { get; } = new Color(0, 0, 0, 15); @@ -429,4 +430,11 @@ namespace MatterHackers.MatterControl return sectionWidget; } } + + public class PresetColors + { + public Color MaterialPreset { get; set; } = Color.Orange; + public Color QualityPreset { get; set; } = Color.Yellow; + public Color UserOverride { get; set; } = new Color(68, 95, 220, 150); + } } \ No newline at end of file diff --git a/PrinterControls/ControlWidgets/MovementControls.cs b/PrinterControls/ControlWidgets/MovementControls.cs index a1408f041..fbfb8dd54 100644 --- a/PrinterControls/ControlWidgets/MovementControls.cs +++ b/PrinterControls/ControlWidgets/MovementControls.cs @@ -278,10 +278,12 @@ namespace MatterHackers.MatterControl.PrinterControls private EventHandler unregisterEvents; private bool allowRemoveButton; - PrinterSettings printerSettings; + private ThemeConfig theme; + private PrinterSettings printerSettings; public ZTuningWidget(PrinterSettings printerSettings, ThemeConfig theme, bool allowRemoveButton = true) { + this.theme = theme; this.printerSettings = printerSettings; this.allowRemoveButton = allowRemoveButton; this.HAnchor = HAnchor.Fit; @@ -332,7 +334,7 @@ namespace MatterHackers.MatterControl.PrinterControls double zoffset = printerSettings.GetValue(SettingsKey.baby_step_z_offset); bool hasOverriddenZOffset = (zoffset != 0); - zOffsetStreamContainer.BackgroundColor = (allowRemoveButton && hasOverriddenZOffset) ? SliceSettingsRow.userSettingBackgroundColor : ActiveTheme.Instance.SecondaryBackgroundColor; + zOffsetStreamContainer.BackgroundColor = (allowRemoveButton && hasOverriddenZOffset) ? theme.PresetColors.UserOverride : ActiveTheme.Instance.SecondaryBackgroundColor; clearZOffsetButton.Visible = allowRemoveButton && hasOverriddenZOffset; zOffsetStreamDisplay.Text = zoffset.ToString("0.##"); diff --git a/SlicerConfiguration/PresetsToolbar.cs b/SlicerConfiguration/PresetsToolbar.cs index c2912bdef..1e0b141a5 100644 --- a/SlicerConfiguration/PresetsToolbar.cs +++ b/SlicerConfiguration/PresetsToolbar.cs @@ -42,9 +42,9 @@ namespace MatterHackers.MatterControl.SlicerConfiguration int numberOfHeatedExtruders = printer.Settings.Helpers.NumberOfHotends(); - this.AddChild(new PresetSelectorWidget(printer, "Quality".Localize(), Color.Yellow, NamedSettingsLayers.Quality, theme)); + this.AddChild(new PresetSelectorWidget(printer, "Quality".Localize(), theme.PresetColors.QualityPreset, NamedSettingsLayers.Quality, theme)); this.AddChild(new GuiWidget(8, 0)); - this.AddChild(new PresetSelectorWidget(printer, "Material".Localize(), Color.Orange, NamedSettingsLayers.Material, theme)); + this.AddChild(new PresetSelectorWidget(printer, "Material".Localize(), theme.PresetColors.MaterialPreset, NamedSettingsLayers.Material, theme)); this.Height = 60 * GuiWidget.DeviceScale; } diff --git a/SlicerConfiguration/SliceSettingsRow.cs b/SlicerConfiguration/SliceSettingsRow.cs index 9524ddaa4..7d4f00978 100644 --- a/SlicerConfiguration/SliceSettingsRow.cs +++ b/SlicerConfiguration/SliceSettingsRow.cs @@ -38,10 +38,6 @@ namespace MatterHackers.MatterControl.SlicerConfiguration { public class SliceSettingsRow : SettingsRow { - private static readonly Color materialSettingBackgroundColor = Color.Orange; - private static readonly Color qualitySettingBackgroundColor = Color.YellowGreen; - public static readonly Color userSettingBackgroundColor = new Color(68, 95, 220, 150); - private SettingsContext settingsContext; private PrinterConfig printer; private SliceSettingData settingData; @@ -143,11 +139,11 @@ namespace MatterHackers.MatterControl.SlicerConfiguration { if (layerName.StartsWith("Material")) { - this.HighlightColor = materialSettingBackgroundColor; + this.HighlightColor = theme.PresetColors.MaterialPreset; } else if (layerName.StartsWith("Quality")) { - this.HighlightColor = qualitySettingBackgroundColor; + this.HighlightColor = theme.PresetColors.QualityPreset; } else { @@ -161,17 +157,17 @@ namespace MatterHackers.MatterControl.SlicerConfiguration } else { - this.HighlightColor = userSettingBackgroundColor; + this.HighlightColor = theme.PresetColors.UserOverride; if (restoreButton != null) restoreButton.Visible = true; } } break; case NamedSettingsLayers.Material: - this.HighlightColor = materialSettingBackgroundColor; + this.HighlightColor = theme.PresetColors.MaterialPreset; if (restoreButton != null) restoreButton.Visible = true; break; case NamedSettingsLayers.Quality: - this.HighlightColor = qualitySettingBackgroundColor; + this.HighlightColor = theme.PresetColors.QualityPreset; if (restoreButton != null) restoreButton.Visible = true; break; } @@ -180,11 +176,11 @@ namespace MatterHackers.MatterControl.SlicerConfiguration { if (printer.Settings.SettingExistsInLayer(settingData.SlicerConfigName, NamedSettingsLayers.Material)) { - this.HighlightColor = materialSettingBackgroundColor; + this.HighlightColor =theme.PresetColors.MaterialPreset; } else if (printer.Settings.SettingExistsInLayer(settingData.SlicerConfigName, NamedSettingsLayers.Quality)) { - this.HighlightColor = qualitySettingBackgroundColor; + this.HighlightColor = theme.PresetColors.QualityPreset; } else { @@ -198,7 +194,6 @@ namespace MatterHackers.MatterControl.SlicerConfiguration if (restoreButton != null) restoreButton.Visible = false; this.HighlightColor = Color.Transparent; } - } internal static void AddBordersToEditFields(GuiWidget row) From ce6c9d10fa6ff9128ba0ffa8da7ba7d208425890 Mon Sep 17 00:00:00 2001 From: John Lewin Date: Tue, 17 Apr 2018 07:43:18 -0700 Subject: [PATCH 2/3] Use softer and more consistent technique to indicate preset color - Issue MatterHackers/MCCentral#3151 Revise preset selector styling --- SlicerConfiguration/PresetSelectorWidget.cs | 43 +++++++++++---------- SlicerConfiguration/PresetsToolbar.cs | 10 ++++- Submodules/agg-sharp | 2 +- 3 files changed, 31 insertions(+), 24 deletions(-) diff --git a/SlicerConfiguration/PresetSelectorWidget.cs b/SlicerConfiguration/PresetSelectorWidget.cs index d3fdde613..87dd3c979 100644 --- a/SlicerConfiguration/PresetSelectorWidget.cs +++ b/SlicerConfiguration/PresetSelectorWidget.cs @@ -1,5 +1,5 @@ /* -Copyright (c) 2016, Kevin Pope, John Lewin +Copyright (c) 2018, Kevin Pope, John Lewin All rights reserved. Redistribution and use in source and binary forms, with or without @@ -34,6 +34,7 @@ using System.Linq; using MatterHackers.Agg; using MatterHackers.Agg.Platform; using MatterHackers.Agg.UI; +using MatterHackers.Agg.VertexSource; using MatterHackers.Localizations; using MatterHackers.VectorMath; @@ -49,14 +50,18 @@ namespace MatterHackers.MatterControl.SlicerConfiguration private PrinterConfig printer; private GuiWidget pullDownContainer; private EventHandler unregisterEvents; - //For multiple materials public PresetSelectorWidget(PrinterConfig printer, string label, Color accentColor, NamedSettingsLayers layerType, ThemeConfig theme) : base(FlowDirection.TopToBottom) { + this.layerType = layerType; this.printer = printer; this.Name = label; this.theme = theme; + this.HAnchor = HAnchor.Stretch; + this.VAnchor = VAnchor.Fit; + this.BackgroundColor = theme.MinimalShade; + this.Padding = theme.DefaultContainerPadding; ActiveSliceSettings.MaterialPresetChanged += ActiveSliceSettings_MaterialPresetChanged; @@ -70,44 +75,33 @@ namespace MatterHackers.MatterControl.SlicerConfiguration } }, ref unregisterEvents); - this.layerType = layerType; - - this.HAnchor = HAnchor.Stretch; - this.VAnchor = VAnchor.Fit; - this.BackgroundColor = theme.Colors.TertiaryBackgroundColor; - - GuiWidget accentBar = new GuiWidget(7, 3) - { - BackgroundColor = accentColor, - HAnchor = HAnchor.Stretch - }; - // Section Label this.AddChild(new TextWidget(label, pointSize: theme.DefaultFontSize, textColor: theme.Colors.PrimaryTextColor) { HAnchor = HAnchor.Left, - Margin = new BorderDouble(12, 3, 0, 6) + Margin = new BorderDouble(0) }); pullDownContainer = new GuiWidget() { HAnchor = HAnchor.Stretch, - VAnchor = VAnchor.Fit + VAnchor = VAnchor.Fit, + Border = new BorderDouble(left: 3), + BorderColor = accentColor, + Margin = new BorderDouble(top: 6), + Padding = new BorderDouble(left: (accentColor != Color.Transparent) ? 6 : 0) }; pullDownContainer.AddChild(GetPulldownContainer()); this.AddChild(pullDownContainer); - - this.AddChild(accentBar); } public FlowLayoutWidget GetPulldownContainer() { DropDownList = CreateDropdown(); - FlowLayoutWidget container = new FlowLayoutWidget() + var container = new FlowLayoutWidget() { HAnchor = HAnchor.MaxFitOrStretch, - Padding = new BorderDouble(12, 0), Name = "Preset Pulldown Container" }; @@ -211,6 +205,12 @@ namespace MatterHackers.MatterControl.SlicerConfiguration return container; } + public override void OnDrawBackground(Graphics2D graphics2D) + { + //base.OnDrawBackground(graphics2D); + graphics2D.Render(new RoundedRect(this.LocalBounds, 5), this.BackgroundColor); + } + public override void OnClosed(ClosedEventArgs e) { ActiveSliceSettings.MaterialPresetChanged -= ActiveSliceSettings_MaterialPresetChanged; @@ -229,12 +229,13 @@ namespace MatterHackers.MatterControl.SlicerConfiguration var dropDownList = new DropDownList(defaultMenuItemText, theme.Colors.PrimaryTextColor, maxHeight: 300, useLeftIcons: true, pointSize: theme.DefaultFontSize) { HAnchor = HAnchor.Stretch, + VAnchor = VAnchor.Center, MenuItemsPadding = new BorderDouble(10, 7, 7, 7), BorderColor = theme.GetBorderColor(75) }; dropDownList.Name = layerType.ToString() + " DropDown List"; - dropDownList.Margin = new BorderDouble(0, 3); + dropDownList.Margin = 0; dropDownList.MinimumSize = new Vector2(dropDownList.LocalBounds.Width, dropDownList.LocalBounds.Height); MenuItem defaultMenuItem = dropDownList.AddItem(defaultMenuItemText, ""); diff --git a/SlicerConfiguration/PresetsToolbar.cs b/SlicerConfiguration/PresetsToolbar.cs index 1e0b141a5..e77b790af 100644 --- a/SlicerConfiguration/PresetsToolbar.cs +++ b/SlicerConfiguration/PresetsToolbar.cs @@ -42,9 +42,15 @@ namespace MatterHackers.MatterControl.SlicerConfiguration int numberOfHeatedExtruders = printer.Settings.Helpers.NumberOfHotends(); - this.AddChild(new PresetSelectorWidget(printer, "Quality".Localize(), theme.PresetColors.QualityPreset, NamedSettingsLayers.Quality, theme)); + this.AddChild(new PresetSelectorWidget(printer, "Quality".Localize(), theme.PresetColors.QualityPreset, NamedSettingsLayers.Quality, theme) + { + BackgroundColor = theme.MinimalShade + }); this.AddChild(new GuiWidget(8, 0)); - this.AddChild(new PresetSelectorWidget(printer, "Material".Localize(), theme.PresetColors.MaterialPreset, NamedSettingsLayers.Material, theme)); + this.AddChild(new PresetSelectorWidget(printer, "Material".Localize(), theme.PresetColors.MaterialPreset, NamedSettingsLayers.Material, theme) + { + BackgroundColor = theme.MinimalShade + }); this.Height = 60 * GuiWidget.DeviceScale; } diff --git a/Submodules/agg-sharp b/Submodules/agg-sharp index 4941ff4ac..b59dbc5a4 160000 --- a/Submodules/agg-sharp +++ b/Submodules/agg-sharp @@ -1 +1 @@ -Subproject commit 4941ff4ac5d66df3626967bf037e2149aee69029 +Subproject commit b59dbc5a4ec76f32eaaea710d03472cfea26b5fa From f160f7e5ab0919043ccc38c49d55c54e20b65fe5 Mon Sep 17 00:00:00 2001 From: John Lewin Date: Tue, 17 Apr 2018 08:14:08 -0700 Subject: [PATCH 3/3] Move event bindings to constructor bottom --- SlicerConfiguration/PresetSelectorWidget.cs | 23 ++++++++++----------- 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/SlicerConfiguration/PresetSelectorWidget.cs b/SlicerConfiguration/PresetSelectorWidget.cs index 87dd3c979..cf61f37f5 100644 --- a/SlicerConfiguration/PresetSelectorWidget.cs +++ b/SlicerConfiguration/PresetSelectorWidget.cs @@ -63,18 +63,6 @@ namespace MatterHackers.MatterControl.SlicerConfiguration this.BackgroundColor = theme.MinimalShade; this.Padding = theme.DefaultContainerPadding; - ActiveSliceSettings.MaterialPresetChanged += ActiveSliceSettings_MaterialPresetChanged; - - ActiveSliceSettings.SettingChanged.RegisterEvent((s, e) => - { - if (e is StringEventArgs stringEvent - && (stringEvent.Data == SettingsKey.default_material_presets - || stringEvent.Data == SettingsKey.layer_name)) - { - RebuildDropDownList(); - } - }, ref unregisterEvents); - // Section Label this.AddChild(new TextWidget(label, pointSize: theme.DefaultFontSize, textColor: theme.Colors.PrimaryTextColor) { @@ -93,6 +81,17 @@ namespace MatterHackers.MatterControl.SlicerConfiguration }; pullDownContainer.AddChild(GetPulldownContainer()); this.AddChild(pullDownContainer); + + ActiveSliceSettings.MaterialPresetChanged += ActiveSliceSettings_MaterialPresetChanged; + ActiveSliceSettings.SettingChanged.RegisterEvent((s, e) => + { + if (e is StringEventArgs stringEvent + && (stringEvent.Data == SettingsKey.default_material_presets + || stringEvent.Data == SettingsKey.layer_name)) + { + RebuildDropDownList(); + } + }, ref unregisterEvents); } public FlowLayoutWidget GetPulldownContainer()