| 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 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 65 void CustomButton::SetAnimationDuration(int duration) { | 65 void CustomButton::SetAnimationDuration(int duration) { |
| 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 gfx::Screen::BadTwoWorldsContext())); |
| 76 ConvertPointToTarget(NULL, this, &cursor_pos); | 77 ConvertPointToTarget(NULL, this, &cursor_pos); |
| 77 return HitTestPoint(cursor_pos); | 78 return HitTestPoint(cursor_pos); |
| 78 } | 79 } |
| 79 | 80 |
| 80 void CustomButton::SetHotTracked(bool is_hot_tracked) { | 81 void CustomButton::SetHotTracked(bool is_hot_tracked) { |
| 81 if (state_ != BS_DISABLED) | 82 if (state_ != BS_DISABLED) |
| 82 SetState(is_hot_tracked ? BS_HOT : BS_NORMAL); | 83 SetState(is_hot_tracked ? BS_HOT : BS_NORMAL); |
| 83 | 84 |
| 84 if (is_hot_tracked && GetWidget()) { | 85 if (is_hot_tracked && GetWidget()) { |
| 85 GetWidget()->NotifyAccessibilityEvent( | 86 GetWidget()->NotifyAccessibilityEvent( |
| (...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 320 if (!is_add && state_ != BS_DISABLED) | 321 if (!is_add && state_ != BS_DISABLED) |
| 321 SetState(BS_NORMAL); | 322 SetState(BS_NORMAL); |
| 322 } | 323 } |
| 323 | 324 |
| 324 void CustomButton::OnBlur() { | 325 void CustomButton::OnBlur() { |
| 325 if (IsHotTracked()) | 326 if (IsHotTracked()) |
| 326 SetState(BS_NORMAL); | 327 SetState(BS_NORMAL); |
| 327 } | 328 } |
| 328 | 329 |
| 329 } // namespace views | 330 } // namespace views |
| OLD | NEW |