Fix more menu issues

- Restore ViewControls3D Overflow menu selection
- Revise DropList styling
- Revert to prior mechanism for DynamicPopupContent
- Create redirector in PrinterTabPage for dynamic overflow menu
This commit is contained in:
John Lewin 2017-05-26 00:23:20 -07:00
parent 88d32b0d2d
commit 7c4ff5569b
6 changed files with 21 additions and 22 deletions

View file

@ -36,7 +36,6 @@ using MatterHackers.Agg.PlatformAbstract;
using MatterHackers.Agg.Image;
using MatterHackers.Agg.ImageProcessing;
using System;
using System.Collections.Generic;
namespace MatterHackers.MatterControl.PartPreviewWindow
{
@ -67,7 +66,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
public GuiWidget PopupContent { get; set; }
public List<Func<GuiWidget>> DynamicPopupContent { get; set; } = new List<Func<GuiWidget>>();
public Func<GuiWidget> DynamicPopupContent { get; set; }
public bool AlignToRightEdge { get; set; }
@ -94,18 +93,9 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
this.PopupContent?.ClearRemovedFlag();
// Invoke registered funcs until content is found
if (this.DynamicPopupContent != null)
{
foreach(var action in this.DynamicPopupContent)
{
var content = action();
if(content != null)
{
this.PopupContent = content;
break;
}
}
this.PopupContent = this.DynamicPopupContent();
}
if (this.PopupContent == null)

View file

@ -132,6 +132,15 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
{
modelViewer.meshViewerWidget.ResetView();
};
viewControls3D.OverflowButton.DynamicPopupContent = () =>
{
if (modelViewer.Visible)
{
return modelViewer.ShowOverflowMenu();
}
return null;
};
// The 3D model view
modelViewer = new View3DWidget(printItem,

View file

@ -85,12 +85,12 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
{
AlignToRightEdge = true,
};
overflowDropdown.DynamicPopupContent.Add(GeneratePopupContent);
overflowDropdown.DynamicPopupContent = GeneratePopupContent;
// Deregister on close
this.Closed += (s, e) =>
{
overflowDropdown.DynamicPopupContent.Add(GeneratePopupContent);
overflowDropdown.DynamicPopupContent = GeneratePopupContent;
};
this.AddChild(overflowDropdown);

View file

@ -64,7 +64,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
private IObject3D item;
private View3DWidget view3DWidget;
public string Name { get { return "General"; } }
public string Name => "General";
public bool Unlocked => true;
@ -2396,7 +2396,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
// ViewControls3D {{
private GuiWidget ShowOverflowMenu()
internal GuiWidget ShowOverflowMenu()
{
var popupContainer = new FlowLayoutWidget(FlowDirection.TopToBottom);

View file

@ -69,7 +69,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
private EventHandler unregisterEvents;
private OverflowDropdown overflowButton;
internal OverflowDropdown OverflowButton;
public event EventHandler ResetView;
@ -176,10 +176,10 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
};
AddChild(layersButton);
overflowButton = new OverflowDropdown(allowLightnessInvert: false);
overflowButton.ToolTipText = "More...".Localize();
overflowButton.Margin = 3;
AddChild(overflowButton);
OverflowButton = new OverflowDropdown(allowLightnessInvert: false);
OverflowButton.ToolTipText = "More...".Localize();
OverflowButton.Margin = 3;
AddChild(OverflowButton);
HAnchor |= Agg.UI.HAnchor.ParentLeft;
VAnchor = Agg.UI.VAnchor.ParentTop;

View file

@ -284,7 +284,7 @@ namespace MatterHackers.MatterControl.SlicerConfiguration
var dropDownList = new DropDownList(defaultMenuItemText, maxHeight: 300, useLeftIcons: true)
{
HAnchor = HAnchor.ParentLeftRight,
MenuItemsPadding = new BorderDouble(10, 4, 10, 6),
MenuItemsPadding = new BorderDouble(10, 7, 7, 7),
};
dropDownList.Name = layerType.ToString();