diff --git a/ConfigurationPage/PrintLeveling/InstructionsPage.cs b/ConfigurationPage/PrintLeveling/InstructionsPage.cs index d5962a6b1..8fba44aea 100644 --- a/ConfigurationPage/PrintLeveling/InstructionsPage.cs +++ b/ConfigurationPage/PrintLeveling/InstructionsPage.cs @@ -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); } diff --git a/ConfigurationPage/PrintLeveling/PrintLevelPages.cs b/ConfigurationPage/PrintLeveling/PrintLevelPages.cs index cdbcc338b..e1bb812b8 100644 --- a/ConfigurationPage/PrintLeveling/PrintLevelPages.cs +++ b/ConfigurationPage/PrintLeveling/PrintLevelPages.cs @@ -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; diff --git a/ControlElements/StyledMessageBoxWindow.cs b/ControlElements/StyledMessageBoxWindow.cs index 4375ed927..969e36ce4 100644 --- a/ControlElements/StyledMessageBoxWindow.cs +++ b/ControlElements/StyledMessageBoxWindow.cs @@ -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 responseCallback; public enum MessageType { OK, YES_NO }; + double extraTextScaling = 1; public static void ShowMessageBox(Action callback, String message, string caption, MessageType messageType = MessageType.OK, string yesOk = "", string no = "") { @@ -31,22 +33,51 @@ namespace MatterHackers.MatterControl public StyledMessageBox(Action 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; } diff --git a/ControlElements/TextImageButtonFactory.cs b/ControlElements/TextImageButtonFactory.cs index adb69b9ac..bd4daea42 100644 --- a/ControlElements/TextImageButtonFactory.cs +++ b/ControlElements/TextImageButtonFactory.cs @@ -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; diff --git a/CustomWidgets/ThumbnailTracer.cs b/CustomWidgets/ThumbnailTracer.cs index 251255a4e..0b147f2c1 100644 --- a/CustomWidgets/ThumbnailTracer.cs +++ b/CustomWidgets/ThumbnailTracer.cs @@ -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; } diff --git a/CustomWidgets/WizardControl.cs b/CustomWidgets/WizardControl.cs index 2ce89ccab..5f045b9de 100644 --- a/CustomWidgets/WizardControl.cs +++ b/CustomWidgets/WizardControl.cs @@ -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); diff --git a/MatterControlApplication.cs b/MatterControlApplication.cs index 5766c59d8..51d2703ec 100644 --- a/MatterControlApplication.cs +++ b/MatterControlApplication.cs @@ -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); diff --git a/PartPreviewWindow/ViewGcodeWidget.cs b/PartPreviewWindow/ViewGcodeWidget.cs index eff878f7b..9865c9a47 100644 --- a/PartPreviewWindow/ViewGcodeWidget.cs +++ b/PartPreviewWindow/ViewGcodeWidget.cs @@ -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; diff --git a/PrinterControls/XYZJogControls.cs b/PrinterControls/XYZJogControls.cs index e6f2e78c8..304e452ed 100644 --- a/PrinterControls/XYZJogControls.cs +++ b/PrinterControls/XYZJogControls.cs @@ -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; } diff --git a/Submodules/agg-sharp b/Submodules/agg-sharp index 6a2767d83..ce1a00747 160000 --- a/Submodules/agg-sharp +++ b/Submodules/agg-sharp @@ -1 +1 @@ -Subproject commit 6a2767d83dd5db2cde8f8487eb4dfa94b7eac800 +Subproject commit ce1a00747c1a1d77636f1b7be9eb3d237502ca9b