Skip to content

Commit

Permalink
PAINTROID-454: Flutter: Add Layers - revert layer combination
Browse files Browse the repository at this point in the history
  • Loading branch information
Lenkomotive committed Jan 24, 2025
1 parent d5297c0 commit f15d742
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 16 deletions.
18 changes: 4 additions & 14 deletions lib/core/providers/state/canvas_state_provider.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import 'package:paintroid/core/commands/command_manager/command_manager_provider
import 'package:paintroid/core/commands/graphic_factory/graphic_factory_provider.dart';
import 'package:paintroid/core/providers/object/device_service.dart';
import 'package:paintroid/core/providers/state/canvas_state_data.dart';
import 'package:paintroid/core/providers/state/layer_menu_state_provider.dart';
import 'package:riverpod_annotation/riverpod_annotation.dart';

part 'canvas_state_provider.g.dart';
Expand Down Expand Up @@ -46,15 +45,11 @@ class CanvasStateProvider extends _$CanvasStateProvider {
final canvas = state.graphicFactory.createCanvasWithRecorder(recorder);
final size = state.size;
final bounds = Rect.fromLTWH(0, 0, size.width, size.height);

final currentLayer =
ref.read(layerMenuStateProvider.notifier).getSelectedLayer();

if (currentLayer.image != null) {
if (state.cachedImage != null) {
paintImage(
canvas: canvas,
rect: bounds,
image: currentLayer.image!,
image: state.cachedImage!,
fit: BoxFit.fill,
filterQuality: FilterQuality.none,
);
Expand All @@ -63,16 +58,11 @@ class CanvasStateProvider extends _$CanvasStateProvider {
state.commandManager.executeLastCommand(canvas);
final picture = recorder.endRecording();
final img = await picture.toImage(size.width.toInt(), size.height.toInt());
ref.read(layerMenuStateProvider.notifier).updateImageOfLayer(img);

final mergedImage = await ref
.read(layerMenuStateProvider.notifier)
.getMergedImageOfVisibleLayers(img);

state = state.copyWith(cachedImage: mergedImage);
state = state.copyWith(cachedImage: img);
}

Future<void> resetCanvasWithNewCommands(Iterable<Command> commands) async {
state.commandManager.clearRedoStack();
state.commandManager.clearUndoStack(newCommands: commands);
if (commands.isEmpty) {
state = state.copyWith(cachedImage: null);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import 'package:paintroid/core/enums/tool_types.dart';
import 'package:paintroid/core/providers/object/canvas_painter_provider.dart';
import 'package:paintroid/core/providers/object/device_service.dart';
import 'package:paintroid/core/providers/state/canvas_state_provider.dart';
import 'package:paintroid/core/providers/state/layer_menu_state_provider.dart';
import 'package:paintroid/core/providers/state/toolbox_state_provider.dart';
import 'package:paintroid/core/providers/state/workspace_state_notifier.dart';
import 'package:paintroid/ui/pages/workspace_page/components/drawing_surface/canvas_painter.dart';
Expand Down Expand Up @@ -45,7 +44,6 @@ class _DrawingCanvasState extends ConsumerState<DrawingCanvas> {
});

void _onPointerDown(PointerDownEvent _) {
ref.read(layerMenuStateProvider.notifier).hide();
_pointersOnScreen++;
if (_pointersOnScreen >= 2) {
_isZooming = true;
Expand Down

0 comments on commit f15d742

Please sign in to comment.