Make the design tabs able to shrink
This commit is contained in:
parent
04b29f8fd9
commit
3d6fe51e32
5 changed files with 48 additions and 11 deletions
|
|
@ -2760,6 +2760,11 @@ namespace MatterHackers.MatterControl
|
|||
public void NotifyPrintersTabRightElement(GuiWidget sourceExentionArea)
|
||||
{
|
||||
AddPrintersTabRightElement?.Invoke(this, new WidgetSourceEventArgs(sourceExentionArea));
|
||||
|
||||
// after adding content to the right side make sure we hold the space in the tab bar
|
||||
var leftChild = sourceExentionArea.Parent.Children.First();
|
||||
var padding = leftChild.Padding;
|
||||
leftChild.Padding = new BorderDouble(padding.Left, padding.Bottom, sourceExentionArea.Width, padding.Height);
|
||||
}
|
||||
|
||||
public async Task PrintPart(EditContext editContext, PrinterConfig printer, IProgress<ProgressStatus> reporter, CancellationToken cancellationToken)
|
||||
|
|
|
|||
|
|
@ -38,6 +38,7 @@ using MatterHackers.Agg.Platform;
|
|||
using MatterHackers.Agg.UI;
|
||||
using MatterHackers.DataConverters3D;
|
||||
using MatterHackers.Localizations;
|
||||
using MatterHackers.MatterControl.CustomWidgets;
|
||||
using MatterHackers.MatterControl.Library;
|
||||
using MatterHackers.MatterControl.PartPreviewWindow.PlusTab;
|
||||
using MatterHackers.MatterControl.PrintLibrary;
|
||||
|
|
@ -752,9 +753,20 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
|
|||
AggContext.StaticData.LoadIcon("cube.png", 16, 16, theme.InvertIcons))
|
||||
{
|
||||
Name = "newPart" + tabControl.AllTabs.Count(),
|
||||
MinimumSize = new Vector2(120, theme.TabButtonHeight)
|
||||
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);
|
||||
|
||||
tabControl.AddTab(partTab);
|
||||
|
||||
void Tab_CloseClicked(object sender, EventArgs args)
|
||||
|
|
|
|||
|
|
@ -384,19 +384,24 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
|
|||
{
|
||||
tabPill = new TabPill(tabLabel, theme.TextColor, tabImageUrl, pointSize);
|
||||
}
|
||||
tabPill.Margin = (hasClose) ? new BorderDouble(right: 16) : 0;
|
||||
|
||||
tabPill.Margin = hasClose ? new BorderDouble(right: 16) : 0;
|
||||
|
||||
this.AddChild(tabPill);
|
||||
|
||||
if (hasClose)
|
||||
{
|
||||
// var fadeRegion = new LeftClipFlowLayoutWidget();
|
||||
// fadeRegion.HAnchor |= HAnchor.Right;
|
||||
// this.AddChild(fadeRegion);
|
||||
|
||||
var closeButton = 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 += (s, e) => ConditionallyCloseTab();
|
||||
|
||||
closeButton.HAnchor |= HAnchor.Right;
|
||||
// fadeRegion.AddChild(closeButton);
|
||||
this.AddChild(closeButton);
|
||||
}
|
||||
}
|
||||
|
|
@ -455,13 +460,13 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
|
|||
});
|
||||
}
|
||||
|
||||
protected class TabPill : FlowLayoutWidget
|
||||
public class TabPill : FlowLayoutWidget
|
||||
{
|
||||
private TextWidget label;
|
||||
private ImageWidget imageWidget;
|
||||
|
||||
public TabPill(string tabTitle, Color textColor, string imageUrl = null, double pointSize = 12)
|
||||
: this (tabTitle, textColor, string.IsNullOrEmpty(imageUrl) ? null : new ImageBuffer(16, 16).CreateScaledImage(GuiWidget.DeviceScale), pointSize)
|
||||
: this(tabTitle, textColor, string.IsNullOrEmpty(imageUrl) ? null : new ImageBuffer(16, 16).CreateScaledImage(GuiWidget.DeviceScale), pointSize)
|
||||
{
|
||||
if (imageWidget != null
|
||||
&& !string.IsNullOrEmpty(imageUrl))
|
||||
|
|
@ -577,8 +582,8 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
|
|||
|
||||
int position = siblings.IndexOf(this);
|
||||
|
||||
//MainTab leftSibling = (position > 0) ? siblings[position - 1] : null;
|
||||
//MainTab rightSibling = (position < siblings.Count - 1) ? siblings[position + 1] : null;
|
||||
// MainTab leftSibling = (position > 0) ? siblings[position - 1] : null;
|
||||
// MainTab rightSibling = (position < siblings.Count - 1) ? siblings[position + 1] : null;
|
||||
|
||||
var activeTab = parentTabControl.ActiveTab;
|
||||
|
||||
|
|
@ -598,6 +603,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
|
|||
{
|
||||
tabShape.LineTo(rect.Right, rect.Bottom);
|
||||
}
|
||||
|
||||
tabShape.LineTo(rect.Right - tabInsetDistance, rect.Bottom);
|
||||
tabShape.LineTo(rect.Left + tabInsetDistance, rect.Bottom);
|
||||
if (!drawLeftTabOverlap)
|
||||
|
|
|
|||
|
|
@ -125,8 +125,7 @@ namespace Markdig.Renderers.Agg.Inlines
|
|||
{
|
||||
WebCache.RetrieveImageSquenceAsync(imageSequence, ImageUrl, () =>
|
||||
{
|
||||
MinimumSize = new Vector2(Math.Max(20 * DeviceScale, MinimumSize.X), MinimumSize.Y);
|
||||
MaximumSize = new Vector2(imageSequence.Width, imageSequence.Height);
|
||||
this.MinStretchOrFitHorizontal(20, imageSequence.Width);
|
||||
UiThread.RunOnIdle(() =>
|
||||
{
|
||||
if (aggRenderer.RootWidget.Parents<MarkdownWidget>().FirstOrDefault() is MarkdownWidget markdownWidget)
|
||||
|
|
@ -143,6 +142,21 @@ namespace Markdig.Renderers.Agg.Inlines
|
|||
base.OnDraw(graphics2D);
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Sets this control to Stretch and all direct parent FlowLayoutWidgets to Stretch, it then ensures
|
||||
/// this and all direct parent FlowLayouts have a max width of the contents of this.
|
||||
/// </summary>
|
||||
/// <param name="absoluteMinWidth">The minimum size will be set to the larger of the existing minimum size or this value.</param>
|
||||
/// <param name="absoluteMaxWidth">The maximum size will be set to this value.</param>
|
||||
private void MinStretchOrFitHorizontal(double absoluteMinWidth, double absoluteMaxWidth)
|
||||
{
|
||||
this.HAnchor = HAnchor.Stretch;
|
||||
|
||||
MinimumSize = new Vector2(Math.Max(absoluteMinWidth * DeviceScale, MinimumSize.X), MinimumSize.Y);
|
||||
MaximumSize = new Vector2(absoluteMaxWidth, MaximumSize.Y);
|
||||
}
|
||||
|
||||
public string ImageUrl { get; }
|
||||
|
||||
private string LinkUrl { get; }
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
Subproject commit 924fcb33e812d9e2b3014bd00283d5c43045039e
|
||||
Subproject commit 157e57e1fb2081b38dccd59b3eab4300fb18845a
|
||||
Loading…
Add table
Add a link
Reference in a new issue