Skip to content

Commit

Permalink
Move eraser tool to property view
Browse files Browse the repository at this point in the history
  • Loading branch information
CodeDoctorDE committed Nov 2, 2024
1 parent fea5df1 commit 15c0ee6
Show file tree
Hide file tree
Showing 15 changed files with 88 additions and 136 deletions.
7 changes: 0 additions & 7 deletions app/lib/handlers/eraser.dart
Original file line number Diff line number Diff line change
Expand Up @@ -101,11 +101,4 @@ class EraserHandler extends Handler<EraserTool> {
// Returns the mouse cursor to be used when the user interacts with the eraser tool.
@override
MouseCursor get cursor => SystemMouseCursors.precise;

@override
PreferredSizeWidget? getToolbar(DocumentBloc bloc) => EraserToolbarView(
eraseElements: data.eraseElements,
onToggleEraseElements: () =>
changeTool(bloc, data.copyWith(eraseElements: !data.eraseElements)),
);
}
1 change: 0 additions & 1 deletion app/lib/handlers/handler.dart
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import 'package:butterfly/models/cursor.dart';
import 'package:butterfly/renderers/foregrounds/area.dart';
import 'package:butterfly/renderers/foregrounds/select.dart';
import 'package:butterfly/services/export.dart';
import 'package:butterfly/views/toolbar/eraser.dart';
import 'package:butterfly/visualizer/tool.dart';
import 'package:butterfly_api/butterfly_api.dart';
import 'package:butterfly_api/butterfly_text.dart' as text;
Expand Down
7 changes: 0 additions & 7 deletions app/lib/handlers/path_eraser.dart
Original file line number Diff line number Diff line change
Expand Up @@ -73,11 +73,4 @@ class PathEraserHandler extends Handler<PathEraserTool> {
context.getDocumentBloc().add(ElementsRemoved(_erased.toList()));
}
}

@override
PreferredSizeWidget? getToolbar(DocumentBloc bloc) => EraserToolbarView(
eraseElements: data.eraseElements,
onToggleEraseElements: () =>
changeTool(bloc, data.copyWith(eraseElements: !data.eraseElements)),
);
}
2 changes: 2 additions & 0 deletions app/lib/selections/properties/pen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ class PenPropertySelection extends PropertySelection<PenProperty>
) =>
[
...super.build(context, property, onChanged),
const SizedBox(height: 4),
ColorField(
value: Color(property.color),
onChanged: (value) =>
Expand All @@ -28,6 +29,7 @@ class PenPropertySelection extends PropertySelection<PenProperty>
onChangeEnd: (value) => onChanged(property.copyWith(
color: convertColor(property.color, value.toInt()))),
),
const SizedBox(height: 4),
CheckboxListTile(
value: property.fill,
title: Text(AppLocalizations.of(context).fill),
Expand Down
1 change: 1 addition & 0 deletions app/lib/selections/tools/area.dart
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ class AreaToolSelection extends ToolSelection<AreaTool> {
selected
.map((e) => e.copyWith(constrainedAspectRatio: value))
.toList())),
const SizedBox(height: 4),
CheckboxListTile(
title: Text(AppLocalizations.of(context).askForName),
value: tool.askForName,
Expand Down
11 changes: 11 additions & 0 deletions app/lib/selections/tools/eraser.dart
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,17 @@ class EraserToolSelection extends ToolSelection<EraserTool> {
onChangeEnd: (value) => update(context,
selected.map((e) => e.copyWith(strokeWidth: value)).toList()),
),
const SizedBox(height: 4),
CheckboxListTile(
value: selected.first.eraseElements,
title: Text(AppLocalizations.of(context).deleteElements),
secondary: const PhosphorIcon(PhosphorIconsLight.image),
onChanged: (value) => update(
context,
selected
.map((e) => e.copyWith(eraseElements: value ?? false))
.toList()),
),
];
}

Expand Down
1 change: 1 addition & 0 deletions app/lib/selections/tools/laser.dart
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ class LaserToolSelection extends ToolSelection<LaserTool> {
selected.map((e) => e.copyWith(thinning: value)).toList(),
),
),
const SizedBox(height: 4),
ColorField(
value: Color(selected.first.color),
onChanged: (value) => update(
Expand Down
11 changes: 11 additions & 0 deletions app/lib/selections/tools/path_eraser.dart
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,17 @@ class PathEraserToolSelection extends ToolSelection<PathEraserTool> {
defaultValue: 5,
onChangeEnd: (value) => update(context,
selected.map((e) => e.copyWith(strokeWidth: value)).toList())),
const SizedBox(height: 4),
CheckboxListTile(
value: selected.first.eraseElements,
title: Text(AppLocalizations.of(context).deleteElements),
secondary: const PhosphorIcon(PhosphorIconsLight.image),
onChanged: (value) => update(
context,
selected
.map((e) => e.copyWith(eraseElements: value ?? false))
.toList()),
),
];
}

Expand Down
1 change: 1 addition & 0 deletions app/lib/selections/tools/tool.dart
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ class ToolSelection<T extends Tool> extends Selection<T> {
initialValue: initialName,
onChanged: (value) => update(context,
selected.map((e) => e.copyWith(name: value) as T).toList())),
const SizedBox(height: 4),
];
}

Expand Down
37 changes: 0 additions & 37 deletions app/lib/views/toolbar/eraser.dart

This file was deleted.

8 changes: 4 additions & 4 deletions app/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -217,10 +217,10 @@ packages:
dependency: "direct main"
description:
name: camera_windows
sha256: "12df8bf0a8b49acd65dc07768fb2cdc9552ab46c2242de88fb208776d8d334da"
sha256: "33cd8fc7e4e30cfd32b63a84fa2f753da04e087dd8cc2b46672ad3f0e604fb86"
url: "https://pub.dev"
source: hosted
version: "0.2.5"
version: "0.2.5+1"
characters:
dependency: transitive
description:
Expand Down Expand Up @@ -1626,10 +1626,10 @@ packages:
dependency: transitive
description:
name: win32
sha256: "10169d3934549017f0ae278ccb07f828f9d6ea21573bab0fb77b0e1ef0fce454"
sha256: "84ba388638ed7a8cb3445a320c8273136ab2631cd5f2c57888335504ddab1bc2"
url: "https://pub.dev"
source: hosted
version: "5.7.2"
version: "5.8.0"
win32_registry:
dependency: transitive
description:
Expand Down
4 changes: 2 additions & 2 deletions docs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"dependencies": {
"@astrojs/check": "^0.9.4",
"@astrojs/react": "^3.6.2",
"@astrojs/starlight": "^0.28.4",
"@astrojs/starlight": "^0.28.5",
"@phosphor-icons/react": "^2.1.7",
"@types/react": "^18.3.12",
"@types/react-dom": "^18.3.1",
Expand All @@ -26,6 +26,6 @@
},
"packageManager": "[email protected]",
"devDependencies": {
"sass": "^1.80.5"
"sass": "^1.80.6"
}
}
Loading

0 comments on commit 15c0ee6

Please sign in to comment.