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

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

Issue 2095193002: clang-format all of //ash (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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/screenshot_delegate.h ('k') | ash/shelf/app_list_shelf_item_delegate.cc » ('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"
(...skipping 28 matching lines...) Expand all
39 draw_background_as_active_(false), 39 draw_background_as_active_(false),
40 listener_(listener), 40 listener_(listener),
41 shelf_view_(shelf_view) { 41 shelf_view_(shelf_view) {
42 SetAccessibleName( 42 SetAccessibleName(
43 app_list::switches::IsExperimentalAppListEnabled() 43 app_list::switches::IsExperimentalAppListEnabled()
44 ? l10n_util::GetStringUTF16(IDS_ASH_SHELF_APP_LIST_LAUNCHER_TITLE) 44 ? l10n_util::GetStringUTF16(IDS_ASH_SHELF_APP_LIST_LAUNCHER_TITLE)
45 : l10n_util::GetStringUTF16(IDS_ASH_SHELF_APP_LIST_TITLE)); 45 : l10n_util::GetStringUTF16(IDS_ASH_SHELF_APP_LIST_TITLE));
46 SetSize( 46 SetSize(
47 gfx::Size(GetShelfConstant(SHELF_SIZE), GetShelfConstant(SHELF_SIZE))); 47 gfx::Size(GetShelfConstant(SHELF_SIZE), GetShelfConstant(SHELF_SIZE)));
48 SetFocusPainter(views::Painter::CreateSolidFocusPainter( 48 SetFocusPainter(views::Painter::CreateSolidFocusPainter(
49 kFocusBorderColor, gfx::Insets(1, 1, 1, 1))); 49 kFocusBorderColor, gfx::Insets(1, 1, 1, 1)));
50 set_notify_action(CustomButton::NOTIFY_ON_PRESS); 50 set_notify_action(CustomButton::NOTIFY_ON_PRESS);
51 } 51 }
52 52
53 AppListButton::~AppListButton() {} 53 AppListButton::~AppListButton() {}
54 54
55 bool AppListButton::OnMousePressed(const ui::MouseEvent& event) { 55 bool AppListButton::OnMousePressed(const ui::MouseEvent& event) {
56 ImageButton::OnMousePressed(event); 56 ImageButton::OnMousePressed(event);
57 shelf_view_->PointerPressedOnButton(this, ShelfView::MOUSE, event); 57 shelf_view_->PointerPressedOnButton(this, ShelfView::MOUSE, event);
58 return true; 58 return true;
59 } 59 }
60 60
61 void AppListButton::OnMouseReleased(const ui::MouseEvent& event) { 61 void AppListButton::OnMouseReleased(const ui::MouseEvent& event) {
62 ImageButton::OnMouseReleased(event); 62 ImageButton::OnMouseReleased(event);
63 shelf_view_->PointerReleasedOnButton(this, ShelfView::MOUSE, false); 63 shelf_view_->PointerReleasedOnButton(this, ShelfView::MOUSE, false);
64 } 64 }
65 65
66 void AppListButton::OnMouseCaptureLost() { 66 void AppListButton::OnMouseCaptureLost() {
67 shelf_view_->PointerReleasedOnButton(this, ShelfView::MOUSE, true); 67 shelf_view_->PointerReleasedOnButton(this, ShelfView::MOUSE, true);
68 ImageButton::OnMouseCaptureLost(); 68 ImageButton::OnMouseCaptureLost();
69 } 69 }
70 70
71 bool AppListButton::OnMouseDragged(const ui::MouseEvent& event) { 71 bool AppListButton::OnMouseDragged(const ui::MouseEvent& event) {
72 ImageButton::OnMouseDragged(event); 72 ImageButton::OnMouseDragged(event);
73 shelf_view_->PointerDraggedOnButton(this, ShelfView::MOUSE, event); 73 shelf_view_->PointerDraggedOnButton(this, ShelfView::MOUSE, event);
74 return true; 74 return true;
75 } 75 }
76 76
77 void AppListButton::OnGestureEvent(ui::GestureEvent* event) { 77 void AppListButton::OnGestureEvent(ui::GestureEvent* event) {
78 switch (event->type()) { 78 switch (event->type()) {
79 case ui::ET_GESTURE_SCROLL_BEGIN: 79 case ui::ET_GESTURE_SCROLL_BEGIN:
80 if (switches::IsTouchFeedbackEnabled()) 80 if (switches::IsTouchFeedbackEnabled())
81 SetDrawBackgroundAsActive(false); 81 SetDrawBackgroundAsActive(false);
82 shelf_view_->PointerPressedOnButton(this, ShelfView::TOUCH, *event); 82 shelf_view_->PointerPressedOnButton(this, ShelfView::TOUCH, *event);
83 event->SetHandled(); 83 event->SetHandled();
84 return; 84 return;
85 case ui::ET_GESTURE_SCROLL_UPDATE: 85 case ui::ET_GESTURE_SCROLL_UPDATE:
86 shelf_view_->PointerDraggedOnButton(this, ShelfView::TOUCH, *event); 86 shelf_view_->PointerDraggedOnButton(this, ShelfView::TOUCH, *event);
87 event->SetHandled(); 87 event->SetHandled();
88 return; 88 return;
89 case ui::ET_GESTURE_SCROLL_END: 89 case ui::ET_GESTURE_SCROLL_END:
90 case ui::ET_SCROLL_FLING_START: 90 case ui::ET_SCROLL_FLING_START:
91 shelf_view_->PointerReleasedOnButton(this, ShelfView::TOUCH, false); 91 shelf_view_->PointerReleasedOnButton(this, ShelfView::TOUCH, false);
92 event->SetHandled(); 92 event->SetHandled();
93 return; 93 return;
94 case ui::ET_GESTURE_TAP_DOWN: 94 case ui::ET_GESTURE_TAP_DOWN:
95 if (switches::IsTouchFeedbackEnabled()) 95 if (switches::IsTouchFeedbackEnabled())
96 SetDrawBackgroundAsActive(true); 96 SetDrawBackgroundAsActive(true);
97 ImageButton::OnGestureEvent(event); 97 ImageButton::OnGestureEvent(event);
98 break; 98 break;
99 case ui::ET_GESTURE_TAP_CANCEL: 99 case ui::ET_GESTURE_TAP_CANCEL:
100 case ui::ET_GESTURE_TAP: 100 case ui::ET_GESTURE_TAP:
101 if (switches::IsTouchFeedbackEnabled()) 101 if (switches::IsTouchFeedbackEnabled())
102 SetDrawBackgroundAsActive(false); 102 SetDrawBackgroundAsActive(false);
103 ImageButton::OnGestureEvent(event); 103 ImageButton::OnGestureEvent(event);
104 break; 104 break;
105 default: 105 default:
106 ImageButton::OnGestureEvent(event); 106 ImageButton::OnGestureEvent(event);
107 return; 107 return;
108 } 108 }
109 } 109 }
110 110
111 void AppListButton::OnPaint(gfx::Canvas* canvas) { 111 void AppListButton::OnPaint(gfx::Canvas* canvas) {
112 // Call the base class first to paint any background/borders. 112 // Call the base class first to paint any background/borders.
113 View::OnPaint(canvas); 113 View::OnPaint(canvas);
114 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); 114 ResourceBundle& rb = ResourceBundle::GetSharedInstance();
115 115
116 const gfx::ImageSkia& foreground_image = 116 const gfx::ImageSkia& foreground_image =
117 MaterialDesignController::IsShelfMaterial() 117 MaterialDesignController::IsShelfMaterial()
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
240 state->role = ui::AX_ROLE_BUTTON; 240 state->role = ui::AX_ROLE_BUTTON;
241 state->name = shelf_view_->GetTitleForView(this); 241 state->name = shelf_view_->GetTitleForView(this);
242 } 242 }
243 243
244 void AppListButton::NotifyClick(const ui::Event& event) { 244 void AppListButton::NotifyClick(const ui::Event& event) {
245 ImageButton::NotifyClick(event); 245 ImageButton::NotifyClick(event);
246 if (listener_) 246 if (listener_)
247 listener_->ButtonPressed(this, event, ink_drop()); 247 listener_->ButtonPressed(this, event, ink_drop());
248 } 248 }
249 249
250 void AppListButton::SetDrawBackgroundAsActive( 250 void AppListButton::SetDrawBackgroundAsActive(bool draw_background_as_active) {
251 bool draw_background_as_active) {
252 if (draw_background_as_active_ == draw_background_as_active) 251 if (draw_background_as_active_ == draw_background_as_active)
253 return; 252 return;
254 draw_background_as_active_ = draw_background_as_active; 253 draw_background_as_active_ = draw_background_as_active;
255 SchedulePaint(); 254 SchedulePaint();
256 } 255 }
257 256
258 } // namespace ash 257 } // namespace ash
OLDNEW
« no previous file with comments | « ash/screenshot_delegate.h ('k') | ash/shelf/app_list_shelf_item_delegate.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698