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" |
(...skipping 23 matching lines...) Expand all Loading... |
34 OmniboxEditModel* edit_model, | 34 OmniboxEditModel* edit_model, |
35 LocationBarView* location_bar_view); | 35 LocationBarView* location_bar_view); |
36 | 36 |
37 // 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 |
38 // 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. |
39 gfx::Rect GetPopupBounds() const; | 39 gfx::Rect GetPopupBounds() const; |
40 | 40 |
41 virtual void LayoutChildren(); | 41 virtual void LayoutChildren(); |
42 | 42 |
43 // Overridden from OmniboxPopupView: | 43 // Overridden from OmniboxPopupView: |
44 virtual bool IsOpen() const OVERRIDE; | 44 virtual bool IsOpen() const override; |
45 virtual void InvalidateLine(size_t line) OVERRIDE; | 45 virtual void InvalidateLine(size_t line) override; |
46 virtual void UpdatePopupAppearance() OVERRIDE; | 46 virtual void UpdatePopupAppearance() override; |
47 virtual gfx::Rect GetTargetBounds() OVERRIDE; | 47 virtual gfx::Rect GetTargetBounds() override; |
48 virtual void PaintUpdatesNow() OVERRIDE; | 48 virtual void PaintUpdatesNow() override; |
49 virtual void OnDragCanceled() OVERRIDE; | 49 virtual void OnDragCanceled() override; |
50 | 50 |
51 // Overridden from gfx::AnimationDelegate: | 51 // Overridden from gfx::AnimationDelegate: |
52 virtual void AnimationProgressed(const gfx::Animation* animation) OVERRIDE; | 52 virtual void AnimationProgressed(const gfx::Animation* animation) override; |
53 | 53 |
54 // Overridden from views::View: | 54 // Overridden from views::View: |
55 virtual void Layout() OVERRIDE; | 55 virtual void Layout() 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 |
66 // Overridden from ui::EventHandler: | 66 // Overridden from ui::EventHandler: |
67 virtual void OnGestureEvent(ui::GestureEvent* event) OVERRIDE; | 67 virtual void OnGestureEvent(ui::GestureEvent* event) override; |
68 | 68 |
69 bool IsSelectedIndex(size_t index) const; | 69 bool IsSelectedIndex(size_t index) const; |
70 bool IsHoveredIndex(size_t index) const; | 70 bool IsHoveredIndex(size_t index) const; |
71 gfx::Image GetIconIfExtensionMatch(size_t index) const; | 71 gfx::Image GetIconIfExtensionMatch(size_t index) const; |
72 bool IsStarredMatch(const AutocompleteMatch& match) const; | 72 bool IsStarredMatch(const AutocompleteMatch& match) const; |
73 | 73 |
74 int max_match_contents_width() const { | 74 int max_match_contents_width() const { |
75 return max_match_contents_width_; | 75 return max_match_contents_width_; |
76 } | 76 } |
77 | 77 |
78 protected: | 78 protected: |
79 OmniboxPopupContentsView(const gfx::FontList& font_list, | 79 OmniboxPopupContentsView(const gfx::FontList& font_list, |
80 OmniboxView* omnibox_view, | 80 OmniboxView* omnibox_view, |
81 OmniboxEditModel* edit_model, | 81 OmniboxEditModel* edit_model, |
82 LocationBarView* location_bar_view); | 82 LocationBarView* location_bar_view); |
83 virtual ~OmniboxPopupContentsView(); | 83 virtual ~OmniboxPopupContentsView(); |
84 | 84 |
85 LocationBarView* location_bar_view() { return location_bar_view_; } | 85 LocationBarView* location_bar_view() { return location_bar_view_; } |
86 | 86 |
87 virtual void PaintResultViews(gfx::Canvas* canvas); | 87 virtual void PaintResultViews(gfx::Canvas* canvas); |
88 | 88 |
89 // Calculates the height needed to show all the results in the model. | 89 // Calculates the height needed to show all the results in the model. |
90 virtual int CalculatePopupHeight(); | 90 virtual int CalculatePopupHeight(); |
91 virtual OmniboxResultView* CreateResultView(int model_index, | 91 virtual OmniboxResultView* CreateResultView(int model_index, |
92 const gfx::FontList& font_list); | 92 const gfx::FontList& font_list); |
93 | 93 |
94 // Overridden from views::View: | 94 // Overridden from views::View: |
95 virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE; | 95 virtual void OnPaint(gfx::Canvas* canvas) override; |
96 // This method should not be triggered directly as we paint our children | 96 // This method should not be triggered directly as we paint our children |
97 // in an un-conventional way inside OnPaint. We use a separate canvas to | 97 // in an un-conventional way inside OnPaint. We use a separate canvas to |
98 // paint the children. Hence we override this method to a no-op so that | 98 // paint the children. Hence we override this method to a no-op so that |
99 // the view hierarchy does not "accidentally" trigger this. | 99 // the view hierarchy does not "accidentally" trigger this. |
100 virtual void PaintChildren(gfx::Canvas* canvas, | 100 virtual void PaintChildren(gfx::Canvas* canvas, |
101 const views::CullSet& cull_set) OVERRIDE; | 101 const views::CullSet& cull_set) override; |
102 | 102 |
103 scoped_ptr<OmniboxPopupModel> model_; | 103 scoped_ptr<OmniboxPopupModel> model_; |
104 | 104 |
105 private: | 105 private: |
106 class AutocompletePopupWidget; | 106 class AutocompletePopupWidget; |
107 | 107 |
108 // views::ViewTargeterDelegate: | 108 // views::ViewTargeterDelegate: |
109 virtual views::View* TargetForRect(views::View* root, | 109 virtual views::View* TargetForRect(views::View* root, |
110 const gfx::Rect& rect) OVERRIDE; | 110 const gfx::Rect& rect) override; |
111 | 111 |
112 // Call immediately after construction. | 112 // Call immediately after construction. |
113 void Init(); | 113 void Init(); |
114 | 114 |
115 // Returns true if the model has a match at the specified index. | 115 // Returns true if the model has a match at the specified index. |
116 bool HasMatchAt(size_t index) const; | 116 bool HasMatchAt(size_t index) const; |
117 | 117 |
118 // Returns the match at the specified index within the popup model. | 118 // Returns the match at the specified index within the popup model. |
119 const AutocompleteMatch& GetMatchAtIndex(size_t index) const; | 119 const AutocompleteMatch& GetMatchAtIndex(size_t index) const; |
120 | 120 |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
177 | 177 |
178 // When the dropdown is not wide enough while displaying postfix suggestions, | 178 // When the dropdown is not wide enough while displaying postfix suggestions, |
179 // we use the width of widest match contents to shift the suggestions so that | 179 // we use the width of widest match contents to shift the suggestions so that |
180 // the widest suggestion just reaches the end edge. | 180 // the widest suggestion just reaches the end edge. |
181 int max_match_contents_width_; | 181 int max_match_contents_width_; |
182 | 182 |
183 DISALLOW_COPY_AND_ASSIGN(OmniboxPopupContentsView); | 183 DISALLOW_COPY_AND_ASSIGN(OmniboxPopupContentsView); |
184 }; | 184 }; |
185 | 185 |
186 #endif // CHROME_BROWSER_UI_VIEWS_OMNIBOX_OMNIBOX_POPUP_CONTENTS_VIEW_H_ | 186 #endif // CHROME_BROWSER_UI_VIEWS_OMNIBOX_OMNIBOX_POPUP_CONTENTS_VIEW_H_ |
OLD | NEW |