From 1ec80d8e624700e9a44c51f260cc271d59926562 Mon Sep 17 00:00:00 2001 From: John Lewin Date: Fri, 4 Aug 2017 15:42:23 -0700 Subject: [PATCH] First pass at new menubar --- ApplicationView/MainApplicationWidget.cs | 2 +- ApplicationView/WidescreenPanel.cs | 57 ++++++++++- .../ApplicationSettingsView.cs | 40 ++++++++ ControlElements/SplitButtonFactory.cs | 4 +- Library/Widgets/PrintLibraryWidget.cs | 38 ++------ PartPreviewWindow/PlusTabPage.cs | 91 ++++++++++-------- PartPreviewWindow/View3D/View3DWidget.cs | 38 ++++++-- StaticData/Icons/AddAzureResource_16x.png | Bin 0 -> 500 bytes 8 files changed, 189 insertions(+), 81 deletions(-) create mode 100644 StaticData/Icons/AddAzureResource_16x.png diff --git a/ApplicationView/MainApplicationWidget.cs b/ApplicationView/MainApplicationWidget.cs index b4eb9a87e..9ab375724 100644 --- a/ApplicationView/MainApplicationWidget.cs +++ b/ApplicationView/MainApplicationWidget.cs @@ -138,7 +138,7 @@ namespace MatterHackers.MatterControl if (!UserSettings.Instance.IsTouchScreen) { -#if !__ANDROID__ +#if false // !__ANDROID__ // The application menu bar, which is suppressed on Android var menuRow = new ApplicationMenuRow(); container.AddChild(menuRow); diff --git a/ApplicationView/WidescreenPanel.cs b/ApplicationView/WidescreenPanel.cs index d13db5dce..fd4a648ed 100644 --- a/ApplicationView/WidescreenPanel.cs +++ b/ApplicationView/WidescreenPanel.cs @@ -30,7 +30,9 @@ either expressed or implied, of the FreeBSD Project. using System.IO; using System.Linq; using MatterHackers.Agg; +using MatterHackers.Agg.PlatformAbstract; using MatterHackers.Agg.UI; +using MatterHackers.MatterControl.ConfigurationPage; using MatterHackers.MatterControl.DataStorage; using MatterHackers.MatterControl.PartPreviewWindow; using MatterHackers.MatterControl.PrintLibrary; @@ -82,8 +84,20 @@ namespace MatterHackers.MatterControl this.AddChild(library3DViewSplitter); + var leftNav = new FlowLayoutWidget(FlowDirection.TopToBottom); + leftNav.AnchorAll(); + + leftNav.AddChild(new BrandMenuButton() + { + MinimumSize = new VectorMath.Vector2(0, 40), + HAnchor = HAnchor.ParentLeftRight, + VAnchor = VAnchor.FitToChildren + }); + + leftNav.AddChild(new PrintLibraryWidget()); + // put in the left column - library3DViewSplitter.Panel1.AddChild(new PrintLibraryWidget()); + library3DViewSplitter.Panel1.AddChild(leftNav); // put in the right column library3DViewSplitter.Panel2.AddChild(new PartPreviewContent(ApplicationController.Instance.ActivePrintItem) @@ -94,6 +108,47 @@ namespace MatterHackers.MatterControl } } + public class BrandMenuButton : GuiWidget + { + public BrandMenuButton() + { + var buttonView = new FlowLayoutWidget() + { + HAnchor = HAnchor.ParentLeftRight, + VAnchor = VAnchor.FitToChildren, + Margin = 8 + }; + buttonView.AfterDraw += (s, e) => + { + //e.graphics2D.Render(directionArrow, buttonView.LocalBounds.Right - arrowHeight * 2 - 2, buttonView.LocalBounds.Center.y + arrowHeight / 2, ActiveTheme.Instance.SecondaryTextColor); + }; + + buttonView.AddChild(new ImageWidget(StaticData.Instance.LoadIcon(Path.Combine("..", "Images", "mh-logo.png"), 24, 24))); + + buttonView.AddChild(new TextWidget("MatterControl 1.7", textColor: ActiveTheme.Instance.PrimaryTextColor) + { + Margin = new BorderDouble(left: 6), + VAnchor = VAnchor.ParentCenter + }); + + var popupButton = new PopupButton(buttonView) + { + VAnchor = VAnchor.ParentCenter, + HAnchor = HAnchor.ParentLeftRight, + Margin = 0 + }; + popupButton.PopupContent = new ApplicationSettingsWidget(ApplicationController.Instance.Theme.MenuButtonFactory) + { + HAnchor = HAnchor.AbsolutePosition, + VAnchor = VAnchor.FitToChildren, + Width = 500, + BackgroundColor = RGBA_Bytes.White + }; + + this.AddChild(popupButton); + } + } + public class UpdateNotificationMark : GuiWidget { public UpdateNotificationMark() diff --git a/ConfigurationPage/ApplicationSettings/ApplicationSettingsView.cs b/ConfigurationPage/ApplicationSettings/ApplicationSettingsView.cs index a6d1dc5ad..b23f5ed4d 100644 --- a/ConfigurationPage/ApplicationSettings/ApplicationSettingsView.cs +++ b/ConfigurationPage/ApplicationSettings/ApplicationSettingsView.cs @@ -36,6 +36,7 @@ using MatterHackers.Agg; using MatterHackers.Agg.PlatformAbstract; using MatterHackers.Agg.UI; using MatterHackers.Localizations; +using MatterHackers.MatterControl.AboutPage; using MatterHackers.MatterControl.CustomWidgets; using MatterHackers.MatterControl.SlicerConfiguration; using MatterHackers.VectorMath; @@ -290,8 +291,47 @@ namespace MatterHackers.MatterControl.ConfigurationPage this.AddSettingsRow(this.GetModeControl()); } + AddMenuItem("Forums".Localize(), () => MatterControlApplication.Instance.LaunchBrowser("https://forums.matterhackers.com/category/20/mattercontrol")); + AddMenuItem("Wiki".Localize(), () => MatterControlApplication.Instance.LaunchBrowser("http://wiki.mattercontrol.com")); + AddMenuItem("Guides and Articles".Localize(), () => MatterControlApplication.Instance.LaunchBrowser("http://www.matterhackers.com/topic/mattercontrol")); + AddMenuItem("Release Notes".Localize(), () => MatterControlApplication.Instance.LaunchBrowser("http://wiki.mattercontrol.com/Release_Notes")); + AddMenuItem("Report a Bug".Localize(), () => MatterControlApplication.Instance.LaunchBrowser("https://github.com/MatterHackers/MatterControl/issues")); + + var updateMatterControl = new SettingsItem("Check For Update".Localize()); + updateMatterControl.Click += (s, e) => + { + UiThread.RunOnIdle(() => + { + ApplicationMenuRow.AlwaysShowUpdateStatus = true; + UpdateControlData.Instance.CheckForUpdateUserRequested(); + CheckForUpdateWindow.Show(); + }); + }; + this.AddSettingsRow(updateMatterControl); + this.AddChild(new SettingsItem("Theme".Localize(), new GuiWidget())); this.AddChild(this.GetThemeControl()); + + var aboutMatterControl = new SettingsItem("About MatterControl".Localize()); + aboutMatterControl.Click += (s, e) => + { + UiThread.RunOnIdle(AboutWindow.Show); + }; + this.AddSettingsRow(aboutMatterControl); + } + + private void AddMenuItem(string title, Action callback) + { + var newItem = new SettingsItem(title); + newItem.Click += (s, e) => + { + UiThread.RunOnIdle(() => + { + callback?.Invoke(); + }); + }; + + this.AddSettingsRow(newItem); } private void AddSettingsRow(GuiWidget widget) diff --git a/ControlElements/SplitButtonFactory.cs b/ControlElements/SplitButtonFactory.cs index cdbac74a4..f7b16d2bd 100644 --- a/ControlElements/SplitButtonFactory.cs +++ b/ControlElements/SplitButtonFactory.cs @@ -3,6 +3,7 @@ using MatterHackers.Agg.UI; using System; using System.Collections.Generic; using System.Linq; +using MatterHackers.Agg.PlatformAbstract; namespace MatterHackers.MatterControl { @@ -41,7 +42,6 @@ namespace MatterHackers.MatterControl menu.HoverArrowColor = this.Options.Hover.TextColor; menu.NormalArrowColor = this.Options.Normal.TextColor; menu.BackgroundColor = this.Options.Normal.FillColor; - menu.Margin = new BorderDouble(); // TODO: Why? if (actions.Count > 1) @@ -53,7 +53,7 @@ namespace MatterHackers.MatterControl var buttonFactory = ApplicationController.Instance.Theme.SmallMarginButtonFactory; - Button button = buttonFactory.Generate(primaryAction.Title, normalImageName: imageName, centerText: true); + Button button = buttonFactory.Generate(primaryAction.Title, StaticData.Instance.LoadIcon(imageName, 24, 24), centerText: true); button.Name = $"{primaryAction.Title} Button"; button.Click += (s, e) => { diff --git a/Library/Widgets/PrintLibraryWidget.cs b/Library/Widgets/PrintLibraryWidget.cs index 6c40e2ab7..64e7afb92 100644 --- a/Library/Widgets/PrintLibraryWidget.cs +++ b/Library/Widgets/PrintLibraryWidget.cs @@ -159,8 +159,7 @@ namespace MatterHackers.MatterControl.PrintLibrary buttonPanel = new FlowLayoutWidget() { HAnchor = HAnchor.ParentLeftRight, - Padding = new BorderDouble(0, 3), - MinimumSize = new Vector2(0, 46), + Padding = 3, BackgroundColor = ActiveTheme.Instance.PrimaryBackgroundColor }; AddLibraryButtonElements(); @@ -248,12 +247,17 @@ namespace MatterHackers.MatterControl.PrintLibrary buttonPanel.RemoveAllChildren(); + var buttonContainer = new FlowLayoutWidget() + { + Padding = 3 + }; + buttonPanel.AddChild(buttonContainer); + // the add button - addToLibraryButton = textImageButtonFactory.Generate("Add".Localize(), "icon_circle_plus.png"); + addToLibraryButton = textImageButtonFactory.Generate("Add".Localize(), "AddAzureResource_16x.png"); addToLibraryButton.Enabled = false; // The library selector (the first library selected) is protected so we can't add to it. addToLibraryButton.ToolTipText = "Add an .stl, .amf, .gcode or .zip file to the Library".Localize(); addToLibraryButton.Name = "Library Add Button"; - buttonPanel.AddChild(addToLibraryButton); addToLibraryButton.Margin = new BorderDouble(0, 0, 3, 0); addToLibraryButton.Click += (sender, e) => UiThread.RunOnIdle(() => { @@ -272,6 +276,7 @@ namespace MatterHackers.MatterControl.PrintLibrary } }); }); + buttonContainer.AddChild(addToLibraryButton); // the create folder button createFolderButton = textImageButtonFactory.Generate("Create Folder".Localize()); @@ -297,30 +302,7 @@ namespace MatterHackers.MatterControl.PrintLibrary createFolderWindow.BringToFront(); } }; - buttonPanel.AddChild(createFolderButton); - - if (OemSettings.Instance.ShowShopButton) - { - var shopButton = textImageButtonFactory.Generate("Buy Materials".Localize(), StaticData.Instance.LoadIcon("icon_shopping_cart_32x32.png", 32, 32)); - shopButton.ToolTipText = "Shop online for printing materials".Localize(); - shopButton.Name = "Buy Materials Button"; - shopButton.Margin = new BorderDouble(0, 0, 3, 0); - shopButton.Click += (sender, e) => - { - double activeFilamentDiameter = 0; - if (ActiveSliceSettings.Instance.PrinterSelected) - { - activeFilamentDiameter = 3; - if (ActiveSliceSettings.Instance.GetValue(SettingsKey.filament_diameter) < 2) - { - activeFilamentDiameter = 1.75; - } - } - - MatterControlApplication.Instance.LaunchBrowser("http://www.matterhackers.com/mc/store/redirect?d={0}&clk=mcs&a={1}".FormatWith(activeFilamentDiameter, OemSettings.Instance.AffiliateCode)); - }; - buttonPanel.AddChild(shopButton); - } + buttonContainer.AddChild(createFolderButton); // add in the message widget providerMessageContainer = new GuiWidget() diff --git a/PartPreviewWindow/PlusTabPage.cs b/PartPreviewWindow/PlusTabPage.cs index c7a985f37..020fc8318 100644 --- a/PartPreviewWindow/PlusTabPage.cs +++ b/PartPreviewWindow/PlusTabPage.cs @@ -38,47 +38,22 @@ namespace MatterHackers.MatterControl.PartPreviewWindow public class PlusTabPage : FlowLayoutWidget { public PlusTabPage() - : base(FlowDirection.BottomToTop) + : base(FlowDirection.TopToBottom) { - Name = "+"; - - HAnchor = HAnchor.ParentLeftRight; - VAnchor = VAnchor.ParentBottomTop; - - var leftRight = new FlowLayoutWidget() - { - HAnchor = HAnchor.ParentLeftRight, - VAnchor = VAnchor.ParentBottomTop, - }; - AddChild(leftRight); + this.Name = "+"; + this.HAnchor = HAnchor.ParentLeftRight; + this.VAnchor = VAnchor.ParentBottomTop; + this.Padding = 20; // put in the add new design stuff - var createItems = new FlowLayoutWidget(FlowDirection.TopToBottom) - { - HAnchor = HAnchor.ParentLeftRight, - VAnchor = VAnchor.ParentBottomTop, - Margin = 15, - }; - leftRight.AddChild(createItems); - - var label = new TextWidget("Create New".Localize() + ":", textColor: ActiveTheme.Instance.PrimaryTextColor); - createItems.AddChild(label); - - var container = new FlowLayoutWidget(FlowDirection.TopToBottom) - { - Margin = new BorderDouble(top: 15, bottom: 15), - HAnchor = HAnchor.FitToChildren, - VAnchor = VAnchor.FitToChildren - }; - createItems.AddChild(container); + var createItemsSection = CreateSection("Create New".Localize() + ":"); var createPart = ApplicationController.Instance.Theme.ButtonFactory.Generate("Create Part".Localize()); createPart.HAnchor = HAnchor.ParentLeft; - container.AddChild(createPart); + createItemsSection.AddChild(createPart); var createPrinter = ApplicationController.Instance.Theme.ButtonFactory.Generate("Create Printer".Localize()); createPrinter.HAnchor = HAnchor.ParentLeft; - container.AddChild(createPrinter); createPrinter.Click += (s, e) => { if (PrinterConnection.Instance.PrinterIsPrinting @@ -96,25 +71,59 @@ namespace MatterHackers.MatterControl.PartPreviewWindow }); } }; + createItemsSection.AddChild(createPrinter); + + var existingPrinterSection = CreateSection("Open Existing".Localize() + ":"); + + var printerSelector = new PrinterSelectEditDropdown() + { + Margin = new BorderDouble(left: 15) + }; + existingPrinterSection.AddChild(printerSelector); + + var otherItemsSection = CreateSection("Other".Localize() + ":"); + + var redeemDesignCode = ApplicationController.Instance.Theme.ButtonFactory.Generate("Redeem Design Code".Localize()); + redeemDesignCode.HAnchor = HAnchor.ParentLeft; + redeemDesignCode.Click += (s, e) => + { + // Implementation already does RunOnIdle + ApplicationController.Instance.RedeemDesignCode?.Invoke(); + }; + otherItemsSection.AddChild(redeemDesignCode); + + var redeemShareCode = ApplicationController.Instance.Theme.ButtonFactory.Generate("Enter Share Code".Localize()); + redeemShareCode.HAnchor = HAnchor.ParentLeft; + redeemShareCode.Click += (s, e) => + { + // Implementation already does RunOnIdle + ApplicationController.Instance.EnterShareCode?.Invoke(); + }; + otherItemsSection.AddChild(redeemShareCode); var importButton = ApplicationController.Instance.Theme.ButtonFactory.Generate("Import".Localize()); importButton.Click += (s, e) => { UiThread.RunOnIdle(() => WizardWindow.Show("ImportSettingsPage", "Import Settings Page")); }; - container.AddChild(importButton); + otherItemsSection.AddChild(importButton); + } - var existingLabel = new TextWidget("Open Existing".Localize() + ":", textColor: ActiveTheme.Instance.PrimaryTextColor) - { - Margin = new BorderDouble(top: 15, bottom: 15) - }; - createItems.AddChild(existingLabel); + private FlowLayoutWidget CreateSection(string headingText) + { + // Add heading + this.AddChild(new TextWidget(headingText, textColor: ActiveTheme.Instance.PrimaryTextColor)); - var printerSelector = new PrinterSelectEditDropdown() + // Add container + var container = new FlowLayoutWidget(FlowDirection.TopToBottom) { - Margin = new BorderDouble(left: 15) + HAnchor = HAnchor.ParentLeftRight, + VAnchor = VAnchor.FitToChildren, + Margin = new BorderDouble(15, 15, 15, 8), }; - createItems.AddChild(printerSelector); + this.AddChild(container); + + return container; } } } diff --git a/PartPreviewWindow/View3D/View3DWidget.cs b/PartPreviewWindow/View3D/View3DWidget.cs index 1e8a217de..ce89c7834 100644 --- a/PartPreviewWindow/View3D/View3DWidget.cs +++ b/PartPreviewWindow/View3D/View3DWidget.cs @@ -51,6 +51,7 @@ using MatterHackers.MatterControl.DataStorage; using MatterHackers.MatterControl.Library; using MatterHackers.MatterControl.PrinterCommunication; using MatterHackers.MatterControl.PrintQueue; +using MatterHackers.MatterControl.SettingsManagement; using MatterHackers.MatterControl.SlicerConfiguration; using MatterHackers.MeshVisualizer; using MatterHackers.PolygonMesh; @@ -203,8 +204,8 @@ namespace MatterHackers.MatterControl.PartPreviewWindow var buttonBottomPanel = new FlowLayoutWidget(FlowDirection.LeftToRight) { HAnchor = HAnchor.ParentLeftRight, - Padding = new BorderDouble(3, 3), - BackgroundColor = ActiveTheme.Instance.PrimaryBackgroundColor + Padding = 3, + BackgroundColor = ActiveTheme.Instance.PrimaryBackgroundColor, }; HashSet mappedEditors; @@ -230,21 +231,21 @@ namespace MatterHackers.MatterControl.PartPreviewWindow // add in the plater tools { + var editToolBar = new FlowLayoutWidget(); + editToolBar.VAnchor |= VAnchor.ParentCenter; + processingProgressControl = new ProgressControl("", ActiveTheme.Instance.PrimaryTextColor, ActiveTheme.Instance.PrimaryAccentColor) { VAnchor = VAnchor.ParentCenter, Visible = false }; - - var editToolBar = new FlowLayoutWidget(); editToolBar.AddChild(processingProgressControl); - editToolBar.VAnchor |= VAnchor.ParentCenter; doEdittingButtonsContainer = new FlowLayoutWidget(); doEdittingButtonsContainer.Visible = false; { - Button addButton = smallMarginButtonFactory.Generate("Insert".Localize(), "icon_insert_32x32.png"); + Button addButton = smallMarginButtonFactory.Generate("Insert".Localize(), StaticData.Instance.LoadIcon("AddAzureResource_16x.png", 16, 16)); doEdittingButtonsContainer.AddChild(addButton); addButton.Click += (sender, e) => { @@ -332,7 +333,6 @@ namespace MatterHackers.MatterControl.PartPreviewWindow }; Button clearPlateButton = smallMarginButtonFactory.Generate("Clear Plate".Localize()); - clearPlateButton.Margin = new BorderDouble(right: 10); clearPlateButton.Click += (sender, e) => { UiThread.RunOnIdle(ApplicationController.Instance.ClearPlate); @@ -360,6 +360,29 @@ namespace MatterHackers.MatterControl.PartPreviewWindow AlignToRightEdge = true }; doEdittingButtonsContainer.AddChild(materialsButton); + + if (OemSettings.Instance.ShowShopButton) + { + var shopButton = smallMarginButtonFactory.Generate("Buy Materials".Localize(), StaticData.Instance.LoadIcon("icon_shopping_cart_32x32.png", 24, 24)); + shopButton.ToolTipText = "Shop online for printing materials".Localize(); + shopButton.Name = "Buy Materials Button"; + shopButton.Margin = new BorderDouble(0, 0, 3, 0); + shopButton.Click += (sender, e) => + { + double activeFilamentDiameter = 0; + if (ActiveSliceSettings.Instance.PrinterSelected) + { + activeFilamentDiameter = 3; + if (ActiveSliceSettings.Instance.GetValue(SettingsKey.filament_diameter) < 2) + { + activeFilamentDiameter = 1.75; + } + } + + MatterControlApplication.Instance.LaunchBrowser("http://www.matterhackers.com/mc/store/redirect?d={0}&clk=mcs&a={1}".FormatWith(activeFilamentDiameter, OemSettings.Instance.AffiliateCode)); + }; + doEdittingButtonsContainer.AddChild(shopButton); + } } editToolBar.AddChild(doEdittingButtonsContainer); @@ -1548,7 +1571,6 @@ namespace MatterHackers.MatterControl.PartPreviewWindow saveButtons.Visible = false; saveButtons.Margin = new BorderDouble(); saveButtons.VAnchor |= VAnchor.ParentCenter; - flowToAddTo.AddChild(saveButtons); } diff --git a/StaticData/Icons/AddAzureResource_16x.png b/StaticData/Icons/AddAzureResource_16x.png new file mode 100644 index 0000000000000000000000000000000000000000..1adad40fc34f10ae189dac2dc302908b9ad4e702 GIT binary patch literal 500 zcmeAS@N?(olHy`uVBq!ia0y~yU=RRd4mJh`2Kmqb6B!s7I14-?iy0XBj({-ZRBb+K z1_s7uo-U3d6>+V>8?%2oNc`1X#`u}NM8|?dw?seGV_|oIQ(=jgY>r}pID5Ewp@2xc zL;EF1aov(%oPQq*d0aTyrb~EsuIqSq$xNboJp)U^4@2{o2^t&=-+ccqz$sL5_xsLpv z%XRbDDdk6oZHroKR4S7$!g8>IZSE%l)}#$_>y>l2Mg?e1J##YUlcTfM7w-Ou1N(QI zyY)@K9WHU_fBXFnF?tIxW=!~4QRDn}`Ks4e2kQmTD^@OW{=Sp@@IwKY6|1;*#_)am zX|rQpx2i8InIT%N+j5=v-)BGn`G5hBh6tCz?6V7kRvswZof_A
    mDRTE#8 z+cB%JDoj4QKUYk%psna+aiU5{mLZK~SacfIx0o|Yfc6WEThs|ay+G~ZBX-?RO8 zuE+ArAH)k}e{YEAvsk`7-*mR`{s^6>Wtj?0w$}<}f4?|5|K$1}`+3f%&LwT+IQ_I} z$IYA>i5}So{f**y5v(zwqeE)OQHKL)0fq{X+)78&qol`;+ E0F+zSfdBvi literal 0 HcmV?d00001