border animation optimization

This commit is contained in:
vaxerski 2021-12-10 23:28:00 +01:00
parent 3216afbf12
commit 158260c0ec
3 changed files with 10 additions and 5 deletions

View file

@ -50,6 +50,7 @@ Animations {
enabled=1
speed=5
cheap=1 # highly recommended
borders=0
}
# keybinds

View file

@ -82,4 +82,6 @@
#define CONTAINS(s, f) s.find(f) != std::string::npos
#define RETURNIFBAR if (g_pWindowManager->statusBar) return;
#define RETURNIFMAIN if (!g_pWindowManager->statusBar) return;
#define RETURNIFMAIN if (!g_pWindowManager->statusBar) return;
#define COLORDELTAOVERX(c, c1, d) (abs(RED(c) - RED(c1)) > d / 255.f || abs(GREEN(c) - GREEN(c1)) > d / 255.f || abs(BLUE(c) - BLUE(c1)) > d / 255.f || abs(ALPHA(c) - ALPHA(c1)) > d / 255.f)

View file

@ -19,17 +19,19 @@ void AnimationUtil::move() {
// Border animations
if (window.getDrawable() > 0) {
if (window.getEffectiveBorderColor().getAsUint32() != window.getRealBorderColor().getAsUint32() /* As uint32 to round and not spam */) {
// interp border color if enabled
const auto PREVCOLOR = window.getRealBorderColor().getAsUint32();
if (ConfigManager::getInt("anim:borders") == 1) {
window.setRealBorderColor(parabolicColor(window.getRealBorderColor(), window.getEffectiveBorderColor(), ANIMATIONSPEED));
} else {
window.setRealBorderColor(window.getEffectiveBorderColor());
}
updateRequired = true;
window.setDirty(true);
if (COLORDELTAOVERX(PREVCOLOR, window.getRealBorderColor().getAsUint32(), 2)) {
updateRequired = true;
window.setDirty(true);
}
}
}