Switch to transparent button backgrounds

- Add TextIconButton for image/text combos
- Add SimpleFlowButton for hover behaviors on Flowlayout types
- Duplicate hover behaviors in PopupMenuButton
- Base SimpleButton on GuiWidget rather than classic button type
- Issue MatterHackers/MCCentral#2671
Evaluate transparent normal fill for toolbar buttons
This commit is contained in:
John Lewin 2018-01-16 19:01:09 -08:00
parent 63963c1464
commit fd439fe675
13 changed files with 271 additions and 73 deletions

View file

@ -51,7 +51,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
}
else
{
this.OverflowMenu = new OverflowMenu(viewWidget)
this.OverflowMenu = new OverflowMenu(viewWidget, theme)
{
AlignToRightEdge = true,
Margin = theme.ButtonSpacing

View file

@ -48,8 +48,9 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
this.printerTabPage = printerTabPage;
this.printer = printer;
this.DrawArrow = true;
this.BackgroundColor = theme.ButtonFactory.Options.NormalFillColor;
//this.HoverColor = theme.ButtonFactory.Options.HoverFillColor;
this.BackgroundColor = theme.ToolbarButtonBackground;
this.HoverColor = theme.ToolbarButtonHover;
this.MouseDownColor = theme.ToolbarButtonDown;
this.Name = "PrintPopupMenu";
this.HAnchor = HAnchor.Fit;
this.VAnchor = VAnchor.Fit;

View file

@ -68,9 +68,14 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
// add the reset button first (if there is one)
if (ActiveSliceSettings.Instance.GetValue<bool>(SettingsKey.show_reset_connection))
{
var resetConnectionButton = theme.ButtonFactory.Generate("Reset".Localize(), AggContext.StaticData.LoadIcon("e_stop.png", 14, 14, IconColor.Theme));
resetConnectionButton.ToolTipText = "Reboots the firmware on the controller".Localize();
resetConnectionButton.Margin = defaultMargin;
var resetConnectionButton = new TextIconButton(
"Reset".Localize(),
AggContext.StaticData.LoadIcon("e_stop.png", 14, 14, IconColor.Theme),
theme)
{
ToolTipText = "Reboots the firmware on the controller".Localize(),
Margin = defaultMargin
};
resetConnectionButton.Click += (s, e) =>
{
UiThread.RunOnIdle(printer.Connection.RebootBoard);
@ -84,8 +89,6 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
var sliceButton = new SliceButton(printer, printerTabPage, theme)
{
Name = "Generate Gcode Button",
BackgroundColor = theme.ButtonFactory.Options.NormalFillColor,
HoverColor = theme.ButtonFactory.Options.HoverFillColor,
Margin = theme.ButtonSpacing,
};
this.AddChild(sliceButton);

View file

@ -31,6 +31,7 @@ using System;
using MatterHackers.Agg.Platform;
using MatterHackers.Agg.UI;
using MatterHackers.Localizations;
using MatterHackers.MatterControl.CustomWidgets;
using MatterHackers.MatterControl.PrinterCommunication;
using MatterHackers.MatterControl.PrinterControls.PrinterConnections;
using MatterHackers.MatterControl.SlicerConfiguration;
@ -43,9 +44,9 @@ namespace MatterHackers.MatterControl.ActionBar
private readonly string disconnectAndCancelTitle = "Disconnect and stop the current print?".Localize();
private readonly string disconnectAndCancelMessage = "WARNING: Disconnecting will stop the current print.\n\nAre you sure you want to disconnect?".Localize();
private Button cancelConnectButton;
private GuiWidget cancelConnectButton;
private GuiWidget connectButton;
private Button disconnectButton;
private GuiWidget disconnectButton;
private EventHandler unregisterEvents;
private PrinterConfig printer;
@ -61,9 +62,18 @@ namespace MatterHackers.MatterControl.ActionBar
this.Margin = 0;
this.Padding = 0;
connectButton = theme.ButtonFactory.Generate("Connect".Localize(), AggContext.StaticData.LoadIcon("connect.png", 14, 14, IconColor.Theme));
connectButton.Name = "Connect to printer button";
connectButton.ToolTipText = "Connect to the currently selected printer".Localize();
connectButton = new TextIconButton(
"Connect".Localize(),
AggContext.StaticData.LoadIcon("connect.png", 14, 14, IconColor.Theme),
theme)
{
Name = "Connect to printer button",
ToolTipText = "Connect to the currently selected printer".Localize(),
BackgroundColor = theme.ToolbarButtonBackground,
HoverColor = theme.ToolbarButtonHover,
MouseDownColor = theme.ToolbarButtonDown,
};
connectButton.Click += (s, e) =>
{
if (connectButton.Enabled)
@ -77,8 +87,16 @@ namespace MatterHackers.MatterControl.ActionBar
this.AddChild(connectButton);
// add the cancel stop button
cancelConnectButton = theme.ButtonFactory.Generate("Cancel".Localize(), AggContext.StaticData.LoadIcon("connect.png", 14, 14, IconColor.Theme));
cancelConnectButton.ToolTipText = "Stop trying to connect to the printer.".Localize();
cancelConnectButton = new TextIconButton(
"Cancel".Localize(),
AggContext.StaticData.LoadIcon("connect.png", 14, 14, IconColor.Theme),
theme)
{
ToolTipText = "Stop trying to connect to the printer.".Localize(),
BackgroundColor = theme.ToolbarButtonBackground,
HoverColor = theme.ToolbarButtonHover,
MouseDownColor = theme.ToolbarButtonDown,
};
cancelConnectButton.Click += (s, e) => UiThread.RunOnIdle(() =>
{
listenForConnectFailed = false;
@ -87,10 +105,18 @@ namespace MatterHackers.MatterControl.ActionBar
});
this.AddChild(cancelConnectButton);
disconnectButton = theme.ButtonFactory.Generate("Disconnect".Localize(), AggContext.StaticData.LoadIcon("connect.png", 14, 14, IconColor.Theme));
disconnectButton.Name = "Disconnect from printer button";
disconnectButton.Visible = false;
disconnectButton.ToolTipText = "Disconnect from current printer".Localize();
disconnectButton = new TextIconButton(
"Disconnect".Localize(),
AggContext.StaticData.LoadIcon("connect.png", 14, 14, IconColor.Theme),
theme)
{
Name = "Disconnect from printer button",
Visible = false,
ToolTipText = "Disconnect from current printer".Localize(),
BackgroundColor = theme.ToolbarButtonBackground,
HoverColor = theme.ToolbarButtonHover,
MouseDownColor = theme.ToolbarButtonDown,
};
disconnectButton.Click += (s, e) => UiThread.RunOnIdle(() =>
{
if (printer.Connection.PrinterIsPrinting)

View file

@ -49,6 +49,10 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
this.printer = printer;
this.printerTabPage = printerTabPage;
this.BackgroundColor = theme.ToolbarButtonBackground;
this.HoverColor = theme.ToolbarButtonHover;
this.MouseDownColor = theme.ToolbarButtonDown;
printer.Connection.CommunicationStateChanged.RegisterEvent((s, e) =>
{
UiThread.RunOnIdle(SetButtonStates);