Render border gradients instead of a flat first stop
The frame collapsed Hyprland's border gradient to m_colors.front(), so a gradient col.active_border showed up as a single flat color. Snapshot the gradient (stops + angle) into a new header-only ChromeGradient and fill the cairo path with a linear gradient built from it: - AxisFor() reproduces the border shader's quadrant-folding progress function (y*sin(a) + x*(1-sin(a)), not a true rotation) as a cairo axis, so the frame's sweep stays in step with the window border it wraps. Checked against a port of the shader across all 360 degrees: cardinal angles exact, worst case 0.003 of the sweep (the shader folds on literal 1.57/3.14/4.71 where this uses pi). - SampleAt() interpolates in OkLab, where the shader interpolates, with each segment subdivided into sampled cairo stops so cairo's own sRGB lerp tracks that curve. active_color/inactive_color become gradient config values, taking the same syntax as general:col.active_border. Single-color configs are unaffected. The cross-focus fade (m_realBorderColorPrevious + fade progress, lerped between two gradients in-shader) is still not reproduced. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
#define WLR_USE_UNSTABLE
|
||||
|
||||
#include "Globals.hpp"
|
||||
#include "ChromeGradient.hpp"
|
||||
#include <hyprland/src/desktop/DesktopTypes.hpp>
|
||||
#include <hyprland/src/render/decorations/IHyprWindowDecoration.hpp>
|
||||
#include <hyprutils/math/Box.hpp>
|
||||
@@ -42,17 +43,19 @@ public:
|
||||
// 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. Cached and only regenerated when any of these change from the
|
||||
// last call.
|
||||
SP<Render::ITexture> GetBorderTexture(const Vector2D& sizePx, float extentPx, float chamferPx, uint64_t colorValue, float titleBarHeightPx, float titleBarWidthPx);
|
||||
// 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<Render::ITexture> 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`, 0xEEEEEEFF otherwise, both at the
|
||||
// border color's own alpha. Cached and only regenerated when any of these
|
||||
// change from the last call. Returns nullptr if `title` is empty.
|
||||
SP<Render::ITexture> GetTitleTexture(const std::string& title, float textSizePx, uint64_t colorValue, const std::string& fontFamily, int maxWidthPx, bool isActive);
|
||||
// `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<Render::ITexture> GetTitleTexture(const std::string& title, float textSizePx, float alpha, const std::string& fontFamily, int maxWidthPx, bool isActive);
|
||||
|
||||
WP<ChromeDecoration> self;
|
||||
|
||||
@@ -64,14 +67,14 @@ private:
|
||||
Vector2D cachedTexSize = {-1, -1};
|
||||
float cachedExtent = -1.F;
|
||||
float cachedChamfer = -1.F;
|
||||
uint64_t cachedColorValue = 0;
|
||||
ChromeGradient cachedGradient;
|
||||
float cachedTitleBarHeight = -1.F;
|
||||
float cachedTitleBarWidth = -1.F;
|
||||
|
||||
SP<Render::ITexture> cachedTitleTex;
|
||||
std::string cachedTitleTexTitle;
|
||||
float cachedTitleTexSize = -1.F;
|
||||
uint64_t cachedTitleTexColor = 0;
|
||||
float cachedTitleTexAlpha = -1.F;
|
||||
std::string cachedTitleTexFont;
|
||||
int cachedTitleTexMaxWidth = -1;
|
||||
bool cachedTitleTexActive = false;
|
||||
|
||||
Reference in New Issue
Block a user