| 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 * ImageEditor is the top level object that holds together and connects | 6 * ImageEditor is the top level object that holds together and connects |
| 7 * everything needed for image editing. | 7 * everything needed for image editing. |
| 8 * | 8 * |
| 9 * @param {!Viewport} viewport The viewport. | 9 * @param {!Viewport} viewport The viewport. |
| 10 * @param {!ImageView} imageView The ImageView containing the images to edit. | 10 * @param {!ImageView} imageView The ImageView containing the images to edit. |
| (...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 294 // First undo click should dismiss the uncommitted modifications. | 294 // First undo click should dismiss the uncommitted modifications. |
| 295 if (this.currentMode_ && this.currentMode_.isUpdated()) { | 295 if (this.currentMode_ && this.currentMode_.isUpdated()) { |
| 296 this.currentMode_.reset(); | 296 this.currentMode_.reset(); |
| 297 return; | 297 return; |
| 298 } | 298 } |
| 299 | 299 |
| 300 this.getPrompt().hide(); | 300 this.getPrompt().hide(); |
| 301 this.leaveModeInternal_(false, false /* not to switch mode */); | 301 this.leaveModeInternal_(false, false /* not to switch mode */); |
| 302 this.commandQueue_.undo(); | 302 this.commandQueue_.undo(); |
| 303 this.updateUndoRedo(); | 303 this.updateUndoRedo(); |
| 304 this.calculateModeApplicativity_(); |
| 304 }; | 305 }; |
| 305 | 306 |
| 306 /** | 307 /** |
| 307 * Redo the recently un-done command. | 308 * Redo the recently un-done command. |
| 308 */ | 309 */ |
| 309 ImageEditor.prototype.redo = function() { | 310 ImageEditor.prototype.redo = function() { |
| 310 if (this.isLocked()) return; | 311 if (this.isLocked()) return; |
| 311 this.recordToolUse('redo'); | 312 this.recordToolUse('redo'); |
| 312 this.getPrompt().hide(); | 313 this.getPrompt().hide(); |
| 313 this.leaveModeInternal_(false, false /* not to switch mode */); | 314 this.leaveModeInternal_(false, false /* not to switch mode */); |
| 314 this.commandQueue_.redo(); | 315 this.commandQueue_.redo(); |
| 315 this.updateUndoRedo(); | 316 this.updateUndoRedo(); |
| 317 this.calculateModeApplicativity_(); |
| 316 }; | 318 }; |
| 317 | 319 |
| 318 /** | 320 /** |
| 319 * Update Undo/Redo buttons state. | 321 * Update Undo/Redo buttons state. |
| 320 */ | 322 */ |
| 321 ImageEditor.prototype.updateUndoRedo = function() { | 323 ImageEditor.prototype.updateUndoRedo = function() { |
| 322 var canUndo = this.commandQueue_ && this.commandQueue_.canUndo(); | 324 var canUndo = this.commandQueue_ && this.commandQueue_.canUndo(); |
| 323 var canRedo = this.commandQueue_ && this.commandQueue_.canRedo(); | 325 var canRedo = this.commandQueue_ && this.commandQueue_.canRedo(); |
| 324 ImageUtil.setAttribute(this.undoButton_, 'disabled', !canUndo); | 326 ImageUtil.setAttribute(this.undoButton_, 'disabled', !canUndo); |
| 325 ImageUtil.setAttribute(this.redoButton_, 'disabled', !canRedo); | 327 ImageUtil.setAttribute(this.redoButton_, 'disabled', !canRedo); |
| (...skipping 302 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 628 if (!this.currentMode_.instant) { | 630 if (!this.currentMode_.instant) { |
| 629 this.getViewport().setScreenTop( | 631 this.getViewport().setScreenTop( |
| 630 ImageEditor.Toolbar.HEIGHT + mode.paddingTop); | 632 ImageEditor.Toolbar.HEIGHT + mode.paddingTop); |
| 631 this.getViewport().setScreenBottom( | 633 this.getViewport().setScreenBottom( |
| 632 ImageEditor.Toolbar.HEIGHT * 2 + mode.paddingBottom); | 634 ImageEditor.Toolbar.HEIGHT * 2 + mode.paddingBottom); |
| 633 this.getImageView().applyViewportChange(); | 635 this.getImageView().applyViewportChange(); |
| 634 } | 636 } |
| 635 | 637 |
| 636 this.currentMode_.setUp(); | 638 this.currentMode_.setUp(); |
| 637 | 639 |
| 640 this.calculateModeApplicativity_(); |
| 638 if (this.currentMode_.instant) { // Instant tool. | 641 if (this.currentMode_.instant) { // Instant tool. |
| 639 this.leaveModeInternal_(true, false /* not to switch mode */); | 642 this.leaveModeInternal_(true, false /* not to switch mode */); |
| 640 return; | 643 return; |
| 641 } | 644 } |
| 642 | 645 |
| 643 this.exitButton_.hidden = true; | 646 this.exitButton_.hidden = true; |
| 644 | 647 |
| 645 this.modeToolbar_.clear(); | 648 this.modeToolbar_.clear(); |
| 646 this.currentMode_.createTools(this.modeToolbar_); | 649 this.currentMode_.createTools(this.modeToolbar_); |
| 647 this.modeToolbar_.show(true); | 650 this.modeToolbar_.show(true); |
| 648 this.calculateModeApplicativity_(); | |
| 649 }; | 651 }; |
| 650 | 652 |
| 651 /** | 653 /** |
| 652 * Handles click event of Done button. | 654 * Handles click event of Done button. |
| 653 * @param {!Event} event An event. | 655 * @param {!Event} event An event. |
| 654 * @private | 656 * @private |
| 655 */ | 657 */ |
| 656 ImageEditor.prototype.onDoneClicked_ = function(event) { | 658 ImageEditor.prototype.onDoneClicked_ = function(event) { |
| 657 this.leaveModeInternal_(true /* commit */, false /* not to switch mode */); | 659 this.leaveModeInternal_(true /* commit */, false /* not to switch mode */); |
| 658 }; | 660 }; |
| (...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 803 if (this.getMode()) { | 805 if (this.getMode()) { |
| 804 var action = this.buffer_.getDoubleTapAction(x, y); | 806 var action = this.buffer_.getDoubleTapAction(x, y); |
| 805 if (action === ImageBuffer.DoubleTapAction.COMMIT) | 807 if (action === ImageBuffer.DoubleTapAction.COMMIT) |
| 806 this.leaveModeInternal_(true, false /* not to switch mode */); | 808 this.leaveModeInternal_(true, false /* not to switch mode */); |
| 807 else if (action === ImageBuffer.DoubleTapAction.CANCEL) | 809 else if (action === ImageBuffer.DoubleTapAction.CANCEL) |
| 808 this.leaveModeInternal_(false, false /* not to switch mode */); | 810 this.leaveModeInternal_(false, false /* not to switch mode */); |
| 809 } | 811 } |
| 810 }; | 812 }; |
| 811 | 813 |
| 812 /** | 814 /** |
| 815 * Called when the user starts editing image. |
| 816 */ |
| 817 ImageEditor.prototype.onStartEditing = function() { |
| 818 this.calculateModeApplicativity_(); |
| 819 }; |
| 820 |
| 821 /** |
| 813 * A helper object for panning the ImageBuffer. | 822 * A helper object for panning the ImageBuffer. |
| 814 * | 823 * |
| 815 * @param {!HTMLElement} rootContainer The top-level container. | 824 * @param {!HTMLElement} rootContainer The top-level container. |
| 816 * @param {!HTMLElement} container The container for mouse events. | 825 * @param {!HTMLElement} container The container for mouse events. |
| 817 * @param {!ImageBuffer} buffer Image buffer. | 826 * @param {!ImageBuffer} buffer Image buffer. |
| 818 * @constructor | 827 * @constructor |
| 819 * @struct | 828 * @struct |
| 820 */ | 829 */ |
| 821 ImageEditor.MouseControl = function(rootContainer, container, buffer) { | 830 ImageEditor.MouseControl = function(rootContainer, container, buffer) { |
| 822 this.rootContainer_ = rootContainer; | 831 this.rootContainer_ = rootContainer; |
| (...skipping 696 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1519 | 1528 |
| 1520 /** | 1529 /** |
| 1521 * Hide the prompt. | 1530 * Hide the prompt. |
| 1522 */ | 1531 */ |
| 1523 ImageEditor.Prompt.prototype.hide = function() { | 1532 ImageEditor.Prompt.prototype.hide = function() { |
| 1524 if (!this.prompt_) return; | 1533 if (!this.prompt_) return; |
| 1525 this.prompt_.setAttribute('state', 'fadeout'); | 1534 this.prompt_.setAttribute('state', 'fadeout'); |
| 1526 // Allow some time for the animation to play out. | 1535 // Allow some time for the animation to play out. |
| 1527 this.setTimer(this.reset.bind(this), 500); | 1536 this.setTimer(this.reset.bind(this), 500); |
| 1528 }; | 1537 }; |
| OLD | NEW |