Skip to content

Commit

Permalink
databinding
Browse files Browse the repository at this point in the history
Diffs=
75823467d databinding (#7341)

Co-authored-by: hernan <hernan@rive.app>
  • Loading branch information
bodymovin and bodymovin committed Jun 20, 2024
1 parent a6f237b commit 6ceb7a5
Show file tree
Hide file tree
Showing 64 changed files with 2,662 additions and 328 deletions.
2 changes: 1 addition & 1 deletion .rive_head
Original file line number Diff line number Diff line change
@@ -1 +1 @@
61f935eedc45f667f74ed7c7be2640d9a0880062
75823467d0c007983e66df245f1e9c27d707728c
9 changes: 9 additions & 0 deletions lib/rive.dart
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ export 'package:rive/src/rive_core/artboard.dart';
export 'package:rive/src/rive_core/assets/audio_asset.dart';
export 'package:rive/src/rive_core/assets/font_asset.dart';
export 'package:rive/src/rive_core/assets/image_asset.dart';
export 'package:rive/src/rive_core/data_bind/data_bind.dart';
export 'package:rive/src/rive_core/data_bind/data_bind_context.dart';
export 'package:rive/src/rive_core/data_bind/data_context.dart';
export 'package:rive/src/rive_core/event.dart';
export 'package:rive/src/rive_core/nested_artboard.dart';
export 'package:rive/src/rive_core/open_url_target.dart';
Expand All @@ -29,6 +32,12 @@ export 'package:rive/src/rive_core/shapes/paint/solid_color.dart';
export 'package:rive/src/rive_core/shapes/paint/stroke.dart';
export 'package:rive/src/rive_core/shapes/shape.dart';
export 'package:rive/src/rive_core/text/text_value_run.dart';
export 'package:rive/src/rive_core/viewmodel/viewmodel_instance.dart';
export 'package:rive/src/rive_core/viewmodel/viewmodel_instance_color.dart';
export 'package:rive/src/rive_core/viewmodel/viewmodel_instance_number.dart';
export 'package:rive/src/rive_core/viewmodel/viewmodel_instance_string.dart';
export 'package:rive/src/rive_core/viewmodel/viewmodel_instance_value.dart';
export 'package:rive/src/rive_core/viewmodel/viewmodel_instance_viewmodel.dart';
export 'package:rive/src/rive_file.dart';
export 'package:rive/src/rive_scene.dart';
export 'package:rive/src/runtime_artboard.dart';
Expand Down
3 changes: 3 additions & 0 deletions lib/src/core/core.dart
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ export 'package:rive/src/core/importers/state_machine_layer_component_importer.d
export 'package:rive/src/core/importers/state_machine_layer_importer.dart';
export 'package:rive/src/core/importers/state_machine_listener_importer.dart';
export 'package:rive/src/core/importers/state_transition_importer.dart';
export 'package:rive/src/data_enum_values.dart';
export 'package:rive/src/event_list.dart';
export 'package:rive/src/generated/rive_core_context.dart';
export 'package:rive/src/layer_component_events.dart';
Expand All @@ -32,6 +33,8 @@ export 'package:rive/src/runtime_artboard.dart';
export 'package:rive/src/state_machine_components.dart';
export 'package:rive/src/state_transition_conditions.dart';
export 'package:rive/src/state_transitions.dart';
export 'package:rive/src/viewmodel_list_items.dart';
export 'package:rive/src/viewmodel_properties.dart';

typedef PropertyChangeCallback = void Function(dynamic from, dynamic to);
typedef BatchAddCallback = void Function();
Expand Down
3 changes: 2 additions & 1 deletion lib/src/core/field_types/core_string_type.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ class CoreStringType extends CoreFieldType<String> {
String deserialize(BinaryReader reader) =>
reader.readString(explicitLength: true);

void read(BinaryReader reader) {
@override
void skip(BinaryReader reader) {
var length = reader.readVarUint();
reader.read(length);
}
Expand Down
12 changes: 12 additions & 0 deletions lib/src/core/importers/viewmodel_instance_importer.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import 'package:rive/src/core/core.dart';
import 'package:rive/src/rive_core/viewmodel/viewmodel_instance.dart';
import 'package:rive/src/rive_core/viewmodel/viewmodel_instance_value.dart';

class ViewModelInstanceImporter extends ImportStackObject {
final ViewModelInstance viewModelInstance;
ViewModelInstanceImporter(this.viewModelInstance);

void addValue(ViewModelInstanceValue value) {
viewModelInstance.addPropertyValue(value);
}
}
20 changes: 20 additions & 0 deletions lib/src/data_enum_values.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import 'dart:collection';

import 'package:rive/src/rive_core/viewmodel/data_enum_value.dart';

class DataEnumValues<T extends DataEnumValue> extends ListBase<T> {
final List<T?> _values = [];
List<T> get values => _values.cast<T>();

@override
int get length => _values.length;

@override
set length(int value) => _values.length = value;

@override
T operator [](int index) => _values[index]!;

@override
void operator []=(int index, T value) => _values[index] = value;
}
26 changes: 26 additions & 0 deletions lib/src/generated/artboard_base.dart
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,31 @@ abstract class ArtboardBase extends LayoutComponent {

void defaultStateMachineIdChanged(int from, int to);

/// --------------------------------------------------------------------------
/// ViewModelId field with key 583.
static const int viewModelIdPropertyKey = 583;
static const int viewModelIdInitialValue = -1;
int _viewModelId = viewModelIdInitialValue;

/// The view model attached to this artboard data context.
int get viewModelId => _viewModelId;

/// Change the [_viewModelId] field value.
/// [viewModelIdChanged] will be invoked only if the field's value has
/// changed.
set viewModelId(int value) {
if (_viewModelId == value) {
return;
}
int from = _viewModelId;
_viewModelId = value;
if (hasValidated) {
viewModelIdChanged(from, value);
}
}

void viewModelIdChanged(int from, int to);

@override
void copy(Core source) {
super.copy(source);
Expand All @@ -151,6 +176,7 @@ abstract class ArtboardBase extends LayoutComponent {
_originX = source._originX;
_originY = source._originY;
_defaultStateMachineId = source._defaultStateMachineId;
_viewModelId = source._viewModelId;
}
}
}
97 changes: 97 additions & 0 deletions lib/src/generated/data_bind/data_bind_base.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
// Core automatically generated
// lib/src/generated/data_bind/data_bind_base.dart.
// Do not modify manually.

import 'package:rive/src/core/core.dart';
import 'package:rive/src/rive_core/component.dart';

abstract class DataBindBase extends Component {
static const int typeKey = 446;
@override
int get coreType => DataBindBase.typeKey;
@override
Set<int> get coreTypes => {DataBindBase.typeKey, ComponentBase.typeKey};

/// --------------------------------------------------------------------------
/// TargetId field with key 585.
static const int targetIdPropertyKey = 585;
static const int targetIdInitialValue = -1;
int _targetId = targetIdInitialValue;

/// Identifier used to track the object that is targetted.
int get targetId => _targetId;

/// Change the [_targetId] field value.
/// [targetIdChanged] will be invoked only if the field's value has changed.
set targetId(int value) {
if (_targetId == value) {
return;
}
int from = _targetId;
_targetId = value;
if (hasValidated) {
targetIdChanged(from, value);
}
}

void targetIdChanged(int from, int to);

/// --------------------------------------------------------------------------
/// PropertyKey field with key 586.
static const int propertyKeyPropertyKey = 586;
static const int propertyKeyInitialValue = CoreContext.invalidPropertyKey;
int _propertyKey = propertyKeyInitialValue;

/// The property that is targeted.
int get propertyKey => _propertyKey;

/// Change the [_propertyKey] field value.
/// [propertyKeyChanged] will be invoked only if the field's value has
/// changed.
set propertyKey(int value) {
if (_propertyKey == value) {
return;
}
int from = _propertyKey;
_propertyKey = value;
if (hasValidated) {
propertyKeyChanged(from, value);
}
}

void propertyKeyChanged(int from, int to);

/// --------------------------------------------------------------------------
/// ModeValue field with key 587.
static const int modeValuePropertyKey = 587;
static const int modeValueInitialValue = 0;
int _modeValue = modeValueInitialValue;

/// Backing enum value for the binding mode.
int get modeValue => _modeValue;

/// Change the [_modeValue] field value.
/// [modeValueChanged] will be invoked only if the field's value has changed.
set modeValue(int value) {
if (_modeValue == value) {
return;
}
int from = _modeValue;
_modeValue = value;
if (hasValidated) {
modeValueChanged(from, value);
}
}

void modeValueChanged(int from, int to);

@override
void copy(Core source) {
super.copy(source);
if (source is DataBindBase) {
_targetId = source._targetId;
_propertyKey = source._propertyKey;
_modeValue = source._modeValue;
}
}
}
52 changes: 52 additions & 0 deletions lib/src/generated/data_bind/data_bind_context_base.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
// Core automatically generated
// lib/src/generated/data_bind/data_bind_context_base.dart.
// Do not modify manually.

import 'package:rive/src/core/core.dart';
import 'package:rive/src/generated/component_base.dart';
import 'package:rive/src/rive_core/data_bind/data_bind.dart';

abstract class DataBindContextBase extends DataBind {
static const int typeKey = 447;
@override
int get coreType => DataBindContextBase.typeKey;
@override
Set<int> get coreTypes => {
DataBindContextBase.typeKey,
DataBindBase.typeKey,
ComponentBase.typeKey
};

/// --------------------------------------------------------------------------
/// SourcePathIds field with key 588.
static const int sourcePathIdsPropertyKey = 588;
static final Uint8List sourcePathIdsInitialValue = Uint8List(0);
Uint8List _sourcePathIds = sourcePathIdsInitialValue;

/// Path to the selected property.
Uint8List get sourcePathIds => _sourcePathIds;

/// Change the [_sourcePathIds] field value.
/// [sourcePathIdsChanged] will be invoked only if the field's value has
/// changed.
set sourcePathIds(Uint8List value) {
if (listEquals(_sourcePathIds, value)) {
return;
}
Uint8List from = _sourcePathIds;
_sourcePathIds = value;
if (hasValidated) {
sourcePathIdsChanged(from, value);
}
}

void sourcePathIdsChanged(Uint8List from, Uint8List to);

@override
void copy(Core source) {
super.copy(source);
if (source is DataBindContextBase) {
_sourcePathIds = source._sourcePathIds;
}
}
}
26 changes: 26 additions & 0 deletions lib/src/generated/nested_artboard_base.dart
Original file line number Diff line number Diff line change
Expand Up @@ -96,13 +96,39 @@ abstract class NestedArtboardBase extends Drawable {

void alignmentChanged(int from, int to);

/// --------------------------------------------------------------------------
/// DataBindPathIds field with key 582.
static const int dataBindPathIdsPropertyKey = 582;
static final Uint8List dataBindPathIdsInitialValue = Uint8List(0);
Uint8List _dataBindPathIds = dataBindPathIdsInitialValue;

/// Path to the selected property.
Uint8List get dataBindPathIds => _dataBindPathIds;

/// Change the [_dataBindPathIds] field value.
/// [dataBindPathIdsChanged] will be invoked only if the field's value has
/// changed.
set dataBindPathIds(Uint8List value) {
if (listEquals(_dataBindPathIds, value)) {
return;
}
Uint8List from = _dataBindPathIds;
_dataBindPathIds = value;
if (hasValidated) {
dataBindPathIdsChanged(from, value);
}
}

void dataBindPathIdsChanged(Uint8List from, Uint8List to);

@override
void copy(Core source) {
super.copy(source);
if (source is NestedArtboardBase) {
_artboardId = source._artboardId;
_fit = source._fit;
_alignment = source._alignment;
_dataBindPathIds = source._dataBindPathIds;
}
}
}
Loading

0 comments on commit 6ceb7a5

Please sign in to comment.