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

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

Issue 14710011: Redesign display options for ChromeOS. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 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 | 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 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
148 * @private 148 * @private
149 */ 149 */
150 lastTouchLocation_: null, 150 lastTouchLocation_: null,
151 151
152 /** 152 /**
153 * Initialize the page. 153 * Initialize the page.
154 */ 154 */
155 initializePage: function() { 155 initializePage: function() {
156 OptionsPage.prototype.initializePage.call(this); 156 OptionsPage.prototype.initializePage.call(this);
157 157
158 $('display-options-toggle-mirroring').onclick = (function() { 158 $('display-options-toggle-mirroring').onclick = function() {
159 this.mirroring_ = !this.mirroring_; 159 this.mirroring_ = !this.mirroring_;
160 chrome.send('setMirroring', [this.mirroring_]); 160 chrome.send('setMirroring', [this.mirroring_]);
161 }).bind(this); 161 }.bind(this);
162 162
163 var container = $('display-options-displays-view-host'); 163 var container = $('display-options-displays-view-host');
164 container.onmousemove = this.onMouseMove_.bind(this); 164 container.onmousemove = this.onMouseMove_.bind(this);
165 window.addEventListener('mouseup', this.endDragging_.bind(this), true); 165 window.addEventListener('mouseup', this.endDragging_.bind(this), true);
166 container.ontouchmove = this.onTouchMove_.bind(this); 166 container.ontouchmove = this.onTouchMove_.bind(this);
167 container.ontouchend = this.endDragging_.bind(this); 167 container.ontouchend = this.endDragging_.bind(this);
168 168
169 $('display-options-set-primary').onclick = (function() { 169 $('display-options-set-primary').onclick = function() {
170 chrome.send('setPrimary', [this.displays_[this.focusedIndex_].id]); 170 chrome.send('setPrimary', [this.displays_[this.focusedIndex_].id]);
171 }).bind(this); 171 }.bind(this);
172 172 $('display-options-resolution-selection').onchange = function(ev) {
173 $('selected-display-start-calibrating-overscan').onclick = (function() { 173 chrome.send('setUIScale', [this.displays_[this.focusedIndex_].id,
174 ev.target.value]);
175 }.bind(this);
176 $('display-options-orientation-selection').onchange = function(ev) {
177 chrome.send('setOrientation', [this.displays_[this.focusedIndex_].id,
178 ev.target.value]);
179 }.bind(this);
180 $('selected-display-start-calibrating-overscan').onclick = function() {
174 // Passes the target display ID. Do not specify it through URL hash, 181 // Passes the target display ID. Do not specify it through URL hash,
175 // we do not care back/forward. 182 // we do not care back/forward.
176 var displayOverscan = options.DisplayOverscan.getInstance(); 183 var displayOverscan = options.DisplayOverscan.getInstance();
177 displayOverscan.setDisplayId(this.displays_[this.focusedIndex_].id); 184 displayOverscan.setDisplayId(this.displays_[this.focusedIndex_].id);
178 OptionsPage.navigateToPage('displayOverscan'); 185 OptionsPage.navigateToPage('displayOverscan');
179 }).bind(this); 186 }.bind(this);
180 187
181 chrome.send('getDisplayInfo'); 188 chrome.send('getDisplayInfo');
182 }, 189 },
183 190
184 /** @override */ 191 /** @override */
185 onVisibilityChanged_: function() { 192 onVisibilityChanged_: function() {
186 OptionsPage.prototype.onVisibilityChanged_(this); 193 OptionsPage.prototype.onVisibilityChanged_(this);
187 if (this.visible) 194 if (this.visible)
188 chrome.send('getDisplayInfo'); 195 chrome.send('getDisplayInfo');
189 }, 196 },
(...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after
458 } 465 }
459 466
460 for (var i = 0; i < this.displays_.length; i++) { 467 for (var i = 0; i < this.displays_.length; i++) {
461 var display = this.displays_[i]; 468 var display = this.displays_[i];
462 display.div.className = 'displays-display'; 469 display.div.className = 'displays-display';
463 this.resizeDisplayRectangle_(display, i); 470 this.resizeDisplayRectangle_(display, i);
464 if (i != this.focusedIndex_) 471 if (i != this.focusedIndex_)
465 continue; 472 continue;
466 473
467 display.div.classList.add('displays-focused'); 474 display.div.classList.add('displays-focused');
468 this.dragging_ = { 475 if (this.displays_.length > 1) {
469 display: display, 476 this.dragging_ = {
470 originalLocation: { 477 display: display,
471 x: display.div.offsetLeft, y: display.div.offsetTop 478 originalLocation: {
472 }, 479 x: display.div.offsetLeft, y: display.div.offsetTop
473 eventLocation: eventLocation 480 },
474 }; 481 eventLocation: eventLocation
482 };
483 }
475 } 484 }
476 485
477 this.updateSelectedDisplayDescription_(); 486 this.updateSelectedDisplayDescription_();
478 return false; 487 return false;
479 }, 488 },
480 489
481 /** 490 /**
482 * finish the current dragging of displays. 491 * finish the current dragging of displays.
483 * @param {Event} e The event which triggers this. 492 * @param {Event} e The event which triggers this.
484 * @private 493 * @private
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
516 } 525 }
517 this.updateSelectedDisplayDescription_(); 526 this.updateSelectedDisplayDescription_();
518 return false; 527 return false;
519 }, 528 },
520 529
521 /** 530 /**
522 * Updates the description of the selected display section. 531 * Updates the description of the selected display section.
523 * @private 532 * @private
524 */ 533 */
525 updateSelectedDisplayDescription_: function() { 534 updateSelectedDisplayDescription_: function() {
535 var resolution = $('display-options-resolution-selection');
536 resolution.textContent = '';
537 var orientation = $('display-options-orientation-selection');
538 var orientationOptions = orientation.getElementsByTagName('option');
539 for (var i = 0; i < orientationOptions.length; i++) {
James Hawkins 2013/05/15 21:55:33 nit: No braces for single-line blocks.
Jun Mukai 2013/05/16 00:04:15 Done.
540 orientationOptions.selected = false;
541 }
542
526 if (this.mirroring_) { 543 if (this.mirroring_) {
James Hawkins 2013/05/15 21:55:33 Each of these blocks is quite long; please break t
Jun Mukai 2013/05/16 00:04:15 Done.
527 $('display-configuration-arrow').hidden = true; 544 $('display-configuration-arrow').hidden = true;
528 $('display-options-set-primary').hidden = true; 545 $('display-options-set-primary').disabled = true;
529 $('display-options-toggle-mirroring').hidden = false; 546 $('display-options-toggle-mirroring').disabled = false;
530 $('selected-display-data-container').hidden = false; 547 $('selected-display-start-calibrating-overscan').disabled = true;
548 orientation.disabled = true;
531 var display = this.displays_[0]; 549 var display = this.displays_[0];
550 $('selected-display-name').textContent =
551 loadTimeData.getString('mirroringDisplay');
552 resolution.appendChild(document.createElement('option'));
553 resolution.disabled = true;
554 } else if (this.focusedIndex_ == null ||
555 this.displays_[this.focusedIndex_] == null) {
556 $('display-configuration-arrow').hidden = true;
557 $('display-options-set-primary').disabled = true;
558 $('display-options-toggle-mirroring').disabled = true;
559 $('selected-display-start-calibrating-overscan').disabled = true;
560 orientation.disabled = true;
532 $('selected-display-name').textContent = ''; 561 $('selected-display-name').textContent = '';
533 $('selected-display-resolution').textContent = 562 resolution.appendChild(document.createElement('option'));
534 display.width + 'x' + display.height; 563 resolution.disabled = true;
535 return; 564 } else {
565 var display = this.displays_[this.focusedIndex_];
566
567 var arrow = $('display-configuration-arrow');
568 arrow.hidden = false;
569 // Adding 1 px to the position to fit the border line and the border in
570 // arrow precisely.
571 arrow.style.top = $('display-configurations').offsetTop -
572 arrow.offsetHeight / 2 + 'px';
573 arrow.style.left = display.div.offsetLeft +
574 display.div.offsetWidth / 2 - arrow.offsetWidth / 2 + 'px';
575
576 $('display-options-set-primary').disabled = display.isPrimary;
577 $('display-options-toggle-mirroring').disabled =
578 (this.displays_.length <= 1);
579 $('selected-display-start-calibrating-overscan').disabled =
580 display.isInternal;
581
582 orientation.disabled = false;
583 orientationOptions[display.orientation].selected = true;
584
585 $('selected-display-name').textContent = display.name;
586
587 if (display.uiScales.length <= 1) {
588 var option = document.createElement('option');
589 option.value = 'default';
590 option.textContent = display.width + 'x' + display.height;
591 option.selected = true;
592 resolution.appendChild(option);
593 resolution.disabled = true;
594 } else {
595 for (var i = 0; i < display.uiScales.length; i++) {
596 var option = document.createElement('option');
597 option.value = display.uiScales[i].scale;
598 option.textContent =
599 display.uiScales[i].width + 'x' + display.uiScales[i].height;
600 if (display.uiScales[i].scale == 1.0) {
601 option.textContent += ' ' +
602 loadTimeData.getString('annotateBest');
603 }
604 option.selected = display.uiScales[i].selected;
605 resolution.appendChild(option);
606 }
607 resolution.disabled = !display.isInternal;
608 }
536 } 609 }
537
538 if (this.focusedIndex_ == null ||
539 this.displays_[this.focusedIndex_] == null) {
540 $('selected-display-data-container').hidden = true;
541 $('display-configuration-arrow').hidden = true;
542 $('display-options-set-primary').hidden = true;
543 $('display-options-toggle-mirroring').hidden = true;
544 return;
545 }
546
547 $('selected-display-data-container').hidden = false;
548 var display = this.displays_[this.focusedIndex_];
549 var nameElement = $('selected-display-name');
550 nameElement.textContent = display.name;
551
552 var resolutionElement = $('selected-display-resolution');
553 resolutionElement.textContent = display.width + 'x' + display.height;
554
555 $('start-calibrating-overscan-control').hidden = display.isInternal;
556
557 var arrow = $('display-configuration-arrow');
558 arrow.hidden = false;
559 // Adding 1 px to the position to fit the border line and the border in
560 // arrow precisely.
561 arrow.style.top = $('display-configurations').offsetTop -
562 arrow.offsetHeight / 2 + 1 + 'px';
563 arrow.style.left = display.div.offsetLeft + display.div.offsetWidth / 2 -
564 arrow.offsetWidth / 2 + 'px';
565
566 $('display-options-set-primary').hidden =
567 this.displays_[this.focusedIndex_].isPrimary;
568 $('display-options-toggle-mirroring').hidden =
569 (this.displays_.length <= 1 && !this.mirroring_);
570 }, 610 },
571 611
572 /** 612 /**
573 * Clears the drawing area for display rectangles. 613 * Clears the drawing area for display rectangles.
574 * @private 614 * @private
575 */ 615 */
576 resetDisplaysView_: function() { 616 resetDisplaysView_: function() {
577 var displaysViewHost = $('display-options-displays-view-host'); 617 var displaysViewHost = $('display-options-displays-view-host');
578 displaysViewHost.removeChild(displaysViewHost.firstChild); 618 displaysViewHost.removeChild(displaysViewHost.firstChild);
579 this.displaysView_ = document.createElement('div'); 619 this.displaysView_ = document.createElement('div');
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
736 if (!this.visible) 776 if (!this.visible)
737 return; 777 return;
738 778
739 var hasExternal = false; 779 var hasExternal = false;
740 for (var i = 0; i < displays.length; i++) { 780 for (var i = 0; i < displays.length; i++) {
741 if (!displays[i].isInternal) { 781 if (!displays[i].isInternal) {
742 hasExternal = true; 782 hasExternal = true;
743 break; 783 break;
744 } 784 }
745 } 785 }
746 if (!hasExternal && !mirroring) {
747 OptionsPage.showDefaultPage();
748 return;
749 }
750 786
751 this.mirroring_ = mirroring; 787 this.mirroring_ = mirroring;
752 this.layout_ = layout; 788 this.layout_ = layout;
753 this.offset_ = offset; 789 this.offset_ = offset;
754 this.dirty_ = false; 790 this.dirty_ = false;
755 791
756 $('display-options-toggle-mirroring').textContent = 792 $('display-options-toggle-mirroring').textContent =
757 loadTimeData.getString( 793 loadTimeData.getString(
758 this.mirroring_ ? 'stopMirroring' : 'startMirroring'); 794 this.mirroring_ ? 'stopMirroring' : 'startMirroring');
759 795
(...skipping 20 matching lines...) Expand all
780 mirroring, displays, layout, offset) { 816 mirroring, displays, layout, offset) {
781 DisplayOptions.getInstance().onDisplayChanged_( 817 DisplayOptions.getInstance().onDisplayChanged_(
782 mirroring, displays, layout, offset); 818 mirroring, displays, layout, offset);
783 }; 819 };
784 820
785 // Export 821 // Export
786 return { 822 return {
787 DisplayOptions: DisplayOptions 823 DisplayOptions: DisplayOptions
788 }; 824 };
789 }); 825 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698