OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "base/logging.h" | 5 #include "base/logging.h" |
6 #include "ui/aura/client/aura_constants.h" | 6 #include "ui/aura/client/aura_constants.h" |
7 #include "ui/aura/client/tooltip_client.h" | 7 #include "ui/aura/client/tooltip_client.h" |
8 #include "ui/aura/desktop.h" | 8 #include "ui/aura/desktop.h" |
9 #include "ui/base/resource/resource_bundle.h" | 9 #include "ui/base/resource/resource_bundle.h" |
10 #include "ui/gfx/font.h" | 10 #include "ui/gfx/font.h" |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
43 | 43 |
44 TooltipManagerAura::~TooltipManagerAura() { | 44 TooltipManagerAura::~TooltipManagerAura() { |
45 native_widget_aura_->GetNativeView()->SetProperty(aura::kTooltipTextKey, | 45 native_widget_aura_->GetNativeView()->SetProperty(aura::kTooltipTextKey, |
46 NULL); | 46 NULL); |
47 } | 47 } |
48 | 48 |
49 //////////////////////////////////////////////////////////////////////////////// | 49 //////////////////////////////////////////////////////////////////////////////// |
50 // TooltipManagerAura, TooltipManager implementation: | 50 // TooltipManagerAura, TooltipManager implementation: |
51 | 51 |
52 void TooltipManagerAura::UpdateTooltip() { | 52 void TooltipManagerAura::UpdateTooltip() { |
53 void* property = aura::Desktop::GetInstance()->GetProperty( | 53 gfx::Point view_point = aura::Desktop::GetInstance()->last_mouse_location(); |
54 aura::kDesktopTooltipClientKey); | 54 aura::Window::ConvertPointToWindow(aura::Desktop::GetInstance(), |
55 if (property) { | 55 native_widget_aura_->GetNativeView(), &view_point); |
56 gfx::Point view_point = aura::Desktop::GetInstance()->last_mouse_location(); | 56 View* view = GetViewUnderPoint(view_point); |
57 aura::Window::ConvertPointToWindow(aura::Desktop::GetInstance(), | 57 if (view) { |
58 native_widget_aura_->GetNativeView(), &view_point); | 58 View::ConvertPointFromWidget(view, &view_point); |
59 View* view = GetViewUnderPoint(view_point); | 59 if (!view->GetTooltipText(view_point, &tooltip_text_)) |
60 if (view) { | 60 tooltip_text_.clear(); |
61 View::ConvertPointFromWidget(view, &view_point); | 61 } else { |
62 if (!view->GetTooltipText(view_point, &tooltip_text_)) | 62 tooltip_text_.clear(); |
63 tooltip_text_.clear(); | |
64 } else { | |
65 tooltip_text_.clear(); | |
66 } | |
67 aura::TooltipClient* tc = static_cast<aura::TooltipClient*>(property); | |
68 tc->UpdateTooltip(native_widget_aura_->GetNativeView()); | |
69 } | 63 } |
| 64 aura::TooltipClient::UpdateTooltip(native_widget_aura_->GetNativeView()); |
70 } | 65 } |
71 | 66 |
72 void TooltipManagerAura::TooltipTextChanged(View* view) { | 67 void TooltipManagerAura::TooltipTextChanged(View* view) { |
73 void* property = aura::Desktop::GetInstance()->GetProperty( | 68 gfx::Point view_point = aura::Desktop::GetInstance()->last_mouse_location(); |
74 aura::kDesktopTooltipClientKey); | 69 aura::Window::ConvertPointToWindow(aura::Desktop::GetInstance(), |
75 if (property) { | 70 native_widget_aura_->GetNativeView(), &view_point); |
76 gfx::Point view_point = aura::Desktop::GetInstance()->last_mouse_location(); | 71 View* target = GetViewUnderPoint(view_point); |
77 aura::Window::ConvertPointToWindow(aura::Desktop::GetInstance(), | 72 if (target != view) |
78 native_widget_aura_->GetNativeView(), &view_point); | 73 return; |
79 View* target = GetViewUnderPoint(view_point); | 74 if (target) { |
80 if (target != view) | 75 View::ConvertPointFromWidget(view, &view_point); |
81 return; | 76 if (!view->GetTooltipText(view_point, &tooltip_text_)) |
82 if (target) { | 77 tooltip_text_.clear(); |
83 View::ConvertPointFromWidget(view, &view_point); | 78 } else { |
84 if (!view->GetTooltipText(view_point, &tooltip_text_)) | 79 tooltip_text_.clear(); |
85 tooltip_text_.clear(); | |
86 } else { | |
87 tooltip_text_.clear(); | |
88 } | |
89 aura::TooltipClient* tc = static_cast<aura::TooltipClient*>(property); | |
90 tc->UpdateTooltip(native_widget_aura_->GetNativeView()); | |
91 } | 80 } |
| 81 aura::TooltipClient::UpdateTooltip(native_widget_aura_->GetNativeView()); |
92 } | 82 } |
93 | 83 |
94 void TooltipManagerAura::ShowKeyboardTooltip(View* view) { | 84 void TooltipManagerAura::ShowKeyboardTooltip(View* view) { |
95 NOTREACHED(); | 85 NOTREACHED(); |
96 } | 86 } |
97 | 87 |
98 void TooltipManagerAura::HideKeyboardTooltip() { | 88 void TooltipManagerAura::HideKeyboardTooltip() { |
99 NOTREACHED(); | 89 NOTREACHED(); |
100 } | 90 } |
101 | 91 |
102 View* TooltipManagerAura::GetViewUnderPoint(const gfx::Point& point) { | 92 View* TooltipManagerAura::GetViewUnderPoint(const gfx::Point& point) { |
103 View* root_view = native_widget_aura_->GetWidget()->GetRootView(); | 93 View* root_view = native_widget_aura_->GetWidget()->GetRootView(); |
104 return root_view->GetEventHandlerForPoint(point); | 94 return root_view->GetEventHandlerForPoint(point); |
105 } | 95 } |
106 | 96 |
107 } // namespace views. | 97 } // namespace views. |
OLD | NEW |