Merge branch 'design_tools' into design_tools

This commit is contained in:
johnlewin 2017-12-29 13:11:54 -08:00 committed by GitHub
commit 8d85137b96
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 37 additions and 21 deletions

View file

@ -35,16 +35,23 @@ namespace MatterHackers.MatterControl
}
public EditableNumberDisplay(double startingValue, string largestPossibleValue)
: base(Agg.UI.FlowDirection.LeftToRight)
: this(startingValue, largestPossibleValue, ActiveTheme.Instance.PrimaryTextColor)
{
}
public EditableNumberDisplay(double startingValue, string largestPossibleValue, Color textColor)
: base(FlowDirection.LeftToRight)
{
this.Margin = new BorderDouble(3, 0);
this.VAnchor = VAnchor.Center;
clickableValueContainer = new ClickWidget();
clickableValueContainer.VAnchor = VAnchor.Stretch;
clickableValueContainer.Cursor = Cursors.Hand;
clickableValueContainer.BorderWidth = 1;
clickableValueContainer.BorderColor = BorderColor;
clickableValueContainer = new ClickWidget
{
VAnchor = VAnchor.Stretch,
Cursor = Cursors.Hand,
BorderWidth = 1,
BorderColor = BorderColor
};
clickableValueContainer.MouseEnterBounds += (sender, e) =>
{
@ -60,7 +67,7 @@ namespace MatterHackers.MatterControl
valueDisplay = new TextWidget(largestPossibleValue, pointSize: 12)
{
TextColor = ActiveTheme.Instance.PrimaryTextColor,
TextColor = textColor,
VAnchor = VAnchor.Center,
HAnchor = HAnchor.Left,
Margin = new BorderDouble(6),
@ -71,10 +78,12 @@ namespace MatterHackers.MatterControl
clickableValueContainer.AddChild(valueDisplay);
clickableValueContainer.SetBoundsToEncloseChildren();
numberInputField = new MHNumberEdit(0, pixelWidth: 40, allowDecimals: true);
numberInputField.VAnchor = VAnchor.Center;
numberInputField.Margin = new BorderDouble(left: 6);
numberInputField.Visible = false;
numberInputField = new MHNumberEdit(0, pixelWidth: 40, allowDecimals: true)
{
VAnchor = VAnchor.Center,
Margin = new BorderDouble(left: 6),
Visible = false
};
// This is a hack to make sure the control is tall enough.
// TODO: This hack needs a unit test and then pass and then remove this line.

View file

@ -42,11 +42,13 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
internal CheckBox usePercents;
internal Vector3 scaleRatios = Vector3.One;
private InteractiveScene scene;
private Color textColor;
public ScaleControls(InteractiveScene scene)
public ScaleControls(InteractiveScene scene, Color textColor)
: base (FlowDirection.TopToBottom)
{
this.scene = scene;
this.textColor = textColor;
var theme = ApplicationController.Instance.Theme;
@ -57,8 +59,8 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
// Put in the scale ratio edit field
this.AddChild(new ScaleOptionsPanel(this));
// Going to use this in the scaling controls, creat it early.
usePercents = new CheckBox("Use Percents".Localize(), textColor: ActiveTheme.Instance.PrimaryTextColor);
// Going to use this in the scaling controls, create it early.
usePercents = new CheckBox("Use Percents".Localize(), textColor: textColor);
// add in the dimensions
this.AddChild(CreateAxisScalingControl("x".ToUpper(), 0));
@ -66,7 +68,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
this.AddChild(CreateAxisScalingControl("z".ToUpper(), 2));
// lock ratio checkbox
uniformScale = new CheckBox("Lock Ratio".Localize(), textColor: ActiveTheme.Instance.PrimaryTextColor);
uniformScale = new CheckBox("Lock Ratio".Localize(), textColor: textColor);
uniformScale.Margin = new BorderDouble(5, 3);
uniformScale.Checked = true;
uniformScale.CheckedStateChanged += (s, e) =>
@ -89,8 +91,13 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
this.AddChild(usePercents);
// put in the apply button
Button applyScaleButton = theme.ButtonFactory.Generate("Apply Scale".Localize());
applyScaleButton.Cursor = Cursors.Hand;
var applyScaleButton = new TextButton("Apply Scale".Localize(), theme, Color.Black)
{
VAnchor = VAnchor.Absolute,
HAnchor = HAnchor.Right,
BackgroundColor = theme.SlightShade,
Cursor = Cursors.Hand
};
this.AddChild(applyScaleButton);
scaleControls.Add(applyScaleButton);
@ -119,13 +126,13 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
FlowLayoutWidget leftToRight = new FlowLayoutWidget();
leftToRight.Padding = new BorderDouble(5, 3);
TextWidget sizeDescription = new TextWidget("{0}:".FormatWith(axis), textColor: ActiveTheme.Instance.PrimaryTextColor)
TextWidget sizeDescription = new TextWidget("{0}:".FormatWith(axis), textColor: textColor)
{
VAnchor = VAnchor.Center
};
leftToRight.AddChild(sizeDescription);
sizeDisplay[axisIndex] = new EditableNumberDisplay(100, "1000.00");
sizeDisplay[axisIndex] = new EditableNumberDisplay(100, "1000.00", textColor);
sizeDisplay[axisIndex].DisplayFormat = "{0:0.00}";
sizeDisplay[axisIndex].ValueChanged += (sender, e) =>
{
@ -144,7 +151,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
leftToRight.AddChild(sizeDisplay[axisIndex]);
TextWidget units = new TextWidget("mm".FormatWith(axis), textColor: ActiveTheme.Instance.PrimaryTextColor)
TextWidget units = new TextWidget("mm".FormatWith(axis), textColor: textColor)
{
VAnchor = VAnchor.Center
};

View file

@ -312,7 +312,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
{
Name = "Scale Button",
PopDirection = Direction.Up,
DynamicPopupContent = () => new ScaleControls(Scene),
DynamicPopupContent = () => new ScaleControls(Scene, Color.Black),
AlignToRightEdge = true,
Margin = buttonSpacing,
};