Merge pull request #2161 from jlewin/design_tools

Design tools
This commit is contained in:
johnlewin 2017-06-12 21:04:12 -07:00 committed by GitHub
commit c199aea16c
7 changed files with 59 additions and 26 deletions

View file

@ -771,6 +771,8 @@ namespace MatterHackers.MatterControl
public View3DWidget ActiveView3DWidget { get; internal set; }
public int ActiveAdvancedControlsTab { get; internal set; }
public bool PrintSettingsPinned { get; internal set; }
public string CachePath(ILibraryItem libraryItem)
{
// TODO: Use content SHA

View file

@ -63,7 +63,7 @@ namespace MatterHackers.MatterControl
var library3DViewSplitter = new Splitter()
{
Padding = new BorderDouble(4),
SplitterDistance = 590,
SplitterDistance = 410,
SplitterWidth = 10,
SplitterBackground = ApplicationController.Instance.Theme.SplitterBackground
};

View file

@ -27,6 +27,7 @@ of the authors and should not be interpreted as representing official policies,
either expressed or implied, of the FreeBSD Project.
*/
using System;
using System.Collections.Generic;
using MatterHackers.Agg;
using MatterHackers.Agg.Font;
@ -42,16 +43,25 @@ namespace MatterHackers.MatterControl.CustomWidgets
{
public class DockingTabControl : GuiWidget
{
public bool ControlIsPinned { get; set; } = true;
public event EventHandler PinStatusChanged;
// TODO: Pinned state should preferably come from MCWS, default to local data if guest and be per user not printer
private bool isPinned;
public bool ControlIsPinned
{
get => isPinned;
set {
isPinned = value;
PinStatusChanged?.Invoke(this, null);
}
}
private GuiWidget topToBottom;
Dictionary<string, GuiWidget> allTabs = new Dictionary<string, GuiWidget>();
public DockingTabControl()
{
// load up the state data for this control and printer
// ActiveSliceSettings.Instance.PrinterSelected
ControlIsPinned = true;
}
public void AddPage(string name, GuiWidget widget)
@ -89,15 +99,17 @@ namespace MatterHackers.MatterControl.CustomWidgets
foreach (var nameWidget in allTabs)
{
string tabTitle = nameWidget.Key;
if (ControlIsPinned)
{
var content = new DockWindowContent(this, nameWidget.Value, nameWidget.Key, ControlIsPinned);
var content = new DockWindowContent(this, nameWidget.Value, tabTitle, ControlIsPinned);
var tabPage = new TabPage(content, nameWidget.Key);
var tabPage = new TabPage(content, tabTitle);
tabControl.AddTab(new SimpleTextTabWidget(
tabPage,
nameWidget.Key + " Tab",
tabTitle + " Tab",
12,
ActiveTheme.Instance.TabLabelSelected,
RGBA_Bytes.Transparent,
@ -107,7 +119,7 @@ namespace MatterHackers.MatterControl.CustomWidgets
else // control is floating
{
var rotatedLabel = new VertexSourceApplyTransform(
new TypeFacePrinter(nameWidget.Key, 12),
new TypeFacePrinter(tabTitle, 12),
Affine.NewRotation(MathHelper.DegreesToRadians(-90)));
var bounds = rotatedLabel.Bounds();
@ -125,8 +137,9 @@ namespace MatterHackers.MatterControl.CustomWidgets
var settingsButton = new PopupButton(optionsText)
{
AlignToRightEdge = true,
Name = $"{tabTitle} Sidebar"
};
settingsButton.PopupContent = new DockWindowContent(this, nameWidget.Value, nameWidget.Key, ControlIsPinned)
settingsButton.PopupContent = new DockWindowContent(this, nameWidget.Value, tabTitle, ControlIsPinned)
{
BackgroundColor = ActiveTheme.Instance.PrimaryBackgroundColor
};
@ -144,7 +157,6 @@ namespace MatterHackers.MatterControl.CustomWidgets
VAnchor = VAnchor.ParentCenter
};
imageWidget.Margin = new BorderDouble(right: 25, top: 6);
imageWidget.DebugShowBounds = true;
imageWidget.MinimumSize = new Vector2(16, 16);
imageWidget.Click += (s, e) =>
{
@ -248,9 +260,12 @@ namespace MatterHackers.MatterControl.CustomWidgets
titleBar.AddChild(new HorizontalSpacer() { Height = 5, DebugShowBounds = false });
var icon = StaticData.Instance.LoadIcon((isDocked) ? "Pushpin_16x.png" : "PushpinUnpin_16x.png", 16, 16).InvertLightness();
var imageWidget = new ImageWidget(icon);
imageWidget.Margin = new BorderDouble(right: 25, top: 6);
imageWidget.MinimumSize = new Vector2(16, 16);
var imageWidget = new ImageWidget(icon)
{
Name = "Pin Settings Button",
Margin = new BorderDouble(right: 25, top: 6),
MinimumSize = new Vector2(16, 16)
};
imageWidget.Click += (s, e) =>
{
parent.ControlIsPinned = !parent.ControlIsPinned;

View file

@ -91,14 +91,12 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
};
}
public override void ShowPopup()
protected override void BeforeShowPopup()
{
if (this.PopupContent.BackgroundColor == RGBA_Bytes.Transparent)
{
this.PopupContent.BackgroundColor = RGBA_Bytes.Blue;
this.PopupContent.BackgroundColor = RGBA_Bytes.White;
}
base.ShowPopup();
}
}
@ -149,7 +147,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
base.OnMouseUp(mouseEvent);
}
public virtual void ShowPopup()
public void ShowPopup()
{
menuVisible = true;
@ -165,6 +163,8 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
return;
}
this.BeforeShowPopup();
popupWidget = new PopupWidget(this.PopupContent, this, Vector2.Zero, this.PopDirection, 0, this.AlignToRightEdge)
{
BorderWidth = 1,
@ -178,5 +178,9 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
};
popupWidget.Focus();
}
protected virtual void BeforeShowPopup()
{
}
}
}

View file

@ -208,17 +208,25 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
private void AddSettingsTabBar(GuiWidget parent)
{
var sideBar = new DockingTabControl();
var sideBar = new DockingTabControl()
{
ControlIsPinned = ApplicationController.Instance.PrintSettingsPinned
};
sideBar.PinStatusChanged += (s, e) =>
{
ApplicationController.Instance.PrintSettingsPinned = sideBar.ControlIsPinned;
};
parent.AddChild(sideBar);
if (ActiveSliceSettings.Instance.PrinterSelected)
{
sideBar.AddPage("Settings", new SliceSettingsWidget());
sideBar.AddPage("Slice Settings".Localize(), new SliceSettingsWidget());
}
else
{
sideBar.AddPage("Settings".Localize(), new SliceSettingsWidget());
sideBar.AddPage("Slice Settings".Localize(), new NoSettingsWidget());
}
sideBar.AddPage("Controls".Localize(), new ManualPrinterControls());
var terminalControls = new TerminalControls();

View file

@ -355,8 +355,6 @@ namespace MatterHackers.MatterControl.Tests.Automation
await MatterControlUtilities.RunTest((testRunner) =>
{
SystemWindow systemWindow;
testRunner.WaitForName("Cancel Wizard Button", 1);
// Set custom adjustment values
@ -377,7 +375,7 @@ namespace MatterHackers.MatterControl.Tests.Automation
testRunner.ClickByName("Start Print Button", 1);
var container = testRunner.GetWidgetByName("ManualPrinterControls.ControlsContainer", out systemWindow, 5);
var container = testRunner.GetWidgetByName("ManualPrinterControls.ControlsContainer", out _, 5);
// Scroll the widget into view
var scrollable = container.Parents<ManualPrinterControls>().First().Children<ScrollableWidget>().First();

View file

@ -548,8 +548,14 @@ namespace MatterHackers.MatterControl.Tests.Automation
public static void SwitchToAdvancedSliceSettings(this AutomationRunner testRunner)
{
testRunner.ClickByName("Slice Settings Sidebar");
testRunner.ClickByName("Pin Settings Button");
testRunner.Delay(1);
// Switch to Slice Settings Tab
testRunner.ClickByName("Slice Settings Tab");
//testRunner.ClickByName("Slice Settings Tab");
// Show the overflow menu
testRunner.ClickByName("Slice Settings Overflow Menu");