Chromium Code Reviews| 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 /** | |
| 6 * @typedef {{ | |
| 7 * availableColorProfiles: Array.<{profileId: number, name: string}>, | |
| 8 * colorProfile: number, | |
| 9 * height: number, | |
| 10 * id: string, | |
| 11 * isInternal: boolean, | |
| 12 * isPrimary: boolean, | |
| 13 * resolutions: Array.<{width: number, height: number, originalWidth: number, | |
| 14 * originalHeight: number, deviceScaleFactor: number, scale: number, | |
| 15 * refreshRate: number, isBest: boolean, selected: boolean}>, | |
| 16 * name: string, | |
| 17 * orientation: number, | |
| 18 * width: number, | |
| 19 * x: number, | |
| 20 * y: number | |
| 21 * }} | |
| 22 */ | |
| 23 var DisplayInfo; | |
| 24 | |
| 25 cr.exportPath('options'); | |
|
Dan Beam
2014/09/11 02:53:09
why not options.{DisplayInfo,SecondaryDisplayLayou
Vitaly Pavlenko
2014/09/11 04:16:25
Done for SecondaryDisplayLayout.
I don't include
Dan Beam
2014/09/11 05:26:12
if the @typedef's never used outside of the namesp
Vitaly Pavlenko
2014/09/11 21:12:30
Done.
| |
| 26 | |
| 27 /** | |
| 28 * Enumeration of secondary display layout. The value has to be same as the | |
| 29 * values in ash/display/display_controller.cc. | |
| 30 * @enum {number} | |
| 31 */ | |
| 32 var SecondaryDisplayLayout = { | |
| 33 TOP: 0, | |
| 34 RIGHT: 1, | |
| 35 BOTTOM: 2, | |
| 36 LEFT: 3 | |
| 37 }; | |
| 38 | |
| 5 cr.define('options', function() { | 39 cr.define('options', function() { |
| 6 var Page = cr.ui.pageManager.Page; | 40 var Page = cr.ui.pageManager.Page; |
| 7 var PageManager = cr.ui.pageManager.PageManager; | 41 var PageManager = cr.ui.pageManager.PageManager; |
| 8 | 42 |
| 9 // The scale ratio of the display rectangle to its original size. | 43 // The scale ratio of the display rectangle to its original size. |
| 10 /** @const */ var VISUAL_SCALE = 1 / 10; | 44 /** @const */ var VISUAL_SCALE = 1 / 10; |
| 11 | 45 |
| 12 // The number of pixels to share the edges between displays. | 46 // The number of pixels to share the edges between displays. |
| 13 /** @const */ var MIN_OFFSET_OVERLAP = 5; | 47 /** @const */ var MIN_OFFSET_OVERLAP = 5; |
| 14 | 48 |
| 15 /** | 49 /** |
| 16 * Enumeration of secondary display layout. The value has to be same as the | |
| 17 * values in ash/display/display_controller.cc. | |
| 18 * @enum {number} | |
| 19 */ | |
| 20 var SecondaryDisplayLayout = { | |
| 21 TOP: 0, | |
| 22 RIGHT: 1, | |
| 23 BOTTOM: 2, | |
| 24 LEFT: 3 | |
| 25 }; | |
| 26 | |
| 27 /** | |
| 28 * Calculates the bounds of |element| relative to the page. | 50 * Calculates the bounds of |element| relative to the page. |
| 29 * @param {HTMLElement} element The element to be known. | 51 * @param {HTMLElement} element The element to be known. |
| 30 * @return {Object} The object for the bounds, with x, y, width, and height. | 52 * @return {Object} The object for the bounds, with x, y, width, and height. |
| 31 */ | 53 */ |
| 32 function getBoundsInPage(element) { | 54 function getBoundsInPage(element) { |
| 33 var bounds = { | 55 var bounds = { |
| 34 x: element.offsetLeft, | 56 x: element.offsetLeft, |
| 35 y: element.offsetTop, | 57 y: element.offsetTop, |
| 36 width: element.offsetWidth, | 58 width: element.offsetWidth, |
| 37 height: element.offsetHeight | 59 height: element.offsetHeight |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 95 | 117 |
| 96 /** | 118 /** |
| 97 * The current secondary display layout. | 119 * The current secondary display layout. |
| 98 * @private | 120 * @private |
| 99 */ | 121 */ |
| 100 layout_: SecondaryDisplayLayout.RIGHT, | 122 layout_: SecondaryDisplayLayout.RIGHT, |
| 101 | 123 |
| 102 /** | 124 /** |
| 103 * The array of current output displays. It also contains the display | 125 * The array of current output displays. It also contains the display |
| 104 * rectangles currently rendered on screen. | 126 * rectangles currently rendered on screen. |
| 127 * @type {Array.<DisplayInfo>} | |
| 105 * @private | 128 * @private |
| 106 */ | 129 */ |
| 107 displays_: [], | 130 displays_: [], |
| 108 | 131 |
| 109 /** | 132 /** |
| 110 * The index for the currently focused display in the options UI. null if | 133 * The index for the currently focused display in the options UI. null if |
| 111 * no one has focus. | 134 * no one has focus. |
| 112 * @private | 135 * @private |
| 113 */ | 136 */ |
| 114 focusedIndex_: null, | 137 focusedIndex_: null, |
| (...skipping 702 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 817 // |displaysView_|. Otherwise its offsetHeight is yet 0. | 840 // |displaysView_|. Otherwise its offsetHeight is yet 0. |
| 818 displayNameContainer.style.marginTop = | 841 displayNameContainer.style.marginTop = |
| 819 (div.offsetHeight - displayNameContainer.offsetHeight) / 2 + 'px'; | 842 (div.offsetHeight - displayNameContainer.offsetHeight) / 2 + 'px'; |
| 820 display.originalPosition = {x: div.offsetLeft, y: div.offsetTop}; | 843 display.originalPosition = {x: div.offsetLeft, y: div.offsetTop}; |
| 821 } | 844 } |
| 822 }, | 845 }, |
| 823 | 846 |
| 824 /** | 847 /** |
| 825 * Called when the display arrangement has changed. | 848 * Called when the display arrangement has changed. |
| 826 * @param {boolean} mirroring Whether current mode is mirroring or not. | 849 * @param {boolean} mirroring Whether current mode is mirroring or not. |
| 827 * @param {Array} displays The list of the display information. | 850 * @param {Array.<DisplayInfo>} displays The list of the display |
| 851 * information. | |
| 828 * @param {SecondaryDisplayLayout} layout The layout strategy. | 852 * @param {SecondaryDisplayLayout} layout The layout strategy. |
| 829 * @param {number} offset The offset of the secondary display. | 853 * @param {number} offset The offset of the secondary display. |
| 830 * @private | 854 * @private |
| 831 */ | 855 */ |
| 832 onDisplayChanged_: function(mirroring, displays, layout, offset) { | 856 onDisplayChanged_: function(mirroring, displays, layout, offset) { |
| 833 if (!this.visible) | 857 if (!this.visible) |
| 834 return; | 858 return; |
| 835 | 859 |
| 836 var hasExternal = false; | 860 var hasExternal = false; |
| 837 for (var i = 0; i < displays.length; i++) { | 861 for (var i = 0; i < displays.length; i++) { |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 873 mirroring, displays, layout, offset) { | 897 mirroring, displays, layout, offset) { |
| 874 DisplayOptions.getInstance().onDisplayChanged_( | 898 DisplayOptions.getInstance().onDisplayChanged_( |
| 875 mirroring, displays, layout, offset); | 899 mirroring, displays, layout, offset); |
| 876 }; | 900 }; |
| 877 | 901 |
| 878 // Export | 902 // Export |
| 879 return { | 903 return { |
| 880 DisplayOptions: DisplayOptions | 904 DisplayOptions: DisplayOptions |
| 881 }; | 905 }; |
| 882 }); | 906 }); |
| OLD | NEW |