From aba50688cd72f71a9a390cdad9adcb18ed90bc5e Mon Sep 17 00:00:00 2001 From: LarsBrubaker Date: Sun, 16 May 2021 09:44:14 -0700 Subject: [PATCH] Adding icons, improving rendering --- .../CustomWidgets/SimpleButton.cs | 5 ++ .../View3D/GridOptionsPanel.cs | 8 +-- .../PartPreviewWindow/View3D/View3DWidget.cs | 66 +++++++++++------- .../PartPreviewWindow/ViewStyleButton.cs | 4 +- StaticData/Icons/perspective.png | Bin 0 -> 1285 bytes StaticData/Icons/select.png | Bin 0 -> 1249 bytes .../Icons/{1694146.png => snap_grid.png} | Bin StaticData/Icons/spin.png | Bin 0 -> 1369 bytes Submodules/agg-sharp | 2 +- 9 files changed, 49 insertions(+), 36 deletions(-) create mode 100644 StaticData/Icons/perspective.png create mode 100644 StaticData/Icons/select.png rename StaticData/Icons/{1694146.png => snap_grid.png} (100%) create mode 100644 StaticData/Icons/spin.png diff --git a/MatterControlLib/CustomWidgets/SimpleButton.cs b/MatterControlLib/CustomWidgets/SimpleButton.cs index 55a00ea2b..2288ffe37 100644 --- a/MatterControlLib/CustomWidgets/SimpleButton.cs +++ b/MatterControlLib/CustomWidgets/SimpleButton.cs @@ -573,6 +573,11 @@ namespace MatterHackers.MatterControl.CustomWidgets } } + public void SetIcon(ImageBuffer imageBuffer) + { + ImageWidget.Image = imageBuffer; + } + public ImageWidget ImageWidget { get; } public override string Text { get => textWidget.Text; set => textWidget.Text = value; } diff --git a/MatterControlLib/PartPreviewWindow/View3D/GridOptionsPanel.cs b/MatterControlLib/PartPreviewWindow/View3D/GridOptionsPanel.cs index a8f9983eb..44c16e757 100644 --- a/MatterControlLib/PartPreviewWindow/View3D/GridOptionsPanel.cs +++ b/MatterControlLib/PartPreviewWindow/View3D/GridOptionsPanel.cs @@ -45,7 +45,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow this.object3DControlLayer = object3DControlLayer; this.PopupContent = () => ShowGridOptions(theme); - this.AddChild(new IconButton(StaticData.Instance.LoadIcon("1694146.png", 16, 16, theme.InvertIcons), theme) + this.AddChild(new TextIconButton("Snap", StaticData.Instance.LoadIcon("snap_grid.png", 16, 16, theme.InvertIcons), theme) { Selectable = false }); @@ -87,12 +87,6 @@ namespace MatterHackers.MatterControl.PartPreviewWindow siblingRadioButtonList: siblingList); } - // Override menu left padding to improve radio circle -> icon spacing - foreach (var menuItem in popupMenu.Children) - { - //menuItem.Padding = menuItem.Padding.Clone(left: 25); - } - return popupMenu; } } diff --git a/MatterControlLib/PartPreviewWindow/View3D/View3DWidget.cs b/MatterControlLib/PartPreviewWindow/View3D/View3DWidget.cs index 809630fed..d58a03820 100644 --- a/MatterControlLib/PartPreviewWindow/View3D/View3DWidget.cs +++ b/MatterControlLib/PartPreviewWindow/View3D/View3DWidget.cs @@ -310,19 +310,24 @@ namespace MatterHackers.MatterControl.PartPreviewWindow controlLayer.AddChild(tumbleCubeControl); - GuiWidget AddRoundButton(GuiWidget widget, Vector2 offset) + GuiWidget AddRoundButton(GuiWidget widget, Vector2 offset, bool center = false) { - widget.BackgroundRadius = new RadiusCorners(widget.Width / 2); + widget.BackgroundRadius = new RadiusCorners(Math.Min(widget.Width / 2, widget.Height / 2)); widget.BackgroundOutlineWidth = 1; widget.VAnchor = VAnchor.Top; widget.HAnchor = HAnchor.Right; + if (center) + { + offset.X -= (widget.Width / 2) / scale; + } + widget.Margin = new BorderDouble(0, 0, offset.X, offset.Y); return controlLayer.AddChild(widget); } Vector2 RotatedMargin(GuiWidget widget, double angle) { - var radius = 120; + var radius = 70 * scale; var widgetCenter = new Vector2(widget.Width / 2, widget.Height / 2); // divide by scale to convert from pixels to margin units return (cubeCenterFromRightTop - widgetCenter - new Vector2(0, radius).GetRotated(angle)) / scale; @@ -344,7 +349,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow var rotateButton = new RadioIconButton(StaticData.Instance.LoadIcon(Path.Combine("ViewTransformControls", "rotate.png"), 16, 16, theme.InvertIcons), theme) { SiblingRadioButtonList = buttonGroupA, - ToolTipText = "Rotate (Alt + Left Mouse)".Localize(), + ToolTipText = "Rotate\n- Right Mouse Button\n- Ctrl + Left Mouse Button".Localize(), Margin = theme.ButtonSpacing }; AddRoundButton(rotateButton, RotatedMargin(rotateButton, MathHelper.Tau * .05)); @@ -354,7 +359,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow var translateButton = new RadioIconButton(StaticData.Instance.LoadIcon(Path.Combine("ViewTransformControls", "translate.png"), 16, 16, theme.InvertIcons), theme) { SiblingRadioButtonList = buttonGroupA, - ToolTipText = "Move (Shift + Left Mouse)".Localize(), + ToolTipText = "Move\n- Middle Mouse Button\n- Ctrl + Shift + Left Mouse Button".Localize(), Margin = theme.ButtonSpacing }; AddRoundButton(translateButton, RotatedMargin(translateButton , - MathHelper.Tau * .05)); @@ -364,7 +369,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow var scaleButton = new RadioIconButton(StaticData.Instance.LoadIcon(Path.Combine("ViewTransformControls", "scale.png"), 16, 16, theme.InvertIcons), theme) { SiblingRadioButtonList = buttonGroupA, - ToolTipText = "Zoom (Ctrl + Left Mouse)".Localize(), + ToolTipText = "Zoom\n- Mouse Wheel\n- Ctrl + Alt + Left Mouse Button".Localize(), Margin = theme.ButtonSpacing }; AddRoundButton(scaleButton, RotatedMargin(scaleButton, - MathHelper.Tau * .15)); @@ -381,13 +386,14 @@ namespace MatterHackers.MatterControl.PartPreviewWindow void renderRoundedGroup(double spanRatio, double startRatio) { var angle = MathHelper.Tau * spanRatio; - var width = 20 * scale; + var width = 17 * scale; var start = MathHelper.Tau * startRatio - angle / 2; var end = MathHelper.Tau * startRatio + angle / 2; - var arc = new Arc(tumbleCubeCenter, tumbleCubeRadius + 10 * scale + width / 2, start, end); - var background = new Stroke(arc, width * scale); + var arc = new Arc(tumbleCubeCenter, tumbleCubeRadius + 12 * scale + width / 2, start, end); + var background = new Stroke(arc, width * 2); background.LineCap = LineCap.Round; - e.Graphics2D.Render(new Stroke(background, scale), Color.Black); + e.Graphics2D.Render(background, theme.TextColor.WithAlpha(20)); + e.Graphics2D.Render(new Stroke(background, scale), theme.TextColor.WithAlpha(200)); } renderRoundedGroup(.31, .25); @@ -406,31 +412,33 @@ namespace MatterHackers.MatterControl.PartPreviewWindow }; AddRoundButton(homeButton, RotatedMargin(homeButton, MathHelper.Tau * .3)).Click += (s, e) => viewControls3D.NotifyResetView(); - var zoomToSelectionButton = new IconButton(StaticData.Instance.LoadIcon("fa-home_16.png", 16, 16, theme.InvertIcons), theme) + var zoomToSelectionButton = new IconButton(StaticData.Instance.LoadIcon("select.png", 16, 16, theme.InvertIcons), theme) { ToolTipText = "Zoom to Selection".Localize(), Margin = theme.ButtonSpacing }; AddRoundButton(zoomToSelectionButton, RotatedMargin(zoomToSelectionButton, MathHelper.Tau * .4)).Click += (s, e) => viewControls3D.NotifyResetView(); - var turnTableButton = new IconButton(StaticData.Instance.LoadIcon("fa-home_16.png", 16, 16, theme.InvertIcons), theme) + var turnTableButton = new IconButton(StaticData.Instance.LoadIcon("spin.png", 16, 16, theme.InvertIcons), theme) { ToolTipText = "Turn Table".Localize(), Margin = theme.ButtonSpacing }; AddRoundButton(turnTableButton, RotatedMargin(turnTableButton, - MathHelper.Tau * .4)).Click += (s, e) => viewControls3D.NotifyResetView(); - var othrographicButton = new IconButton(StaticData.Instance.LoadIcon("fa-home_16.png", 16, 16, theme.InvertIcons), theme) + var projectionButton = new IconButton(StaticData.Instance.LoadIcon("perspective.png", 16, 16, theme.InvertIcons), theme) { - ToolTipText = "Orthographic".Localize(), + ToolTipText = "Perspective Projection".Localize(), Margin = theme.ButtonSpacing }; - AddRoundButton(othrographicButton, RotatedMargin(othrographicButton, -MathHelper.Tau * .3)).Click += (s, e) => viewControls3D.NotifyResetView(); + AddRoundButton(projectionButton, RotatedMargin(projectionButton, -MathHelper.Tau * .3)).Click += (s, e) => viewControls3D.NotifyResetView(); + var startHeight = 180; + var ySpacing = 40; // put in the bed and build volume buttons - AddBedAndBuildVolumeButtons(controlLayer, sceneContext, printer, theme); + AddBedAndBuildVolumeButtons(controlLayer, sceneContext, printer, theme, cubeCenterFromRightTop.X, startHeight, scale); - // put in the list buttons + // put in the view list buttons modelViewStyleButton = new ViewStyleButton(sceneContext, theme) { ToolTipText = "Model View Style".Localize(), @@ -441,15 +449,15 @@ namespace MatterHackers.MatterControl.PartPreviewWindow }; modelViewStyleButton.AnchorMate.Mate.VerticalEdge = MateEdge.Bottom; modelViewStyleButton.AnchorMate.Mate.HorizontalEdge = MateEdge.Left; - - AddRoundButton(modelViewStyleButton, new Vector2(80, 230)); + var marginCenter = cubeCenterFromRightTop.X / scale; + AddRoundButton(modelViewStyleButton, new Vector2(marginCenter, startHeight + 1 * ySpacing), true); if (printer?.ViewState != null) { printer.ViewState.ViewModeChanged += this.ViewState_ViewModeChanged; } - // now add the grid snap button + // Add the grid snap button var gridSnapButton = new GridOptionsPanel(Object3DControlLayer, theme) { ToolTipText = "Snap Grid".Localize(), @@ -460,8 +468,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow }; gridSnapButton.AnchorMate.Mate.VerticalEdge = MateEdge.Bottom; gridSnapButton.AnchorMate.Mate.HorizontalEdge = MateEdge.Right; - - AddRoundButton(gridSnapButton, new Vector2(80, 260)); + AddRoundButton(gridSnapButton, new Vector2(marginCenter, startHeight + 2 * ySpacing), true); #if DEBUG var renderOptionsButton = new RenderOptionsButton(theme, this.Object3DControlLayer) @@ -476,18 +483,23 @@ namespace MatterHackers.MatterControl.PartPreviewWindow Mate = new MateOptions(MateEdge.Left, MateEdge.Bottom) } }; - AddRoundButton(renderOptionsButton, new Vector2(80, 290)); + AddRoundButton(renderOptionsButton, new Vector2(marginCenter, startHeight + 3 * ySpacing), true); #endif } - internal void AddBedAndBuildVolumeButtons(GuiWidget parent, ISceneContext sceneContext, PrinterConfig printer, ThemeConfig theme) + internal void AddBedAndBuildVolumeButtons(GuiWidget parent, + ISceneContext sceneContext, + PrinterConfig printer, + ThemeConfig theme, + double center, + double height, + double scale) { var bedButton = new RadioIconButton(StaticData.Instance.LoadIcon("bed.png", 16, 16, theme.InvertIcons), theme) { Name = "Bed Button", ToolTipText = "Show Print Bed".Localize(), Checked = sceneContext.RendererOptions.RenderBed, - Margin = new BorderDouble(0, 0, 70, 200), VAnchor = VAnchor.Top, HAnchor = HAnchor.Right, ToggleButton = true, @@ -495,6 +507,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow Width = theme.ButtonHeight, SiblingRadioButtonList = new List() }; + bedButton.Margin = new BorderDouble(0, 0, (center + 18 * scale - bedButton.Width / 2) / scale, height); bedButton.CheckedStateChanged += (s, e) => { sceneContext.RendererOptions.RenderBed = bedButton.Checked; @@ -508,7 +521,6 @@ namespace MatterHackers.MatterControl.PartPreviewWindow Name = "Bed Button", ToolTipText = BuildHeightValid() ? "Show Print Area".Localize() : "Define printer build height to enable", Checked = sceneContext.RendererOptions.RenderBuildVolume, - Margin = new BorderDouble(0, 0, 90, 200), VAnchor = VAnchor.Top, HAnchor = HAnchor.Right, ToggleButton = true, @@ -517,6 +529,8 @@ namespace MatterHackers.MatterControl.PartPreviewWindow Width = theme.ButtonHeight, SiblingRadioButtonList = new List() }; + printAreaButton.Margin = new BorderDouble(0, 0, (center - 18 * scale - printAreaButton.Width / 2) / scale, height); + printAreaButton.CheckedStateChanged += (s, e) => { sceneContext.RendererOptions.RenderBuildVolume = printAreaButton.Checked; diff --git a/MatterControlLib/PartPreviewWindow/ViewStyleButton.cs b/MatterControlLib/PartPreviewWindow/ViewStyleButton.cs index fa6dbc325..6e66a2316 100644 --- a/MatterControlLib/PartPreviewWindow/ViewStyleButton.cs +++ b/MatterControlLib/PartPreviewWindow/ViewStyleButton.cs @@ -41,7 +41,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow { public class ViewStyleButton : DropButton { - private IconButton iconButton; + private TextIconButton iconButton; private ISceneContext sceneContext; private Dictionary viewIcons; @@ -64,7 +64,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow [RenderTypes.Overhang] = StaticData.Instance.LoadIcon("view_overhang.png", 16, 16, theme.InvertIcons), }; - this.AddChild(iconButton = new IconButton(viewIcons[sceneContext.ViewState.RenderType], theme) + this.AddChild(iconButton = new TextIconButton("View".Localize(), viewIcons[sceneContext.ViewState.RenderType], theme) { Selectable = false }); diff --git a/StaticData/Icons/perspective.png b/StaticData/Icons/perspective.png new file mode 100644 index 0000000000000000000000000000000000000000..68a3dc4438d016b90fc8a59701222483cc09f4e6 GIT binary patch literal 1285 zcmeAS@N?(olHy`uVBq!ia0y~yU{C;I4mJh`hT^KKFANM!kE=o=N`ey06$*;-(=u~X z6-p`#QWa7wGSe6sDsH`<9$555gQxAjf_kdcW{ZrD<){xqZdm z*(a}*PtkvWazf9#4eByKL?(6E`Rg0yPwEQ1I5|bbb)#zM3)dIF@3j8@s9O2`viG~B zyG50Lt~;9M7VdwNaoThL`MaksJnwk%@aN0slW!k+zdQEA?pWp8b<28uo^BBTx^c=^ zmZQuor$Cfp;KR+IVA`r-R6w=YO+F6mr! zf2UK7O}12`PtoRfv4#sbEU!+zfA!GvU7hm}aB;ly+ML{IDmT5;`DI}ACJXK_Cd&lY zuXVh(opA}rKGA~{8XV53c+Fg7C@uKu#e-l$OYcX_EFM#>TN%xo<|e$csZH*?cq#R% zch6#0g%G1{UCjZkYo>^NO+Fdu9O@bzaCObHb*|ad=4^U4NB6w(s#y_6TXWL#j;`uf z4?myxE^d#QUX!wqx1Lzn^q{QP%UqX5H*1?@+5VWIEL-*DFrWRYK2`0wY@SoP;96UcNy(GM!|sw_mu*{V7ra=!X#X;| z*|$`tO`B)C!ZGJtV$-w2MUy2v3Y7%5dor+|og7)>)v3Poq>k9JWdUrampGSSR$*&; zsdCNHd^h{f_#*CE|3uCIN$xbb_?NRNanbE3`-*-&$VUte3~Wi>?k)`fL2$v|<&zm0 z7&r?&B8wRq#8g3;(KATp0|NsCdx@v7EBjMc0X_!#sYW*%85kHBd%8G=L>zuQeYY2L zpg`OHvq!mI0*{DjH8pkgE-Dnh?_hoZ;PnmLH*DJYm67FO)WLH~aY6zjIW-L>f>Q+^ zFSX=8JSpY*oXr!Q>Lq6QmZd*GQlVw6^jCrGLsu1r2jvglM1B<fi?ccJnDJk~)w6_cl3=E#GelF{r5}E+w{9J7S literal 0 HcmV?d00001 diff --git a/StaticData/Icons/select.png b/StaticData/Icons/select.png new file mode 100644 index 0000000000000000000000000000000000000000..2898fb388b97eca97156dec910e89353134c8a1b GIT binary patch literal 1249 zcmeAS@N?(olHy`uVBq!ia0y~yU{C;I4mJh`hT^KKFANM!PpU#9N`ey06$*;-(=u~X z6-p`#QWa7wGSe6sDsH`<9$555gQxAjyuW#*NERYSy3`J(cj{Orix(cyttHoDxzx_shteynshO|=Sz~|Rt-rIo z^z>6p(T7}R$No-QtgHUlu3X!BzVf2>=gS!<-#$A1PVdFqp3hOSzLGOfCF;LQ)?Ceg zlzHV8Q{BZ9ajy5nG&TBE%>-UAs9dncp;h9h+>{l;OC6tQNt?FJ_>tm#`p$ubQ!zc< z<_rp+n=d3xR~HQ7w*$;E@qm5QbvVdt2jRnEnn!=irhM&++#GK-gTc0&XUT_ znj8^T^=$#$#+&V&v#xjgr70Zibhx9&n3FN@%%Wf~o0Gn28x8ncjaE$bvzV)9DBz>M zk#E;c+Y^5$MPK-`e#gi2Ct5q-`A^^$zN_|q>TUBYRk8auHZhzHwkVcLeUQ|A=;hSC z=k71LpLe+4^n=+KWcc6EjA5L~c#`D6wL z2F?PH$YKTtF;x&|^bAt@z`(%3UgGKN%Kns9fY-!a^0n<%1_s7DPZ!6Kh{JEE@Af+4 zAkwx!QaH@jMP&W~x9@^EIjr2dIxZWg=CXQQuhr4f(aFiltzqEy7Cl%dn5eD4yK7q0 ziCG&x4Q0}dCg0_CJi+g5F>{Xb^w0CXMFfJCvZnN0G8f>iWVyjG&34^RhI71?G8RnB zj7oML;QXMVo|K%!Z0k^ctntEZ#yF-ga*dI}*Gn3iu3d`O;3___sGFH<1%E;eYn}1L zqm06w8>YssJu-R1{)STSe3K2_Yg#4+Xx(Ri+c5brQ+eOcel7kG=@XMVqYtbQWWDbk zv6%Oc#HZywry~sP^K*Vr$TZeUI2gmZN-0rgT^4_a#J<~%R?O=zvP|Qdef+@IwKCTm zwHKFsYp4t?`z@K?c9!Kv$<)VM!eN04-U{3YmZZMptq?t%b2u^o)^^Ttkr!JoZs@J` z4*vD#huO(4rk#)HJBVu@x1R64HD<9|)q&GrB1P^s-qzup!<2krRl9twxBm^Voe!PZ wEvD=`^^skqXlfOQ)w$qrkK3NaKWnsa5lE}IRD7Arz`(%Z>FVdQ&MBb@0Pc`6T>t<8 literal 0 HcmV?d00001 diff --git a/StaticData/Icons/1694146.png b/StaticData/Icons/snap_grid.png similarity index 100% rename from StaticData/Icons/1694146.png rename to StaticData/Icons/snap_grid.png diff --git a/StaticData/Icons/spin.png b/StaticData/Icons/spin.png new file mode 100644 index 0000000000000000000000000000000000000000..de39732059ab03de3675b1ed5ca3dbc4282a7bf2 GIT binary patch literal 1369 zcmeAS@N?(olHy`uVBq!ia0y~yU{C;I4mJh`hT^KKFANM!kE=o=N`ey06$*;-(=u~X z6-p`#QWa7wGSe6sDsH`<9$555gQxAj~eX-e_YkR+~Mc?x6^MG%=X4&PY-`{z3 zYw9cOQ`4WPc({e%5az4l@^qQMTzsav=g}1}JdLI-x?$>mK4{G4FyY+WUFa9m@eCzI6Mn+Q)-@9@=>>5uO zdyr;!q?_@buAOVcF33dZC|q;=?2z5aWw^;!BXGG_^Ep$qEDpnuC)+0OY&#Rt_~s|46P*|L}n?{B>DDSFy|H@@?87o22CZV`=-`r-G(`mLGCF`d{&FUr>m zh@YS3CNcTWn}w_jCS`u5Ps_J{Sef@oeFIa|u1jxjB=jCneH2i2Wtz@8Cfi=kBd;?i ze9dLhY|3{vP*D&t?hIO%amKC1#_C6i%ehHE7#M?|`Xx5>K2VXc_P-yIyrm@ar_kfe zOafiXNe;nFn8LieerT`KnnFMq6{z@{X?RRu4a) z_bzUam|m0rjA=1CBKk|Oa4i>IrX3cZai!{mqPx|X6Ya8fQx=;|@%Q$P&bzi}YM6ET zON)QD<=l6xUw&O8ytHIl@cEisFVihwJFMlE%zSa;a9h98E8pDU+GTF~PwISo&9-{# z=-O5XG~al0nC0yGPQNsTW1S9n)EGrf{L?OKs?K|&wmCwg-AVF_hx#19$r2pPCP%Q} zeIxgz?xb$UukbrR(w`i1`L2GVwKH$>?^AE3v-Ylw7l~|mra8y5*XToH^P!hh_ny1I zA7O7#P@+yxmywFr#OX$_EAp2KEw9Usv|0tO9%jvWEXw|6yQY{O;-E7!q;#?X~mWX9^|Q zKU~jAyS8q_)+Yva>h@AHYBGPdRQH$h|6_c5;^fhTp3!>WR?KnPsnKN-nAf%FM1N4u zrfxT-z?QqEm1)1s(w_Z3+qcZb-}dX<&wuOYJ^%Zs!v4H@`yM{8em-w;2XTkvjAu^$ zxGOa!@KBP7q4>@U`_BG~X7P%y-xc$ZR_yD1cfc~l;P3Qb66zZ_wa&Na`}W`<&m6N$ znlVSZ!WgOwm!0i<{gsC^Sk;+@$Hjs15QaC z{F<>Z?Q4wmf=h2~R^MBBsUX|UEavEUvG?(h^4P3j8%#KJ;9rmAj024x)wN%kEd+U| zr#&zJ60?@Qs*qjUIBn6S2bKOM->30>U4P2s!scm>iEEDEuunT!V)8*x$LCUkhQjd|H$sm zk!?q;zopr0O~`E2mk;8 literal 0 HcmV?d00001 diff --git a/Submodules/agg-sharp b/Submodules/agg-sharp index 21557b54a..78bf6adf8 160000 --- a/Submodules/agg-sharp +++ b/Submodules/agg-sharp @@ -1 +1 @@ -Subproject commit 21557b54a3e5b88eb386b9fe688899bd944d8824 +Subproject commit 78bf6adf833e2ea715ab2b954df09a9a03fddf57