Browse Source

Make the <img> element load the texture once attached to the document. (It still won't actually be compiled until it is rendered). This allows listing and pre-fetching all image sources in the document, even if they are not displayed yet. See #131.

Michael Ragazzon 5 years ago
parent
commit
2e9503f5d8
3 changed files with 17 additions and 1 deletions
  1. 9 0
      Source/Core/Elements/ElementImage.cpp
  2. 3 0
      Source/Core/Elements/ElementImage.h
  3. 5 1
      changelog.md

+ 9 - 0
Source/Core/Elements/ElementImage.cpp

@@ -138,6 +138,15 @@ void ElementImage::OnPropertyChange(const PropertyIdSet& changed_properties)
     }
 }
 
+void ElementImage::OnChildAdd(Element* child)
+{
+	if (child == this && texture_dirty)
+	{
+		// Load the texture once we have attached to the document
+		LoadTexture();
+	}
+}
+
 // Regenerates the element's geometry.
 void ElementImage::OnResize()
 {

+ 3 - 0
Source/Core/Elements/ElementImage.h

@@ -90,6 +90,9 @@ protected:
 	/// @param[in] changed_properties The properties changed on the element.
 	void OnPropertyChange(const PropertyIdSet& changed_properties) override;
 
+	/// Detect when we have been added to the document.
+	void OnChildAdd(Element* child) override;
+
 private:
 	// Generates the element's geometry.
 	void GenerateGeometry();

+ 5 - 1
changelog.md

@@ -107,6 +107,10 @@ Use the RCSS `display` property to enable table formatting. See the stylesheet r
 - Implemented the `word-break` RCSS property.
 - Implemented the `box-sizing` RCSS property.
 
+### New RML elements
+
+- Added [Lottie plugin](https://mikke89.github.io/RmlUiDoc/pages/cpp_manual/lottie.html) for displaying vector animations using the `<lottie>` element [#134](https://github.com/mikke89/RmlUi/pull/134) (thanks @diamondhat).
+
 ### Other features and improvements
 
 - Implemented `Element::QuerySelector` and `Element::QuerySelectorAll`.
@@ -118,7 +122,7 @@ Use the RCSS `display` property to enable table formatting. See the stylesheet r
 - Fixed several compilation issues and warnings. [#118](https://github.com/mikke89/RmlUi/issues/118) [#97](https://github.com/mikke89/RmlUi/pull/97) (thanks @SpaceCat-Chan).
 - Debugger improvements: Sort property names alphabetically. Fix a bug where the outlines would draw underneath the document.
 - Tabs and panels in tab sets will no longer set the `display` property to `inline-block`, thus it is now possible to customize the display property.
-- [Lottie plugin](https://mikke89.github.io/RmlUiDoc/pages/cpp_manual/lottie.html) added for displaying vector animations [#134](https://github.com/mikke89/RmlUi/pull/134) (thanks @diamondhat).
+- Add `Rml::GetTextureSourceList()` function to list all image sources loaded in all documents. [#131](https://github.com/mikke89/RmlUi/issues/131)
 
 ### Bug fixes