OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "ui/views/controls/button/custom_button.h" | 5 #include "ui/views/controls/button/custom_button.h" |
6 | 6 |
7 #include "ui/base/accessibility/accessible_view_state.h" | 7 #include "ui/base/accessibility/accessible_view_state.h" |
8 #include "ui/base/animation/throb_animation.h" | 8 #include "ui/base/animation/throb_animation.h" |
9 #include "ui/base/events/event.h" | 9 #include "ui/base/events/event.h" |
10 #include "ui/base/keycodes/keyboard_codes.h" | 10 #include "ui/base/keycodes/keyboard_codes.h" |
(...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
240 */ | 240 */ |
241 // TODO(beng): remove once NotifyClick takes ui::Event. | 241 // TODO(beng): remove once NotifyClick takes ui::Event. |
242 ui::MouseEvent synthetic_event(ui::ET_MOUSE_RELEASED, | 242 ui::MouseEvent synthetic_event(ui::ET_MOUSE_RELEASED, |
243 gfx::Point(), | 243 gfx::Point(), |
244 gfx::Point(), | 244 gfx::Point(), |
245 ui::EF_LEFT_MOUSE_BUTTON); | 245 ui::EF_LEFT_MOUSE_BUTTON); |
246 NotifyClick(synthetic_event); | 246 NotifyClick(synthetic_event); |
247 return true; | 247 return true; |
248 } | 248 } |
249 | 249 |
250 void CustomButton::ShowContextMenu(const gfx::Point& p, bool is_mouse_gesture) { | 250 void CustomButton::ShowContextMenu(const gfx::Point& p, |
| 251 ui::MenuSourceType source_type) { |
251 if (!context_menu_controller()) | 252 if (!context_menu_controller()) |
252 return; | 253 return; |
253 | 254 |
254 // We're about to show the context menu. Showing the context menu likely means | 255 // We're about to show the context menu. Showing the context menu likely means |
255 // we won't get a mouse exited and reset state. Reset it now to be sure. | 256 // we won't get a mouse exited and reset state. Reset it now to be sure. |
256 if (state_ != STATE_DISABLED) | 257 if (state_ != STATE_DISABLED) |
257 SetState(STATE_NORMAL); | 258 SetState(STATE_NORMAL); |
258 View::ShowContextMenu(p, is_mouse_gesture); | 259 View::ShowContextMenu(p, source_type); |
259 } | 260 } |
260 | 261 |
261 void CustomButton::OnDragDone() { | 262 void CustomButton::OnDragDone() { |
262 SetState(STATE_NORMAL); | 263 SetState(STATE_NORMAL); |
263 } | 264 } |
264 | 265 |
265 void CustomButton::GetAccessibleState(ui::AccessibleViewState* state) { | 266 void CustomButton::GetAccessibleState(ui::AccessibleViewState* state) { |
266 Button::GetAccessibleState(state); | 267 Button::GetAccessibleState(state); |
267 switch (state_) { | 268 switch (state_) { |
268 case STATE_HOVERED: | 269 case STATE_HOVERED: |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
330 if (!details.is_add && state_ != STATE_DISABLED) | 331 if (!details.is_add && state_ != STATE_DISABLED) |
331 SetState(STATE_NORMAL); | 332 SetState(STATE_NORMAL); |
332 } | 333 } |
333 | 334 |
334 void CustomButton::OnBlur() { | 335 void CustomButton::OnBlur() { |
335 if (IsHotTracked()) | 336 if (IsHotTracked()) |
336 SetState(STATE_NORMAL); | 337 SetState(STATE_NORMAL); |
337 } | 338 } |
338 | 339 |
339 } // namespace views | 340 } // namespace views |
OLD | NEW |