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/event.h" | 9 #include "ui/base/event.h" |
10 #include "ui/base/keycodes/keyboard_codes.h" | 10 #include "ui/base/keycodes/keyboard_codes.h" |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
66 hover_animation_->SetSlideDuration(duration); | 66 hover_animation_->SetSlideDuration(duration); |
67 } | 67 } |
68 | 68 |
69 bool CustomButton::IsMouseHovered() const { | 69 bool CustomButton::IsMouseHovered() const { |
70 // If we haven't yet been placed in an onscreen view hierarchy, we can't be | 70 // If we haven't yet been placed in an onscreen view hierarchy, we can't be |
71 // hovered. | 71 // hovered. |
72 if (!GetWidget()) | 72 if (!GetWidget()) |
73 return false; | 73 return false; |
74 | 74 |
75 gfx::Point cursor_pos(gfx::Screen::GetCursorScreenPoint()); | 75 gfx::Point cursor_pos(gfx::Screen::GetCursorScreenPoint()); |
76 ConvertPointToView(NULL, this, &cursor_pos); | 76 ConvertPointToTarget(NULL, this, &cursor_pos); |
77 return HitTestPoint(cursor_pos); | 77 return HitTestPoint(cursor_pos); |
78 } | 78 } |
79 | 79 |
80 void CustomButton::SetHotTracked(bool is_hot_tracked) { | 80 void CustomButton::SetHotTracked(bool is_hot_tracked) { |
81 if (state_ != BS_DISABLED) | 81 if (state_ != BS_DISABLED) |
82 SetState(is_hot_tracked ? BS_HOT : BS_NORMAL); | 82 SetState(is_hot_tracked ? BS_HOT : BS_NORMAL); |
83 | 83 |
84 if (is_hot_tracked && GetWidget()) { | 84 if (is_hot_tracked && GetWidget()) { |
85 GetWidget()->NotifyAccessibilityEvent( | 85 GetWidget()->NotifyAccessibilityEvent( |
86 this, ui::AccessibilityTypes::EVENT_FOCUS, true); | 86 this, ui::AccessibilityTypes::EVENT_FOCUS, true); |
(...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
314 if (!is_add && state_ != BS_DISABLED) | 314 if (!is_add && state_ != BS_DISABLED) |
315 SetState(BS_NORMAL); | 315 SetState(BS_NORMAL); |
316 } | 316 } |
317 | 317 |
318 void CustomButton::OnBlur() { | 318 void CustomButton::OnBlur() { |
319 if (IsHotTracked()) | 319 if (IsHotTracked()) |
320 SetState(BS_NORMAL); | 320 SetState(BS_NORMAL); |
321 } | 321 } |
322 | 322 |
323 } // namespace views | 323 } // namespace views |
OLD | NEW |