diff --git a/api/lib/src/models/element.dart b/api/lib/src/models/element.dart index 3bb564155806..0d6da0cbeb90 100644 --- a/api/lib/src/models/element.dart +++ b/api/lib/src/models/element.dart @@ -62,6 +62,7 @@ class PadElement with _$PadElement { @DoublePointJsonConverter() @Default(Point(0.0, 0.0)) Point position, + @Default(1.0) double scale, @Default(PackAssetLocation()) PackAssetLocation styleSheet, required TextArea area, @Default(ElementConstraint(size: 1000)) ElementConstraint constraint, diff --git a/api/lib/src/models/element.freezed.dart b/api/lib/src/models/element.freezed.dart index b299bd3d486b..094646d07b78 100644 --- a/api/lib/src/models/element.freezed.dart +++ b/api/lib/src/models/element.freezed.dart @@ -871,6 +871,7 @@ mixin _$PadElement { required TResult Function( String layer, @DoublePointJsonConverter() Point position, + double scale, PackAssetLocation styleSheet, TextArea area, ElementConstraint constraint) @@ -907,6 +908,7 @@ mixin _$PadElement { TResult? Function( String layer, @DoublePointJsonConverter() Point position, + double scale, PackAssetLocation styleSheet, TextArea area, ElementConstraint constraint)? @@ -943,6 +945,7 @@ mixin _$PadElement { TResult Function( String layer, @DoublePointJsonConverter() Point position, + double scale, PackAssetLocation styleSheet, TextArea area, ElementConstraint constraint)? @@ -1147,6 +1150,7 @@ class _$PenElement implements PenElement { required TResult Function( String layer, @DoublePointJsonConverter() Point position, + double scale, PackAssetLocation styleSheet, TextArea area, ElementConstraint constraint) @@ -1186,6 +1190,7 @@ class _$PenElement implements PenElement { TResult? Function( String layer, @DoublePointJsonConverter() Point position, + double scale, PackAssetLocation styleSheet, TextArea area, ElementConstraint constraint)? @@ -1225,6 +1230,7 @@ class _$PenElement implements PenElement { TResult Function( String layer, @DoublePointJsonConverter() Point position, + double scale, PackAssetLocation styleSheet, TextArea area, ElementConstraint constraint)? @@ -1339,6 +1345,7 @@ abstract class _$$TextElementCopyWith<$Res> $Res call( {String layer, @DoublePointJsonConverter() Point position, + double scale, PackAssetLocation styleSheet, TextArea area, ElementConstraint constraint}); @@ -1361,6 +1368,7 @@ class __$$TextElementCopyWithImpl<$Res> $Res call({ Object? layer = null, Object? position = null, + Object? scale = null, Object? styleSheet = null, Object? area = null, Object? constraint = null, @@ -1374,6 +1382,10 @@ class __$$TextElementCopyWithImpl<$Res> ? _value.position : position // ignore: cast_nullable_to_non_nullable as Point, + scale: null == scale + ? _value.scale + : scale // ignore: cast_nullable_to_non_nullable + as double, styleSheet: null == styleSheet ? _value.styleSheet : styleSheet // ignore: cast_nullable_to_non_nullable @@ -1420,6 +1432,7 @@ class _$TextElement implements TextElement { const _$TextElement( {this.layer = '', @DoublePointJsonConverter() this.position = const Point(0.0, 0.0), + this.scale = 1.0, this.styleSheet = const PackAssetLocation(), required this.area, this.constraint = const ElementConstraint(size: 1000), @@ -1438,6 +1451,9 @@ class _$TextElement implements TextElement { final Point position; @override @JsonKey() + final double scale; + @override + @JsonKey() final PackAssetLocation styleSheet; @override final TextArea area; @@ -1450,7 +1466,7 @@ class _$TextElement implements TextElement { @override String toString() { - return 'PadElement.text(layer: $layer, position: $position, styleSheet: $styleSheet, area: $area, constraint: $constraint)'; + return 'PadElement.text(layer: $layer, position: $position, scale: $scale, styleSheet: $styleSheet, area: $area, constraint: $constraint)'; } @JsonKey(ignore: true) @@ -1468,6 +1484,7 @@ class _$TextElement implements TextElement { required TResult Function( String layer, @DoublePointJsonConverter() Point position, + double scale, PackAssetLocation styleSheet, TextArea area, ElementConstraint constraint) @@ -1495,7 +1512,7 @@ class _$TextElement implements TextElement { ShapeProperty property) shape, }) { - return text(layer, position, styleSheet, area, constraint); + return text(layer, position, scale, styleSheet, area, constraint); } @override @@ -1507,6 +1524,7 @@ class _$TextElement implements TextElement { TResult? Function( String layer, @DoublePointJsonConverter() Point position, + double scale, PackAssetLocation styleSheet, TextArea area, ElementConstraint constraint)? @@ -1534,7 +1552,7 @@ class _$TextElement implements TextElement { ShapeProperty property)? shape, }) { - return text?.call(layer, position, styleSheet, area, constraint); + return text?.call(layer, position, scale, styleSheet, area, constraint); } @override @@ -1546,6 +1564,7 @@ class _$TextElement implements TextElement { TResult Function( String layer, @DoublePointJsonConverter() Point position, + double scale, PackAssetLocation styleSheet, TextArea area, ElementConstraint constraint)? @@ -1575,7 +1594,7 @@ class _$TextElement implements TextElement { required TResult orElse(), }) { if (text != null) { - return text(layer, position, styleSheet, area, constraint); + return text(layer, position, scale, styleSheet, area, constraint); } return orElse(); } @@ -1632,6 +1651,7 @@ abstract class TextElement implements PadElement { const factory TextElement( {final String layer, @DoublePointJsonConverter() final Point position, + final double scale, final PackAssetLocation styleSheet, required final TextArea area, final ElementConstraint constraint}) = _$TextElement; @@ -1643,6 +1663,7 @@ abstract class TextElement implements PadElement { String get layer; @DoublePointJsonConverter() Point get position; + double get scale; PackAssetLocation get styleSheet; TextArea get area; ElementConstraint get constraint; @@ -1786,6 +1807,7 @@ class _$ImageElement implements ImageElement { required TResult Function( String layer, @DoublePointJsonConverter() Point position, + double scale, PackAssetLocation styleSheet, TextArea area, ElementConstraint constraint) @@ -1825,6 +1847,7 @@ class _$ImageElement implements ImageElement { TResult? Function( String layer, @DoublePointJsonConverter() Point position, + double scale, PackAssetLocation styleSheet, TextArea area, ElementConstraint constraint)? @@ -1864,6 +1887,7 @@ class _$ImageElement implements ImageElement { TResult Function( String layer, @DoublePointJsonConverter() Point position, + double scale, PackAssetLocation styleSheet, TextArea area, ElementConstraint constraint)? @@ -2106,6 +2130,7 @@ class _$SvgElement implements SvgElement { required TResult Function( String layer, @DoublePointJsonConverter() Point position, + double scale, PackAssetLocation styleSheet, TextArea area, ElementConstraint constraint) @@ -2145,6 +2170,7 @@ class _$SvgElement implements SvgElement { TResult? Function( String layer, @DoublePointJsonConverter() Point position, + double scale, PackAssetLocation styleSheet, TextArea area, ElementConstraint constraint)? @@ -2184,6 +2210,7 @@ class _$SvgElement implements SvgElement { TResult Function( String layer, @DoublePointJsonConverter() Point position, + double scale, PackAssetLocation styleSheet, TextArea area, ElementConstraint constraint)? @@ -2396,6 +2423,7 @@ class _$ShapeElement implements ShapeElement { required TResult Function( String layer, @DoublePointJsonConverter() Point position, + double scale, PackAssetLocation styleSheet, TextArea area, ElementConstraint constraint) @@ -2435,6 +2463,7 @@ class _$ShapeElement implements ShapeElement { TResult? Function( String layer, @DoublePointJsonConverter() Point position, + double scale, PackAssetLocation styleSheet, TextArea area, ElementConstraint constraint)? @@ -2474,6 +2503,7 @@ class _$ShapeElement implements ShapeElement { TResult Function( String layer, @DoublePointJsonConverter() Point position, + double scale, PackAssetLocation styleSheet, TextArea area, ElementConstraint constraint)? diff --git a/api/lib/src/models/element.g.dart b/api/lib/src/models/element.g.dart index 81fbef4f61b7..cb588a136856 100644 --- a/api/lib/src/models/element.g.dart +++ b/api/lib/src/models/element.g.dart @@ -99,6 +99,7 @@ _$TextElement _$$TextElementFromJson(Map json) => _$TextElement( position: json['position'] == null ? const Point(0.0, 0.0) : const DoublePointJsonConverter().fromJson(json['position'] as Map), + scale: (json['scale'] as num?)?.toDouble() ?? 1.0, styleSheet: json['styleSheet'] == null ? const PackAssetLocation() : PackAssetLocation.fromJson( @@ -115,6 +116,7 @@ Map _$$TextElementToJson(_$TextElement instance) => { 'layer': instance.layer, 'position': const DoublePointJsonConverter().toJson(instance.position), + 'scale': instance.scale, 'styleSheet': instance.styleSheet.toJson(), 'area': instance.area.toJson(), 'constraint': instance.constraint.toJson(), diff --git a/api/lib/src/models/painter.dart b/api/lib/src/models/painter.dart index 067c867c64d5..94f7c6ede7eb 100644 --- a/api/lib/src/models/painter.dart +++ b/api/lib/src/models/painter.dart @@ -70,6 +70,7 @@ class Painter with _$Painter { factory Painter.label({ @Default('') String name, + @Default(true) bool zoomDependent, @Default(PackAssetLocation()) PackAssetLocation styleSheet, }) = LabelPainter; diff --git a/api/lib/src/models/painter.freezed.dart b/api/lib/src/models/painter.freezed.dart index b810837cad8a..b573ee51fa86 100644 --- a/api/lib/src/models/painter.freezed.dart +++ b/api/lib/src/models/painter.freezed.dart @@ -632,7 +632,9 @@ mixin _$Painter { import, required TResult Function(String name) undo, required TResult Function(String name) redo, - required TResult Function(String name, PackAssetLocation styleSheet) label, + required TResult Function( + String name, bool zoomDependent, PackAssetLocation styleSheet) + label, required TResult Function( String name, bool zoomDependent, PenProperty property) pen, @@ -669,7 +671,9 @@ mixin _$Painter { import, TResult? Function(String name)? undo, TResult? Function(String name)? redo, - TResult? Function(String name, PackAssetLocation styleSheet)? label, + TResult? Function( + String name, bool zoomDependent, PackAssetLocation styleSheet)? + label, TResult? Function(String name, bool zoomDependent, PenProperty property)? pen, TResult? Function(String name, double strokeWidth)? eraser, @@ -705,7 +709,9 @@ mixin _$Painter { import, TResult Function(String name)? undo, TResult Function(String name)? redo, - TResult Function(String name, PackAssetLocation styleSheet)? label, + TResult Function( + String name, bool zoomDependent, PackAssetLocation styleSheet)? + label, TResult Function(String name, bool zoomDependent, PenProperty property)? pen, TResult Function(String name, double strokeWidth)? eraser, @@ -898,7 +904,9 @@ class _$HandPainter implements HandPainter { import, required TResult Function(String name) undo, required TResult Function(String name) redo, - required TResult Function(String name, PackAssetLocation styleSheet) label, + required TResult Function( + String name, bool zoomDependent, PackAssetLocation styleSheet) + label, required TResult Function( String name, bool zoomDependent, PenProperty property) pen, @@ -938,7 +946,9 @@ class _$HandPainter implements HandPainter { import, TResult? Function(String name)? undo, TResult? Function(String name)? redo, - TResult? Function(String name, PackAssetLocation styleSheet)? label, + TResult? Function( + String name, bool zoomDependent, PackAssetLocation styleSheet)? + label, TResult? Function(String name, bool zoomDependent, PenProperty property)? pen, TResult? Function(String name, double strokeWidth)? eraser, @@ -977,7 +987,9 @@ class _$HandPainter implements HandPainter { import, TResult Function(String name)? undo, TResult Function(String name)? redo, - TResult Function(String name, PackAssetLocation styleSheet)? label, + TResult Function( + String name, bool zoomDependent, PackAssetLocation styleSheet)? + label, TResult Function(String name, bool zoomDependent, PenProperty property)? pen, TResult Function(String name, double strokeWidth)? eraser, @@ -1204,7 +1216,9 @@ class _$ImportPainter implements ImportPainter { import, required TResult Function(String name) undo, required TResult Function(String name) redo, - required TResult Function(String name, PackAssetLocation styleSheet) label, + required TResult Function( + String name, bool zoomDependent, PackAssetLocation styleSheet) + label, required TResult Function( String name, bool zoomDependent, PenProperty property) pen, @@ -1244,7 +1258,9 @@ class _$ImportPainter implements ImportPainter { import, TResult? Function(String name)? undo, TResult? Function(String name)? redo, - TResult? Function(String name, PackAssetLocation styleSheet)? label, + TResult? Function( + String name, bool zoomDependent, PackAssetLocation styleSheet)? + label, TResult? Function(String name, bool zoomDependent, PenProperty property)? pen, TResult? Function(String name, double strokeWidth)? eraser, @@ -1283,7 +1299,9 @@ class _$ImportPainter implements ImportPainter { import, TResult Function(String name)? undo, TResult Function(String name)? redo, - TResult Function(String name, PackAssetLocation styleSheet)? label, + TResult Function( + String name, bool zoomDependent, PackAssetLocation styleSheet)? + label, TResult Function(String name, bool zoomDependent, PenProperty property)? pen, TResult Function(String name, double strokeWidth)? eraser, @@ -1483,7 +1501,9 @@ class _$UndoPainter implements UndoPainter { import, required TResult Function(String name) undo, required TResult Function(String name) redo, - required TResult Function(String name, PackAssetLocation styleSheet) label, + required TResult Function( + String name, bool zoomDependent, PackAssetLocation styleSheet) + label, required TResult Function( String name, bool zoomDependent, PenProperty property) pen, @@ -1523,7 +1543,9 @@ class _$UndoPainter implements UndoPainter { import, TResult? Function(String name)? undo, TResult? Function(String name)? redo, - TResult? Function(String name, PackAssetLocation styleSheet)? label, + TResult? Function( + String name, bool zoomDependent, PackAssetLocation styleSheet)? + label, TResult? Function(String name, bool zoomDependent, PenProperty property)? pen, TResult? Function(String name, double strokeWidth)? eraser, @@ -1562,7 +1584,9 @@ class _$UndoPainter implements UndoPainter { import, TResult Function(String name)? undo, TResult Function(String name)? redo, - TResult Function(String name, PackAssetLocation styleSheet)? label, + TResult Function( + String name, bool zoomDependent, PackAssetLocation styleSheet)? + label, TResult Function(String name, bool zoomDependent, PenProperty property)? pen, TResult Function(String name, double strokeWidth)? eraser, @@ -1757,7 +1781,9 @@ class _$RedoPainter implements RedoPainter { import, required TResult Function(String name) undo, required TResult Function(String name) redo, - required TResult Function(String name, PackAssetLocation styleSheet) label, + required TResult Function( + String name, bool zoomDependent, PackAssetLocation styleSheet) + label, required TResult Function( String name, bool zoomDependent, PenProperty property) pen, @@ -1797,7 +1823,9 @@ class _$RedoPainter implements RedoPainter { import, TResult? Function(String name)? undo, TResult? Function(String name)? redo, - TResult? Function(String name, PackAssetLocation styleSheet)? label, + TResult? Function( + String name, bool zoomDependent, PackAssetLocation styleSheet)? + label, TResult? Function(String name, bool zoomDependent, PenProperty property)? pen, TResult? Function(String name, double strokeWidth)? eraser, @@ -1836,7 +1864,9 @@ class _$RedoPainter implements RedoPainter { import, TResult Function(String name)? undo, TResult Function(String name)? redo, - TResult Function(String name, PackAssetLocation styleSheet)? label, + TResult Function( + String name, bool zoomDependent, PackAssetLocation styleSheet)? + label, TResult Function(String name, bool zoomDependent, PenProperty property)? pen, TResult Function(String name, double strokeWidth)? eraser, @@ -1970,7 +2000,7 @@ abstract class _$$LabelPainterCopyWith<$Res> implements $PainterCopyWith<$Res> { __$$LabelPainterCopyWithImpl<$Res>; @override @useResult - $Res call({String name, PackAssetLocation styleSheet}); + $Res call({String name, bool zoomDependent, PackAssetLocation styleSheet}); $PackAssetLocationCopyWith<$Res> get styleSheet; } @@ -1987,6 +2017,7 @@ class __$$LabelPainterCopyWithImpl<$Res> @override $Res call({ Object? name = null, + Object? zoomDependent = null, Object? styleSheet = null, }) { return _then(_$LabelPainter( @@ -1994,6 +2025,10 @@ class __$$LabelPainterCopyWithImpl<$Res> ? _value.name : name // ignore: cast_nullable_to_non_nullable as String, + zoomDependent: null == zoomDependent + ? _value.zoomDependent + : zoomDependent // ignore: cast_nullable_to_non_nullable + as bool, styleSheet: null == styleSheet ? _value.styleSheet : styleSheet // ignore: cast_nullable_to_non_nullable @@ -2015,6 +2050,7 @@ class __$$LabelPainterCopyWithImpl<$Res> class _$LabelPainter implements LabelPainter { _$LabelPainter( {this.name = '', + this.zoomDependent = true, this.styleSheet = const PackAssetLocation(), final String? $type}) : $type = $type ?? 'label'; @@ -2027,6 +2063,9 @@ class _$LabelPainter implements LabelPainter { final String name; @override @JsonKey() + final bool zoomDependent; + @override + @JsonKey() final PackAssetLocation styleSheet; @JsonKey(name: 'type') @@ -2034,7 +2073,7 @@ class _$LabelPainter implements LabelPainter { @override String toString() { - return 'Painter.label(name: $name, styleSheet: $styleSheet)'; + return 'Painter.label(name: $name, zoomDependent: $zoomDependent, styleSheet: $styleSheet)'; } @JsonKey(ignore: true) @@ -2052,7 +2091,9 @@ class _$LabelPainter implements LabelPainter { import, required TResult Function(String name) undo, required TResult Function(String name) redo, - required TResult Function(String name, PackAssetLocation styleSheet) label, + required TResult Function( + String name, bool zoomDependent, PackAssetLocation styleSheet) + label, required TResult Function( String name, bool zoomDependent, PenProperty property) pen, @@ -2081,7 +2122,7 @@ class _$LabelPainter implements LabelPainter { required TResult Function(String name, PackAssetLocation component) stamp, required TResult Function(String name) presentation, }) { - return label(name, styleSheet); + return label(name, zoomDependent, styleSheet); } @override @@ -2092,7 +2133,9 @@ class _$LabelPainter implements LabelPainter { import, TResult? Function(String name)? undo, TResult? Function(String name)? redo, - TResult? Function(String name, PackAssetLocation styleSheet)? label, + TResult? Function( + String name, bool zoomDependent, PackAssetLocation styleSheet)? + label, TResult? Function(String name, bool zoomDependent, PenProperty property)? pen, TResult? Function(String name, double strokeWidth)? eraser, @@ -2120,7 +2163,7 @@ class _$LabelPainter implements LabelPainter { TResult? Function(String name, PackAssetLocation component)? stamp, TResult? Function(String name)? presentation, }) { - return label?.call(name, styleSheet); + return label?.call(name, zoomDependent, styleSheet); } @override @@ -2131,7 +2174,9 @@ class _$LabelPainter implements LabelPainter { import, TResult Function(String name)? undo, TResult Function(String name)? redo, - TResult Function(String name, PackAssetLocation styleSheet)? label, + TResult Function( + String name, bool zoomDependent, PackAssetLocation styleSheet)? + label, TResult Function(String name, bool zoomDependent, PenProperty property)? pen, TResult Function(String name, double strokeWidth)? eraser, @@ -2161,7 +2206,7 @@ class _$LabelPainter implements LabelPainter { required TResult orElse(), }) { if (label != null) { - return label(name, styleSheet); + return label(name, zoomDependent, styleSheet); } return orElse(); } @@ -2246,13 +2291,16 @@ class _$LabelPainter implements LabelPainter { abstract class LabelPainter implements Painter { factory LabelPainter( - {final String name, final PackAssetLocation styleSheet}) = _$LabelPainter; + {final String name, + final bool zoomDependent, + final PackAssetLocation styleSheet}) = _$LabelPainter; factory LabelPainter.fromJson(Map json) = _$LabelPainter.fromJson; @override String get name; + bool get zoomDependent; PackAssetLocation get styleSheet; @override @JsonKey(ignore: true) @@ -2348,7 +2396,9 @@ class _$PenPainter implements PenPainter { import, required TResult Function(String name) undo, required TResult Function(String name) redo, - required TResult Function(String name, PackAssetLocation styleSheet) label, + required TResult Function( + String name, bool zoomDependent, PackAssetLocation styleSheet) + label, required TResult Function( String name, bool zoomDependent, PenProperty property) pen, @@ -2388,7 +2438,9 @@ class _$PenPainter implements PenPainter { import, TResult? Function(String name)? undo, TResult? Function(String name)? redo, - TResult? Function(String name, PackAssetLocation styleSheet)? label, + TResult? Function( + String name, bool zoomDependent, PackAssetLocation styleSheet)? + label, TResult? Function(String name, bool zoomDependent, PenProperty property)? pen, TResult? Function(String name, double strokeWidth)? eraser, @@ -2427,7 +2479,9 @@ class _$PenPainter implements PenPainter { import, TResult Function(String name)? undo, TResult Function(String name)? redo, - TResult Function(String name, PackAssetLocation styleSheet)? label, + TResult Function( + String name, bool zoomDependent, PackAssetLocation styleSheet)? + label, TResult Function(String name, bool zoomDependent, PenProperty property)? pen, TResult Function(String name, double strokeWidth)? eraser, @@ -2636,7 +2690,9 @@ class _$EraserPainter implements EraserPainter { import, required TResult Function(String name) undo, required TResult Function(String name) redo, - required TResult Function(String name, PackAssetLocation styleSheet) label, + required TResult Function( + String name, bool zoomDependent, PackAssetLocation styleSheet) + label, required TResult Function( String name, bool zoomDependent, PenProperty property) pen, @@ -2676,7 +2732,9 @@ class _$EraserPainter implements EraserPainter { import, TResult? Function(String name)? undo, TResult? Function(String name)? redo, - TResult? Function(String name, PackAssetLocation styleSheet)? label, + TResult? Function( + String name, bool zoomDependent, PackAssetLocation styleSheet)? + label, TResult? Function(String name, bool zoomDependent, PenProperty property)? pen, TResult? Function(String name, double strokeWidth)? eraser, @@ -2715,7 +2773,9 @@ class _$EraserPainter implements EraserPainter { import, TResult Function(String name)? undo, TResult Function(String name)? redo, - TResult Function(String name, PackAssetLocation styleSheet)? label, + TResult Function( + String name, bool zoomDependent, PackAssetLocation styleSheet)? + label, TResult Function(String name, bool zoomDependent, PenProperty property)? pen, TResult Function(String name, double strokeWidth)? eraser, @@ -2922,7 +2982,9 @@ class _$PathEraserPainter implements PathEraserPainter { import, required TResult Function(String name) undo, required TResult Function(String name) redo, - required TResult Function(String name, PackAssetLocation styleSheet) label, + required TResult Function( + String name, bool zoomDependent, PackAssetLocation styleSheet) + label, required TResult Function( String name, bool zoomDependent, PenProperty property) pen, @@ -2962,7 +3024,9 @@ class _$PathEraserPainter implements PathEraserPainter { import, TResult? Function(String name)? undo, TResult? Function(String name)? redo, - TResult? Function(String name, PackAssetLocation styleSheet)? label, + TResult? Function( + String name, bool zoomDependent, PackAssetLocation styleSheet)? + label, TResult? Function(String name, bool zoomDependent, PenProperty property)? pen, TResult? Function(String name, double strokeWidth)? eraser, @@ -3001,7 +3065,9 @@ class _$PathEraserPainter implements PathEraserPainter { import, TResult Function(String name)? undo, TResult Function(String name)? redo, - TResult Function(String name, PackAssetLocation styleSheet)? label, + TResult Function( + String name, bool zoomDependent, PackAssetLocation styleSheet)? + label, TResult Function(String name, bool zoomDependent, PenProperty property)? pen, TResult Function(String name, double strokeWidth)? eraser, @@ -3206,7 +3272,9 @@ class _$LayerPainter implements LayerPainter { import, required TResult Function(String name) undo, required TResult Function(String name) redo, - required TResult Function(String name, PackAssetLocation styleSheet) label, + required TResult Function( + String name, bool zoomDependent, PackAssetLocation styleSheet) + label, required TResult Function( String name, bool zoomDependent, PenProperty property) pen, @@ -3246,7 +3314,9 @@ class _$LayerPainter implements LayerPainter { import, TResult? Function(String name)? undo, TResult? Function(String name)? redo, - TResult? Function(String name, PackAssetLocation styleSheet)? label, + TResult? Function( + String name, bool zoomDependent, PackAssetLocation styleSheet)? + label, TResult? Function(String name, bool zoomDependent, PenProperty property)? pen, TResult? Function(String name, double strokeWidth)? eraser, @@ -3285,7 +3355,9 @@ class _$LayerPainter implements LayerPainter { import, TResult Function(String name)? undo, TResult Function(String name)? redo, - TResult Function(String name, PackAssetLocation styleSheet)? label, + TResult Function( + String name, bool zoomDependent, PackAssetLocation styleSheet)? + label, TResult Function(String name, bool zoomDependent, PenProperty property)? pen, TResult Function(String name, double strokeWidth)? eraser, @@ -3525,7 +3597,9 @@ class _$AreaPainter implements AreaPainter { import, required TResult Function(String name) undo, required TResult Function(String name) redo, - required TResult Function(String name, PackAssetLocation styleSheet) label, + required TResult Function( + String name, bool zoomDependent, PackAssetLocation styleSheet) + label, required TResult Function( String name, bool zoomDependent, PenProperty property) pen, @@ -3566,7 +3640,9 @@ class _$AreaPainter implements AreaPainter { import, TResult? Function(String name)? undo, TResult? Function(String name)? redo, - TResult? Function(String name, PackAssetLocation styleSheet)? label, + TResult? Function( + String name, bool zoomDependent, PackAssetLocation styleSheet)? + label, TResult? Function(String name, bool zoomDependent, PenProperty property)? pen, TResult? Function(String name, double strokeWidth)? eraser, @@ -3606,7 +3682,9 @@ class _$AreaPainter implements AreaPainter { import, TResult Function(String name)? undo, TResult Function(String name)? redo, - TResult Function(String name, PackAssetLocation styleSheet)? label, + TResult Function( + String name, bool zoomDependent, PackAssetLocation styleSheet)? + label, TResult Function(String name, bool zoomDependent, PenProperty property)? pen, TResult Function(String name, double strokeWidth)? eraser, @@ -3812,7 +3890,9 @@ class _$WaypointPainter implements WaypointPainter { import, required TResult Function(String name) undo, required TResult Function(String name) redo, - required TResult Function(String name, PackAssetLocation styleSheet) label, + required TResult Function( + String name, bool zoomDependent, PackAssetLocation styleSheet) + label, required TResult Function( String name, bool zoomDependent, PenProperty property) pen, @@ -3852,7 +3932,9 @@ class _$WaypointPainter implements WaypointPainter { import, TResult? Function(String name)? undo, TResult? Function(String name)? redo, - TResult? Function(String name, PackAssetLocation styleSheet)? label, + TResult? Function( + String name, bool zoomDependent, PackAssetLocation styleSheet)? + label, TResult? Function(String name, bool zoomDependent, PenProperty property)? pen, TResult? Function(String name, double strokeWidth)? eraser, @@ -3891,7 +3973,9 @@ class _$WaypointPainter implements WaypointPainter { import, TResult Function(String name)? undo, TResult Function(String name)? redo, - TResult Function(String name, PackAssetLocation styleSheet)? label, + TResult Function( + String name, bool zoomDependent, PackAssetLocation styleSheet)? + label, TResult Function(String name, bool zoomDependent, PenProperty property)? pen, TResult Function(String name, double strokeWidth)? eraser, @@ -4129,7 +4213,9 @@ class _$LaserPainter implements LaserPainter { import, required TResult Function(String name) undo, required TResult Function(String name) redo, - required TResult Function(String name, PackAssetLocation styleSheet) label, + required TResult Function( + String name, bool zoomDependent, PackAssetLocation styleSheet) + label, required TResult Function( String name, bool zoomDependent, PenProperty property) pen, @@ -4169,7 +4255,9 @@ class _$LaserPainter implements LaserPainter { import, TResult? Function(String name)? undo, TResult? Function(String name)? redo, - TResult? Function(String name, PackAssetLocation styleSheet)? label, + TResult? Function( + String name, bool zoomDependent, PackAssetLocation styleSheet)? + label, TResult? Function(String name, bool zoomDependent, PenProperty property)? pen, TResult? Function(String name, double strokeWidth)? eraser, @@ -4208,7 +4296,9 @@ class _$LaserPainter implements LaserPainter { import, TResult Function(String name)? undo, TResult Function(String name)? redo, - TResult Function(String name, PackAssetLocation styleSheet)? label, + TResult Function( + String name, bool zoomDependent, PackAssetLocation styleSheet)? + label, TResult Function(String name, bool zoomDependent, PenProperty property)? pen, TResult Function(String name, double strokeWidth)? eraser, @@ -4465,7 +4555,9 @@ class _$ShapePainter implements ShapePainter { import, required TResult Function(String name) undo, required TResult Function(String name) redo, - required TResult Function(String name, PackAssetLocation styleSheet) label, + required TResult Function( + String name, bool zoomDependent, PackAssetLocation styleSheet) + label, required TResult Function( String name, bool zoomDependent, PenProperty property) pen, @@ -4506,7 +4598,9 @@ class _$ShapePainter implements ShapePainter { import, TResult? Function(String name)? undo, TResult? Function(String name)? redo, - TResult? Function(String name, PackAssetLocation styleSheet)? label, + TResult? Function( + String name, bool zoomDependent, PackAssetLocation styleSheet)? + label, TResult? Function(String name, bool zoomDependent, PenProperty property)? pen, TResult? Function(String name, double strokeWidth)? eraser, @@ -4546,7 +4640,9 @@ class _$ShapePainter implements ShapePainter { import, TResult Function(String name)? undo, TResult Function(String name)? redo, - TResult Function(String name, PackAssetLocation styleSheet)? label, + TResult Function( + String name, bool zoomDependent, PackAssetLocation styleSheet)? + label, TResult Function(String name, bool zoomDependent, PenProperty property)? pen, TResult Function(String name, double strokeWidth)? eraser, @@ -4774,7 +4870,9 @@ class _$StampPainter implements StampPainter { import, required TResult Function(String name) undo, required TResult Function(String name) redo, - required TResult Function(String name, PackAssetLocation styleSheet) label, + required TResult Function( + String name, bool zoomDependent, PackAssetLocation styleSheet) + label, required TResult Function( String name, bool zoomDependent, PenProperty property) pen, @@ -4814,7 +4912,9 @@ class _$StampPainter implements StampPainter { import, TResult? Function(String name)? undo, TResult? Function(String name)? redo, - TResult? Function(String name, PackAssetLocation styleSheet)? label, + TResult? Function( + String name, bool zoomDependent, PackAssetLocation styleSheet)? + label, TResult? Function(String name, bool zoomDependent, PenProperty property)? pen, TResult? Function(String name, double strokeWidth)? eraser, @@ -4853,7 +4953,9 @@ class _$StampPainter implements StampPainter { import, TResult Function(String name)? undo, TResult Function(String name)? redo, - TResult Function(String name, PackAssetLocation styleSheet)? label, + TResult Function( + String name, bool zoomDependent, PackAssetLocation styleSheet)? + label, TResult Function(String name, bool zoomDependent, PenProperty property)? pen, TResult Function(String name, double strokeWidth)? eraser, @@ -5052,7 +5154,9 @@ class _$PresentationPainter implements PresentationPainter { import, required TResult Function(String name) undo, required TResult Function(String name) redo, - required TResult Function(String name, PackAssetLocation styleSheet) label, + required TResult Function( + String name, bool zoomDependent, PackAssetLocation styleSheet) + label, required TResult Function( String name, bool zoomDependent, PenProperty property) pen, @@ -5092,7 +5196,9 @@ class _$PresentationPainter implements PresentationPainter { import, TResult? Function(String name)? undo, TResult? Function(String name)? redo, - TResult? Function(String name, PackAssetLocation styleSheet)? label, + TResult? Function( + String name, bool zoomDependent, PackAssetLocation styleSheet)? + label, TResult? Function(String name, bool zoomDependent, PenProperty property)? pen, TResult? Function(String name, double strokeWidth)? eraser, @@ -5131,7 +5237,9 @@ class _$PresentationPainter implements PresentationPainter { import, TResult Function(String name)? undo, TResult Function(String name)? redo, - TResult Function(String name, PackAssetLocation styleSheet)? label, + TResult Function( + String name, bool zoomDependent, PackAssetLocation styleSheet)? + label, TResult Function(String name, bool zoomDependent, PenProperty property)? pen, TResult Function(String name, double strokeWidth)? eraser, diff --git a/api/lib/src/models/painter.g.dart b/api/lib/src/models/painter.g.dart index eb577b53c4e3..f2cda6211e14 100644 --- a/api/lib/src/models/painter.g.dart +++ b/api/lib/src/models/painter.g.dart @@ -96,6 +96,7 @@ Map _$$RedoPainterToJson(_$RedoPainter instance) => _$LabelPainter _$$LabelPainterFromJson(Map json) => _$LabelPainter( name: json['name'] as String? ?? '', + zoomDependent: json['zoomDependent'] as bool? ?? true, styleSheet: json['styleSheet'] == null ? const PackAssetLocation() : PackAssetLocation.fromJson( @@ -106,6 +107,7 @@ _$LabelPainter _$$LabelPainterFromJson(Map json) => _$LabelPainter( Map _$$LabelPainterToJson(_$LabelPainter instance) => { 'name': instance.name, + 'zoomDependent': instance.zoomDependent, 'styleSheet': instance.styleSheet.toJson(), 'type': instance.$type, }; diff --git a/app/lib/handlers/label.dart b/app/lib/handlers/label.dart index 946ff1c87a9d..df9dedfa68b7 100644 --- a/app/lib/handlers/label.dart +++ b/app/lib/handlers/label.dart @@ -9,7 +9,7 @@ class LabelHandler extends Handler LabelHandler(super.data); - TextContext _createContext([Point? position]) { + TextContext _createContext([Point? position, double zoom = 1]) { return TextContext( painter: data, isCreating: true, @@ -24,6 +24,7 @@ class LabelHandler extends Handler ), ), styleSheet: data.styleSheet, + scale: data.zoomDependent ? 1 / zoom : 1, ), textPainter: TextPainter(), forcedProperty: _context?.forcedProperty, @@ -122,7 +123,8 @@ class LabelHandler extends Handler _connection!.show(); if (hadFocus || _context?.element == null) { if (_context?.element != null) _submit(context.getDocumentBloc()); - _context = _createContext(globalPos.toPoint()); + _context = _createContext( + globalPos.toPoint(), context.getCameraTransform().size); } if (hit) { final position = _context!.textPainter.getPositionForOffset(globalPos - @@ -325,13 +327,13 @@ class LabelHandler extends Handler var nextNextLine = paragraph.nextLineIndex(nextLine + 1); if (nextNextLine <= nextLine) { nextNextLine = paragraph.length + 2; - nextLine = paragraph.length + 1; + nextLine = paragraph.length; } - var nextLineLength = nextNextLine - nextLine; + var nextLineLength = nextNextLine - nextLine + 1; final previousLine = paragraph.previousLineIndex(max(currentLine, 0)); var previousLineLength = max(currentLine - previousLine, 0); - final lineSelection = min( - selection - currentLine, forward ? nextLineLength : previousLineLength); + final lineSelection = min(max(selection - currentLine, 1), + forward ? nextLineLength : previousLineLength); return (forward ? nextLine + lineSelection : previousLine + lineSelection) .clamp(0, paragraph.length); } diff --git a/app/lib/handlers/laser.dart b/app/lib/handlers/laser.dart index 3385f034a4c5..1f763b245c85 100644 --- a/app/lib/handlers/laser.dart +++ b/app/lib/handlers/laser.dart @@ -125,7 +125,7 @@ class LaserHandler extends Handler { PenElement( layer: state.currentLayer, property: PenProperty( - strokeWidth: data.strokeWidth, + strokeWidth: data.strokeWidth / transform.size, thinning: data.thinning, color: data.color), ); diff --git a/app/lib/models/text.dart b/app/lib/models/text.dart index 2ce939193f04..9240265113a3 100644 --- a/app/lib/models/text.dart +++ b/app/lib/models/text.dart @@ -17,6 +17,7 @@ class TextContext with _$TextContext { required TextPainter textPainter, TextElement? element, @Default(false) bool isCreating, + @Default(1.0) double zoom, @Default(TextSelection.collapsed(offset: 0)) TextSelection selection, ParagraphProperty? forcedProperty, SpanProperty? forcedSpanProperty, diff --git a/app/lib/models/text.freezed.dart b/app/lib/models/text.freezed.dart index 7f0ba3ad1994..a15786e66913 100644 --- a/app/lib/models/text.freezed.dart +++ b/app/lib/models/text.freezed.dart @@ -20,6 +20,7 @@ mixin _$TextContext { TextPainter get textPainter => throw _privateConstructorUsedError; TextElement? get element => throw _privateConstructorUsedError; bool get isCreating => throw _privateConstructorUsedError; + double get zoom => throw _privateConstructorUsedError; TextSelection get selection => throw _privateConstructorUsedError; text.ParagraphProperty? get forcedProperty => throw _privateConstructorUsedError; @@ -43,6 +44,7 @@ abstract class $TextContextCopyWith<$Res> { TextPainter textPainter, TextElement? element, bool isCreating, + double zoom, TextSelection selection, text.ParagraphProperty? forcedProperty, text.SpanProperty? forcedSpanProperty, @@ -69,6 +71,7 @@ class _$TextContextCopyWithImpl<$Res, $Val extends TextContext> Object? textPainter = null, Object? element = freezed, Object? isCreating = null, + Object? zoom = null, Object? selection = null, Object? forcedProperty = freezed, Object? forcedSpanProperty = freezed, @@ -91,6 +94,10 @@ class _$TextContextCopyWithImpl<$Res, $Val extends TextContext> ? _value.isCreating : isCreating // ignore: cast_nullable_to_non_nullable as bool, + zoom: null == zoom + ? _value.zoom + : zoom // ignore: cast_nullable_to_non_nullable + as double, selection: null == selection ? _value.selection : selection // ignore: cast_nullable_to_non_nullable @@ -148,6 +155,7 @@ abstract class _$$_TextContextCopyWith<$Res> TextPainter textPainter, TextElement? element, bool isCreating, + double zoom, TextSelection selection, text.ParagraphProperty? forcedProperty, text.SpanProperty? forcedSpanProperty, @@ -174,6 +182,7 @@ class __$$_TextContextCopyWithImpl<$Res> Object? textPainter = null, Object? element = freezed, Object? isCreating = null, + Object? zoom = null, Object? selection = null, Object? forcedProperty = freezed, Object? forcedSpanProperty = freezed, @@ -196,6 +205,10 @@ class __$$_TextContextCopyWithImpl<$Res> ? _value.isCreating : isCreating // ignore: cast_nullable_to_non_nullable as bool, + zoom: null == zoom + ? _value.zoom + : zoom // ignore: cast_nullable_to_non_nullable + as double, selection: null == selection ? _value.selection : selection // ignore: cast_nullable_to_non_nullable @@ -224,6 +237,7 @@ class _$_TextContext extends _TextContext { required this.textPainter, this.element, this.isCreating = false, + this.zoom = 1.0, this.selection = const TextSelection.collapsed(offset: 0), this.forcedProperty, this.forcedSpanProperty, @@ -241,6 +255,9 @@ class _$_TextContext extends _TextContext { final bool isCreating; @override @JsonKey() + final double zoom; + @override + @JsonKey() final TextSelection selection; @override final text.ParagraphProperty? forcedProperty; @@ -251,7 +268,7 @@ class _$_TextContext extends _TextContext { @override String toString() { - return 'TextContext(painter: $painter, textPainter: $textPainter, element: $element, isCreating: $isCreating, selection: $selection, forcedProperty: $forcedProperty, forcedSpanProperty: $forcedSpanProperty, forceParagraph: $forceParagraph)'; + return 'TextContext(painter: $painter, textPainter: $textPainter, element: $element, isCreating: $isCreating, zoom: $zoom, selection: $selection, forcedProperty: $forcedProperty, forcedSpanProperty: $forcedSpanProperty, forceParagraph: $forceParagraph)'; } @override @@ -265,6 +282,7 @@ class _$_TextContext extends _TextContext { (identical(other.element, element) || other.element == element) && (identical(other.isCreating, isCreating) || other.isCreating == isCreating) && + (identical(other.zoom, zoom) || other.zoom == zoom) && (identical(other.selection, selection) || other.selection == selection) && (identical(other.forcedProperty, forcedProperty) || @@ -282,6 +300,7 @@ class _$_TextContext extends _TextContext { textPainter, element, isCreating, + zoom, selection, forcedProperty, forcedSpanProperty, @@ -300,6 +319,7 @@ abstract class _TextContext extends TextContext { required final TextPainter textPainter, final TextElement? element, final bool isCreating, + final double zoom, final TextSelection selection, final text.ParagraphProperty? forcedProperty, final text.SpanProperty? forcedSpanProperty, @@ -315,6 +335,8 @@ abstract class _TextContext extends TextContext { @override bool get isCreating; @override + double get zoom; + @override TextSelection get selection; @override text.ParagraphProperty? get forcedProperty; diff --git a/app/lib/renderers/cursors/text.dart b/app/lib/renderers/cursors/text.dart index edc9799eddcc..322b9ec5473b 100644 --- a/app/lib/renderers/cursors/text.dart +++ b/app/lib/renderers/cursors/text.dart @@ -25,7 +25,9 @@ class TextCursor extends Renderer { const icon = PhosphorIconsLight.cursorText; final property = element.context?.getDefinedProperty(document); final iconSize = - (property ?? const text.DefinedParagraphProperty()).span.getSize(); + (property ?? const text.DefinedParagraphProperty()).span.getSize() * + (element.context?.element?.scale ?? + (element.painter.zoomDependent ? transform.size : 1)); final iconColor = Color(property?.span.color ?? colorScheme?.primary.value ?? Colors.black.value); @@ -81,15 +83,18 @@ class TextSelectionCursor extends Renderer { final cursorBox = element.textPainter.getOffsetForCaret(selection.base, Rect.zero); final height = - element.textPainter.getFullHeightForCaret(selection.base, Rect.zero); + element.textPainter.getFullHeightForCaret(selection.base, Rect.zero) ?? + 0; canvas.drawRect( Rect.fromLTWH( - textElement.position.x + cursorBox.dx - 1, + textElement.position.x + cursorBox.dx - 1 / transform.size, textElement.position.y + cursorBox.dy, - 2, - height ?? element.textPainter.preferredLineHeight, + 2 / transform.size, + height, ), - Paint()..color = color, + Paint() + ..color = color + ..strokeWidth = 1 / transform.size, ); final rect = element.getRect(); @@ -99,7 +104,7 @@ class TextSelectionCursor extends Renderer { Paint() ..color = color.withOpacity(0.5) ..style = PaintingStyle.stroke - ..strokeWidth = 1, + ..strokeWidth = 1 / transform.size, ); } } diff --git a/app/lib/renderers/elements/text.dart b/app/lib/renderers/elements/text.dart index be86695710b3..5ab10114cce6 100644 --- a/app/lib/renderers/elements/text.dart +++ b/app/lib/renderers/elements/text.dart @@ -63,7 +63,7 @@ class TextRenderer extends Renderer { TextStyle _buildSpanStyle(text.DefinedSpanProperty property, [text.DefinedParagraphProperty? parent]) { return TextStyle( - fontSize: property.getSize(parent), + fontSize: property.getSize(parent) * element.scale, color: Color(property.getColor(parent)), fontFamily: 'Roboto', fontStyle: diff --git a/app/lib/selections/painters/label.dart b/app/lib/selections/painters/label.dart index 56224c02c968..09ffbc573394 100644 --- a/app/lib/selections/painters/label.dart +++ b/app/lib/selections/painters/label.dart @@ -13,6 +13,15 @@ class LabelPainterSelection extends PainterSelection { packs.firstWhereOrNull((e) => e.name == selected.first.styleSheet.pack); return [ ...super.buildProperties(context), + CheckboxListTile( + value: selected.first.zoomDependent, + title: Text(AppLocalizations.of(context).zoomDependent), + onChanged: (value) => update( + context, + selected + .map((e) => e.copyWith( + zoomDependent: value ?? selected.first.zoomDependent)) + .toList())), const SizedBox(height: 16), DropdownButtonFormField( items: packs diff --git a/app/lib/selections/painters/pen.dart b/app/lib/selections/painters/pen.dart index 98ded96f99f1..8b038e3c6f42 100644 --- a/app/lib/selections/painters/pen.dart +++ b/app/lib/selections/painters/pen.dart @@ -20,7 +20,7 @@ class PenPainterSelection extends PainterSelection { .map((e) => e.copyWith( zoomDependent: value ?? selected.first.zoomDependent)) .toList())), - const SizedBox(height: 15), + const SizedBox(height: 16), ..._propertySelection.build(context, property, updateProperty), ]; } diff --git a/app/lib/views/toolbars/label.dart b/app/lib/views/toolbars/label.dart index c506e22c6213..7634cbc7e97b 100644 --- a/app/lib/views/toolbars/label.dart +++ b/app/lib/views/toolbars/label.dart @@ -168,6 +168,18 @@ class _LabelToolbarViewState extends State { )); }, ), + const SizedBox(width: 8), + IconButton( + icon: const PhosphorIcon( + PhosphorIconsLight.magnifyingGlass), + isSelected: widget.value.painter.zoomDependent, + tooltip: AppLocalizations.of(context).zoomDependent, + onPressed: () => widget.onChanged(widget.value + .copyWith( + painter: widget.value.painter.copyWith( + zoomDependent: !widget + .value.painter.zoomDependent))), + ), const SizedBox(width: 16), IconButton( icon: const PhosphorIcon(PhosphorIconsLight.article), @@ -391,11 +403,13 @@ class _LabelToolbarViewState extends State { textAlign: TextAlign.center, keyboardType: TextInputType.number, controller: _sizeController, - onFieldSubmitted: (current) => updateSpan( - (value) => value.copyWith( - size: double.tryParse(current) ?? span.size, - ), - ), + onFieldSubmitted: (current) { + updateSpan( + (value) => value.copyWith( + size: double.tryParse(current) ?? span.size, + ), + ); + }, ), ), const SizedBox(width: 16), diff --git a/fastlane/metadata/android/en-US/changelogs/61.txt b/fastlane/metadata/android/en-US/changelogs/61.txt index e4dee1952ccf..7ba025784993 100644 --- a/fastlane/metadata/android/en-US/changelogs/61.txt +++ b/fastlane/metadata/android/en-US/changelogs/61.txt @@ -1,4 +1,5 @@ * Use the best painter color based on the background color +* Make laser and text painter zoom dependent * Fix timeline colors * Fix reload after resizing the window * Fix reset does not replace templates