Merge pull request #3211 from jlewin/design_tools
Remove plus tab button, use fixed Start tab
This commit is contained in:
commit
b40f7a1d52
8 changed files with 97 additions and 76 deletions
|
|
@ -726,6 +726,14 @@ namespace MatterHackers.MatterControl
|
|||
this.MenuTheme.RebuildTheme(clonedColors);
|
||||
|
||||
this.RebuildSceneOperations(this.Theme);
|
||||
|
||||
#if DEBUG
|
||||
if (AggContext.StaticData is FileSystemStaticData staticData)
|
||||
{
|
||||
staticData.PurgeCache();
|
||||
}
|
||||
#endif
|
||||
|
||||
}, ref unregisterEvents);
|
||||
|
||||
this.Theme.RebuildTheme(ActiveTheme.Instance);
|
||||
|
|
|
|||
|
|
@ -34,6 +34,32 @@ using MatterHackers.MatterControl.CustomWidgets;
|
|||
|
||||
namespace MatterHackers.MatterControl.PartPreviewWindow
|
||||
{
|
||||
public class TabTrailer : GuiWidget
|
||||
{
|
||||
private SimpleTabs parentTabControl;
|
||||
private ThemeConfig theme;
|
||||
|
||||
public ITab LastTab { get; set; }
|
||||
|
||||
public IconButton IconButton { get; }
|
||||
|
||||
public TabTrailer(SimpleTabs parentTabControl, ThemeConfig theme)
|
||||
{
|
||||
this.parentTabControl = parentTabControl;
|
||||
this.theme = theme;
|
||||
}
|
||||
|
||||
public override void OnDraw(Graphics2D graphics2D)
|
||||
{
|
||||
ChromeTab.DrawTabLowerLeft(
|
||||
graphics2D,
|
||||
this.LocalBounds,
|
||||
(parentTabControl.ActiveTab == this.LastTab) ? theme.ActiveTabColor : theme.InactiveTabColor);
|
||||
|
||||
base.OnDraw(graphics2D);
|
||||
}
|
||||
}
|
||||
|
||||
public class NewTabButton : GuiWidget
|
||||
{
|
||||
private SimpleTabs parentTabControl;
|
||||
|
|
|
|||
|
|
@ -90,16 +90,6 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
|
|||
|
||||
Color selectedTabColor = ActiveTheme.Instance.TabLabelSelected;
|
||||
|
||||
// Add a tab for the current printer
|
||||
if (ActiveSliceSettings.Instance.PrinterSelected)
|
||||
{
|
||||
string tabTitle = ActiveSliceSettings.Instance.GetValue(SettingsKey.printer_name);
|
||||
this.CreatePrinterTab(printer, theme, tabTitle);
|
||||
}
|
||||
else
|
||||
{
|
||||
}
|
||||
|
||||
// add in the update available button
|
||||
Button updateAvailableButton = theme.LinkButtonFactory.Generate("Update Available");
|
||||
updateAvailableButton.Name = "Update Available Link";
|
||||
|
|
@ -139,15 +129,27 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
|
|||
ApplicationController.Instance.NotifyPrintersTabRightElement(extensionArea);
|
||||
|
||||
// Show start page during initial application startup
|
||||
if (AppContext.IsLoading)
|
||||
{
|
||||
tabControl.AddTab(
|
||||
new ChromeTab("New Tab".Localize(), tabControl, tabControl.NewTabPage(), theme)
|
||||
new ChromeTab("Start".Localize(), tabControl, tabControl.NewTabPage(), theme, hasClose: false)
|
||||
{
|
||||
MinimumSize = new Vector2(0, theme.TabButtonHeight),
|
||||
Name = "Initial Plus Tab"
|
||||
Name = "Initial Plus Tab",
|
||||
Padding = new BorderDouble(15, 0)
|
||||
});
|
||||
}
|
||||
|
||||
// Add a tab for the current printer
|
||||
if (ActiveSliceSettings.Instance.PrinterSelected)
|
||||
{
|
||||
string tabTitle = ActiveSliceSettings.Instance.GetValue(SettingsKey.printer_name);
|
||||
this.CreatePrinterTab(printer, theme, tabTitle);
|
||||
}
|
||||
else
|
||||
{
|
||||
}
|
||||
|
||||
// ************** Restore active tabs..... ******************
|
||||
}
|
||||
|
||||
internal ChromeTab CreatePrinterTab(PrinterConfig printer, ThemeConfig theme, string tabTitle)
|
||||
|
|
|
|||
|
|
@ -33,6 +33,7 @@ using System.Linq;
|
|||
using MatterHackers.Agg;
|
||||
using MatterHackers.Agg.Platform;
|
||||
using MatterHackers.Agg.UI;
|
||||
using MatterHackers.DataConverters3D;
|
||||
using MatterHackers.Localizations;
|
||||
using MatterHackers.MatterControl.CustomWidgets;
|
||||
using MatterHackers.MatterControl.DataStorage;
|
||||
|
|
@ -88,7 +89,8 @@ namespace MatterHackers.MatterControl.PartPreviewWindow.PlusTab
|
|||
HAnchor = HAnchor.Absolute,
|
||||
Border = 0,
|
||||
MinimumSize = Vector2.Zero,
|
||||
Width = 200
|
||||
Width = 200,
|
||||
BackgroundColor = theme.MinimalShade
|
||||
});
|
||||
|
||||
this.printerInfo = printerInfo;
|
||||
|
|
@ -98,6 +100,25 @@ namespace MatterHackers.MatterControl.PartPreviewWindow.PlusTab
|
|||
|
||||
var listView = new ListView(ApplicationController.Instance.Library, theme);
|
||||
|
||||
var emptyPlateButton = new ImageWidget(AggContext.StaticData.LoadIcon("empty-workspace.png", 70, 70))
|
||||
{
|
||||
Margin = new BorderDouble(right: 5),
|
||||
Selectable = true,
|
||||
BackgroundColor = theme.MinimalShade,
|
||||
Name = "Open Empty Plate Button"
|
||||
};
|
||||
emptyPlateButton.Click += async (s, e) =>
|
||||
{
|
||||
await ProfileManager.Instance.LoadPrinterOpenItem(new InMemoryLibraryItem(new Object3D()));
|
||||
|
||||
string tabTitle = ActiveSliceSettings.Instance.GetValue(SettingsKey.printer_name);
|
||||
|
||||
var printer = ApplicationController.Instance.ActivePrinter;
|
||||
|
||||
partPreviewContent.CreatePrinterTab(printer, theme, tabTitle);
|
||||
};
|
||||
toolbar.AddChild(emptyPlateButton);
|
||||
|
||||
foreach (var item in recentFiles.Take(10).Select(f => new SceneReplacementFileItem(f.FullName)).ToList<ILibraryItem>())
|
||||
{
|
||||
var iconButton = new IconViewItem(new ListViewItem(item, listView), 70, 70, theme)
|
||||
|
|
@ -210,27 +231,14 @@ namespace MatterHackers.MatterControl.PartPreviewWindow.PlusTab
|
|||
|
||||
var listView = new ListView(ApplicationController.Instance.Library, theme);
|
||||
|
||||
foreach (var item in recentParts.Take(10).Select(f => new SceneReplacementFileItem(f.FullName)).ToList<ILibraryItem>())
|
||||
var emptyPlateButton = new ImageWidget(AggContext.StaticData.LoadIcon("empty-workspace.png", 70, 70))
|
||||
{
|
||||
toolbar.AddChild(new IconViewItem(new ListViewItem(item, listView), 70, 70, theme)
|
||||
{
|
||||
Margin = new BorderDouble(right: 5)
|
||||
});
|
||||
}
|
||||
|
||||
var sideBar = new FlowLayoutWidget()
|
||||
{
|
||||
VAnchor = VAnchor.Center | VAnchor.Fit,
|
||||
HAnchor = HAnchor.Fit
|
||||
Margin = new BorderDouble(right: 5),
|
||||
Selectable = true,
|
||||
BackgroundColor = theme.MinimalShade,
|
||||
Name = "Create Part"
|
||||
};
|
||||
|
||||
var createPart = new TextButton("Create Part".Localize(), theme)
|
||||
{
|
||||
Name = "Create Part Button",
|
||||
Margin = theme.ButtonSpacing,
|
||||
BackgroundColor = theme.MinimalShade
|
||||
};
|
||||
createPart.Click += (s, e) =>
|
||||
emptyPlateButton.Click += async (s, e) =>
|
||||
{
|
||||
UiThread.RunOnIdle(() =>
|
||||
{
|
||||
|
|
@ -249,9 +257,17 @@ namespace MatterHackers.MatterControl.PartPreviewWindow.PlusTab
|
|||
}).ConfigureAwait(false);
|
||||
});
|
||||
};
|
||||
sideBar.AddChild(createPart);
|
||||
toolbar.AddChild(emptyPlateButton);
|
||||
|
||||
|
||||
foreach (var item in recentParts.Take(10).Select(f => new SceneReplacementFileItem(f.FullName)).ToList<ILibraryItem>())
|
||||
{
|
||||
toolbar.AddChild(new IconViewItem(new ListViewItem(item, listView), 70, 70, theme)
|
||||
{
|
||||
Margin = new BorderDouble(right: 5)
|
||||
});
|
||||
}
|
||||
|
||||
toolbar.SetRightAnchorItem(sideBar);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -178,7 +178,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
|
|||
|
||||
public class ChromeTabs : SimpleTabs
|
||||
{
|
||||
private NewTabButton plusTabButton;
|
||||
private TabTrailer tabTrailer;
|
||||
|
||||
public ChromeTabs(GuiWidget rightAnchorItem, ThemeConfig theme)
|
||||
: base(theme, rightAnchorItem)
|
||||
|
|
@ -195,32 +195,20 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
|
|||
ChromeTab.DrawTabLowerRight(e.Graphics2D, leadingTabAdornment.LocalBounds, (firstItem == this.ActiveTab) ? theme.ActiveTabColor : theme.InactiveTabColor);
|
||||
};
|
||||
this.TabBar.ActionArea.AddChild(leadingTabAdornment);
|
||||
|
||||
// TODO: add in the printers and designs that are currently open (or were open last run).
|
||||
plusTabButton = new NewTabButton(
|
||||
AggContext.StaticData.LoadIcon("fa-plus_12.png", theme.InvertIcons),
|
||||
this,
|
||||
theme)
|
||||
tabTrailer = new TabTrailer(this, theme)
|
||||
{
|
||||
VAnchor = VAnchor.Bottom,
|
||||
MinimumSize = new Vector2(16, theme.TabButtonHeight),
|
||||
ToolTipText = "Create New".Localize()
|
||||
};
|
||||
plusTabButton.IconButton.Click += (s, e) =>
|
||||
{
|
||||
this.AddTab(
|
||||
new ChromeTab("New Tab".Localize(), this, this.NewTabPage(), theme)
|
||||
{
|
||||
MinimumSize = new Vector2(0, theme.TabButtonHeight)
|
||||
});
|
||||
};
|
||||
|
||||
this.TabBar.ActionArea.AddChild(plusTabButton);
|
||||
this.TabBar.ActionArea.AddChild(tabTrailer);
|
||||
}
|
||||
|
||||
public void AddTab(GuiWidget tab)
|
||||
{
|
||||
var position = this.TabBar.ActionArea.GetChildIndex(plusTabButton);
|
||||
var position = this.TabBar.ActionArea.GetChildIndex(tabTrailer);
|
||||
|
||||
if (tab is ChromeTab chromeTab)
|
||||
{
|
||||
|
|
@ -232,7 +220,6 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
|
|||
|
||||
this.AddTab(tab, position);
|
||||
|
||||
chromeTab.CloseClicked += ChromeTab_CloseClicked;
|
||||
this.ActiveTab = chromeTab;
|
||||
}
|
||||
}
|
||||
|
|
@ -259,15 +246,11 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
|
|||
}
|
||||
}
|
||||
|
||||
private async void ChromeTab_CloseClicked(object sender, EventArgs e)
|
||||
{
|
||||
}
|
||||
|
||||
public Func<GuiWidget> NewTabPage { get; set; }
|
||||
|
||||
protected override void OnActiveTabChanged()
|
||||
{
|
||||
plusTabButton.LastTab = this.AllTabs.LastOrDefault();
|
||||
tabTrailer.LastTab = this.AllTabs.LastOrDefault();
|
||||
base.OnActiveTabChanged();
|
||||
}
|
||||
}
|
||||
|
|
@ -447,13 +430,13 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
|
|||
|
||||
public class ChromeTab : SimpleTab
|
||||
{
|
||||
public ChromeTab(string tabLabel, SimpleTabs parentTabControl, GuiWidget tabContent, ThemeConfig theme, string tabImageUrl = null)
|
||||
: base(tabLabel, parentTabControl, tabContent, theme, tabImageUrl)
|
||||
public ChromeTab(string tabLabel, SimpleTabs parentTabControl, GuiWidget tabContent, ThemeConfig theme, string tabImageUrl = null, bool hasClose = true)
|
||||
: base(tabLabel, parentTabControl, tabContent, theme, tabImageUrl, hasClose)
|
||||
{
|
||||
}
|
||||
|
||||
public ChromeTab(string tabLabel, SimpleTabs parentTabControl, GuiWidget tabContent, ThemeConfig theme, ImageBuffer imageBuffer)
|
||||
: base(tabLabel, parentTabControl, tabContent, theme, iconImage: imageBuffer)
|
||||
public ChromeTab(string tabLabel, SimpleTabs parentTabControl, GuiWidget tabContent, ThemeConfig theme, ImageBuffer imageBuffer, bool hasClose = true)
|
||||
: base(tabLabel, parentTabControl, tabContent, theme, iconImage: imageBuffer, hasClose: hasClose)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -155,20 +155,6 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
|
|||
buttonGroupB.Add(layers2DButton);
|
||||
this.AddChild(layers2DButton);
|
||||
|
||||
//// put in the detail message
|
||||
//var printerConnectionDetail = new TextWidget("")
|
||||
//{
|
||||
// Margin = new BorderDouble(5, 0),
|
||||
// TextColor = ActiveTheme.Instance.PrimaryTextColor,
|
||||
// AutoExpandBoundsToText = true,
|
||||
// PointSize = 8
|
||||
//};
|
||||
//printer.Connection.PrintingStateChanged.RegisterEvent((s, e) =>
|
||||
//{
|
||||
// printerConnectionDetail.Text = printer.PrinterConnectionStatus;
|
||||
//}, ref unregisterEvents);
|
||||
//this.AddChild(printerConnectionDetail);
|
||||
|
||||
this.AddChild(new HorizontalSpacer());
|
||||
|
||||
bool shareTemp = printer.Settings.GetValue<bool>(SettingsKey.extruders_share_temperature);
|
||||
|
|
|
|||
BIN
StaticData/Icons/empty-workspace.png
Normal file
BIN
StaticData/Icons/empty-workspace.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 4.5 KiB |
|
|
@ -1 +1 @@
|
|||
Subproject commit 5a72ceef8b2c7aa1c2c43b97907d61f9c421765f
|
||||
Subproject commit 9c491cffc88bb8b5733a1c5927c63e7d836859a4
|
||||
Loading…
Add table
Add a link
Reference in a new issue