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

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

Issue 2053113002: Replaced BackgroundAnimator with ShelfBackgroundAnimator. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Merge branch 'master' into animate_shelf_chip_backgrounds 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/app_list_button.h ('k') | ash/common/shelf/overflow_button.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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/app_list_button.h" 5 #include "ash/common/shelf/app_list_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 17 matching lines...) Expand all
28 #include "ui/views/animation/square_ink_drop_ripple.h" 28 #include "ui/views/animation/square_ink_drop_ripple.h"
29 #include "ui/views/painter.h" 29 #include "ui/views/painter.h"
30 30
31 namespace ash { 31 namespace ash {
32 32
33 AppListButton::AppListButton(InkDropButtonListener* listener, 33 AppListButton::AppListButton(InkDropButtonListener* listener,
34 ShelfView* shelf_view, 34 ShelfView* shelf_view,
35 WmShelf* wm_shelf) 35 WmShelf* wm_shelf)
36 : views::ImageButton(nullptr), 36 : views::ImageButton(nullptr),
37 draw_background_as_active_(false), 37 draw_background_as_active_(false),
38 background_alpha_(0),
38 listener_(listener), 39 listener_(listener),
39 shelf_view_(shelf_view), 40 shelf_view_(shelf_view),
40 wm_shelf_(wm_shelf) { 41 wm_shelf_(wm_shelf) {
41 DCHECK(listener_); 42 DCHECK(listener_);
42 DCHECK(shelf_view_); 43 DCHECK(shelf_view_);
43 DCHECK(wm_shelf_); 44 DCHECK(wm_shelf_);
44 if (ash::MaterialDesignController::IsShelfMaterial()) { 45 if (ash::MaterialDesignController::IsShelfMaterial()) {
45 SetInkDropMode(InkDropMode::ON_NO_GESTURE_HANDLER); 46 SetInkDropMode(InkDropMode::ON_NO_GESTURE_HANDLER);
46 set_ink_drop_base_color(kShelfInkDropBaseColor); 47 set_ink_drop_base_color(kShelfInkDropBaseColor);
47 set_ink_drop_visible_opacity(kShelfInkDropVisibleOpacity); 48 set_ink_drop_visible_opacity(kShelfInkDropVisibleOpacity);
(...skipping 18 matching lines...) Expand all
66 SchedulePaint(); 67 SchedulePaint();
67 } 68 }
68 69
69 void AppListButton::OnAppListDismissed() { 70 void AppListButton::OnAppListDismissed() {
70 if (ash::MaterialDesignController::IsShelfMaterial()) 71 if (ash::MaterialDesignController::IsShelfMaterial())
71 AnimateInkDrop(views::InkDropState::DEACTIVATED, nullptr); 72 AnimateInkDrop(views::InkDropState::DEACTIVATED, nullptr);
72 else 73 else
73 SchedulePaint(); 74 SchedulePaint();
74 } 75 }
75 76
77 void AppListButton::SetBackgroundAlpha(int alpha) {
78 background_alpha_ = alpha;
79 SchedulePaint();
80 }
81
76 bool AppListButton::OnMousePressed(const ui::MouseEvent& event) { 82 bool AppListButton::OnMousePressed(const ui::MouseEvent& event) {
77 ImageButton::OnMousePressed(event); 83 ImageButton::OnMousePressed(event);
78 shelf_view_->PointerPressedOnButton(this, ShelfView::MOUSE, event); 84 shelf_view_->PointerPressedOnButton(this, ShelfView::MOUSE, event);
79 return true; 85 return true;
80 } 86 }
81 87
82 void AppListButton::OnMouseReleased(const ui::MouseEvent& event) { 88 void AppListButton::OnMouseReleased(const ui::MouseEvent& event) {
83 ImageButton::OnMouseReleased(event); 89 ImageButton::OnMouseReleased(event);
84 shelf_view_->PointerReleasedOnButton(this, ShelfView::MOUSE, false); 90 shelf_view_->PointerReleasedOnButton(this, ShelfView::MOUSE, false);
85 } 91 }
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
150 PaintBackgroundMD(canvas); 156 PaintBackgroundMD(canvas);
151 PaintForegroundMD(canvas, foreground_image); 157 PaintForegroundMD(canvas, foreground_image);
152 } else { 158 } else {
153 PaintAppListButton(canvas, foreground_image); 159 PaintAppListButton(canvas, foreground_image);
154 } 160 }
155 161
156 views::Painter::PaintFocusPainter(this, canvas, focus_painter()); 162 views::Painter::PaintFocusPainter(this, canvas, focus_painter());
157 } 163 }
158 164
159 void AppListButton::PaintBackgroundMD(gfx::Canvas* canvas) { 165 void AppListButton::PaintBackgroundMD(gfx::Canvas* canvas) {
160 SkPaint background_paint;
161 background_paint.setColor(SK_ColorTRANSPARENT);
162 background_paint.setFlags(SkPaint::kAntiAlias_Flag);
163 background_paint.setStyle(SkPaint::kFill_Style);
164
165 if (wm_shelf_->GetBackgroundType() ==
166 ShelfBackgroundType::SHELF_BACKGROUND_DEFAULT) {
167 background_paint.setColor(
168 SkColorSetA(kShelfBaseColor, GetShelfConstant(SHELF_BACKGROUND_ALPHA)));
169 }
170
171 // Paint the circular background of AppList button. 166 // Paint the circular background of AppList button.
172 gfx::Point circle_center = GetContentsBounds().CenterPoint(); 167 gfx::Point circle_center = GetContentsBounds().CenterPoint();
173 if (!IsHorizontalAlignment(wm_shelf_->GetAlignment())) 168 if (!IsHorizontalAlignment(wm_shelf_->GetAlignment()))
174 circle_center = gfx::Point(circle_center.y(), circle_center.x()); 169 circle_center = gfx::Point(circle_center.y(), circle_center.x());
175 170
171 SkPaint background_paint;
172 background_paint.setColor(SkColorSetA(kShelfBaseColor, background_alpha_));
173 background_paint.setFlags(SkPaint::kAntiAlias_Flag);
174 background_paint.setStyle(SkPaint::kFill_Style);
175
176 canvas->DrawCircle(circle_center, kAppListButtonRadius, background_paint); 176 canvas->DrawCircle(circle_center, kAppListButtonRadius, background_paint);
177 } 177 }
178 178
179 void AppListButton::PaintForegroundMD(gfx::Canvas* canvas, 179 void AppListButton::PaintForegroundMD(gfx::Canvas* canvas,
180 const gfx::ImageSkia& foreground_image) { 180 const gfx::ImageSkia& foreground_image) {
181 gfx::Rect foreground_bounds(foreground_image.size()); 181 gfx::Rect foreground_bounds(foreground_image.size());
182 gfx::Rect contents_bounds = GetContentsBounds(); 182 gfx::Rect contents_bounds = GetContentsBounds();
183 183
184 if (IsHorizontalAlignment(wm_shelf_->GetAlignment())) { 184 if (IsHorizontalAlignment(wm_shelf_->GetAlignment())) {
185 foreground_bounds.set_x( 185 foreground_bounds.set_x(
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
287 } 287 }
288 288
289 void AppListButton::SetDrawBackgroundAsActive(bool draw_background_as_active) { 289 void AppListButton::SetDrawBackgroundAsActive(bool draw_background_as_active) {
290 if (draw_background_as_active_ == draw_background_as_active) 290 if (draw_background_as_active_ == draw_background_as_active)
291 return; 291 return;
292 draw_background_as_active_ = draw_background_as_active; 292 draw_background_as_active_ = draw_background_as_active;
293 SchedulePaint(); 293 SchedulePaint();
294 } 294 }
295 295
296 } // namespace ash 296 } // namespace ash
OLDNEW
« no previous file with comments | « ash/common/shelf/app_list_button.h ('k') | ash/common/shelf/overflow_button.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698