f94c5d75ae90ce738dfaae43fdb7254ce3074523
- 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 bf315a7b00c79c1a2cea00d5e6ca9fef70806f23..1dab1d0c7e1a3feb9e8032fabaaaa3299a6b2552 100644
3--- a/src/TabGroup.cpp
4+++ b/src/TabGroup.cpp
5@@ -119,152 +119,127 @@ bool Hy3TabBarEntry::shouldRemove() {
6 return this->destroying && (this->vertical_pos.value() == 1.0 || this->width.value() == 0.0);
7 }
8
9-void Hy3TabBarEntry::prepareTexture(float scale, CBox& box) {
10- // clang-format off
11+void Hy3TabBarEntry::render(float scale, CBox& box, float opacity_mul) {
12+ auto opacity = opacity_mul * this->fade_opacity.value();
13+
14 static const auto s_rounding = ConfigValue<Hyprlang::INT>("plugin:hy3:tabs:rounding");
15+ static const auto col_active = ConfigValue<Hyprlang::INT>("plugin:hy3:tabs:col.active");
16+ static const auto col_urgent = ConfigValue<Hyprlang::INT>("plugin:hy3:tabs:col.urgent");
17+ static const auto col_inactive = ConfigValue<Hyprlang::INT>("plugin:hy3:tabs:col.inactive");
18+
19+ auto rounding =
20+ std::min((double) *s_rounding * scale, std::min(box.width * 0.5, box.height * 0.5));
21+
22+ auto focused = this->focused.value();
23+ auto urgent = this->urgent.value();
24+ auto inactive = 1.0f - (focused + urgent);
25+ CHyprColor c = merge_colors(
26+ focused,
27+ CHyprColor(*col_active),
28+ urgent,
29+ CHyprColor(*col_urgent),
30+ inactive,
31+ CHyprColor(*col_inactive)
32+ );
33+
34+ c.a *= opacity;
35+
36+ g_pHyprOpenGL->renderRect(&box, c, rounding);
37+ this->renderText(scale, box, opacity);
38+}
39+
40+void Hy3TabBarEntry::renderText(float scale, CBox& box, float opacity) {
41+ // clang-format off
42 static const auto render_text = ConfigValue<Hyprlang::INT>("plugin:hy3:tabs:render_text");
43 static const auto text_center = ConfigValue<Hyprlang::INT>("plugin:hy3:tabs:text_center");
44 static const auto text_font = ConfigValue<Hyprlang::STRING>("plugin:hy3:tabs:text_font");
45 static const auto text_height = ConfigValue<Hyprlang::INT>("plugin:hy3:tabs:text_height");
46 static const auto text_padding = ConfigValue<Hyprlang::INT>("plugin:hy3:tabs:text_padding");
47- static const auto col_active = ConfigValue<Hyprlang::INT>("plugin:hy3:tabs:col.active");
48- static const auto col_urgent = ConfigValue<Hyprlang::INT>("plugin:hy3:tabs:col.urgent");
49- static const auto col_inactive = ConfigValue<Hyprlang::INT>("plugin:hy3:tabs:col.inactive");
50 static const auto col_text_active = ConfigValue<Hyprlang::INT>("plugin:hy3:tabs:col.text.active");
51 static const auto col_text_urgent = ConfigValue<Hyprlang::INT>("plugin:hy3:tabs:col.text.urgent");
52 static const auto col_text_inactive = ConfigValue<Hyprlang::INT>("plugin:hy3:tabs:col.text.inactive");
53 // clang-format on
54
55- auto width = box.width;
56- auto height = box.height;
57+ if (!*render_text) {
58+ if (this->texture) this->texture.reset();
59+ return;
60+ }
61
62- auto rounding = std::min((double) *s_rounding * scale, std::min(width * 0.5, height * 0.5));
63+ auto padding = *text_padding * scale;
64+ auto width = box.width - padding * 2;
65
66- if (this->texture->m_iTexID == 0
67+ if (!this->texture
68 // clang-format off
69- || this->last_render.x != box.x
70- || this->last_render.y != box.y
71- || this->last_render.focused != this->focused.value()
72- || this->last_render.urgent != this->urgent.value()
73 || this->last_render.window_title != this->window_title
74- || this->last_render.rounding != rounding
75 || this->last_render.text_font != *text_font
76- || this->last_render.text_height != *text_height
77- || this->last_render.text_padding != *text_padding
78- || this->last_render.col_active != *col_active
79- || this->last_render.col_urgent != *col_urgent
80- || this->last_render.col_inactive != *col_inactive
81- || this->last_render.col_text_active != *col_text_active
82- || this->last_render.col_text_urgent != *col_text_urgent
83- || this->last_render.col_text_inactive != *col_text_inactive
84+ || this->last_render.font_height != *text_height
85+ || this->last_render.scale != scale
86 // clang-format on
87- )
88+ // If render width was smaller than full render width and size changed,
89+ // the text is probably ellipsized and needs to be recalculated.
90+ || (width != this->last_render.render_width
91+ && (width < this->last_render.full_logical_width
92+ || this->last_render.logical_width != this->last_render.full_logical_width)))
93 {
94- this->last_render.x = box.x;
95- this->last_render.y = box.y;
96- this->last_render.focused = this->focused.value();
97- this->last_render.urgent = this->urgent.value();
98 this->last_render.window_title = this->window_title;
99- this->last_render.rounding = rounding;
100 this->last_render.text_font = *text_font;
101- this->last_render.text_height = *text_height;
102- this->last_render.text_padding = *text_padding;
103- this->last_render.col_active = *col_active;
104- this->last_render.col_urgent = *col_urgent;
105diff --git a/src/TabGroup.hpp b/src/TabGroup.hpp
106index d31cd2b6088041e308fd015482c4b3eaf3a94c80..9e85e9dbade38e35398d6db8517fe527d1767173 100644
107--- a/src/TabGroup.hpp
108+++ b/src/TabGroup.hpp
109@@ -8,8 +8,8 @@ class Hy3TabBar;
110 #include <vector>
111
112 #include <hyprland/src/plugins/PluginAPI.hpp>
113-#include <hyprland/src/render/Texture.hpp>
114 #include <hyprland/src/render/Renderer.hpp>
115+#include <hyprland/src/render/Texture.hpp>
116
117 #include "Hy3Node.hpp"
118
119@@ -27,22 +27,21 @@ struct Hy3TabBarEntry {
120 Hy3Node& node; // only used for comparioson. do not deref.
121
122 struct {
123- int x, y;
124- float rounding = 0.0;
125 float scale = 0.0;
126- float focused = 0.0;
127- float urgent = 0.0;
128 std::string window_title;
129+ int full_logical_width = 0;
130+ float render_width = 0;
131
132 std::string text_font;
133- int text_height = 0;
134- int text_padding = 0;
135- int col_active = 0;
136- int col_urgent = 0;
137- int col_inactive = 0;
138- int col_text_active = 0;
139- int col_text_urgent = 0;
140- int col_text_inactive = 0;
141+ int font_height = 0;
142+
143+ int texture_x_offset = 0;
144+ int texture_y_offset = 0;
145+ int texture_width = 0;
146+ int texture_height = 0;
147+
148+ int logical_width = 0;
149+ int logical_height = 0;
150 } last_render;
151
152 Hy3TabBarEntry(Hy3TabBar&, Hy3Node&);
153@@ -55,7 +54,10 @@ struct Hy3TabBarEntry {
154 void beginDestroy();
155 void unDestroy();
156 bool shouldRemove();
157- void prepareTexture(float, CBox&);
158+ void render(float scale, CBox& box, float opacity_mul);
159+
160+private:
161+ void renderText(float scale, CBox& box, float opacity);
162 };
163
164 class Hy3TabBar {