| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_item_view_md.h" | 5 #include "chrome/browser/ui/views/download/download_item_view_md.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 444 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 455 state->name = accessible_name_; | 455 state->name = accessible_name_; |
| 456 state->role = ui::AX_ROLE_BUTTON; | 456 state->role = ui::AX_ROLE_BUTTON; |
| 457 if (model_.IsDangerous()) | 457 if (model_.IsDangerous()) |
| 458 state->AddStateFlag(ui::AX_STATE_DISABLED); | 458 state->AddStateFlag(ui::AX_STATE_DISABLED); |
| 459 else | 459 else |
| 460 state->AddStateFlag(ui::AX_STATE_HASPOPUP); | 460 state->AddStateFlag(ui::AX_STATE_HASPOPUP); |
| 461 } | 461 } |
| 462 | 462 |
| 463 void DownloadItemViewMd::OnThemeChanged() { | 463 void DownloadItemViewMd::OnThemeChanged() { |
| 464 UpdateColorsFromTheme(); | 464 UpdateColorsFromTheme(); |
| 465 SchedulePaint(); |
| 465 } | 466 } |
| 466 | 467 |
| 467 void DownloadItemViewMd::AddInkDropLayer(ui::Layer* ink_drop_layer) { | 468 void DownloadItemViewMd::AddInkDropLayer(ui::Layer* ink_drop_layer) { |
| 468 InkDropHostView::AddInkDropLayer(ink_drop_layer); | 469 InkDropHostView::AddInkDropLayer(ink_drop_layer); |
| 469 // The layer that's added to host the ink drop layer must mask to bounds | 470 // The layer that's added to host the ink drop layer must mask to bounds |
| 470 // so the hover effect is clipped while animating open. | 471 // so the hover effect is clipped while animating open. |
| 471 layer()->SetMasksToBounds(true); | 472 layer()->SetMasksToBounds(true); |
| 472 } | 473 } |
| 473 | 474 |
| 474 scoped_ptr<views::InkDropAnimation> DownloadItemViewMd::CreateInkDropAnimation() | 475 scoped_ptr<views::InkDropAnimation> DownloadItemViewMd::CreateInkDropAnimation() |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 581 download()->Remove(); | 582 download()->Remove(); |
| 582 } | 583 } |
| 583 | 584 |
| 584 void DownloadItemViewMd::AnimationProgressed(const gfx::Animation* animation) { | 585 void DownloadItemViewMd::AnimationProgressed(const gfx::Animation* animation) { |
| 585 // We don't care if what animation (body button/drop button/complete), | 586 // We don't care if what animation (body button/drop button/complete), |
| 586 // is calling back, as they all have to go through the same paint call. | 587 // is calling back, as they all have to go through the same paint call. |
| 587 SchedulePaint(); | 588 SchedulePaint(); |
| 588 } | 589 } |
| 589 | 590 |
| 590 void DownloadItemViewMd::OnPaint(gfx::Canvas* canvas) { | 591 void DownloadItemViewMd::OnPaint(gfx::Canvas* canvas) { |
| 592 // Make sure to draw |this| opaquely. Since the toolbar color can be partially |
| 593 // transparent, start with an opaque black backdrop. |
| 594 canvas->DrawColor(SK_ColorBLACK); |
| 595 canvas->DrawColor( |
| 596 GetThemeProvider()->GetColor(ThemeProperties::COLOR_TOOLBAR)); |
| 597 |
| 591 DrawStatusText(canvas); | 598 DrawStatusText(canvas); |
| 592 DrawFilename(canvas); | 599 DrawFilename(canvas); |
| 593 DrawIcon(canvas); | 600 DrawIcon(canvas); |
| 594 OnPaintBorder(canvas); | 601 OnPaintBorder(canvas); |
| 595 | 602 |
| 596 if (HasFocus()) | 603 if (HasFocus()) |
| 597 canvas->DrawFocusRect(GetLocalBounds()); | 604 views::CustomButton::PaintMdFocusRing(canvas, this); |
| 598 } | 605 } |
| 599 | 606 |
| 600 int DownloadItemViewMd::GetYForFilenameText() const { | 607 int DownloadItemViewMd::GetYForFilenameText() const { |
| 601 int text_height = font_list_.GetBaseline(); | 608 int text_height = font_list_.GetBaseline(); |
| 602 if (!status_text_.empty()) | 609 if (!status_text_.empty()) |
| 603 text_height += kVerticalTextPadding + status_font_list_.GetBaseline(); | 610 text_height += kVerticalTextPadding + status_font_list_.GetBaseline(); |
| 604 return (height() - text_height) / 2; | 611 return (height() - text_height) / 2; |
| 605 } | 612 } |
| 606 | 613 |
| 607 void DownloadItemViewMd::DrawStatusText(gfx::Canvas* canvas) { | 614 void DownloadItemViewMd::DrawStatusText(gfx::Canvas* canvas) { |
| (...skipping 496 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1104 SchedulePaint(); | 1111 SchedulePaint(); |
| 1105 } | 1112 } |
| 1106 | 1113 |
| 1107 SkColor DownloadItemViewMd::GetTextColor() const { | 1114 SkColor DownloadItemViewMd::GetTextColor() const { |
| 1108 return GetTextColorForThemeProvider(GetThemeProvider()); | 1115 return GetTextColorForThemeProvider(GetThemeProvider()); |
| 1109 } | 1116 } |
| 1110 | 1117 |
| 1111 SkColor DownloadItemViewMd::GetDimmedTextColor() const { | 1118 SkColor DownloadItemViewMd::GetDimmedTextColor() const { |
| 1112 return SkColorSetA(GetTextColor(), 0xC7); | 1119 return SkColorSetA(GetTextColor(), 0xC7); |
| 1113 } | 1120 } |
| OLD | NEW |