Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(479)

Unified Diff: chrome/browser/ui/views/sad_tab_view.cc

Issue 8221027: Make views::Label and views::Link auto-color themselves to be readable over their background colo... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/ui/views/sad_tab_view.h ('k') | chrome/browser/ui/views/wrench_menu.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/views/sad_tab_view.cc
===================================================================
--- chrome/browser/ui/views/sad_tab_view.cc (revision 104959)
+++ chrome/browser/ui/views/sad_tab_view.cc (working copy)
@@ -41,6 +41,8 @@
: tab_contents_(tab_contents),
kind_(kind),
painted_(false),
+ base_font_(ResourceBundle::GetSharedInstance().GetFont(
+ ResourceBundle::BaseFont)),
message_(NULL),
help_link_(NULL),
feedback_link_(NULL) {
@@ -95,47 +97,33 @@
columns->AddPaddingColumn(1, kPadding);
views::ImageView* image = new views::ImageView();
- ResourceBundle& rb = ResourceBundle::GetSharedInstance();
- image->SetImage(
- rb.GetBitmapNamed((kind_ == CRASHED) ? IDR_SAD_TAB : IDR_KILLED_TAB));
+ image->SetImage(ResourceBundle::GetSharedInstance().GetBitmapNamed(
+ (kind_ == CRASHED) ? IDR_SAD_TAB : IDR_KILLED_TAB));
layout->StartRowWithPadding(0, column_set_id, 1, kPadding);
layout->AddView(image);
- views::Label* title = new views::Label(l10n_util::GetStringUTF16(
+ views::Label* title = CreateLabel(l10n_util::GetStringUTF16(
(kind_ == CRASHED) ? IDS_SAD_TAB_TITLE : IDS_KILLED_TAB_TITLE));
- const gfx::Font& base_font = rb.GetFont(ResourceBundle::BaseFont);
- title->SetFont(base_font.DeriveFont(kTitleFontSizeDelta, gfx::Font::BOLD));
- title->SetColor(kTextColor);
+ title->SetFont(base_font_.DeriveFont(kTitleFontSizeDelta, gfx::Font::BOLD));
layout->StartRowWithPadding(0, column_set_id, 0, kPadding);
layout->AddView(title);
- message_ = new views::Label(l10n_util::GetStringUTF16(
+ message_ = CreateLabel(l10n_util::GetStringUTF16(
(kind_ == CRASHED) ? IDS_SAD_TAB_MESSAGE : IDS_KILLED_TAB_MESSAGE));
- message_->SetFont(base_font.DeriveFont(kMessageFontSizeDelta));
- message_->SetColor(kTextColor);
message_->SetMultiLine(true);
layout->StartRowWithPadding(0, column_set_id, 0, kPadding);
layout->AddView(message_);
if (tab_contents_) {
- string16 help_link(l10n_util::GetStringUTF16(
+ help_link_ = CreateLink(l10n_util::GetStringUTF16(
(kind_ == CRASHED) ? IDS_SAD_TAB_HELP_LINK : IDS_LEARN_MORE));
- help_link_ = new views::Link(help_link);
- help_link_->SetFont(base_font.DeriveFont(kMessageFontSizeDelta));
- help_link_->SetNormalColor(kTextColor);
- help_link_->set_listener(this);
if (kind_ == CRASHED) {
size_t offset = 0;
string16 help_text(l10n_util::GetStringFUTF16(IDS_SAD_TAB_HELP_MESSAGE,
string16(), &offset));
- views::Label* help_prefix =
- new views::Label(help_text.substr(0, offset));
- help_prefix->SetFont(base_font.DeriveFont(kMessageFontSizeDelta));
- help_prefix->SetColor(kTextColor);
- views::Label* help_suffix = new views::Label(help_text.substr(offset));
- help_suffix->SetFont(base_font.DeriveFont(kMessageFontSizeDelta));
- help_suffix->SetColor(kTextColor);
+ views::Label* help_prefix = CreateLabel(help_text.substr(0, offset));
+ views::Label* help_suffix = CreateLabel(help_text.substr(offset));
const int help_column_set_id = 1;
views::ColumnSet* help_columns = layout->AddColumnSet(help_column_set_id);
@@ -154,11 +142,8 @@
layout->StartRowWithPadding(0, column_set_id, 0, kPadding);
layout->AddView(help_link_);
- feedback_link_ = new views::Link(
+ feedback_link_ = CreateLink(
l10n_util::GetStringUTF16(IDS_KILLED_TAB_FEEDBACK_LINK));
- feedback_link_->SetFont(base_font.DeriveFont(kMessageFontSizeDelta));
- feedback_link_->SetNormalColor(kTextColor);
- feedback_link_->set_listener(this);
layout->StartRowWithPadding(0, column_set_id, 0, kPadding);
layout->AddView(feedback_link_);
}
@@ -174,3 +159,20 @@
}
View::OnPaint(canvas);
}
+
+views::Label* SadTabView::CreateLabel(const string16& text) {
+ views::Label* label = new views::Label(text);
+ label->SetFont(base_font_.DeriveFont(kMessageFontSizeDelta));
+ label->SetBackgroundColor(background()->get_color());
+ label->SetEnabledColor(kTextColor);
+ return label;
+}
+
+views::Link* SadTabView::CreateLink(const string16& text) {
+ views::Link* link = new views::Link(text);
+ link->SetFont(base_font_.DeriveFont(kMessageFontSizeDelta));
+ link->SetBackgroundColor(background()->get_color());
+ link->SetEnabledColor(kTextColor);
+ link->set_listener(this);
+ return link;
+}
« no previous file with comments | « chrome/browser/ui/views/sad_tab_view.h ('k') | chrome/browser/ui/views/wrench_menu.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698