summaryrefslogtreecommitdiff
path: root/src/editing_tools
diff options
context:
space:
mode:
authorJörg Frings-Fürst <debian@jff-webhosting.net>2014-09-23 09:36:56 +0200
committerJörg Frings-Fürst <debian@jff-webhosting.net>2014-09-23 09:36:56 +0200
commit8004f1a7ad3cc6a3659517f3374bdf1b63416b24 (patch)
treeb7b82cc6e01cd47d22f660e25508a7d8d555dc89 /src/editing_tools
parent28c68a75acac7ac3ce7fb169bc6aa65e16551c53 (diff)
parent566dc060676b41e1e58a446b7dcc4159e242fee6 (diff)
Merge tag 'upstream/0.20.0'
Upstream version 0.20.0
Diffstat (limited to 'src/editing_tools')
-rw-r--r--src/editing_tools/EditingTools.vala29
1 files changed, 29 insertions, 0 deletions
diff --git a/src/editing_tools/EditingTools.vala b/src/editing_tools/EditingTools.vala
index b06dbf4..f5fb144 100644
--- a/src/editing_tools/EditingTools.vala
+++ b/src/editing_tools/EditingTools.vala
@@ -927,6 +927,25 @@ public class CropTool : EditingTool {
return result;
}
+
+ private float get_constraint_aspect_ratio_for_constraint(ConstraintDescription constraint, Photo photo) {
+ float result = constraint.aspect_ratio;
+
+ if (result == ORIGINAL_ASPECT_RATIO) {
+ Dimensions orig_dim = photo.get_original_dimensions();
+ result = ((float) orig_dim.width) / ((float) orig_dim.height);
+ } else if (result == SCREEN_ASPECT_RATIO) {
+ Gdk.Screen screen = Gdk.Screen.get_default();
+ result = ((float) screen.get_width()) / ((float) screen.get_height());
+ } else if (result == CUSTOM_ASPECT_RATIO) {
+ result = custom_aspect_ratio;
+ }
+ if (reticle_orientation == ReticleOrientation.PORTRAIT)
+ result = 1.0f / result;
+
+ return result;
+
+ }
private void constraint_changed() {
ConstraintDescription selected_constraint = get_selected_constraint();
@@ -1090,6 +1109,16 @@ public class CropTool : EditingTool {
if (desc != null && !desc.is_separator())
crop_tool_window.constraint_combo.set_active(index);
}
+ else {
+ // get aspect ratio of current photo
+ Photo photo = canvas.get_photo();
+ Dimensions cropped_dim = photo.get_dimensions();
+ float ratio = (float) cropped_dim.width / (float) cropped_dim.height;
+ for (int index = 1; index < constraints.length; index++) {
+ if (Math.fabs(ratio - get_constraint_aspect_ratio_for_constraint(constraints[index], photo)) < 0.005)
+ crop_tool_window.constraint_combo.set_active(index);
+ }
+ }
// set up the pivot reticle button
update_pivot_button_state();