From 5455078127308dca6ae3c3eea18c688ec8121323 Mon Sep 17 00:00:00 2001 From: LarsBrubaker Date: Fri, 29 May 2020 08:15:32 -0700 Subject: [PATCH 1/5] Incorporating UI designer feedback Changed flatten to apply Changed delete to cancel --- .../CustomWidgets/SimpleButton.cs | 8 +++++ .../PartPreviewWindow/SelectedObjectPanel.cs | 33 +++++++++++------- StaticData/Icons/apply.png | Bin 0 -> 1539 bytes StaticData/Icons/cancel.png | Bin 0 -> 1474 bytes Submodules/agg-sharp | 2 +- 5 files changed, 29 insertions(+), 14 deletions(-) create mode 100644 StaticData/Icons/apply.png create mode 100644 StaticData/Icons/cancel.png diff --git a/MatterControlLib/CustomWidgets/SimpleButton.cs b/MatterControlLib/CustomWidgets/SimpleButton.cs index c3f686158..5f6eb8cca 100644 --- a/MatterControlLib/CustomWidgets/SimpleButton.cs +++ b/MatterControlLib/CustomWidgets/SimpleButton.cs @@ -85,6 +85,14 @@ namespace MatterHackers.MatterControl.CustomWidgets this.Invalidate(); } + protected override void OnClick(MouseEventArgs mouseEvent) + { + if (mouseEvent.Button == MouseButtons.Left) + { + base.OnClick(mouseEvent); + } + } + public override void OnKeyUp(KeyEventArgs keyEvent) { if (keyEvent.KeyCode == Keys.Enter diff --git a/MatterControlLib/PartPreviewWindow/SelectedObjectPanel.cs b/MatterControlLib/PartPreviewWindow/SelectedObjectPanel.cs index 796e9b3a5..adf699c03 100644 --- a/MatterControlLib/PartPreviewWindow/SelectedObjectPanel.cs +++ b/MatterControlLib/PartPreviewWindow/SelectedObjectPanel.cs @@ -76,12 +76,21 @@ namespace MatterHackers.MatterControl.PartPreviewWindow scene = sceneContext.Scene; + // put in the container for dynamic actions + primaryActionsPanel = new FlowLayoutWidget() + { + HAnchor = HAnchor.Fit, + VAnchor = VAnchor.Center | VAnchor.Fit + }; + + toolbar.AddChild(primaryActionsPanel); + // put in a make permanent button - var icon = AggContext.StaticData.LoadIcon("noun_766157.png", 16, 16, theme.InvertIcons).SetPreMultiply(); + var icon = AggContext.StaticData.LoadIcon("apply.png", 16, 16, theme.InvertIcons).SetPreMultiply(); flattenButton = new IconButton(icon, theme) { Margin = theme.ButtonSpacing, - ToolTipText = "Flatten".Localize(), + ToolTipText = "Apply".Localize(), Enabled = true }; flattenButton.Click += (s, e) => @@ -103,10 +112,10 @@ namespace MatterHackers.MatterControl.PartPreviewWindow toolbar.AddChild(flattenButton); // put in a remove button - removeButton = new IconButton(AggContext.StaticData.LoadIcon("remove.png", 16, 16, theme.InvertIcons), theme) + removeButton = new IconButton(AggContext.StaticData.LoadIcon("cancel.png", 16, 16, theme.InvertIcons), theme) { Margin = theme.ButtonSpacing, - ToolTipText = "Delete".Localize(), + ToolTipText = "Cancel".Localize(), Enabled = scene.SelectedItem != null }; removeButton.Click += (s, e) => @@ -119,14 +128,6 @@ namespace MatterHackers.MatterControl.PartPreviewWindow }; toolbar.AddChild(removeButton); - primaryActionsPanel = new FlowLayoutWidget() - { - HAnchor = HAnchor.Fit, - VAnchor = VAnchor.Center | VAnchor.Fit - }; - - toolbar.AddChild(primaryActionsPanel); - overflowButton = new OverflowBar.OverflowMenuButton(theme) { Enabled = scene.SelectedItem != null, @@ -229,6 +230,12 @@ namespace MatterHackers.MatterControl.PartPreviewWindow } } + if(primaryActionsPanel.Children.Any()) + { + // add in a separator from the apply and cancel buttons + primaryActionsPanel.AddChild(new ToolbarSeparator(theme)); + } + editorSectionWidget.Text = selectedItem.Name ?? selectedItemType.Name; HashSet mappedEditors = ApplicationController.Instance.Extensions.GetEditorsForType(selectedItemType); @@ -430,7 +437,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow flattenButton.Enabled = selectedItem != null && (selectedItem is GroupObject3D - || selectedItem.GetType() == typeof(Object3D) + || (selectedItem.GetType() == typeof(Object3D) && selectedItem.Children.Any()) || selectedItem.CanFlatten); removeButton.Enabled = selectedItem != null; overflowButton.Enabled = selectedItem != null; diff --git a/StaticData/Icons/apply.png b/StaticData/Icons/apply.png new file mode 100644 index 0000000000000000000000000000000000000000..b89ddbd279404f95c33adcf5708776557f4e0ec1 GIT binary patch literal 1539 zcmeAS@N?(olHy`uVBq!ia0y~yU{C;I4mJh`hT^KKFANM!_p3r8N`ey06$*;-(=u~X z6-p`#QWa7wGSe6sDsH`<9ysZa22b04OV_>zm6jug8yZ*bJt${yKcmpUTy3S-CjQ?S zmhnVzaDL&eQu|W>U-F@}oR*Mt(C3(LgeCI>c=X@*IsE+fUzio58{^{p) zN_h9ys5=|XIyA4~fu4$B={&BYy`t+ErD+CqC9OWc!u8MV8?C#43+>tcU1)d2_LzCj zf=TzdeyX}f`~50?6V_t4zC&)_d^Vpvar+~AJ~OjhqO7OVG6~ zJxLX!wb4r#SZu3kieNs={FEo8L-4I*r&OramGJ6IovLc@ax!N6Pg5;6)T?1)@SN4k zHd`dqQO3kCK)B;)9JlWN)SuQTAMO-1nVHZdc5u4TKB0e}J9&EzgQsi!lGR?*o&G9O za`K%u3t1IR%6v+XmQVelng2+A15?wkLvL;*^d3)r6j1eKn$9^U+g{BhuQMiW&1Fz* z%0HUq;h>NvwAAO~j9!kyk`F5*EWIBwvv^FEZe=u6k}R0BJpYVg)UGu(orPN&TD*=0 z77DCtm^w+RUdOU%#i|UhRkN;M*_v^7Qt-7oo1a#?hYEWyn|Aih+KAGRPhQP&^RSteYtnd!QGO2wqvXOa?SxKaa@=N3r$CMnFY+Q_%-rtOKp zlcFztiN5nA{mCJh@9`73h3~3;SKh9_V(YHDz!b(=%L|T~oH}rnt@Yj1z31*PvClhv zU#dd73JL!DFCq2gG2{QNw)YBiCcIAl+v?81z`&N|?e4&pIwRhCao?fuMmY77iaOFdm2Ln00zo$l)q>L_x&e*3)l zd;jRE@&+wrip@}U$w<3szNJ$`Ly0AG;_R@sESbU{7ua3p1uiaX(%^`45jklbu%Rhx z3x^KJA+ALWT(@u>&AC`%H5C?eBs03oxr$Hd z`m&z=R)eX7^#v`N#|N?>h<;%EVIZ!kDi_Tb;DDKsKjYZ)(yYK?#M1sb90#A z`a~i?bi(DJ2Mbv1xlXikWNdEu&i*f8St(O+S9)|ugEm)*iP46im*0lP9Cq00@6gR; z!=$C$RL&sZSo&!m<2mhfdh;6&pQ@~O`M`T1|6r}T%bL(Rf9)8f8@-uR&M zx8lLg2UdLiJ9(A$f0mR6&ch$qan+riaXaTsDdXj7^4}#lIMw{R8nf5ep|wa#q+LsM zt!ZjA-%`6L(fl7w z7Od>GXu7`gyJxuho`us+-MQ@Ra4z_B@v}=()7a#s>h?Fdu8S>jnV1)n(tAMI`-7r; zL3FO(+LUcN(Q0=zA-t z^|8zaz1sN4$6{7`*@#b;dZ1HqV$=QoOxqjvFEM95U2-MoqwM5c28PpvKPDw4$hBYU zKCo$mbLJ`sKkLS7!N%ePdZ)$uyc*@WQ#-FSM>jHaeRjw?#JzKlPg{&f63dNCVR}2} oU-DjbyoTk^^ob(BC;ei->!J9rIbhZg1_lNOPgg&ebxsLQ0NyRR1^@s6 literal 0 HcmV?d00001 diff --git a/StaticData/Icons/cancel.png b/StaticData/Icons/cancel.png new file mode 100644 index 0000000000000000000000000000000000000000..5eda13148f82a8fedfc5f840afdeac385ddd84dd GIT binary patch literal 1474 zcmeAS@N?(olHy`uVBq!ia0y~yU{C;I4mJh`hT^KKFANM!_p3r8N`ey06$*;-(=u~X z6-p`#QWa7wGSe6sDsH`<9$555gQxAj?Kf^=u6)QY=JkJ)Nw0z{LD!T4P#h!Vqm(B>=D|gTNN8P0M>IOxj zEk(7@_I=fU@@qyy=IQ?Q$_>T0Kjvoe*GNoxSy^?vY9B9We9^7@3*S_l*4{c-w^wI= z@g>tQpXTx$%;2g%)VOdGpzP^2Fnl%-ud4{@S{GmXXrb!}qQn4-4b(Vt3Na zj&d{H)3tAHP=HLdjpLfeXN^T{T1Ps*EpX}8;(fK+_T>>F;c~MrXVgzm+9@G!$Jn59 z)~VUIYl{M(ocapRBQ@(=r`_N5XYP{^cQ|JG7`V;&xU}Vc%l_az=j1b2RJ-bqbG?2v zvnt}4ig|VhBS)`naO}re)tXbYe{im8Sg_8(+AQL6;Y^DuaywPKH#_(zbA7auO39UW z=y(vlQ9?+dW2TE{ut}P-lZ z3)nW^Z0DSHz0)sE;aI1`9W_Q36aTb}nyT}jsBMmrXm^sl;-NmrZL$Q%GQTy=d1d@X z`=5xJ{MF9;V_cND=(q5bLoVA-);|5lyEW{(ewU8JXOVL=+$4A0Sa4zQrt3dvf4QCe zV?EowHe~qEzK!i)#ew~^9?GXRPx#=tF?1gT0|Q%s*@{NxjPA-&x`-b728c)t^ zlYqa`4Obgi)H5U>kV_D~z&E9l_WHg6d++;d#xlk& zS2~{vU3kNw!PMPY`1pUotzt$#*K1#jm|Q07O#fy-i9LWRPP2Ws&`zaQ*UJdGJ4R|C{gYt z6KWUV=&INdro2y0VamzZ8Pkm+NSxS<NyIhemF(R*mMn!|h_kDZ^rRvN34l*<0K(yf@B2NeQ}`F^#3~?i4G= zEoarW*Ihk(U~NmIdShOHnc~OW1xpW Date: Fri, 29 May 2020 19:08:41 -0700 Subject: [PATCH 2/5] Changed cut copy past menu items into a grouped item --- MatterControl.Printing/NamedAction.cs | 5 ++ .../ApplicationView/ApplicationController.cs | 61 ++++++------- .../ApplicationView/Themes/ThemeConfig.cs | 88 +++++++++++++++---- .../PartPreviewWindow/PopupMenu.cs | 19 ++-- .../SystemWindowExtension.cs | 2 +- .../View3D/PrinterBar/PrinterActionsBar.cs | 5 +- .../PartPreviewWindow/View3D/View3DWidget.cs | 10 +-- .../PartPreviewWindow/ViewControls3D.cs | 4 +- 8 files changed, 123 insertions(+), 71 deletions(-) diff --git a/MatterControl.Printing/NamedAction.cs b/MatterControl.Printing/NamedAction.cs index 9f81d072e..ab0103aee 100644 --- a/MatterControl.Printing/NamedAction.cs +++ b/MatterControl.Printing/NamedAction.cs @@ -60,6 +60,11 @@ namespace MatterHackers.MatterControl public Action SetIsActive { get; set; } } + public class NamedActionGroup : NamedAction + { + public NamedAction[] Group { get; set; } + } + public static class NamedActionExtensions { public static void Add(this List list, string title, Action action) diff --git a/MatterControlLib/ApplicationView/ApplicationController.cs b/MatterControlLib/ApplicationView/ApplicationController.cs index 86951f40e..e23ddc131 100644 --- a/MatterControlLib/ApplicationView/ApplicationController.cs +++ b/MatterControlLib/ApplicationView/ApplicationController.cs @@ -319,9 +319,7 @@ namespace MatterHackers.MatterControl var actions = new[] { new ActionSeparator(), - workspaceActions["Cut"], - workspaceActions["Copy"], - workspaceActions["Paste"], + workspaceActions["Edit"], new ActionSeparator(), new NamedAction() { @@ -578,7 +576,7 @@ namespace MatterHackers.MatterControl if (e.Operation != WorkspacesChangedEventArgs.OperationType.Restore) { - UiThread.RunOnIdle(async() => + UiThread.RunOnIdle(async () => { await ApplicationController.Instance.PersistUserTabs(); }); @@ -1158,38 +1156,35 @@ namespace MatterHackers.MatterControl || (sceneContext.EditContext.SourceItem is ILibraryAsset libraryAsset && string.Equals(Path.GetExtension(libraryAsset.FileName), ".gcode", StringComparison.OrdinalIgnoreCase)) }, - new NamedAction() + new NamedActionGroup() { - ID = "Cut", - Title = "Cut".Localize(), - Shortcut = "Ctrl+X", - Action = () => + ID = "Edit", + Title = "Edit", + Group = new NamedAction[] { - sceneContext.Scene.Cut(); + new NamedAction() + { + ID = "Cut", + Title = "Cut".Localize(), + Action = () => sceneContext.Scene.Cut(), + IsEnabled = () => sceneContext.Scene.SelectedItem != null + }, + new NamedAction() + { + ID = "Copy", + Title = "Copy".Localize(), + Action = () => sceneContext.Scene.Copy(), + IsEnabled = () => sceneContext.Scene.SelectedItem != null + }, + new NamedAction() + { + ID = "Paste", + Title = "Paste".Localize(), + Action = () => sceneContext.Paste(), + IsEnabled = () => Clipboard.Instance.ContainsImage || Clipboard.Instance.GetText() == "!--IObjectSelection--!" + } }, - IsEnabled = () => sceneContext.Scene.SelectedItem != null - }, - new NamedAction() - { - ID = "Copy", - Title = "Copy".Localize(), - Shortcut = "Ctrl+C", - Action = () => - { - sceneContext.Scene.Copy(); - }, - IsEnabled = () => sceneContext.Scene.SelectedItem != null - }, - new NamedAction() - { - ID = "Paste", - Title = "Paste".Localize(), - Shortcut = "Ctrl+V", - Action = () => - { - sceneContext.Paste(); - }, - IsEnabled = () => Clipboard.Instance.ContainsImage || Clipboard.Instance.GetText() == "!--IObjectSelection--!" + IsEnabled = () => true, }, new NamedAction() { diff --git a/MatterControlLib/ApplicationView/Themes/ThemeConfig.cs b/MatterControlLib/ApplicationView/Themes/ThemeConfig.cs index 790772b16..c837c9c58 100644 --- a/MatterControlLib/ApplicationView/Themes/ThemeConfig.cs +++ b/MatterControlLib/ApplicationView/Themes/ThemeConfig.cs @@ -415,30 +415,82 @@ namespace MatterHackers.MatterControl } else { - PopupMenu.MenuItem menuItem; - - if (menuAction is NamedBoolAction boolAction) + if (menuAction is NamedActionGroup namedActionButtons) { - menuItem = popupMenu.CreateBoolMenuItem(menuAction.Title, boolAction.GetIsActive, boolAction.SetIsActive); + var content = new FlowLayoutWidget() + { + HAnchor = HAnchor.Fit | HAnchor.Stretch + }; + + var textWidget = new TextWidget(menuAction.Title, pointSize: this.DefaultFontSize, textColor: this.TextColor) + { + // Padding = MenuPadding, + VAnchor = VAnchor.Center + }; + content.AddChild(textWidget); + + content.AddChild(new HorizontalSpacer()); + + foreach (var actionButton in namedActionButtons.Group) + { + var button = new TextButton(actionButton.Title, this) + { + Border = new BorderDouble(1, 0, 0, 0), + BorderColor = this.MinimalShade, + HoverColor = this.AccentMimimalOverlay + }; + + content.AddChild(button); + + if (actionButton.IsEnabled()) + { + button.Click += (s, e) => + { + actionButton.Action(); + popupMenu.Unfocus(); + }; + } + } + + var menuItem = new PopupMenu.MenuItem(content, this) + { + HAnchor = HAnchor.Fit | HAnchor.Stretch, + VAnchor = VAnchor.Fit, + HoverColor = Color.Transparent, + }; + popupMenu.AddChild(menuItem); + menuItem.Padding = new BorderDouble(menuItem.Padding.Left, + menuItem.Padding.Bottom, + 0, + menuItem.Padding.Top); } else { - menuItem = popupMenu.CreateMenuItem(menuAction.Title, menuAction.Icon, menuAction.Shortcut); - } + PopupMenu.MenuItem menuItem; - menuItem.Name = $"{menuAction.Title} Menu Item"; - - menuItem.Enabled = menuAction.Action != null - && menuAction.IsEnabled?.Invoke() != false; - - menuItem.ClearRemovedFlag(); - - if (menuItem.Enabled) - { - menuItem.Click += (s, e) => + if (menuAction is NamedBoolAction boolAction) { - menuAction.Action(); - }; + menuItem = popupMenu.CreateBoolMenuItem(menuAction.Title, boolAction.GetIsActive, boolAction.SetIsActive); + } + else + { + menuItem = popupMenu.CreateMenuItem(menuAction.Title, menuAction.Icon, menuAction.Shortcut); + } + + menuItem.Name = $"{menuAction.Title} Menu Item"; + + menuItem.Enabled = menuAction is NamedActionGroup + || (menuAction.Action != null && menuAction.IsEnabled?.Invoke() != false); + + menuItem.ClearRemovedFlag(); + + if (menuItem.Enabled) + { + menuItem.Click += (s, e) => + { + menuAction.Action(); + }; + } } } } diff --git a/MatterControlLib/PartPreviewWindow/PopupMenu.cs b/MatterControlLib/PartPreviewWindow/PopupMenu.cs index 3ab89b198..8f9321557 100644 --- a/MatterControlLib/PartPreviewWindow/PopupMenu.cs +++ b/MatterControlLib/PartPreviewWindow/PopupMenu.cs @@ -123,7 +123,6 @@ namespace MatterHackers.MatterControl.PartPreviewWindow { public PopupMenu SubMenu { get; set; } - public SubMenuItemButton(GuiWidget content, ThemeConfig theme) : base(content, theme) { } @@ -308,7 +307,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow UiThread.RunOnIdle(() => { populateSubMenu(subMenu); - + systemWindow.ShowPopup( new MatePoint(subMenuItemButton) { @@ -319,15 +318,14 @@ namespace MatterHackers.MatterControl.PartPreviewWindow { Mate = new MateOptions(MateEdge.Left, MateEdge.Top), AltMate = new MateOptions(MateEdge.Right, MateEdge.Top) - } - );// altBounds: new RectangleDouble(mouseEvent.X + 1, mouseEvent.Y + 1, mouseEvent.X + 1, mouseEvent.Y + 1)); + }); // altBounds: new RectangleDouble(mouseEvent.X + 1, mouseEvent.Y + 1, mouseEvent.X + 1, mouseEvent.Y + 1)); }); subMenu.Closed += (s1, e1) => { subMenu.ClearRemovedFlag(); subMenuItemButton.SubMenu = null; - if(!this.ContainsFocus) + if (!this.ContainsFocus) { this.Close(); } @@ -365,7 +363,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow public MenuItem CreateBoolMenuItem(GuiWidget guiWidget, string name, Func getter, Action setter, bool useRadioStyle = false, IList siblingRadioButtonList = null) { - bool isChecked = (getter?.Invoke() == true); + bool isChecked = getter?.Invoke() == true; MenuItem menuItem; @@ -397,7 +395,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow return; } - isChecked = radioMenu.Checked = !radioMenu.Checked; + isChecked = radioMenu.Checked = !radioMenu.Checked; } else if (menuItem is CheckboxMenuItem checkboxMenu) { @@ -433,10 +431,10 @@ namespace MatterHackers.MatterControl.PartPreviewWindow private GuiWidget content; public MenuItem(GuiWidget content, ThemeConfig theme) - : base (theme) + : base(theme) { // Inflate padding to match the target (MenuGutterWidth) after scale operation in assignment - this.Padding = new BorderDouble(left: Math.Ceiling(theme.MenuGutterWidth / GuiWidget.DeviceScale) , right: 15); + this.Padding = new BorderDouble(left: Math.Ceiling(theme.MenuGutterWidth / DeviceScale), right: 15); this.HAnchor = HAnchor.MaxFitOrStretch; this.VAnchor = VAnchor.Fit; this.MinimumSize = new Vector2(150 * GuiWidget.DeviceScale, theme.ButtonHeight); @@ -455,6 +453,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow public ImageBuffer Image { get; set; } private ImageBuffer _disabledImage; + public ImageBuffer DisabledImage { get @@ -491,7 +490,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow var x = this.LocalBounds.Left + (this.GutterWidth / 2 - this.Image.Width / 2); var y = this.Size.Y / 2 - this.Image.Height / 2; - graphics2D.Render((this.Enabled) ? this.Image : this.DisabledImage, (int)x, (int)y); + graphics2D.Render(this.Enabled ? this.Image : this.DisabledImage, (int)x, (int)y); } base.OnDraw(graphics2D); diff --git a/MatterControlLib/PartPreviewWindow/SystemWindowExtension.cs b/MatterControlLib/PartPreviewWindow/SystemWindowExtension.cs index 446c659f2..ae3925ea4 100644 --- a/MatterControlLib/PartPreviewWindow/SystemWindowExtension.cs +++ b/MatterControlLib/PartPreviewWindow/SystemWindowExtension.cs @@ -191,7 +191,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow // When the widgets position changes, sync the popup position systemWindow?.AddChild(popup.Widget); - if(secondsToClose > 0) + if (secondsToClose > 0) { UiThread.RunOnIdle(() => anchor_Closed(null, null), secondsToClose); } diff --git a/MatterControlLib/PartPreviewWindow/View3D/PrinterBar/PrinterActionsBar.cs b/MatterControlLib/PartPreviewWindow/View3D/PrinterBar/PrinterActionsBar.cs index 2edf75138..02000e57b 100644 --- a/MatterControlLib/PartPreviewWindow/View3D/PrinterBar/PrinterActionsBar.cs +++ b/MatterControlLib/PartPreviewWindow/View3D/PrinterBar/PrinterActionsBar.cs @@ -240,6 +240,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow } bool buttonIsBeingClicked; + private void SwitchModes_Click(object sender, MouseEventArgs e) { buttonIsBeingClicked = true; @@ -260,6 +261,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow printer.ViewState.ViewMode = PartViewMode.Model; } } + buttonIsBeingClicked = false; } @@ -363,7 +365,6 @@ namespace MatterHackers.MatterControl.PartPreviewWindow Title = "Restore Settings".Localize(), Action = () => { - DialogWindow.Show(new PrinterProfileHistoryPage(printer)); } }, @@ -445,6 +446,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow DialogWindow.Show(repetierEEPromPage); } + break; case FirmwareTypes.Marlin: @@ -462,6 +464,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow DialogWindow.Show(marlinEEPromPage); } + break; default: diff --git a/MatterControlLib/PartPreviewWindow/View3D/View3DWidget.cs b/MatterControlLib/PartPreviewWindow/View3D/View3DWidget.cs index a44151a5d..dd05f96a8 100644 --- a/MatterControlLib/PartPreviewWindow/View3D/View3DWidget.cs +++ b/MatterControlLib/PartPreviewWindow/View3D/View3DWidget.cs @@ -1537,12 +1537,12 @@ namespace MatterHackers.MatterControl.PartPreviewWindow new MatePoint(this) { Mate = new MateOptions(MateEdge.Left, MateEdge.Top), - AltMate = new MateOptions(MateEdge.Left, MateEdge.Top) + AltMate = new MateOptions(MateEdge.Right, MateEdge.Bottom) }, new MatePoint(menu) { Mate = new MateOptions(MateEdge.Left, MateEdge.Top), - AltMate = new MateOptions(MateEdge.Left, MateEdge.Top) + AltMate = new MateOptions(MateEdge.Right, MateEdge.Bottom) }, altBounds: new RectangleDouble(mouseEvent.X + 1, mouseEvent.Y + 1, mouseEvent.X + 1, mouseEvent.Y + 1)); } @@ -1585,12 +1585,12 @@ namespace MatterHackers.MatterControl.PartPreviewWindow new MatePoint(this) { Mate = new MateOptions(MateEdge.Left, MateEdge.Bottom), - AltMate = new MateOptions(MateEdge.Left, MateEdge.Top) + AltMate = new MateOptions(MateEdge.Right, MateEdge.Top) }, new MatePoint(popupMenu) { - Mate = new MateOptions(MateEdge.Left, MateEdge.Top), - AltMate = new MateOptions(MateEdge.Left, MateEdge.Top) + Mate = new MateOptions(MateEdge.Left, MateEdge.Bottom), + AltMate = new MateOptions(MateEdge.Right, MateEdge.Top) }, altBounds: popupBounds); } diff --git a/MatterControlLib/PartPreviewWindow/ViewControls3D.cs b/MatterControlLib/PartPreviewWindow/ViewControls3D.cs index a0e551cdd..0446a4c11 100644 --- a/MatterControlLib/PartPreviewWindow/ViewControls3D.cs +++ b/MatterControlLib/PartPreviewWindow/ViewControls3D.cs @@ -574,9 +574,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow var actions = new NamedAction[] { new ActionSeparator(), - workspaceActions["Cut"], - workspaceActions["Copy"], - workspaceActions["Paste"], + workspaceActions["Edit"], new ActionSeparator(), workspaceActions["Print"], new ActionSeparator(), From 392583ad7959c485a1d478cf930da074284847dc Mon Sep 17 00:00:00 2001 From: LarsBrubaker Date: Sat, 30 May 2020 08:59:32 -0700 Subject: [PATCH 3/5] sorting --- MatterControl.Printing/NamedAction.cs | 12 ++++++------ MatterControlLib/CustomWidgets/NamedAction.cs | 14 +++++++------- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/MatterControl.Printing/NamedAction.cs b/MatterControl.Printing/NamedAction.cs index ab0103aee..1502ee8ac 100644 --- a/MatterControl.Printing/NamedAction.cs +++ b/MatterControl.Printing/NamedAction.cs @@ -36,17 +36,17 @@ namespace MatterHackers.MatterControl { public class NamedAction { - public string Title { get; set; } - - public string Shortcut { get; set; } - public Action Action { get; set; } - public ImageBuffer Icon { get; set; } - public Func IsEnabled { get; set; } + public ImageBuffer Icon { get; set; } + public string ID { get; set; } + + public string Shortcut { get; set; } + + public string Title { get; set; } } public class ActionSeparator : NamedAction diff --git a/MatterControlLib/CustomWidgets/NamedAction.cs b/MatterControlLib/CustomWidgets/NamedAction.cs index 41e5cd32c..de4509e9d 100644 --- a/MatterControlLib/CustomWidgets/NamedAction.cs +++ b/MatterControlLib/CustomWidgets/NamedAction.cs @@ -41,19 +41,19 @@ namespace MatterHackers.Agg.UI { public Action Action { get; set; } - public Func IsEnabled { get; set; } = (sceneContext) => true; - - public Type OperationType { get; set; } - public Func Icon { get; set; } - public Func TitleResolver { get; set; } - - public string Title => this.TitleResolver?.Invoke(); + public Func IsEnabled { get; set; } = (sceneContext) => true; public Func HelpTextResolver { get; set; } + public Func TitleResolver { get; set; } + public string HelpText => this.HelpTextResolver?.Invoke(); + + public string Title => this.TitleResolver?.Invoke(); + + public Type OperationType { get; set; } } public class SceneSelectionSeparator : SceneSelectionOperation From 04b29f8fd9789652b6fdf201d959b5441c81828f Mon Sep 17 00:00:00 2001 From: LarsBrubaker Date: Sat, 30 May 2020 08:59:52 -0700 Subject: [PATCH 4/5] Respect enabled on widget --- MatterControlLib/ApplicationView/Themes/ThemeConfig.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/MatterControlLib/ApplicationView/Themes/ThemeConfig.cs b/MatterControlLib/ApplicationView/Themes/ThemeConfig.cs index c837c9c58..39b93d66a 100644 --- a/MatterControlLib/ApplicationView/Themes/ThemeConfig.cs +++ b/MatterControlLib/ApplicationView/Themes/ThemeConfig.cs @@ -437,7 +437,8 @@ namespace MatterHackers.MatterControl { Border = new BorderDouble(1, 0, 0, 0), BorderColor = this.MinimalShade, - HoverColor = this.AccentMimimalOverlay + HoverColor = this.AccentMimimalOverlay, + Enabled = actionButton.IsEnabled() }; content.AddChild(button); From 3d6fe51e32322d6e7fec1f78a56aa16167164619 Mon Sep 17 00:00:00 2001 From: LarsBrubaker Date: Sat, 30 May 2020 16:50:36 -0700 Subject: [PATCH 5/5] Make the design tabs able to shrink --- .../ApplicationView/ApplicationController.cs | 5 +++++ .../PartPreviewWindow/MainViewWidget.cs | 14 ++++++++++++- MatterControlLib/PartPreviewWindow/Tabs.cs | 20 ++++++++++++------- .../Inlines/AggLinkInlineRenderer.cs | 18 +++++++++++++++-- Submodules/MatterSlice | 2 +- 5 files changed, 48 insertions(+), 11 deletions(-) diff --git a/MatterControlLib/ApplicationView/ApplicationController.cs b/MatterControlLib/ApplicationView/ApplicationController.cs index e23ddc131..32a635cc7 100644 --- a/MatterControlLib/ApplicationView/ApplicationController.cs +++ b/MatterControlLib/ApplicationView/ApplicationController.cs @@ -2760,6 +2760,11 @@ namespace MatterHackers.MatterControl public void NotifyPrintersTabRightElement(GuiWidget sourceExentionArea) { AddPrintersTabRightElement?.Invoke(this, new WidgetSourceEventArgs(sourceExentionArea)); + + // after adding content to the right side make sure we hold the space in the tab bar + var leftChild = sourceExentionArea.Parent.Children.First(); + var padding = leftChild.Padding; + leftChild.Padding = new BorderDouble(padding.Left, padding.Bottom, sourceExentionArea.Width, padding.Height); } public async Task PrintPart(EditContext editContext, PrinterConfig printer, IProgress reporter, CancellationToken cancellationToken) diff --git a/MatterControlLib/PartPreviewWindow/MainViewWidget.cs b/MatterControlLib/PartPreviewWindow/MainViewWidget.cs index 2fdfc62f1..4ba442b19 100644 --- a/MatterControlLib/PartPreviewWindow/MainViewWidget.cs +++ b/MatterControlLib/PartPreviewWindow/MainViewWidget.cs @@ -38,6 +38,7 @@ using MatterHackers.Agg.Platform; using MatterHackers.Agg.UI; using MatterHackers.DataConverters3D; using MatterHackers.Localizations; +using MatterHackers.MatterControl.CustomWidgets; using MatterHackers.MatterControl.Library; using MatterHackers.MatterControl.PartPreviewWindow.PlusTab; using MatterHackers.MatterControl.PrintLibrary; @@ -752,9 +753,20 @@ namespace MatterHackers.MatterControl.PartPreviewWindow AggContext.StaticData.LoadIcon("cube.png", 16, 16, theme.InvertIcons)) { Name = "newPart" + tabControl.AllTabs.Count(), - MinimumSize = new Vector2(120, theme.TabButtonHeight) + MinimumSize = new Vector2(120, theme.TabButtonHeight), }; + partTab.MaximumSize = new Vector2(partTab.Width, partTab.MaximumSize.Y); + partTab.HAnchor = HAnchor.Stretch; + + var textWidget = partTab.Descendants().First(); + textWidget.HAnchor = HAnchor.Stretch; + var tabPill = partTab.Descendants().First(); + partTab.ToolTipText = textWidget.Text; + tabPill.HAnchor = HAnchor.Stretch; + var tabPillMarign = tabPill.Margin; + tabPill.Margin = new BorderDouble(tabPillMarign.Left, tabPillMarign.Bottom, tabPillMarign.Right + 10, tabPillMarign.Top); + tabControl.AddTab(partTab); void Tab_CloseClicked(object sender, EventArgs args) diff --git a/MatterControlLib/PartPreviewWindow/Tabs.cs b/MatterControlLib/PartPreviewWindow/Tabs.cs index ca692af7b..75ddc22a8 100644 --- a/MatterControlLib/PartPreviewWindow/Tabs.cs +++ b/MatterControlLib/PartPreviewWindow/Tabs.cs @@ -384,19 +384,24 @@ namespace MatterHackers.MatterControl.PartPreviewWindow { tabPill = new TabPill(tabLabel, theme.TextColor, tabImageUrl, pointSize); } - tabPill.Margin = (hasClose) ? new BorderDouble(right: 16) : 0; + + tabPill.Margin = hasClose ? new BorderDouble(right: 16) : 0; this.AddChild(tabPill); if (hasClose) { + // var fadeRegion = new LeftClipFlowLayoutWidget(); + // fadeRegion.HAnchor |= HAnchor.Right; + // this.AddChild(fadeRegion); + var closeButton = theme.CreateSmallResetButton(); - closeButton.HAnchor = HAnchor.Right; closeButton.Margin = new BorderDouble(right: 7, top: 1); closeButton.Name = "Close Tab Button"; closeButton.ToolTipText = "Close".Localize(); closeButton.Click += (s, e) => ConditionallyCloseTab(); - + closeButton.HAnchor |= HAnchor.Right; + // fadeRegion.AddChild(closeButton); this.AddChild(closeButton); } } @@ -455,13 +460,13 @@ namespace MatterHackers.MatterControl.PartPreviewWindow }); } - protected class TabPill : FlowLayoutWidget + public class TabPill : FlowLayoutWidget { private TextWidget label; private ImageWidget imageWidget; public TabPill(string tabTitle, Color textColor, string imageUrl = null, double pointSize = 12) - : this (tabTitle, textColor, string.IsNullOrEmpty(imageUrl) ? null : new ImageBuffer(16, 16).CreateScaledImage(GuiWidget.DeviceScale), pointSize) + : this(tabTitle, textColor, string.IsNullOrEmpty(imageUrl) ? null : new ImageBuffer(16, 16).CreateScaledImage(GuiWidget.DeviceScale), pointSize) { if (imageWidget != null && !string.IsNullOrEmpty(imageUrl)) @@ -577,8 +582,8 @@ namespace MatterHackers.MatterControl.PartPreviewWindow int position = siblings.IndexOf(this); - //MainTab leftSibling = (position > 0) ? siblings[position - 1] : null; - //MainTab rightSibling = (position < siblings.Count - 1) ? siblings[position + 1] : null; + // MainTab leftSibling = (position > 0) ? siblings[position - 1] : null; + // MainTab rightSibling = (position < siblings.Count - 1) ? siblings[position + 1] : null; var activeTab = parentTabControl.ActiveTab; @@ -598,6 +603,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow { tabShape.LineTo(rect.Right, rect.Bottom); } + tabShape.LineTo(rect.Right - tabInsetDistance, rect.Bottom); tabShape.LineTo(rect.Left + tabInsetDistance, rect.Bottom); if (!drawLeftTabOverlap) diff --git a/MatterControlLib/Utilities/MarkdigAgg/Inlines/AggLinkInlineRenderer.cs b/MatterControlLib/Utilities/MarkdigAgg/Inlines/AggLinkInlineRenderer.cs index 2b4100757..c1d234638 100644 --- a/MatterControlLib/Utilities/MarkdigAgg/Inlines/AggLinkInlineRenderer.cs +++ b/MatterControlLib/Utilities/MarkdigAgg/Inlines/AggLinkInlineRenderer.cs @@ -125,8 +125,7 @@ namespace Markdig.Renderers.Agg.Inlines { WebCache.RetrieveImageSquenceAsync(imageSequence, ImageUrl, () => { - MinimumSize = new Vector2(Math.Max(20 * DeviceScale, MinimumSize.X), MinimumSize.Y); - MaximumSize = new Vector2(imageSequence.Width, imageSequence.Height); + this.MinStretchOrFitHorizontal(20, imageSequence.Width); UiThread.RunOnIdle(() => { if (aggRenderer.RootWidget.Parents().FirstOrDefault() is MarkdownWidget markdownWidget) @@ -143,6 +142,21 @@ namespace Markdig.Renderers.Agg.Inlines base.OnDraw(graphics2D); } + + /// + /// Sets this control to Stretch and all direct parent FlowLayoutWidgets to Stretch, it then ensures + /// this and all direct parent FlowLayouts have a max width of the contents of this. + /// + /// The minimum size will be set to the larger of the existing minimum size or this value. + /// The maximum size will be set to this value. + private void MinStretchOrFitHorizontal(double absoluteMinWidth, double absoluteMaxWidth) + { + this.HAnchor = HAnchor.Stretch; + + MinimumSize = new Vector2(Math.Max(absoluteMinWidth * DeviceScale, MinimumSize.X), MinimumSize.Y); + MaximumSize = new Vector2(absoluteMaxWidth, MaximumSize.Y); + } + public string ImageUrl { get; } private string LinkUrl { get; } diff --git a/Submodules/MatterSlice b/Submodules/MatterSlice index 924fcb33e..157e57e1f 160000 --- a/Submodules/MatterSlice +++ b/Submodules/MatterSlice @@ -1 +1 @@ -Subproject commit 924fcb33e812d9e2b3014bd00283d5c43045039e +Subproject commit 157e57e1fb2081b38dccd59b3eab4300fb18845a