Made RoundedToggleSwitch play mouse down animation
Made UiThread SetInterval return a RunningInterval Added EaseIn EaseOut and EaseInOut to agg_basics
This commit is contained in:
parent
69a6a39545
commit
3091a719ee
15 changed files with 104 additions and 69 deletions
|
|
@ -134,10 +134,11 @@ namespace MatterHackers.MatterControl.ActionBar
|
|||
Margin = new BorderDouble(0, 5, 0, 0),
|
||||
};
|
||||
|
||||
UiThread.SetInterval(() =>
|
||||
var runningInterval = UiThread.SetInterval(() =>
|
||||
{
|
||||
graph.AddData(this.ActualTemperature);
|
||||
}, 1, () => !HasBeenClosed);
|
||||
}, 1);
|
||||
this.Closed += (s, e) => runningInterval.Continue = false;
|
||||
|
||||
var valueField = temperatureRow.Descendants<MHNumberEdit>().FirstOrDefault();
|
||||
var settingsRow = temperatureRow.DescendantsAndSelf<SliceSettingsRow>().FirstOrDefault();
|
||||
|
|
|
|||
|
|
@ -271,10 +271,11 @@ namespace MatterHackers.MatterControl.ActionBar
|
|||
Width = widget.Width - 20,
|
||||
Height = 35, // this works better if it is a common multiple of the Width
|
||||
};
|
||||
UiThread.SetInterval(() =>
|
||||
var runningInterval = UiThread.SetInterval(() =>
|
||||
{
|
||||
graph.AddData(this.ActualTemperature);
|
||||
}, 1, () => !HasBeenClosed);
|
||||
}, 1);
|
||||
this.Closed += (s, e) => runningInterval.Continue = false;
|
||||
|
||||
var valueField = temperatureRow.Descendants<MHNumberEdit>().FirstOrDefault();
|
||||
valueField.Name = "Temperature Input";
|
||||
|
|
|
|||
|
|
@ -2176,7 +2176,7 @@ namespace MatterHackers.MatterControl
|
|||
UiThread.SetInterval(() =>
|
||||
{
|
||||
ApplicationController.Instance.ActivePrinter.Connection.OnIdle();
|
||||
}, .1, () => true);
|
||||
}, .1);
|
||||
|
||||
return ApplicationController.Instance.MainView;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -99,7 +99,7 @@ namespace MatterHackers.MatterControl.ConfigurationPage.PrintLeveling
|
|||
}
|
||||
|
||||
yield return new HomePrinterPage(printer, this,
|
||||
levelingStrings.HomingPageStepText,
|
||||
"Homing The Printer".Localize(),
|
||||
levelingStrings.HomingPageInstructions(useZProbe, hasHeatedBed),
|
||||
useZProbe, theme);
|
||||
|
||||
|
|
@ -181,9 +181,34 @@ namespace MatterHackers.MatterControl.ConfigurationPage.PrintLeveling
|
|||
i++;
|
||||
}
|
||||
|
||||
this.nextButton.Enabled = false;
|
||||
this.cancelButton.Visible = false;
|
||||
this.doneButton.Visible = true;
|
||||
yield return new LastPagelInstructions(printer, this, "Done".Localize(), levelingStrings.DoneInstructions, probePositions, theme);
|
||||
var done1 = "Print Leveling is now configured and enabled.".Localize();
|
||||
string done2 = "If you need to recalibrate the printer in the future, the print leveling controls can be found under: Controls, Calibration";
|
||||
string done3 = "Click 'Done' to close this window.".Localize();
|
||||
|
||||
var doneString = "";
|
||||
if (useZProbe)
|
||||
{
|
||||
doneString = $"{"Congratulations!".Localize()} {done1}\n"
|
||||
+ "\n"
|
||||
+ $"{done2}\n"
|
||||
+ "\n"
|
||||
+ $"{done3}";
|
||||
}
|
||||
else
|
||||
{
|
||||
doneString = $"{"Congratulations!".Localize()} {done1}\n"
|
||||
+ "\n"
|
||||
+ $"\t• {"Remove the paper".Localize()}\n"
|
||||
+ "\n"
|
||||
+ $"{done2}\n"
|
||||
+ "\n"
|
||||
+ $"{done3}";
|
||||
}
|
||||
|
||||
yield return new LastPagelInstructions(printer, this, "Done".Localize(), doneString, probePositions, theme);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -36,13 +36,7 @@ namespace MatterHackers.MatterControl.ConfigurationPage.PrintLeveling
|
|||
{
|
||||
public class LevelingStrings
|
||||
{
|
||||
public string HomingPageStepText = "Homing The Printer".Localize();
|
||||
public string initialPrinterSetupStepText = "Initial Printer Setup".Localize();
|
||||
private string doneLine1 = "Congratulations!";
|
||||
private string doneLine1b = "Auto Print Leveling is now configured and enabled.".Localize();
|
||||
private string doneLine2 = "Remove the paper".Localize();
|
||||
private string doneLine3 = "If you need to recalibrate the printer in the future, the print leveling controls can be found under: Controls, Calibration";
|
||||
private string doneLine3b = "Click 'Done' to close this window.".Localize();
|
||||
private int stepNumber = 1;
|
||||
private string welcomeLine1 = "Welcome to the print leveling wizard. Here is a quick overview on what we are going to do.".Localize();
|
||||
private string selectMaterial = "Select the material you are printing".Localize();
|
||||
|
|
@ -58,21 +52,6 @@ namespace MatterHackers.MatterControl.ConfigurationPage.PrintLeveling
|
|||
this.printerSettings = printerSettings;
|
||||
}
|
||||
|
||||
public string DoneInstructions
|
||||
{
|
||||
get
|
||||
{
|
||||
if (printerSettings.Helpers.UseZProbe())
|
||||
{
|
||||
return $"{doneLine1} {doneLine1b}\n\n{doneLine3}\n\n{doneLine3b}";
|
||||
}
|
||||
else
|
||||
{
|
||||
return $"{doneLine1} {doneLine1b}\n\n\t• {doneLine2}\n\n{doneLine3}\n\n{doneLine3b}";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public string HomingPageInstructions(bool useZProbe, bool heatBed)
|
||||
{
|
||||
string line1 = "The printer should now be 'homing'.".Localize();
|
||||
|
|
|
|||
|
|
@ -93,7 +93,7 @@ namespace MatterHackers.MatterControl.ConfigurationPage.PrintLeveling
|
|||
|
||||
// add in the homing printer page
|
||||
yield return new HomePrinterPage(printer, this,
|
||||
levelingStrings.HomingPageStepText,
|
||||
"Homing The Printer".Localize(),
|
||||
levelingStrings.HomingPageInstructions(true, false),
|
||||
false, theme);
|
||||
|
||||
|
|
@ -135,6 +135,7 @@ namespace MatterHackers.MatterControl.ConfigurationPage.PrintLeveling
|
|||
|
||||
this.cancelButton.Visible = false;
|
||||
this.doneButton.Visible = true;
|
||||
this.nextButton.Enabled = false;
|
||||
yield return new CalibrateProbeLastPagelInstructions(printer, this,
|
||||
"Done".Localize(),
|
||||
"Your Probe is now calibrated.".Localize() + "\n\n\t• " + "Remove the paper".Localize() + "\n\n" + "Click 'Done' to close this window.".Localize(),
|
||||
|
|
|
|||
|
|
@ -77,11 +77,13 @@ namespace MatterHackers.MatterControl.ConfigurationPage.PrintLeveling
|
|||
Margin = new BorderDouble(10, 0),
|
||||
};
|
||||
|
||||
UiThread.SetInterval(() =>
|
||||
var runningInterval = UiThread.SetInterval(() =>
|
||||
{
|
||||
Vector3 destinationPosition = printer.Connection.CurrentDestination;
|
||||
zPosition.Text = "Z: {0:0.00}".FormatWith(destinationPosition.Z);
|
||||
}, .3, () => !HasBeenClosed);
|
||||
}, .3);
|
||||
|
||||
this.Closed += (s, e) => runningInterval.Continue = false;
|
||||
|
||||
zButtonsAndInfo.AddChild(zPosition);
|
||||
|
||||
|
|
|
|||
|
|
@ -161,7 +161,8 @@ namespace MatterHackers.MatterControl.ConfigurationPage.PrintLeveling
|
|||
{
|
||||
bedStartingTemp = printer.Connection.ActualBedTemperature;
|
||||
|
||||
UiThread.SetInterval(ShowTempChangeProgress, 1, () => !HasBeenClosed);
|
||||
var runningInterval = UiThread.SetInterval(ShowTempChangeProgress, 1);
|
||||
this.Closed += (s, e) => runningInterval.Continue = false;
|
||||
|
||||
if (bedTargetTemp > 0)
|
||||
{
|
||||
|
|
@ -171,7 +172,7 @@ namespace MatterHackers.MatterControl.ConfigurationPage.PrintLeveling
|
|||
|
||||
if (hotEndTargetTemp > 0)
|
||||
{
|
||||
// start heating the bed and show our progress
|
||||
// start heating the hot end and show our progress
|
||||
printer.Connection.SetTargetHotendTemperature(0, hotEndTargetTemp);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -44,6 +44,7 @@ namespace MatterHackers.MatterControl.PrinterControls
|
|||
{
|
||||
private long startTimeMs;
|
||||
private ProgressBar progressBar;
|
||||
private RunningInterval runningInterval;
|
||||
|
||||
private TextWidget progressBarText;
|
||||
|
||||
|
|
@ -111,10 +112,7 @@ namespace MatterHackers.MatterControl.PrinterControls
|
|||
{
|
||||
timeToWaitMs = (long)(macroData.countDown * 1000);
|
||||
startTimeMs = UiThread.CurrentTimerMs;
|
||||
UiThread.SetInterval(CountDownTime, .2, () =>
|
||||
{
|
||||
return (!HasBeenClosed && progressBar.RatioComplete < 1);
|
||||
});
|
||||
runningInterval = UiThread.SetInterval(CountDownTime, .2);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -150,6 +148,10 @@ namespace MatterHackers.MatterControl.PrinterControls
|
|||
|
||||
private void CountDownTime()
|
||||
{
|
||||
if(runningInterval != null)
|
||||
{
|
||||
runningInterval.Continue = !HasBeenClosed && progressBar.RatioComplete < 1;
|
||||
}
|
||||
progressBar.Visible = true;
|
||||
long timeSinceStartMs = UiThread.CurrentTimerMs - startTimeMs;
|
||||
progressBar.RatioComplete = timeToWaitMs == 0 ? 1 : Math.Max(0, Math.Min(1, ((double)timeSinceStartMs / (double)timeToWaitMs)));
|
||||
|
|
@ -165,8 +167,10 @@ namespace MatterHackers.MatterControl.PrinterControls
|
|||
&& stringEvent.Data.Contains("M104"))
|
||||
{
|
||||
startingTemp = printer.Connection.GetActualHotendTemperature(0);
|
||||
UiThread.SetInterval(() =>
|
||||
RunningInterval runningInterval = null;
|
||||
runningInterval = UiThread.SetInterval(() =>
|
||||
{
|
||||
runningInterval.Continue = !HasBeenClosed && progressBar.RatioComplete < 1;
|
||||
progressBar.Visible = true;
|
||||
double targetTemp = printer.Connection.GetTargetHotendTemperature(0);
|
||||
double actualTemp = printer.Connection.GetActualHotendTemperature(0);
|
||||
|
|
@ -175,7 +179,7 @@ namespace MatterHackers.MatterControl.PrinterControls
|
|||
double ratioDone = totalDelta != 0 ? (currentDelta / totalDelta) : 1;
|
||||
progressBar.RatioComplete = Math.Min(Math.Max(0, ratioDone), 1);
|
||||
progressBarText.Text = $"Temperature: {actualTemp:0} / {targetTemp:0}";
|
||||
}, 1, () => !HasBeenClosed && progressBar.RatioComplete < 1);
|
||||
}, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -96,7 +96,7 @@ namespace MatterHackers.MatterControl
|
|||
time = 1 - (time - 1);
|
||||
}
|
||||
|
||||
double lightnessMultiplier = EaseInOutQuad(time);
|
||||
double lightnessMultiplier = agg_basics.EaseInOutQuad(time);
|
||||
|
||||
widgetToHighlight.BackgroundColor = startColor.AdjustLightness(1 + lightnessChange * lightnessMultiplier).ToColor();
|
||||
if (widgetToHighlight.HasBeenClosed || timeSinceStart.Elapsed.TotalSeconds > cycles * pulseTime)
|
||||
|
|
@ -110,17 +110,6 @@ namespace MatterHackers.MatterControl
|
|||
}
|
||||
}
|
||||
|
||||
private double EaseInOutQuad(double t)
|
||||
{
|
||||
if (t <= 0.5f)
|
||||
{
|
||||
return 2.0f * (t * t);
|
||||
}
|
||||
|
||||
t -= 0.5f;
|
||||
return 2.0f * t * (1.0f - t) + 0.5;
|
||||
}
|
||||
|
||||
private void ConnectToWidget(object drawingWidget, DrawEventArgs e)
|
||||
{
|
||||
GuiWidget parent = drawingWidget as GuiWidget;
|
||||
|
|
@ -131,7 +120,8 @@ namespace MatterHackers.MatterControl
|
|||
startColor = parent.BackgroundColor;
|
||||
timeSinceStart = Stopwatch.StartNew();
|
||||
widgetToHighlight.AfterDraw -= ConnectToWidget;
|
||||
UiThread.SetInterval(ChangeBackgroundColor, animationDelay, () => parent.HasBeenClosed);
|
||||
var runningInterval = UiThread.SetInterval(ChangeBackgroundColor, animationDelay);
|
||||
parent.Closed += (s, e2) => runningInterval.Continue = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -81,7 +81,8 @@ namespace MatterHackers.MatterControl.CustomWidgets
|
|||
VAnchor = VAnchor.Fit;
|
||||
HAnchor = HAnchor.Fit;
|
||||
|
||||
UiThread.SetInterval(HideIfApplicable, .1, () => !HasBeenClosed);
|
||||
var runningInterval = UiThread.SetInterval(HideIfApplicable, .1);
|
||||
this.Closed += (s, e) => runningInterval.Continue = false;
|
||||
}
|
||||
|
||||
public Color TextColor { get; set; } = Color.Black;
|
||||
|
|
|
|||
|
|
@ -541,7 +541,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
|
|||
|
||||
timeContainer.AddChild(timeWidget);
|
||||
|
||||
UiThread.SetInterval(
|
||||
var runningInterval = UiThread.SetInterval(
|
||||
() =>
|
||||
{
|
||||
int secondsPrinted = printer.Connection.SecondsPrinted;
|
||||
|
|
@ -569,7 +569,8 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
|
|||
bodyRow.Visible = false;
|
||||
break;
|
||||
}
|
||||
}, 1, () => !bodyRow.HasBeenClosed);
|
||||
}, 1);
|
||||
bodyRow.Closed += (s, e) => runningInterval.Continue = false;
|
||||
|
||||
bodyRow.Visible = false;
|
||||
|
||||
|
|
|
|||
|
|
@ -28,6 +28,7 @@ either expressed or implied, of the FreeBSD Project.
|
|||
*/
|
||||
|
||||
using System;
|
||||
using System.Linq;
|
||||
using MatterHackers.Agg;
|
||||
using MatterHackers.Agg.Image;
|
||||
using MatterHackers.Agg.UI;
|
||||
|
|
@ -82,16 +83,55 @@ namespace MatterHackers.MatterControl.CustomWidgets
|
|||
this.MinimumSize = new Vector2(minWidth, theme.ButtonHeight);
|
||||
}
|
||||
|
||||
double animationRatio = 0;
|
||||
double finalRadius = 22;
|
||||
Animation animation;
|
||||
public override void OnMouseDown(MouseEventArgs mouseEvent)
|
||||
{
|
||||
mouseIsDown = true;
|
||||
base.OnMouseDown(mouseEvent);
|
||||
|
||||
// animation up
|
||||
animationRatio = 0;
|
||||
animation = new Animation(this, (t) =>
|
||||
{
|
||||
if (animation.Continue)
|
||||
{
|
||||
animationRatio += 1.0 / 7.0;
|
||||
}
|
||||
if (animationRatio >= 1)
|
||||
{
|
||||
animation.Continue = false;
|
||||
}
|
||||
}, 1.0 / 30.0);
|
||||
|
||||
this.Parents<SystemWindow>().First().AfterDraw += RoundedToggleSwitch_AfterDraw;
|
||||
|
||||
Closed += (s, e) =>
|
||||
{
|
||||
animation.Continue = false;
|
||||
};
|
||||
|
||||
this.Invalidate();
|
||||
}
|
||||
|
||||
private void RoundedToggleSwitch_AfterDraw(object sender, DrawEventArgs e)
|
||||
{
|
||||
var position = new Vector2((this.Checked) ? LocalBounds.Right - toggleRadiusPlusPadding : toggleRadiusPlusPadding, centerY);
|
||||
position = this.TransformToScreenSpace(position);
|
||||
Color toggleColor = (this.Checked) ? theme.Colors.PrimaryAccentColor : Color.Gray;
|
||||
|
||||
e.Graphics2D.Circle(position,
|
||||
finalRadius * agg_basics.EaseOutQuartic(animationRatio),
|
||||
new Color(toggleColor, 100));
|
||||
}
|
||||
|
||||
public override void OnMouseUp(MouseEventArgs mouseEvent)
|
||||
{
|
||||
this.Parents<SystemWindow>().First().AfterDraw -= RoundedToggleSwitch_AfterDraw;
|
||||
|
||||
animation.Continue = false;
|
||||
animationRatio = 0;
|
||||
mouseIsDown = false;
|
||||
base.OnMouseUp(mouseEvent);
|
||||
|
||||
|
|
|
|||
|
|
@ -525,11 +525,11 @@ namespace MatterHackers.MeshVisualizer
|
|||
var accentColor = Color.LightGray;
|
||||
if (secondsSinceSelectionChanged < .25)
|
||||
{
|
||||
selectionColor = Color.White.Blend(accentColor, EaseInOut(secondsSinceSelectionChanged * 4));
|
||||
selectionColor = Color.White.Blend(accentColor, agg_basics.EaseInOutQuad(secondsSinceSelectionChanged * 4));
|
||||
}
|
||||
else
|
||||
{
|
||||
selectionColor = accentColor.Blend(Color.White, EaseInOut((secondsSinceSelectionChanged - .25) * 4));
|
||||
selectionColor = accentColor.Blend(Color.White, agg_basics.EaseInOutQuad((secondsSinceSelectionChanged - .25) * 4));
|
||||
}
|
||||
Invalidate();
|
||||
}
|
||||
|
|
@ -678,17 +678,6 @@ namespace MatterHackers.MeshVisualizer
|
|||
}
|
||||
}
|
||||
|
||||
private double EaseInOut(double t)
|
||||
{
|
||||
if (t <= 0.5f)
|
||||
{
|
||||
return 2.0f * (t * t);
|
||||
}
|
||||
|
||||
t -= 0.5f;
|
||||
return 2.0f * t * (1.0f - t) + 0.5;
|
||||
}
|
||||
|
||||
public enum EditorType { Printer, Part }
|
||||
|
||||
public EditorType EditorMode { get; set; } = EditorType.Part;
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
Subproject commit 7f81c4b5adcac1a8d25727fe0a1157bac059b8cb
|
||||
Subproject commit af88c2020bde9ba76fc369ec105ac480b1cb2c25
|
||||
Loading…
Add table
Add a link
Reference in a new issue