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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/ui/views/download/download_shelf_view.h" 5 #include "chrome/browser/ui/views/download/download_shelf_view.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
173 delete view; 173 delete view;
174 if (download_views_.empty()) 174 if (download_views_.empty())
175 Close(); 175 Close();
176 else if (CanAutoClose()) 176 else if (CanAutoClose())
177 mouse_watcher_.Start(); 177 mouse_watcher_.Start();
178 Layout(); 178 Layout();
179 SchedulePaint(); 179 SchedulePaint();
180 } 180 }
181 181
182 views::View* DownloadShelfView::GetDefaultFocusableChild() { 182 views::View* DownloadShelfView::GetDefaultFocusableChild() {
183 if (!download_views_.empty()) 183 return download_views_.empty() ?
184 return download_views_[0]; 184 static_cast<View*>(show_all_view_) : download_views_[0];
185 else
186 return show_all_view_;
187 } 185 }
188 186
189 void DownloadShelfView::OnPaint(gfx::Canvas* canvas) { 187 void DownloadShelfView::OnPaint(gfx::Canvas* canvas) {
190 OnPaintBackground(canvas); 188 OnPaintBackground(canvas);
191 OnPaintBorder(canvas); 189 OnPaintBorder(canvas);
192 190
193 // Draw the focus rect here, since it's outside the bounds of the item. 191 // Draw the focus rect here, since it's outside the bounds of the item.
194 for (size_t i = 0; i < download_views_.size(); ++i) { 192 for (size_t i = 0; i < download_views_.size(); ++i) {
195 if (download_views_[i]->HasFocus()) { 193 if (download_views_[i]->HasFocus()) {
196 gfx::Rect r = GetFocusRectBounds(download_views_[i]); 194 gfx::Rect r = GetFocusRectBounds(download_views_[i]);
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
244 242
245 void DownloadShelfView::AnimationEnded(const ui::Animation *animation) { 243 void DownloadShelfView::AnimationEnded(const ui::Animation *animation) {
246 if (animation == shelf_animation_.get()) { 244 if (animation == shelf_animation_.get()) {
247 parent_->SetDownloadShelfVisible(shelf_animation_->IsShowing()); 245 parent_->SetDownloadShelfVisible(shelf_animation_->IsShowing());
248 if (!shelf_animation_->IsShowing()) 246 if (!shelf_animation_->IsShowing())
249 Closed(); 247 Closed();
250 } 248 }
251 } 249 }
252 250
253 void DownloadShelfView::Layout() { 251 void DownloadShelfView::Layout() {
254 // Now that we know we have a parent, we can safely set our theme colors.
255 show_all_view_->SetColor(
256 GetThemeProvider()->GetColor(ThemeService::COLOR_BOOKMARK_TEXT));
257 set_background(views::Background::CreateSolidBackground(
258 GetThemeProvider()->GetColor(ThemeService::COLOR_TOOLBAR)));
259
260 // Let our base class layout our child views 252 // Let our base class layout our child views
261 views::View::Layout(); 253 views::View::Layout();
262 254
263 // If there is not enough room to show the first download item, show the 255 // If there is not enough room to show the first download item, show the
264 // "Show all downloads" link to the left to make it more visible that there is 256 // "Show all downloads" link to the left to make it more visible that there is
265 // something to see. 257 // something to see.
266 bool show_link_only = !CanFitFirstDownloadItem(); 258 bool show_link_only = !CanFitFirstDownloadItem();
267 259
268 gfx::Size image_size = arrow_image_->GetPreferredSize(); 260 gfx::Size image_size = arrow_image_->GetPreferredSize();
269 gfx::Size close_button_size = close_button_->GetPreferredSize(); 261 gfx::Size close_button_size = close_button_->GetPreferredSize();
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
320 if (next_x < max_download_x) { 312 if (next_x < max_download_x) {
321 (*ri)->SetVisible(true); 313 (*ri)->SetVisible(true);
322 (*ri)->SetBounds(x, CenterPosition(view_size.height(), height()), 314 (*ri)->SetBounds(x, CenterPosition(view_size.height(), height()),
323 item_width, view_size.height()); 315 item_width, view_size.height());
324 } else { 316 } else {
325 (*ri)->SetVisible(false); 317 (*ri)->SetVisible(false);
326 } 318 }
327 } 319 }
328 } 320 }
329 321
322 void DownloadShelfView::ViewHierarchyChanged(bool is_add,
323 View* parent,
324 View* child) {
325 View::ViewHierarchyChanged(is_add, parent, child);
326
327 if (is_add && (child == this)) {
328 // Now that we know we have a parent, we can safely set our theme colors.
329 set_background(views::Background::CreateSolidBackground(
330 GetThemeProvider()->GetColor(ThemeService::COLOR_TOOLBAR)));
331 show_all_view_->SetBackgroundColor(background()->get_color());
332 show_all_view_->SetEnabledColor(
333 GetThemeProvider()->GetColor(ThemeService::COLOR_BOOKMARK_TEXT));
334 }
335 }
336
330 bool DownloadShelfView::CanFitFirstDownloadItem() { 337 bool DownloadShelfView::CanFitFirstDownloadItem() {
331 if (download_views_.empty()) 338 if (download_views_.empty())
332 return true; 339 return true;
333 340
334 gfx::Size image_size = arrow_image_->GetPreferredSize(); 341 gfx::Size image_size = arrow_image_->GetPreferredSize();
335 gfx::Size close_button_size = close_button_->GetPreferredSize(); 342 gfx::Size close_button_size = close_button_->GetPreferredSize();
336 gfx::Size show_all_size = show_all_view_->GetPreferredSize(); 343 gfx::Size show_all_size = show_all_view_->GetPreferredSize();
337 344
338 // Let's compute the width available for download items, which is the width 345 // Let's compute the width available for download items, which is the width
339 // of the shelf minus the "Show all downloads" link, arrow and close button 346 // of the shelf minus the "Show all downloads" link, arrow and close button
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
444 const DownloadItemView* download_item_view) { 451 const DownloadItemView* download_item_view) {
445 gfx::Rect bounds = download_item_view->bounds(); 452 gfx::Rect bounds = download_item_view->bounds();
446 453
447 #if defined(TOOLKIT_VIEWS) 454 #if defined(TOOLKIT_VIEWS)
448 bounds.set_height(bounds.height() - 1); 455 bounds.set_height(bounds.height() - 1);
449 bounds.Offset(0, 3); 456 bounds.Offset(0, 3);
450 #endif 457 #endif
451 458
452 return bounds; 459 return bounds;
453 } 460 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698