Enable animation for Text Run style prop <img width="262" alt="CleanShot 2023-08-01 at 10 17 31@2x" src="https://github.com/rive-app/rive/assets/8057513/ee375ef9-7a23-418b-81a2-6f38bc102200"> Diffs= da909105a Enable animation for Text Run style prop (#5726) Co-authored-by: Alex Gibson <agibson.uk@gmail.com> Co-authored-by: Luigi Rosso <luigi.rosso@gmail.com>
diff --git a/.rive_head b/.rive_head index 89affb8..b9d3c3b 100644 --- a/.rive_head +++ b/.rive_head
@@ -1 +1 @@ -b69ae131259dd46e67c0be905b86b89d4f2ad20e +da909105ad9ad42fc9245fc2ae05ac10f6bca41c
diff --git a/dev/defs/text/text_value_run.json b/dev/defs/text/text_value_run.json index be4ee8c..0dae240 100644 --- a/dev/defs/text/text_value_run.json +++ b/dev/defs/text/text_value_run.json
@@ -11,6 +11,7 @@ "typeRuntime": "uint", "initialValue": "Core.missingId", "initialValueRuntime": "-1", + "animates": true, "key": { "int": 272, "string": "styleid" @@ -28,4 +29,4 @@ "description": "The text string value." } } -} \ No newline at end of file +}
diff --git a/include/rive/text/text_value_run.hpp b/include/rive/text/text_value_run.hpp index 5583f13..3bdca17 100644 --- a/include/rive/text/text_value_run.hpp +++ b/include/rive/text/text_value_run.hpp
@@ -15,6 +15,7 @@ protected: void textChanged() override; + void styleIdChanged() override; private: TextStyle* m_style = nullptr;
diff --git a/src/text/text_value_run.cpp b/src/text/text_value_run.cpp index 8e2b7fb..f46c83b 100644 --- a/src/text/text_value_run.cpp +++ b/src/text/text_value_run.cpp
@@ -2,6 +2,7 @@ #include "rive/text/text.hpp" #include "rive/text/text_style.hpp" #include "rive/text/text_value_run.hpp" +#include "rive/artboard.hpp" using namespace rive; @@ -42,6 +43,16 @@ return StatusCode::Ok; } +void TextValueRun::styleIdChanged() +{ + auto coreObject = artboard()->resolve(styleId()); + if (coreObject != nullptr && coreObject->is<TextStyle>()) + { + m_style = static_cast<TextStyle*>(coreObject); + parent()->as<Text>()->markShapeDirty(); + } +} + uint32_t TextValueRun::offset() const { #ifdef WITH_RIVE_TEXT