Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 /** | 5 /** |
| 6 * Crop mode. | 6 * Crop mode. |
| 7 * | 7 * |
| 8 * @extends {ImageEditor.Mode} | 8 * @extends {ImageEditor.Mode} |
| 9 * @constructor | 9 * @constructor |
| 10 * @struct | 10 * @struct |
| (...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 136 * @override | 136 * @override |
| 137 */ | 137 */ |
| 138 ImageEditor.Mode.Crop.prototype.createTools = function(toolbar) { | 138 ImageEditor.Mode.Crop.prototype.createTools = function(toolbar) { |
| 139 var aspects = { | 139 var aspects = { |
| 140 GALLERY_ASPECT_RATIO_1_1: 1 / 1, | 140 GALLERY_ASPECT_RATIO_1_1: 1 / 1, |
| 141 GALLERY_ASPECT_RATIO_6_4: 6 / 4, | 141 GALLERY_ASPECT_RATIO_6_4: 6 / 4, |
| 142 GALLERY_ASPECT_RATIO_7_5: 7 / 5, | 142 GALLERY_ASPECT_RATIO_7_5: 7 / 5, |
| 143 GALLERY_ASPECT_RATIO_16_9: 16 / 9 | 143 GALLERY_ASPECT_RATIO_16_9: 16 / 9 |
| 144 }; | 144 }; |
| 145 | 145 |
| 146 // TODO(fukino): The loop order is not guaranteed. Fix it! | |
|
oka
2016/10/06 09:11:55
suggestion: Consider using Map.
A Map object itera
fukino
2016/10/06 14:34:30
Map can be used if tooling support works well. I'l
| |
| 146 for (var name in aspects) { | 147 for (var name in aspects) { |
| 147 var button = toolbar.addButton( | 148 var button = toolbar.addButton( |
| 148 name, | 149 name, |
| 149 ImageEditor.Toolbar.ButtonType.LABEL, | 150 ImageEditor.Toolbar.ButtonType.LABEL, |
| 150 this.onCropAspectRatioClicked_.bind(this, toolbar, aspects[name]), | 151 this.onCropAspectRatioClicked_.bind(this, toolbar, aspects[name]), |
| 151 'crop-aspect-ratio'); | 152 'crop-aspect-ratio'); |
| 152 | 153 |
| 153 // Prevent from cropping by Enter key if the button is focused. | 154 // Prevent from cropping by Enter key if the button is focused. |
| 154 button.addEventListener('keydown', function(event) { | 155 button.addEventListener('keydown', function(event) { |
| 155 var key = util.getKeyModifiers(event) + event.key; | 156 var key = util.getKeyModifiers(event) + event.key; |
| (...skipping 581 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 737 break; | 738 break; |
| 738 case 'bottom': | 739 case 'bottom': |
| 739 this.bounds_.bottom = this.bounds_.top + newHeight; | 740 this.bounds_.bottom = this.bounds_.top + newHeight; |
| 740 break; | 741 break; |
| 741 case 'none': | 742 case 'none': |
| 742 this.bounds_.top = middle - newHeight / 2; | 743 this.bounds_.top = middle - newHeight / 2; |
| 743 this.bounds_.bottom = middle + newHeight / 2; | 744 this.bounds_.bottom = middle + newHeight / 2; |
| 744 break; | 745 break; |
| 745 } | 746 } |
| 746 }; | 747 }; |
| OLD | NEW |