diff options
author | Jörg Frings-Fürst <debian@jff-webhosting.net> | 2014-09-23 09:36:45 +0200 |
---|---|---|
committer | Jörg Frings-Fürst <debian@jff-webhosting.net> | 2014-09-23 09:36:45 +0200 |
commit | 566dc060676b41e1e58a446b7dcc4159e242fee6 (patch) | |
tree | 6eaeba1cf78d3f03b8a1d5bfa998eb104ca47425 /src/editing_tools | |
parent | 4ea2cc3bd4a7d9b1c54a9d33e6a1cf82e7c8c21d (diff) |
Imported Upstream version 0.20.0upstream/0.20.0
Diffstat (limited to 'src/editing_tools')
-rw-r--r-- | src/editing_tools/EditingTools.vala | 29 |
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(); |