Merge pull request #2320 from jlewin/design_tools

First pass at new menubar
This commit is contained in:
Lars Brubaker 2017-08-04 15:54:14 -07:00 committed by GitHub
commit 46da2d7506
8 changed files with 189 additions and 81 deletions

View file

@ -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);

View file

@ -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()

View file

@ -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)

View file

@ -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) =>
{

View file

@ -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<double>(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()

View file

@ -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>("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;
}
}
}

View file

@ -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<IObject3DEditor> 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<double>(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);
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 500 B