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

Side by Side Diff: chrome/browser/ui/views/autocomplete/autocomplete_popup_contents_view.h

Issue 10384007: First stab at touch optimized omnibox auto-complete per sgabriel's mocks. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address review comments. Created 8 years, 7 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
« no previous file with comments | « no previous file | chrome/browser/ui/views/autocomplete/autocomplete_popup_contents_view.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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_AUTOCOMPLETE_AUTOCOMPLETE_POPUP_CONTENTS_VIEW_H_ 5 #ifndef CHROME_BROWSER_UI_VIEWS_AUTOCOMPLETE_AUTOCOMPLETE_POPUP_CONTENTS_VIEW_H_
6 #define CHROME_BROWSER_UI_VIEWS_AUTOCOMPLETE_AUTOCOMPLETE_POPUP_CONTENTS_VIEW_H_ 6 #define CHROME_BROWSER_UI_VIEWS_AUTOCOMPLETE_AUTOCOMPLETE_POPUP_CONTENTS_VIEW_H_
7 #pragma once 7 #pragma once
8 8
9 #include "base/memory/weak_ptr.h" 9 #include "base/memory/weak_ptr.h"
10 #include "chrome/browser/autocomplete/autocomplete.h" 10 #include "chrome/browser/autocomplete/autocomplete.h"
(...skipping 14 matching lines...) Expand all
25 namespace views { 25 namespace views {
26 class BubbleBorder; 26 class BubbleBorder;
27 } 27 }
28 28
29 // A view representing the contents of the autocomplete popup. 29 // A view representing the contents of the autocomplete popup.
30 class AutocompletePopupContentsView : public views::View, 30 class AutocompletePopupContentsView : public views::View,
31 public AutocompleteResultViewModel, 31 public AutocompleteResultViewModel,
32 public AutocompletePopupView, 32 public AutocompletePopupView,
33 public ui::AnimationDelegate { 33 public ui::AnimationDelegate {
34 public: 34 public:
35 AutocompletePopupContentsView(const gfx::Font& font, 35 // Creates the appropriate type of omnibox dropdown for the
36 OmniboxView* omnibox_view, 36 // current environment, e.g. desktop vs. touch optimized layout.
37 AutocompleteEditModel* edit_model, 37 static AutocompletePopupContentsView* CreateForEnvironment(
38 views::View* location_bar); 38 const gfx::Font& font,
39 virtual ~AutocompletePopupContentsView(); 39 OmniboxView* omnibox_view,
40 AutocompleteEditModel* edit_model,
41 views::View* location_bar);
40 42
41 // Returns the bounds the popup should be shown at. This is the display bounds 43 // Returns the bounds the popup should be shown at. This is the display bounds
42 // and includes offsets for the dropshadow which this view's border renders. 44 // and includes offsets for the dropshadow which this view's border renders.
43 gfx::Rect GetPopupBounds() const; 45 gfx::Rect GetPopupBounds() const;
44 46
45 virtual void LayoutChildren(); 47 virtual void LayoutChildren();
46 48
47 // Overridden from AutocompletePopupView: 49 // Overridden from AutocompletePopupView:
48 virtual bool IsOpen() const OVERRIDE; 50 virtual bool IsOpen() const OVERRIDE;
49 virtual void InvalidateLine(size_t line) OVERRIDE; 51 virtual void InvalidateLine(size_t line) OVERRIDE;
(...skipping 16 matching lines...) Expand all
66 const gfx::Point& point) OVERRIDE; 68 const gfx::Point& point) OVERRIDE;
67 virtual bool OnMousePressed(const views::MouseEvent& event) OVERRIDE; 69 virtual bool OnMousePressed(const views::MouseEvent& event) OVERRIDE;
68 virtual bool OnMouseDragged(const views::MouseEvent& event) OVERRIDE; 70 virtual bool OnMouseDragged(const views::MouseEvent& event) OVERRIDE;
69 virtual void OnMouseReleased(const views::MouseEvent& event) OVERRIDE; 71 virtual void OnMouseReleased(const views::MouseEvent& event) OVERRIDE;
70 virtual void OnMouseCaptureLost() OVERRIDE; 72 virtual void OnMouseCaptureLost() OVERRIDE;
71 virtual void OnMouseMoved(const views::MouseEvent& event) OVERRIDE; 73 virtual void OnMouseMoved(const views::MouseEvent& event) OVERRIDE;
72 virtual void OnMouseEntered(const views::MouseEvent& event) OVERRIDE; 74 virtual void OnMouseEntered(const views::MouseEvent& event) OVERRIDE;
73 virtual void OnMouseExited(const views::MouseEvent& event) OVERRIDE; 75 virtual void OnMouseExited(const views::MouseEvent& event) OVERRIDE;
74 76
75 protected: 77 protected:
78 AutocompletePopupContentsView(const gfx::Font& font,
79 OmniboxView* omnibox_view,
80 AutocompleteEditModel* edit_model,
81 views::View* location_bar);
82 virtual ~AutocompletePopupContentsView();
83
76 virtual void PaintResultViews(gfx::Canvas* canvas); 84 virtual void PaintResultViews(gfx::Canvas* canvas);
77 85
78 // Calculates the height needed to show all the results in the model. 86 // Calculates the height needed to show all the results in the model.
79 virtual int CalculatePopupHeight(); 87 virtual int CalculatePopupHeight();
80 virtual AutocompleteResultView* CreateResultView( 88 virtual AutocompleteResultView* CreateResultView(
81 AutocompleteResultViewModel* model, 89 AutocompleteResultViewModel* model,
82 int model_index, 90 int model_index,
83 const gfx::Font& font, 91 const gfx::Font& font,
84 const gfx::Font& bold_font); 92 const gfx::Font& bold_font);
85 93
86 // Overridden from views::View: 94 // Overridden from views::View:
87 virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE; 95 virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE;
88 // 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
89 // 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
90 // 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
91 // the view hierarchy does not "accidentally" trigger this. 99 // the view hierarchy does not "accidentally" trigger this.
92 virtual void PaintChildren(gfx::Canvas* canvas) OVERRIDE; 100 virtual void PaintChildren(gfx::Canvas* canvas) OVERRIDE;
93 101
94 scoped_ptr<AutocompletePopupModel> model_; 102 scoped_ptr<AutocompletePopupModel> model_;
95 103
96 private: 104 private:
97 class AutocompletePopupWidget; 105 class AutocompletePopupWidget;
98 106
107 // Call immediately after construction.
108 void Init();
109
99 // Returns true if the model has a match at the specified index. 110 // Returns true if the model has a match at the specified index.
100 bool HasMatchAt(size_t index) const; 111 bool HasMatchAt(size_t index) const;
101 112
102 // Returns the match at the specified index within the popup model. 113 // Returns the match at the specified index within the popup model.
103 const AutocompleteMatch& GetMatchAtIndex(size_t index) const; 114 const AutocompleteMatch& GetMatchAtIndex(size_t index) const;
104 115
105 // Fill a path for the contents' roundrect. |bounding_rect| is the rect that 116 // Fill a path for the contents' roundrect. |bounding_rect| is the rect that
106 // bounds the path. 117 // bounds the path.
107 void MakeContentsPath(gfx::Path* path, const gfx::Rect& bounding_rect); 118 void MakeContentsPath(gfx::Path* path, const gfx::Rect& bounding_rect);
108 119
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
159 // The popup sizes vertically using an animation when the popup is getting 170 // The popup sizes vertically using an animation when the popup is getting
160 // shorter (not larger, that makes it look "slow"). 171 // shorter (not larger, that makes it look "slow").
161 ui::SlideAnimation size_animation_; 172 ui::SlideAnimation size_animation_;
162 gfx::Rect start_bounds_; 173 gfx::Rect start_bounds_;
163 gfx::Rect target_bounds_; 174 gfx::Rect target_bounds_;
164 175
165 DISALLOW_COPY_AND_ASSIGN(AutocompletePopupContentsView); 176 DISALLOW_COPY_AND_ASSIGN(AutocompletePopupContentsView);
166 }; 177 };
167 178
168 #endif // CHROME_BROWSER_UI_VIEWS_AUTOCOMPLETE_AUTOCOMPLETE_POPUP_CONTENTS_VIEW _H_ 179 #endif // CHROME_BROWSER_UI_VIEWS_AUTOCOMPLETE_AUTOCOMPLETE_POPUP_CONTENTS_VIEW _H_
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/ui/views/autocomplete/autocomplete_popup_contents_view.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698