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

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

Issue 2033553003: Add MD ink drop ripple to shelf app items (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Removed TODO Created 4 years, 6 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/shelf/app_list_button.h ('k') | ash/shelf/ink_drop_button_listener.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/shelf/app_list_button.h" 5 #include "ash/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/shelf_constants.h" 9 #include "ash/common/shelf/shelf_constants.h"
10 #include "ash/common/shelf/shelf_item_types.h" 10 #include "ash/common/shelf/shelf_item_types.h"
11 #include "ash/common/shelf/shelf_types.h" 11 #include "ash/common/shelf/shelf_types.h"
12 #include "ash/common/shelf/wm_shelf_util.h" 12 #include "ash/common/shelf/wm_shelf_util.h"
13 #include "ash/shelf/ink_drop_button_listener.h"
13 #include "ash/shelf/shelf_layout_manager.h" 14 #include "ash/shelf/shelf_layout_manager.h"
14 #include "ash/shelf/shelf_view.h" 15 #include "ash/shelf/shelf_view.h"
15 #include "ash/shelf/shelf_widget.h" 16 #include "ash/shelf/shelf_widget.h"
16 #include "ash/shell.h" 17 #include "ash/shell.h"
17 #include "base/command_line.h" 18 #include "base/command_line.h"
18 #include "grit/ash_resources.h" 19 #include "grit/ash_resources.h"
19 #include "grit/ash_strings.h" 20 #include "grit/ash_strings.h"
20 #include "ui/accessibility/ax_view_state.h" 21 #include "ui/accessibility/ax_view_state.h"
21 #include "ui/app_list/app_list_switches.h" 22 #include "ui/app_list/app_list_switches.h"
22 #include "ui/base/l10n/l10n_util.h" 23 #include "ui/base/l10n/l10n_util.h"
23 #include "ui/base/resource/resource_bundle.h" 24 #include "ui/base/resource/resource_bundle.h"
24 #include "ui/base/ui_base_switches_util.h" 25 #include "ui/base/ui_base_switches_util.h"
25 #include "ui/gfx/canvas.h" 26 #include "ui/gfx/canvas.h"
26 #include "ui/gfx/paint_vector_icon.h" 27 #include "ui/gfx/paint_vector_icon.h"
27 #include "ui/gfx/vector_icons_public.h" 28 #include "ui/gfx/vector_icons_public.h"
28 #include "ui/views/painter.h" 29 #include "ui/views/painter.h"
29 30
30 namespace ash { 31 namespace ash {
31 32
32 // Radius of the app list button circular background. 33 // Radius of the app list button circular background.
33 const int kAppListButtonBackgroundRadius = 16; 34 const int kAppListButtonBackgroundRadius = 16;
34 35
35 AppListButton::AppListButton(ShelfView* shelf_view) 36 AppListButton::AppListButton(InkDropButtonListener* listener,
36 : views::ImageButton(shelf_view), 37 ShelfView* shelf_view)
38 : views::ImageButton(nullptr),
37 draw_background_as_active_(false), 39 draw_background_as_active_(false),
40 listener_(listener),
38 shelf_view_(shelf_view) { 41 shelf_view_(shelf_view) {
39 SetAccessibleName( 42 SetAccessibleName(
40 app_list::switches::IsExperimentalAppListEnabled() 43 app_list::switches::IsExperimentalAppListEnabled()
41 ? l10n_util::GetStringUTF16(IDS_ASH_SHELF_APP_LIST_LAUNCHER_TITLE) 44 ? l10n_util::GetStringUTF16(IDS_ASH_SHELF_APP_LIST_LAUNCHER_TITLE)
42 : l10n_util::GetStringUTF16(IDS_ASH_SHELF_APP_LIST_TITLE)); 45 : l10n_util::GetStringUTF16(IDS_ASH_SHELF_APP_LIST_TITLE));
43 SetSize( 46 SetSize(
44 gfx::Size(GetShelfConstant(SHELF_SIZE), GetShelfConstant(SHELF_SIZE))); 47 gfx::Size(GetShelfConstant(SHELF_SIZE), GetShelfConstant(SHELF_SIZE)));
45 SetFocusPainter(views::Painter::CreateSolidFocusPainter( 48 SetFocusPainter(views::Painter::CreateSolidFocusPainter(
46 kFocusBorderColor, gfx::Insets(1, 1, 1, 1))); 49 kFocusBorderColor, gfx::Insets(1, 1, 1, 1)));
47 set_notify_action(CustomButton::NOTIFY_ON_PRESS); 50 set_notify_action(CustomButton::NOTIFY_ON_PRESS);
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after
231 (background_bounds.height() - foreground_bounds.height()) / 2)); 234 (background_bounds.height() - foreground_bounds.height()) / 2));
232 canvas->DrawImageInt(foreground_image, foreground_bounds.x(), 235 canvas->DrawImageInt(foreground_image, foreground_bounds.x(),
233 foreground_bounds.y()); 236 foreground_bounds.y());
234 } 237 }
235 238
236 void AppListButton::GetAccessibleState(ui::AXViewState* state) { 239 void AppListButton::GetAccessibleState(ui::AXViewState* state) {
237 state->role = ui::AX_ROLE_BUTTON; 240 state->role = ui::AX_ROLE_BUTTON;
238 state->name = shelf_view_->GetTitleForView(this); 241 state->name = shelf_view_->GetTitleForView(this);
239 } 242 }
240 243
244 void AppListButton::NotifyClick(const ui::Event& event) {
245 ImageButton::NotifyClick(event);
246 if (listener_)
247 listener_->ButtonPressed(this, event, ink_drop());
248 }
249
241 void AppListButton::SetDrawBackgroundAsActive( 250 void AppListButton::SetDrawBackgroundAsActive(
242 bool draw_background_as_active) { 251 bool draw_background_as_active) {
243 if (draw_background_as_active_ == draw_background_as_active) 252 if (draw_background_as_active_ == draw_background_as_active)
244 return; 253 return;
245 draw_background_as_active_ = draw_background_as_active; 254 draw_background_as_active_ = draw_background_as_active;
246 SchedulePaint(); 255 SchedulePaint();
247 } 256 }
248 257
249 } // namespace ash 258 } // namespace ash
OLDNEW
« no previous file with comments | « ash/shelf/app_list_button.h ('k') | ash/shelf/ink_drop_button_listener.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698