mirror of
https://github.com/virtcode/hypr-dynamic-cursors
synced 2025-09-19 16:13:21 +02:00
fix: use new animations from hyprutils like hl
This commit is contained in:
parent
0ad0a0e4b7
commit
55fd61757b
2 changed files with 20 additions and 19 deletions
|
@ -9,6 +9,7 @@
|
||||||
#include <chrono>
|
#include <chrono>
|
||||||
#include <hyprland/src/Compositor.hpp>
|
#include <hyprland/src/Compositor.hpp>
|
||||||
#include <hyprland/src/debug/Log.hpp>
|
#include <hyprland/src/debug/Log.hpp>
|
||||||
|
#include <hyprutils/animation/AnimationConfig.hpp>
|
||||||
|
|
||||||
CShake::CShake() {
|
CShake::CShake() {
|
||||||
// the timing and the bezier are quite crucial, as things will break down if they are just changed slighly
|
// the timing and the bezier are quite crucial, as things will break down if they are just changed slighly
|
||||||
|
@ -23,17 +24,14 @@ CShake::CShake() {
|
||||||
g_pAnimationManager->addBezierWithName(bezier, {0.22, 1.0}, {0.36, 1.0});
|
g_pAnimationManager->addBezierWithName(bezier, {0.22, 1.0}, {0.36, 1.0});
|
||||||
});
|
});
|
||||||
|
|
||||||
// wtf is this struct?
|
// wtf is this struct, what is pValues?
|
||||||
static SAnimationPropertyConfig properties = {false, bezier, "", time / 100.F, 1, nullptr, nullptr };
|
static SP<SAnimationPropertyConfig> properties = makeShared<SAnimationPropertyConfig>();
|
||||||
properties.pValues = &properties;
|
properties->internalBezier = bezier;
|
||||||
|
properties->internalSpeed = time / 100.f;
|
||||||
|
properties->internalEnabled = 1;
|
||||||
|
properties->pValues = properties;
|
||||||
|
|
||||||
zoom.create(&properties, AVARDAMAGE_NONE);
|
g_pAnimationManager->createAnimation(1.f, zoom, properties, AVARDAMAGE_NONE);
|
||||||
zoom.registerVar();
|
|
||||||
zoom.setValueAndWarp(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
CShake::~CShake() {
|
|
||||||
zoom.unregister();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
double CShake::update(Vector2D pos) {
|
double CShake::update(Vector2D pos) {
|
||||||
|
@ -77,30 +75,30 @@ double CShake::update(Vector2D pos) {
|
||||||
if (diagonal > 100 && amount > 0) {
|
if (diagonal > 100 && amount > 0) {
|
||||||
float delta = 1.F / g_pHyprRenderer->m_pMostHzMonitor->refreshRate;
|
float delta = 1.F / g_pHyprRenderer->m_pMostHzMonitor->refreshRate;
|
||||||
|
|
||||||
float next = this->zoom.goal();
|
float next = this->zoom->goal();
|
||||||
|
|
||||||
if (!started) next = **PBASE; // start on base zoom
|
if (!started) next = **PBASE; // start on base zoom
|
||||||
next += delta * (**PSPEED + (amount * amount) * **PINFLUENCE); // increase when moving
|
next += delta * (**PSPEED + (amount * amount) * **PINFLUENCE); // increase when moving
|
||||||
if (**PLIMIT > 1) next = std::min(**PLIMIT, next); // limit overall zoom
|
if (**PLIMIT > 1) next = std::min(**PLIMIT, next); // limit overall zoom
|
||||||
|
|
||||||
if (next != this->zoom.goal()) this->zoom = next;
|
*this->zoom = next;
|
||||||
this->end = steady_clock::now() + milliseconds(**PTIMEOUT);
|
this->end = steady_clock::now() + milliseconds(**PTIMEOUT);
|
||||||
started = true;
|
started = true;
|
||||||
} else {
|
} else {
|
||||||
if (started && end < std::chrono::steady_clock::now()) {
|
if (started && end < std::chrono::steady_clock::now()) {
|
||||||
this->zoom = 1;
|
*this->zoom = 1;
|
||||||
started = false;
|
started = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (**PIPC) {
|
if (**PIPC) {
|
||||||
if (started || this->zoom.value() > 1) {
|
if (started || this->zoom->value() > 1) {
|
||||||
if (!ipc) {
|
if (!ipc) {
|
||||||
g_pEventManager->postEvent(SHyprIPCEvent { IPC_SHAKE_START });
|
g_pEventManager->postEvent(SHyprIPCEvent { IPC_SHAKE_START });
|
||||||
ipc = true;
|
ipc = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
g_pEventManager->postEvent(SHyprIPCEvent { IPC_SHAKE_UPDATE, std::format("{},{},{},{},{}", (int) pos.x, (int) pos.y, trail, diagonal, this->zoom.value()) });
|
g_pEventManager->postEvent(SHyprIPCEvent { IPC_SHAKE_UPDATE, std::format("{},{},{},{},{}", (int) pos.x, (int) pos.y, trail, diagonal, this->zoom->value()) });
|
||||||
} else {
|
} else {
|
||||||
if (ipc) {
|
if (ipc) {
|
||||||
g_pEventManager->postEvent(SHyprIPCEvent { IPC_SHAKE_END });
|
g_pEventManager->postEvent(SHyprIPCEvent { IPC_SHAKE_END });
|
||||||
|
@ -109,7 +107,9 @@ double CShake::update(Vector2D pos) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return this->zoom.value();
|
Debug::log(ERR, "value: {}, goal: {}", this->zoom->value(), this->zoom->goal());
|
||||||
|
|
||||||
|
return this->zoom->value();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CShake::warp(Vector2D old, Vector2D pos) {
|
void CShake::warp(Vector2D old, Vector2D pos) {
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
#include "src/helpers/AnimatedVariable.hpp"
|
#include "helpers/AnimatedVariable.hpp"
|
||||||
|
#include <hyprutils/animation/AnimatedVariable.hpp>
|
||||||
#include <hyprutils/math/Vector2D.hpp>
|
#include <hyprutils/math/Vector2D.hpp>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
@ -7,12 +8,12 @@
|
||||||
#define IPC_SHAKE_END "shakeend"
|
#define IPC_SHAKE_END "shakeend"
|
||||||
|
|
||||||
using namespace Hyprutils::Math;
|
using namespace Hyprutils::Math;
|
||||||
|
using namespace Hyprutils::Animation;
|
||||||
using namespace std::chrono;
|
using namespace std::chrono;
|
||||||
|
|
||||||
class CShake {
|
class CShake {
|
||||||
public:
|
public:
|
||||||
CShake();
|
CShake();
|
||||||
~CShake();
|
|
||||||
|
|
||||||
/* calculates the new zoom factor for the current pos */
|
/* calculates the new zoom factor for the current pos */
|
||||||
double update(Vector2D pos);
|
double update(Vector2D pos);
|
||||||
|
@ -24,7 +25,7 @@ class CShake {
|
||||||
bool ipc = false;
|
bool ipc = false;
|
||||||
|
|
||||||
bool started = false;
|
bool started = false;
|
||||||
CAnimatedVariable<float> zoom;
|
PHLANIMVAR<float> zoom;
|
||||||
steady_clock::time_point end;
|
steady_clock::time_point end;
|
||||||
|
|
||||||
/* ringbuffer for last samples */
|
/* ringbuffer for last samples */
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue