| 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.exportPath('options'); | 5 cr.exportPath('options'); |
| 6 | 6 |
| 7 /** | 7 /** |
| 8 * Enumeration of multi display mode. These values must match the C++ values in | 8 * Enumeration of multi display mode. These values must match the C++ values in |
| 9 * ash::DisplayManager. | 9 * ash::DisplayManager. |
| 10 * @enum {number} | 10 * @enum {number} |
| (...skipping 352 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 363 var secondaryId; | 363 var secondaryId; |
| 364 for (var i = 0; i < this.displays_.length; i++) { | 364 for (var i = 0; i < this.displays_.length; i++) { |
| 365 if (!this.displays_[i].isPrimary) { | 365 if (!this.displays_[i].isPrimary) { |
| 366 secondaryId = this.displays_[i].id; | 366 secondaryId = this.displays_[i].id; |
| 367 break; | 367 break; |
| 368 } | 368 } |
| 369 } | 369 } |
| 370 assert(!!secondaryId); | 370 assert(!!secondaryId); |
| 371 var displayLayout = | 371 var displayLayout = |
| 372 this.displayLayoutManager_.getDisplayLayout(secondaryId); | 372 this.displayLayoutManager_.getDisplayLayout(secondaryId); |
| 373 console.log( |
| 374 'setDisplayLayout: ' + displayLayout.layoutType + ' : ' + |
| 375 displayLayout.offset); |
| 373 chrome.send( | 376 chrome.send( |
| 374 'setDisplayLayout', | 377 'setDisplayLayout', |
| 375 [secondaryId, displayLayout.layoutType, displayLayout.offset]); | 378 [secondaryId, displayLayout.layoutType, displayLayout.offset]); |
| 379 // TODO(stevenjb): Remove once we send all layout changes. |
| 380 chrome.send('getDisplayInfo'); |
| 376 }, | 381 }, |
| 377 | 382 |
| 378 /** | 383 /** |
| 379 * Processes the actual dragging of display rectangle. | 384 * Processes the actual dragging of display rectangle. |
| 380 * @param {Event} e The event which triggers this drag. | 385 * @param {Event} e The event which triggers this drag. |
| 381 * @param {options.DisplayPosition} eventLocation The location where the | 386 * @param {options.DisplayPosition} eventLocation The location where the |
| 382 * event happens. | 387 * event happens. |
| 383 * @private | 388 * @private |
| 384 */ | 389 */ |
| 385 processDragging_: function(e, eventLocation) { | 390 processDragging_: function(e, eventLocation) { |
| (...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 653 div.style.height = height + 'px'; | 658 div.style.height = height + 'px'; |
| 654 div.style.zIndex = i; | 659 div.style.zIndex = i; |
| 655 // set 'display-mirrored' class for the background display rectangles. | 660 // set 'display-mirrored' class for the background display rectangles. |
| 656 if (i != numDisplays - 1) | 661 if (i != numDisplays - 1) |
| 657 div.classList.add('display-mirrored'); | 662 div.classList.add('display-mirrored'); |
| 658 this.displaysView_.appendChild(div); | 663 this.displaysView_.appendChild(div); |
| 659 } | 664 } |
| 660 }, | 665 }, |
| 661 | 666 |
| 662 /** | 667 /** |
| 663 * Creates a DisplayLayout object representing the display. | |
| 664 * @param {!options.DisplayInfo} display | |
| 665 * @param {!options.DisplayLayoutType} layoutType | |
| 666 * @param {string} parentId | |
| 667 * @return {!options.DisplayLayout} | |
| 668 * @private | |
| 669 */ | |
| 670 createDisplayLayout_: function(display, layoutType, parentId) { | |
| 671 return { | |
| 672 bounds: display.bounds, | |
| 673 div: null, | |
| 674 id: display.id, | |
| 675 layoutType: layoutType, | |
| 676 name: display.name, | |
| 677 offset: 0, | |
| 678 originalPosition: {x: 0, y: 0}, | |
| 679 parentId: parentId | |
| 680 }; | |
| 681 }, | |
| 682 | |
| 683 /** | |
| 684 * Layouts the display rectangles according to the current layout_. | 668 * Layouts the display rectangles according to the current layout_. |
| 685 * @param {options.DisplayLayoutType} layoutType | 669 * @param {options.DisplayLayoutType} layoutType |
| 686 * @private | 670 * @private |
| 687 */ | 671 */ |
| 688 layoutDisplays_: function(layoutType) { | 672 layoutDisplays_: function(layoutType) { |
| 689 // Create the layout manager. | 673 // Create the layout manager. |
| 690 this.displayLayoutManager_ = new options.DisplayLayoutManager(); | 674 this.displayLayoutManager_ = new options.DisplayLayoutManagerMulti(); |
| 691 | 675 |
| 692 // Create the display layouts. Child displays are parented to the primary. | 676 // Create the display layouts. Child displays are parented to the primary. |
| 693 // TODO(stevenjb): DisplayInfo should provide the parent id for displays. | 677 // TODO(stevenjb): DisplayInfo should provide the parent id for displays. |
| 694 var primaryDisplayId = ''; | 678 var primaryDisplayId = ''; |
| 695 for (var i = 0; i < this.displays_.length; i++) { | 679 for (var i = 0; i < this.displays_.length; i++) { |
| 696 var display = this.displays_[i]; | 680 var display = this.displays_[i]; |
| 697 if (display.isPrimary) { | 681 if (display.isPrimary) { |
| 698 primaryDisplayId = display.id; | 682 primaryDisplayId = display.id; |
| 699 break; | 683 break; |
| 700 } | 684 } |
| 701 } | 685 } |
| 702 for (var i = 0; i < this.displays_.length; i++) { | 686 for (var i = 0; i < this.displays_.length; i++) { |
| 703 var display = this.displays_[i]; | 687 var display = this.displays_[i]; |
| 704 var parentId = display.isPrimary ? '' : primaryDisplayId; | 688 var parentId = display.isPrimary ? '' : primaryDisplayId; |
| 705 var layout = this.createDisplayLayout_(display, layoutType, parentId); | 689 var layout = this.displayLayoutManager_.createDisplayLayout( |
| 690 display.id, display.name, display.bounds, layoutType, parentId); |
| 706 this.displayLayoutManager_.addDisplayLayout(layout); | 691 this.displayLayoutManager_.addDisplayLayout(layout); |
| 707 } | 692 } |
| 708 | 693 |
| 709 // Calculate the display area bounds and create the divs for each display. | 694 // Calculate the display area bounds and create the divs for each display. |
| 710 this.visualScale_ = this.displayLayoutManager_.createDisplayArea( | 695 this.visualScale_ = this.displayLayoutManager_.createDisplayArea( |
| 711 /** @type {!Element} */(this.displaysView_), VISUAL_SCALE); | 696 /** @type {!Element} */(this.displaysView_), VISUAL_SCALE); |
| 712 | 697 |
| 713 this.displayLayoutManager_.setFocusedId(this.focusedId_); | 698 this.displayLayoutManager_.setFocusedId(this.focusedId_); |
| 714 this.displayLayoutManager_.setDivCallbacks( | 699 this.displayLayoutManager_.setDivCallbacks( |
| 715 this.onMouseDown_.bind(this), this.onTouchStart_.bind(this)); | 700 this.onMouseDown_.bind(this), this.onTouchStart_.bind(this)); |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 777 mode, displays, layoutType, offset) { | 762 mode, displays, layoutType, offset) { |
| 778 DisplayOptions.getInstance().onDisplayChanged_( | 763 DisplayOptions.getInstance().onDisplayChanged_( |
| 779 mode, displays, layoutType, offset); | 764 mode, displays, layoutType, offset); |
| 780 }; | 765 }; |
| 781 | 766 |
| 782 // Export | 767 // Export |
| 783 return { | 768 return { |
| 784 DisplayOptions: DisplayOptions | 769 DisplayOptions: DisplayOptions |
| 785 }; | 770 }; |
| 786 }); | 771 }); |
| OLD | NEW |