From 0c99e76f4efd23d2a681e76257cd927ac2dee41e Mon Sep 17 00:00:00 2001 From: LarsBrubaker Date: Fri, 14 Aug 2020 21:56:39 -0700 Subject: [PATCH] Made menus resolution sensitive Put in default note options for history --- .../AboutPage/CheckForUpdatesPage.cs | 2 +- .../History/PrintHistoryListItem.cs | 85 ++++++++----------- .../SystemWindowExtension.cs | 37 ++++---- .../ApplicationSettingsPage.cs | 2 +- MatterControlLib/SetupWizard/InputBoxPage.cs | 4 +- .../PresetSelectorWidget.cs | 2 +- .../UIFields/ComPortField.cs | 2 +- .../UIFields/DropMenuWrappedField.cs | 2 +- .../UIFields/IpAddessField.cs | 2 +- .../SlicerConfiguration/UIFields/ListField.cs | 2 +- .../UIFields/SliceEngineField.cs | 2 +- Submodules/agg-sharp | 2 +- 12 files changed, 70 insertions(+), 74 deletions(-) diff --git a/MatterControlLib/AboutPage/CheckForUpdatesPage.cs b/MatterControlLib/AboutPage/CheckForUpdatesPage.cs index c5d80fba1..d69053109 100644 --- a/MatterControlLib/AboutPage/CheckForUpdatesPage.cs +++ b/MatterControlLib/AboutPage/CheckForUpdatesPage.cs @@ -117,7 +117,7 @@ namespace MatterHackers.MatterControl UserSettings.Instance.set(UserSettingsKey.UpdateFeedType, "release"); } - var releaseOptionsDropList = new MHDropDownList("Development", theme, maxHeight: 200) + var releaseOptionsDropList = new MHDropDownList("Development", theme, maxHeight: 200 * GuiWidget.DeviceScale) { HAnchor = HAnchor.Fit, }; diff --git a/MatterControlLib/History/PrintHistoryListItem.cs b/MatterControlLib/History/PrintHistoryListItem.cs index ec6781329..cf8358acc 100644 --- a/MatterControlLib/History/PrintHistoryListItem.cs +++ b/MatterControlLib/History/PrintHistoryListItem.cs @@ -275,76 +275,65 @@ namespace MatterHackers.MatterControl.PrintHistory addNotest.Click += (s, e) => { var inputBoxPage = new InputBoxPage( - "Print History Note".Localize(), - "Note".Localize(), - printTask.Note == null ? "" : printTask.Note, - "Enter Note Here".Localize(), - string.IsNullOrEmpty(printTask.Note) ? "Add Note".Localize() : "Update".Localize(), - (newNote) => - { - printTask.Note = newNote; - printTask.Commit(); - popupMenu.Unfocus(); - printInfoWidget.Text = GetPrintInfo(); - }) + "Print History Note".Localize(), + "Note".Localize(), + printTask.Note == null ? "" : printTask.Note, + "Enter Note Here".Localize(), + string.IsNullOrEmpty(printTask.Note) ? "Add Note".Localize() : "Update".Localize(), + (newNote) => + { + printTask.Note = newNote; + printTask.Commit(); + popupMenu.Unfocus(); + printInfoWidget.Text = GetPrintInfo(); + }) { AllowEmpty = true, }; - inputBoxPage.ContentRow.AddChild(CreateDefaultOptions(printTask)); + inputBoxPage.ContentRow.AddChild(CreateDefaultOptions(inputBoxPage)); DialogWindow.Show(inputBoxPage); + + inputBoxPage.Parent.Height += 40 * GuiWidget.DeviceScale; }; } - private GuiWidget CreateDefaultOptions(PrintTask printTask) + private GuiWidget CreateDefaultOptions(GuiWidget textField) { var issues = new string[] { - "Bad print quality", - "Print dislodged from bed", - "Warping", + "Bed Dislodged", + "Bowden Tube Popped Out", + "Computer Crashed", + "Couldn't Resume", + "Dislodged From Bed", + "Filament Jam", + "Filament Runout", "Layer shift", - "Filament runout", - "Filament jam", - "Thermal runaway", - "Computer crash", - "Power outage", - "Bed dislodged from printer", + "Power Outage", + "Print Quality", + "Rough Overhangs", + "Skipped Layers", "Stringing / Poor retractions", - "Skilled layers", - "Rough overhangs", - "Bowden tube popped out", - "Poor retractions and overhangs", + "Thermal Runaway", "User Error", - "MatterControl Crash", - "Windows Update", - "Unknown", + "Warping", }; - var optionsButton = new TextButton("Standard Issues".Localize(), theme) - { - HAnchor = HAnchor.Left, - VAnchor = VAnchor.Absolute - }; + var dropdownList = new MHDropDownList("Standard Issues".Localize(), theme, maxHeight: 300 * GuiWidget.DeviceScale); - optionsButton.Click += (s, mouseEvent) => + foreach (var issue in issues) { - var popupMenu = new PopupMenu(theme); + MenuItem newItem = dropdownList.AddItem(issue); - foreach (var issue in issues) + newItem.Selected += (sender, e) => { - var addNotest = popupMenu.CreateMenuItem(issue); - addNotest.Click += (s2, e2) => - { - printTask.Note = issue; - }; - } + textField.Text = issue; + }; + } - popupMenu.ShowMenu(optionsButton, mouseEvent); - }; - - return optionsButton; + return dropdownList; } private void AddQualityMenu(PopupMenu popupMenu) diff --git a/MatterControlLib/PartPreviewWindow/SystemWindowExtension.cs b/MatterControlLib/PartPreviewWindow/SystemWindowExtension.cs index dfed5c344..ea785043a 100644 --- a/MatterControlLib/PartPreviewWindow/SystemWindowExtension.cs +++ b/MatterControlLib/PartPreviewWindow/SystemWindowExtension.cs @@ -58,17 +58,22 @@ namespace MatterHackers.MatterControl.PartPreviewWindow } public MateEdge HorizontalEdge { get; set; } + public MateEdge VerticalEdge { get; set; } public bool Top => this.VerticalEdge.HasFlag(MateEdge.Top); + public bool Bottom => this.VerticalEdge.HasFlag(MateEdge.Bottom); + public bool Left => this.HorizontalEdge.HasFlag(MateEdge.Left); + public bool Right => this.HorizontalEdge.HasFlag(MateEdge.Right); } public class MatePoint { public MateOptions Mate { get; set; } = new MateOptions(); + public MateOptions AltMate { get; set; } = new MateOptions(); public GuiWidget Widget { get; set; } @@ -116,7 +121,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow } } - void widgetRelativeTo_PositionChanged(object sender, EventArgs e) + void WidgetRelativeTo_PositionChanged(object sender, EventArgs e) { if (anchor.Widget?.Parent != null) { @@ -171,7 +176,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow if (settingsRow != null) { - settingsRow.ArrowDirection = settingsRow.ArrowDirection == ArrowDirection.Up ? ArrowDirection.Down: ArrowDirection.Up; + settingsRow.ArrowDirection = settingsRow.ArrowDirection == ArrowDirection.Up ? ArrowDirection.Down : ArrowDirection.Up; } } @@ -191,7 +196,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow } } - widgetRelativeTo_PositionChanged(anchor.Widget, null); + WidgetRelativeTo_PositionChanged(anchor.Widget, null); // When the widgets position changes, sync the popup position systemWindow?.AddChild(popup.Widget); @@ -230,7 +235,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow List ignoredWidgets = popup.Widget.Children.OfType().ToList(); - void widget_Draw(object sender, DrawEventArgs e) + void Widget_Draw(object sender, DrawEventArgs e) { if (borderWidth > 0) { @@ -242,7 +247,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow } } - void widgetRelativeTo_PositionChanged(object sender, EventArgs e) + void WidgetRelativeTo_PositionChanged(object sender, EventArgs e) { if (anchor.Widget?.Parent != null) { @@ -252,21 +257,21 @@ namespace MatterHackers.MatterControl.PartPreviewWindow void CloseMenu() { - popup.Widget.AfterDraw -= widget_Draw; + popup.Widget.AfterDraw -= Widget_Draw; popup.Widget.Close(); - anchor.Widget.Closed -= anchor_Closed; + anchor.Widget.Closed -= Anchor_Closed; // Unbind callbacks on parents for position_changed if we're closing foreach (GuiWidget widget in hookedParents) { - widget.PositionChanged -= widgetRelativeTo_PositionChanged; - widget.BoundsChanged -= widgetRelativeTo_PositionChanged; + widget.PositionChanged -= WidgetRelativeTo_PositionChanged; + widget.BoundsChanged -= WidgetRelativeTo_PositionChanged; } // Long lived originating item must be unregistered - anchor.Widget.Closed -= anchor_Closed; + anchor.Widget.Closed -= Anchor_Closed; // Restore focus to originating widget on close if (anchor.Widget?.HasBeenClosed == false) @@ -296,7 +301,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow }); } - void anchor_Closed(object sender, EventArgs e) + void Anchor_Closed(object sender, EventArgs e) { // If the owning widget closed, so should we CloseMenu(); @@ -306,16 +311,16 @@ namespace MatterHackers.MatterControl.PartPreviewWindow { if (hookedParents.Add(ancestor)) { - ancestor.PositionChanged += widgetRelativeTo_PositionChanged; - ancestor.BoundsChanged += widgetRelativeTo_PositionChanged; + ancestor.PositionChanged += WidgetRelativeTo_PositionChanged; + ancestor.BoundsChanged += WidgetRelativeTo_PositionChanged; } } popup.Widget.ContainsFocusChanged += FocusChanged; - popup.Widget.AfterDraw += widget_Draw; + popup.Widget.AfterDraw += Widget_Draw; - widgetRelativeTo_PositionChanged(anchor.Widget, null); - anchor.Widget.Closed += anchor_Closed; + WidgetRelativeTo_PositionChanged(anchor.Widget, null); + anchor.Widget.Closed += Anchor_Closed; // When the widgets position changes, sync the popup position systemWindow?.AddChild(popup.Widget); diff --git a/MatterControlLib/SettingsManagement/ApplicationSettingsPage.cs b/MatterControlLib/SettingsManagement/ApplicationSettingsPage.cs index 582dbaea2..d5db2592e 100644 --- a/MatterControlLib/SettingsManagement/ApplicationSettingsPage.cs +++ b/MatterControlLib/SettingsManagement/ApplicationSettingsPage.cs @@ -219,7 +219,7 @@ namespace MatterHackers.MatterControl #if !__ANDROID__ // ThumbnailRendering - var thumbnailsModeDropList = new MHDropDownList("", theme, maxHeight: 200); + var thumbnailsModeDropList = new MHDropDownList("", theme, maxHeight: 200 * GuiWidget.DeviceScale); thumbnailsModeDropList.AddItem("Flat".Localize(), "orthographic"); thumbnailsModeDropList.AddItem("3D".Localize(), "raytraced"); diff --git a/MatterControlLib/SetupWizard/InputBoxPage.cs b/MatterControlLib/SetupWizard/InputBoxPage.cs index 532e1822d..093c5b29c 100644 --- a/MatterControlLib/SetupWizard/InputBoxPage.cs +++ b/MatterControlLib/SetupWizard/InputBoxPage.cs @@ -38,11 +38,13 @@ namespace MatterHackers.MatterControl { private MHTextEditWidget textEditWidget; + public override string Text { get => textEditWidget.Text; set => textEditWidget.Text = value; } + public InputBoxPage(string windowTitle, string label, string initialValue, string emptyText, string actionButtonTitle, Action action) { this.WindowTitle = windowTitle; this.HeaderText = windowTitle; - this.WindowSize = new Vector2(500, 200); + this.WindowSize = new Vector2(500 * GuiWidget.DeviceScale, 200 * GuiWidget.DeviceScale); GuiWidget actionButton = null; diff --git a/MatterControlLib/SlicerConfiguration/PresetSelectorWidget.cs b/MatterControlLib/SlicerConfiguration/PresetSelectorWidget.cs index ccf3f5206..25350664f 100644 --- a/MatterControlLib/SlicerConfiguration/PresetSelectorWidget.cs +++ b/MatterControlLib/SlicerConfiguration/PresetSelectorWidget.cs @@ -228,7 +228,7 @@ namespace MatterHackers.MatterControl.SlicerConfiguration private DropDownList CreateDropdown() { - var dropDownList = new MHDropDownList(defaultMenuItemText, theme, maxHeight: 300, useLeftIcons: true) + var dropDownList = new MHDropDownList(defaultMenuItemText, theme, maxHeight: 300 * GuiWidget.DeviceScale, useLeftIcons: true) { HAnchor = HAnchor.Stretch, VAnchor = VAnchor.Center, diff --git a/MatterControlLib/SlicerConfiguration/UIFields/ComPortField.cs b/MatterControlLib/SlicerConfiguration/UIFields/ComPortField.cs index ab18f8a80..ec5731b59 100644 --- a/MatterControlLib/SlicerConfiguration/UIFields/ComPortField.cs +++ b/MatterControlLib/SlicerConfiguration/UIFields/ComPortField.cs @@ -65,7 +65,7 @@ namespace MatterHackers.MatterControl.SlicerConfiguration // bind to a context that will place it in the SliceSetting view but it binds its values to a machine // specific dictionary key that is not exposed in the UI. At runtime we lookup and store to '_com_port' // ensuring that a single printer can be shared across different devices and we'll select the correct com port in each case - dropdownList = new MHDropDownList("None".Localize(), theme, maxHeight: 200) + dropdownList = new MHDropDownList("None".Localize(), theme, maxHeight: 200 * GuiWidget.DeviceScale) { ToolTipText = this.HelpText, Margin = new BorderDouble(), diff --git a/MatterControlLib/SlicerConfiguration/UIFields/DropMenuWrappedField.cs b/MatterControlLib/SlicerConfiguration/UIFields/DropMenuWrappedField.cs index d0174d36e..5675e1ec1 100644 --- a/MatterControlLib/SlicerConfiguration/UIFields/DropMenuWrappedField.cs +++ b/MatterControlLib/SlicerConfiguration/UIFields/DropMenuWrappedField.cs @@ -65,7 +65,7 @@ namespace MatterHackers.MatterControl.SlicerConfiguration { var totalContent = new FlowLayoutWidget(); - var selectableOptions = new MHDropDownList("Custom", theme, maxHeight: 200) + var selectableOptions = new MHDropDownList("Custom", theme, maxHeight: 200 * GuiWidget.DeviceScale) { Margin = new BorderDouble(0, 0, 10, 0) }; diff --git a/MatterControlLib/SlicerConfiguration/UIFields/IpAddessField.cs b/MatterControlLib/SlicerConfiguration/UIFields/IpAddessField.cs index a170f010d..8194b02c2 100644 --- a/MatterControlLib/SlicerConfiguration/UIFields/IpAddessField.cs +++ b/MatterControlLib/SlicerConfiguration/UIFields/IpAddessField.cs @@ -34,7 +34,7 @@ namespace MatterHackers.MatterControl.SlicerConfiguration bool canChangeComPort = !printer.Connection.IsConnected && printer.Connection.CommunicationState != CommunicationStates.AttemptingToConnect; //This setting defaults to Manual var selectedMachine = printer.Settings.GetValue(SettingsKey.selector_ip_address); - dropdownList = new MHDropDownList(selectedMachine, theme, maxHeight: 200) + dropdownList = new MHDropDownList(selectedMachine, theme, maxHeight: 200 * GuiWidget.DeviceScale) { ToolTipText = HelpText, Margin = new BorderDouble(), diff --git a/MatterControlLib/SlicerConfiguration/UIFields/ListField.cs b/MatterControlLib/SlicerConfiguration/UIFields/ListField.cs index 458e63558..5efd93ab4 100644 --- a/MatterControlLib/SlicerConfiguration/UIFields/ListField.cs +++ b/MatterControlLib/SlicerConfiguration/UIFields/ListField.cs @@ -49,7 +49,7 @@ namespace MatterHackers.MatterControl.SlicerConfiguration public override void Initialize(int tabIndex) { - dropdownList = new MHDropDownList("None".Localize(), theme, maxHeight: 200) + dropdownList = new MHDropDownList("None".Localize(), theme, maxHeight: 200 * GuiWidget.DeviceScale) { ToolTipText = this.HelpText, TabIndex = tabIndex, diff --git a/MatterControlLib/SlicerConfiguration/UIFields/SliceEngineField.cs b/MatterControlLib/SlicerConfiguration/UIFields/SliceEngineField.cs index 5044c7777..e674926f7 100644 --- a/MatterControlLib/SlicerConfiguration/UIFields/SliceEngineField.cs +++ b/MatterControlLib/SlicerConfiguration/UIFields/SliceEngineField.cs @@ -56,7 +56,7 @@ namespace MatterHackers.MatterControl.SlicerConfiguration var panel = new FlowLayoutWidget(); - dropdownList = new MHDropDownList("None".Localize(), theme, maxHeight: 200) + dropdownList = new MHDropDownList("None".Localize(), theme, maxHeight: 200 * GuiWidget.DeviceScale) { ToolTipText = this.HelpText, TabIndex = tabIndex, diff --git a/Submodules/agg-sharp b/Submodules/agg-sharp index b853bade0..fe25a4b92 160000 --- a/Submodules/agg-sharp +++ b/Submodules/agg-sharp @@ -1 +1 @@ -Subproject commit b853bade0ebbf776d6b9b828d83b4c9a486bb74c +Subproject commit fe25a4b92814e99db13c24b57dd6b2ba2887a878