Commit c3263287 authored by Bailey Berro's avatar Bailey Berro Committed by Commit Bot

Only show display arrangement section when there are >1 displays

This change hides the arrangement section of Display settings when
there is only one display connected to the device. Since no action can
be taken in this section when there is only one Display, we hide it to
avoid wasting space.

Bug: 997471
Change-Id: Idf367efbeac835b77e99b70671741a60dd42ae58
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1881335
Commit-Queue: Bailey Berro <baileyberro@chromium.org>
Reviewed-by: default avatarSteven Bennetts <stevenjb@chromium.org>
Reviewed-by: default avatarKyle Horimoto <khorimoto@chromium.org>
Cr-Commit-Position: refs/heads/master@{#711571}
parent 8662ae7b
...@@ -56,6 +56,10 @@ ...@@ -56,6 +56,10 @@
margin-inline-end: var(--cr-controlled-by-spacing); margin-inline-end: var(--cr-controlled-by-spacing);
} }
.underbar {
border-bottom: var(--cr-separator-line);
}
#controlsDiv > .settings-box:first-of-type { #controlsDiv > .settings-box:first-of-type {
border-top: none; border-top: none;
} }
...@@ -71,39 +75,41 @@ ...@@ -71,39 +75,41 @@
</style> </style>
<!-- Arrangement section --> <!-- Arrangement section -->
<div class="settings-box first layout vertical self-stretch"> <template is="dom-if"
<h2 class="layout self-start"> if="[[shouldShowArrangementSection_(displays)]]" restamp>
$i18n{displayArrangementTitle} <div class="settings-box first layout vertical self-stretch underbar"
</h2> id="arrangement-section">
<div class="secondary layout self-start" <h2 class="layout self-start">
hidden="[[!hasMultipleDisplays_(displays)]]"> $i18n{displayArrangementTitle}
$i18n{displayArrangementText} </h2>`
</div> <div class="secondary layout self-start">
<display-layout id="displayLayout" $i18n{displayArrangementText}
selected-display="[[selectedDisplay]]"
on-select-display="onSelectDisplay_">
</display-layout>
<template is="dom-if" if="[[showMirror_(unifiedDesktopMode_, displays)]]"
restamp>
<div class="secondary self-start">
<cr-checkbox checked="[[isMirrored_(displays)]]"
on-click="onMirroredTap_"
aria-label="[[getDisplayMirrorText_(displays)]]">
<div class="text-area">[[getDisplayMirrorText_(displays)]]</div>
</cr-checkbox>
</div> </div>
</template> <display-layout id="displayLayout"
</div> selected-display="[[selectedDisplay]]"
on-select-display="onSelectDisplay_">
</display-layout>
<template is="dom-if"
if="[[showMirror_(unifiedDesktopMode_, displays)]]" restamp>
<div class="secondary self-start">
<cr-checkbox checked="[[isMirrored_(displays)]]"
on-click="onMirroredTap_"
aria-label="[[getDisplayMirrorText_(displays)]]">
<div class="text-area">[[getDisplayMirrorText_(displays)]]</div>
</cr-checkbox>
</div>
</template>
</div>
</template>
<!-- Display tabs --> <!-- Display tabs -->
<div hidden="[[!hasMultipleDisplays_(displays)]]" class="settings-box"> <div hidden="[[!hasMultipleDisplays_(displays)]]"
class="settings-box first">
<cr-tabs selected="[[selectedTab_]]" class="display-tabs" <cr-tabs selected="[[selectedTab_]]" class="display-tabs"
on-selected-changed="onSelectDisplayTab_" on-selected-changed="onSelectDisplayTab_"
tab-names="[[displayTabNames_]]"></cr-tabs> tab-names="[[displayTabNames_]]"></cr-tabs>
</div> </div>
<div hidden="[[hasMultipleDisplays_(displays)]]"
class="settings-box line-only"></div>
<div id="controlsDiv" class="settings-box layout vertical first"> <div id="controlsDiv" class="settings-box layout vertical first">
<h2>[[selectedDisplay.name]]</h2> <h2>[[selectedDisplay.name]]</h2>
...@@ -142,7 +148,7 @@ ...@@ -142,7 +148,7 @@
</template> </template>
<!-- Display zoom selection slider --> <!-- Display zoom selection slider -->
<div class="settings-box indented two-line"> <div class="settings-box indented two-line first">
<div class="start text-area layout vertical"> <div class="start text-area layout vertical">
<div id="displayZoomTitle">$i18n{displayZoomTitle}</div> <div id="displayZoomTitle">$i18n{displayZoomTitle}</div>
<div class="secondary self-start">$i18n{displayZoomSublabel}</div> <div class="secondary self-start">$i18n{displayZoomSublabel}</div>
......
...@@ -194,7 +194,8 @@ Polymer({ ...@@ -194,7 +194,8 @@ Polymer({
'updateNightLightScheduleSettings_(prefs.ash.night_light.schedule_type.*,' + 'updateNightLightScheduleSettings_(prefs.ash.night_light.schedule_type.*,' +
' prefs.ash.night_light.enabled.*)', ' prefs.ash.night_light.enabled.*)',
'onSelectedModeChange_(selectedModePref_.value)', 'onSelectedModeChange_(selectedModePref_.value)',
'onSelectedZoomChange_(selectedZoomPref_.value)' 'onSelectedZoomChange_(selectedZoomPref_.value)',
'onDisplaysChanged_(displays.*)',
], ],
/** @private {number} Selected mode index received from chrome. */ /** @private {number} Selected mode index received from chrome. */
...@@ -513,12 +514,11 @@ Polymer({ ...@@ -513,12 +514,11 @@ Polymer({
}, },
/** /**
* @param {!Array<!chrome.system.display.DisplayUnitInfo>} displays
* @return {boolean} * @return {boolean}
* @private * @private
*/ */
hasMultipleDisplays_: function(displays) { hasMultipleDisplays_: function() {
return displays.length > 1; return this.displays.length > 1;
}, },
/** /**
...@@ -952,9 +952,6 @@ Polymer({ ...@@ -952,9 +952,6 @@ Polymer({
this.setSelectedDisplay_(selectedDisplay); this.setSelectedDisplay_(selectedDisplay);
this.unifiedDesktopMode_ = !!primaryDisplay && primaryDisplay.isUnified; this.unifiedDesktopMode_ = !!primaryDisplay && primaryDisplay.isUnified;
this.$.displayLayout.updateDisplays(
this.displays, this.layouts, this.mirroringDestinationIds);
}, },
/** @private */ /** @private */
...@@ -985,4 +982,22 @@ Polymer({ ...@@ -985,4 +982,22 @@ Polymer({
this.nightLightScheduleSubLabel_ = ''; this.nightLightScheduleSubLabel_ = '';
} }
}, },
/**
* @return {boolean}
* @private
*/
shouldShowArrangementSection_: function() {
return this.hasMultipleDisplays_() || this.isMirrored_(this.displays);
},
/** @private */
onDisplaysChanged_: function() {
Polymer.dom.flush();
const displayLayout = this.$$('#displayLayout');
if (displayLayout) {
displayLayout.updateDisplays(
this.displays, this.layouts, this.mirroringDestinationIds);
}
},
}); });
...@@ -790,6 +790,9 @@ cr.define('device_page_tests', function() { ...@@ -790,6 +790,9 @@ cr.define('device_page_tests', function() {
expectFalse(displayPage.showUnifiedDesktop_( expectFalse(displayPage.showUnifiedDesktop_(
false, false, displayPage.displays)); false, false, displayPage.displays));
// Verify that the arrangement section is not shown.
expectEquals(null, displayPage.$$('#arrangement-section'));
// Add a second display. // Add a second display.
addDisplay(2); addDisplay(2);
fakeSystemDisplay.onDisplayChanged.callListeners(); fakeSystemDisplay.onDisplayChanged.callListeners();
...@@ -819,6 +822,9 @@ cr.define('device_page_tests', function() { ...@@ -819,6 +822,9 @@ cr.define('device_page_tests', function() {
expectFalse(displayPage.showUnifiedDesktop_( expectFalse(displayPage.showUnifiedDesktop_(
false, false, displayPage.displays)); false, false, displayPage.displays));
// Verify that the arrangement section is shown.
expectTrue(!!displayPage.$$('#arrangement-section'));
// Select the second display and make it primary. Also change the // Select the second display and make it primary. Also change the
// orientation of the second display. // orientation of the second display.
const displayLayout = displayPage.$$('#displayLayout'); const displayLayout = displayPage.$$('#displayLayout');
...@@ -874,6 +880,9 @@ cr.define('device_page_tests', function() { ...@@ -874,6 +880,9 @@ cr.define('device_page_tests', function() {
expectTrue(displayPage.showMirror_(false, displayPage.displays)); expectTrue(displayPage.showMirror_(false, displayPage.displays));
expectTrue(displayPage.isMirrored_(displayPage.displays)); expectTrue(displayPage.isMirrored_(displayPage.displays));
// Verify that the arrangement section is shown while mirroring.
expectTrue(!!displayPage.$$('#arrangement-section'));
// Ensure that the zoom value remains unchanged while draggging. // Ensure that the zoom value remains unchanged while draggging.
function pointerEvent(eventType, ratio) { function pointerEvent(eventType, ratio) {
const crSlider = displayPage.$.displaySizeSlider.$.slider; const crSlider = displayPage.$.displaySizeSlider.$.slider;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment