2
0
Эх сурвалжийг харах

Fix an issue where some elements could end up rendered at the wrong offset after scrolling, see #230.

Modify Element::DirtyOffset so that all descendents are dirtied. It is possible that a child is dirty while a grandchild is not, eg. if the grandchild is hovered over thereby calling Element::GetAbsoluteOffset to resolve the offset *and* the grandchild's offset_parent is its grandparent. Then previously the grandchild would never be dirtied even when its grandparent was dirtied, which again would result in the wrong offset during Element::GetAbsoluteOffset.
Michael Ragazzon 4 жил өмнө
parent
commit
aac830ef82

+ 1 - 0
Include/RmlUi/Core/Element.h

@@ -656,6 +656,7 @@ private:
 	void SetDataModel(DataModel* new_data_model);
 
 	void DirtyOffset();
+	void DirtyOffsetRecursive();
 	void UpdateOffset();
 	void SetBaseline(float baseline);
 

+ 11 - 6
Source/Core/Element.cpp

@@ -2130,17 +2130,22 @@ void Element::SetParent(Element* _parent)
 
 void Element::DirtyOffset()
 {
-	if(!offset_dirty)
+	if (!offset_dirty)
+		DirtyOffsetRecursive();
+}
+
+void Element::DirtyOffsetRecursive()
+{
+	if (!offset_dirty)
 	{
 		offset_dirty = true;
 
-		if(transform_state)
+		if (transform_state)
 			DirtyTransformState(true, true);
-
-		// Not strictly true ... ?
-		for (size_t i = 0; i < children.size(); i++)
-			children[i]->DirtyOffset();
 	}
+
+	for (size_t i = 0; i < children.size(); i++)
+		children[i]->DirtyOffsetRecursive();
 }
 
 void Element::UpdateOffset()