| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 * A stack of overlays that display itself and handle mouse events. | 6 * A stack of overlays that display itself and handle mouse events. |
| 7 * TODO(kaznacheev) Consider disbanding this class and moving | 7 * TODO(kaznacheev) Consider disbanding this class and moving |
| 8 * the functionality to individual objects that display anything or handle | 8 * the functionality to individual objects that display anything or handle |
| 9 * mouse events. | 9 * mouse events. |
| 10 * @constructor | 10 * @constructor |
| 11 */ | 11 */ |
| 12 function ImageBuffer() { | 12 function ImageBuffer() { |
| 13 this.overlays_ = []; | 13 this.overlays_ = []; |
| 14 } | 14 } |
| 15 | 15 |
| 16 //TODO(JSDOC) | 16 /** |
| 17 * TODO(JSDOC). |
| 18 * @param {ImageBuffer.Overlay} overlay //TODO(JSDOC). |
| 19 */ |
| 17 ImageBuffer.prototype.addOverlay = function(overlay) { | 20 ImageBuffer.prototype.addOverlay = function(overlay) { |
| 18 var zIndex = overlay.getZIndex(); | 21 var zIndex = overlay.getZIndex(); |
| 19 // Store the overlays in the ascending Z-order. | 22 // Store the overlays in the ascending Z-order. |
| 20 var i; | 23 var i; |
| 21 for (i = 0; i != this.overlays_.length; i++) { | 24 for (i = 0; i != this.overlays_.length; i++) { |
| 22 if (zIndex < this.overlays_[i].getZIndex()) break; | 25 if (zIndex < this.overlays_[i].getZIndex()) break; |
| 23 } | 26 } |
| 24 this.overlays_.splice(i, 0, overlay); | 27 this.overlays_.splice(i, 0, overlay); |
| 25 }; | 28 }; |
| 26 | 29 |
| 27 //TODO(JSDOC) | 30 /** |
| 31 * TODO(JSDOC). |
| 32 * @param {ImageBuffer.Overlay} overlay //TODO(JSDOC). |
| 33 */ |
| 28 ImageBuffer.prototype.removeOverlay = function(overlay) { | 34 ImageBuffer.prototype.removeOverlay = function(overlay) { |
| 29 for (var i = 0; i != this.overlays_.length; i++) { | 35 for (var i = 0; i != this.overlays_.length; i++) { |
| 30 if (this.overlays_[i] == overlay) { | 36 if (this.overlays_[i] == overlay) { |
| 31 this.overlays_.splice(i, 1); | 37 this.overlays_.splice(i, 1); |
| 32 return; | 38 return; |
| 33 } | 39 } |
| 34 } | 40 } |
| 35 throw new Error('Cannot remove overlay ' + overlay); | 41 throw new Error('Cannot remove overlay ' + overlay); |
| 36 }; | 42 }; |
| 37 | 43 |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 112 NOTHING: 0, | 118 NOTHING: 0, |
| 113 COMMIT: 1, | 119 COMMIT: 1, |
| 114 CANCEL: 2 | 120 CANCEL: 2 |
| 115 }; | 121 }; |
| 116 | 122 |
| 117 /** | 123 /** |
| 118 * ImageBuffer.Overlay is a pluggable extension that modifies the outlook | 124 * ImageBuffer.Overlay is a pluggable extension that modifies the outlook |
| 119 * and the behavior of the ImageBuffer instance. | 125 * and the behavior of the ImageBuffer instance. |
| 120 * @class | 126 * @class |
| 121 */ | 127 */ |
| 122 //TODO(JSDOC) | |
| 123 ImageBuffer.Overlay = function() {}; | 128 ImageBuffer.Overlay = function() {}; |
| 124 | 129 |
| 125 //TODO(JSDOC) | 130 /** |
| 131 * TODO(JSDOC). |
| 132 * @return {number} //TODO(JSDOC). |
| 133 */ |
| 126 ImageBuffer.Overlay.prototype.getZIndex = function() { return 0 }; | 134 ImageBuffer.Overlay.prototype.getZIndex = function() { return 0 }; |
| 127 | 135 |
| 128 //TODO(JSDOC) | 136 /** |
| 137 * TODO(JSDOC). |
| 138 */ |
| 129 ImageBuffer.Overlay.prototype.draw = function() {}; | 139 ImageBuffer.Overlay.prototype.draw = function() {}; |
| 130 | 140 |
| 131 //TODO(JSDOC) | 141 /** |
| 132 ImageBuffer.Overlay.prototype.getCursorStyle = function() { return null }; | 142 * TODO(JSDOC). |
| 143 * @param {number} x X coordinate for cursor. |
| 144 * @param {number} y Y coordinate for cursor. |
| 145 * @param {boolean} mouseDown If mouse button is down. |
| 146 * @return {?string} A value for style.cursor CSS property or null for |
| 147 * default. |
| 148 */ |
| 149 ImageBuffer.Overlay.prototype.getCursorStyle = function(x, y, mouseDown) { |
| 150 return null; |
| 151 }; |
| 133 | 152 |
| 134 //TODO(JSDOC) | 153 /** |
| 135 ImageBuffer.Overlay.prototype.onClick = function() { return false }; | 154 * TODO(JSDOC). |
| 155 * @param {number} x //TODO(JSDOC). |
| 156 * @param {number} y //TODO(JSDOC). |
| 157 * @return {boolean} //TODO(JSDOC). |
| 158 */ |
| 159 ImageBuffer.Overlay.prototype.onClick = function(x, y) { |
| 160 return false; |
| 161 }; |
| 136 | 162 |
| 137 //TODO(JSDOC) | 163 /** |
| 138 ImageBuffer.Overlay.prototype.getDragHandler = function() { return null }; | 164 * TODO(JSDOC). |
| 165 * @param {number} x Event X coordinate. |
| 166 * @param {number} y Event Y coordinate. |
| 167 * @param {boolean} touch True if it's a touch event, false if mouse. |
| 168 * @return {function(number,number)} A function to be called on mouse drag. |
| 169 */ |
| 170 ImageBuffer.Overlay.prototype.getDragHandler = function(x, y, touch) { |
| 171 return null; |
| 172 }; |
| 139 | 173 |
| 140 //TODO(JSDOC) | 174 /** |
| 175 * TODO(JSDOC). |
| 176 * @param {number} x //TODO(JSDOC). |
| 177 * @param {number} y //TODO(JSDOC). |
| 178 * @return {ImageBuffer.DoubleTapAction} //TODO(JSDOC). |
| 179 */ |
| 141 ImageBuffer.Overlay.prototype.getDoubleTapAction = function(x, y) { | 180 ImageBuffer.Overlay.prototype.getDoubleTapAction = function(x, y) { |
| 142 return ImageBuffer.DoubleTapAction.NOTHING; | 181 return ImageBuffer.DoubleTapAction.NOTHING; |
| 143 }; | 182 }; |
| OLD | NEW |