-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding booleans to the list of view model primitives Diffs= e66e242c6 Xxxx databinding add boolean (#7456) Co-authored-by: hernan <[email protected]>
- Loading branch information
Showing
14 changed files
with
268 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
9cd8759a02aaa45684e80a8d77671c1536ab387d | ||
e66e242c649e3e61f12a3adbd824bcd9a7525a53 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
{ | ||
"name": "ViewModelInstanceBoolean", | ||
"key": { | ||
"int": 449, | ||
"string": "viewmodelinstanceboolean" | ||
}, | ||
"extends": "viewmodel/viewmodel_instance_value.json", | ||
"properties": { | ||
"propertyValue": { | ||
"type": "bool", | ||
"initialValue": "false", | ||
"key": { | ||
"int": 593, | ||
"string": "propertyvalue" | ||
}, | ||
"description": "The boolean value." | ||
}, | ||
"playbackValue": { | ||
"type": "bool", | ||
"initialValue": "false", | ||
"key": { | ||
"int": 594, | ||
"string": "playbackvalue" | ||
}, | ||
"runtime": false, | ||
"coop": false | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"name": "ViewModelPropertyBoolean", | ||
"key": { | ||
"int": 448, | ||
"string": "viewmodelpropertyboolean" | ||
}, | ||
"extends": "viewmodel/viewmodel_property.json" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
#ifndef _RIVE_DATA_BIND_CONTEXT_VALUE_BOOLEAN_HPP_ | ||
#define _RIVE_DATA_BIND_CONTEXT_VALUE_BOOLEAN_HPP_ | ||
#include "rive/data_bind/context/context_value.hpp" | ||
namespace rive | ||
{ | ||
class DataBindContextValueBoolean : public DataBindContextValue | ||
{ | ||
|
||
public: | ||
DataBindContextValueBoolean(ViewModelInstanceValue* value); | ||
void apply(Component* component, uint32_t propertyKey) override; | ||
virtual void applyToSource(Component* component, uint32_t propertyKey) override; | ||
|
||
private: | ||
bool m_Value; | ||
}; | ||
} // namespace rive | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
71 changes: 71 additions & 0 deletions
71
include/rive/generated/viewmodel/viewmodel_instance_boolean_base.hpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
#ifndef _RIVE_VIEW_MODEL_INSTANCE_BOOLEAN_BASE_HPP_ | ||
#define _RIVE_VIEW_MODEL_INSTANCE_BOOLEAN_BASE_HPP_ | ||
#include "rive/core/field_types/core_bool_type.hpp" | ||
#include "rive/viewmodel/viewmodel_instance_value.hpp" | ||
namespace rive | ||
{ | ||
class ViewModelInstanceBooleanBase : public ViewModelInstanceValue | ||
{ | ||
protected: | ||
typedef ViewModelInstanceValue Super; | ||
|
||
public: | ||
static const uint16_t typeKey = 449; | ||
|
||
/// Helper to quickly determine if a core object extends another without RTTI | ||
/// at runtime. | ||
bool isTypeOf(uint16_t typeKey) const override | ||
{ | ||
switch (typeKey) | ||
{ | ||
case ViewModelInstanceBooleanBase::typeKey: | ||
case ViewModelInstanceValueBase::typeKey: | ||
return true; | ||
default: | ||
return false; | ||
} | ||
} | ||
|
||
uint16_t coreType() const override { return typeKey; } | ||
|
||
static const uint16_t propertyValuePropertyKey = 593; | ||
|
||
private: | ||
bool m_PropertyValue = false; | ||
|
||
public: | ||
inline bool propertyValue() const { return m_PropertyValue; } | ||
void propertyValue(bool value) | ||
{ | ||
if (m_PropertyValue == value) | ||
{ | ||
return; | ||
} | ||
m_PropertyValue = value; | ||
propertyValueChanged(); | ||
} | ||
|
||
Core* clone() const override; | ||
void copy(const ViewModelInstanceBooleanBase& object) | ||
{ | ||
m_PropertyValue = object.m_PropertyValue; | ||
ViewModelInstanceValue::copy(object); | ||
} | ||
|
||
bool deserialize(uint16_t propertyKey, BinaryReader& reader) override | ||
{ | ||
switch (propertyKey) | ||
{ | ||
case propertyValuePropertyKey: | ||
m_PropertyValue = CoreBoolType::deserialize(reader); | ||
return true; | ||
} | ||
return ViewModelInstanceValue::deserialize(propertyKey, reader); | ||
} | ||
|
||
protected: | ||
virtual void propertyValueChanged() {} | ||
}; | ||
} // namespace rive | ||
|
||
#endif |
37 changes: 37 additions & 0 deletions
37
include/rive/generated/viewmodel/viewmodel_property_boolean_base.hpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
#ifndef _RIVE_VIEW_MODEL_PROPERTY_BOOLEAN_BASE_HPP_ | ||
#define _RIVE_VIEW_MODEL_PROPERTY_BOOLEAN_BASE_HPP_ | ||
#include "rive/viewmodel/viewmodel_property.hpp" | ||
namespace rive | ||
{ | ||
class ViewModelPropertyBooleanBase : public ViewModelProperty | ||
{ | ||
protected: | ||
typedef ViewModelProperty Super; | ||
|
||
public: | ||
static const uint16_t typeKey = 448; | ||
|
||
/// Helper to quickly determine if a core object extends another without RTTI | ||
/// at runtime. | ||
bool isTypeOf(uint16_t typeKey) const override | ||
{ | ||
switch (typeKey) | ||
{ | ||
case ViewModelPropertyBooleanBase::typeKey: | ||
case ViewModelPropertyBase::typeKey: | ||
case ViewModelComponentBase::typeKey: | ||
return true; | ||
default: | ||
return false; | ||
} | ||
} | ||
|
||
uint16_t coreType() const override { return typeKey; } | ||
|
||
Core* clone() const override; | ||
|
||
protected: | ||
}; | ||
} // namespace rive | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
#ifndef _RIVE_VIEW_MODEL_INSTANCE_BOOLEAN_HPP_ | ||
#define _RIVE_VIEW_MODEL_INSTANCE_BOOLEAN_HPP_ | ||
#include "rive/generated/viewmodel/viewmodel_instance_boolean_base.hpp" | ||
#include <stdio.h> | ||
namespace rive | ||
{ | ||
class ViewModelInstanceBoolean : public ViewModelInstanceBooleanBase | ||
{ | ||
protected: | ||
void propertyValueChanged() override; | ||
}; | ||
} // namespace rive | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
#ifndef _RIVE_VIEW_MODEL_PROPERTY_BOOLEAN_HPP_ | ||
#define _RIVE_VIEW_MODEL_PROPERTY_BOOLEAN_HPP_ | ||
#include "rive/generated/viewmodel/viewmodel_property_boolean_base.hpp" | ||
#include <stdio.h> | ||
namespace rive | ||
{ | ||
class ViewModelPropertyBoolean : public ViewModelPropertyBooleanBase | ||
{ | ||
public: | ||
}; | ||
} // namespace rive | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
#include "rive/data_bind/context/context_value_boolean.hpp" | ||
#include "rive/generated/core_registry.hpp" | ||
|
||
using namespace rive; | ||
|
||
DataBindContextValueBoolean::DataBindContextValueBoolean(ViewModelInstanceValue* value) | ||
{ | ||
m_Source = value; | ||
} | ||
|
||
void DataBindContextValueBoolean::apply(Component* target, uint32_t propertyKey) | ||
{ | ||
CoreRegistry::setBool(target, | ||
propertyKey, | ||
m_Source->as<ViewModelInstanceBoolean>()->propertyValue()); | ||
} | ||
|
||
void DataBindContextValueBoolean::applyToSource(Component* target, uint32_t propertyKey) | ||
{ | ||
auto value = CoreRegistry::getBool(target, propertyKey); | ||
if (m_Value != value) | ||
{ | ||
m_Value = value; | ||
m_Source->as<ViewModelInstanceBoolean>()->propertyValue(value); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 11 additions & 0 deletions
11
src/generated/viewmodel/viewmodel_instance_boolean_base.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#include "rive/generated/viewmodel/viewmodel_instance_boolean_base.hpp" | ||
#include "rive/viewmodel/viewmodel_instance_boolean.hpp" | ||
|
||
using namespace rive; | ||
|
||
Core* ViewModelInstanceBooleanBase::clone() const | ||
{ | ||
auto cloned = new ViewModelInstanceBoolean(); | ||
cloned->copy(*this); | ||
return cloned; | ||
} |
11 changes: 11 additions & 0 deletions
11
src/generated/viewmodel/viewmodel_property_boolean_base.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#include "rive/generated/viewmodel/viewmodel_property_boolean_base.hpp" | ||
#include "rive/viewmodel/viewmodel_property_boolean.hpp" | ||
|
||
using namespace rive; | ||
|
||
Core* ViewModelPropertyBooleanBase::clone() const | ||
{ | ||
auto cloned = new ViewModelPropertyBoolean(); | ||
cloned->copy(*this); | ||
return cloned; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
#include <sstream> | ||
#include <iomanip> | ||
#include <array> | ||
|
||
#include "rive/viewmodel/viewmodel_instance_boolean.hpp" | ||
#include "rive/component_dirt.hpp" | ||
|
||
using namespace rive; | ||
|
||
void ViewModelInstanceBoolean::propertyValueChanged() { addDirt(ComponentDirt::Bindings); } |