From b46bf0b76032e013fbddbfbf075d6ec69324875d Mon Sep 17 00:00:00 2001 From: John Lewin Date: Mon, 22 Jan 2018 12:11:36 -0800 Subject: [PATCH] Improve visibility calculation --- PartPreviewWindow/View3D/PrinterBar/OverflowBar.cs | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/PartPreviewWindow/View3D/PrinterBar/OverflowBar.cs b/PartPreviewWindow/View3D/PrinterBar/OverflowBar.cs index 3f84bbd00..e014b92c2 100644 --- a/PartPreviewWindow/View3D/PrinterBar/OverflowBar.cs +++ b/PartPreviewWindow/View3D/PrinterBar/OverflowBar.cs @@ -41,7 +41,8 @@ namespace MatterHackers.MatterControl.PartPreviewWindow { public class OverflowBar : Toolbar { - private static HashSet ignoredTypes = new HashSet { typeof(VerticalLine), typeof(HorizontalLine), typeof(SearchInputBox) }; + private static HashSet ignoredTypes = new HashSet { typeof(HorizontalLine), typeof(SearchInputBox) }; + private static HashSet ignoredInMenuTypes = new HashSet { typeof(VerticalLine), typeof(HorizontalLine), typeof(SearchInputBox) }; public OverflowBar(ThemeConfig theme) { @@ -79,11 +80,17 @@ namespace MatterHackers.MatterControl.PartPreviewWindow double maxRight = this.Width - RightAnchorItem.Width; + double rightPos = 0; + foreach (var widget in this.ActionArea.Children.Where(c => !ignoredTypes.Contains(c.GetType()))) { + rightPos += widget.Width + widget.Margin.Width; + // Widget is visible when its right edge is less than maxRight - widget.Visible = widget.Position.X + widget.Width < maxRight; + widget.Visible = rightPos < maxRight; // widget.Position.X + widget.Width < maxRight; } + + base.OnBoundsChanged(e); } @@ -100,7 +107,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow var popupMenu = new PopupMenu(theme); bool hasOverflowItems = false; - foreach (var widget in overflowBar.ActionArea.Children.Where(c => c.Enabled && !c.Visible && !ignoredTypes.Contains(c.GetType()))) + foreach (var widget in overflowBar.ActionArea.Children.Where(c => c.Enabled && !c.Visible && !ignoredInMenuTypes.Contains(c.GetType()))) { hasOverflowItems = true;