8b491e203ac81b83ab38f9ad7da38792a412c19a
- Author
- outfoxxed <outfoxxed@outfoxxed.me>
- Committer
- outfoxxed <outfoxxed@outfoxxed.me>
- Date
Message
Diff
This diff is truncated to protect this page.
1diff --git a/src/TabGroup.cpp b/src/TabGroup.cpp
2index 6b4a38f55c865994b0e0fd51335d4db91c7163a5..4da574bdc5bbfea1021b36d4c773f43e0d5d6ceb 100644
3--- a/src/TabGroup.cpp
4+++ b/src/TabGroup.cpp
5@@ -4,6 +4,7 @@
6
7 #include <GLES2/gl2.h>
8 #include <cairo/cairo.h>
9+#include <hyprgraphics/color/Color.hpp>
10 #include <hyprland/src/Compositor.hpp>
11 #include <hyprland/src/config/ConfigManager.hpp>
12 #include <hyprland/src/desktop/DesktopTypes.hpp>
13@@ -22,21 +23,25 @@
14 #include "globals.hpp"
15 #include "render.hpp"
16
17+using Hyprgraphics::CColor;
18+
19 // This is a workaround CHyprColor not having working arithmetic operator...
20-static inline CHyprColor
21-merge_colors(float f1, CHyprColor c1, float f2, CHyprColor c2, float f3, CHyprColor c3) {
22- Hyprgraphics::CColor::SOkLab oklab_out;
23- float f[3] = {f1, f2, f3};
24- Hyprgraphics::CColor::SOkLab c[3] = {c1.asOkLab(), c2.asOkLab(), c3.asOkLab()};
25+template <typename... Args>
26+CHyprColor merge_colors(Args... colors) {
27+ auto merge_oklab = []<typename... Args2>(Args2... colors) {
28+ return CColor::SOkLab {
29+ .l = ((colors.first * colors.second.l) + ...),
30+ .a = ((colors.first * colors.second.a) + ...),
31+ .b = ((colors.first * colors.second.b) + ...),
32+ };
33+ };
34
35- oklab_out.l = c[0].l * f[0] + c[1].l * f[1] + c[2].l * f[2];
36- oklab_out.a = c[0].a * f[0] + c[1].a * f[1] + c[2].a * f[2];
37- oklab_out.b = c[0].b * f[0] + c[1].b * f[1] + c[2].b * f[2];
38- float alpha = c1.a * f[0] + c2.a * f[1] + c3.a * f[2];
39+ auto oklab = merge_oklab(std::make_pair(colors.first, colors.second.asOkLab())...);
40+ auto alpha = ((colors.first * colors.second.a) + ...);
41
42 // the alpha is linear, otherwise use the fact that CColor can take an OkLab and do the correct
43 // conversion to an rgb
44- return (CHyprColor(Hyprgraphics::CColor(oklab_out), alpha));
45+ return CHyprColor(Hyprgraphics::CColor(oklab), alpha);
46 }
47
48 Hy3TabBarEntry::Hy3TabBarEntry(Hy3TabBar& tab_bar, Hy3Node& node): tab_bar(tab_bar), node(node) {
49@@ -158,27 +163,10 @@ void Hy3TabBarEntry::render(float scale, CBox& box, float opacity_mul) {
50
51 auto radius = std::min((double) *s_radius * scale, std::min(box.width * 0.5, box.height * 0.5));
52
53- auto focused = this->focused->value();
54- auto urgent = this->urgent->value();
55- auto inactive = 1.0f - (focused + urgent);
56-
57- auto color = merge_colors(
58- focused,
59- CHyprColor(*col_active),
60- urgent,
61- CHyprColor(*col_urgent),
62- inactive,
63- CHyprColor(*col_inactive)
64- );
65+ auto color = this->mergeColors(*col_active, *col_urgent, *col_inactive);
66
67- auto border_color = merge_colors(
68- focused,
69- CHyprColor(*col_border_active),
70- urgent,
71- CHyprColor(*col_border_urgent),
72- inactive,
73- CHyprColor(*col_border_inactive)
74- );
75+ auto border_color =
76+ this->mergeColors(*col_border_active, *col_border_urgent, *col_border_inactive);
77
78 box.round();
79
80@@ -334,18 +322,7 @@ void Hy3TabBarEntry::renderText(float scale, CBox& box, float opacity) {
81
82 texture_box.round();
83
84- auto focused = this->focused->value();
85- auto urgent = this->urgent->value();
86- auto inactive = 1.0f - (focused + urgent);
87-
88- CHyprColor c = merge_colors(
89- focused,
90- CHyprColor(*col_text_active),
91- urgent,
92- CHyprColor(*col_text_urgent),
93- inactive,
94- CHyprColor(*col_text_inactive)
95- );
96+ auto c = mergeColors(*col_text_active, *col_text_urgent, *col_text_inactive);
97
98 glBlendFunc(GL_CONSTANT_COLOR, GL_ONE_MINUS_SRC_ALPHA);
99 glBlendColor(c.r, c.g, c.b, c.a);
100@@ -356,6 +333,22 @@ void Hy3TabBarEntry::renderText(float scale, CBox& box, float opacity) {
101 glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
102 }
103
104+CHyprColor Hy3TabBarEntry::mergeColors(
105diff --git a/src/TabGroup.hpp b/src/TabGroup.hpp
106index 28c7c043e6a2bb470b12333796d88b889478545a..06ea38dcf7440a6dc80dba99bfd49f1b78bc9578 100644
107--- a/src/TabGroup.hpp
108+++ b/src/TabGroup.hpp
109@@ -60,6 +60,8 @@ struct Hy3TabBarEntry {
110
111 private:
112 void renderText(float scale, CBox& box, float opacity);
113+ CHyprColor
114+ mergeColors(const CHyprColor& focused, const CHyprColor& urgent, const CHyprColor& inactive);
115 };
116
117 class Hy3TabBar {