OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "chrome/browser/ui/views/autofill/tooltip_icon.h" | 5 #include "chrome/browser/ui/views/autofill/tooltip_icon.h" |
6 | 6 |
7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
8 #include "base/timer/timer.h" | 8 #include "base/timer/timer.h" |
9 #include "chrome/browser/ui/views/autofill/info_bubble.h" | 9 #include "chrome/browser/ui/views/autofill/info_bubble.h" |
10 #include "grit/theme_resources.h" | 10 #include "grit/theme_resources.h" |
11 #include "ui/accessibility/ax_view_state.h" | 11 #include "ui/accessibility/ax_view_state.h" |
12 #include "ui/base/resource/resource_bundle.h" | 12 #include "ui/base/resource/resource_bundle.h" |
13 #include "ui/views/bubble/bubble_frame_view.h" | 13 #include "ui/views/bubble/bubble_frame_view.h" |
14 #include "ui/views/mouse_watcher_view_host.h" | 14 #include "ui/views/mouse_watcher_view_host.h" |
15 #include "ui/views/painter.h" | 15 #include "ui/views/painter.h" |
16 | 16 |
17 namespace autofill { | 17 namespace autofill { |
18 | 18 |
19 namespace { | 19 namespace { |
20 | 20 |
21 gfx::Insets GetPreferredInsets(views::View* view) { | 21 gfx::Insets GetPreferredInsets(const views::View* view) { |
22 gfx::Size pref_size = view->GetPreferredSize(); | 22 gfx::Size pref_size = view->GetPreferredSize(); |
23 gfx::Rect local_bounds = view->GetLocalBounds(); | 23 gfx::Rect local_bounds = view->GetLocalBounds(); |
24 gfx::Point origin = local_bounds.CenterPoint(); | 24 gfx::Point origin = local_bounds.CenterPoint(); |
25 origin.Offset(-pref_size.width() / 2, -pref_size.height() / 2); | 25 origin.Offset(-pref_size.width() / 2, -pref_size.height() / 2); |
26 return gfx::Insets(origin.y(), | 26 return gfx::Insets(origin.y(), |
27 origin.x(), | 27 origin.x(), |
28 local_bounds.bottom() - (origin.y() + pref_size.height()), | 28 local_bounds.bottom() - (origin.y() + pref_size.height()), |
29 local_bounds.right() - (origin.x() + pref_size.width())); | 29 local_bounds.right() - (origin.x() + pref_size.width())); |
30 } | 30 } |
31 | 31 |
32 // An info bubble with some extra positioning magic for tooltip icons. | 32 // An info bubble with some extra positioning magic for tooltip icons. |
33 class TooltipBubble : public InfoBubble { | 33 class TooltipBubble : public InfoBubble { |
34 public: | 34 public: |
35 TooltipBubble(views::View* anchor, const base::string16& message) | 35 TooltipBubble(views::View* anchor, const base::string16& message) |
36 : InfoBubble(anchor, message) {} | 36 : InfoBubble(anchor, message) {} |
37 virtual ~TooltipBubble() {} | 37 virtual ~TooltipBubble() {} |
38 | 38 |
39 protected: | 39 protected: |
40 // InfoBubble: | 40 // InfoBubble: |
41 virtual gfx::Rect GetAnchorRect() OVERRIDE { | 41 virtual gfx::Rect GetAnchorRect() const OVERRIDE { |
42 gfx::Rect bounds = views::BubbleDelegateView::GetAnchorRect(); | 42 gfx::Rect bounds = views::BubbleDelegateView::GetAnchorRect(); |
43 bounds.Inset(GetPreferredInsets(anchor())); | 43 bounds.Inset(GetPreferredInsets(anchor())); |
44 return bounds; | 44 return bounds; |
45 } | 45 } |
46 | 46 |
47 private: | 47 private: |
48 DISALLOW_COPY_AND_ASSIGN(TooltipBubble); | 48 DISALLOW_COPY_AND_ASSIGN(TooltipBubble); |
49 }; | 49 }; |
50 | 50 |
51 } // namespace | 51 } // namespace |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
135 | 135 |
136 void TooltipIcon::OnWidgetDestroyed(views::Widget* widget) { | 136 void TooltipIcon::OnWidgetDestroyed(views::Widget* widget) { |
137 observer_.Remove(widget); | 137 observer_.Remove(widget); |
138 | 138 |
139 ChangeImageTo(IDR_AUTOFILL_TOOLTIP_ICON); | 139 ChangeImageTo(IDR_AUTOFILL_TOOLTIP_ICON); |
140 mouse_watcher_.reset(); | 140 mouse_watcher_.reset(); |
141 bubble_ = NULL; | 141 bubble_ = NULL; |
142 } | 142 } |
143 | 143 |
144 } // namespace autofill | 144 } // namespace autofill |
OLD | NEW |