Revise styling of DesignSpaceHelp

This commit is contained in:
John Lewin 2018-04-24 13:32:48 -07:00
parent 0c301fd695
commit 4e715ab7ec

View file

@ -1,5 +1,5 @@
/*
Copyright (c) 2016, Lars Brubaker
Copyright (c) 2018, Lars Brubaker, John Lewin
All rights reserved.
Redistribution and use in source and binary forms, with or without
@ -29,60 +29,60 @@ either expressed or implied, of the FreeBSD Project.
using System;
using System.Collections.Generic;
using System.IO;
using MatterHackers.Agg;
using MatterHackers.Agg.Platform;
using MatterHackers.Agg.UI;
using MatterHackers.Localizations;
using MatterHackers.MatterControl.SlicerConfiguration;
using MatterHackers.MatterControl.PartPreviewWindow;
namespace MatterHackers.MatterControl
{
public class DesignSpaceHelp : DialogPage
{
FlowLayoutWidget mouseKeys;
FlowLayoutWidget keys;
FlowLayoutWidget mouseControls;
FlowLayoutWidget shortcutKeys;
public DesignSpaceHelp()
: base("Close".Localize())
{
this.WindowTitle = "Design Space Help".Localize();
this.HeaderText = "Navigation Controls and Shortcut Keys".Localize();
var scrollWindow = new ScrollableWidget()
{
AutoScroll = true,
HAnchor = HAnchor.Stretch,
VAnchor = VAnchor.Stretch,
};
scrollWindow.ScrollArea.HAnchor = HAnchor.Stretch;
contentRow.AddChild(scrollWindow);
this.ChildBorderColor = theme.GetBorderColor(75);
var container = new FlowLayoutWidget(FlowDirection.TopToBottom)
{
HAnchor = HAnchor.Stretch,
VAnchor = VAnchor.Stretch
};
scrollWindow.AddChild(container);
contentRow.AddChild(container);
var tabControl = new SimpleTabs(theme, new GuiWidget())
{
HAnchor = HAnchor.Stretch,
VAnchor = VAnchor.Stretch
};
tabControl.TabBar.BackgroundColor = theme.ActiveTabBarBackground;
container.AddChild(tabControl);
// add the mouse commands
mouseControls = new FlowLayoutWidget()
var mouseControls = new FlowLayoutWidget()
{
HAnchor = HAnchor.Fit | HAnchor.Left
HAnchor = HAnchor.Fit | HAnchor.Center,
Padding = theme.DefaultContainerPadding
};
container.AddChild(mouseControls);
mouseKeys = new FlowLayoutWidget(FlowDirection.TopToBottom);
var mouseTab = new ToolTab("Mouse".Localize(), tabControl, mouseControls, theme, hasClose: false);
tabControl.AddTab(mouseTab);
var mouseKeys = new FlowLayoutWidget(FlowDirection.TopToBottom);
mouseControls.AddChild(mouseKeys);
var mouseActions = new FlowLayoutWidget(FlowDirection.TopToBottom)
{
Border = new BorderDouble(3, 0, 0, 0),
BorderColor = Color.Black
Border = new BorderDouble(1, 0, 0, 0),
BorderColor = this.ChildBorderColor
};
mouseControls.AddChild(mouseActions);
List<(string key, string action)> mouseKeyActions = new List<(string key, string action)>(new(string, string)[]
var mouseKeyActions = new List<(string key, string action)>(new(string, string)[]
{
("ctrl left, right","Rotate".Localize()),
("ctrl shift left, middle","Pan".Localize()),
@ -98,27 +98,34 @@ namespace MatterHackers.MatterControl
AddContent(mouseActions, keyAction.action, false, false);
}
container.AddChild(new GuiWidget(10, 30));
// center the vertical bar in the view by adding margin to the small side
var left = Math.Max(0, mouseActions.Width - mouseKeys.Width);
var right = Math.Max(0, mouseKeys.Width - mouseActions.Width);
mouseControls.Margin = new BorderDouble(left, 0, right, 0);
// now add the keyboard commands
shortcutKeys = new FlowLayoutWidget()
var shortcutKeys = new FlowLayoutWidget()
{
HAnchor = HAnchor.Fit | HAnchor.Left
HAnchor = HAnchor.Fit | HAnchor.Center,
Padding = theme.DefaultContainerPadding
};
container.AddChild(shortcutKeys);
var keyboardTab = new ToolTab("Keys".Localize(), tabControl, shortcutKeys, theme, hasClose: false);
tabControl.AddTab(keyboardTab);
keys = new FlowLayoutWidget(FlowDirection.TopToBottom);
var keys = new FlowLayoutWidget(FlowDirection.TopToBottom);
shortcutKeys.AddChild(keys);
var action = new FlowLayoutWidget(FlowDirection.TopToBottom)
var actions = new FlowLayoutWidget(FlowDirection.TopToBottom)
{
Border = new BorderDouble(3, 0, 0, 0),
BorderColor = Color.Black
Border = new BorderDouble(1, 0, 0, 0),
BorderColor = this.ChildBorderColor
};
shortcutKeys.AddChild(action);
shortcutKeys.AddChild(actions);
List<(string key, string action)> keyActions = new List<(string key, string action)>(new(string, string)[]
tabControl.TabBar.Padding = theme.ToolbarPadding.Clone(left: 2, bottom: 0);
var keyActions = new List<(string key, string action)>(new(string, string)[]
{
("shift z","Zoom in".Localize()),
("z","Zoom out".Localize()),
@ -135,25 +142,47 @@ namespace MatterHackers.MatterControl
});
AddContent(keys, "Keys".Localize(), true, true);
AddContent(action, "Action".Localize(), false, true);
AddContent(actions, "Action".Localize(), false, true);
foreach (var keyAction in keyActions)
{
AddContent(keys, keyAction.key, true, false);
AddContent(action, keyAction.action, false, false);
AddContent(actions, keyAction.action, false, false);
}
// center the vertical bar in the view by adding margin to the small side
left = Math.Max(0, actions.Width - keys.Width);
right = Math.Max(0, keys.Width - actions.Width);
shortcutKeys.Margin = new BorderDouble(left, 0, right, 0);
var tipsContainer = new FlowLayoutWidget(FlowDirection.TopToBottom)
{
HAnchor = HAnchor.Stretch,
VAnchor = VAnchor.Stretch
};
tabControl.AddTab(new ToolTab("Tips".Localize(), tabControl, tipsContainer, theme, hasClose: false));
AddTips(tipsContainer);
var whatsNewContainer = new FlowLayoutWidget(FlowDirection.TopToBottom)
{
HAnchor = HAnchor.Stretch,
VAnchor = VAnchor.Stretch
};
tabControl.AddTab(new ToolTab("What's New".Localize(), tabControl, whatsNewContainer, theme, hasClose: false));
tabControl.SelectedTabIndex = 0;
}
public override void OnBoundsChanged(EventArgs e)
private void AddTips(FlowLayoutWidget tipsContainer)
{
// align the centers bars to the window center
var maxLeft = Math.Max(mouseKeys.Width, keys.Width);
mouseControls.Margin = new BorderDouble(Width / 2 - maxLeft / 2, 0, 0, 0);
shortcutKeys.Margin = new BorderDouble(Width / 2 - maxLeft / 2, 0, 0, 0);
base.OnBoundsChanged(e);
var sequence = AggContext.StaticData.LoadSequence(@"C:\Users\jlewin\Desktop\editwidget-never-closes.gif");
sequence.FramePerSecond = 3;
tipsContainer.AddChild(new ImageSequenceWidget(sequence));
}
public Color ChildBorderColor { get; private set; }
private void AddContent(GuiWidget column, string text, bool left, bool bold)
{
var container = new GuiWidget()
@ -161,7 +190,7 @@ namespace MatterHackers.MatterControl
HAnchor = HAnchor.Fit | (left ? HAnchor.Right: HAnchor.Left),
VAnchor = VAnchor.Fit
};
var content = new TextWidget(text, bold: bold)
var content = new TextWidget(text, bold: bold, textColor: theme.Colors.PrimaryTextColor, pointSize: theme.DefaultFontSize)
{
Margin = (left ? new BorderDouble(5, 3, 10, 3) : new BorderDouble(10, 3, 5, 3))
};
@ -172,7 +201,7 @@ namespace MatterHackers.MatterControl
{
HAnchor = HAnchor.Stretch,
Border = new BorderDouble(0, 1, 0, 0),
BorderColor = Color.Black,
BorderColor = this.ChildBorderColor,
});
}
}