| 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 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 77 gfx::Point cursor_pos(gfx::Screen::GetScreenFor( | 77 gfx::Point cursor_pos(gfx::Screen::GetScreenFor( |
| 78 GetWidget()->GetNativeView())->GetCursorScreenPoint()); | 78 GetWidget()->GetNativeView())->GetCursorScreenPoint()); |
| 79 ConvertPointToTarget(NULL, this, &cursor_pos); | 79 ConvertPointToTarget(NULL, this, &cursor_pos); |
| 80 return HitTestPoint(cursor_pos); | 80 return HitTestPoint(cursor_pos); |
| 81 } | 81 } |
| 82 | 82 |
| 83 void CustomButton::SetHotTracked(bool is_hot_tracked) { | 83 void CustomButton::SetHotTracked(bool is_hot_tracked) { |
| 84 if (state_ != STATE_DISABLED) | 84 if (state_ != STATE_DISABLED) |
| 85 SetState(is_hot_tracked ? STATE_HOVERED : STATE_NORMAL); | 85 SetState(is_hot_tracked ? STATE_HOVERED : STATE_NORMAL); |
| 86 | 86 |
| 87 if (is_hot_tracked && GetWidget()) { | 87 if (is_hot_tracked) |
| 88 GetWidget()->NotifyAccessibilityEvent( | 88 NotifyAccessibilityEvent(ui::AccessibilityTypes::EVENT_FOCUS, true); |
| 89 this, ui::AccessibilityTypes::EVENT_FOCUS, true); | |
| 90 } | |
| 91 } | 89 } |
| 92 | 90 |
| 93 bool CustomButton::IsHotTracked() const { | 91 bool CustomButton::IsHotTracked() const { |
| 94 return state_ == STATE_HOVERED; | 92 return state_ == STATE_HOVERED; |
| 95 } | 93 } |
| 96 | 94 |
| 97 //////////////////////////////////////////////////////////////////////////////// | 95 //////////////////////////////////////////////////////////////////////////////// |
| 98 // CustomButton, View overrides: | 96 // CustomButton, View overrides: |
| 99 | 97 |
| 100 void CustomButton::OnEnabledChanged() { | 98 void CustomButton::OnEnabledChanged() { |
| (...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 333 if (!is_add && state_ != STATE_DISABLED) | 331 if (!is_add && state_ != STATE_DISABLED) |
| 334 SetState(STATE_NORMAL); | 332 SetState(STATE_NORMAL); |
| 335 } | 333 } |
| 336 | 334 |
| 337 void CustomButton::OnBlur() { | 335 void CustomButton::OnBlur() { |
| 338 if (IsHotTracked()) | 336 if (IsHotTracked()) |
| 339 SetState(STATE_NORMAL); | 337 SetState(STATE_NORMAL); |
| 340 } | 338 } |
| 341 | 339 |
| 342 } // namespace views | 340 } // namespace views |
| OLD | NEW |