Skip to content

Commit

Permalink
Make laser and text painter zoom dependent
Browse files Browse the repository at this point in the history
  • Loading branch information
CodeDoctorDE committed Apr 21, 2023
1 parent aa20097 commit dfa2ed2
Show file tree
Hide file tree
Showing 16 changed files with 278 additions and 80 deletions.
1 change: 1 addition & 0 deletions api/lib/src/models/element.dart
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ class PadElement with _$PadElement {
@DoublePointJsonConverter()
@Default(Point(0.0, 0.0))
Point<double> position,
@Default(1.0) double scale,
@Default(PackAssetLocation()) PackAssetLocation styleSheet,
required TextArea area,
@Default(ElementConstraint(size: 1000)) ElementConstraint constraint,
Expand Down
38 changes: 34 additions & 4 deletions api/lib/src/models/element.freezed.dart
Original file line number Diff line number Diff line change
Expand Up @@ -871,6 +871,7 @@ mixin _$PadElement {
required TResult Function(
String layer,
@DoublePointJsonConverter() Point<double> position,
double scale,
PackAssetLocation styleSheet,
TextArea area,
ElementConstraint constraint)
Expand Down Expand Up @@ -907,6 +908,7 @@ mixin _$PadElement {
TResult? Function(
String layer,
@DoublePointJsonConverter() Point<double> position,
double scale,
PackAssetLocation styleSheet,
TextArea area,
ElementConstraint constraint)?
Expand Down Expand Up @@ -943,6 +945,7 @@ mixin _$PadElement {
TResult Function(
String layer,
@DoublePointJsonConverter() Point<double> position,
double scale,
PackAssetLocation styleSheet,
TextArea area,
ElementConstraint constraint)?
Expand Down Expand Up @@ -1147,6 +1150,7 @@ class _$PenElement implements PenElement {
required TResult Function(
String layer,
@DoublePointJsonConverter() Point<double> position,
double scale,
PackAssetLocation styleSheet,
TextArea area,
ElementConstraint constraint)
Expand Down Expand Up @@ -1186,6 +1190,7 @@ class _$PenElement implements PenElement {
TResult? Function(
String layer,
@DoublePointJsonConverter() Point<double> position,
double scale,
PackAssetLocation styleSheet,
TextArea area,
ElementConstraint constraint)?
Expand Down Expand Up @@ -1225,6 +1230,7 @@ class _$PenElement implements PenElement {
TResult Function(
String layer,
@DoublePointJsonConverter() Point<double> position,
double scale,
PackAssetLocation styleSheet,
TextArea area,
ElementConstraint constraint)?
Expand Down Expand Up @@ -1339,6 +1345,7 @@ abstract class _$$TextElementCopyWith<$Res>
$Res call(
{String layer,
@DoublePointJsonConverter() Point<double> position,
double scale,
PackAssetLocation styleSheet,
TextArea area,
ElementConstraint constraint});
Expand All @@ -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,
Expand All @@ -1374,6 +1382,10 @@ class __$$TextElementCopyWithImpl<$Res>
? _value.position
: position // ignore: cast_nullable_to_non_nullable
as Point<double>,
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
Expand Down Expand Up @@ -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),
Expand All @@ -1438,6 +1451,9 @@ class _$TextElement implements TextElement {
final Point<double> position;
@override
@JsonKey()
final double scale;
@override
@JsonKey()
final PackAssetLocation styleSheet;
@override
final TextArea area;
Expand All @@ -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)
Expand All @@ -1468,6 +1484,7 @@ class _$TextElement implements TextElement {
required TResult Function(
String layer,
@DoublePointJsonConverter() Point<double> position,
double scale,
PackAssetLocation styleSheet,
TextArea area,
ElementConstraint constraint)
Expand Down Expand Up @@ -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
Expand All @@ -1507,6 +1524,7 @@ class _$TextElement implements TextElement {
TResult? Function(
String layer,
@DoublePointJsonConverter() Point<double> position,
double scale,
PackAssetLocation styleSheet,
TextArea area,
ElementConstraint constraint)?
Expand Down Expand Up @@ -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
Expand All @@ -1546,6 +1564,7 @@ class _$TextElement implements TextElement {
TResult Function(
String layer,
@DoublePointJsonConverter() Point<double> position,
double scale,
PackAssetLocation styleSheet,
TextArea area,
ElementConstraint constraint)?
Expand Down Expand Up @@ -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();
}
Expand Down Expand Up @@ -1632,6 +1651,7 @@ abstract class TextElement implements PadElement {
const factory TextElement(
{final String layer,
@DoublePointJsonConverter() final Point<double> position,
final double scale,
final PackAssetLocation styleSheet,
required final TextArea area,
final ElementConstraint constraint}) = _$TextElement;
Expand All @@ -1643,6 +1663,7 @@ abstract class TextElement implements PadElement {
String get layer;
@DoublePointJsonConverter()
Point<double> get position;
double get scale;
PackAssetLocation get styleSheet;
TextArea get area;
ElementConstraint get constraint;
Expand Down Expand Up @@ -1786,6 +1807,7 @@ class _$ImageElement implements ImageElement {
required TResult Function(
String layer,
@DoublePointJsonConverter() Point<double> position,
double scale,
PackAssetLocation styleSheet,
TextArea area,
ElementConstraint constraint)
Expand Down Expand Up @@ -1825,6 +1847,7 @@ class _$ImageElement implements ImageElement {
TResult? Function(
String layer,
@DoublePointJsonConverter() Point<double> position,
double scale,
PackAssetLocation styleSheet,
TextArea area,
ElementConstraint constraint)?
Expand Down Expand Up @@ -1864,6 +1887,7 @@ class _$ImageElement implements ImageElement {
TResult Function(
String layer,
@DoublePointJsonConverter() Point<double> position,
double scale,
PackAssetLocation styleSheet,
TextArea area,
ElementConstraint constraint)?
Expand Down Expand Up @@ -2106,6 +2130,7 @@ class _$SvgElement implements SvgElement {
required TResult Function(
String layer,
@DoublePointJsonConverter() Point<double> position,
double scale,
PackAssetLocation styleSheet,
TextArea area,
ElementConstraint constraint)
Expand Down Expand Up @@ -2145,6 +2170,7 @@ class _$SvgElement implements SvgElement {
TResult? Function(
String layer,
@DoublePointJsonConverter() Point<double> position,
double scale,
PackAssetLocation styleSheet,
TextArea area,
ElementConstraint constraint)?
Expand Down Expand Up @@ -2184,6 +2210,7 @@ class _$SvgElement implements SvgElement {
TResult Function(
String layer,
@DoublePointJsonConverter() Point<double> position,
double scale,
PackAssetLocation styleSheet,
TextArea area,
ElementConstraint constraint)?
Expand Down Expand Up @@ -2396,6 +2423,7 @@ class _$ShapeElement implements ShapeElement {
required TResult Function(
String layer,
@DoublePointJsonConverter() Point<double> position,
double scale,
PackAssetLocation styleSheet,
TextArea area,
ElementConstraint constraint)
Expand Down Expand Up @@ -2435,6 +2463,7 @@ class _$ShapeElement implements ShapeElement {
TResult? Function(
String layer,
@DoublePointJsonConverter() Point<double> position,
double scale,
PackAssetLocation styleSheet,
TextArea area,
ElementConstraint constraint)?
Expand Down Expand Up @@ -2474,6 +2503,7 @@ class _$ShapeElement implements ShapeElement {
TResult Function(
String layer,
@DoublePointJsonConverter() Point<double> position,
double scale,
PackAssetLocation styleSheet,
TextArea area,
ElementConstraint constraint)?
Expand Down
2 changes: 2 additions & 0 deletions api/lib/src/models/element.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions api/lib/src/models/painter.dart
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ class Painter with _$Painter {

factory Painter.label({
@Default('') String name,
@Default(true) bool zoomDependent,
@Default(PackAssetLocation()) PackAssetLocation styleSheet,
}) = LabelPainter;

Expand Down
Loading

0 comments on commit dfa2ed2

Please sign in to comment.