OLD | NEW |
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 "chrome/browser/ui/views/toolbar/toolbar_button.h" | 5 #include "chrome/browser/ui/views/toolbar/toolbar_button.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/location.h" | 8 #include "base/location.h" |
9 #include "base/single_thread_task_runner.h" | 9 #include "base/single_thread_task_runner.h" |
10 #include "base/thread_task_runner_handle.h" | 10 #include "base/thread_task_runner_handle.h" |
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
182 switch (event->type()) { | 182 switch (event->type()) { |
183 case ui::ET_GESTURE_TAP_DOWN: | 183 case ui::ET_GESTURE_TAP_DOWN: |
184 ink_drop_state = views::InkDropState::ACTION_PENDING; | 184 ink_drop_state = views::InkDropState::ACTION_PENDING; |
185 // The ui::ET_GESTURE_TAP_DOWN event needs to be marked as handled so that | 185 // The ui::ET_GESTURE_TAP_DOWN event needs to be marked as handled so that |
186 // subsequent events for the gesture are sent to |this|. | 186 // subsequent events for the gesture are sent to |this|. |
187 event->SetHandled(); | 187 event->SetHandled(); |
188 break; | 188 break; |
189 case ui::ET_GESTURE_LONG_PRESS: | 189 case ui::ET_GESTURE_LONG_PRESS: |
190 ink_drop_state = views::InkDropState::SLOW_ACTION_PENDING; | 190 ink_drop_state = views::InkDropState::SLOW_ACTION_PENDING; |
191 break; | 191 break; |
192 case ui::ET_GESTURE_TAP: | |
193 ink_drop_state = views::InkDropState::QUICK_ACTION; | |
194 break; | |
195 case ui::ET_GESTURE_LONG_TAP: | 192 case ui::ET_GESTURE_LONG_TAP: |
196 ink_drop_state = views::InkDropState::SLOW_ACTION; | 193 ink_drop_state = views::InkDropState::SLOW_ACTION; |
197 break; | 194 break; |
| 195 case ui::ET_GESTURE_SCROLL_BEGIN: |
198 case ui::ET_GESTURE_END: | 196 case ui::ET_GESTURE_END: |
199 case ui::ET_GESTURE_TAP_CANCEL: | |
200 ink_drop_state = views::InkDropState::HIDDEN; | 197 ink_drop_state = views::InkDropState::HIDDEN; |
201 break; | 198 break; |
202 default: | 199 default: |
203 return; | 200 return; |
204 } | 201 } |
| 202 |
| 203 if (ink_drop_animation_controller_->WillAutoAnimateToHidden()) { |
| 204 // Some InkDropStates automatically transition to the HIDDEN state so we |
| 205 // don't make an explicit call. Explicitly animating to HIDDEN in this case |
| 206 // would prematurely pre-empt these animations. |
| 207 return; |
| 208 } |
205 ink_drop_animation_controller_->AnimateToState(ink_drop_state); | 209 ink_drop_animation_controller_->AnimateToState(ink_drop_state); |
206 } | 210 } |
207 | 211 |
208 void ToolbarButton::GetAccessibleState(ui::AXViewState* state) { | 212 void ToolbarButton::GetAccessibleState(ui::AXViewState* state) { |
209 CustomButton::GetAccessibleState(state); | 213 CustomButton::GetAccessibleState(state); |
210 state->role = ui::AX_ROLE_BUTTON_DROP_DOWN; | 214 state->role = ui::AX_ROLE_BUTTON_DROP_DOWN; |
211 state->default_action = l10n_util::GetStringUTF16(IDS_APP_ACCACTION_PRESS); | 215 state->default_action = l10n_util::GetStringUTF16(IDS_APP_ACCACTION_PRESS); |
212 state->AddStateFlag(ui::AX_STATE_HASPOPUP); | 216 state->AddStateFlag(ui::AX_STATE_HASPOPUP); |
213 } | 217 } |
214 | 218 |
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
360 return GetLocalBounds().CenterPoint(); | 364 return GetLocalBounds().CenterPoint(); |
361 } | 365 } |
362 | 366 |
363 void ToolbarButton::UpdateInkDropHoverState() { | 367 void ToolbarButton::UpdateInkDropHoverState() { |
364 ink_drop_animation_controller_->SetHovered(enabled() && IsMouseHovered()); | 368 ink_drop_animation_controller_->SetHovered(enabled() && IsMouseHovered()); |
365 } | 369 } |
366 | 370 |
367 const char* ToolbarButton::GetClassName() const { | 371 const char* ToolbarButton::GetClassName() const { |
368 return "ToolbarButton"; | 372 return "ToolbarButton"; |
369 } | 373 } |
OLD | NEW |