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

Side by Side Diff: chrome/browser/ui/views/autocomplete/autocomplete_result_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
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_RESULT_VIEW_H_ 5 #ifndef CHROME_BROWSER_UI_VIEWS_AUTOCOMPLETE_AUTOCOMPLETE_RESULT_VIEW_H_
6 #define CHROME_BROWSER_UI_VIEWS_AUTOCOMPLETE_AUTOCOMPLETE_RESULT_VIEW_H_ 6 #define CHROME_BROWSER_UI_VIEWS_AUTOCOMPLETE_AUTOCOMPLETE_RESULT_VIEW_H_
7 #pragma once 7 #pragma once
8 8
9 #include "chrome/browser/autocomplete/autocomplete_match.h" 9 #include "chrome/browser/autocomplete/autocomplete_match.h"
10 #include "third_party/skia/include/core/SkColor.h" 10 #include "third_party/skia/include/core/SkColor.h"
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
53 void SetMatch(const AutocompleteMatch& match); 53 void SetMatch(const AutocompleteMatch& match);
54 54
55 void ShowKeyword(bool show_keyword); 55 void ShowKeyword(bool show_keyword);
56 56
57 void Invalidate(); 57 void Invalidate();
58 58
59 // views::View: 59 // views::View:
60 virtual gfx::Size GetPreferredSize() OVERRIDE; 60 virtual gfx::Size GetPreferredSize() OVERRIDE;
61 61
62 protected: 62 protected:
63 ResultViewState GetState() const;
64
63 virtual void PaintMatch(gfx::Canvas* canvas, 65 virtual void PaintMatch(gfx::Canvas* canvas,
64 const AutocompleteMatch& match, 66 const AutocompleteMatch& match,
65 int x); 67 int x);
66 68
69 // The base class never adjusts the bounds for the icon. Subclasses
70 // may adjust them e.g. if they are using a multi-line or horizontal
71 // layout.
72 virtual void AdjustIconBounds(const AutocompleteMatch& match,
73 gfx::Rect* bounds);
74
67 // Returns the height of the text portion of the result view. In the base 75 // Returns the height of the text portion of the result view. In the base
68 // class, this is the height of one line of text. 76 // class, this is the height of one line of text.
69 virtual int GetTextHeight() const; 77 virtual int GetTextHeight() const;
70 78
71 // Draws the specified |text| into the canvas, using highlighting provided by 79 // Draws the specified |text| into the canvas, using highlighting provided by
72 // |classifications|. If |force_dim| is true, ACMatchClassification::DIM is 80 // |classifications|. If |force_dim| is true, ACMatchClassification::DIM is
73 // added to all of the classifications. Returns the x position to the right 81 // added to all of the classifications. Returns the x position to the right
74 // of the string. 82 // of the string.
75 int DrawString(gfx::Canvas* canvas, 83 int DrawString(gfx::Canvas* canvas,
76 const string16& text, 84 const string16& text,
77 const ACMatchClassifications& classifications, 85 const ACMatchClassifications& classifications,
78 bool force_dim, 86 bool force_dim,
79 int x, 87 int x,
80 int y); 88 int y);
81 89
82 const gfx::Rect& text_bounds() const { return text_bounds_; } 90 const gfx::Rect& text_bounds() const { return text_bounds_; }
83 91
92 void set_edge_item_padding(int value) { edge_item_padding_ = value; }
93 void set_item_padding(int value) { item_padding_ = value; }
94 void set_minimum_text_vertical_padding(int value) {
95 minimum_text_vertical_padding_ = value;
96 }
97
84 private: 98 private:
85 struct ClassificationData; 99 struct ClassificationData;
86 typedef std::vector<ClassificationData> Classifications; 100 typedef std::vector<ClassificationData> Classifications;
87 101
88 struct RunData; 102 struct RunData;
89 typedef std::vector<RunData> Runs; 103 typedef std::vector<RunData> Runs;
90 104
91 // Predicate functions for use when sorting the runs. 105 // Predicate functions for use when sorting the runs.
92 static bool SortRunsLogically(const RunData& lhs, const RunData& rhs); 106 static bool SortRunsLogically(const RunData& lhs, const RunData& rhs);
93 static bool SortRunsVisually(const RunData& lhs, const RunData& rhs); 107 static bool SortRunsVisually(const RunData& lhs, const RunData& rhs);
94 108
95 ResultViewState GetState() const;
96 const SkBitmap* GetIcon() const; 109 const SkBitmap* GetIcon() const;
97 const SkBitmap* GetKeywordIcon() const; 110 const SkBitmap* GetKeywordIcon() const;
98 111
99 // Elides |runs| to fit in |remaining_width|. The runs in |runs| should be in 112 // Elides |runs| to fit in |remaining_width|. The runs in |runs| should be in
100 // logical order. 113 // logical order.
101 // 114 //
102 // When we need to elide a run, the ellipsis will be placed at the end of that 115 // When we need to elide a run, the ellipsis will be placed at the end of that
103 // run. This means that if we elide a run whose visual direction is opposite 116 // run. This means that if we elide a run whose visual direction is opposite
104 // that of the drawing context, the ellipsis will not be at the "end" of the 117 // that of the drawing context, the ellipsis will not be at the "end" of the
105 // drawn string. For example, if in an LTR context we have the LTR run 118 // drawn string. For example, if in an LTR context we have the LTR run
106 // "LTR_STRING" and the RTL run "RTL_STRING", the unelided text would be drawn 119 // "LTR_STRING" and the RTL run "RTL_STRING", the unelided text would be drawn
107 // like: 120 // like:
108 // LTR_STRING GNIRTS_LTR 121 // LTR_STRING GNIRTS_LTR
109 // If we need to elide the RTL run, then it will be drawn like: 122 // If we need to elide the RTL run, then it will be drawn like:
110 // LTR_STRING ...RTS_LTR 123 // LTR_STRING ...RTS_LTR
111 // Instead of: 124 // Instead of:
112 // LTR_STRING RTS_LTR... 125 // LTR_STRING RTS_LTR...
113 void Elide(Runs* runs, int remaining_width) const; 126 void Elide(Runs* runs, int remaining_width) const;
114 127
115 // views::View: 128 // views::View:
116 virtual void Layout() OVERRIDE; 129 virtual void Layout() OVERRIDE;
117 virtual void OnBoundsChanged(const gfx::Rect& previous_bounds) OVERRIDE; 130 virtual void OnBoundsChanged(const gfx::Rect& previous_bounds) OVERRIDE;
118 virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE; 131 virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE;
119 132
120 // ui::AnimationDelegate: 133 // ui::AnimationDelegate:
121 virtual void AnimationProgressed(const ui::Animation* animation) OVERRIDE; 134 virtual void AnimationProgressed(const ui::Animation* animation) OVERRIDE;
122 135
123 static int default_icon_size_; 136 static int default_icon_size_;
124 137
138 // Default values cached here, may be overridden by subclasses.
139 int edge_item_padding_;
140 int item_padding_;
141 int minimum_text_vertical_padding_;
142
125 // This row's model and model index. 143 // This row's model and model index.
126 AutocompleteResultViewModel* model_; 144 AutocompleteResultViewModel* model_;
127 size_t model_index_; 145 size_t model_index_;
128 146
129 const gfx::Font normal_font_; 147 const gfx::Font normal_font_;
130 const gfx::Font bold_font_; 148 const gfx::Font bold_font_;
131 149
132 // Width of the ellipsis in the normal font. 150 // Width of the ellipsis in the normal font.
133 int ellipsis_width_; 151 int ellipsis_width_;
134 152
135 // A context used for mirroring regions. 153 // A context used for mirroring regions.
136 class MirroringContext; 154 class MirroringContext;
137 scoped_ptr<MirroringContext> mirroring_context_; 155 scoped_ptr<MirroringContext> mirroring_context_;
138 156
139 AutocompleteMatch match_; 157 AutocompleteMatch match_;
140 158
141 gfx::Rect text_bounds_; 159 gfx::Rect text_bounds_;
142 gfx::Rect icon_bounds_; 160 gfx::Rect icon_bounds_;
143 161
144 gfx::Rect keyword_text_bounds_; 162 gfx::Rect keyword_text_bounds_;
145 scoped_ptr<views::ImageView> keyword_icon_; 163 scoped_ptr<views::ImageView> keyword_icon_;
146 164
147 scoped_ptr<ui::SlideAnimation> animation_; 165 scoped_ptr<ui::SlideAnimation> animation_;
148 166
149 DISALLOW_COPY_AND_ASSIGN(AutocompleteResultView); 167 DISALLOW_COPY_AND_ASSIGN(AutocompleteResultView);
150 }; 168 };
151 169
152 #endif // CHROME_BROWSER_UI_VIEWS_AUTOCOMPLETE_AUTOCOMPLETE_RESULT_VIEW_H_ 170 #endif // CHROME_BROWSER_UI_VIEWS_AUTOCOMPLETE_AUTOCOMPLETE_RESULT_VIEW_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698