Browse Source

Progressbar elements now take the 'fill-image' property on itself, instead of its inner fill element (breaking change). This fixes a bug where changing the 'fill-image' property had no effect.

Michael Ragazzon 5 years ago
parent
commit
dcf7ae6ef2

+ 0 - 1
Include/RmlUi/Core/Elements/ElementProgressBar.h

@@ -104,7 +104,6 @@ private:
 
 	// The texture this element is rendering from if the 'fill-image' property is set.
 	Texture texture;
-	bool texture_dirty;
 
 	// The rectangle extracted from a sprite, 'rect_set' controls whether it is active.
 	Rectangle rect;

+ 0 - 2
Samples/basic/demo/data/demo.rml

@@ -458,8 +458,6 @@ progressbar {
 	decorator: image( gauge );
 	width: 100px;
 	height: 86px;
-}
-#gauge fill { 
 	fill-image: gauge-fill;
 }
 #progress_horizontal { 

+ 6 - 7
Source/Core/Elements/ElementProgressBar.cpp

@@ -42,7 +42,6 @@ namespace Rml {
 ElementProgressBar::ElementProgressBar(const String& tag) : Element(tag), direction(DefaultDirection), start_edge(DefaultStartEdge), value(0), fill(nullptr), rect_set(false), geometry(this)
 {
 	geometry_dirty = false;
-	texture_dirty = true;
 
 	// Add the fill element as a non-DOM element.
 	ElementPtr fill_element = Factory::InstanceElement(this, "*", "fill", XMLAttributes());
@@ -129,7 +128,7 @@ void ElementProgressBar::OnPropertyChange(const PropertyIdSet& changed_propertie
     }
 
 	if (changed_properties.Contains(PropertyId::FillImage)) {
-		texture_dirty = true;
+		LoadTexture();
 	}
 }
 
@@ -161,6 +160,10 @@ void ElementProgressBar::OnResize()
 
 void ElementProgressBar::GenerateGeometry()
 {
+	// Warn the user when using the old approach of adding the 'fill-image' property to the 'fill' element.
+	if (const Property* property = fill->GetLocalProperty(PropertyId::FillImage))
+		Log::Message(Log::LT_WARNING, "Breaking change: The 'fill-image' property now needs to be set on the <progressbar> element, instead of its inner <fill> element. Please update your RCSS source to fix progress bars in this document.");
+
 	Vector2f render_size = fill_size;
 
 	{
@@ -197,9 +200,6 @@ void ElementProgressBar::GenerateGeometry()
 		fill->SetOffset(offset, this);
 	}
 
-	if (texture_dirty)
-		LoadTexture();
-
 	geometry.Release(true);
 	geometry_dirty = false;
 
@@ -332,13 +332,12 @@ void ElementProgressBar::GenerateGeometry()
 
 bool ElementProgressBar::LoadTexture()
 {
-	texture_dirty = false;
 	geometry_dirty = true;
 	rect_set = false;
 
 	String name;
 
-	if (auto property = fill->GetLocalProperty(PropertyId::FillImage))
+	if (const Property* property = GetLocalProperty(PropertyId::FillImage))
 		name = property->Get<String>();
 
 	ElementDocument* document = GetOwnerDocument();

+ 2 - 1
changelog.md

@@ -123,6 +123,7 @@ Use the RCSS `display` property to enable table formatting. See the stylesheet r
 ### Bug fixes
 
 - Fix some situations where `text-decoration` would not be rendered. [#119](https://github.com/mikke89/RmlUi/issues/119).
+- Changing the `fill-image` property of \<progressbar\> elements now actually updates the image.
 
 ### Breaking changes
 
@@ -133,7 +134,7 @@ Use the RCSS `display` property to enable table formatting. See the stylesheet r
 - The `BaseXMLParser` class has some minor interface changes.
 - Tab set elements `tab` and `panel` should now have their `display` property set in the RCSS document, use `display: inline-block` for the same behavior as before.
 - For custom, replaced elements: `Element::GetIntrinsicDimensions()` now additionally takes an intrinsic ratio parameter.
-
+- The `fill-image` property should now be applied to the \<progressbar\> element instead of its inner \<fill\> element.
 
 
 ## RmlUi 3.3