From ce6c9d10fa6ff9128ba0ffa8da7ba7d208425890 Mon Sep 17 00:00:00 2001 From: John Lewin Date: Tue, 17 Apr 2018 07:43:18 -0700 Subject: [PATCH] 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