Skip to content

Commit

Permalink
Merge pull request #159 from Lyatus/master
Browse files Browse the repository at this point in the history
Add method to reload ElementDocument's stylesheet, resolves #156
  • Loading branch information
mikke89 authored Dec 21, 2020
2 parents 1572783 + 01d821b commit b7ff498
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
2 changes: 2 additions & 0 deletions Include/RmlUi/Core/ElementDocument.h
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,8 @@ class RMLUICORE_API ElementDocument : public Element
void SetStyleSheet(SharedPtr<StyleSheet> style_sheet);
/// Returns the document's style sheet.
const SharedPtr<StyleSheet>& GetStyleSheet() const override;
/// Reload the document's style sheet from source files.
void ReloadStyleSheet();

/// Brings the document to the front of the document stack.
void PullToFront();
Expand Down
15 changes: 15 additions & 0 deletions Source/Core/ElementDocument.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,21 @@ const SharedPtr<StyleSheet>& ElementDocument::GetStyleSheet() const
return style_sheet;
}

// Reload the document's style sheet from source files.
void ElementDocument::ReloadStyleSheet()
{
auto stream = MakeUnique<StreamFile>();
if(!stream->Open(source_url))
return;

Factory::ClearStyleSheetCache();
ElementPtr temp_doc = Factory::InstanceDocumentStream(context, stream.get());
if(!temp_doc)
return;

SetStyleSheet(temp_doc->GetStyleSheet());
}

// Brings the document to the front of the document stack.
void ElementDocument::PullToFront()
{
Expand Down

0 comments on commit b7ff498

Please sign in to comment.