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

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
« no previous file with comments | « no previous file | chrome/browser/ui/webui/options2/chromeos/display_options_handler.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 // Always show two displays because there must be two displays when
234 // the display_options is enabled. Don't rely on displays_.length because
235 // there is only one display from chrome's perspective in mirror mode.
236 var num_displays = Math.max(2, this.displays_.length);
237
233 this.displays_view_.style.height = 238 this.displays_view_.style.height =
234 height + this.displays_.length * 2 + 'px'; 239 height + num_displays * 2 + 'px';
James Hawkins 2012/07/25 15:07:16 What is this 2 about? In general I'd pull these m
Jun Mukai 2012/07/27 08:43:52 Introduced a const and replaced.
235 240
236 for (var i = 0; i < this.displays_.length; i++) { 241 for (var i = 0; i < num_displays; i++) {
237 var div = document.createElement('div'); 242 var div = document.createElement('div');
238 this.displays_[i].div = div;
239 div.className = 'displays-display'; 243 div.className = 'displays-display';
240 div.style.top = i * 2 + 'px'; 244 div.style.top = i * 2 + 'px';
241 div.style.left = i * 2 + 'px'; 245 div.style.left = i * 2 + 'px';
242 div.style.width = width + 'px'; 246 div.style.width = width + 'px';
243 div.style.height = height + 'px'; 247 div.style.height = height + 'px';
244 div.style.zIndex = i; 248 div.style.zIndex = i;
245 if (i == this.displays_.length - 1) 249 if (i == num_displays - 1)
246 div.className += ' displays-primary'; 250 div.className += ' displays-primary';
247 this.displays_view_.appendChild(div); 251 this.displays_view_.appendChild(div);
248 } 252 }
249 }, 253 },
250 254
251 /** 255 /**
252 * Layouts the display rectangles according to the current layout_. 256 * Layouts the display rectangles according to the current layout_.
253 * @private 257 * @private
254 */ 258 */
255 layoutDisplays_: function() { 259 layoutDisplays_: function() {
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
323 loadTimeData.getString( 327 loadTimeData.getString(
324 this.mirroring_ ? 'stopMirroring' : 'startMirroring'); 328 this.mirroring_ ? 'stopMirroring' : 'startMirroring');
325 329
326 // Focus to the first display next to the primary one when |displays| list 330 // Focus to the first display next to the primary one when |displays| list
327 // is updated. 331 // is updated.
328 if (this.displays_.length != displays.length) 332 if (this.displays_.length != displays.length)
329 this.focused_index_ = 1; 333 this.focused_index_ = 1;
330 334
331 this.displays_ = displays; 335 this.displays_ = displays;
332 336
333 if (this.displays_.length <= 1)
334 return;
335
336 this.resetDisplaysView_(); 337 this.resetDisplaysView_();
337 if (this.mirroring_) 338 if (this.mirroring_)
338 this.layoutMirroringDisplays_(); 339 this.layoutMirroringDisplays_();
339 else 340 else
340 this.layoutDisplays_(); 341 this.layoutDisplays_();
341 }, 342 },
342 }; 343 };
343 344
344 DisplayOptions.setDisplayInfo = function(mirroring, displays, layout) { 345 DisplayOptions.setDisplayInfo = function(mirroring, displays, layout) {
345 DisplayOptions.getInstance().onDisplayChanged_(mirroring, displays, layout); 346 DisplayOptions.getInstance().onDisplayChanged_(mirroring, displays, layout);
346 }; 347 };
347 348
348 // Export 349 // Export
349 return { 350 return {
350 DisplayOptions: DisplayOptions 351 DisplayOptions: DisplayOptions
351 }; 352 };
352 }); 353 });
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/ui/webui/options2/chromeos/display_options_handler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698