3e0800206839b6ff8b7f8e2728d5819158f656a7
- 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 eb8d7f9766ef414c6ee70a6e08e74c7f7aa605d9..0c48d48e0d9ab0d9762f7c17395652de283460bd 100644
3--- a/src/TabGroup.cpp
4+++ b/src/TabGroup.cpp
5@@ -27,16 +27,39 @@ Hy3TabBarEntry::Hy3TabBarEntry(Hy3TabBar& tab_bar, Hy3Node& node): tab_bar(tab_b
6 AVARDAMAGE_NONE
7 );
8
9+ this->vertical_pos.create(
10+ AVARTYPE_FLOAT,
11+ 1.0f,
12+ g_pConfigManager->getAnimationPropertyConfig("windowsIn"),
13+ nullptr,
14+ AVARDAMAGE_NONE
15+ );
16+
17+ this->fade_opacity.create(
18+ AVARTYPE_FLOAT,
19+ 0.0f,
20+ g_pConfigManager->getAnimationPropertyConfig("windowsIn"),
21+ nullptr,
22+ AVARDAMAGE_NONE
23+ );
24+
25 this->offset.registerVar();
26 this->width.registerVar();
27+ this->vertical_pos.registerVar();
28+ this->fade_opacity.registerVar();
29
30 auto update_callback = [this](void*) { this->tab_bar.dirty = true; };
31
32 this->offset.setUpdateCallback(update_callback);
33 this->width.setUpdateCallback(update_callback);
34+ this->vertical_pos.setUpdateCallback(update_callback);
35+ this->fade_opacity.setUpdateCallback(update_callback);
36
37 this->window_title = node.getTitle();
38 this->urgent = node.isUrgent();
39+
40+ this->vertical_pos = 0.0;
41+ this->fade_opacity = 1.0;
42 }
43
44 bool Hy3TabBarEntry::operator==(const Hy3Node& node) const { return this->node == node; }
45@@ -66,6 +89,22 @@ void Hy3TabBarEntry::setWindowTitle(std::string title) {
46 }
47 }
48
49+void Hy3TabBarEntry::beginDestroy() {
50+ this->destroying = true;
51+ this->vertical_pos = 1.0;
52+ this->fade_opacity = 0.0;
53+}
54+
55+void Hy3TabBarEntry::unDestroy() {
56+ this->destroying = false;
57+ this->vertical_pos = 0.0;
58+ this->fade_opacity = 1.0;
59+}
60+
61+bool Hy3TabBarEntry::shouldRemove() {
62+ return this->destroying && (this->vertical_pos.fl() == 1.0 || this->width.fl() == 0.0);
63+}
64+
65 void Hy3TabBarEntry::prepareTexture(float scale, wlr_box& box) {
66 // clang-format off
67 static const auto* s_rounding = &HyprlandAPI::getConfigValue(PHANDLE, "plugin:hy3:tabs:rounding")->intValue;
68@@ -225,39 +264,33 @@ void Hy3TabBarEntry::prepareTexture(float scale, wlr_box& box) {
69 }
70
71 Hy3TabBar::Hy3TabBar() {
72- this->vertical_pos.create(
73- AVARTYPE_FLOAT,
74- 1.0f,
75- g_pConfigManager->getAnimationPropertyConfig("windowsMove"),
76- nullptr,
77- AVARDAMAGE_NONE
78- );
79-
80 this->fade_opacity.create(
81 AVARTYPE_FLOAT,
82- 0.0f,
83+ 1.0f,
84 g_pConfigManager->getAnimationPropertyConfig("windowsMove"),
85 nullptr,
86 AVARDAMAGE_NONE
87 );
88
89- this->vertical_pos.registerVar();
90 this->fade_opacity.registerVar();
91+ this->fade_opacity.setUpdateCallback([this](void*) { this->dirty = true; });
92+}
93
94- auto update_callback = [this](void*) { this->dirty = true; };
95+void Hy3TabBar::beginDestroy() {
96+ for (auto& entry: this->entries) {
97+ entry.beginDestroy();
98+ }
99+}
100
101- this->vertical_pos.setUpdateCallback(update_callback);
102- this->fade_opacity.setUpdateCallback(update_callback);
103+void Hy3TabBar::tick() {
104+ auto iter = this->entries.begin();
105diff --git a/src/TabGroup.hpp b/src/TabGroup.hpp
106index dc12a00382c915efc2d1e13155ae13c3b2ed711e..5204ce54edab9b9ba3d6354d4240014ec9645a8b 100644
107--- a/src/TabGroup.hpp
108+++ b/src/TabGroup.hpp
109@@ -14,9 +14,12 @@ struct Hy3TabBarEntry {
110 std::string window_title;
111 bool focused = false;
112 bool urgent = false;
113+ bool destroying = false;
114 CTexture texture;
115- CAnimatedVariable offset; // offset 0, 0.0-1.0 of total bar
116- CAnimatedVariable width; // 0.0-1.0 of total bar
117+ CAnimatedVariable offset; // 0.0-1.0 of total bar
118+ CAnimatedVariable width; // 0.0-1.0 of total bar
119+ CAnimatedVariable vertical_pos; // 0.0-1.0, user specified direction
120+ CAnimatedVariable fade_opacity; // 0.0-1.0
121 Hy3TabBar& tab_bar;
122 Hy3Node& node; // only used for comparioson. do not deref.
123
124@@ -46,21 +49,23 @@ struct Hy3TabBarEntry {
125 void setFocused(bool);
126 void setUrgent(bool);
127 void setWindowTitle(std::string);
128+ void beginDestroy();
129+ void unDestroy();
130+ bool shouldRemove();
131 void prepareTexture(float, wlr_box&);
132 };
133
134 class Hy3TabBar {
135 public:
136 bool destroy = false;
137- bool destroying = false;
138 bool dirty = true;
139 bool damaged = true;
140- CAnimatedVariable vertical_pos;
141 CAnimatedVariable fade_opacity;
142
143 Hy3TabBar();
144 void beginDestroy();
145
146+ void tick();
147 void updateNodeList(std::list<Hy3Node*>& nodes);
148 void updateAnimations(bool warp = false);
149 void setSize(Vector2D);