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 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 572 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
583 */ | 583 */ |
584 resizeDisplayRectangle_: function(display, index) { | 584 resizeDisplayRectangle_: function(display, index) { |
585 var borderWidth = (index == this.focusedIndex_) ? | 585 var borderWidth = (index == this.focusedIndex_) ? |
586 FOCUSED_BORDER_WIDTH_PX : NORMAL_BORDER_WIDTH_PX; | 586 FOCUSED_BORDER_WIDTH_PX : NORMAL_BORDER_WIDTH_PX; |
587 display.div.style.width = | 587 display.div.style.width = |
588 display.width * this.visualScale_ - borderWidth * 2 + 'px'; | 588 display.width * this.visualScale_ - borderWidth * 2 + 'px'; |
589 var newHeight = display.height * this.visualScale_ - borderWidth * 2; | 589 var newHeight = display.height * this.visualScale_ - borderWidth * 2; |
590 display.div.style.height = newHeight + 'px'; | 590 display.div.style.height = newHeight + 'px'; |
591 display.nameContainer.style.marginTop = | 591 display.nameContainer.style.marginTop = |
592 (newHeight - display.nameContainer.offsetHeight) / 2 + 'px'; | 592 (newHeight - display.nameContainer.offsetHeight) / 2 + 'px'; |
593 if (display.isPrimary) { | |
594 var launcher = display.div.firstChild; | |
595 if (launcher && launcher.id == 'display-launcher') { | |
596 launcher.style.width = display.div.style.width; | |
597 } | |
598 } | |
599 }, | 593 }, |
600 | 594 |
601 /** | 595 /** |
602 * Lays out the display rectangles for mirroring. | 596 * Lays out the display rectangles for mirroring. |
603 * @private | 597 * @private |
604 */ | 598 */ |
605 layoutMirroringDisplays_: function() { | 599 layoutMirroringDisplays_: function() { |
606 // Offset pixels for secondary display rectangles. The offset includes the | 600 // Offset pixels for secondary display rectangles. The offset includes the |
607 // border width. | 601 // border width. |
608 /** @const */ var MIRRORING_OFFSET_PIXELS = 3; | 602 /** @const */ var MIRRORING_OFFSET_PIXELS = 3; |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
690 for (var i = 0; i < this.displays_.length; i++) { | 684 for (var i = 0; i < this.displays_.length; i++) { |
691 var display = this.displays_[i]; | 685 var display = this.displays_[i]; |
692 var div = document.createElement('div'); | 686 var div = document.createElement('div'); |
693 display.div = div; | 687 display.div = div; |
694 | 688 |
695 div.className = 'displays-display'; | 689 div.className = 'displays-display'; |
696 if (i == this.focusedIndex_) | 690 if (i == this.focusedIndex_) |
697 div.classList.add('displays-focused'); | 691 div.classList.add('displays-focused'); |
698 | 692 |
699 if (display.isPrimary) { | 693 if (display.isPrimary) { |
700 // Put a grey rectangle to the primary display to denote launcher | |
701 // below. | |
702 var launcher = document.createElement('div'); | |
703 launcher.id = 'display-launcher'; | |
704 div.appendChild(launcher); | |
705 this.primaryDisplay_ = display; | 694 this.primaryDisplay_ = display; |
706 } else { | 695 } else { |
707 this.secondaryDisplay_ = display; | 696 this.secondaryDisplay_ = display; |
708 } | 697 } |
709 var displayNameContainer = document.createElement('div'); | 698 var displayNameContainer = document.createElement('div'); |
710 displayNameContainer.textContent = display.name; | 699 displayNameContainer.textContent = display.name; |
711 div.appendChild(displayNameContainer); | 700 div.appendChild(displayNameContainer); |
712 display.nameContainer = displayNameContainer; | 701 display.nameContainer = displayNameContainer; |
713 this.resizeDisplayRectangle_(display, i); | 702 this.resizeDisplayRectangle_(display, i); |
714 div.style.left = display.x * this.visualScale_ + offset.x + 'px'; | 703 div.style.left = display.x * this.visualScale_ + offset.x + 'px'; |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
784 mirroring, displays, layout, offset) { | 773 mirroring, displays, layout, offset) { |
785 DisplayOptions.getInstance().onDisplayChanged_( | 774 DisplayOptions.getInstance().onDisplayChanged_( |
786 mirroring, displays, layout, offset); | 775 mirroring, displays, layout, offset); |
787 }; | 776 }; |
788 | 777 |
789 // Export | 778 // Export |
790 return { | 779 return { |
791 DisplayOptions: DisplayOptions | 780 DisplayOptions: DisplayOptions |
792 }; | 781 }; |
793 }); | 782 }); |
OLD | NEW |