b2e94fcd44c1e37622b82487933e07254f8d6549

Author
myamusashi <jinxprogilang666@gmail.com>
Committer
myamusashi <jinxprogilang666@gmail.com>
Date

Message

Change animation property

Diff

This diff is truncated to protect this page.

  1diff --git a/src/Hy3Layout.cpp b/src/Hy3Layout.cpp
  2index 519e6acc7790e64c4728b75aac1a00e272998ce6..375877df4f8bc24f3cb219ff0177c43a51c668a7 100644
  3--- a/src/Hy3Layout.cpp
  4+++ b/src/Hy3Layout.cpp
  5@@ -504,10 +504,10 @@ void Hy3Layout::resizeActiveWindow(const Vector2D& delta, eRectCorner corner, PH
  6 	} else if (window->m_bIsFloating) {
  7 		// No parent node - is this a floating window?  If so, use the same logic as the `main` layout
  8 		const auto required_size = Vector2D(
  9-		    std::max((window->m_vRealSize.goal() + delta).x, 20.0),
 10-		    std::max((window->m_vRealSize.goal() + delta).y, 20.0)
 11+		    std::max((window->m_vRealSize->goal() + delta).x, 20.0),
 12+		    std::max((window->m_vRealSize->goal() + delta).y, 20.0)
 13 		);
 14-		window->m_vRealSize = required_size;
 15+		*window->m_vRealSize = required_size;
 16 	}
 17 }
 18 
 19@@ -531,23 +531,23 @@ void Hy3Layout::fullscreenRequestForWindow(
 20 			this->applyNodeDataToWindow(node);
 21 		} else {
 22 			// restore floating position if not
 23-			window->m_vRealPosition = window->m_vLastFloatingPosition;
 24-			window->m_vRealSize = window->m_vLastFloatingSize;
 25+			*window->m_vRealPosition = window->m_vLastFloatingPosition;
 26+			*window->m_vRealSize = window->m_vLastFloatingSize;
 27 
 28 			window->unsetWindowData(PRIORITY_LAYOUT);
 29 		}
 30 	} else {
 31 		// save position and size if floating
 32 		if (window->m_bIsFloating) {
 33-			window->m_vLastFloatingPosition = window->m_vRealPosition.goal();
 34-			window->m_vPosition = window->m_vRealPosition.goal();
 35-			window->m_vLastFloatingSize = window->m_vRealSize.goal();
 36-			window->m_vSize = window->m_vRealSize.goal();
 37+			window->m_vLastFloatingPosition = window->m_vRealPosition->goal();
 38+			window->m_vPosition = window->m_vRealPosition->goal();
 39+			window->m_vLastFloatingSize = window->m_vRealSize->goal();
 40+			window->m_vSize = window->m_vRealSize->goal();
 41 		}
 42 
 43 		if (target_mode == FSMODE_FULLSCREEN) {
 44-			window->m_vRealPosition = monitor->vecPosition;
 45-			window->m_vRealSize = monitor->vecSize;
 46+			*window->m_vRealPosition = monitor->vecPosition;
 47+			*window->m_vRealSize = monitor->vecSize;
 48 		} else {
 49 			// Copy of vaxry's massive hack
 50 
 51@@ -1212,15 +1212,15 @@ Hy3Node* findTabBarAt(Hy3Node& node, Vector2D pos, Hy3Node** focused_node) {
 52 				auto& children = group.children;
 53 				auto& tab_bar = *group.tab_bar;
 54 
 55-				auto size = tab_bar.size.value();
 56-				auto x = pos.x - tab_bar.pos.value().x;
 57+				auto size = tab_bar.size->value();
 58+				auto x = pos.x - tab_bar.pos->value().x;
 59 				auto child_iter = children.begin();
 60 
 61 				for (auto& tab: tab_bar.bar.entries) {
 62 					if (child_iter == children.end()) break;
 63 
 64-					if (x > tab.offset.value() * size.x
 65-					    && x < (tab.offset.value() + tab.width.value()) * size.x)
 66+					if (x > tab.offset->value() * size.x
 67+					    && x < (tab.offset->value() + tab.width->value()) * size.x)
 68 					{
 69 						*focused_node = *child_iter;
 70 						return &node;
 71@@ -1646,24 +1646,24 @@ void Hy3Layout::applyNodeDataToWindow(Hy3Node* node, bool no_animation) {
 72 
 73 		const auto reserved = window->getFullWindowReservedArea();
 74 
 75-		window->m_vRealPosition = window->m_vPosition + reserved.topLeft;
 76-		window->m_vRealSize = window->m_vSize - (reserved.topLeft + reserved.bottomRight);
 77+		*window->m_vRealPosition = window->m_vPosition + reserved.topLeft;
 78+		*window->m_vRealSize = window->m_vSize - (reserved.topLeft + reserved.bottomRight);
 79 
 80-		g_pXWaylandManager->setWindowSize(window, window->m_vRealSize.goal());
 81+		g_pXWaylandManager->setWindowSize(window, window->m_vRealSize->goal());
 82 	} else {
 83 		auto reserved = window->getFullWindowReservedArea();
 84 		auto wb = node->getStandardWindowArea({-reserved.topLeft, -reserved.bottomRight});
 85 
 86-		window->m_vRealPosition = wb.pos();
 87-		window->m_vRealSize = wb.size();
 88+		*window->m_vRealPosition = wb.pos();
 89+		*window->m_vRealSize = wb.size();
 90 
 91 		g_pXWaylandManager->setWindowSize(window, wb.size());
 92 
 93 		if (no_animation) {
 94 			g_pHyprRenderer->damageWindow(window);
 95 
 96-			window->m_vRealPosition.warp();
 97-			window->m_vRealSize.warp();
 98+			window->m_vRealPosition->warp();
 99+			window->m_vRealSize->warp();
100 
101 			g_pHyprRenderer->damageWindow(window);
102 		}
103diff --git a/src/Hy3Node.cpp b/src/Hy3Node.cpp
104index 1766e93a439d376e8dec67507ec84d290169bd0d..5bede0d2878025cea4df72c77c85d8777ed66b82 100644
105--- a/src/Hy3Node.cpp
106+++ b/src/Hy3Node.cpp
107@@ -325,8 +325,8 @@ void Hy3Node::recalcSizePosRecursive(bool no_animation) {
108 		auto monitor = this->workspace->m_pMonitor.lock();
109 
110 		if (window->isEffectiveInternalFSMode(FSMODE_FULLSCREEN)) {
111-			window->m_vRealPosition = monitor->vecPosition;
112-			window->m_vRealSize = monitor->vecSize;
113+			*window->m_vRealPosition = monitor->vecPosition;
114+			*window->m_vRealSize = monitor->vecSize;
115 			return;
116 		}
117 
118diff --git a/src/TabGroup.cpp b/src/TabGroup.cpp
119index c9ac3250bb2ca53b47e20fa5ca8cf5c57a87e238..da6438b911b728352d79938cc3ec6dc69ee9148e 100644
120--- a/src/TabGroup.cpp
121+++ b/src/TabGroup.cpp
122@@ -36,45 +36,62 @@ merge_colors(float f1, CHyprColor c1, float f2, CHyprColor c2, float f3, CHyprCo
123 }
124 
125 Hy3TabBarEntry::Hy3TabBarEntry(Hy3TabBar& tab_bar, Hy3Node& node): tab_bar(tab_bar), node(node) {
126-	this->focused
127-	    .create(0.0f, g_pConfigManager->getAnimationPropertyConfig("fadeSwitch"), AVARDAMAGE_NONE);
128-
129-	this->urgent
130-	    .create(0.0f, g_pConfigManager->getAnimationPropertyConfig("fadeSwitch"), AVARDAMAGE_NONE);
131+	g_pAnimationManager->createAnimation(
132+	    0.0F,
133+	    this->focused,
134+	    g_pConfigManager->getAnimationPropertyConfig("fadeSwitch"),
135+	    AVARDAMAGE_NONE
136+	);
137 
138-	this->offset
139-	    .create(-1.0f, g_pConfigManager->getAnimationPropertyConfig("windowsMove"), AVARDAMAGE_NONE);
140+	g_pAnimationManager->createAnimation(
141+	    0.0F,
142+	    this->urgent,
143+	    g_pConfigManager->getAnimationPropertyConfig("fadeSwitch"),
144+	    AVARDAMAGE_NONE
145+	);
146 
147-	this->width
148-	    .create(-1.0f, g_pConfigManager->getAnimationPropertyConfig("windowsMove"), AVARDAMAGE_NONE);
149+	g_pAnimationManager->createAnimation(
150+	    -1.0F,
151+	    this->offset,
152+	    g_pConfigManager->getAnimationPropertyConfig("windowsMove"),
153+	    AVARDAMAGE_NONE
154+	);
155 
156-	this->vertical_pos
157-	    .create(1.0f, g_pConfigManager->getAnimationPropertyConfig("windowsMove"), AVARDAMAGE_NONE);
158+	g_pAnimationManager->createAnimation(
159+	    -1.0F,
160+	    this->width,
161+	    g_pConfigManager->getAnimationPropertyConfig("windowsMove"),
162+	    AVARDAMAGE_NONE
163+	);
164 
165-	this->fade_opacity
166-	    .create(0.0f, g_pConfigManager->getAnimationPropertyConfig("windowsMove"), AVARDAMAGE_NONE);
167+	g_pAnimationManager->createAnimation(
168+	    1.0F,
169+	    this->vertical_pos,
170+	    g_pConfigManager->getAnimationPropertyConfig("windowsMove"),
171+	    AVARDAMAGE_NONE
172+	);
173 
174-	this->focused.registerVar();
175-	this->urgent.registerVar();
176-	this->offset.registerVar();
177-	this->width.registerVar();
178-	this->vertical_pos.registerVar();
179-	this->fade_opacity.registerVar();
180+	g_pAnimationManager->createAnimation(
181+	    0.0F,
182+	    this->fade_opacity,
183+	    g_pConfigManager->getAnimationPropertyConfig("windowsMove"),
184+	    AVARDAMAGE_NONE
185+	);
186 
187-	auto update_callback = [this](void*) { this->tab_bar.dirty = true; };
188+	auto update_callback = [this](auto) { this->tab_bar.dirty = true; };
189 
190-	this->focused.setUpdateCallback(update_callback);
191-	this->urgent.setUpdateCallback(update_callback);
192-	this->offset.setUpdateCallback(update_callback);
193-	this->width.setUpdateCallback(update_callback);
194-	this->vertical_pos.setUpdateCallback(update_callback);
195-	this->fade_opacity.setUpdateCallback(update_callback);
196+	this->focused->setUpdateCallback(update_callback);
197+	this->urgent->setUpdateCallback(update_callback);
198+	this->offset->setUpdateCallback(update_callback);
199+	this->width->setUpdateCallback(update_callback);
200+	this->vertical_pos->setUpdateCallback(update_callback);
201+	this->fade_opacity->setUpdateCallback(update_callback);
202 
203 	this->window_title = node.getTitle();
204-	this->urgent = node.isUrgent();
205+	*this->urgent = node.isUrgent();
206 
207-	this->vertical_pos = 0.0;
208-	this->fade_opacity = 1.0;
209+	*this->vertical_pos = 0.0;
210+	*this->fade_opacity = 1.0;
211 }
212 
213 bool Hy3TabBarEntry::operator==(const Hy3Node& node) const { return this->node == node; }
214@@ -84,15 +101,15 @@ bool Hy3TabBarEntry::operator==(const Hy3TabBarEntry& entry) const {
215 }
216 
217 void Hy3TabBarEntry::setFocused(bool focused) {
218-	if (this->focused.goal() != focused) {
219-		this->focused = focused;
220+	if (this->focused->goal() != focused) {
221+		*this->focused = focused;
222diff --git a/src/TabGroup.hpp b/src/TabGroup.hpp
223index 9e85e9dbade38e35398d6db8517fe527d1767173..b05a43d7fb09ecb1f35046bf8d9f814309f178fc 100644
224--- a/src/TabGroup.hpp
225+++ b/src/TabGroup.hpp
226@@ -17,12 +17,12 @@ struct Hy3TabBarEntry {
227 	std::string window_title;
228 	bool destroying = false;
229 	SP<CTexture> texture;
230-	CAnimatedVariable<float> focused;
231-	CAnimatedVariable<float> urgent;
232-	CAnimatedVariable<float> offset;       // 0.0-1.0 of total bar
233-	CAnimatedVariable<float> width;        // 0.0-1.0 of total bar
234-	CAnimatedVariable<float> vertical_pos; // 0.0-1.0, user specified direction
235-	CAnimatedVariable<float> fade_opacity; // 0.0-1.0
236+	PHLANIMVAR<float> focused;
237+	PHLANIMVAR<float> urgent;
238+	PHLANIMVAR<float> offset;       // 0.0-1.0 of total bar
239+	PHLANIMVAR<float> width;        // 0.0-1.0 of total bar
240+	PHLANIMVAR<float> vertical_pos; // 0.0-1.0, user specified direction
241+	PHLANIMVAR<float> fade_opacity; // 0.0-1.0
242 	Hy3TabBar& tab_bar;
243 	Hy3Node& node; // only used for comparioson. do not deref.
244 
245@@ -65,7 +65,7 @@ public:
246 	bool destroy = false;
247 	bool dirty = true;
248 	bool damaged = true;
249-	CAnimatedVariable<float> fade_opacity;
250+	PHLANIMVAR<float> fade_opacity;
251 
252 	Hy3TabBar();
253 	void beginDestroy();
254@@ -105,8 +105,8 @@ public:
255 	PHLWORKSPACE workspace = nullptr;
256 	bool hidden = false;
257 	Hy3TabBar bar;
258-	CAnimatedVariable<Vector2D> pos;
259-	CAnimatedVariable<Vector2D> size;
260+	PHLANIMVAR<Vector2D> pos;
261+	PHLANIMVAR<Vector2D> size;
262 
263 	// initialize a group with the given node. UB if node is not a group.
264 	Hy3TabGroup(Hy3Node&);