Skip to content

Commit

Permalink
Make the <img> element load the texture once attached to the document…
Browse files Browse the repository at this point in the history
…. (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.
  • Loading branch information
mikke89 committed Oct 19, 2020
1 parent dcf7ae6 commit 2e9503f
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 1 deletion.
9 changes: 9 additions & 0 deletions Source/Core/Elements/ElementImage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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()
{
Expand Down
3 changes: 3 additions & 0 deletions Source/Core/Elements/ElementImage.h
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,9 @@ class RMLUICORE_API ElementImage : public Element
/// @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();
Expand Down
6 changes: 5 additions & 1 deletion changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`.
Expand All @@ -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

Expand Down

0 comments on commit 2e9503f

Please sign in to comment.