| 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/accessibility/ax_view_state.h" | 7 #include "ui/accessibility/ax_view_state.h" |
| 8 #include "ui/events/event.h" | 8 #include "ui/events/event.h" |
| 9 #include "ui/events/event_utils.h" | 9 #include "ui/events/event_utils.h" |
| 10 #include "ui/events/keycodes/keyboard_codes.h" | 10 #include "ui/events/keycodes/keyboard_codes.h" |
| (...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 243 event->type() == ui::ET_GESTURE_END) { | 243 event->type() == ui::ET_GESTURE_END) { |
| 244 SetState(STATE_NORMAL); | 244 SetState(STATE_NORMAL); |
| 245 } | 245 } |
| 246 if (!event->handled()) | 246 if (!event->handled()) |
| 247 Button::OnGestureEvent(event); | 247 Button::OnGestureEvent(event); |
| 248 } | 248 } |
| 249 | 249 |
| 250 bool CustomButton::AcceleratorPressed(const ui::Accelerator& accelerator) { | 250 bool CustomButton::AcceleratorPressed(const ui::Accelerator& accelerator) { |
| 251 SetState(STATE_NORMAL); | 251 SetState(STATE_NORMAL); |
| 252 // TODO(beng): remove once NotifyClick takes ui::Event. | 252 // TODO(beng): remove once NotifyClick takes ui::Event. |
| 253 ui::MouseEvent synthetic_event( | 253 ui::MouseEvent synthetic_event(ui::ET_MOUSE_RELEASED, gfx::PointF(), |
| 254 ui::ET_MOUSE_RELEASED, gfx::Point(), gfx::Point(), ui::EventTimeForNow(), | 254 gfx::PointF(), ui::EventTimeForNow(), |
| 255 ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON); | 255 ui::EF_LEFT_MOUSE_BUTTON, |
| 256 ui::EF_LEFT_MOUSE_BUTTON); |
| 256 NotifyClick(synthetic_event); | 257 NotifyClick(synthetic_event); |
| 257 return true; | 258 return true; |
| 258 } | 259 } |
| 259 | 260 |
| 260 void CustomButton::ShowContextMenu(const gfx::Point& p, | 261 void CustomButton::ShowContextMenu(const gfx::Point& p, |
| 261 ui::MenuSourceType source_type) { | 262 ui::MenuSourceType source_type) { |
| 262 if (!context_menu_controller()) | 263 if (!context_menu_controller()) |
| 263 return; | 264 return; |
| 264 | 265 |
| 265 // We're about to show the context menu. Showing the context menu likely means | 266 // We're about to show the context menu. Showing the context menu likely means |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 369 if (!details.is_add && state_ != STATE_DISABLED) | 370 if (!details.is_add && state_ != STATE_DISABLED) |
| 370 SetState(STATE_NORMAL); | 371 SetState(STATE_NORMAL); |
| 371 } | 372 } |
| 372 | 373 |
| 373 void CustomButton::OnBlur() { | 374 void CustomButton::OnBlur() { |
| 374 if (IsHotTracked()) | 375 if (IsHotTracked()) |
| 375 SetState(STATE_NORMAL); | 376 SetState(STATE_NORMAL); |
| 376 } | 377 } |
| 377 | 378 |
| 378 } // namespace views | 379 } // namespace views |
| OLD | NEW |