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

Side by Side Diff: ui/file_manager/gallery/js/image_editor/commands.js

Issue 624563002: Files.app: Rename Rect used in Gallery with ImageRect. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 2 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 unified diff | Download patch
« no previous file with comments | « no previous file | ui/file_manager/gallery/js/image_editor/image_editor.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 'use strict'; 5 'use strict';
6 6
7 /** 7 /**
8 * Command queue is the only way to modify images. 8 * Command queue is the only way to modify images.
9 * Supports undo/redo. 9 * Supports undo/redo.
10 * Command execution is asynchronous (callback-based). 10 * Command execution is asynchronous (callback-based).
(...skipping 346 matching lines...) Expand 10 before | Expand all | Expand 10 after
357 357
358 /** @override */ 358 /** @override */
359 Command.Rotate.prototype.revertView = function(canvas, imageView) { 359 Command.Rotate.prototype.revertView = function(canvas, imageView) {
360 return imageView.replaceAndAnimate(canvas, null, -this.rotate90_); 360 return imageView.replaceAndAnimate(canvas, null, -this.rotate90_);
361 }; 361 };
362 362
363 363
364 /** 364 /**
365 * Crop command. 365 * Crop command.
366 * 366 *
367 * @param {Rect} imageRect Crop rectangle in image coordinates. 367 * @param {ImageRect} imageRect Crop rectangle in image coordinates.
368 * @constructor 368 * @constructor
369 * @extends {Command} 369 * @extends {Command}
370 */ 370 */
371 Command.Crop = function(imageRect) { 371 Command.Crop = function(imageRect) {
372 Command.call(this, 'crop' + imageRect.toString()); 372 Command.call(this, 'crop' + imageRect.toString());
373 this.imageRect_ = imageRect; 373 this.imageRect_ = imageRect;
374 }; 374 };
375 375
376 Command.Crop.prototype = { __proto__: Command.prototype }; 376 Command.Crop.prototype = { __proto__: Command.prototype };
377 377
378 /** @override */ 378 /** @override */
379 Command.Crop.prototype.execute = function( 379 Command.Crop.prototype.execute = function(
380 document, srcCanvas, callback, uiContext) { 380 document, srcCanvas, callback, uiContext) {
381 var result = this.createCanvas_( 381 var result = this.createCanvas_(
382 document, srcCanvas, this.imageRect_.width, this.imageRect_.height); 382 document, srcCanvas, this.imageRect_.width, this.imageRect_.height);
383 Rect.drawImage(result.getContext('2d'), srcCanvas, null, this.imageRect_); 383 ImageRect.drawImage(
384 result.getContext('2d'), srcCanvas, null, this.imageRect_);
384 var delay; 385 var delay;
385 if (uiContext.imageView) { 386 if (uiContext.imageView) {
386 delay = uiContext.imageView.replaceAndAnimate(result, this.imageRect_, 0); 387 delay = uiContext.imageView.replaceAndAnimate(result, this.imageRect_, 0);
387 } 388 }
388 setTimeout(callback, 0, result, delay); 389 setTimeout(callback, 0, result, delay);
389 }; 390 };
390 391
391 /** @override */ 392 /** @override */
392 Command.Crop.prototype.revertView = function(canvas, imageView) { 393 Command.Crop.prototype.revertView = function(canvas, imageView) {
393 return imageView.animateAndReplace(canvas, this.imageRect_); 394 return imageView.animateAndReplace(canvas, this.imageRect_);
(...skipping 26 matching lines...) Expand all
420 421
421 function onProgressVisible(updatedRow, rowCount) { 422 function onProgressVisible(updatedRow, rowCount) {
422 if (updatedRow == rowCount) { 423 if (updatedRow == rowCount) {
423 uiContext.imageView.replace(result); 424 uiContext.imageView.replace(result);
424 if (self.message_) 425 if (self.message_)
425 uiContext.prompt.show(self.message_, 2000); 426 uiContext.prompt.show(self.message_, 2000);
426 callback(result); 427 callback(result);
427 } else { 428 } else {
428 var viewport = uiContext.imageView.viewport_; 429 var viewport = uiContext.imageView.viewport_;
429 430
430 var imageStrip = new Rect(viewport.getImageBounds()); 431 var imageStrip = new ImageRect(viewport.getImageBounds());
431 imageStrip.top = previousRow; 432 imageStrip.top = previousRow;
432 imageStrip.height = updatedRow - previousRow; 433 imageStrip.height = updatedRow - previousRow;
433 434
434 var screenStrip = new Rect(viewport.getImageBoundsOnScreen()); 435 var screenStrip = new ImageRect(viewport.getImageBoundsOnScreen());
435 screenStrip.top = Math.round(viewport.imageToScreenY(previousRow)); 436 screenStrip.top = Math.round(viewport.imageToScreenY(previousRow));
436 screenStrip.height = 437 screenStrip.height =
437 Math.round(viewport.imageToScreenY(updatedRow)) - screenStrip.top; 438 Math.round(viewport.imageToScreenY(updatedRow)) - screenStrip.top;
438 439
439 uiContext.imageView.paintDeviceRect(result, imageStrip); 440 uiContext.imageView.paintDeviceRect(result, imageStrip);
440 previousRow = updatedRow; 441 previousRow = updatedRow;
441 } 442 }
442 } 443 }
443 444
444 function onProgressInvisible(updatedRow, rowCount) { 445 function onProgressInvisible(updatedRow, rowCount) {
445 if (updatedRow == rowCount) { 446 if (updatedRow == rowCount) {
446 callback(result); 447 callback(result);
447 } 448 }
448 } 449 }
449 450
450 filter.applyByStrips(result, srcCanvas, this.filter_, 451 filter.applyByStrips(result, srcCanvas, this.filter_,
451 uiContext.imageView ? onProgressVisible : onProgressInvisible); 452 uiContext.imageView ? onProgressVisible : onProgressInvisible);
452 }; 453 };
OLDNEW
« no previous file with comments | « no previous file | ui/file_manager/gallery/js/image_editor/image_editor.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698