mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-08 04:07:40 +02:00
Couple two members of ZoneWindowDrawing
This commit is contained in:
@@ -14,13 +14,13 @@ namespace NonLocalizable
|
|||||||
float ZoneWindowDrawing::GetAnimationAlpha()
|
float ZoneWindowDrawing::GetAnimationAlpha()
|
||||||
{
|
{
|
||||||
// Lock is being held
|
// Lock is being held
|
||||||
if (!m_tAnimationStart)
|
if (!m_animation)
|
||||||
{
|
{
|
||||||
return 1.f;
|
return 1.f;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto tNow = std::chrono::steady_clock().now();
|
auto tNow = std::chrono::steady_clock().now();
|
||||||
auto alpha = (tNow - *m_tAnimationStart).count() / (1e6f * m_animationDuration);
|
auto alpha = (tNow - m_animation->tStart).count() / (1e6f * m_animation->duration);
|
||||||
if (alpha < 1.f)
|
if (alpha < 1.f)
|
||||||
{
|
{
|
||||||
return alpha;
|
return alpha;
|
||||||
@@ -68,7 +68,6 @@ ZoneWindowDrawing::ZoneWindowDrawing(HWND window)
|
|||||||
{
|
{
|
||||||
m_window = window;
|
m_window = window;
|
||||||
m_renderTarget = nullptr;
|
m_renderTarget = nullptr;
|
||||||
m_animationDuration = 0;
|
|
||||||
m_shouldRender = false;
|
m_shouldRender = false;
|
||||||
|
|
||||||
// Obtain the size of the drawing area.
|
// Obtain the size of the drawing area.
|
||||||
@@ -192,9 +191,9 @@ void ZoneWindowDrawing::Render()
|
|||||||
void ZoneWindowDrawing::Hide()
|
void ZoneWindowDrawing::Hide()
|
||||||
{
|
{
|
||||||
std::unique_lock lock(m_mutex);
|
std::unique_lock lock(m_mutex);
|
||||||
if (m_tAnimationStart)
|
if (m_animation)
|
||||||
{
|
{
|
||||||
m_tAnimationStart.reset();
|
m_animation.reset();
|
||||||
ShowWindow(m_window, SW_HIDE);
|
ShowWindow(m_window, SW_HIDE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -205,11 +204,13 @@ void ZoneWindowDrawing::Show(unsigned animationMillis)
|
|||||||
std::unique_lock lock(m_mutex);
|
std::unique_lock lock(m_mutex);
|
||||||
m_lowLatencyLock = false;
|
m_lowLatencyLock = false;
|
||||||
|
|
||||||
if (!m_tAnimationStart)
|
if (!m_animation)
|
||||||
{
|
{
|
||||||
ShowWindow(m_window, SW_SHOWDEFAULT);
|
ShowWindow(m_window, SW_SHOWDEFAULT);
|
||||||
m_tAnimationStart = std::chrono::steady_clock().now();
|
if (animationMillis > 0)
|
||||||
m_animationDuration = max(1u, animationMillis);
|
{
|
||||||
|
m_animation.emplace(AnimationInfo{ std::chrono::steady_clock().now(), animationMillis });
|
||||||
|
}
|
||||||
m_shouldRender = true;
|
m_shouldRender = true;
|
||||||
m_cv.notify_all();
|
m_cv.notify_all();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,11 +21,16 @@ class ZoneWindowDrawing
|
|||||||
size_t id;
|
size_t id;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct AnimationInfo
|
||||||
|
{
|
||||||
|
std::chrono::steady_clock::time_point tStart;
|
||||||
|
unsigned duration;
|
||||||
|
};
|
||||||
|
|
||||||
HWND m_window;
|
HWND m_window;
|
||||||
RECT m_clientRect;
|
RECT m_clientRect;
|
||||||
ID2D1HwndRenderTarget* m_renderTarget;
|
ID2D1HwndRenderTarget* m_renderTarget;
|
||||||
std::optional<std::chrono::steady_clock::time_point> m_tAnimationStart;
|
std::optional<AnimationInfo> m_animation;
|
||||||
unsigned m_animationDuration;
|
|
||||||
|
|
||||||
std::mutex m_mutex;
|
std::mutex m_mutex;
|
||||||
std::vector<DrawableRect> m_sceneRects;
|
std::vector<DrawableRect> m_sceneRects;
|
||||||
|
|||||||
Reference in New Issue
Block a user