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

Side by Side Diff: chrome/browser/resources/options/chromeos/display_options.js

Issue 1126933004: Allow switching between extended and unified (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 7 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
OLDNEW
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 cr.exportPath('options'); 5 cr.exportPath('options');
6 6
7 /** 7 /**
8 * @typedef {{ 8 * @typedef {{
9 * availableColorProfiles: Array<{profileId: number, name: string}>, 9 * availableColorProfiles: Array<{profileId: number, name: string}>,
10 * colorProfile: number, 10 * colorProfile: number,
(...skipping 18 matching lines...) Expand all
29 * values in ash/display/display_controller.cc. 29 * values in ash/display/display_controller.cc.
30 * @enum {number} 30 * @enum {number}
31 */ 31 */
32 options.SecondaryDisplayLayout = { 32 options.SecondaryDisplayLayout = {
33 TOP: 0, 33 TOP: 0,
34 RIGHT: 1, 34 RIGHT: 1,
35 BOTTOM: 2, 35 BOTTOM: 2,
36 LEFT: 3 36 LEFT: 3
37 }; 37 };
38 38
39 /**
40 * Enumeration of multi display mode. The value has to be same as the
41 * values in ash/display/display_manager..
42 * @enum {number}
43 */
44 options.MultiDisplayMode = {
45 EXTENDED: 0,
46 MIRRORING: 1,
47 UNIFIED: 2,
48 };
49
39 cr.define('options', function() { 50 cr.define('options', function() {
40 var Page = cr.ui.pageManager.Page; 51 var Page = cr.ui.pageManager.Page;
41 var PageManager = cr.ui.pageManager.PageManager; 52 var PageManager = cr.ui.pageManager.PageManager;
42 53
43 // The scale ratio of the display rectangle to its original size. 54 // The scale ratio of the display rectangle to its original size.
44 /** @const */ var VISUAL_SCALE = 1 / 10; 55 /** @const */ var VISUAL_SCALE = 1 / 10;
45 56
46 // The number of pixels to share the edges between displays. 57 // The number of pixels to share the edges between displays.
47 /** @const */ var MIN_OFFSET_OVERLAP = 5; 58 /** @const */ var MIN_OFFSET_OVERLAP = 5;
48 59
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
109 120
110 DisplayOptions.prototype = { 121 DisplayOptions.prototype = {
111 __proto__: Page.prototype, 122 __proto__: Page.prototype,
112 123
113 /** 124 /**
114 * Whether the current output status is mirroring displays or not. 125 * Whether the current output status is mirroring displays or not.
115 * @private 126 * @private
116 */ 127 */
117 mirroring_: false, 128 mirroring_: false,
118 129
130 /*
131 * Whether the unified desktop is enable or not.
132 * @private
133 */
134 unifiedDesktopEnabled_: false,
135
136 /*
137 * Whether the unified desktop option should be present.
138 * @private
139 */
140 showUnifiedDesktopOption_: false,
141
119 /** 142 /**
120 * The current secondary display layout. 143 * The current secondary display layout.
121 * @private 144 * @private
122 */ 145 */
123 layout_: options.SecondaryDisplayLayout.RIGHT, 146 layout_: options.SecondaryDisplayLayout.RIGHT,
124 147
125 /** 148 /**
126 * The array of current output displays. It also contains the display 149 * The array of current output displays. It also contains the display
127 * rectangles currently rendered on screen. 150 * rectangles currently rendered on screen.
128 * @type {Array<options.DisplayInfo>} 151 * @type {Array<options.DisplayInfo>}
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
213 var displayOverscan = options.DisplayOverscan.getInstance(); 236 var displayOverscan = options.DisplayOverscan.getInstance();
214 displayOverscan.setDisplayId(this.displays_[this.focusedIndex_].id); 237 displayOverscan.setDisplayId(this.displays_[this.focusedIndex_].id);
215 PageManager.showPageByName('displayOverscan'); 238 PageManager.showPageByName('displayOverscan');
216 chrome.send('coreOptionsUserMetricsAction', 239 chrome.send('coreOptionsUserMetricsAction',
217 ['Options_DisplaySetOverscan']); 240 ['Options_DisplaySetOverscan']);
218 }).bind(this); 241 }).bind(this);
219 242
220 $('display-options-done').onclick = function() { 243 $('display-options-done').onclick = function() {
221 PageManager.closeOverlay(); 244 PageManager.closeOverlay();
222 }; 245 };
246
247 $('display-options-toggle-unified-desktop').onclick = (function() {
248 this.unifiedDesktopEnabled_ = !this.unifiedDesktopEnabled_;
249 chrome.send('setUnifiedDesktopEnabled',
250 [this.unifiedDesktopEnabled_]);
251 }).bind(this);
223 }, 252 },
224 253
225 /** @override */ 254 /** @override */
226 didShowPage: function() { 255 didShowPage: function() {
227 var optionTitles = document.getElementsByClassName( 256 var optionTitles = document.getElementsByClassName(
228 'selected-display-option-title'); 257 'selected-display-option-title');
229 var maxSize = 0; 258 var maxSize = 0;
230 for (var i = 0; i < optionTitles.length; i++) 259 for (var i = 0; i < optionTitles.length; i++)
231 maxSize = Math.max(maxSize, optionTitles[i].clientWidth); 260 maxSize = Math.max(maxSize, optionTitles[i].clientWidth);
232 for (var i = 0; i < optionTitles.length; i++) 261 for (var i = 0; i < optionTitles.length; i++)
233 optionTitles[i].style.width = maxSize + 'px'; 262 optionTitles[i].style.width = maxSize + 'px';
234 chrome.send('getDisplayInfo'); 263 chrome.send('getDisplayInfo');
235 }, 264 },
236 265
237 /** @override */ 266 /** @override */
238 canShowPage: function() { 267 canShowPage: function() {
239 return this.enabled_; 268 return this.enabled_;
240 }, 269 },
241 270
242 /** 271 /**
243 * Enables or disables the page. When disabled, the page will not be able to 272 * Enables or disables the page. When disabled, the page will not be able to
244 * open, and will close if currently opened. 273 * open, and will close if currently opened.
245 * @param {boolean} enabled Whether the page should be enabled. 274 * @param {boolean} enabled Whether the page should be enabled.
275 * @param {boolean} showUnifiedDesktop Whether the unified desktop option
276 * should be present.
246 */ 277 */
247 setEnabled: function(enabled) { 278 setEnabled: function(enabled, showUnifiedDesktop) {
248 if (this.enabled_ == enabled) 279 if (this.enabled_ == enabled &&
280 this.showUnifiedDesktopOption_ == showUnifiedDesktop) {
249 return; 281 return;
282 }
250 this.enabled_ = enabled; 283 this.enabled_ = enabled;
284 this.showUnifiedDesktopOption_ = showUnifiedDesktop;
251 if (!enabled && this.visible) 285 if (!enabled && this.visible)
252 PageManager.closeOverlay(); 286 PageManager.closeOverlay();
253 }, 287 },
254 288
255 /** 289 /**
256 * Mouse move handler for dragging display rectangle. 290 * Mouse move handler for dragging display rectangle.
257 * @param {Event} e The mouse move event. 291 * @param {Event} e The mouse move event.
258 * @private 292 * @private
259 */ 293 */
260 onMouseMove_: function(e) { 294 onMouseMove_: function(e) {
(...skipping 663 matching lines...) Expand 10 before | Expand all | Expand 10 after
924 offset.y + 'px'; 958 offset.y + 'px';
925 break; 959 break;
926 } 960 }
927 this.secondaryDisplay_.originalPosition = { 961 this.secondaryDisplay_.originalPosition = {
928 x: secondaryDiv.offsetLeft, y: secondaryDiv.offsetTop}; 962 x: secondaryDiv.offsetLeft, y: secondaryDiv.offsetTop};
929 } 963 }
930 }, 964 },
931 965
932 /** 966 /**
933 * Called when the display arrangement has changed. 967 * Called when the display arrangement has changed.
934 * @param {boolean} mirroring Whether current mode is mirroring or not. 968 * @param {options.MultiDisplayMode} multi display mode.
935 * @param {Array<options.DisplayInfo>} displays The list of the display 969 * @param {Array<options.DisplayInfo>} displays The list of the display
936 * information. 970 * information.
937 * @param {options.SecondaryDisplayLayout} layout The layout strategy. 971 * @param {options.SecondaryDisplayLayout} layout The layout strategy.
938 * @param {number} offset The offset of the secondary display. 972 * @param {number} offset The offset of the secondary display.
939 * @private 973 * @private
940 */ 974 */
941 onDisplayChanged_: function(mirroring, displays, layout, offset) { 975 onDisplayChanged_: function(mode, displays, layout, offset) {
942 if (!this.visible) 976 if (!this.visible)
943 return; 977 return;
944 978
945 var hasExternal = false; 979 var hasExternal = false;
946 for (var i = 0; i < displays.length; i++) { 980 for (var i = 0; i < displays.length; i++) {
947 if (!displays[i].isInternal) { 981 if (!displays[i].isInternal) {
948 hasExternal = true; 982 hasExternal = true;
949 break; 983 break;
950 } 984 }
951 } 985 }
952 986
953 this.layout_ = layout; 987 this.layout_ = layout;
954 988
989 var mirroring = mode == options.MultiDisplayMode.MIRRORING;
990 var unifiedDesktopEnabled = mode == options.MultiDisplayMode.UNIFIED;
991
955 $('display-options-toggle-mirroring').textContent = 992 $('display-options-toggle-mirroring').textContent =
956 loadTimeData.getString( 993 loadTimeData.getString(
957 mirroring ? 'stopMirroring' : 'startMirroring'); 994 mirroring ? 'stopMirroring' : 'startMirroring');
958 995
959 // Focus to the first display next to the primary one when |displays| list 996 // Focus to the first display next to the primary one when |displays| list
960 // is updated. 997 // is updated.
961 if (mirroring) { 998 if (mirroring || unifiedDesktopEnabled) {
962 this.focusedIndex_ = null; 999 this.focusedIndex_ = null;
963 } else if (this.mirroring_ != mirroring || 1000 } else if (this.mirroring_ != mirroring ||
1001 this.unifiedDesktopEnabled_ != unifiedDesktopEnabled ||
964 this.displays_.length != displays.length) { 1002 this.displays_.length != displays.length) {
965 this.focusedIndex_ = 0; 1003 this.focusedIndex_ = 0;
966 } 1004 }
967 1005
968 this.mirroring_ = mirroring; 1006 this.mirroring_ = mirroring;
1007 this.unifiedDesktopEnabled_ = unifiedDesktopEnabled;
969 this.displays_ = displays; 1008 this.displays_ = displays;
970 1009
971 this.resetDisplaysView_(); 1010 this.resetDisplaysView_();
972 if (this.mirroring_) 1011 if (this.mirroring_)
973 this.layoutMirroringDisplays_(); 1012 this.layoutMirroringDisplays_();
974 else 1013 else
975 this.layoutDisplays_(); 1014 this.layoutDisplays_();
976 1015
1016 $('display-options-unified-desktop').hidden =
1017 !this.showUnifiedDesktopOption_;
1018
1019 $('display-options-toggle-unified-desktop').checked =
1020 this.unifiedDesktopEnabled_;
1021
1022 var disableUnifiedDesktopOption =
1023 (this.mirroring_ ||
1024 (!this.unifiedDesktopEnabled_ &&
1025 this.displays_.length == 1));
1026
1027 $('display-options-toggle-unified-desktop').disabled =
1028 disableUnifiedDesktopOption;
1029
977 this.updateSelectedDisplayDescription_(); 1030 this.updateSelectedDisplayDescription_();
978 } 1031 }
979 }; 1032 };
980 1033
981 DisplayOptions.setDisplayInfo = function( 1034 DisplayOptions.setDisplayInfo = function(
982 mirroring, displays, layout, offset) { 1035 mode, displays, layout, offset) {
983 DisplayOptions.getInstance().onDisplayChanged_( 1036 DisplayOptions.getInstance().onDisplayChanged_(
984 mirroring, displays, layout, offset); 1037 mode, displays, layout, offset);
985 }; 1038 };
986 1039
987 // Export 1040 // Export
988 return { 1041 return {
989 DisplayOptions: DisplayOptions 1042 DisplayOptions: DisplayOptions
990 }; 1043 };
991 }); 1044 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698