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

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

Issue 10828005: Show "displays" section in the options page even for 1 display. It happens in case of mirroring. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 5 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 | Annotate | Revision Log
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.define('options', function() { 5 cr.define('options', function() {
6 var OptionsPage = options.OptionsPage; 6 var OptionsPage = options.OptionsPage;
7 7
8 // The scale ratio of the display rectangle to its original size. 8 // The scale ratio of the display rectangle to its original size.
9 /** @const */ var VISUAL_SCALE = 1 / 10; 9 /** @const */ var VISUAL_SCALE = 1 / 10;
10 10
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after
223 223
224 /** 224 /**
225 * Lays out the display rectangles for mirroring. 225 * Lays out the display rectangles for mirroring.
226 * @private 226 * @private
227 */ 227 */
228 layoutMirroringDisplays_: function() { 228 layoutMirroringDisplays_: function() {
229 // The width/height should be same as the primary display: 229 // The width/height should be same as the primary display:
230 var width = this.displays_[0].width * VISUAL_SCALE; 230 var width = this.displays_[0].width * VISUAL_SCALE;
231 var height = this.displays_[0].height * VISUAL_SCALE; 231 var height = this.displays_[0].height * VISUAL_SCALE;
232 232
233 // Sometimes the system provies only one display in case of mirroring.
234 // We show at least 2 display rectangles to have the "mirroring" looking.
oshima 2012/07/25 07:53:41 We only support up to 2 displays now, and there is
oshima 2012/07/25 07:54:25 should read: "there is only one display from chro
Jun Mukai 2012/07/25 08:14:43 Done.
235 var num_displays = Math.max(2, this.displays_.length);
236
233 this.displays_view_.style.height = 237 this.displays_view_.style.height =
234 height + this.displays_.length * 2 + 'px'; 238 height + num_displays * 2 + 'px';
235 239
236 for (var i = 0; i < this.displays_.length; i++) { 240 for (var i = 0; i < num_displays; i++) {
237 var div = document.createElement('div'); 241 var div = document.createElement('div');
238 this.displays_[i].div = div;
239 div.className = 'displays-display'; 242 div.className = 'displays-display';
240 div.style.top = i * 2 + 'px'; 243 div.style.top = i * 2 + 'px';
241 div.style.left = i * 2 + 'px'; 244 div.style.left = i * 2 + 'px';
242 div.style.width = width + 'px'; 245 div.style.width = width + 'px';
243 div.style.height = height + 'px'; 246 div.style.height = height + 'px';
244 div.style.zIndex = i; 247 div.style.zIndex = i;
245 if (i == this.displays_.length - 1) 248 if (i == num_displays - 1)
246 div.className += ' displays-primary'; 249 div.className += ' displays-primary';
247 this.displays_view_.appendChild(div); 250 this.displays_view_.appendChild(div);
248 } 251 }
249 }, 252 },
250 253
251 /** 254 /**
252 * Layouts the display rectangles according to the current layout_. 255 * Layouts the display rectangles according to the current layout_.
253 * @private 256 * @private
254 */ 257 */
255 layoutDisplays_: function() { 258 layoutDisplays_: function() {
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
323 loadTimeData.getString( 326 loadTimeData.getString(
324 this.mirroring_ ? 'stopMirroring' : 'startMirroring'); 327 this.mirroring_ ? 'stopMirroring' : 'startMirroring');
325 328
326 // Focus to the first display next to the primary one when |displays| list 329 // Focus to the first display next to the primary one when |displays| list
327 // is updated. 330 // is updated.
328 if (this.displays_.length != displays.length) 331 if (this.displays_.length != displays.length)
329 this.focused_index_ = 1; 332 this.focused_index_ = 1;
330 333
331 this.displays_ = displays; 334 this.displays_ = displays;
332 335
333 if (this.displays_.length <= 1)
334 return;
335
336 this.resetDisplaysView_(); 336 this.resetDisplaysView_();
337 if (this.mirroring_) 337 if (this.mirroring_)
338 this.layoutMirroringDisplays_(); 338 this.layoutMirroringDisplays_();
339 else 339 else
340 this.layoutDisplays_(); 340 this.layoutDisplays_();
341 }, 341 },
342 }; 342 };
343 343
344 DisplayOptions.setDisplayInfo = function(mirroring, displays, layout) { 344 DisplayOptions.setDisplayInfo = function(mirroring, displays, layout) {
345 DisplayOptions.getInstance().onDisplayChanged_(mirroring, displays, layout); 345 DisplayOptions.getInstance().onDisplayChanged_(mirroring, displays, layout);
346 }; 346 };
347 347
348 // Export 348 // Export
349 return { 349 return {
350 DisplayOptions: DisplayOptions 350 DisplayOptions: DisplayOptions
351 }; 351 };
352 }); 352 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698