2024-02-18 23:08:03 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
|
|
#include "IWidget.hpp"
|
2024-02-19 20:50:58 +00:00
|
|
|
#include "../../helpers/Color.hpp"
|
2024-10-13 12:04:32 +00:00
|
|
|
#include "../../helpers/Math.hpp"
|
2024-12-18 16:28:05 +01:00
|
|
|
#include "../../core/Timer.hpp"
|
2024-02-21 22:19:01 +00:00
|
|
|
#include "../Framebuffer.hpp"
|
2024-12-18 16:28:05 +01:00
|
|
|
#include "../AsyncResourceGatherer.hpp"
|
2025-03-05 08:35:43 +01:00
|
|
|
#include <hyprutils/math/Misc.hpp>
|
2024-02-18 23:08:03 +00:00
|
|
|
#include <string>
|
2024-02-21 22:19:01 +00:00
|
|
|
#include <unordered_map>
|
|
|
|
|
#include <any>
|
2024-12-18 16:28:05 +01:00
|
|
|
#include <chrono>
|
|
|
|
|
#include <filesystem>
|
2024-02-18 23:08:03 +00:00
|
|
|
|
|
|
|
|
struct SPreloadedAsset;
|
2024-03-03 02:19:25 +00:00
|
|
|
class COutput;
|
2024-02-18 23:08:03 +00:00
|
|
|
|
2024-12-18 16:28:05 +01:00
|
|
|
struct SFade {
|
|
|
|
|
std::chrono::system_clock::time_point start;
|
|
|
|
|
float a = 0;
|
|
|
|
|
std::shared_ptr<CTimer> crossFadeTimer = nullptr;
|
|
|
|
|
};
|
|
|
|
|
|
2024-02-18 23:08:03 +00:00
|
|
|
class CBackground : public IWidget {
|
|
|
|
|
public:
|
2025-03-05 08:35:43 +01:00
|
|
|
CBackground() = default;
|
2024-12-18 16:28:05 +01:00
|
|
|
~CBackground();
|
2024-02-18 23:08:03 +00:00
|
|
|
|
2025-03-05 08:35:43 +01:00
|
|
|
void registerSelf(const SP<CBackground>& self);
|
|
|
|
|
|
|
|
|
|
virtual void configure(const std::unordered_map<std::string, std::any>& props, const SP<COutput>& pOutput);
|
2024-02-19 16:26:08 +00:00
|
|
|
virtual bool draw(const SRenderData& data);
|
2025-03-05 08:35:43 +01:00
|
|
|
|
|
|
|
|
void reset(); // Unload assets, remove timers, etc.
|
|
|
|
|
|
2025-01-06 12:34:21 +00:00
|
|
|
void renderRect(CHyprColor color);
|
2024-02-18 23:08:03 +00:00
|
|
|
|
2024-12-18 16:28:05 +01:00
|
|
|
void onReloadTimerUpdate();
|
|
|
|
|
void onCrossFadeTimerUpdate();
|
|
|
|
|
void plantReloadTimer();
|
|
|
|
|
void startCrossFadeOrUpdateRender();
|
|
|
|
|
|
2024-02-18 23:08:03 +00:00
|
|
|
private:
|
2025-03-05 08:35:43 +01:00
|
|
|
WP<CBackground> m_self;
|
|
|
|
|
|
2024-02-21 22:19:01 +00:00
|
|
|
// if needed
|
2024-12-18 16:28:05 +01:00
|
|
|
CFramebuffer blurredFB;
|
|
|
|
|
|
|
|
|
|
int blurSize = 10;
|
|
|
|
|
int blurPasses = 3;
|
|
|
|
|
float noise = 0.0117;
|
|
|
|
|
float contrast = 0.8916;
|
|
|
|
|
float brightness = 0.8172;
|
|
|
|
|
float vibrancy = 0.1696;
|
|
|
|
|
float vibrancy_darkness = 0.0;
|
|
|
|
|
Vector2D viewport;
|
|
|
|
|
std::string path = "";
|
|
|
|
|
|
2025-03-05 08:35:43 +01:00
|
|
|
std::string outputPort;
|
|
|
|
|
Hyprutils::Math::eTransform transform;
|
|
|
|
|
|
2024-12-18 16:28:05 +01:00
|
|
|
std::string resourceID;
|
|
|
|
|
std::string pendingResourceID;
|
|
|
|
|
|
|
|
|
|
float crossFadeTime = -1.0;
|
|
|
|
|
|
2025-01-06 12:34:21 +00:00
|
|
|
CHyprColor color;
|
2024-12-18 16:28:05 +01:00
|
|
|
SPreloadedAsset* asset = nullptr;
|
|
|
|
|
bool isScreenshot = false;
|
|
|
|
|
SPreloadedAsset* pendingAsset = nullptr;
|
|
|
|
|
bool firstRender = true;
|
|
|
|
|
|
2025-03-05 08:35:43 +01:00
|
|
|
UP<SFade> fade;
|
2024-12-18 16:28:05 +01:00
|
|
|
|
|
|
|
|
int reloadTime = -1;
|
|
|
|
|
std::string reloadCommand;
|
|
|
|
|
CAsyncResourceGatherer::SPreloadRequest request;
|
|
|
|
|
std::shared_ptr<CTimer> reloadTimer;
|
|
|
|
|
std::filesystem::file_time_type modificationTime;
|
2025-03-05 08:35:43 +01:00
|
|
|
};
|