Skip to content

Commit

Permalink
Add duplicate layer button
Browse files Browse the repository at this point in the history
  • Loading branch information
CodeDoctorDE committed Nov 24, 2024
1 parent b8d3e8f commit e42e3c7
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 1 deletion.
1 change: 1 addition & 0 deletions api/lib/src/protocol/event.dart
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ class DocumentEvent extends ReplayEvent with _$DocumentEvent {

const factory DocumentEvent.layersMerged(
List<String> layers,
[bool duplicate = false],
) = LayersMerged;

const factory DocumentEvent.layerOrderChanged(
Expand Down
2 changes: 1 addition & 1 deletion app/lib/bloc/document_bloc.dart
Original file line number Diff line number Diff line change
Expand Up @@ -687,7 +687,7 @@ class DocumentBloc extends ReplayBloc<DocumentEvent, DocumentState> {
...aboveLayers.expand((e) => current.page.getLayer(e).content),
]);
final newLayers = layers
.where((e) => !mergedLayers.contains(e.id))
.where((e) => duplicate || !mergedLayers.contains(e.id))
.map((e) => e.id == mainLayer ? layer : e)
.toList();
return _saveState(
Expand Down
8 changes: 8 additions & 0 deletions app/lib/views/navigator/layers.dart
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,14 @@ class LayersView extends StatelessWidget {
],
child: Text(AppLocalizations.of(context).merge),
),
MenuItemButton(
leadingIcon:
const PhosphorIcon(PhosphorIconsLight.copySimple),
onPressed: () => context
.read<DocumentBloc>()
.add(LayersMerged.duplicate([id])),
child: Text(AppLocalizations.of(context).duplicate),
),
MenuItemButton(
leadingIcon: const PhosphorIcon(PhosphorIconsLight.trash),
onPressed: currentLayer == layer
Expand Down
1 change: 1 addition & 0 deletions metadata/en-US/changelogs/123.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
* Add toggle for color toolbar ([#611](https://github.com/LinwoodDev/Butterfly/issues/611))
* Add save button indicator for autosave ([#757](https://github.com/LinwoodDev/Butterfly/issues/757))
* Add duplicate layer button
* Fix webdav on windows

Read more here: https://linwood.dev/butterfly/2.2.3-rc.0

0 comments on commit e42e3c7

Please sign in to comment.