diff --git a/src/editing/preview.rs b/src/editing/preview.rs
index a7ec3e8..2c9017d 100644
--- a/src/editing/preview.rs
+++ b/src/editing/preview.rs
@@ -1,8 +1,26 @@
-use crate::deps::*;
+// Copyright (c) 2024 Sophie Herold
+//
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, see .
+//
+// SPDX-License-Identifier: GPL-3.0-or-later
+
use glycin::{Operation, Operations};
use gtk::prelude::*;
use gufo_common::orientation::Rotation;
+use crate::deps::*;
+
pub fn apply_operations(
node: gsk::RenderNode,
width: u32,
diff --git a/src/widgets/edit/crop.rs b/src/widgets/edit/crop.rs
index 7046a16..d044f38 100644
--- a/src/widgets/edit/crop.rs
+++ b/src/widgets/edit/crop.rs
@@ -22,7 +22,7 @@ use adw::subclass::prelude::*;
use adw::{glib, gtk};
use crate::widgets::edit::LpEditCropSelection;
-use crate::widgets::LpImage;
+use crate::widgets::{edit_window, LpEditWindow, LpImage};
#[derive(Debug, Clone, Copy, Default, glib::Enum)]
#[enum_type(name = "LpAspectRatio")]
@@ -75,6 +75,8 @@ mod imp {
#[property(get, construct_only)]
original_image: OnceCell,
+ #[property(get, construct_only)]
+ edit_window: OnceCell,
#[property(get, set)]
child: OnceCell,
@@ -240,30 +242,47 @@ mod imp {
fn apply_crop(&self) {
if let Some(crop) = self.crop_area_image_coord() {
- self.image.add_operation(Operation::Clip(crop));
+ let edit_window = self.obj().edit_window();
+
+ edit_window.add_operation(Operation::Clip(crop));
+ self.image.set_operations(edit_window.operations());
+
self.reset_selection();
}
}
fn apply_mirror(&self) {
- self.image.add_operation(Operation::MirrorHorizontally);
+ let edit_window = self.obj().edit_window();
+
+ edit_window.add_operation(Operation::MirrorHorizontally);
+ self.image.set_operations(edit_window.operations());
+
self.reset_selection();
}
fn apply_rotate_cw(&self) {
- self.image
- .add_operation(Operation::Rotate(gufo_common::orientation::Rotation::_90));
+ let edit_window = self.obj().edit_window();
+
+ edit_window.add_operation(Operation::Rotate(gufo_common::orientation::Rotation::_90));
+ self.image.set_operations(edit_window.operations());
+
self.reset_selection();
}
fn apply_rotate_ccw(&self) {
- self.image
- .add_operation(Operation::Rotate(gufo_common::orientation::Rotation::_270));
+ let edit_window = self.obj().edit_window();
+
+ edit_window.add_operation(Operation::Rotate(gufo_common::orientation::Rotation::_270));
+ self.image.set_operations(edit_window.operations());
+
self.reset_selection();
}
fn apply_reset(&self) {
+ let obj = self.obj();
+
self.image.set_operations(None);
+ obj.edit_window().set_operations(None);
self.reset_selection();
}
}
@@ -275,9 +294,10 @@ glib::wrapper! {
}
impl LpEditCrop {
- pub fn new(original_image: LpImage) -> Self {
+ pub fn new(edit_window: LpEditWindow) -> Self {
glib::Object::builder()
- .property("original_image", original_image)
+ .property("original_image", edit_window.original_image())
+ .property("edit_window", edit_window)
.build()
}
diff --git a/src/widgets/edit_window.rs b/src/widgets/edit_window.rs
index 007b9b8..86def4d 100644
--- a/src/widgets/edit_window.rs
+++ b/src/widgets/edit_window.rs
@@ -15,10 +15,12 @@
//
// SPDX-License-Identifier: GPL-3.0-or-later
-use std::cell::OnceCell;
+use std::cell::{OnceCell, RefCell};
use adw::prelude::*;
use adw::subclass::prelude::*;
+use glycin::Operations;
+use std::sync::Arc;
use super::edit::LpEditCrop;
use super::{LpImage, LpWindow};
@@ -35,11 +37,15 @@ mod imp {
toolbar_view: TemplateChild,
#[template_child]
cancel: TemplateChild,
+ #[template_child]
+ save: TemplateChild,
#[property(get, construct_only)]
window: OnceCell,
#[property(get, construct_only)]
original_image: OnceCell,
+
+ pub(super) operations: RefCell