From daa407bf83019cca7acdec7b267b994e334c8454 Mon Sep 17 00:00:00 2001 From: LarsBrubaker Date: Wed, 24 Feb 2021 23:00:56 -0800 Subject: [PATCH] improving layout --- .../ApplicationView/ApplicationController.cs | 8 +++--- .../RunningTasks/RunningTaskOptions.cs | 4 +-- .../CustomWidgets/SimpleButton.cs | 21 ++++++++------- .../PartPreviewWindow/RunningTaskRow.cs | 27 ++++++++++++------- 4 files changed, 35 insertions(+), 25 deletions(-) diff --git a/MatterControlLib/ApplicationView/ApplicationController.cs b/MatterControlLib/ApplicationView/ApplicationController.cs index 2d31ee127..1d8f34337 100644 --- a/MatterControlLib/ApplicationView/ApplicationController.cs +++ b/MatterControlLib/ApplicationView/ApplicationController.cs @@ -1060,13 +1060,13 @@ namespace MatterHackers.MatterControl }, taskActions: new RunningTaskOptions() { - PauseAction = (action) => UiThread.RunOnIdle(() => + PauseAction = () => UiThread.RunOnIdle(() => { paused = true; printerConnection.TimeHaveBeenHoldingTemperature.Stop(); }), PauseToolTip = "Pause automatic heater shutdown".Localize(), - ResumeAction = (action) => UiThread.RunOnIdle(() => + ResumeAction = () => UiThread.RunOnIdle(() => { paused = false; printerConnection.TimeHaveBeenHoldingTemperature.Start(); @@ -1973,7 +1973,7 @@ namespace MatterHackers.MatterControl { ExpansionSerializationKey = $"{nameof(MonitorPrintTask)}_expanded", RichProgressWidget = () => PrinterTabPage.PrintProgressWidget(printer, this.Theme), - PauseAction = (action) => UiThread.RunOnIdle(() => + PauseAction = () => UiThread.RunOnIdle(() => { printer.Connection.RequestPause(); }), @@ -1983,7 +1983,7 @@ namespace MatterHackers.MatterControl }, PauseToolTip = "Pause Print".Localize(), PauseText = "Pause".Localize(), - ResumeAction = (action) => UiThread.RunOnIdle(() => + ResumeAction = () => UiThread.RunOnIdle(() => { printer.Connection.Resume(); }), diff --git a/MatterControlLib/ApplicationView/RunningTasks/RunningTaskOptions.cs b/MatterControlLib/ApplicationView/RunningTasks/RunningTaskOptions.cs index 69b38d90a..351269d46 100644 --- a/MatterControlLib/ApplicationView/RunningTasks/RunningTaskOptions.cs +++ b/MatterControlLib/ApplicationView/RunningTasks/RunningTaskOptions.cs @@ -102,9 +102,9 @@ namespace MatterHackers.MatterControl /// public Func IsPaused { get; set; } - public Action PauseAction { get; set; } + public Action PauseAction { get; set; } - public Action ResumeAction { get; set; } + public Action ResumeAction { get; set; } public Action StopAction { get; set; } diff --git a/MatterControlLib/CustomWidgets/SimpleButton.cs b/MatterControlLib/CustomWidgets/SimpleButton.cs index 3b279afcb..728bf16ad 100644 --- a/MatterControlLib/CustomWidgets/SimpleButton.cs +++ b/MatterControlLib/CustomWidgets/SimpleButton.cs @@ -245,21 +245,22 @@ namespace MatterHackers.MatterControl.CustomWidgets public override void OnDrawBackground(Graphics2D graphics2D) { + var bounds = this.LocalBounds; + var rect = new RoundedRect(bounds.Left, bounds.Bottom, bounds.Right, bounds.Top, RoundRadius); + if (BackgroundColor.Alpha0To255 > 0) { - var bounds = this.LocalBounds; - var rect = new RoundedRect(bounds.Left, bounds.Bottom, bounds.Right, bounds.Top, RoundRadius); graphics2D.Render(rect, BackgroundColor); + } - if (RenderOutline) - { - var stroke = 1 * GuiWidget.DeviceScale; - var expand = stroke / 2; - rect = new RoundedRect(bounds.Left + expand, bounds.Bottom + expand, bounds.Right - expand, bounds.Top - expand, RoundRadius); - var rectOutline = new Stroke(rect, stroke); + if (BorderColor.Alpha0To255 > 0 && RenderOutline) + { + var stroke = 1 * GuiWidget.DeviceScale; + var expand = stroke / 2; + rect = new RoundedRect(bounds.Left + expand, bounds.Bottom + expand, bounds.Right - expand, bounds.Top - expand, RoundRadius); + var rectOutline = new Stroke(rect, stroke); - graphics2D.Render(rectOutline, BorderColor); - } + graphics2D.Render(rectOutline, BorderColor); } } diff --git a/MatterControlLib/PartPreviewWindow/RunningTaskRow.cs b/MatterControlLib/PartPreviewWindow/RunningTaskRow.cs index a148cfe3e..053cd34a7 100644 --- a/MatterControlLib/PartPreviewWindow/RunningTaskRow.cs +++ b/MatterControlLib/PartPreviewWindow/RunningTaskRow.cs @@ -108,7 +108,8 @@ namespace MatterHackers.MatterControl.PartPreviewWindow taskDetails.Options?.PauseAction, taskDetails.Options?.PauseToolTip ?? "Pause".Localize(), "", - theme); + theme, + 0); if (taskDetails.Options?.IsPaused != null) { @@ -133,7 +134,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow } pauseButton.Click += (s, e) => { - taskDetails.Options?.PauseAction(null); + taskDetails.Options?.PauseAction(); pauseButton.Visible = false; resumeButton.Visible = true; }; @@ -145,13 +146,14 @@ namespace MatterHackers.MatterControl.PartPreviewWindow taskDetails.Options?.ResumeAction, taskDetails.Options?.ResumeToolTip ?? "Resume".Localize(), "", - theme); + theme, + 0); // start with it hidden resumeButton.Visible = false; resumeButton.Click += (s, e) => { - taskDetails.Options?.ResumeAction(null); + taskDetails.Options?.ResumeAction(); pauseButton.Visible = true; resumeButton.Visible = false; }; @@ -162,7 +164,8 @@ namespace MatterHackers.MatterControl.PartPreviewWindow taskDetails.Options?.StopAction, taskDetails.Options?.StopToolTip ?? "Cancel".Localize(), "Stop Task Button", - theme); + theme, + 5); stopButton.Click += (s, e) => { @@ -210,7 +213,13 @@ namespace MatterHackers.MatterControl.PartPreviewWindow taskDetails.ProgressChanged += TaskDetails_ProgressChanged; } - private static GuiWidget CreateIconOrTextButton(string iconFilename, string buttonText, Action clickAction, string toolTip, string name, ThemeConfig theme) + private static GuiWidget CreateIconOrTextButton(string iconFilename, + string buttonText, + Object clickAction, + string toolTip, + string name, + ThemeConfig theme, + double marginX) { if (string.IsNullOrEmpty(buttonText)) { @@ -228,13 +237,13 @@ namespace MatterHackers.MatterControl.PartPreviewWindow theme.DefaultFontSize = 8; var pauseButton = new TextIconButton(buttonText, StaticData.Instance.LoadIcon(iconFilename, 12, 12, theme.InvertIcons), theme) { - Margin = new BorderDouble(5, 0), + Margin = new BorderDouble(marginX, 0), Padding = new BorderDouble(7, 3), VAnchor = VAnchor.Fit | VAnchor.Center, HAnchor = HAnchor.Fit, - BackgroundColor = new Color(theme.AccentMimimalOverlay, 50), + // BackgroundColor = new Color(theme.AccentMimimalOverlay, 50), HoverColor = theme.AccentMimimalOverlay, - BorderColor = theme.PrimaryAccentColor, + BorderColor = theme.TextColor, RenderOutline = true, // Margin = theme.ButtonSpacing,