Browse Source

Transition-end event, and fix Matrix3d primitive.

Michael 7 years ago
parent
commit
946e1f208e

+ 5 - 5
Include/Rocket/Core/TransformPrimitive.h

@@ -122,32 +122,32 @@ struct Matrix3D : public ResolvedPrimitive< 16 >
 struct TranslateX : public UnresolvedPrimitive< 1 >
 struct TranslateX : public UnresolvedPrimitive< 1 >
 {
 {
 	TranslateX(const NumericValue* values) noexcept : UnresolvedPrimitive(values) { }
 	TranslateX(const NumericValue* values) noexcept : UnresolvedPrimitive(values) { }
-	TranslateX(float x, Property::Unit unit) noexcept : UnresolvedPrimitive({ NumericValue{x, unit} }) { }
+	TranslateX(float x, Property::Unit unit = Property::PX) noexcept : UnresolvedPrimitive({ NumericValue{x, unit} }) { }
 };
 };
 
 
 struct TranslateY : public UnresolvedPrimitive< 1 >
 struct TranslateY : public UnresolvedPrimitive< 1 >
 {
 {
 	TranslateY(const NumericValue* values) noexcept : UnresolvedPrimitive(values) { }
 	TranslateY(const NumericValue* values) noexcept : UnresolvedPrimitive(values) { }
-	TranslateY(float y, Property::Unit unit) noexcept : UnresolvedPrimitive({ NumericValue(y, unit) }) { }
+	TranslateY(float y, Property::Unit unit = Property::PX) noexcept : UnresolvedPrimitive({ NumericValue(y, unit) }) { }
 };
 };
 
 
 struct TranslateZ : public UnresolvedPrimitive< 1 >
 struct TranslateZ : public UnresolvedPrimitive< 1 >
 {
 {
 	TranslateZ(const NumericValue* values) noexcept : UnresolvedPrimitive(values) { }
 	TranslateZ(const NumericValue* values) noexcept : UnresolvedPrimitive(values) { }
-	TranslateZ(float z, Property::Unit unit) noexcept : UnresolvedPrimitive({ NumericValue(z, unit) }) { }
+	TranslateZ(float z, Property::Unit unit = Property::PX) noexcept : UnresolvedPrimitive({ NumericValue(z, unit) }) { }
 };
 };
 
 
 struct Translate2D : public UnresolvedPrimitive< 2 >
 struct Translate2D : public UnresolvedPrimitive< 2 >
 {
 {
 	Translate2D(const NumericValue* values) noexcept : UnresolvedPrimitive(values) { }
 	Translate2D(const NumericValue* values) noexcept : UnresolvedPrimitive(values) { }
-	Translate2D(float x, float y, Property::Unit units) noexcept : UnresolvedPrimitive({ NumericValue(x, units), NumericValue(y, units) }) { }
+	Translate2D(float x, float y, Property::Unit units = Property::PX) noexcept : UnresolvedPrimitive({ NumericValue(x, units), NumericValue(y, units) }) { }
 };
 };
 
 
 struct Translate3D : public UnresolvedPrimitive< 3 >
 struct Translate3D : public UnresolvedPrimitive< 3 >
 {
 {
 	Translate3D(const NumericValue* values) noexcept : UnresolvedPrimitive(values) { }
 	Translate3D(const NumericValue* values) noexcept : UnresolvedPrimitive(values) { }
 	Translate3D(NumericValue x, NumericValue y, NumericValue z) noexcept : UnresolvedPrimitive({ x, y, z }) { }
 	Translate3D(NumericValue x, NumericValue y, NumericValue z) noexcept : UnresolvedPrimitive({ x, y, z }) { }
-	Translate3D(float x, float y, float z, Property::Unit units) noexcept : UnresolvedPrimitive({ NumericValue(x, units), NumericValue(y, units), NumericValue(z, units) }) { }
+	Translate3D(float x, float y, float z, Property::Unit units = Property::PX) noexcept : UnresolvedPrimitive({ NumericValue(x, units), NumericValue(y, units), NumericValue(z, units) }) { }
 };
 };
 
 
 struct ScaleX : public ResolvedPrimitive< 1 >
 struct ScaleX : public ResolvedPrimitive< 1 >

+ 6 - 4
Source/Core/Element.cpp

@@ -2480,19 +2480,21 @@ void Element::AdvanceAnimations()
 		auto it_completed = std::remove_if(animations.begin(), animations.end(), [](const ElementAnimation& animation) { return animation.IsComplete(); });
 		auto it_completed = std::remove_if(animations.begin(), animations.end(), [](const ElementAnimation& animation) { return animation.IsComplete(); });
 
 
 		std::vector<Dictionary> dictionary_list;
 		std::vector<Dictionary> dictionary_list;
+		std::vector<bool> is_transition;
 		dictionary_list.reserve(animations.end() - it_completed);
 		dictionary_list.reserve(animations.end() - it_completed);
+		is_transition.reserve(animations.end() - it_completed);
 
 
 		for (auto it = it_completed; it != animations.end(); ++it)
 		for (auto it = it_completed; it != animations.end(); ++it)
 		{
 		{
-			if(!it->IsTransition())
-				dictionary_list.emplace_back().Set("property", it->GetPropertyName());
+			dictionary_list.emplace_back().Set("property", it->GetPropertyName());
+			is_transition.push_back(it->IsTransition());
 		}
 		}
 
 
 		// Need to erase elements before submitting event, as iterators might be invalidated when calling external code.
 		// Need to erase elements before submitting event, as iterators might be invalidated when calling external code.
 		animations.erase(it_completed, animations.end());
 		animations.erase(it_completed, animations.end());
 
 
-		for (auto& dictionary : dictionary_list)
-			DispatchEvent(ANIMATIONEND, dictionary);
+		for (size_t i = 0; i < dictionary_list.size(); i++)
+			DispatchEvent(is_transition[i] ? TRANSITIONEND : ANIMATIONEND, dictionary_list[i]);
 	}
 	}
 }
 }
 
 

+ 1 - 0
Source/Core/StringCache.cpp

@@ -134,6 +134,7 @@ const String DRAGOUT = "dragout";
 const String DRAGEND = "dragend";
 const String DRAGEND = "dragend";
 const String RESIZE = "resize";
 const String RESIZE = "resize";
 const String ANIMATIONEND = "animationend";
 const String ANIMATIONEND = "animationend";
+const String TRANSITIONEND = "transitionend";
 
 
 }
 }
 }
 }

+ 1 - 0
Source/Core/StringCache.h

@@ -141,6 +141,7 @@ extern const String DRAGEND;
 extern const String DRAGOVER;
 extern const String DRAGOVER;
 extern const String RESIZE;
 extern const String RESIZE;
 extern const String ANIMATIONEND;
 extern const String ANIMATIONEND;
+extern const String TRANSITIONEND;
 
 
 }
 }
 }
 }

+ 1 - 1
Source/Core/TransformPrimitive.cpp

@@ -160,7 +160,7 @@ struct ResolveTransformVisitor
 
 
 	bool operator()(const Matrix3D& p)
 	bool operator()(const Matrix3D& p)
 	{
 	{
-		m = Matrix4f::FromRows(
+		m = Matrix4f::FromColumns(
 			Vector4f(p.values[0], p.values[1], p.values[2], p.values[3]),
 			Vector4f(p.values[0], p.values[1], p.values[2], p.values[3]),
 			Vector4f(p.values[4], p.values[5], p.values[6], p.values[7]),
 			Vector4f(p.values[4], p.values[5], p.values[6], p.values[7]),
 			Vector4f(p.values[8], p.values[9], p.values[10], p.values[11]),
 			Vector4f(p.values[8], p.values[9], p.values[10], p.values[11]),