diff --git a/data/resources/edit_crop.css b/data/resources/edit_crop.css
index 8aa7219..4e810dc 100644
--- a/data/resources/edit_crop.css
+++ b/data/resources/edit_crop.css
@@ -45,4 +45,9 @@ lpcrop {
.discarded-area {
background: var(--discarded-background);
+}
+
+.apply-button {
+ margin-right: 12px;
+ margin-top: -6px;
}
\ No newline at end of file
diff --git a/data/resources/icons/scalable/actions/apply-crop-symbolic.svg b/data/resources/icons/scalable/actions/apply-crop-symbolic.svg
new file mode 100644
index 0000000..8a4eba4
--- /dev/null
+++ b/data/resources/icons/scalable/actions/apply-crop-symbolic.svg
@@ -0,0 +1,2 @@
+
+
diff --git a/src/widgets/edit/crop.rs b/src/widgets/edit/crop.rs
index 4d50ab0..5ff88e1 100644
--- a/src/widgets/edit/crop.rs
+++ b/src/widgets/edit/crop.rs
@@ -71,8 +71,6 @@ mod imp {
image: TemplateChild,
#[template_child]
pub(super) selection: TemplateChild,
- #[template_child]
- pub apply_crop: TemplateChild,
#[property(get, set, builder(LpAspectRatio::default()))]
aspect_ratio: Cell,
@@ -229,9 +227,6 @@ mod imp {
self.crop_area_image_coord.replace(crop_area_image_coord);
}
- let apply_sensitive = self.cropped();
- self.apply_crop.set_visible(apply_sensitive);
-
self.obj().notify_cropped();
}
diff --git a/src/widgets/edit/crop.ui b/src/widgets/edit/crop.ui
index c5bee1a..311b041 100644
--- a/src/widgets/edit/crop.ui
+++ b/src/widgets/edit/crop.ui
@@ -323,18 +323,6 @@
LpEditCrop
-
-
-
diff --git a/src/widgets/edit/crop_selection.rs b/src/widgets/edit/crop_selection.rs
index f3b830d..425b655 100644
--- a/src/widgets/edit/crop_selection.rs
+++ b/src/widgets/edit/crop_selection.rs
@@ -26,7 +26,7 @@ use adw::{glib, gtk};
use super::crop::{LpAspectRatio, LpEditCrop, LpOrientation};
-const MIN_SELECTION_SIZE: f32 = 50.;
+const MIN_SELECTION_SIZE: f32 = 80.;
#[derive(Debug, Clone, Copy)]
struct InResize {
@@ -155,6 +155,9 @@ mod imp {
#[template_child]
handle_bottom_left: TemplateChild,
+ #[template_child]
+ apply_button: TemplateChild,
+
#[template_child]
selection_move: TemplateChild,
@@ -226,6 +229,7 @@ mod imp {
}
self.selection.set_cursor_from_name(Some("move"));
+ self.apply_button.set_cursor_from_name(Some("default"));
obj.crop()
.connect_aspect_ratio_notify(|x| x.selection().imp().on_aspect_ratio_changed());
@@ -256,7 +260,7 @@ mod imp {
let crop_area = imp.crop_area();
- imp.selection_in_resize.set(Some(InResize {
+ imp.set_selection_in_resize(Some(InResize {
corner,
initial_selection: crop_area,
}));
@@ -264,7 +268,7 @@ mod imp {
gesture.set_state(gtk::EventSequenceState::Claimed);
let crop_area = imp.crop_area();
- imp.selection_in_move.set(Some(InMove {
+ imp.set_selection_in_move(Some(InMove {
initial_selection: crop_area,
}));
} else {
@@ -315,8 +319,8 @@ mod imp {
#[weak]
obj,
move |_, _, _| {
- obj.imp().selection_in_resize.set(None);
- obj.imp().selection_in_move.set(None);
+ obj.imp().set_selection_in_resize(None);
+ obj.imp().set_selection_in_move(None);
}
));
}
@@ -683,6 +687,7 @@ mod imp {
self.crop_x.set(x);
self.space_top_left.set_width_request(x.round() as i32);
self.obj().notify_crop_x();
+ self.update_apply_crop_visibility();
}
/// Set y coordinate of crop selection rectangle origin
@@ -695,6 +700,7 @@ mod imp {
self.crop_y.set(y);
self.space_top_left.set_height_request(y.round() as i32);
self.obj().notify_crop_y();
+ self.update_apply_crop_visibility();
}
/// Set width of crop selection rectangle
@@ -707,6 +713,7 @@ mod imp {
self.crop_width.set(width);
self.selection.set_width_request(width.round() as i32);
self.obj().notify_crop_width();
+ self.update_apply_crop_visibility();
}
/// Set height of crop selection rectangle
@@ -719,6 +726,7 @@ mod imp {
self.crop_height.set(height);
self.selection.set_height_request(height.round() as i32);
self.obj().notify_crop_height();
+ self.update_apply_crop_visibility();
}
/// Width of area in which the crop selection can exist
@@ -728,6 +736,7 @@ mod imp {
fn set_total_width(&self, width: i32) {
self.obj().set_width_request(width);
+ self.update_apply_crop_visibility();
}
/// Height of area in which the crop selection can exist
@@ -737,6 +746,7 @@ mod imp {
fn set_total_height(&self, width: i32) {
self.obj().set_height_request(width);
+ self.update_apply_crop_visibility();
}
pub(super) fn aspect_ratio_animation(&self) -> &adw::TimedAnimation {
@@ -751,6 +761,24 @@ mod imp {
.build()
})
}
+
+ fn set_selection_in_resize(&self, in_resize: Option) {
+ self.selection_in_resize.replace(in_resize);
+ self.update_apply_crop_visibility();
+ }
+
+ fn set_selection_in_move(&self, in_move: Option) {
+ self.selection_in_move.replace(in_move);
+ self.update_apply_crop_visibility();
+ }
+
+ fn update_apply_crop_visibility(&self) {
+ self.apply_button.set_visible(
+ self.obj().is_cropped()
+ && !self.selection_in_resize.get().is_some()
+ && !self.selection_in_move.get().is_some(),
+ );
+ }
}
}
diff --git a/src/widgets/edit/crop_selection.ui b/src/widgets/edit/crop_selection.ui
index 8a27d91..8f9a5a3 100644
--- a/src/widgets/edit/crop_selection.ui
+++ b/src/widgets/edit/crop_selection.ui
@@ -128,7 +128,7 @@
true
0
- 1
+ 2
+
+
+