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 #ifndef CHROME_BROWSER_UI_VIEWS_OMNIBOX_OMNIBOX_POPUP_CONTENTS_VIEW_H_ | 5 #ifndef CHROME_BROWSER_UI_VIEWS_OMNIBOX_OMNIBOX_POPUP_CONTENTS_VIEW_H_ |
6 #define CHROME_BROWSER_UI_VIEWS_OMNIBOX_OMNIBOX_POPUP_CONTENTS_VIEW_H_ | 6 #define CHROME_BROWSER_UI_VIEWS_OMNIBOX_OMNIBOX_POPUP_CONTENTS_VIEW_H_ |
7 | 7 |
8 #include "base/memory/weak_ptr.h" | 8 #include "base/memory/weak_ptr.h" |
9 #include "chrome/browser/ui/omnibox/omnibox_popup_model.h" | 9 #include "chrome/browser/ui/omnibox/omnibox_popup_model.h" |
10 #include "chrome/browser/ui/omnibox/omnibox_popup_view.h" | 10 #include "chrome/browser/ui/omnibox/omnibox_popup_view.h" |
11 #include "ui/base/window_open_disposition.h" | 11 #include "ui/base/window_open_disposition.h" |
12 #include "ui/gfx/animation/animation_delegate.h" | 12 #include "ui/gfx/animation/animation_delegate.h" |
13 #include "ui/gfx/animation/slide_animation.h" | 13 #include "ui/gfx/animation/slide_animation.h" |
14 #include "ui/gfx/font_list.h" | 14 #include "ui/gfx/font_list.h" |
15 #include "ui/views/view.h" | 15 #include "ui/views/view.h" |
| 16 #include "ui/views/view_targeter_delegate.h" |
16 | 17 |
17 struct AutocompleteMatch; | 18 struct AutocompleteMatch; |
18 class LocationBarView; | 19 class LocationBarView; |
19 class OmniboxEditModel; | 20 class OmniboxEditModel; |
20 class OmniboxResultView; | 21 class OmniboxResultView; |
21 class OmniboxView; | 22 class OmniboxView; |
22 class Profile; | 23 class Profile; |
23 | 24 |
24 // A view representing the contents of the autocomplete popup. | 25 // A view representing the contents of the autocomplete popup. |
25 class OmniboxPopupContentsView : public views::View, | 26 class OmniboxPopupContentsView : public views::View, |
26 public OmniboxPopupView, | 27 public OmniboxPopupView, |
| 28 public views::ViewTargeterDelegate, |
27 public gfx::AnimationDelegate { | 29 public gfx::AnimationDelegate { |
28 public: | 30 public: |
29 // Factory method for creating the AutocompletePopupView. | 31 // Factory method for creating the AutocompletePopupView. |
30 static OmniboxPopupView* Create(const gfx::FontList& font_list, | 32 static OmniboxPopupView* Create(const gfx::FontList& font_list, |
31 OmniboxView* omnibox_view, | 33 OmniboxView* omnibox_view, |
32 OmniboxEditModel* edit_model, | 34 OmniboxEditModel* edit_model, |
33 LocationBarView* location_bar_view); | 35 LocationBarView* location_bar_view); |
34 | 36 |
35 // Returns the bounds the popup should be shown at. This is the display bounds | 37 // Returns the bounds the popup should be shown at. This is the display bounds |
36 // and includes offsets for the dropshadow which this view's border renders. | 38 // and includes offsets for the dropshadow which this view's border renders. |
37 gfx::Rect GetPopupBounds() const; | 39 gfx::Rect GetPopupBounds() const; |
38 | 40 |
39 virtual void LayoutChildren(); | 41 virtual void LayoutChildren(); |
40 | 42 |
41 // Overridden from OmniboxPopupView: | 43 // Overridden from OmniboxPopupView: |
42 virtual bool IsOpen() const OVERRIDE; | 44 virtual bool IsOpen() const OVERRIDE; |
43 virtual void InvalidateLine(size_t line) OVERRIDE; | 45 virtual void InvalidateLine(size_t line) OVERRIDE; |
44 virtual void UpdatePopupAppearance() OVERRIDE; | 46 virtual void UpdatePopupAppearance() OVERRIDE; |
45 virtual gfx::Rect GetTargetBounds() OVERRIDE; | 47 virtual gfx::Rect GetTargetBounds() OVERRIDE; |
46 virtual void PaintUpdatesNow() OVERRIDE; | 48 virtual void PaintUpdatesNow() OVERRIDE; |
47 virtual void OnDragCanceled() OVERRIDE; | 49 virtual void OnDragCanceled() OVERRIDE; |
48 | 50 |
49 // Overridden from gfx::AnimationDelegate: | 51 // Overridden from gfx::AnimationDelegate: |
50 virtual void AnimationProgressed(const gfx::Animation* animation) OVERRIDE; | 52 virtual void AnimationProgressed(const gfx::Animation* animation) OVERRIDE; |
51 | 53 |
52 // Overridden from views::View: | 54 // Overridden from views::View: |
53 virtual void Layout() OVERRIDE; | 55 virtual void Layout() OVERRIDE; |
54 virtual views::View* GetEventHandlerForRect( | |
55 const gfx::Rect& rect) OVERRIDE; | |
56 virtual views::View* GetTooltipHandlerForPoint( | 56 virtual views::View* GetTooltipHandlerForPoint( |
57 const gfx::Point& point) OVERRIDE; | 57 const gfx::Point& point) OVERRIDE; |
58 virtual bool OnMousePressed(const ui::MouseEvent& event) OVERRIDE; | 58 virtual bool OnMousePressed(const ui::MouseEvent& event) OVERRIDE; |
59 virtual bool OnMouseDragged(const ui::MouseEvent& event) OVERRIDE; | 59 virtual bool OnMouseDragged(const ui::MouseEvent& event) OVERRIDE; |
60 virtual void OnMouseReleased(const ui::MouseEvent& event) OVERRIDE; | 60 virtual void OnMouseReleased(const ui::MouseEvent& event) OVERRIDE; |
61 virtual void OnMouseCaptureLost() OVERRIDE; | 61 virtual void OnMouseCaptureLost() OVERRIDE; |
62 virtual void OnMouseMoved(const ui::MouseEvent& event) OVERRIDE; | 62 virtual void OnMouseMoved(const ui::MouseEvent& event) OVERRIDE; |
63 virtual void OnMouseEntered(const ui::MouseEvent& event) OVERRIDE; | 63 virtual void OnMouseEntered(const ui::MouseEvent& event) OVERRIDE; |
64 virtual void OnMouseExited(const ui::MouseEvent& event) OVERRIDE; | 64 virtual void OnMouseExited(const ui::MouseEvent& event) OVERRIDE; |
65 | 65 |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
97 // paint the children. Hence we override this method to a no-op so that | 97 // paint the children. Hence we override this method to a no-op so that |
98 // the view hierarchy does not "accidentally" trigger this. | 98 // the view hierarchy does not "accidentally" trigger this. |
99 virtual void PaintChildren(gfx::Canvas* canvas, | 99 virtual void PaintChildren(gfx::Canvas* canvas, |
100 const views::CullSet& cull_set) OVERRIDE; | 100 const views::CullSet& cull_set) OVERRIDE; |
101 | 101 |
102 scoped_ptr<OmniboxPopupModel> model_; | 102 scoped_ptr<OmniboxPopupModel> model_; |
103 | 103 |
104 private: | 104 private: |
105 class AutocompletePopupWidget; | 105 class AutocompletePopupWidget; |
106 | 106 |
| 107 // views::ViewTargeterDelegate: |
| 108 virtual views::View* TargetForRect(views::View* root, |
| 109 const gfx::Rect& rect) OVERRIDE; |
| 110 |
107 // Call immediately after construction. | 111 // Call immediately after construction. |
108 void Init(); | 112 void Init(); |
109 | 113 |
110 // Returns true if the model has a match at the specified index. | 114 // Returns true if the model has a match at the specified index. |
111 bool HasMatchAt(size_t index) const; | 115 bool HasMatchAt(size_t index) const; |
112 | 116 |
113 // Returns the match at the specified index within the popup model. | 117 // Returns the match at the specified index within the popup model. |
114 const AutocompleteMatch& GetMatchAtIndex(size_t index) const; | 118 const AutocompleteMatch& GetMatchAtIndex(size_t index) const; |
115 | 119 |
116 // Fill a path for the contents' roundrect. |bounding_rect| is the rect that | 120 // Fill a path for the contents' roundrect. |bounding_rect| is the rect that |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
172 | 176 |
173 // When the dropdown is not wide enough while displaying postfix suggestions, | 177 // When the dropdown is not wide enough while displaying postfix suggestions, |
174 // we use the width of widest match contents to shift the suggestions so that | 178 // we use the width of widest match contents to shift the suggestions so that |
175 // the widest suggestion just reaches the end edge. | 179 // the widest suggestion just reaches the end edge. |
176 int max_match_contents_width_; | 180 int max_match_contents_width_; |
177 | 181 |
178 DISALLOW_COPY_AND_ASSIGN(OmniboxPopupContentsView); | 182 DISALLOW_COPY_AND_ASSIGN(OmniboxPopupContentsView); |
179 }; | 183 }; |
180 | 184 |
181 #endif // CHROME_BROWSER_UI_VIEWS_OMNIBOX_OMNIBOX_POPUP_CONTENTS_VIEW_H_ | 185 #endif // CHROME_BROWSER_UI_VIEWS_OMNIBOX_OMNIBOX_POPUP_CONTENTS_VIEW_H_ |
OLD | NEW |