Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(45)

Side by Side Diff: ui/views/controls/button/custom_button.cc

Issue 11030017: Add context to gfx::Screen calls in support of simultaneous desktop+ash (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: tidy Created 8 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
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
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
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698