Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(501)

Unified Diff: ui/file_manager/gallery/js/image_editor/image_transform.js

Issue 363873002: Gallery.app: Add buttons to the cropping mode to specifying the aspect ratio. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixed Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ui/file_manager/gallery/js/image_editor/image_editor.js ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/file_manager/gallery/js/image_editor/image_transform.js
diff --git a/ui/file_manager/gallery/js/image_editor/image_transform.js b/ui/file_manager/gallery/js/image_editor/image_transform.js
index dbb96516879ed581a5c6492ba49a69d0a47cf655..91d7a96b73c9221e51c2ab357c08b0817593bb7e 100644
--- a/ui/file_manager/gallery/js/image_editor/image_transform.js
+++ b/ui/file_manager/gallery/js/image_editor/image_transform.js
@@ -77,6 +77,38 @@ ImageEditor.Mode.Crop.prototype.setUp = function() {
};
/**
+ * @override
+ */
+ImageEditor.Mode.Crop.prototype.createTools = function(toolbar) {
+ var aspects = {
+ GALLERY_ASPECT_RATIO_1_1: 1 / 1,
+ GALLERY_ASPECT_RATIO_6_4: 6 / 4,
+ GALLERY_ASPECT_RATIO_7_5: 7 / 5,
+ GALLERY_ASPECT_RATIO_16_9: 16 / 9
+ };
+ for (name in aspects) {
+ toolbar.addButton(
+ name,
+ name,
+ function(aspect, event) {
+ var button = event.target;
+ if (button.classList.contains('selected')) {
+ button.classList.remove('selected');
+ this.cropRect_.fixedAspectRatio = null;
+ } else {
+ var selectedButtons =
+ toolbar.element.querySelectorAll('button.selected');
+ for (var i = 0; i < selectedButtons.length; i++) {
+ selectedButtons[i].classList.remove('selected');
+ }
+ button.classList.add('selected');
+ this.cropRect_.fixedAspectRatio = aspect;
+ }
+ }.bind(this, aspects[name]));
+ }
+};
+
+/**
* Handles resizing of the window and updates the crop rectangle.
* @private
*/
@@ -247,6 +279,13 @@ function DraggableRect(rect, viewport) {
*/
this.dragMode_ = null;
+ /**
+ * Fixed aspect ratio.
+ * The aspect ratio is not fixed when null.
+ * @type {?number}
+ */
+ this.fixedAspectRatio = null;
+
Object.seal(this);
}
@@ -501,7 +540,9 @@ DraggableRect.prototype.getDragHandler = function(
}
// Update aspect ratio.
- if (shiftKey)
+ if (this.fixedAspectRatio)
+ this.forceAspectRatio(this.fixedAspectRatio, clipRect);
+ else if (shiftKey)
this.forceAspectRatio(initialWidth / initialHeight, clipRect);
}.bind(this);
}
« no previous file with comments | « ui/file_manager/gallery/js/image_editor/image_editor.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698