aboutsummaryrefslogtreecommitdiff
path: root/Src/auth/Loginbox/animation.cpp
diff options
context:
space:
mode:
authorJef <jef@targetspot.com>2024-09-24 08:54:57 -0400
committerJef <jef@targetspot.com>2024-09-24 08:54:57 -0400
commit20d28e80a5c861a9d5f449ea911ab75b4f37ad0d (patch)
tree12f17f78986871dd2cfb0a56e5e93b545c1ae0d0 /Src/auth/Loginbox/animation.cpp
parent537bcbc86291b32fc04ae4133ce4d7cac8ebe9a7 (diff)
downloadwinamp-20d28e80a5c861a9d5f449ea911ab75b4f37ad0d.tar.gz
Initial community commit
Diffstat (limited to 'Src/auth/Loginbox/animation.cpp')
-rw-r--r--Src/auth/Loginbox/animation.cpp77
1 files changed, 77 insertions, 0 deletions
diff --git a/Src/auth/Loginbox/animation.cpp b/Src/auth/Loginbox/animation.cpp
new file mode 100644
index 00000000..6ec82225
--- /dev/null
+++ b/Src/auth/Loginbox/animation.cpp
@@ -0,0 +1,77 @@
+#include "./animation.h"
+#include "./common.h"
+
+BOOL Animation_Initialize(ANIMATIONDATA *animation, UINT durationMs)
+{
+ if (NULL == animation)
+ return FALSE;
+
+ if (FALSE == QueryPerformanceFrequency(&animation->frequency))
+ return FALSE;
+
+ QueryPerformanceCounter(&animation->completion);
+ animation->completion.QuadPart += animation->frequency.QuadPart*durationMs/1000LL;
+ return TRUE;
+}
+
+BOOL Animation_BeginStep(ANIMATIONDATA *animation)
+{
+ if (NULL == animation || FALSE == QueryPerformanceCounter(&animation->stepBegin))
+ return FALSE;
+
+ return TRUE;
+}
+
+BOOL Animation_EndStep(ANIMATIONDATA *animation, size_t stepsRemaining)
+{
+ if (NULL == animation || FALSE == QueryPerformanceCounter(&animation->stepEnd))
+ return FALSE;
+
+ if (0 == stepsRemaining || animation->stepEnd.QuadPart >= animation->completion.QuadPart)
+ return TRUE;
+
+ LARGE_INTEGER sleep;
+ sleep.QuadPart = (animation->completion.QuadPart - animation->stepEnd.QuadPart) -
+ (stepsRemaining * (animation->stepEnd.QuadPart - animation->stepBegin.QuadPart));
+
+ if (stepsRemaining > 1)
+ sleep.QuadPart /= (stepsRemaining -1);
+
+ if (sleep.QuadPart <= 0)
+ return TRUE;
+
+ sleep.QuadPart += animation->stepEnd.QuadPart;
+ do
+ {
+ SleepEx(0, FALSE);
+ QueryPerformanceCounter(&animation->stepEnd);
+ } while(sleep.QuadPart > animation->stepEnd.QuadPart);
+
+ return TRUE;
+}
+
+BOOL Animation_SetWindowPos(HWND hwnd, INT x, INT y, INT cx, INT cy, UINT flags, HDC hdc, INT contextX, INT contextY)
+{
+ if (NULL == hwnd ||
+ FALSE == SetWindowPos(hwnd, NULL, x, y, cx, cy,
+ flags | SWP_NOACTIVATE | SWP_NOZORDER | SWP_NOREDRAW | SWP_NOCOPYBITS))
+ {
+ return FALSE;
+ }
+
+ UINT windowStyle = GetWindowStyle(hwnd);
+
+ POINT origPoint;
+ SetViewportOrgEx(hdc, contextX, contextY, &origPoint);
+ if (0 == (WS_VISIBLE & windowStyle))
+ SetWindowLongPtr(hwnd, GWL_STYLE, windowStyle | WS_VISIBLE);
+
+ if (FALSE == LoginBox_PrintWindow(hwnd, hdc, 0))
+ SendMessage(hwnd, WM_PRINT, (WPARAM)hdc, (LPARAM)(PRF_CLIENT | PRF_ERASEBKGND | PRF_CHILDREN | PRF_NONCLIENT));
+
+ if (0 == (WS_VISIBLE & windowStyle))
+ SetWindowLongPtr(hwnd, GWL_STYLE, windowStyle & ~WS_VISIBLE);
+
+ SetViewportOrgEx(hdc, origPoint.x, origPoint.y, NULL);
+ return TRUE;
+} \ No newline at end of file