diff --git a/MatterControlLib/ApplicationView/Themes/ThemeConfig.cs b/MatterControlLib/ApplicationView/Themes/ThemeConfig.cs index 7aea485f2..5c4528127 100644 --- a/MatterControlLib/ApplicationView/Themes/ThemeConfig.cs +++ b/MatterControlLib/ApplicationView/Themes/ThemeConfig.cs @@ -328,6 +328,7 @@ namespace MatterHackers.MatterControl { BackgroundColor = this.MinimalShade, BorderColor = this.BorderColor40, + RenderOutline = true, VAnchor = VAnchor.Absolute, HAnchor = HAnchor.Absolute, Margin = 0, @@ -343,6 +344,7 @@ namespace MatterHackers.MatterControl { BackgroundColor = this.MinimalShade, BorderColor = this.BorderColor40, + RenderOutline = true, VAnchor = VAnchor.Absolute, HAnchor = HAnchor.Absolute, Margin = 0, @@ -523,19 +525,34 @@ namespace MatterHackers.MatterControl { PopupMenuButton menuButton = null; - var innerButton = new IconButton(buttonParams.Icon, this) + GuiWidget innerButton; + if (buttonParams.ButtonText == null) { - Name = buttonParams.ButtonName + " Inner SplitButton", - ToolTipText = buttonParams.DefaultActionTooltip, - }; + innerButton = new IconButton(buttonParams.Icon, this) + { + Name = buttonParams.ButtonName + " Inner SplitButton", + Enabled = buttonParams.ButtonEnabled, + ToolTipText = buttonParams.ButtonTooltip, + }; + + // Remove right Padding for drop style + innerButton.Padding = innerButton.Padding.Clone(right: 0); + } + else + { + innerButton = new TextButton(buttonParams.ButtonText, this) + { + Name = buttonParams.ButtonName, + Enabled = buttonParams.ButtonEnabled, + ToolTipText = buttonParams.ButtonTooltip, + }; + } innerButton.Click += (s, e) => { - buttonParams.DefaultAction.Invoke(menuButton); + buttonParams.ButtonAction.Invoke(menuButton); }; - // Remove right Padding for drop style - innerButton.Padding = innerButton.Padding.Clone(right: 0); if (operationGroup == null) { @@ -555,7 +572,15 @@ namespace MatterHackers.MatterControl }; menuButton.Name = buttonParams.ButtonName + " Menu SplitButton"; - menuButton.BackgroundColor = this.ToolbarButtonBackground; + if (buttonParams.ButtonText == null) + { + menuButton.BackgroundColor = this.ToolbarButtonBackground; + } + else + { + menuButton.BackgroundColor = this.MinimalShade; + } + menuButton.HoverColor = this.ToolbarButtonHover; menuButton.MouseDownColor = this.ToolbarButtonDown; menuButton.DrawArrow = true; @@ -723,14 +748,18 @@ namespace MatterHackers.MatterControl { public ImageBuffer Icon { get; set; } - public Action DefaultAction { get; set; } + public bool ButtonEnabled { get; set; } = true; - public string DefaultActionTooltip { get; set; } + public string ButtonName { get; set; } + + public Action ButtonAction { get; set; } + + public string ButtonTooltip { get; set; } public Action MenuAction { get; set; } public Action ExtendPopupMenu { get; set; } - public string ButtonName { get; set; } + public string ButtonText { get; set; } } } \ No newline at end of file diff --git a/MatterControlLib/CustomWidgets/ExportPrintItemPage.cs b/MatterControlLib/CustomWidgets/ExportPrintItemPage.cs index e8f038d28..4815fe330 100644 --- a/MatterControlLib/CustomWidgets/ExportPrintItemPage.cs +++ b/MatterControlLib/CustomWidgets/ExportPrintItemPage.cs @@ -53,8 +53,16 @@ namespace MatterHackers.MatterControl public ExportPrintItemPage(IEnumerable libraryItems, bool centerOnBed, PrinterConfig printer) { this.WindowTitle = "Export File".Localize(); - this.HeaderText = "Export selection to".Localize() + ":"; - this.Name = "Export Item Window"; + if (libraryItems.First().Name == printer.Bed.Scene.Name) + { + this.HeaderText = "Export bed to".Localize() + ":"; + this.Name = "Export Scene Window"; + } + else + { + this.HeaderText = "Export selection to".Localize() + ":"; + this.Name = "Export Item Window"; + } var commonMargin = new BorderDouble(4, 2); diff --git a/MatterControlLib/CustomWidgets/SimpleButton.cs b/MatterControlLib/CustomWidgets/SimpleButton.cs index 2ca878c4b..563798531 100644 --- a/MatterControlLib/CustomWidgets/SimpleButton.cs +++ b/MatterControlLib/CustomWidgets/SimpleButton.cs @@ -146,7 +146,11 @@ namespace MatterHackers.MatterControl.CustomWidgets bounds -= BackgroundInset; var stroke = 1 * GuiWidget.DeviceScale; var expand = stroke / 2; - var rect = new RoundedRect(bounds.Left + expand, bounds.Bottom + expand, bounds.Right - expand, bounds.Top - expand, RoundRadius); + var rect = new RoundedRect(bounds.Left + expand, + bounds.Bottom + expand, + bounds.Right - expand, + bounds.Top - expand, + RoundRadius * GuiWidget.DeviceScale); var rectOutline = new Stroke(rect, stroke); graphics2D.Render(rectOutline, theme.EditFieldColors.Focused.BorderColor); @@ -157,7 +161,11 @@ namespace MatterHackers.MatterControl.CustomWidgets { var bounds = this.LocalBounds; bounds -= BackgroundInset; - var rect = new RoundedRect(bounds.Left, bounds.Bottom, bounds.Right, bounds.Top, RoundRadius); + var rect = new RoundedRect(bounds.Left, + bounds.Bottom, + bounds.Right, + bounds.Top, + RoundRadius * GuiWidget.DeviceScale); if (BackgroundColor.Alpha0To255 > 0) { @@ -168,7 +176,11 @@ namespace MatterHackers.MatterControl.CustomWidgets { 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); + rect = new RoundedRect(bounds.Left + expand, + bounds.Bottom + expand, + bounds.Right - expand, + bounds.Top - expand, + RoundRadius * GuiWidget.DeviceScale); var rectOutline = new Stroke(rect, stroke); graphics2D.Render(rectOutline, BorderColor); @@ -191,6 +203,9 @@ namespace MatterHackers.MatterControl.CustomWidgets public BorderDouble BackgroundInset { get; set; } + /// + /// This is in device units and will be scaled when drawn to the screen (do not scale the input by DeviceScale) + /// public double RoundRadius { get; set; } public bool RenderOutline { get; set; } @@ -198,6 +213,9 @@ namespace MatterHackers.MatterControl.CustomWidgets public class SimpleFlowButton : FlowLayoutWidget { + /// + /// This is in device units and will be scaled when drawn to the screen (do not scale the input by DeviceScale) + /// public double RoundRadius { get; set; } public bool RenderOutline { get; set; } @@ -247,7 +265,11 @@ 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); + var rect = new RoundedRect(bounds.Left, + bounds.Bottom, + bounds.Right, + bounds.Top, + RoundRadius * GuiWidget.DeviceScale); if (BackgroundColor.Alpha0To255 > 0) { @@ -258,7 +280,11 @@ namespace MatterHackers.MatterControl.CustomWidgets { 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); + rect = new RoundedRect(bounds.Left + expand, + bounds.Bottom + expand, + bounds.Right - expand, + bounds.Top - expand, + RoundRadius * GuiWidget.DeviceScale); var rectOutline = new Stroke(rect, stroke); graphics2D.Render(rectOutline, BorderColor); diff --git a/MatterControlLib/CustomWidgets/SolidSlider.cs b/MatterControlLib/CustomWidgets/SolidSlider.cs index 0895ca7c8..b2daf39f0 100644 --- a/MatterControlLib/CustomWidgets/SolidSlider.cs +++ b/MatterControlLib/CustomWidgets/SolidSlider.cs @@ -102,23 +102,14 @@ namespace MatterHackers.MatterControl public void DrawTrackAndThumb(Graphics2D graphics2D) { - RoundedRect track = new RoundedRect(GetTrackBounds(), this.TrackRadius); - Vector2 ValuePrintPosition; - if (sliderAttachedTo.Orientation == Orientation.Horizontal) - { - ValuePrintPosition = new Vector2(sliderAttachedTo.TotalWidthInPixels / 2, -TrackHeight - 12); - } - else - { - ValuePrintPosition = new Vector2(0, -TrackHeight - 12); - } + var track = new RoundedRect(GetTrackBounds(), this.TrackRadius); // draw the track graphics2D.Render(track, TrackColor); // now do the thumb RectangleDouble thumbBounds = sliderAttachedTo.GetThumbHitBounds(); - RoundedRect thumbOutside = new RoundedRect(thumbBounds, 0); + var thumbOutside = new RoundedRect(thumbBounds, 2 * GuiWidget.DeviceScale); graphics2D.Render(thumbOutside, this.ThumbColor); // ColorF.GetTweenColor(ThumbColor.ToColorF(), ColorF.Black.ToColorF(), .2).ToColor()); } } diff --git a/MatterControlLib/PartPreviewWindow/SectionWidget.cs b/MatterControlLib/PartPreviewWindow/SectionWidget.cs index 7d7503abd..1cb33087e 100644 --- a/MatterControlLib/PartPreviewWindow/SectionWidget.cs +++ b/MatterControlLib/PartPreviewWindow/SectionWidget.cs @@ -155,7 +155,7 @@ namespace MatterHackers.MatterControl.CustomWidgets this.ContentPanel.BorderColor = Color.Transparent; } - public int BorderRadius { get; set; } = 0; + public int BorderRadius { get; set; } public bool ExpandableWhenDisabled { get; set; } diff --git a/MatterControlLib/PartPreviewWindow/View3D/PrinterBar/PrintPopupMenu.cs b/MatterControlLib/PartPreviewWindow/View3D/PrinterBar/PrintPopupMenu.cs index e1ba4a022..532001b3c 100644 --- a/MatterControlLib/PartPreviewWindow/View3D/PrinterBar/PrintPopupMenu.cs +++ b/MatterControlLib/PartPreviewWindow/View3D/PrinterBar/PrintPopupMenu.cs @@ -204,20 +204,35 @@ namespace MatterHackers.MatterControl.PartPreviewWindow exportPlugin.Initialize(printer); - var exportGCodeButton = menuTheme.CreateDialogButton("Export".Localize()); - - exportGCodeButton.Name = "Export Gcode Button"; - exportGCodeButton.Enabled = exportPlugin.Enabled; - exportGCodeButton.ToolTipText = exportPlugin.Enabled ? exportType : exportPlugin.DisabledReason; - - exportGCodeButton.Click += (s, e) => + var exportGCodeButton = menuTheme.CreateSplitButton(new SplitButtonParams() { - this.CloseMenu(); - ExportPrintItemPage.DoExport( - new[] { new InMemoryLibraryItem(printer.Bed.Scene) }, - printer, - exportPlugin); - }; + ButtonText = "Export".Localize(), + ButtonTooltip = exportPlugin.Enabled ? exportType : exportPlugin.DisabledReason, + ExtendPopupMenu = (popupMenu) => + { + var operationMenu = popupMenu.CreateMenuItem("Options..."); + operationMenu.Click += (s, e) => + { + ApplicationController.Instance.ExportLibraryItems( + new[] { new InMemoryLibraryItem(printer.Bed.Scene) }, + centerOnBed: false, + printer: printer); + this.CloseMenu(); + }; + }, + ButtonEnabled = exportPlugin.Enabled, + ButtonName = "Export Gcode Button", + ButtonAction = (widget) => + { + this.CloseMenu(); + ExportPrintItemPage.DoExport( + new[] { new InMemoryLibraryItem(printer.Bed.Scene) }, + printer, + exportPlugin); + }, + + }); + exportGCodeButton.ToolTipText = "More Export Options".Localize(); setupRow.AddChild(exportGCodeButton); } diff --git a/MatterControlLib/PartPreviewWindow/ViewControls3D.cs b/MatterControlLib/PartPreviewWindow/ViewControls3D.cs index 1e684fd6f..3e8bb50c8 100644 --- a/MatterControlLib/PartPreviewWindow/ViewControls3D.cs +++ b/MatterControlLib/PartPreviewWindow/ViewControls3D.cs @@ -295,11 +295,11 @@ namespace MatterHackers.MatterControl.PartPreviewWindow new SplitButtonParams() { Icon = defaultOperation.Icon(theme.InvertIcons), - DefaultAction = (menuButton) => + ButtonAction = (menuButton) => { defaultOperation.Action.Invoke(sceneContext); }, - DefaultActionTooltip = defaultOperation.HelpText ?? defaultOperation.Title, + ButtonTooltip = defaultOperation.HelpText ?? defaultOperation.Title, ButtonName = defaultOperation.Title, ExtendPopupMenu = (PopupMenu popupMenu) => { @@ -816,7 +816,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow { ButtonName = "Save", Icon = StaticData.Instance.LoadIcon("save_grey_16x.png", 16, 16, theme.InvertIcons), - DefaultAction = (menuButton) => + ButtonAction = (menuButton) => { ApplicationController.Instance.Tasks.Execute("Saving".Localize(), sceneContext.Printer, async (progress, cancellationToken) => { @@ -834,7 +834,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow menuButton.Enabled = true; }).ConfigureAwait(false); }, - DefaultActionTooltip = "Save".Localize(), + ButtonTooltip = "Save".Localize(), ExtendPopupMenu = (PopupMenu popupMenu) => { var saveAs = popupMenu.CreateMenuItem("Save As".Localize()); diff --git a/MatterControlLib/SlicerConfiguration/SettingsRow.cs b/MatterControlLib/SlicerConfiguration/SettingsRow.cs index b7db41ec6..9e86e899f 100644 --- a/MatterControlLib/SlicerConfiguration/SettingsRow.cs +++ b/MatterControlLib/SlicerConfiguration/SettingsRow.cs @@ -32,6 +32,7 @@ using System.Linq; using MatterHackers.Agg; using MatterHackers.Agg.Image; using MatterHackers.Agg.UI; +using MatterHackers.Agg.VertexSource; using MatterHackers.MatterControl.PartPreviewWindow; using MatterHackers.VectorMath; @@ -190,6 +191,8 @@ namespace MatterHackers.MatterControl.CustomWidgets set => base.BackgroundColor = value; } + public int BorderRadius { get; set; } = 3; + public override void OnLoad(EventArgs args) { // The top level SystemWindow - due to single window implementation details, multiple SystemWindow parents may exist - proceed to the topmost one @@ -277,6 +280,19 @@ namespace MatterHackers.MatterControl.CustomWidgets { } + public override void OnDrawBackground(Graphics2D graphics2D) + { + if (this.BorderRadius > 0) + { + var rect = new RoundedRect(this.LocalBounds, this.BorderRadius); + graphics2D.Render(rect, this.BackgroundColor); + } + else + { + base.OnDrawBackground(graphics2D); + } + } + protected void ShowPopover(SettingsRow settingsRow) { // Only display popovers when we're the active widget, exit if we're not first under mouse