| 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 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 67 void CustomButton::SetAnimationDuration(int duration) { | 67 void CustomButton::SetAnimationDuration(int duration) { |
| 68 hover_animation_->SetSlideDuration(duration); | 68 hover_animation_->SetSlideDuration(duration); |
| 69 } | 69 } |
| 70 | 70 |
| 71 bool CustomButton::IsMouseHovered() const { | 71 bool CustomButton::IsMouseHovered() const { |
| 72 // If we haven't yet been placed in an onscreen view hierarchy, we can't be | 72 // If we haven't yet been placed in an onscreen view hierarchy, we can't be |
| 73 // hovered. | 73 // hovered. |
| 74 if (!GetWidget()) | 74 if (!GetWidget()) |
| 75 return false; | 75 return false; |
| 76 | 76 |
| 77 gfx::Point cursor_pos(gfx::Screen::GetCursorScreenPoint()); | 77 gfx::Point cursor_pos(gfx::Screen::GetScreenFor( |
| 78 GetWidget()->GetNativeView())->GetCursorScreenPoint()); |
| 78 ConvertPointToTarget(NULL, this, &cursor_pos); | 79 ConvertPointToTarget(NULL, this, &cursor_pos); |
| 79 return HitTestPoint(cursor_pos); | 80 return HitTestPoint(cursor_pos); |
| 80 } | 81 } |
| 81 | 82 |
| 82 void CustomButton::SetHotTracked(bool is_hot_tracked) { | 83 void CustomButton::SetHotTracked(bool is_hot_tracked) { |
| 83 if (state_ != BS_DISABLED) | 84 if (state_ != BS_DISABLED) |
| 84 SetState(is_hot_tracked ? BS_HOT : BS_NORMAL); | 85 SetState(is_hot_tracked ? BS_HOT : BS_NORMAL); |
| 85 | 86 |
| 86 if (is_hot_tracked && GetWidget()) { | 87 if (is_hot_tracked && GetWidget()) { |
| 87 GetWidget()->NotifyAccessibilityEvent( | 88 GetWidget()->NotifyAccessibilityEvent( |
| (...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 322 if (!is_add && state_ != BS_DISABLED) | 323 if (!is_add && state_ != BS_DISABLED) |
| 323 SetState(BS_NORMAL); | 324 SetState(BS_NORMAL); |
| 324 } | 325 } |
| 325 | 326 |
| 326 void CustomButton::OnBlur() { | 327 void CustomButton::OnBlur() { |
| 327 if (IsHotTracked()) | 328 if (IsHotTracked()) |
| 328 SetState(BS_NORMAL); | 329 SetState(BS_NORMAL); |
| 329 } | 330 } |
| 330 | 331 |
| 331 } // namespace views | 332 } // namespace views |
| OLD | NEW |