Merge pull request #2805 from jlewin/design_tools

Update overflow menus
This commit is contained in:
Lars Brubaker 2017-12-26 09:24:34 -08:00 committed by GitHub
commit 2346898064
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 96 additions and 52 deletions

View file

@ -81,7 +81,7 @@ namespace MatterHackers.MatterControl
};
toolbar.BorderColor = ApplicationController.Instance.Theme.SlightShade;
toolbar.Border = new BorderDouble(bottom: 2);
toolbar.ActionBar.AddChild(new BrandMenuButton(theme)
toolbar.ActionArea.AddChild(new BrandMenuButton(theme)
{
MinimumSize = new VectorMath.Vector2(0, 34),
HAnchor = HAnchor.Stretch,

View file

@ -85,6 +85,7 @@
<Compile Include="ApplicationView\WindowsPlatformsFeatures.cs" />
<Compile Include="PartPreviewWindow\LibraryBrowserPage.cs" />
<Compile Include="PartPreviewWindow\MoveItemPage.cs" />
<Compile Include="PartPreviewWindow\View3D\PrinterBar\OverflowBar.cs" />
<Compile Include="PartPreviewWindow\View3D\PrinterBar\PrintPopupMenu.cs" />
<Compile Include="PartPreviewWindow\View3D\PrinterBar\SliceButton.cs" />
<Compile Include="PartPreviewWindow\View3D\PrinterBar\PrinterConnectButton.cs" />

View file

@ -126,7 +126,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
});
});
tabControl.TabBar.ActionBar.AddChild(updateAvailableButton);
tabControl.TabBar.ActionArea.AddChild(updateAvailableButton);
UpdateControlData.Instance.UpdateStatusChanged.RegisterEvent((s, e) =>
{

View file

@ -70,6 +70,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
}
};
viewControls3D.OverflowMenu.DynamicPopupContent = this.GetViewControls3DOverflowMenu;
viewControls3D.OverflowMenu.BackgroundColor = theme.ResolveColor(theme.TabBodyBackground, theme.TabBodyBackground);
bool isPrinterType = this is PrinterTabPage;

View file

@ -144,6 +144,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
{
Padding = new BorderDouble(0, theme.ToolbarPadding.Top, theme.ToolbarPadding.Right, theme.ToolbarPadding.Top)
};
printerActionsBar.OverflowMenu.BackgroundColor = theme.ResolveColor(theme.TabBodyBackground, theme.TabBodyBackground);
// Must come after we have an instance of View3DWidget an its undo buffer
topToBottom.AddChild(printerActionsBar, 0);

View file

@ -40,21 +40,35 @@ using MatterHackers.VectorMath;
namespace MatterHackers.MatterControl.PartPreviewWindow
{
/// <summary>
/// A toolbar with an optional right anchored element and an ActionBar child to add actions to the bar
/// A toolbar with an optional right anchored element and an ActionBar child to add actions to the bar
/// </summary>
public class Toolbar : Bar
public class Toolbar : GuiWidget
{
public FlowLayoutWidget ActionBar { get; }
public FlowLayoutWidget ActionArea { get; }
public Toolbar(GuiWidget rightAnchorItem, ThemeConfig theme, bool bottomBorder = true)
: base(rightAnchorItem, theme)
{
this.ActionBar = new FlowLayoutWidget()
this.ActionArea = new FlowLayoutWidget()
{
HAnchor = HAnchor.Stretch
};
this.AddChild(this.ActionBar, 0);
base.AddChild(this.ActionArea, 0);
this.SetRightAnchorItem(rightAnchorItem);
}
protected void SetRightAnchorItem(GuiWidget rightAnchorItem)
{
if (rightAnchorItem != null)
{
rightAnchorItem.HAnchor |= HAnchor.Right;
base.AddChild(rightAnchorItem);
}
}
public override void AddChild(GuiWidget childToAdd, int indexInChildrenList = -1)
{
ActionArea.AddChild(childToAdd, indexInChildrenList);
}
}
@ -63,21 +77,6 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
GuiWidget TabContent { get; }
}
/// <summary>
/// A toolbar like item with an optional right anchored element
/// </summary>
public class Bar : GuiWidget
{
public Bar(GuiWidget rightAnchorItem, ThemeConfig theme)
{
if (rightAnchorItem != null)
{
rightAnchorItem.HAnchor |= HAnchor.Right;
this.AddChild(rightAnchorItem);
}
}
}
/// <summary>
/// A toolbar and associated tab body
/// </summary>
@ -117,7 +116,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
tabWidget.Click += TabWidget_Click;
this.TabBar.ActionBar.AddChild(tabWidget, position);
this.TabBar.ActionArea.AddChild(tabWidget, position);
this.body.AddChild(iTab.TabContent);
}
@ -131,7 +130,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
{
_allTabs.Remove(tab);
TabBar.ActionBar.RemoveChild(tab as GuiWidget);
TabBar.ActionArea.RemoveChild(tab as GuiWidget);
body.RemoveChild(tab.TabContent);
ActiveTab = _allTabs.LastOrDefault();
@ -183,7 +182,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
var firstItem = this.AllTabs.OfType<MainTab>().FirstOrDefault();
MainTab.DrawTabLowerRight(e.graphics2D, leadingTabAdornment.LocalBounds, (firstItem == this.ActiveTab) ? theme.ActiveTabColor : theme.InactiveTabColor);
};
this.TabBar.ActionBar.AddChild(leadingTabAdornment);
this.TabBar.ActionArea.AddChild(leadingTabAdornment);
// TODO: add in the printers and designs that are currently open (or were open last run).
plusTabButton = new NewTabButton(
@ -204,12 +203,12 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
});
};
this.TabBar.ActionBar.AddChild(plusTabButton);
this.TabBar.ActionArea.AddChild(plusTabButton);
}
public void AddTab(GuiWidget tab)
{
var position = this.TabBar.ActionBar.GetChildIndex(plusTabButton);
var position = this.TabBar.ActionArea.GetChildIndex(plusTabButton);
if (tab is MainTab mainTab)
{

View file

@ -0,0 +1,59 @@
/*
Copyright (c) 2017, Lars Brubaker, John Lewin
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
The views and conclusions contained in the software and documentation are those
of the authors and should not be interpreted as representing official policies,
either expressed or implied, of the FreeBSD Project.
*/
using MatterHackers.Agg.Platform;
namespace MatterHackers.MatterControl.PartPreviewWindow
{
public class OverflowBar : Toolbar
{
public OverflowBar(ThemeConfig theme)
: base(null, theme)
{
this.OverflowMenu = new OverflowMenu(IconColor.Theme)
{
AlignToRightEdge = true,
Margin = theme.ButtonSpacing
};
this.SetRightAnchorItem(this.OverflowMenu);
}
public OverflowMenu OverflowMenu { get; }
//// On parent changes walk back to the first ancestor with background colors and copy
//public override void OnParentChanged(EventArgs e)
//{
// var firstBackgroundColor = this.Parents<GuiWidget>().Where(p => p.BackgroundColor != Color.Transparent).FirstOrDefault()?.BackgroundColor;
// this.OverflowMenu.BackgroundColor = firstBackgroundColor ?? Color.Transparent;
// base.OnParentChanged(e);
//}
}
}

View file

@ -28,6 +28,7 @@ either expressed or implied, of the FreeBSD Project.
*/
using System;
using System.Linq;
using System.Threading.Tasks;
using MatterHackers.Agg;
using MatterHackers.Agg.Platform;
@ -42,7 +43,7 @@ using MatterHackers.MatterControl.SlicerConfiguration;
namespace MatterHackers.MatterControl.PartPreviewWindow
{
public class PrinterActionsBar : FlowLayoutWidget
public class PrinterActionsBar : OverflowBar
{
private PrinterConfig printer;
private EventHandler unregisterEvents;
@ -51,12 +52,11 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
private string noEepromMappingMessage = "Oops! There is no eeprom mapping for your printer's firmware.".Localize() + "\n\n" + "You may need to wait a minute for your printer to finish initializing.".Localize();
private string noEepromMappingTitle = "Warning - No EEProm Mapping".Localize();
private OverflowMenu overflowMenu;
private PrinterTabPage printerTabPage;
internal GuiWidget sliceButton;
public PrinterActionsBar(PrinterConfig printer, PrinterTabPage printerTabPage, ThemeConfig theme)
: base(theme)
{
this.printer = printer;
this.printerTabPage = printerTabPage;
@ -126,20 +126,13 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
this.AddChild(new TemperatureWidgetBed(printer));
}
overflowMenu = new OverflowMenu(IconColor.Theme)
{
AlignToRightEdge = true,
Name = "Printer Overflow Menu",
Margin = theme.ButtonSpacing
};
overflowMenu.DynamicPopupContent = GeneratePrinterOverflowMenu;
this.OverflowMenu.Name = "Printer Overflow Menu";
this.OverflowMenu.DynamicPopupContent = GeneratePrinterOverflowMenu;
ApplicationController.Instance.ActivePrinter.Connection.ConnectionSucceeded.RegisterEvent((s, e) =>
{
UiThread.RunOnIdle(PrintRecovery.CheckIfNeedToRecoverPrint);
}, ref unregisterEvents);
this.AddChild(overflowMenu);
}
public override void AddChild(GuiWidget childToAdd, int indexInChildrenList = -1)

View file

@ -66,14 +66,12 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
public ViewControls3DButtons TransformMode { get; set; }
}
public class ViewControls3D : FlowLayoutWidget
public class ViewControls3D : OverflowBar
{
public event EventHandler ResetView;
public event EventHandler<TransformStateChangedEventArgs> TransformStateChanged;
internal OverflowMenu OverflowMenu;
private GuiWidget partSelectSeparator;
private RadioIconButton translateButton;
@ -142,6 +140,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
}
public ViewControls3D(BedConfig sceneContext, ThemeConfig theme, UndoBuffer undoBuffer)
: base (theme)
{
this.printer = sceneContext.Printer;
@ -328,15 +327,6 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
this.AddChild(button);
}
this.AddChild(new HorizontalSpacer());
this.AddChild(this.OverflowMenu = new OverflowMenu()
{
Name = "View3D Overflow Menu",
AlignToRightEdge = true,
Margin = 3
});
if (printer != null)
{
printer.ViewState.ViewModeChanged += (s, e) =>