Merge pull request #3196 from jlewin/design_tools
Consolidate differing widget colors into single shared instance
This commit is contained in:
commit
469849be01
6 changed files with 63 additions and 52 deletions
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
@ -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<double>(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.##");
|
||||
|
|
|
|||
|
|
@ -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,17 +50,39 @@ 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;
|
||||
|
||||
// Section Label
|
||||
this.AddChild(new TextWidget(label, pointSize: theme.DefaultFontSize, textColor: theme.Colors.PrimaryTextColor)
|
||||
{
|
||||
HAnchor = HAnchor.Left,
|
||||
Margin = new BorderDouble(0)
|
||||
});
|
||||
|
||||
pullDownContainer = new GuiWidget()
|
||||
{
|
||||
HAnchor = HAnchor.Stretch,
|
||||
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);
|
||||
|
||||
ActiveSliceSettings.MaterialPresetChanged += ActiveSliceSettings_MaterialPresetChanged;
|
||||
|
||||
ActiveSliceSettings.SettingChanged.RegisterEvent((s, e) =>
|
||||
{
|
||||
if (e is StringEventArgs stringEvent
|
||||
|
|
@ -69,45 +92,15 @@ namespace MatterHackers.MatterControl.SlicerConfiguration
|
|||
RebuildDropDownList();
|
||||
}
|
||||
}, 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)
|
||||
});
|
||||
|
||||
pullDownContainer = new GuiWidget()
|
||||
{
|
||||
HAnchor = HAnchor.Stretch,
|
||||
VAnchor = VAnchor.Fit
|
||||
};
|
||||
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 +204,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 +228,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, "");
|
||||
|
|
|
|||
|
|
@ -42,9 +42,15 @@ 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)
|
||||
{
|
||||
BackgroundColor = theme.MinimalShade
|
||||
});
|
||||
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)
|
||||
{
|
||||
BackgroundColor = theme.MinimalShade
|
||||
});
|
||||
|
||||
this.Height = 60 * GuiWidget.DeviceScale;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
Subproject commit 4941ff4ac5d66df3626967bf037e2149aee69029
|
||||
Subproject commit b59dbc5a4ec76f32eaaea710d03472cfea26b5fa
|
||||
Loading…
Add table
Add a link
Reference in a new issue