Commit a43869c6 authored by evliu's avatar evliu Committed by Commit Bot

Update caption settings page UI

This CL contains the following changes:
 - Add a background image behind the caption preview text
 - Move the preview section to the top of the page
 - Remove the top padding of the preview section
 - Replace the opacity sliders with dropdowns

Bug: 1009561
Change-Id: I659bccfbd5bac27f63afba0e4f899fb94a2e5d84
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1831943Reviewed-by: default avatarColin Blundell <blundell@chromium.org>
Reviewed-by: default avatarDan Beam <dbeam@chromium.org>
Commit-Queue: Evan Liu <evliu@google.com>
Cr-Commit-Position: refs/heads/master@{#703846}
parent 8c1432bf
...@@ -192,11 +192,14 @@ ...@@ -192,11 +192,14 @@
<message name="IDS_SETTINGS_CAPTIONS_BACKGROUND_OPACITY" desc="Name of the caption background opacity preference."> <message name="IDS_SETTINGS_CAPTIONS_BACKGROUND_OPACITY" desc="Name of the caption background opacity preference.">
Background opacity Background opacity
</message> </message>
<message name="IDS_SETTINGS_CAPTIONS_OPACITY_MIN" desc="Value of the minimum captions text opacity setting."> <message name="IDS_SETTINGS_CAPTIONS_OPACITY_OPAQUE" desc="Name of the opaque opacity preference.">
0 Opaque
</message> </message>
<message name="IDS_SETTINGS_CAPTIONS_OPACITY_MAX" desc="Value of the maximum captions text opacity setting."> <message name="IDS_SETTINGS_CAPTIONS_OPACITY_SEMI_TRANSPARENT" desc="Name of the semi-transparent opacity preference.">
100 Semi-transparent
</message>
<message name="IDS_SETTINGS_CAPTIONS_OPACITY_TRANSPARENT" desc="Name of the transparent opacity preference.">
Transparent
</message> </message>
<message name="IDS_SETTINGS_CAPTIONS_TEXT_SHADOW" desc="Name of the caption text shadow preference."> <message name="IDS_SETTINGS_CAPTIONS_TEXT_SHADOW" desc="Name of the caption text shadow preference.">
Text shadow Text shadow
......
39f3d045711d6364907ad1e709fa85cfac133726 9e5cc39d8f7e3468604037bee09decfa463359ff
\ No newline at end of file \ No newline at end of file
...@@ -25,6 +25,9 @@ ...@@ -25,6 +25,9 @@
<!-- KEEP THESE IN ALPHABETICAL ORDER! DO NOT ADD TO RANDOM PLACES JUST <!-- KEEP THESE IN ALPHABETICAL ORDER! DO NOT ADD TO RANDOM PLACES JUST
BECAUSE YOUR RESOURCES ARE FUNCTIONALLY RELATED OR FALL UNDER THE BECAUSE YOUR RESOURCES ARE FUNCTIONALLY RELATED OR FALL UNDER THE
SAME CONDITIONALS. --> SAME CONDITIONALS. -->
<if expr="is_linux or is_win or chromeos">
<structure type="chrome_scaled_image" name="IDR_ACCESSIBILITY_CAPTIONS_PREVIEW_BACKGROUND" file="common/captions-preview-bg.png" />
</if>
<if expr="toolkit_views and not is_macosx"> <if expr="toolkit_views and not is_macosx">
<structure type="chrome_scaled_image" name="IDR_APP_WINDOW_CLOSE" file="common/app_window_close.png" /> <structure type="chrome_scaled_image" name="IDR_APP_WINDOW_CLOSE" file="common/app_window_close.png" />
<structure type="chrome_scaled_image" name="IDR_APP_WINDOW_CLOSE_H" file="common/app_window_close_hover.png" /> <structure type="chrome_scaled_image" name="IDR_APP_WINDOW_CLOSE_H" file="common/app_window_close_hover.png" />
......
...@@ -10,16 +10,37 @@ ...@@ -10,16 +10,37 @@
<style include="settings-shared"> <style include="settings-shared">
.preview-box { .preview-box {
align-items: center; align-items: center;
border: var(--cr-separator-line); background-image:
border-radius: var(--cr-card-border-radius); url(chrome://theme/IDR_ACCESSIBILITY_CAPTIONS_PREVIEW_BACKGROUND);
background-position: center;
background-size: cover;
display: flex; display: flex;
height: 112px; height: 112px;
justify-content: center; justify-content: center;
margin: var(--cr-section-padding); margin: 0 var(--cr-section-padding) var(--cr-section-padding);
text-align: center; text-align: center;
} }
</style> </style>
<div class="settings-box first"> <div class="settings-box first">
<h2 class="start">$i18n{captionsPreview}</h2>
</div>
<div class="preview-box">
<span style="
font-size:[[prefs.accessibility.captions.text_size.value]];
font-family:[[prefs.accessibility.captions.text_font.value]];
background-color: [[computeBackgroundColor_(
prefs.accessibility.captions.background_opacity.value,
prefs.accessibility.captions.background_color.value)]];
color: [[computeTextColor_(
prefs.accessibility.captions.text_opacity.value,
prefs.accessibility.captions.text_color.value)]];
text-shadow: [[prefs.accessibility.captions.text_shadow.value]];
padding: [[computePadding_(
prefs.accessibility.captions.text_size.value)]]">
$i18n{quickBrownFox}
</span>
</div>
<div class="settings-box continuation">
<h2 class="start">$i18n{captionsSettings}</h2> <h2 class="start">$i18n{captionsSettings}</h2>
</div> </div>
<div class="list-frame"> <div class="list-frame">
...@@ -49,12 +70,11 @@ ...@@ -49,12 +70,11 @@
</div> </div>
<div class="list-item underbar"> <div class="list-item underbar">
<div class="start settings-box-text">$i18n{captionsTextOpacity}</div> <div class="start settings-box-text">$i18n{captionsTextOpacity}</div>
<settings-slider id="captionsTextOpacity" <settings-dropdown-menu id="captionsTextOpacity"
ticks="[[textOpacityRange_]]" label="$i18n{captionsTextOpacity}"
label-min="$i18n{captionsOpacityMin}" pref="{{prefs.accessibility.captions.text_opacity}}"
label-max="$i18n{captionsOpacityMax}" menu-options="[[textOpacityOptions_]]">
pref="{{prefs.accessibility.captions.text_opacity}}"> </settings-dropdown-menu>
</settings-slider>
</div> </div>
<div class="list-item underbar"> <div class="list-item underbar">
<div class="start settings-box-text">$i18n{captionsTextShadow}</div> <div class="start settings-box-text">$i18n{captionsTextShadow}</div>
...@@ -78,32 +98,12 @@ ...@@ -78,32 +98,12 @@
<div class="start settings-box-text"> <div class="start settings-box-text">
$i18n{captionsBackgroundOpacity} $i18n{captionsBackgroundOpacity}
</div> </div>
<settings-slider id="captionsBackgroundOpacity" <settings-dropdown-menu id="captionsBackgroundOpacity"
ticks="[[textOpacityRange_]]" label="$i18n{captionsBackgroundOpacity}"
label-min="$i18n{captionsOpacityMin}" pref="{{prefs.accessibility.captions.background_opacity}}"
label-max="$i18n{captionsOpacityMax}" menu-options="[[backgroundOpacityOptions_]]">
pref="{{prefs.accessibility.captions.background_opacity}}"> </settings-dropdown-menu>
</settings-slider>
</div>
</div>
<div class="settings-box continuation">
<h2 class="start">$i18n{captionsPreview}</h2>
</div> </div>
<div class="preview-box">
<span style="
font-size:[[prefs.accessibility.captions.text_size.value]];
font-family:[[prefs.accessibility.captions.text_font.value]];
background-color: [[computeBackgroundColor_(
prefs.accessibility.captions.background_opacity.value,
prefs.accessibility.captions.background_color.value)]];
color: [[computeTextColor_(
prefs.accessibility.captions.text_opacity.value,
prefs.accessibility.captions.text_color.value)]];
text-shadow: [[prefs.accessibility.captions.text_shadow.value]];
padding: [[computePadding_(
prefs.accessibility.captions.text_size.value)]]">
$i18n{quickBrownFox}
</span>
</div> </div>
</template> </template>
<script src="captions_subpage.js"></script> <script src="captions_subpage.js"></script>
......
...@@ -9,21 +9,6 @@ ...@@ -9,21 +9,6 @@
(function() { (function() {
'use strict'; 'use strict';
/** @type {!Array<number>} */
const TEXT_OPACITY_RANGE = [
0, 5, 10, 15, 20, 25, 30, 35, 40, 45, 50,
55, 60, 65, 70, 75, 80, 85, 90, 95, 100
];
/**
* @param {!Array<number>} ticks
* @return {!Array<!cr_slider.SliderTick>}
*/
function ticksWithLabels(ticks) {
return ticks.map(x => ({label: `${x}`, value: x}));
}
Polymer({ Polymer({
is: 'settings-captions', is: 'settings-captions',
...@@ -36,34 +21,26 @@ Polymer({ ...@@ -36,34 +21,26 @@ Polymer({
}, },
/** /**
* List of fonts populated by the fonts browser proxy. * List of options for the background opacity drop-down menu.
* @private {!DropdownMenuOptionList} */
textFontOptions_: Object,
/**
* Reasonable, text opacity range.
* @private {!Array<!cr_slider.SliderTick>}
*/
textOpacityRange_: {
readOnly: true,
type: Array,
value: ticksWithLabels(TEXT_OPACITY_RANGE),
},
/**
* List of options for the text size drop-down menu.
* @type {!DropdownMenuOptionList} * @type {!DropdownMenuOptionList}
*/ */
textSizeOptions_: { backgroundOpacityOptions_: {
readOnly: true, readOnly: true,
type: Array, type: Array,
value: function() { value: function() {
return [ return [
{value: '25%', name: loadTimeData.getString('verySmall')}, {
{value: '50%', name: loadTimeData.getString('small')}, value: 100, // Default
{value: '', name: loadTimeData.getString('medium')}, // Default = 100% name: loadTimeData.getString('captionsOpacityOpaque')
{value: '150%', name: loadTimeData.getString('large')}, },
{value: '200%', name: loadTimeData.getString('veryLarge')}, {
value: 50,
name: loadTimeData.getString('captionsOpacitySemiTransparent')
},
{
value: 0,
name: loadTimeData.getString('captionsOpacityTransparent')
},
]; ];
}, },
}, },
...@@ -77,18 +54,30 @@ Polymer({ ...@@ -77,18 +54,30 @@ Polymer({
type: Array, type: Array,
value: function() { value: function() {
return [ return [
{value: '', name: loadTimeData.getString('captionsDefaultSetting')}, {
{value: '0,0,0', name: loadTimeData.getString('captionsColorBlack')}, value: '',
name: loadTimeData.getString('captionsDefaultSetting')
},
{
value: '0,0,0',
name: loadTimeData.getString('captionsColorBlack')
},
{ {
value: '255,255,255', value: '255,255,255',
name: loadTimeData.getString('captionsColorWhite') name: loadTimeData.getString('captionsColorWhite')
}, },
{value: '255,0,0', name: loadTimeData.getString('captionsColorRed')}, {
value: '255,0,0',
name: loadTimeData.getString('captionsColorRed')
},
{ {
value: '0,255,0', value: '0,255,0',
name: loadTimeData.getString('captionsColorGreen') name: loadTimeData.getString('captionsColorGreen')
}, },
{value: '0,0,255', name: loadTimeData.getString('captionsColorBlue')}, {
value: '0,0,255',
name: loadTimeData.getString('captionsColorBlue')
},
{ {
value: '255,255,0', value: '255,255,0',
name: loadTimeData.getString('captionsColorYellow') name: loadTimeData.getString('captionsColorYellow')
...@@ -105,6 +94,36 @@ Polymer({ ...@@ -105,6 +94,36 @@ Polymer({
}, },
}, },
/**
* List of fonts populated by the fonts browser proxy.
* @private {!DropdownMenuOptionList} */
textFontOptions_: Object,
/**
* List of options for the text opacity drop-down menu.
* @type {!DropdownMenuOptionList}
*/
textOpacityOptions_: {
readOnly: true,
type: Array,
value: function() {
return [
{
value: 100, // Default
name: loadTimeData.getString('captionsOpacityOpaque')
},
{
value: 50,
name: loadTimeData.getString('captionsOpacitySemiTransparent')
},
{
value: 10,
name: loadTimeData.getString('captionsOpacityTransparent')
},
];
},
},
/** /**
* List of options for the text shadow drop-down menu. * List of options for the text shadow drop-down menu.
* @type {!DropdownMenuOptionList} * @type {!DropdownMenuOptionList}
...@@ -135,6 +154,24 @@ Polymer({ ...@@ -135,6 +154,24 @@ Polymer({
]; ];
}, },
}, },
/**
* List of options for the text size drop-down menu.
* @type {!DropdownMenuOptionList}
*/
textSizeOptions_: {
readOnly: true,
type: Array,
value: function() {
return [
{value: '25%', name: loadTimeData.getString('verySmall')},
{value: '50%', name: loadTimeData.getString('small')},
{value: '', name: loadTimeData.getString('medium')}, // Default = 100%
{value: '150%', name: loadTimeData.getString('large')},
{value: '200%', name: loadTimeData.getString('veryLarge')},
];
},
},
}, },
/** @private {?settings.FontsBrowserProxy} */ /** @private {?settings.FontsBrowserProxy} */
......
...@@ -208,8 +208,10 @@ void AddA11yStrings(content::WebUIDataSource* html_source) { ...@@ -208,8 +208,10 @@ void AddA11yStrings(content::WebUIDataSource* html_source) {
{"captionsTextColor", IDS_SETTINGS_CAPTIONS_TEXT_COLOR}, {"captionsTextColor", IDS_SETTINGS_CAPTIONS_TEXT_COLOR},
{"captionsTextOpacity", IDS_SETTINGS_CAPTIONS_TEXT_OPACITY}, {"captionsTextOpacity", IDS_SETTINGS_CAPTIONS_TEXT_OPACITY},
{"captionsBackgroundOpacity", IDS_SETTINGS_CAPTIONS_BACKGROUND_OPACITY}, {"captionsBackgroundOpacity", IDS_SETTINGS_CAPTIONS_BACKGROUND_OPACITY},
{"captionsOpacityMin", IDS_SETTINGS_CAPTIONS_OPACITY_MIN}, {"captionsOpacityOpaque", IDS_SETTINGS_CAPTIONS_OPACITY_OPAQUE},
{"captionsOpacityMax", IDS_SETTINGS_CAPTIONS_OPACITY_MAX}, {"captionsOpacitySemiTransparent",
IDS_SETTINGS_CAPTIONS_OPACITY_SEMI_TRANSPARENT},
{"captionsOpacityTransparent", IDS_SETTINGS_CAPTIONS_OPACITY_TRANSPARENT},
{"captionsTextShadow", IDS_SETTINGS_CAPTIONS_TEXT_SHADOW}, {"captionsTextShadow", IDS_SETTINGS_CAPTIONS_TEXT_SHADOW},
{"captionsTextShadowNone", IDS_SETTINGS_CAPTIONS_TEXT_SHADOW_NONE}, {"captionsTextShadowNone", IDS_SETTINGS_CAPTIONS_TEXT_SHADOW_NONE},
{"captionsTextShadowRaised", IDS_SETTINGS_CAPTIONS_TEXT_SHADOW_RAISED}, {"captionsTextShadowRaised", IDS_SETTINGS_CAPTIONS_TEXT_SHADOW_RAISED},
......
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