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

Side by Side Diff: ash/common/shelf/overflow_button.cc

Issue 2191153002: Revert of Replaced BackgroundAnimator with ShelfBackgroundAnimator. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 4 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
« no previous file with comments | « ash/common/shelf/overflow_button.h ('k') | ash/common/shelf/shelf_background_animator.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "ash/common/shelf/overflow_button.h" 5 #include "ash/common/shelf/overflow_button.h"
6 6
7 #include "ash/common/ash_constants.h" 7 #include "ash/common/ash_constants.h"
8 #include "ash/common/material_design/material_design_controller.h" 8 #include "ash/common/material_design/material_design_controller.h"
9 #include "ash/common/shelf/ink_drop_button_listener.h" 9 #include "ash/common/shelf/ink_drop_button_listener.h"
10 #include "ash/common/shelf/shelf_constants.h" 10 #include "ash/common/shelf/shelf_constants.h"
(...skipping 13 matching lines...) Expand all
24 #include "ui/gfx/transform.h" 24 #include "ui/gfx/transform.h"
25 #include "ui/gfx/vector_icons_public.h" 25 #include "ui/gfx/vector_icons_public.h"
26 26
27 namespace ash { 27 namespace ash {
28 28
29 OverflowButton::OverflowButton(InkDropButtonListener* listener, 29 OverflowButton::OverflowButton(InkDropButtonListener* listener,
30 WmShelf* wm_shelf) 30 WmShelf* wm_shelf)
31 : CustomButton(nullptr), 31 : CustomButton(nullptr),
32 bottom_image_(nullptr), 32 bottom_image_(nullptr),
33 listener_(listener), 33 listener_(listener),
34 wm_shelf_(wm_shelf), 34 wm_shelf_(wm_shelf) {
35 background_alpha_(0) {
36 if (MaterialDesignController::IsShelfMaterial()) { 35 if (MaterialDesignController::IsShelfMaterial()) {
37 bottom_image_md_ = 36 bottom_image_md_ =
38 CreateVectorIcon(gfx::VectorIconId::SHELF_OVERFLOW, kShelfIconColor); 37 CreateVectorIcon(gfx::VectorIconId::SHELF_OVERFLOW, kShelfIconColor);
39 bottom_image_ = &bottom_image_md_; 38 bottom_image_ = &bottom_image_md_;
40 } else { 39 } else {
41 bottom_image_ = ui::ResourceBundle::GetSharedInstance().GetImageSkiaNamed( 40 bottom_image_ = ui::ResourceBundle::GetSharedInstance().GetImageSkiaNamed(
42 IDR_ASH_SHELF_OVERFLOW); 41 IDR_ASH_SHELF_OVERFLOW);
43 } 42 }
44 43
45 SetFocusBehavior(FocusBehavior::ACCESSIBLE_ONLY); 44 SetFocusBehavior(FocusBehavior::ACCESSIBLE_ONLY);
46 SetAccessibleName(l10n_util::GetStringUTF16(IDS_ASH_SHELF_OVERFLOW_NAME)); 45 SetAccessibleName(l10n_util::GetStringUTF16(IDS_ASH_SHELF_OVERFLOW_NAME));
47 } 46 }
48 47
49 OverflowButton::~OverflowButton() {} 48 OverflowButton::~OverflowButton() {}
50 49
51 void OverflowButton::OnShelfAlignmentChanged() { 50 void OverflowButton::OnShelfAlignmentChanged() {
52 SchedulePaint(); 51 SchedulePaint();
53 } 52 }
54 53
55 void OverflowButton::SetBackgroundAlpha(int alpha) {
56 background_alpha_ = alpha;
57 SchedulePaint();
58 }
59
60 void OverflowButton::OnPaint(gfx::Canvas* canvas) { 54 void OverflowButton::OnPaint(gfx::Canvas* canvas) {
61 gfx::Rect bounds = CalculateButtonBounds(); 55 gfx::Rect bounds = CalculateButtonBounds();
62 PaintBackground(canvas, bounds); 56 PaintBackground(canvas, bounds);
63 PaintForeground(canvas, bounds); 57 PaintForeground(canvas, bounds);
64 } 58 }
65 59
66 void OverflowButton::NotifyClick(const ui::Event& event) { 60 void OverflowButton::NotifyClick(const ui::Event& event) {
67 CustomButton::NotifyClick(event); 61 CustomButton::NotifyClick(event);
68 if (listener_) 62 if (listener_)
69 listener_->ButtonPressed(this, event, ink_drop()); 63 listener_->ButtonPressed(this, event, ink_drop());
70 } 64 }
71 65
72 void OverflowButton::PaintBackground(gfx::Canvas* canvas, 66 void OverflowButton::PaintBackground(gfx::Canvas* canvas,
73 const gfx::Rect& bounds) { 67 const gfx::Rect& bounds) {
74 if (MaterialDesignController::IsShelfMaterial()) { 68 if (MaterialDesignController::IsShelfMaterial()) {
69 SkColor background_color = SK_ColorTRANSPARENT;
70 if (wm_shelf_->GetBackgroundType() ==
71 ShelfBackgroundType::SHELF_BACKGROUND_DEFAULT) {
72 background_color = SkColorSetA(kShelfBaseColor,
73 GetShelfConstant(SHELF_BACKGROUND_ALPHA));
74 }
75
76 // TODO(bruthig|tdanderson): The background should be changed using a
77 // fade in/out animation.
75 SkPaint background_paint; 78 SkPaint background_paint;
76 background_paint.setFlags(SkPaint::kAntiAlias_Flag); 79 background_paint.setFlags(SkPaint::kAntiAlias_Flag);
77 background_paint.setColor(SkColorSetA(kShelfBaseColor, background_alpha_)); 80 background_paint.setColor(background_color);
78 canvas->DrawRoundRect(bounds, kOverflowButtonCornerRadius, 81 canvas->DrawRoundRect(bounds, kOverflowButtonCornerRadius,
79 background_paint); 82 background_paint);
80 83
81 if (wm_shelf_->IsShowingOverflowBubble()) { 84 if (wm_shelf_->IsShowingOverflowBubble()) {
82 SkPaint highlight_paint; 85 SkPaint highlight_paint;
83 highlight_paint.setFlags(SkPaint::kAntiAlias_Flag); 86 highlight_paint.setFlags(SkPaint::kAntiAlias_Flag);
84 highlight_paint.setColor(kShelfButtonActivatedHighlightColor); 87 highlight_paint.setColor(kShelfButtonActivatedHighlightColor);
85 canvas->DrawRoundRect(bounds, kOverflowButtonCornerRadius, 88 canvas->DrawRoundRect(bounds, kOverflowButtonCornerRadius,
86 highlight_paint); 89 highlight_paint);
87 } 90 }
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
161 bounds = 164 bounds =
162 gfx::Rect(bounds.x() + (bounds.width() - background->width()) / 2, 165 gfx::Rect(bounds.x() + (bounds.width() - background->width()) / 2,
163 bounds.y() + kShelfItemInset, background->width(), 166 bounds.y() + kShelfItemInset, background->width(),
164 background->height()); 167 background->height());
165 } 168 }
166 } 169 }
167 return bounds; 170 return bounds;
168 } 171 }
169 172
170 } // namespace ash 173 } // namespace ash
OLDNEW
« no previous file with comments | « ash/common/shelf/overflow_button.h ('k') | ash/common/shelf/shelf_background_animator.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698