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

Unified Diff: chrome/browser/ui/views/download/download_shelf_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
Index: chrome/browser/ui/views/download/download_shelf_view.cc
===================================================================
--- chrome/browser/ui/views/download/download_shelf_view.cc (revision 104959)
+++ chrome/browser/ui/views/download/download_shelf_view.cc (working copy)
@@ -93,44 +93,13 @@
mouse_watcher_.set_notify_on_exit_time_ms(kNotifyOnExitTimeMS);
set_id(VIEW_ID_DOWNLOAD_SHELF);
parent->AddChildView(this);
- Init();
+ Show();
}
DownloadShelfView::~DownloadShelfView() {
parent_->RemoveChildView(this);
}
-void DownloadShelfView::Init() {
- ResourceBundle &rb = ResourceBundle::GetSharedInstance();
- arrow_image_ = new views::ImageView();
- arrow_image_->SetImage(rb.GetBitmapNamed(IDR_DOWNLOADS_FAVICON));
- AddChildView(arrow_image_);
-
- show_all_view_ = new views::Link(
- l10n_util::GetStringUTF16(IDS_SHOW_ALL_DOWNLOADS));
- show_all_view_->set_listener(this);
- AddChildView(show_all_view_);
-
- close_button_ = new views::ImageButton(this);
- close_button_->SetImage(views::CustomButton::BS_NORMAL,
- rb.GetBitmapNamed(IDR_CLOSE_BAR));
- close_button_->SetImage(views::CustomButton::BS_HOT,
- rb.GetBitmapNamed(IDR_CLOSE_BAR_H));
- close_button_->SetImage(views::CustomButton::BS_PUSHED,
- rb.GetBitmapNamed(IDR_CLOSE_BAR_P));
- close_button_->SetAccessibleName(
- l10n_util::GetStringUTF16(IDS_ACCNAME_CLOSE));
- UpdateButtonColors();
- AddChildView(close_button_);
-
- new_item_animation_.reset(new ui::SlideAnimation(this));
- new_item_animation_->SetSlideDuration(kNewItemAnimationDurationMs);
-
- shelf_animation_.reset(new ui::SlideAnimation(this));
- shelf_animation_->SetSlideDuration(kShelfAnimationDurationMs);
- Show();
-}
-
void DownloadShelfView::AddDownloadView(DownloadItemView* view) {
mouse_watcher_.Stop();
@@ -180,10 +149,8 @@
}
views::View* DownloadShelfView::GetDefaultFocusableChild() {
- if (!download_views_.empty())
- return download_views_[0];
- else
- return show_all_view_;
+ return download_views_.empty() ?
+ static_cast<View*>(show_all_view_) : download_views_[0];
}
void DownloadShelfView::OnPaint(gfx::Canvas* canvas) {
@@ -251,12 +218,6 @@
}
void DownloadShelfView::Layout() {
- // Now that we know we have a parent, we can safely set our theme colors.
- show_all_view_->SetColor(
- GetThemeProvider()->GetColor(ThemeService::COLOR_BOOKMARK_TEXT));
- set_background(views::Background::CreateSolidBackground(
- GetThemeProvider()->GetColor(ThemeService::COLOR_TOOLBAR)));
-
// Let our base class layout our child views
views::View::Layout();
@@ -327,6 +288,48 @@
}
}
+void DownloadShelfView::ViewHierarchyChanged(bool is_add,
+ View* parent,
+ View* child) {
+ View::ViewHierarchyChanged(is_add, parent, child);
+
+ if (is_add && (child == this)) {
+ set_background(views::Background::CreateSolidBackground(
+ GetThemeProvider()->GetColor(ThemeService::COLOR_TOOLBAR)));
+
+ ResourceBundle& rb = ResourceBundle::GetSharedInstance();
+ arrow_image_ = new views::ImageView();
+ arrow_image_->SetImage(rb.GetBitmapNamed(IDR_DOWNLOADS_FAVICON));
+ AddChildView(arrow_image_);
+
+ show_all_view_ = new views::Link(
+ l10n_util::GetStringUTF16(IDS_SHOW_ALL_DOWNLOADS));
+ show_all_view_->set_listener(this);
+ show_all_view_->SetBackgroundColor(background()->get_color());
+ show_all_view_->SetEnabledColor(
+ GetThemeProvider()->GetColor(ThemeService::COLOR_BOOKMARK_TEXT));
+ AddChildView(show_all_view_);
+
+ close_button_ = new views::ImageButton(this);
+ close_button_->SetImage(views::CustomButton::BS_NORMAL,
+ rb.GetBitmapNamed(IDR_CLOSE_BAR));
+ close_button_->SetImage(views::CustomButton::BS_HOT,
+ rb.GetBitmapNamed(IDR_CLOSE_BAR_H));
+ close_button_->SetImage(views::CustomButton::BS_PUSHED,
+ rb.GetBitmapNamed(IDR_CLOSE_BAR_P));
+ close_button_->SetAccessibleName(
+ l10n_util::GetStringUTF16(IDS_ACCNAME_CLOSE));
+ UpdateButtonColors();
+ AddChildView(close_button_);
+
+ new_item_animation_.reset(new ui::SlideAnimation(this));
+ new_item_animation_->SetSlideDuration(kNewItemAnimationDurationMs);
+
+ shelf_animation_.reset(new ui::SlideAnimation(this));
+ shelf_animation_->SetSlideDuration(kShelfAnimationDurationMs);
+ }
+}
+
bool DownloadShelfView::CanFitFirstDownloadItem() {
if (download_views_.empty())
return true;

Powered by Google App Engine
This is Rietveld 408576698