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

Side by Side Diff: chrome/browser/ui/views/omnibox/omnibox_popup_contents_view.h

Issue 15745031: Restyle omnibox popup (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Remove code from toolbar. Created 7 years, 6 months 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
OLDNEW
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 "chrome/browser/ui/views/omnibox/omnibox_result_view_model.h" 11 #include "chrome/browser/ui/views/omnibox/omnibox_result_view_model.h"
12 #include "ui/base/animation/animation_delegate.h" 12 #include "ui/base/animation/animation_delegate.h"
13 #include "ui/base/animation/slide_animation.h" 13 #include "ui/base/animation/slide_animation.h"
14 #include "ui/base/window_open_disposition.h" 14 #include "ui/base/window_open_disposition.h"
15 #include "ui/gfx/font.h" 15 #include "ui/gfx/font.h"
16 #include "ui/views/view.h" 16 #include "ui/views/view.h"
17 17
18 struct AutocompleteMatch; 18 struct AutocompleteMatch;
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 namespace views {
25 class BubbleBorder;
26 }
27
28 // A view representing the contents of the autocomplete popup. 25 // A view representing the contents of the autocomplete popup.
29 class OmniboxPopupContentsView : public views::View, 26 class OmniboxPopupContentsView : public views::View,
30 public OmniboxResultViewModel, 27 public OmniboxResultViewModel,
31 public OmniboxPopupView, 28 public OmniboxPopupView,
32 public ui::AnimationDelegate { 29 public ui::AnimationDelegate {
33 public: 30 public:
34 // Factory method for creating the AutocompletePopupView. 31 // Factory method for creating the AutocompletePopupView.
35 static OmniboxPopupView* Create(const gfx::Font& font, 32 static OmniboxPopupView* Create(const gfx::Font& font,
36 OmniboxView* omnibox_view, 33 OmniboxView* omnibox_view,
37 OmniboxEditModel* edit_model, 34 OmniboxEditModel* edit_model,
38 views::View* location_bar); 35 LocationBarView* location_bar_view);
39 36
40 // 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
41 // 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.
42 gfx::Rect GetPopupBounds() const; 39 gfx::Rect GetPopupBounds() const;
43 40
44 virtual void LayoutChildren(); 41 virtual void LayoutChildren();
45 42
46 // Overridden from OmniboxPopupView: 43 // Overridden from OmniboxPopupView:
47 virtual bool IsOpen() const OVERRIDE; 44 virtual bool IsOpen() const OVERRIDE;
48 virtual void InvalidateLine(size_t line) OVERRIDE; 45 virtual void InvalidateLine(size_t line) OVERRIDE;
(...skipping 24 matching lines...) Expand all
73 virtual void OnMouseEntered(const ui::MouseEvent& event) OVERRIDE; 70 virtual void OnMouseEntered(const ui::MouseEvent& event) OVERRIDE;
74 virtual void OnMouseExited(const ui::MouseEvent& event) OVERRIDE; 71 virtual void OnMouseExited(const ui::MouseEvent& event) OVERRIDE;
75 72
76 // Overridden from ui::EventHandler: 73 // Overridden from ui::EventHandler:
77 virtual void OnGestureEvent(ui::GestureEvent* event) OVERRIDE; 74 virtual void OnGestureEvent(ui::GestureEvent* event) OVERRIDE;
78 75
79 protected: 76 protected:
80 OmniboxPopupContentsView(const gfx::Font& font, 77 OmniboxPopupContentsView(const gfx::Font& font,
81 OmniboxView* omnibox_view, 78 OmniboxView* omnibox_view,
82 OmniboxEditModel* edit_model, 79 OmniboxEditModel* edit_model,
83 views::View* location_bar); 80 LocationBarView* location_bar_view);
84 virtual ~OmniboxPopupContentsView(); 81 virtual ~OmniboxPopupContentsView();
85 82
86 views::View* location_bar() { return location_bar_; } 83 LocationBarView* location_bar_view() { return location_bar_view_; }
87 84
88 virtual void PaintResultViews(gfx::Canvas* canvas); 85 virtual void PaintResultViews(gfx::Canvas* canvas);
89 86
90 // Calculates the height needed to show all the results in the model. 87 // Calculates the height needed to show all the results in the model.
91 virtual int CalculatePopupHeight(); 88 virtual int CalculatePopupHeight();
92 virtual OmniboxResultView* CreateResultView(OmniboxResultViewModel* model, 89 virtual OmniboxResultView* CreateResultView(OmniboxResultViewModel* model,
93 int model_index, 90 int model_index,
94 const gfx::Font& font); 91 const gfx::Font& font);
95 92
96 // Overridden from views::View: 93 // Overridden from views::View:
(...skipping 15 matching lines...) Expand all
112 // Returns true if the model has a match at the specified index. 109 // Returns true if the model has a match at the specified index.
113 bool HasMatchAt(size_t index) const; 110 bool HasMatchAt(size_t index) const;
114 111
115 // Returns the match at the specified index within the popup model. 112 // Returns the match at the specified index within the popup model.
116 const AutocompleteMatch& GetMatchAtIndex(size_t index) const; 113 const AutocompleteMatch& GetMatchAtIndex(size_t index) const;
117 114
118 // Fill a path for the contents' roundrect. |bounding_rect| is the rect that 115 // Fill a path for the contents' roundrect. |bounding_rect| is the rect that
119 // bounds the path. 116 // bounds the path.
120 void MakeContentsPath(gfx::Path* path, const gfx::Rect& bounding_rect); 117 void MakeContentsPath(gfx::Path* path, const gfx::Rect& bounding_rect);
121 118
122 // Updates the window's blur region for the current size.
123 void UpdateBlurRegion();
124
125 // Makes the contents of the canvas slightly transparent.
126 void MakeCanvasTransparent(gfx::Canvas* canvas);
127
128 // Called when the line at the specified index should be opened with the
129 // provided disposition.
130 void OpenIndex(size_t index, WindowOpenDisposition disposition);
131
132 // Find the index of the match under the given |point|, specified in window 119 // Find the index of the match under the given |point|, specified in window
133 // coordinates. Returns OmniboxPopupModel::kNoMatch if there isn't a match at 120 // coordinates. Returns OmniboxPopupModel::kNoMatch if there isn't a match at
134 // the specified point. 121 // the specified point.
135 size_t GetIndexForPoint(const gfx::Point& point); 122 size_t GetIndexForPoint(const gfx::Point& point);
136 123
137 // Processes a located event (e.g. mouse/gesture) and sets the selection/hover 124 // Processes a located event (e.g. mouse/gesture) and sets the selection/hover
138 // state of a line in the list. 125 // state of a line in the list.
139 void UpdateLineEvent(const ui::LocatedEvent& event, 126 void UpdateLineEvent(const ui::LocatedEvent& event,
140 bool should_set_selected_line); 127 bool should_set_selected_line);
141 128
142 // Opens an entry from the list depending on the event and the selected 129 // Opens an entry from the list depending on the event and the selected
143 // disposition. 130 // disposition.
144 void OpenSelectedLine(const ui::LocatedEvent& event, 131 void OpenSelectedLine(const ui::LocatedEvent& event,
145 WindowOpenDisposition disposition); 132 WindowOpenDisposition disposition);
146 133
147 // Returns the target bounds given the specified content height.
148 gfx::Rect CalculateTargetBounds(int h);
149
150 OmniboxResultView* result_view_at(size_t i); 134 OmniboxResultView* result_view_at(size_t i);
151 135
152 // The popup that contains this view. We create this, but it deletes itself 136 // The popup that contains this view. We create this, but it deletes itself
153 // when its window is destroyed. This is a WeakPtr because it's possible for 137 // when its window is destroyed. This is a WeakPtr because it's possible for
154 // the OS to destroy the window and thus delete this object before we're 138 // the OS to destroy the window and thus delete this object before we're
155 // deleted, or without our knowledge. 139 // deleted, or without our knowledge.
156 base::WeakPtr<AutocompletePopupWidget> popup_; 140 base::WeakPtr<AutocompletePopupWidget> popup_;
157 141
158 // The edit view that invokes us. 142 // The edit view that invokes us.
159 OmniboxView* omnibox_view_; 143 OmniboxView* omnibox_view_;
160 144
161 // An object that the popup positions itself against. 145 LocationBarView* location_bar_view_;
162 views::View* location_bar_;
163
164 // Our border, which can compute our desired bounds.
165 const views::BubbleBorder* bubble_border_;
166 146
167 // The font used for result rows, based on the omnibox font. 147 // The font used for result rows, based on the omnibox font.
168 gfx::Font font_; 148 gfx::Font font_;
169 149
170 // If the user cancels a dragging action (i.e. by pressing ESC), we don't have 150 // If the user cancels a dragging action (i.e. by pressing ESC), we don't have
171 // a convenient way to release mouse capture. Instead we use this flag to 151 // a convenient way to release mouse capture. Instead we use this flag to
172 // simply ignore all remaining drag events, and the eventual mouse release 152 // simply ignore all remaining drag events, and the eventual mouse release
173 // event. Since OnDragCanceled() can be called when we're not dragging, this 153 // event. Since OnDragCanceled() can be called when we're not dragging, this
174 // flag is reset to false on a mouse pressed event, to make sure we don't 154 // flag is reset to false on a mouse pressed event, to make sure we don't
175 // erroneously ignore the next drag. 155 // erroneously ignore the next drag.
176 bool ignore_mouse_drag_; 156 bool ignore_mouse_drag_;
177 157
178 // The popup sizes vertically using an animation when the popup is getting 158 // The popup sizes vertically using an animation when the popup is getting
179 // shorter (not larger, that makes it look "slow"). 159 // shorter (not larger, that makes it look "slow").
180 ui::SlideAnimation size_animation_; 160 ui::SlideAnimation size_animation_;
181 gfx::Rect start_bounds_; 161 gfx::Rect start_bounds_;
182 gfx::Rect target_bounds_; 162 gfx::Rect target_bounds_;
183 163
164 int left_margin_;
165 int right_margin_;
166
167 const gfx::ImageSkia* bottom_shadow_; // Ptr owned by resource bundle.
168
169 // Amount of extra padding to add to the popup on the top and bottom.
170 int outside_vertical_padding_;
171
184 DISALLOW_COPY_AND_ASSIGN(OmniboxPopupContentsView); 172 DISALLOW_COPY_AND_ASSIGN(OmniboxPopupContentsView);
185 }; 173 };
186 174
187 #endif // CHROME_BROWSER_UI_VIEWS_OMNIBOX_OMNIBOX_POPUP_CONTENTS_VIEW_H_ 175 #endif // CHROME_BROWSER_UI_VIEWS_OMNIBOX_OMNIBOX_POPUP_CONTENTS_VIEW_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698