2023-02-27 13:32:38 +01:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "../defines.hpp"
|
|
|
|
#include "../helpers/Timer.hpp"
|
|
|
|
#include "../helpers/Monitor.hpp"
|
|
|
|
#include "../render/Texture.hpp"
|
2023-03-20 16:23:25 +01:00
|
|
|
#include "../SharedDefs.hpp"
|
2023-02-27 13:32:38 +01:00
|
|
|
|
|
|
|
#include <deque>
|
|
|
|
|
|
|
|
#include <cairo/cairo.h>
|
|
|
|
|
2023-12-06 23:54:56 +01:00
|
|
|
enum eIconBackend {
|
2023-03-20 16:02:47 +01:00
|
|
|
ICONS_BACKEND_NONE = 0,
|
|
|
|
ICONS_BACKEND_NF,
|
|
|
|
ICONS_BACKEND_FA
|
|
|
|
};
|
|
|
|
|
2023-03-20 16:49:46 +01:00
|
|
|
static const std::array<std::array<std::string, ICON_NONE + 1>, 3 /* backends */> ICONS_ARRAY = {
|
2023-12-06 23:54:56 +01:00
|
|
|
std::array<std::string, ICON_NONE + 1>{"[!]", "[i]", "[Hint]", "[Err]", "[?]", "[ok]", ""},
|
|
|
|
std::array<std::string, ICON_NONE + 1>{"", "", "", "", "", "", ""}, std::array<std::string, ICON_NONE + 1>{"", "", "", "", "", ""}};
|
2023-03-20 16:49:46 +01:00
|
|
|
static const std::array<CColor, ICON_NONE + 1> ICONS_COLORS = {CColor{255.0 / 255.0, 204 / 255.0, 102 / 255.0, 1.0},
|
|
|
|
CColor{128 / 255.0, 255 / 255.0, 255 / 255.0, 1.0},
|
|
|
|
CColor{179 / 255.0, 255 / 255.0, 204 / 255.0, 1.0},
|
|
|
|
CColor{255 / 255.0, 77 / 255.0, 77 / 255.0, 1.0},
|
|
|
|
CColor{255 / 255.0, 204 / 255.0, 153 / 255.0, 1.0},
|
|
|
|
CColor{128 / 255.0, 255 / 255.0, 128 / 255.0, 1.0},
|
|
|
|
CColor{0, 0, 0, 1.0}};
|
2023-03-20 16:02:47 +01:00
|
|
|
|
2023-02-27 13:32:38 +01:00
|
|
|
struct SNotification {
|
|
|
|
std::string text = "";
|
|
|
|
CColor color;
|
|
|
|
CTimer started;
|
|
|
|
float timeMs = 0;
|
2023-03-20 16:02:47 +01:00
|
|
|
eIcons icon = ICON_NONE;
|
2023-02-27 13:32:38 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
class CHyprNotificationOverlay {
|
|
|
|
public:
|
|
|
|
CHyprNotificationOverlay();
|
|
|
|
|
|
|
|
void draw(CMonitor* pMonitor);
|
2023-03-20 16:02:47 +01:00
|
|
|
void addNotification(const std::string& text, const CColor& color, const float timeMs, const eIcons icon = ICON_NONE);
|
2024-03-02 19:12:31 +01:00
|
|
|
void dismissNotifications(const int amount);
|
2024-02-14 12:09:18 +01:00
|
|
|
bool hasAny();
|
2023-02-27 13:32:38 +01:00
|
|
|
|
|
|
|
private:
|
2023-11-04 18:03:05 +01:00
|
|
|
CBox drawNotifications(CMonitor* pMonitor);
|
|
|
|
CBox m_bLastDamage;
|
2023-02-27 13:32:38 +01:00
|
|
|
|
|
|
|
std::deque<std::unique_ptr<SNotification>> m_dNotifications;
|
|
|
|
|
|
|
|
cairo_surface_t* m_pCairoSurface = nullptr;
|
|
|
|
cairo_t* m_pCairo = nullptr;
|
|
|
|
|
|
|
|
CMonitor* m_pLastMonitor = nullptr;
|
|
|
|
|
|
|
|
CTexture m_tTexture;
|
2023-03-20 16:02:47 +01:00
|
|
|
|
|
|
|
eIconBackend m_eIconBackend = ICONS_BACKEND_NONE;
|
|
|
|
std::string m_szIconFontName = "Sans";
|
2023-02-27 13:32:38 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
inline std::unique_ptr<CHyprNotificationOverlay> g_pHyprNotificationOverlay;
|