Made the leveling page easier to use on touch

made the message box easier to use on touch
fixed spelling errors.
This commit is contained in:
Lars Brubaker 2015-10-19 15:59:42 -07:00
parent e540643db9
commit 02a5d6993d
10 changed files with 107 additions and 66 deletions

View file

@ -36,11 +36,17 @@ namespace MatterHackers.MatterControl
{
public class InstructionsPage : WizardPage
{
double extraTextScaling = 1;
protected FlowLayoutWidget topToBottomControls;
public InstructionsPage(string pageDescription, string instructionsText)
: base(pageDescription)
{
if (ActiveTheme.Instance.IsTouchScreen)
{
extraTextScaling = 1.33333;
}
topToBottomControls = new FlowLayoutWidget(FlowDirection.TopToBottom);
topToBottomControls.Padding = new BorderDouble(3);
topToBottomControls.HAnchor |= Agg.UI.HAnchor.ParentLeft;
@ -75,7 +81,7 @@ namespace MatterHackers.MatterControl
EnglishTextWrapping wrapper = new EnglishTextWrapping(12);
string wrappedInstructions = wrapper.InsertCRs(instructionsText, 400);
string wrappedInstructionsTabsToSpaces = wrappedInstructions.Replace("\t", " ");
TextWidget instructionsWidget = new TextWidget(wrappedInstructionsTabsToSpaces, textColor: ActiveTheme.Instance.PrimaryTextColor);
TextWidget instructionsWidget = new TextWidget(wrappedInstructionsTabsToSpaces, textColor: ActiveTheme.Instance.PrimaryTextColor, pointSize: 12 * extraTextScaling);
instructionsWidget.HAnchor = Agg.UI.HAnchor.ParentLeft;
topToBottomControls.AddChild(instructionsWidget);
}

View file

@ -283,7 +283,7 @@ namespace MatterHackers.MatterControl.ConfigurationPage.PrintLeveling
private FlowLayoutWidget CreateZButtons()
{
FlowLayoutWidget zButtons = JogControls.CreateZButtons(RGBA_Bytes.White, 4, out zPlusControl, out zMinusControl);
FlowLayoutWidget zButtons = JogControls.CreateZButtons(RGBA_Bytes.White, 4, out zPlusControl, out zMinusControl, true);
// set these to 0 so the button does not do any movements by default (we will handle the movement on our click callback)
zPlusControl.MoveAmount = 0;
zMinusControl.MoveAmount = 0;

View file

@ -2,6 +2,7 @@
using MatterHackers.Agg.Font;
using MatterHackers.Agg.UI;
using MatterHackers.Localizations;
using MatterHackers.MatterControl.CustomWidgets;
using System;
namespace MatterHackers.MatterControl
@ -16,6 +17,7 @@ namespace MatterHackers.MatterControl
private Action<bool> responseCallback;
public enum MessageType { OK, YES_NO };
double extraTextScaling = 1;
public static void ShowMessageBox(Action<bool> callback, String message, string caption, MessageType messageType = MessageType.OK, string yesOk = "", string no = "")
{
@ -31,22 +33,51 @@ namespace MatterHackers.MatterControl
public StyledMessageBox(Action<bool> callback, String message, string windowTitle, MessageType messageType, GuiWidget[] extraWidgetsToAdd, double width, double height, string yesOk, string no)
: base(width, height)
{
if (ActiveTheme.Instance.IsTouchScreen)
{
extraTextScaling = 1.33333;
}
textImageButtonFactory.fontSize = extraTextScaling * textImageButtonFactory.fontSize;
if (yesOk == "")
{
if (messageType == MessageType.OK)
{
yesOk = "Ok".Localize();
}
else
{
yesOk = "Yes".Localize();
}
}
if (no == "")
{
no = "No".Localize();
}
responseCallback = callback;
unwrappedMessage = message;
FlowLayoutWidget topToBottom = new FlowLayoutWidget(FlowDirection.TopToBottom);
topToBottom.AnchorAll();
topToBottom.Padding = new BorderDouble(3, 0, 3, 5);
if (ActiveTheme.Instance.IsTouchScreen)
{
topToBottom.Padding = new BorderDouble(12, 12, 13, 8);
}
else
{
topToBottom.Padding = new BorderDouble(3, 0, 3, 5) * TextWidget.GlobalPointSizeScaleRatio;
}
// Creates Header
FlowLayoutWidget headerRow = new FlowLayoutWidget(FlowDirection.LeftToRight);
headerRow.HAnchor = HAnchor.ParentLeftRight;
headerRow.Margin = new BorderDouble(0, 3, 0, 0);
headerRow.Padding = new BorderDouble(0, 3, 0, 3);
headerRow.Margin = new BorderDouble(0, 3, 0, 0) * TextWidget.GlobalPointSizeScaleRatio;
headerRow.Padding = new BorderDouble(0, 3, 0, 3) * TextWidget.GlobalPointSizeScaleRatio;
BackgroundColor = ActiveTheme.Instance.PrimaryBackgroundColor;
//Creates Text and adds into header
{
TextWidget elementHeader = new TextWidget(windowTitle, pointSize: 14);
TextWidget elementHeader = new TextWidget(windowTitle, pointSize: 14 * extraTextScaling);
elementHeader.TextColor = ActiveTheme.Instance.PrimaryTextColor;
elementHeader.HAnchor = HAnchor.ParentLeftRight;
elementHeader.VAnchor = Agg.UI.VAnchor.ParentBottom;
@ -61,11 +92,11 @@ namespace MatterHackers.MatterControl
middleRowContainer.HAnchor = HAnchor.ParentLeftRight;
middleRowContainer.VAnchor = VAnchor.ParentBottomTop;
// normally the padding for the middle container should be just (5) all around. The has extra top space
middleRowContainer.Padding = new BorderDouble(5, 5, 5, 15);
middleRowContainer.Padding = new BorderDouble(5, 5, 5, 15) * TextWidget.GlobalPointSizeScaleRatio;
middleRowContainer.BackgroundColor = ActiveTheme.Instance.SecondaryBackgroundColor;
}
messageContainer = new TextWidget(message, textColor: ActiveTheme.Instance.PrimaryTextColor);
messageContainer = new TextWidget(message, textColor: ActiveTheme.Instance.PrimaryTextColor, pointSize: 12 * extraTextScaling);
messageContainer.AutoExpandBoundsToText = true;
messageContainer.HAnchor = Agg.UI.HAnchor.ParentLeft;
middleRowContainer.AddChild(messageContainer);
@ -85,10 +116,9 @@ namespace MatterHackers.MatterControl
{
BackgroundColor = ActiveTheme.Instance.PrimaryBackgroundColor;
buttonRow.HAnchor = HAnchor.ParentLeftRight;
buttonRow.Padding = new BorderDouble(0, 3);
buttonRow.Padding = new BorderDouble(0, 3) * TextWidget.GlobalPointSizeScaleRatio;
}
int minButtonWidth = (int)(50 * TextWidget.GlobalPointSizeScaleRatio + .5);
switch (messageType)
{
@ -96,29 +126,13 @@ namespace MatterHackers.MatterControl
{
Title = "MatterControl - " + "Please Confirm".Localize();
Button yesButton = textImageButtonFactory.Generate(yesOk, centerText: true);
if (yesOk == "")
{
yesOk = "Yes".Localize();
textImageButtonFactory.FixedWidth = minButtonWidth;
yesButton = textImageButtonFactory.Generate(yesOk, centerText: true);
textImageButtonFactory.FixedWidth = 0;
}
yesButton.Width = Math.Max(minButtonWidth, yesButton.Width);
yesButton.Click += new EventHandler(okButton_Click);
yesButton.Cursor = Cursors.Hand;
buttonRow.AddChild(yesButton);
//buttonRow.AddChild(new HorizontalSpacer());
buttonRow.AddChild(new HorizontalSpacer());
Button noButton = textImageButtonFactory.Generate(no, centerText: true);
if (no == "")
{
no = "No".Localize();
textImageButtonFactory.FixedWidth = minButtonWidth;
noButton = textImageButtonFactory.Generate(no, centerText: true);
textImageButtonFactory.FixedWidth = 0;
}
noButton.Width = Math.Max(minButtonWidth, noButton.Width);
noButton.Click += new EventHandler(noButton_Click);
noButton.Cursor = Cursors.Hand;
buttonRow.AddChild(noButton);
@ -129,14 +143,6 @@ namespace MatterHackers.MatterControl
{
Title = "MatterControl - " + "Alert".Localize();
Button okButton = textImageButtonFactory.Generate(LocalizedString.Get("Ok"), centerText: true);
if (yesOk == "")
{
yesOk = "Ok".Localize();
textImageButtonFactory.FixedWidth = minButtonWidth;
okButton = textImageButtonFactory.Generate(yesOk, centerText: true);
textImageButtonFactory.FixedWidth = 0;
}
okButton.Width = Math.Max(minButtonWidth, okButton.Width);
okButton.Cursor = Cursors.Hand;
okButton.Click += new EventHandler(okButton_Click);
buttonRow.AddChild(okButton);
@ -167,7 +173,7 @@ namespace MatterHackers.MatterControl
double wrappingSize = middleRowContainer.Width - (middleRowContainer.Padding.Width + messageContainer.Margin.Width);
if (wrappingSize > 0)
{
EnglishTextWrapping wrapper = new EnglishTextWrapping(12);
EnglishTextWrapping wrapper = new EnglishTextWrapping(12 * extraTextScaling * TextWidget.GlobalPointSizeScaleRatio);
string wrappedMessage = wrapper.InsertCRs(unwrappedMessage, wrappingSize);
messageContainer.Text = wrappedMessage;
}

View file

@ -46,7 +46,7 @@ namespace MatterHackers.MatterControl
protected double borderWidth = 1;
protected double borderRadius = 0;
public TextImageWidget(string label, RGBA_Bytes fillColor, RGBA_Bytes borderColor, RGBA_Bytes textColor, double borderWidth, BorderDouble margin, ImageBuffer image = null, int fontSize = 12, FlowDirection flowDirection = FlowDirection.LeftToRight, double height = 40, double width = 0, bool centerText = false, double imageSpacing = 0)
public TextImageWidget(string label, RGBA_Bytes fillColor, RGBA_Bytes borderColor, RGBA_Bytes textColor, double borderWidth, BorderDouble margin, ImageBuffer image = null, double fontSize = 12, FlowDirection flowDirection = FlowDirection.LeftToRight, double height = 40, double width = 0, bool centerText = false, double imageSpacing = 0)
: base()
{
this.image = image;
@ -155,7 +155,7 @@ namespace MatterHackers.MatterControl
public RGBA_Bytes hoverTextColor = ActiveTheme.Instance.PrimaryTextColor;
public RGBA_Bytes pressedTextColor = ActiveTheme.Instance.PrimaryTextColor;
public RGBA_Bytes disabledTextColor = ActiveTheme.Instance.PrimaryTextColor;
public int fontSize = 12;
public double fontSize = 12;
public double borderWidth = 1;
public bool invertImageLocation = false;
public bool AllowThemeToAdjustImage = true;

View file

@ -382,7 +382,7 @@ namespace MatterHackers.RayTracer
AxisAlignedBoundingBox meshBounds = GetAxisAlignedBoundingBox(loadedMeshGroups);
bool done = false;
double scallFraction = .1;
double scaleFraction = .1;
RectangleDouble goalBounds = new RectangleDouble(0, 0, size.x, size.y);
goalBounds.Inflate(-10);
while (!done)
@ -391,25 +391,25 @@ namespace MatterHackers.RayTracer
if (!NeedsToBeSmaller(partScreenBounds, goalBounds))
{
trackballTumbleWidget.TrackBallController.Scale *= (1 + scallFraction);
trackballTumbleWidget.TrackBallController.Scale *= (1 + scaleFraction);
partScreenBounds = GetScreenBounds(meshBounds);
// If it crossed over the goal reduct the amount we are adjusting by.
if (NeedsToBeSmaller(partScreenBounds, goalBounds))
{
scallFraction /= 2;
scaleFraction /= 2;
}
}
else
{
trackballTumbleWidget.TrackBallController.Scale *= (1 - scallFraction);
trackballTumbleWidget.TrackBallController.Scale *= (1 - scaleFraction);
partScreenBounds = GetScreenBounds(meshBounds);
// If it crossed over the goal reduct the amount we are adjusting by.
if (!NeedsToBeSmaller(partScreenBounds, goalBounds))
{
scallFraction /= 2;
if (scallFraction < .001)
scaleFraction /= 2;
if (scaleFraction < .001)
{
done = true;
}

View file

@ -29,6 +29,7 @@ namespace MatterHackers.MatterControl
public class WizardControl : GuiWidget
{
double extraTextScaling = 1;
protected TextImageButtonFactory textImageButtonFactory = new TextImageButtonFactory();
private FlowLayoutWidget bottomToTopLayout;
@ -49,9 +50,23 @@ namespace MatterHackers.MatterControl
public WizardControl()
{
if (ActiveTheme.Instance.IsTouchScreen)
{
extraTextScaling = 1.33333;
}
textImageButtonFactory.fontSize = extraTextScaling * textImageButtonFactory.fontSize;
FlowLayoutWidget topToBottom = new FlowLayoutWidget(FlowDirection.TopToBottom);
topToBottom.AnchorAll();
topToBottom.Padding = new BorderDouble(3, 0, 3, 5);
if (ActiveTheme.Instance.IsTouchScreen)
{
topToBottom.Padding = new BorderDouble(12);
}
else
{
topToBottom.Padding = new BorderDouble(3, 0, 3, 5);
}
FlowLayoutWidget headerRow = new FlowLayoutWidget(FlowDirection.LeftToRight);
headerRow.HAnchor = HAnchor.ParentLeftRight;
@ -60,7 +75,7 @@ namespace MatterHackers.MatterControl
{
string titleString = LocalizedString.Get("Title Stuff".Localize());
stepDescriptionWidget = new TextWidget(titleString, pointSize: 14);
stepDescriptionWidget = new TextWidget(titleString, pointSize: 14 * extraTextScaling);
stepDescriptionWidget.AutoExpandBoundsToText = true;
stepDescriptionWidget.TextColor = ActiveTheme.Instance.PrimaryTextColor;
stepDescriptionWidget.HAnchor = HAnchor.ParentLeftRight;
@ -91,7 +106,6 @@ namespace MatterHackers.MatterControl
buttonBar.HAnchor = Agg.UI.HAnchor.ParentLeftRight;
buttonBar.Padding = new BorderDouble(0, 3);
textImageButtonFactory.FixedWidth = 60 * TextWidget.GlobalPointSizeScaleRatio;
backButton = textImageButtonFactory.Generate(LocalizedString.Get("Back"), centerText: true);
backButton.Click += new EventHandler(back_Click);

View file

@ -572,6 +572,12 @@ namespace MatterHackers.MatterControl
{
AfterFirstDraw();
}
UiThread.RunOnIdle(() =>
{
StyledMessageBox.ShowMessageBox(null, "message that is long and wraps. message that is long and wraps. message that is long and wraps." , "caption", StyledMessageBox.MessageType.YES_NO);
// show a dialog to tell the user there is an update
});
}
//msGraph.AddData("ms", totalDrawTime.ElapsedMilliseconds);

View file

@ -139,7 +139,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
private Vector2 gridSizeMm;
private Vector2 gridCenterMm;
private Affine ScallingTransform
private Affine ScalingTransform
{
get
{
@ -155,7 +155,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
transform *= Affine.NewTranslation(unscaledRenderOffset);
// scale to view
transform *= ScallingTransform;
transform *= ScalingTransform;
transform *= Affine.NewTranslation(Width / 2, Height / 2);
return transform;
@ -449,7 +449,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
switch (TransformState)
{
case ETransformState.Move:
ScallingTransform.inverse_transform(ref mouseDelta);
ScalingTransform.inverse_transform(ref mouseDelta);
unscaledRenderOffset += mouseDelta;
break;

View file

@ -483,13 +483,13 @@ namespace MatterHackers.MatterControl
}
public static FlowLayoutWidget CreateZButtons(RGBA_Bytes color, double buttonSeparationDistance,
out MoveButton zPlusControl, out MoveButton zMinusControl)
out MoveButton zPlusControl, out MoveButton zMinusControl, bool levelingButtons = false)
{
FlowLayoutWidget zButtons = new FlowLayoutWidget(FlowDirection.TopToBottom);
{
MoveButtonFactory moveButtonFactory = new MoveButtonFactory();
moveButtonFactory.normalFillColor = color;
zPlusControl = moveButtonFactory.Generate("Z+", PrinterConnectionAndCommunication.Axis.Z, MovementControls.ZSpeed);
zPlusControl = moveButtonFactory.Generate("Z+", PrinterConnectionAndCommunication.Axis.Z, MovementControls.ZSpeed, levelingButtons);
zPlusControl.ToolTipText = "Move Z positive";
zButtons.AddChild(zPlusControl);
@ -498,7 +498,7 @@ namespace MatterHackers.MatterControl
spacer.BackgroundColor = XYZColors.zColor;
zButtons.AddChild(spacer);
zMinusControl = moveButtonFactory.Generate("Z-", PrinterConnectionAndCommunication.Axis.Z, MovementControls.ZSpeed);
zMinusControl = moveButtonFactory.Generate("Z-", PrinterConnectionAndCommunication.Axis.Z, MovementControls.ZSpeed, levelingButtons);
zMinusControl.ToolTipText = "Move Z negative";
zButtons.AddChild(zMinusControl);
}
@ -616,7 +616,7 @@ namespace MatterHackers.MatterControl
protected double borderWidth = 0;
protected double borderRadius = 0;
public MoveButtonWidget(string label, RGBA_Bytes fillColor, RGBA_Bytes textColor)
public MoveButtonWidget(string label, RGBA_Bytes fillColor, RGBA_Bytes textColor, bool levelingButtons)
: base()
{
this.BackgroundColor = fillColor;
@ -632,8 +632,17 @@ namespace MatterHackers.MatterControl
textWidget.Padding = new BorderDouble(3, 0);
this.AddChild(textWidget);
}
this.Height = 40 * TextWidget.GlobalPointSizeScaleRatio;
this.Width = 40 * TextWidget.GlobalPointSizeScaleRatio;
if (levelingButtons)
{
this.Height = 45 * TextWidget.GlobalPointSizeScaleRatio;
this.Width = 90 * TextWidget.GlobalPointSizeScaleRatio;
}
else
{
this.Height = 40 * TextWidget.GlobalPointSizeScaleRatio;
this.Width = 40 * TextWidget.GlobalPointSizeScaleRatio;
}
}
public override void OnDraw(Graphics2D graphics2D)
@ -662,34 +671,34 @@ namespace MatterHackers.MatterControl
public RGBA_Bytes pressedTextColor = RGBA_Bytes.White;
public RGBA_Bytes disabledTextColor = RGBA_Bytes.White;
public MoveButton Generate(string label, PrinterConnectionAndCommunication.Axis axis, double movementFeedRate)
public MoveButton Generate(string label, PrinterConnectionAndCommunication.Axis axis, double movementFeedRate, bool levelingButtons = false)
{
//Create button based on view container widget
ButtonViewStates buttonViewWidget = GetButtonView(label);
ButtonViewStates buttonViewWidget = GetButtonView(label, levelingButtons);
MoveButton textImageButton = new MoveButton(0, 0, buttonViewWidget, axis, movementFeedRate);
textImageButton.Margin = new BorderDouble(0);
textImageButton.Padding = new BorderDouble(0);
return textImageButton;
}
public ExtrudeButton Generate(string label, double movementFeedRate, int extruderNumber = 0)
public ExtrudeButton Generate(string label, double movementFeedRate, int extruderNumber = 0, bool levelingButtons = false)
{
//Create button based on view container widget
ButtonViewStates buttonViewWidget = GetButtonView(label);
ButtonViewStates buttonViewWidget = GetButtonView(label, levelingButtons);
ExtrudeButton textImageButton = new ExtrudeButton(0, 0, buttonViewWidget, movementFeedRate, extruderNumber);
textImageButton.Margin = new BorderDouble(0);
textImageButton.Padding = new BorderDouble(0);
return textImageButton;
}
private ButtonViewStates GetButtonView(string label)
private ButtonViewStates GetButtonView(string label, bool levelingButtons)
{
//Create the multi-state button view
ButtonViewStates buttonViewWidget = new ButtonViewStates(
new MoveButtonWidget(label, normalFillColor, normalTextColor),
new MoveButtonWidget(label, hoverFillColor, hoverTextColor),
new MoveButtonWidget(label, pressedFillColor, pressedTextColor),
new MoveButtonWidget(label, disabledFillColor, disabledTextColor)
new MoveButtonWidget(label, normalFillColor, normalTextColor, levelingButtons),
new MoveButtonWidget(label, hoverFillColor, hoverTextColor, levelingButtons),
new MoveButtonWidget(label, pressedFillColor, pressedTextColor, levelingButtons),
new MoveButtonWidget(label, disabledFillColor, disabledTextColor, levelingButtons)
);
return buttonViewWidget;
}

@ -1 +1 @@
Subproject commit 6a2767d83dd5db2cde8f8487eb4dfa94b7eac800
Subproject commit ce1a00747c1a1d77636f1b7be9eb3d237502ca9b