Skip to content

Commit

Permalink
update text in flutter
Browse files Browse the repository at this point in the history
Diffs=
1f3571277f update text in flutter (#8399)
bb3b386c15 Fix layout size propagation (#8407)
d73f590cf8 Fix for layouts alignment bug when created with fill type (#8402)

Co-authored-by: hernan <hernan@rive.app>
  • Loading branch information
bodymovin and bodymovin committed Oct 25, 2024
1 parent d62035e commit 8bc5a39
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 3 deletions.
2 changes: 1 addition & 1 deletion .rive_head
Original file line number Diff line number Diff line change
@@ -1 +1 @@
6931974fe3eb4a5dcda546cafe2ed50e9da2c939
1f3571277f4eb3bfdfb069b621a06b870fef69ef
13 changes: 13 additions & 0 deletions lib/src/generated/rive_core_context.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2318,6 +2318,11 @@ class RiveCoreContext {
object.verticalAlignValue = value;
}
break;
case TextBase.fitFromBaselinePropertyKey:
if (object is TextBase && value is bool) {
object.fitFromBaseline = value;
}
break;
case TextValueRunBase.styleIdPropertyKey:
if (object is TextValueRunBase && value is int) {
object.styleId = value;
Expand Down Expand Up @@ -2420,6 +2425,7 @@ class RiveCoreContext {
case LayoutComponentBase.clipPropertyKey:
case BindablePropertyBooleanBase.propertyValuePropertyKey:
case TextModifierRangeBase.clampPropertyKey:
case TextBase.fitFromBaselinePropertyKey:
return boolType;
case ViewModelInstanceListItemBase.viewModelIdPropertyKey:
case ViewModelInstanceListItemBase.viewModelInstanceIdPropertyKey:
Expand Down Expand Up @@ -2853,6 +2859,8 @@ class RiveCoreContext {
return (object as BindablePropertyBooleanBase).propertyValue;
case TextModifierRangeBase.clampPropertyKey:
return (object as TextModifierRangeBase).clamp;
case TextBase.fitFromBaselinePropertyKey:
return (object as TextBase).fitFromBaseline;
}
return false;
}
Expand Down Expand Up @@ -3733,6 +3741,11 @@ class RiveCoreContext {
object.clamp = value;
}
break;
case TextBase.fitFromBaselinePropertyKey:
if (object is TextBase) {
object.fitFromBaseline = value;
}
break;
}
}

Expand Down
26 changes: 25 additions & 1 deletion lib/src/generated/text/text_base.dart
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ abstract class TextBase extends Drawable {
static const int wrapValueInitialValue = 0;
int _wrapValue = wrapValueInitialValue;

/// One of wrap, no-wrap
/// One of wrap, noWrap
int get wrapValue => _wrapValue;

/// Change the [_wrapValue] field value.
Expand Down Expand Up @@ -285,6 +285,29 @@ abstract class TextBase extends Drawable {

void verticalAlignValueChanged(int from, int to);

/// --------------------------------------------------------------------------
/// FitFromBaseline field with key 703.
static const int fitFromBaselinePropertyKey = 703;
static const bool fitFromBaselineInitialValue = true;
bool _fitFromBaseline = fitFromBaselineInitialValue;
bool get fitFromBaseline => _fitFromBaseline;

/// Change the [_fitFromBaseline] field value.
/// [fitFromBaselineChanged] will be invoked only if the field's value has
/// changed.
set fitFromBaseline(bool value) {
if (_fitFromBaseline == value) {
return;
}
bool from = _fitFromBaseline;
_fitFromBaseline = value;
if (hasValidated) {
fitFromBaselineChanged(from, value);
}
}

void fitFromBaselineChanged(bool from, bool to);

@override
void copy(Core source) {
super.copy(source);
Expand All @@ -300,6 +323,7 @@ abstract class TextBase extends Drawable {
_originValue = source._originValue;
_wrapValue = source._wrapValue;
_verticalAlignValue = source._verticalAlignValue;
_fitFromBaseline = source._fitFromBaseline;
}
}
}
7 changes: 6 additions & 1 deletion lib/src/rive_core/text/text.dart
Original file line number Diff line number Diff line change
Expand Up @@ -628,7 +628,7 @@ class Text extends TextBase with TextStyleContainer implements Sizable {
(effectiveSizing != TextSizing.autoWidth && maxWidth > _bounds.width)
? _bounds.width / maxWidth
: 1;
double baseline = lines[0][0].baseline;
double baseline = fitFromBaseline ? lines[0][0].baseline : 0;
double yScale =
(effectiveSizing == TextSizing.fixed && totalHeight > _bounds.height)
? (_bounds.height - baseline) / (totalHeight - baseline)
Expand Down Expand Up @@ -846,6 +846,11 @@ class Text extends TextBase with TextStyleContainer implements Sizable {
markShapeDirty();
}

@override
void fitFromBaselineChanged(bool from, bool to) {
markShapeDirty();
}

TextAlign get align => enumAt(TextAlign.values, alignValue);
set align(TextAlign value) => alignValue = value.index;

Expand Down

0 comments on commit 8bc5a39

Please sign in to comment.