Make tabs able to shrink
Rename SDCard project folder to Printer
This commit is contained in:
parent
97d73b827b
commit
1db11ee42a
6 changed files with 67 additions and 17 deletions
|
|
@ -67,6 +67,18 @@ namespace MatterHackers.MatterControl.Library
|
|||
IsReadOnly = true
|
||||
});
|
||||
|
||||
#if false // working on a new container that holds custom parts for a given printer
|
||||
this.ChildContainers.Add(
|
||||
new DynamicContainerLink(
|
||||
() => "Printer Parts".Localize(),
|
||||
AggContext.StaticData.LoadIcon(Path.Combine("Library", "folder_20x20.png")),
|
||||
AggContext.StaticData.LoadIcon(Path.Combine("Library", "folder.png")),
|
||||
() => new GitHubPartsContainer(printer),
|
||||
() => repositoryExistsAndHasContent) // visibility
|
||||
{
|
||||
IsReadOnly = true
|
||||
});
|
||||
#else
|
||||
this.ChildContainers.Add(
|
||||
new DynamicContainerLink(
|
||||
() => "Calibration Parts".Localize(),
|
||||
|
|
@ -76,6 +88,7 @@ namespace MatterHackers.MatterControl.Library
|
|||
{
|
||||
IsReadOnly = true
|
||||
});
|
||||
#endif
|
||||
|
||||
// TODO: An enumerable list of serialized container paths (or some other markup) to construct for this printer
|
||||
// printer.Settings.GetValue(SettingsKey.library_containers);
|
||||
|
|
@ -31,6 +31,7 @@ using System;
|
|||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Threading.Tasks;
|
||||
using MatterControlLib;
|
||||
using MatterHackers.Agg;
|
||||
|
|
@ -262,10 +263,11 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
|
|||
|
||||
ApplicationController.Instance.NotifyPrintersTabRightElement(extensionArea);
|
||||
|
||||
ChromeTab tab = null;
|
||||
|
||||
// Upgrade tab
|
||||
if (!ApplicationController.Instance.IsMatterControlPro())
|
||||
{
|
||||
GuiWidget tab;
|
||||
tabControl.AddTab(
|
||||
tab = new ChromeTab("Upgrade", "Upgrade".Localize(), tabControl, new UpgradeToProTabPage(theme), theme, hasClose: false)
|
||||
{
|
||||
|
|
@ -278,13 +280,14 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
|
|||
{
|
||||
// Store tab
|
||||
tabControl.AddTab(
|
||||
new ChromeTab("Store", "Store".Localize(), tabControl, new StoreTabPage(theme), theme, hasClose: false)
|
||||
tab = new ChromeTab("Store", "Store".Localize(), tabControl, new StoreTabPage(theme), theme, hasClose: false)
|
||||
{
|
||||
MinimumSize = new Vector2(0, theme.TabButtonHeight),
|
||||
Name = "Store Tab",
|
||||
Padding = new BorderDouble(15, 0),
|
||||
});
|
||||
}
|
||||
EnableReduceWidth(tab, theme);
|
||||
|
||||
// Library tab
|
||||
var libraryWidget = new LibraryWidget(this, theme)
|
||||
|
|
@ -293,16 +296,17 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
|
|||
};
|
||||
|
||||
tabControl.AddTab(
|
||||
new ChromeTab("Library", "Library".Localize(), tabControl, libraryWidget, theme, hasClose: false)
|
||||
tab = new ChromeTab("Library", "Library".Localize(), tabControl, libraryWidget, theme, hasClose: false)
|
||||
{
|
||||
MinimumSize = new Vector2(0, theme.TabButtonHeight),
|
||||
Name = "Library Tab",
|
||||
Padding = new BorderDouble(15, 0),
|
||||
});
|
||||
EnableReduceWidth(tab, theme);
|
||||
|
||||
// Hardware tab
|
||||
tabControl.AddTab(
|
||||
new ChromeTab(
|
||||
tab = new ChromeTab(
|
||||
"Hardware",
|
||||
"Hardware".Localize(),
|
||||
tabControl,
|
||||
|
|
@ -317,6 +321,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
|
|||
Name = "Hardware Tab",
|
||||
Padding = new BorderDouble(15, 0),
|
||||
});
|
||||
EnableReduceWidth(tab, theme);
|
||||
|
||||
SetInitialTab();
|
||||
|
||||
|
|
@ -683,7 +688,6 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
|
|||
tabImageUrl: ApplicationController.Instance.GetFavIconUrl(oemName: printer.Settings.GetValue(SettingsKey.make)))
|
||||
{
|
||||
Name = "3D View Tab",
|
||||
MinimumSize = new Vector2(120, theme.TabButtonHeight)
|
||||
};
|
||||
|
||||
// add a right click menu
|
||||
|
|
@ -695,6 +699,8 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
|
|||
}
|
||||
};
|
||||
|
||||
EnableReduceWidth(printerTab, theme);
|
||||
|
||||
void Tab_CloseClicked(object sender, EventArgs args)
|
||||
{
|
||||
ApplicationController.Instance.ClosePrinter(printer);
|
||||
|
|
@ -786,19 +792,9 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
|
|||
AggContext.StaticData.LoadIcon("cube.png", 16, 16, theme.InvertIcons))
|
||||
{
|
||||
Name = "newPart" + tabControl.AllTabs.Count(),
|
||||
MinimumSize = new Vector2(120, theme.TabButtonHeight),
|
||||
};
|
||||
|
||||
partTab.MaximumSize = new Vector2(partTab.Width, partTab.MaximumSize.Y);
|
||||
partTab.HAnchor = HAnchor.Stretch;
|
||||
|
||||
var textWidget = partTab.Descendants<TextWidget>().First();
|
||||
textWidget.HAnchor = HAnchor.Stretch;
|
||||
var tabPill = partTab.Descendants<SimpleTab.TabPill>().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);
|
||||
EnableReduceWidth(partTab, theme);
|
||||
|
||||
tabControl.AddTab(partTab);
|
||||
|
||||
|
|
@ -819,6 +815,47 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
|
|||
return partTab;
|
||||
}
|
||||
|
||||
private static void EnableReduceWidth(ChromeTab partTab, ThemeConfig theme)
|
||||
{
|
||||
partTab.MinimumSize = new Vector2(80, theme.TabButtonHeight);
|
||||
|
||||
var textWidget = partTab.Descendants<TextWidget>().First();
|
||||
var tabPill = partTab.Descendants<SimpleTab.TabPill>().First();
|
||||
partTab.ToolTipText = textWidget.Text;
|
||||
tabPill.HAnchor = HAnchor.Stretch;
|
||||
var closeBox = partTab.Descendants<ImageWidget>().FirstOrDefault();
|
||||
if (closeBox != null)
|
||||
{
|
||||
var tabPillMarign = tabPill.Margin;
|
||||
tabPill.Margin = new BorderDouble(tabPillMarign.Left, tabPillMarign.Bottom, tabPillMarign.Right + 10, tabPillMarign.Top);
|
||||
}
|
||||
|
||||
UpadetMaxWidth();
|
||||
|
||||
textWidget.TextChanged += (s, e) => UpadetMaxWidth();
|
||||
|
||||
void UpadetMaxWidth()
|
||||
{
|
||||
// the text
|
||||
var width = textWidget.Width;
|
||||
// the tab pill
|
||||
width += tabPill.Margin.Width + tabPill.Padding.Width;
|
||||
if (closeBox != null)
|
||||
{
|
||||
// the close box
|
||||
width += closeBox.Width;
|
||||
}
|
||||
else
|
||||
{
|
||||
width += 32;
|
||||
}
|
||||
|
||||
partTab.MaximumSize = new Vector2(width, partTab.MaximumSize.Y);
|
||||
}
|
||||
|
||||
partTab.HAnchor = HAnchor.Stretch;
|
||||
}
|
||||
|
||||
public override void OnClosed(EventArgs e)
|
||||
{
|
||||
// Unregister listeners
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
Subproject commit 71e3ef9688101735b4c7b98f7f0c02c14b1af118
|
||||
Subproject commit afb3857da3d30fe9957f8d4654ea2eb7218743b8
|
||||
Loading…
Add table
Add a link
Reference in a new issue