Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 * @fileoverview | 6 * @fileoverview |
| 7 * 'display-layout' presents a visual representation of the layout of one or | 7 * 'display-layout' presents a visual representation of the layout of one or |
| 8 * more displays and allows them to be arranged. | 8 * more displays and allows them to be arranged. |
| 9 */ | 9 */ |
| 10 | 10 |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 68 !this.mirroring, this.$.displayArea, this.onDrag_.bind(this)); | 68 !this.mirroring, this.$.displayArea, this.onDrag_.bind(this)); |
| 69 }, | 69 }, |
| 70 | 70 |
| 71 /** | 71 /** |
| 72 * Calculates the visual offset and scale for the display area | 72 * Calculates the visual offset and scale for the display area |
| 73 * (i.e. the ratio of the display area div size to the area required to | 73 * (i.e. the ratio of the display area div size to the area required to |
| 74 * contain the DisplayUnitInfo bounding boxes). | 74 * contain the DisplayUnitInfo bounding boxes). |
| 75 * @return {boolean} Whether the calculation was successful. | 75 * @return {boolean} Whether the calculation was successful. |
| 76 * @private | 76 * @private |
| 77 */ | 77 */ |
| 78 calculateVisualScale_() { | 78 calculateVisualScale_: function() { |
| 79 var displayAreaDiv = this.$.displayArea; | 79 var displayAreaDiv = this.$.displayArea; |
| 80 if (!displayAreaDiv || !displayAreaDiv.offsetWidth || !this.displays || | 80 if (!displayAreaDiv || !displayAreaDiv.offsetWidth || !this.displays || |
| 81 !this.displays.length) { | 81 !this.displays.length) { |
| 82 return false; | 82 return false; |
| 83 } | 83 } |
| 84 | 84 |
| 85 var display = this.displays[0]; | 85 var display = this.displays[0]; |
| 86 var bounds = this.getCalculatedDisplayBounds(display.id); | 86 var bounds = this.getCalculatedDisplayBounds(display.id); |
| 87 var boundsBoundingBox = { | 87 var boundsBoundingBox = { |
| 88 left: bounds.left, | 88 left: bounds.left, |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 208 // Make sure the dragged display is also selected. | 208 // Make sure the dragged display is also selected. |
| 209 if (id != this.selectedDisplay.id) | 209 if (id != this.selectedDisplay.id) |
| 210 this.fire('select-display', id); | 210 this.fire('select-display', id); |
| 211 | 211 |
| 212 var calculatedBounds = this.getCalculatedDisplayBounds(id); | 212 var calculatedBounds = this.getCalculatedDisplayBounds(id); |
| 213 newBounds = | 213 newBounds = |
| 214 /** @type {chrome.system.display.Bounds} */ ( | 214 /** @type {chrome.system.display.Bounds} */ ( |
| 215 Object.assign({}, calculatedBounds)); | 215 Object.assign({}, calculatedBounds)); |
| 216 newBounds.left += Math.round(amount.x / this.visualScale); | 216 newBounds.left += Math.round(amount.x / this.visualScale); |
| 217 newBounds.top += Math.round(amount.y / this.visualScale); | 217 newBounds.top += Math.round(amount.y / this.visualScale); |
| 218 newBounds = this.updateDisplayBounds(id, newBounds); | 218 |
| 219 if (this.displays.length >= 2) | |
| 220 newBounds = this.updateDisplayBounds(id, newBounds); | |
| 219 } | 221 } |
| 220 var left = | 222 var left = |
| 221 this.visualOffset_.left + Math.round(newBounds.left * this.visualScale); | 223 this.visualOffset_.left + Math.round(newBounds.left * this.visualScale); |
| 222 var top = | 224 var top = |
| 223 this.visualOffset_.top + Math.round(newBounds.top * this.visualScale); | 225 this.visualOffset_.top + Math.round(newBounds.top * this.visualScale); |
| 224 var div = this.$$('#_' + id); | 226 var div = this.$$('#_' + id); |
| 225 div.style.left = '' + left + 'px'; | 227 div.style.left = '' + left + 'px'; |
|
dpapad
2016/11/23 18:18:43
Unrelated drive-by question: What is the point of
stevenjb
2016/11/23 18:44:32
Some of this code is new, some of it was copy/past
dpapad
2016/11/23 18:51:21
I suggest holding off ES6-ifying this file, becaus
| |
| 226 div.style.top = '' + top + 'px'; | 228 div.style.top = '' + top + 'px'; |
| 227 }, | 229 }, |
| 228 | 230 |
| 229 }); | 231 }); |
| 230 | 232 |
| 231 })(); | 233 })(); |
| OLD | NEW |