Files
hypr-chrome/src/Common.hpp
T
darmanandClaude Opus 5 b9dafe2ce1 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>
2026-07-29 20:36:24 +02:00

30 lines
1.2 KiB
C++

#pragma once
#include <hyprutils/memory/SharedPtr.hpp>
#include <hyprland/src/config/values/types/BoolValue.hpp>
#include <hyprland/src/config/values/types/ColorValue.hpp>
#include <hyprland/src/config/values/types/GradientValue.hpp>
#include <hyprland/src/config/values/types/IntValue.hpp>
#include <hyprland/src/config/values/types/StringValue.hpp>
#include <hyprland/src/plugins/PluginAPI.hpp>
using IntValue = Config::Values::CIntValue;
using BoolValue = Config::Values::CBoolValue;
using ColorValue = Config::Values::CColorValue;
// Accepts the same syntax as Hyprland's own general:col.* values - a single
// color, or several plus an optional trailing angle ("... 45deg").
using GradientValue = Config::Values::CGradientValue;
using StringValue = Config::Values::CStringValue;
// Hyprland's raw color ints (and CHyprColor(uint64_t)) are AARRGGBB, but
// literals are easier to read/write as the more common RRGGBBAA. Convert so
// config defaults can be written in that order.
constexpr uint64_t RGBAToARGB(uint64_t rgba) {
const uint64_t r = (rgba >> 24) & 0xFF;
const uint64_t g = (rgba >> 16) & 0xFF;
const uint64_t b = (rgba >> 8) & 0xFF;
const uint64_t a = rgba & 0xFF;
return (a << 24) | (r << 16) | (g << 8) | b;
}