Commit 02f98476 authored by Eric Willigers's avatar Eric Willigers Committed by Commit Bot

Label responds to theme change

Previously, Label would only update colors in response to theme changes
if the text_style was STYLE_PRIMARY.

CustomTabBarView now uses CONTEXT_LABEL for the title and the origin.
As the origin has STYLE_SECONDARY, this causes the origin to be faded
relative to the title.

Screen shots before and after:
https://docs.google.com/document/d/1YRuzw0Bh9IyjmbtwBa0NpwNvu7ttbMM8mdRF0K3YWzc/edit?usp=sharing

Bug: 1033298
Change-Id: Iff4dbc7dfe611cd4c3a38da0b39fc790dae29bcc
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2010757
Commit-Queue: Eric Willigers <ericwilligers@chromium.org>
Reviewed-by: default avatarPeter Kasting <pkasting@chromium.org>
Cr-Commit-Position: refs/heads/master@{#733552}
parent 37cf4fd9
......@@ -83,10 +83,9 @@ class CustomTabBarTitleOriginView : public views::View {
public:
CustomTabBarTitleOriginView() {
auto title_label = std::make_unique<views::Label>(
base::string16(), CONTEXT_BODY_TEXT_LARGE,
views::style::TextStyle::STYLE_PRIMARY);
base::string16(), views::style::CONTEXT_LABEL);
auto location_label = std::make_unique<views::Label>(
base::string16(), CONTEXT_BODY_TEXT_SMALL,
base::string16(), views::style::CONTEXT_LABEL,
views::style::STYLE_SECONDARY,
gfx::DirectionalityMode::DIRECTIONALITY_AS_URL);
......
......@@ -67,17 +67,17 @@ Label::Label(const base::string16& text,
int text_context,
int text_style,
gfx::DirectionalityMode directionality_mode)
: text_context_(text_context), context_menu_contents_(this) {
: text_context_(text_context),
text_style_(text_style),
context_menu_contents_(this) {
Init(text, style::GetFont(text_context, text_style), directionality_mode);
SetLineHeight(style::GetLineHeight(text_context, text_style));
// If an explicit style is given, ignore color changes due to the NativeTheme.
if (text_style != style::STYLE_PRIMARY)
SetEnabledColor(style::GetColor(*this, text_context, text_style));
}
Label::Label(const base::string16& text, const CustomFont& font)
: text_context_(style::CONTEXT_LABEL), context_menu_contents_(this) {
: text_context_(style::CONTEXT_LABEL),
text_style_(style::STYLE_PRIMARY),
context_menu_contents_(this) {
Init(text, font.font_list, gfx::DirectionalityMode::DIRECTIONALITY_FROM_TEXT);
}
......@@ -1059,7 +1059,7 @@ void Label::UpdateColorsFromTheme() {
ui::NativeTheme* theme = GetNativeTheme();
if (!enabled_color_set_) {
requested_enabled_color_ =
style::GetColor(*this, text_context_, style::STYLE_PRIMARY);
style::GetColor(*this, text_context_, text_style_);
}
if (!background_color_set_) {
background_color_ =
......
......@@ -373,6 +373,7 @@ class VIEWS_EXPORT Label : public View,
void BuildContextMenuContents();
const int text_context_;
const int text_style_;
// An un-elided and single-line RenderText object used for preferred sizing.
std::unique_ptr<gfx::RenderText> full_text_;
......
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