Finishing color and material buttons in properties panel
Added ability to auto switch to view mode for correct setting being changed issue: MatterHackers/MatterControl#3799 When setting color or material, switch to correct view mode
This commit is contained in:
parent
b5dacdfa56
commit
593a32cfa6
5 changed files with 55 additions and 38 deletions
|
|
@ -199,33 +199,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
|
|||
|
||||
if (!buttonIsBeingClicked)
|
||||
{
|
||||
double displayTime = 2;
|
||||
double pulseTime = .5;
|
||||
double totalSeconds = 0;
|
||||
Color backgroundColor = activeButton.BackgroundColor;
|
||||
Color hightlightColor = theme.Colors.PrimaryAccentColor.AdjustContrast(theme.Colors.PrimaryTextColor, 6).ToColor();
|
||||
// Show a highlight on the button as the user did not click it
|
||||
Animation flashBackground = null;
|
||||
flashBackground = new Animation()
|
||||
{
|
||||
DrawTarget = activeButton,
|
||||
FramesPerSecond = 10,
|
||||
Update = (s1, updateEvent) =>
|
||||
{
|
||||
totalSeconds += updateEvent.SecondsPassed;
|
||||
if (totalSeconds < displayTime)
|
||||
{
|
||||
double blend = AttentionGetter.GetFadeInOutPulseRatio(totalSeconds, pulseTime);
|
||||
activeButton.BackgroundColor = new Color(hightlightColor, (int)(blend * 255));
|
||||
}
|
||||
else
|
||||
{
|
||||
activeButton.BackgroundColor = backgroundColor;
|
||||
flashBackground.Stop();
|
||||
}
|
||||
}
|
||||
};
|
||||
flashBackground.Start();
|
||||
activeButton.FlashBackground(theme.Colors.PrimaryAccentColor.AdjustContrast(theme.Colors.PrimaryTextColor, 6).ToColor());
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
@ -460,4 +434,37 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
|
|||
});
|
||||
}
|
||||
}
|
||||
|
||||
public static class WidgetAnimationExtensions
|
||||
{
|
||||
public static void FlashBackground(this GuiWidget widget, Color hightlightColor)
|
||||
{
|
||||
double displayTime = 2;
|
||||
double pulseTime = .5;
|
||||
double totalSeconds = 0;
|
||||
Color backgroundColor = widget.BackgroundColor;
|
||||
// Show a highlight on the button as the user did not click it
|
||||
Animation flashBackground = null;
|
||||
flashBackground = new Animation()
|
||||
{
|
||||
DrawTarget = widget,
|
||||
FramesPerSecond = 10,
|
||||
Update = (s1, updateEvent) =>
|
||||
{
|
||||
totalSeconds += updateEvent.SecondsPassed;
|
||||
if (totalSeconds < displayTime)
|
||||
{
|
||||
double blend = AttentionGetter.GetFadeInOutPulseRatio(totalSeconds, pulseTime);
|
||||
widget.BackgroundColor = new Color(hightlightColor, (int)(blend * 255));
|
||||
}
|
||||
else
|
||||
{
|
||||
widget.BackgroundColor = backgroundColor;
|
||||
flashBackground.Stop();
|
||||
}
|
||||
}
|
||||
};
|
||||
flashBackground.Start();
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue