Skip to content

Commit

Permalink
Add a function that enables all the variables in a data model to be m…
Browse files Browse the repository at this point in the history
…arked dirty (#289)
  • Loading branch information
EhWhoAmI authored Mar 6, 2022
1 parent 7dcd9c4 commit 48aacad
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 0 deletions.
1 change: 1 addition & 0 deletions Include/RmlUi/Core/DataModelHandle.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ class RMLUICORE_API DataModelHandle {

bool IsVariableDirty(const String& variable_name);
void DirtyVariable(const String& variable_name);
void DirtyAllVariables();

explicit operator bool() { return model; }

Expand Down
7 changes: 7 additions & 0 deletions Source/Core/DataModel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -341,6 +341,13 @@ bool DataModel::IsVariableDirty(const String& variable_name) const
return dirty_variables.count(variable_name) == 1;
}

void DataModel::DirtyAllVariables() {
dirty_variables.reserve(variables.size());
for (const auto& variable : variables) {
dirty_variables.emplace(variable.first);
}
}

bool DataModel::CallTransform(const String& name, Variant& inout_result, const VariantList& arguments) const
{
if (transform_register)
Expand Down
1 change: 1 addition & 0 deletions Source/Core/DataModel.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ class DataModel : NonCopyMoveable {

void DirtyVariable(const String& variable_name);
bool IsVariableDirty(const String& variable_name) const;
void DirtyAllVariables();

bool CallTransform(const String& name, Variant& inout_result, const VariantList& arguments) const;

Expand Down
4 changes: 4 additions & 0 deletions Source/Core/DataModelHandle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@ void DataModelHandle::DirtyVariable(const String& variable_name) {
model->DirtyVariable(variable_name);
}

void DataModelHandle::DirtyAllVariables() {
model->DirtyAllVariables();
}


DataModelConstructor::DataModelConstructor() : model(nullptr), type_register(nullptr) {}

Expand Down

0 comments on commit 48aacad

Please sign in to comment.