Files
hypr-chrome/src/GlobalState.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

60 lines
2.4 KiB
C++

#pragma once
#include "Common.hpp"
#include "ChromeConfig.hpp"
#include <vector>
class ChromeDecoration;
struct GlobalState {
ChromeConfig config;
std::vector<WP<ChromeDecoration>> decorations;
GlobalState(HANDLE plugin) {
config = ChromeConfig{
.enabled = makeShared<BoolValue>(
"plugin:hyprchrome:enabled",
"Whether the border decoration is enabled",
true),
.extent = makeShared<IntValue>(
"plugin:hyprchrome:extent",
"How far the border extends past each window edge, in pixels",
12),
.followHyprlandBorderColor = makeShared<BoolValue>(
"plugin:hyprchrome:follow_hyprland_border_color",
"Whether the border tracks Hyprland's own active/inactive border color instead of active_color/inactive_color",
true),
.activeColor = makeShared<GradientValue>(
"plugin:hyprchrome:active_color",
"Color (or gradient) of the border on the focused window, used when follow_hyprland_border_color is false",
CHyprColor{RGBAToARGB(0xFFD063FF)}),
.inactiveColor = makeShared<GradientValue>(
"plugin:hyprchrome:inactive_color",
"Color (or gradient) of the border on unfocused windows, used when follow_hyprland_border_color is false",
CHyprColor{RGBAToARGB(0x6C6C6CFF)}),
.titlebarHeight = makeShared<IntValue>(
"plugin:hyprchrome:titlebar_height",
"Height of the title bar hanging off the floating top-border cutout, in pixels",
8),
.titlebarTextSize = makeShared<IntValue>(
"plugin:hyprchrome:titlebar_text_size",
"Font size of the title bar's text, in pixels",
12),
.titlebarFont = makeShared<StringValue>(
"plugin:hyprchrome:titlebar_font",
"Font family of the title bar's text",
"sans-serif"),
};
HyprlandAPI::addConfigValueV2(plugin, config.enabled);
HyprlandAPI::addConfigValueV2(plugin, config.extent);
HyprlandAPI::addConfigValueV2(plugin, config.followHyprlandBorderColor);
HyprlandAPI::addConfigValueV2(plugin, config.activeColor);
HyprlandAPI::addConfigValueV2(plugin, config.inactiveColor);
HyprlandAPI::addConfigValueV2(plugin, config.titlebarHeight);
HyprlandAPI::addConfigValueV2(plugin, config.titlebarTextSize);
HyprlandAPI::addConfigValueV2(plugin, config.titlebarFont);
}
};