#pragma once #define WLR_USE_UNSTABLE #include "Globals.hpp" #include "ChromeGradient.hpp" #include #include #include #include #include namespace Render { class ITexture; } // A decoration that draws a chamfered HUD-style border frame behind each // window, expanding past the window's edges by `plugin:hyprchrome:extent` // pixels on every side. The frame's corners are chamfered by an amount // inferred from the window's own border rounding, so the border peeking out // around a rounded window's corners reads as a matching diagonal cut rather // than a hard rectangular corner. class ChromeDecoration : public IHyprWindowDecoration { public: ChromeDecoration(PHLWINDOW window); virtual ~ChromeDecoration(); virtual SDecorationPositioningInfo getPositioningInfo(); virtual void onPositioningReply(const SDecorationPositioningReply& reply); virtual void draw(PHLMONITOR monitor, float const& alpha); virtual eDecorationType getDecorationType(); virtual void updateWindow(PHLWINDOW window); virtual void damageEntire(); virtual eDecorationLayer getDecorationLayer(); virtual uint64_t getDecorationFlags(); virtual std::string getDisplayName(); PHLWINDOW GetOwner(); // Returns a cairo-rendered texture of the chamfered border frame sized to // `sizePx` (device pixels): a hollow ring `extentPx` thick inset from the // outer edge, with both the outer and inner boundaries corner-chamfered // by `chamferPx`, plus a title bar of height `titleBarHeightPx` and width // `titleBarWidthPx` (already measured/clamped by the caller - see // ChromeDecorationGeometry) hanging off the floating top-border // cutout. Filled with `gradient` swept across the whole texture along that // gradient's own axis (a single-stop gradient is just a flat fill). Cached // and only regenerated when any of these change from the last call. SP GetBorderTexture(const Vector2D& sizePx, float extentPx, float chamferPx, const ChromeGradient& gradient, float titleBarHeightPx, float titleBarWidthPx); // Returns a texture of `title` rendered via Hyprland's own text renderer // (Pango, through IHyprRenderer::renderText) at `textSizePx` using // `fontFamily`, truncated with a trailing "…" if it doesn't fit within // `maxWidthPx` - black while `isActive`, 0xEEEEEE otherwise, both at // `alpha` (the border's own alpha, so translucent borders keep translucent // text). Cached and only regenerated when any of these change from the last // call. Returns nullptr if `title` is empty. SP GetTitleTexture(const std::string& title, float textSizePx, float alpha, const std::string& fontFamily, int maxWidthPx, bool isActive); WP self; private: PHLWINDOWREF windowRef; CBox assignedBox; SP cachedTexture; Vector2D cachedTexSize = {-1, -1}; float cachedExtent = -1.F; float cachedChamfer = -1.F; ChromeGradient cachedGradient; float cachedTitleBarHeight = -1.F; float cachedTitleBarWidth = -1.F; SP cachedTitleTex; std::string cachedTitleTexTitle; float cachedTitleTexSize = -1.F; float cachedTitleTexAlpha = -1.F; std::string cachedTitleTexFont; int cachedTitleTexMaxWidth = -1; bool cachedTitleTexActive = false; // The border frame's box in global (monitor-independent) logical // coordinates: the window's own box, expanded by `extent` and offset by // the window's workspace/floating animation offsets. CBox FullDecorationExtentGlobal(); friend class ChromePassElement; };