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

Side by Side Diff: ui/views/widget/tooltip_manager_aura.cc

Issue 8747022: Aura: Tooltips (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: moved test_tooltip_client to ui/views/test Created 9 years 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
« no previous file with comments | « ui/views/widget/tooltip_manager_aura.h ('k') | ui/views/widget/tooltip_manager_views.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "base/logging.h"
6 #include "ui/aura/client/aura_constants.h"
7 #include "ui/aura/client/tooltip_client.h"
8 #include "ui/aura/desktop.h"
9 #include "ui/base/resource/resource_bundle.h"
10 #include "ui/gfx/font.h"
11 #include "ui/gfx/rect.h"
12 #include "ui/gfx/screen.h"
13 #include "ui/views/widget/native_widget_aura.h"
14 #include "ui/views/widget/tooltip_manager_aura.h"
15
16 namespace views {
17
18 // static
19 int TooltipManager::GetTooltipHeight() {
20 // Not used for linux and chromeos.
21 NOTIMPLEMENTED();
22 return 0;
23 }
24
25 // static
26 gfx::Font TooltipManager::GetDefaultFont() {
27 return aura::TooltipClient::GetDefaultFont();
28 }
29
30 // static
31 int TooltipManager::GetMaxWidth(int x, int y) {
32 return aura::TooltipClient::GetMaxWidth(x, y);
33 }
34
35 ////////////////////////////////////////////////////////////////////////////////
36 // TooltipManagerAura public:
37
38 TooltipManagerAura::TooltipManagerAura(NativeWidgetAura* native_widget_aura)
39 : native_widget_aura_(native_widget_aura) {
40 native_widget_aura_->GetNativeView()->SetProperty(aura::kTooltipTextKey,
41 &tooltip_text_);
42 }
43
44 TooltipManagerAura::~TooltipManagerAura() {
45 native_widget_aura_->GetNativeView()->SetProperty(aura::kTooltipTextKey,
46 NULL);
47 }
48
49 ////////////////////////////////////////////////////////////////////////////////
50 // TooltipManagerAura, TooltipManager implementation:
51
52 void TooltipManagerAura::UpdateTooltip() {
53 void* property = aura::Desktop::GetInstance()->GetProperty(
54 aura::kDesktopTooltipClientKey);
55 if (property) {
56 gfx::Point view_point = aura::Desktop::GetInstance()->last_mouse_location();
57 aura::Window::ConvertPointToWindow(aura::Desktop::GetInstance(),
58 native_widget_aura_->GetNativeView(), &view_point);
59 View* view = GetViewUnderPoint(view_point);
60 if (view) {
61 View::ConvertPointFromWidget(view, &view_point);
62 if (!view->GetTooltipText(view_point, &tooltip_text_))
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 }
70 }
71
72 void TooltipManagerAura::TooltipTextChanged(View* view) {
73 void* property = aura::Desktop::GetInstance()->GetProperty(
74 aura::kDesktopTooltipClientKey);
75 if (property) {
76 gfx::Point view_point = aura::Desktop::GetInstance()->last_mouse_location();
77 aura::Window::ConvertPointToWindow(aura::Desktop::GetInstance(),
78 native_widget_aura_->GetNativeView(), &view_point);
79 View* target = GetViewUnderPoint(view_point);
80 if (target != view)
81 return;
82 if (target) {
83 View::ConvertPointFromWidget(view, &view_point);
84 if (!view->GetTooltipText(view_point, &tooltip_text_))
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 }
92 }
93
94 void TooltipManagerAura::ShowKeyboardTooltip(View* view) {
95 NOTREACHED();
96 }
97
98 void TooltipManagerAura::HideKeyboardTooltip() {
99 NOTREACHED();
100 }
101
102 View* TooltipManagerAura::GetViewUnderPoint(const gfx::Point& point) {
103 View* root_view = native_widget_aura_->GetWidget()->GetRootView();
104 return root_view->GetEventHandlerForPoint(point);
105 }
106
107 } // namespace views.
OLDNEW
« no previous file with comments | « ui/views/widget/tooltip_manager_aura.h ('k') | ui/views/widget/tooltip_manager_views.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698