Merge pull request #2856 from jlewin/design_tools

Revise tabs
This commit is contained in:
Lars Brubaker 2018-01-08 16:40:57 -08:00 committed by GitHub
commit 5d42ab1471
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
10 changed files with 264 additions and 176 deletions

View file

@ -108,6 +108,7 @@ namespace MatterHackers.MatterControl
public Color ActiveTabColor { get; set; }
public Color InactiveTabColor { get; set; }
public Color ActiveTabBarBackground { get; set; }
public TextImageButtonFactory DisableableControlBase { get; private set; }
public TextImageButtonFactory HomingButtons { get; private set; }
@ -165,14 +166,15 @@ namespace MatterHackers.MatterControl
commonOptions.BorderWidth = 0;
commonOptions.FixedHeight = 32;
this.ActiveTabColor = ResolveColor(theme.PrimaryBackgroundColor, new Color(Color.Black, this.SlightShade.alpha));
this.TabBodyBackground = this.ResolveColor(
ActiveTheme.Instance.TertiaryBackgroundColor,
new Color(
Color.White,
(ActiveTheme.Instance.IsDarkTheme) ? 3 : 25));
this.ActiveTabColor = this.TabBodyBackground;
this.ActiveTabBarBackground = this.ActiveTabColor.AdjustLightness(0.85).ToColor();
// Active tab color with slight transparency
this.InteractionLayerOverlayColor = new Color(this.ActiveTabColor, 200);

View file

@ -73,19 +73,22 @@ namespace MatterHackers.MatterControl
var leftNav = new FlowLayoutWidget(FlowDirection.TopToBottom);
leftNav.AnchorAll();
var toolbar = new Toolbar(null, theme)
var toolbar = new Toolbar()
{
HAnchor = HAnchor.Stretch,
VAnchor = VAnchor.Fit,
MinimumSize = new Vector2(16, 16)
MinimumSize = new Vector2(16, 16),
BackgroundColor = theme.ActiveTabBarBackground,
BorderColor = theme.ActiveTabColor,
Border = 0 //new BorderDouble(bottom: 2),
};
toolbar.BorderColor = ApplicationController.Instance.Theme.SlightShade;
toolbar.Border = new BorderDouble(bottom: 2);
toolbar.ActionArea.AddChild(new BrandMenuButton(theme)
{
MinimumSize = new VectorMath.Vector2(0, 34),
MinimumSize = new Vector2(0, 34),
HAnchor = HAnchor.Stretch,
VAnchor = VAnchor.Fit
VAnchor = VAnchor.Fit,
Border = new BorderDouble(right: 1),
BorderColor = theme.MinimalShade
});
leftNav.AddChild(toolbar);

View file

@ -157,7 +157,7 @@ namespace MatterHackers.MatterControl.CustomWidgets
this.RemoveAllChildren();
TabControl tabControl = null;
SimpleTabs tabControl = null;
if (this.ControlIsPinned)
{
var resizePage = new ResizeContainer(this)
@ -168,39 +168,54 @@ namespace MatterHackers.MatterControl.CustomWidgets
SplitterWidth = theme.SplitterWidth,
};
tabControl = theme.CreateTabControl();
tabControl = new SimpleTabs(this.CreatePinButton())
{
VAnchor = VAnchor.Stretch,
HAnchor = HAnchor.Stretch,
};
tabControl.TabBar.BackgroundColor = theme.ActiveTabBarBackground;
tabControl.ActiveTabChanged += (s, e) =>
{
printer.ViewState.SliceSettingsTabIndex = tabControl.SelectedTabIndex;
};
resizePage.AddChild(tabControl);
this.AddChild(resizePage);
}
int tabIndex = 0;
foreach (var nameWidget in allTabs)
foreach (var kvp in allTabs)
{
string tabTitle = nameWidget.Key;
string tabTitle = kvp.Key;
if (this.ControlIsPinned)
{
var content = new DockingWindowContent(this, nameWidget.Value, tabTitle);
var content = new DockingWindowContent(this, kvp.Value, tabTitle);
var tabPage = new TabPage(content, tabTitle);
var textTab = new TextTab(
tabPage,
tabTitle + " Tab",
12,
ActiveTheme.Instance.TabLabelSelected,
Color.Transparent,
ActiveTheme.Instance.TabLabelUnselected,
Color.Transparent,
useUnderlineStyling: true);
var tab = new ToolTab(
tabTitle,
tabControl,
content,
theme,
hasClose: kvp.Value is ConfigurePrinterWidget,
pointSize: theme.FontSize11)
{
Name = tabTitle + " Tab",
InactiveTabColor = Color.Transparent,
ActiveTabColor = theme.TabBodyBackground
};
tabControl.AddTab(textTab);
int localTabIndex = tabIndex;
textTab.Click += (s, e) =>
tab.CloseClicked += (s, e) =>
{
printer.ViewState.SliceSettingsTabIndex = localTabIndex;
if (tab.Name == "Printer Tab")
{
printer.ViewState.ConfigurePrinterVisible = false;
}
};
tabControl.AddTab(tab);
}
else // control is floating
{
@ -241,7 +256,7 @@ namespace MatterHackers.MatterControl.CustomWidgets
SpliterBarColor = spliterColor,
SplitterWidth = ApplicationController.Instance.Theme.SplitterWidth,
};
resizeContainer.AddChild(new DockingWindowContent(this, nameWidget.Value, tabTitle)
resizeContainer.AddChild(new DockingWindowContent(this, kvp.Value, tabTitle)
{
BackgroundColor = ActiveTheme.Instance.PrimaryBackgroundColor,
Width = PageWidth
@ -291,15 +306,16 @@ namespace MatterHackers.MatterControl.CustomWidgets
if (this.ControlIsPinned)
{
tabControl.TabBar.AddChild(new HorizontalSpacer());
tabControl.TabBar.AddChild(this.CreatePinButton());
tabControl.TabBar.Padding = new BorderDouble(right: theme.ToolbarPadding.Right);
if (printer.ViewState.SliceSettingsTabIndex < tabControl.TabCount)
{
tabControl.SelectedTabIndex = printer.ViewState.SliceSettingsTabIndex;
}
else
{
tabControl.SelectedTabIndex = 0;
}
}
}

View file

@ -37,13 +37,19 @@ using MatterHackers.Localizations;
namespace MatterHackers.MatterControl.PartPreviewWindow
{
public class MainTab : GuiWidget, ITab
public class SimpleTab : GuiWidget, ITab
{
public event EventHandler CloseClicked;
private SimpleTabs parentTabControl;
protected SimpleTabs parentTabControl;
public MainTab(string tabLabel, SimpleTabs parentTabControl, GuiWidget tabContent, ThemeConfig theme, string tabImageUrl = null)
protected ThemeConfig theme;
protected TabPill tabPill;
public GuiWidget TabContent { get; protected set; }
public SimpleTab(string tabLabel, SimpleTabs parentTabControl, GuiWidget tabContent, ThemeConfig theme, string tabImageUrl = null, bool hasClose = true, double pointSize = 12, ImageBuffer iconImage = null)
{
this.HAnchor = HAnchor.Fit;
this.VAnchor = VAnchor.Fit | VAnchor.Bottom;
@ -54,45 +60,151 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
this.TabContent = tabContent;
this.parentTabControl = parentTabControl;
this.AddChild(
new TabPill(tabLabel, ActiveTheme.Instance.PrimaryTextColor, tabImageUrl)
{
Margin = new BorderDouble(right: 16)
});
var closeButton = ApplicationController.Instance.Theme.CreateSmallResetButton();
closeButton.HAnchor = HAnchor.Right;
closeButton.Margin = new BorderDouble(right: 7, top: 1);
closeButton.Name = "Close Tab Button";
closeButton.ToolTipText = "Close".Localize();
closeButton.Click += (sender, e) =>
if (iconImage != null)
{
UiThread.RunOnIdle(() =>
{
this.parentTabControl.RemoveTab(this);
this.CloseClicked?.Invoke(this, null);
});
};
tabPill = new TabPill(tabLabel, ActiveTheme.Instance.PrimaryTextColor, iconImage, pointSize);
}
else
{
tabPill = new TabPill(tabLabel, ActiveTheme.Instance.PrimaryTextColor, tabImageUrl, pointSize);
}
tabPill.Margin = (hasClose) ? new BorderDouble(right: 16) : 0;
this.AddChild(closeButton);
this.AddChild(tabPill);
if (hasClose)
{
var closeButton = ApplicationController.Instance.Theme.CreateSmallResetButton();
closeButton.HAnchor = HAnchor.Right;
closeButton.Margin = new BorderDouble(right: 7, top: 1);
closeButton.Name = "Close Tab Button";
closeButton.ToolTipText = "Close".Localize();
closeButton.Click += (sender, e) =>
{
UiThread.RunOnIdle(() =>
{
this.parentTabControl.RemoveTab(this);
this.CloseClicked?.Invoke(this, null);
});
};
this.AddChild(closeButton);
}
}
private ThemeConfig theme;
protected class TabPill : FlowLayoutWidget
{
private TextWidget label;
private ImageWidget imageWidget;
public GuiWidget TabContent { get; }
public TabPill(string tabTitle, Color textColor, string imageUrl = null, double pointSize = 12)
: this (tabTitle, textColor, string.IsNullOrEmpty(imageUrl) ? null : new ImageBuffer(16, 16), pointSize)
{
if (imageWidget != null
&& !string.IsNullOrEmpty(imageUrl))
{
try
{
// TODO: Use caching
// Attempt to load image
ApplicationController.Instance.DownloadToImageAsync(imageWidget.Image, imageUrl, false);
}
catch { }
}
}
public TabPill(string tabTitle, Color textColor, ImageBuffer imageBuffer = null, double pointSize = 12)
{
this.Selectable = false;
this.Padding = new BorderDouble(10, 5, 10, 4);
if (imageBuffer != null)
{
imageWidget = new ImageWidget(imageBuffer)
{
Margin = new BorderDouble(right: 6, bottom: 2),
VAnchor = VAnchor.Center
};
this.AddChild(imageWidget);
}
label = new TextWidget(tabTitle, pointSize: pointSize)
{
TextColor = textColor,
VAnchor = VAnchor.Center
};
this.AddChild(label);
}
public Color TextColor
{
get => label.TextColor;
set => label.TextColor = value;
}
public override string Text
{
get => label.Text;
set => label.Text = value;
}
}
}
public class ToolTab : SimpleTab
{
public Color InactiveTabColor { get; set; }
public Color ActiveTabColor { get; set; }
public override Color BorderColor
{
get => (this.IsActiveTab) ? ActiveTheme.Instance.PrimaryAccentColor : base.BorderColor;
set => base.BorderColor = value;
}
public ToolTab(string tabLabel, SimpleTabs parentTabControl, GuiWidget tabContent, ThemeConfig theme, string tabImageUrl = null, bool hasClose = true, int pointSize = -1)
: base(tabLabel, parentTabControl, tabContent, theme, tabImageUrl, hasClose, pointSize: (pointSize == -1) ? theme.FontSize10 : pointSize)
{
this.Border = new BorderDouble(top: 1);
tabPill.Padding = tabPill.Padding.Clone(top: 10, bottom: 10);
}
private bool IsActiveTab => this == parentTabControl.ActiveTab;
public override void OnDraw(Graphics2D graphics2D)
{
graphics2D.Render(
new RoundedRect(this.LocalBounds, 0),
(this.IsActiveTab) ? this.ActiveTabColor : this.InactiveTabColor);
base.OnDraw(graphics2D);
}
}
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, ImageBuffer imageBuffer)
: base(tabLabel, parentTabControl, tabContent, theme, iconImage: imageBuffer)
{
}
private static int tabInsetDistance = 14 / 2;
internal MainTab NextTab { get; set; }
internal ChromeTab NextTab { get; set; }
internal MainTab PreviousTab { get; set; }
internal ChromeTab PreviousTab { get; set; }
public override void OnDraw(Graphics2D graphics2D)
{
var rect = LocalBounds;
var centerY = rect.YCenter;
var siblings = this.Parent.Children.OfType<MainTab>().ToList();
var siblings = this.Parent.Children.OfType<ChromeTab>().ToList();
int position = siblings.IndexOf(this);
@ -165,53 +277,5 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
graphics2D.Render(tabLeft, color);
}
private class TabPill : FlowLayoutWidget
{
private TextWidget label;
public TabPill(string tabTitle, Color textColor, string imageUrl = null)
{
this.Selectable = false;
this.Padding = new BorderDouble(10, 5, 10, 4);
if (!string.IsNullOrEmpty(imageUrl))
{
var imageWidget = new ImageWidget(new ImageBuffer(16, 16))
{
Margin = new BorderDouble(right: 6, bottom: 2),
VAnchor = VAnchor.Center
};
this.AddChild(imageWidget);
// Attempt to load image
try
{
// TODO: Must use caching
ApplicationController.Instance.DownloadToImageAsync(imageWidget.Image, imageUrl, false);
}
catch { }
}
label = new TextWidget(tabTitle)
{
TextColor = textColor,
VAnchor = VAnchor.Center
};
this.AddChild(label);
}
public Color TextColor
{
get => label.TextColor;
set => label.TextColor = value;
}
public override string Text
{
get => label.Text;
set => label.Text = value;
}
}
}
}

View file

@ -64,7 +64,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
public override void OnDraw(Graphics2D graphics2D)
{
MainTab.DrawTabLowerLeft(
ChromeTab.DrawTabLowerLeft(
graphics2D,
this.LocalBounds,
(parentTabControl.ActiveTab == this.LastTab) ? theme.ActiveTabColor : theme.InactiveTabColor);

View file

@ -46,7 +46,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
public class PartPreviewContent : FlowLayoutWidget
{
private EventHandler unregisterEvents;
private MainTab printerTab = null;
private ChromeTab printerTab = null;
private ChromeTabs tabControl;
public PartPreviewContent()
@ -64,11 +64,14 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
VAnchor = VAnchor.Stretch,
HAnchor = HAnchor.Stretch,
BackgroundColor = ActiveTheme.Instance.PrimaryBackgroundColor,
BorderColor = theme.MinimalShade,
Border = new BorderDouble(left: 1),
NewTabPage = () =>
{
return new PlusTabPage(this, tabControl, theme);
}
};
tabControl.TabBar.BackgroundColor = theme.ActiveTabBarBackground;
tabControl.ActiveTabChanged += (s, e) =>
{
@ -84,7 +87,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
tabControl.TabBar.BorderColor = theme.ActiveTabColor;
tabControl.TabBar.Padding = new BorderDouble(top: 4);
tabControl.TabBar.Border = new BorderDouble(bottom: 2);
//tabControl.TabBar.Border = new BorderDouble(bottom: 2);
Color selectedTabColor = ActiveTheme.Instance.TabLabelSelected;
@ -135,19 +138,6 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
updateAvailableButton.Visible = UpdateControlData.Instance.UpdateStatus == UpdateControlData.UpdateStatusStates.UpdateAvailable;
}, ref unregisterEvents);
// this causes the update button to be centered
//tabControl.TabBar.AddChild(new HorizontalSpacer());
//rightPanelArea.AddChild(
// new ImageWidget(
// AggContext.StaticData.LoadImage(Path.Combine("Images", "minimize.png")))
// {
// VAnchor = VAnchor.Top,
// DebugShowBounds = true
// });
//this.AddChild(tabControl);
this.AddChild(tabControl);
ActiveSliceSettings.SettingChanged.RegisterEvent((s, e) =>
@ -168,7 +158,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
if (false && AppContext.IsLoading)
{
tabControl.AddTab(
new MainTab("New Tab".Localize(), tabControl, tabControl.NewTabPage(), theme)
new ChromeTab("New Tab".Localize(), tabControl, tabControl.NewTabPage(), theme)
{
MinimumSize = new Vector2(0, theme.shortButtonHeight)
});
@ -183,13 +173,13 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
}, ref unregisterEvents);
}
private MainTab CreatePrinterTab(PrinterConfig printer, ThemeConfig theme, string tabTitle)
private ChromeTab CreatePrinterTab(PrinterConfig printer, ThemeConfig theme, string tabTitle)
{
string oemName = printer.Settings.GetValue(SettingsKey.make);
OemSettings.Instance.OemUrls.TryGetValue(oemName, out string oemUrl);
return new MainTab(
return new ChromeTab(
tabTitle,
tabControl,
new PrinterTabPage(printer, theme, tabTitle.ToUpper()),
@ -201,14 +191,14 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
};
}
public MainTab CreatePartTab(string tabTitle, BedConfig sceneContext, ThemeConfig theme)
public ChromeTab CreatePartTab(string tabTitle, BedConfig sceneContext, ThemeConfig theme)
{
var partTab = new MainTab(
var partTab = new ChromeTab(
tabTitle,
tabControl,
new PartTabPage(null, sceneContext, theme, "xxxxx"),
theme,
"https://i.imgur.com/nkeYgfU.png")
AggContext.StaticData.LoadIcon("part.png"))
{
Name = "newPart" + tabControl.AllTabs.Count(),
MinimumSize = new Vector2(120, theme.shortButtonHeight)

View file

@ -46,7 +46,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
{
public FlowLayoutWidget ActionArea { get; }
public Toolbar(GuiWidget rightAnchorItem, ThemeConfig theme, bool bottomBorder = true)
public Toolbar(GuiWidget rightAnchorItem = null)
{
this.ActionArea = new FlowLayoutWidget()
{
@ -86,10 +86,10 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
private GuiWidget body;
public SimpleTabs(GuiWidget rightAnchorItem, ThemeConfig theme, bool bottomBorder = true)
public SimpleTabs(GuiWidget rightAnchorItem)
: base(FlowDirection.TopToBottom)
{
this.AddChild(TabBar = new Toolbar(rightAnchorItem, theme, bottomBorder)
this.AddChild(TabBar = new Toolbar(rightAnchorItem)
{
HAnchor = HAnchor.Stretch,
VAnchor = VAnchor.Fit
@ -108,7 +108,9 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
public IEnumerable<ITab> AllTabs => _allTabs;
public void AddTab(GuiWidget tabWidget, int position)
public int TabCount => _allTabs.Count;
public void AddTab(GuiWidget tabWidget, int position = -1)
{
var iTab = tabWidget as ITab;
@ -124,6 +126,16 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
private void TabWidget_Click(object sender, MouseEventArgs e)
{
this.ActiveTab = sender as ITab;
//this.SelectedTabIndex = this.Children.IndexOf(sender as GuiWidget);
}
public int SelectedTabIndex
{
get => _allTabs.IndexOf(this.ActiveTab);
set
{
this.ActiveTab = _allTabs[value];
}
}
internal void RemoveTab(ITab tab)
@ -169,18 +181,18 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
private NewTabButton plusTabButton;
public ChromeTabs(GuiWidget rightAnchorItem, ThemeConfig theme)
: base(rightAnchorItem, theme)
: base(rightAnchorItem)
{
// TODO: add in the printers and designs that are currently open (or were open last run).
var leadingTabAdornment = new GuiWidget()
{
MinimumSize = new VectorMath.Vector2(16, theme.shortButtonHeight),
MinimumSize = new Vector2(16, theme.shortButtonHeight),
VAnchor = VAnchor.Bottom
};
leadingTabAdornment.AfterDraw += (s, e) =>
{
var firstItem = this.AllTabs.OfType<MainTab>().FirstOrDefault();
MainTab.DrawTabLowerRight(e.graphics2D, leadingTabAdornment.LocalBounds, (firstItem == this.ActiveTab) ? theme.ActiveTabColor : theme.InactiveTabColor);
var firstItem = this.AllTabs.OfType<ChromeTab>().FirstOrDefault();
ChromeTab.DrawTabLowerRight(e.graphics2D, leadingTabAdornment.LocalBounds, (firstItem == this.ActiveTab) ? theme.ActiveTabColor : theme.InactiveTabColor);
};
this.TabBar.ActionArea.AddChild(leadingTabAdornment);
@ -197,7 +209,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
plusTabButton.IconButton.Click += (s, e) =>
{
this.AddTab(
new MainTab("New Tab".Localize(), this, this.NewTabPage(), theme)
new ChromeTab("New Tab".Localize(), this, this.NewTabPage(), theme)
{
MinimumSize = new Vector2(0, theme.shortButtonHeight)
});
@ -210,9 +222,9 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
{
var position = this.TabBar.ActionArea.GetChildIndex(plusTabButton);
if (tab is MainTab mainTab)
if (tab is ChromeTab mainTab)
{
mainTab.PreviousTab = this.AllTabs.OfType<MainTab>().LastOrDefault();
mainTab.PreviousTab = this.AllTabs.OfType<ChromeTab>().LastOrDefault();
if (mainTab.PreviousTab != null)
{
mainTab.PreviousTab.NextTab = mainTab;

View file

@ -38,7 +38,6 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
public class OverflowBar : Toolbar
{
public OverflowBar(ThemeConfig theme, GuiWidget viewWidget = null)
: base(null, theme)
{
this.Padding = theme.ToolbarPadding.Clone(left: 0);

View file

@ -34,13 +34,14 @@ using MatterHackers.Agg;
using MatterHackers.Agg.UI;
using MatterHackers.Localizations;
using MatterHackers.MatterControl.CustomWidgets;
using MatterHackers.MatterControl.PartPreviewWindow;
using MatterHackers.VectorMath;
namespace MatterHackers.MatterControl.SlicerConfiguration
{
public class SliceSettingsWidget : FlowLayoutWidget
{
private TabControl primaryTabControl;
private SimpleTabs primaryTabControl;
internal PresetsToolbar settingsControlBar;
internal SettingsContext settingsContext;
@ -101,63 +102,64 @@ namespace MatterHackers.MatterControl.SlicerConfiguration
// Close and remove children
primaryTabControl?.Close();
primaryTabControl = new TabControl();
primaryTabControl.TabBar.BorderColor = ActiveTheme.Instance.PrimaryTextColor;
primaryTabControl.Margin = new BorderDouble(top: 8);
primaryTabControl.AnchorAll();
var rightItem = (settingsContext.IsPrimarySettingsView) ? new SliceSettingsOverflowMenu(printer, this) : new GuiWidget();
primaryTabControl = new SimpleTabs(rightItem)
{
Margin = new BorderDouble(top: 8),
VAnchor = VAnchor.Stretch,
HAnchor = HAnchor.Stretch,
MinimumSize = new Vector2(200, 200)
};
primaryTabControl.TabBar.BackgroundColor = theme.ActiveTabBarBackground;
for (int topCategoryIndex = 0; topCategoryIndex < SliceSettingsOrganizer.Instance.UserLevels[UserLevel].CategoriesList.Count; topCategoryIndex++)
{
OrganizerCategory category = SliceSettingsOrganizer.Instance.UserLevels[UserLevel].CategoriesList[topCategoryIndex];
if (category.Name == "Printer"
&& (settingsContext.ViewFilter == NamedSettingsLayers.Material || settingsContext.ViewFilter == NamedSettingsLayers.Quality))
{
continue;
}
var categoryPage = new TabPage(category.Name.Localize());
categoryPage.AnchorAll();
var content = CreateSideTabsAndPages(category, this.ShowHelpControls);
content.BackgroundColor = theme.ActiveTabColor;
primaryTabControl.AddTab(new TextTab(
categoryPage,
category.Name + " Tab",
theme.FontSize11, // TODO: Short term workaround for tests until new tabs and overflow menu come in
ActiveTheme.Instance.TabLabelSelected,
new Color(),
ActiveTheme.Instance.TabLabelUnselected,
new Color(),
useUnderlineStyling: true));
var sideTabs = CreateSideTabsAndPages(category, this.ShowHelpControls);
sideTabs.MinimumSize = new Vector2(200, 200);
categoryPage.AddChild(sideTabs);
primaryTabControl.AddTab(
new ToolTab(category.Name.Localize(),
primaryTabControl,
content,
theme,
hasClose: false)
{
Name = category.Name + " Tab",
InactiveTabColor = Color.Transparent,
ActiveTabColor = theme.ActiveTabColor
});
}
primaryTabControl.TabBar.AddChild(new HorizontalSpacer());
if (settingsContext.IsPrimarySettingsView)
{
// Add the Overflow menu
primaryTabControl.TabBar.AddChild(new SliceSettingsOverflowMenu(printer, this)
{
Margin = new BorderDouble(right: theme.ToolbarPadding.Right)
});
}
this.AddChild(primaryTabControl);
// Restore the last selected tab
primaryTabControl.SelectTab(UserSettings.Instance.get(UserSettingsKey.SliceSettingsWidget_CurrentTab));
if (int.TryParse(UserSettings.Instance.get(UserSettingsKey.SliceSettingsWidget_CurrentTab), out int tabIndex)
&& tabIndex >= 0
&& tabIndex < primaryTabControl.TabCount - 1)
{
primaryTabControl.SelectedTabIndex = tabIndex;
}
else
{
primaryTabControl.SelectedTabIndex = 0;
}
// Store the last selected tab on change
primaryTabControl.TabBar.TabIndexChanged += (s, e) =>
primaryTabControl.ActiveTabChanged += (s, e) =>
{
if (!string.IsNullOrEmpty(primaryTabControl.TabBar.SelectedTabName)
&& settingsContext.IsPrimarySettingsView)
if (settingsContext.IsPrimarySettingsView)
{
UserSettings.Instance.set(UserSettingsKey.SliceSettingsWidget_CurrentTab, primaryTabControl.TabBar.SelectedTabName);
UserSettings.Instance.set(UserSettingsKey.SliceSettingsWidget_CurrentTab, primaryTabControl.SelectedTabIndex.ToString());
}
};
}

BIN
StaticData/Icons/part.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB