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

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

Issue 6349101: Create a new autocomplete popup for touch. This CL depends on (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: minor changes Created 9 years, 10 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 26 matching lines...) Expand all
37 AutocompleteResultView(AutocompleteResultViewModel* model, 37 AutocompleteResultView(AutocompleteResultViewModel* model,
38 int model_index, 38 int model_index,
39 const gfx::Font& font, 39 const gfx::Font& font,
40 const gfx::Font& bold_font); 40 const gfx::Font& bold_font);
41 virtual ~AutocompleteResultView(); 41 virtual ~AutocompleteResultView();
42 42
43 // Updates the match used to paint the contents of this result view. We copy 43 // Updates the match used to paint the contents of this result view. We copy
44 // the match so that we can continue to paint the last result even after the 44 // the match so that we can continue to paint the last result even after the
45 // model has changed. 45 // model has changed.
46 void set_match(const AutocompleteMatch& match) { match_ = match; } 46 void set_match(const AutocompleteMatch& match) { match_ = match; }
47 const gfx::Font& normal_font() const { return normal_font_; }
48 const gfx::Font& bold_font() const { return bold_font_; }
49 const gfx::Rect& text_bounds() const { return text_bounds_; }
50 void set_text_bounds(const gfx::Rect& tb) { text_bounds_ = tb; }
47 51
48 // Overridden from views::View: 52 // Overridden from views::View:
49 virtual void OnPaint(gfx::Canvas* canvas); 53 virtual void OnPaint(gfx::Canvas* canvas);
50 virtual void Layout(); 54 virtual void Layout();
51 virtual gfx::Size GetPreferredSize(); 55 virtual gfx::Size GetPreferredSize();
52 56
53 // Returns the preferred height for a single row. 57 // Returns the preferred height for a single row.
54 int GetPreferredHeight(const gfx::Font& font, 58 int GetPreferredHeight(const gfx::Font& font,
55 const gfx::Font& bold_font); 59 const gfx::Font& bold_font);
56 static SkColor GetColor(ResultViewState state, ColorKind kind); 60 static SkColor GetColor(ResultViewState state, ColorKind kind);
61 static int icon_size() { return icon_size_; }
57 62
58 protected: 63 protected:
59 virtual void PaintMatch(gfx::Canvas* canvas, 64 virtual void PaintMatch(gfx::Canvas* canvas,
60 const AutocompleteMatch& match, 65 const AutocompleteMatch& match,
61 int x); 66 int x);
62 67
68 // Draws the specified |text| into the canvas, using highlighting provided by
69 // |classifications|. If |force_dim| is true, ACMatchClassification::DIM is
70 // added to all of the classifications. Returns the x position to the right
71 // of the string.
72 int DrawString(gfx::Canvas* canvas,
73 const string16& text,
74 const ACMatchClassifications& classifications,
75 bool force_dim,
76 int x,
77 int y);
78
63 int icon_vertical_padding_; 79 int icon_vertical_padding_;
64 int text_vertical_padding_; 80 int text_vertical_padding_;
65 81
66 private: 82 private:
67 // Precalculated data used to draw the portion of a match classification that 83 // Precalculated data used to draw the portion of a match classification that
68 // fits entirely within one run. 84 // fits entirely within one run.
69 struct ClassificationData { 85 struct ClassificationData {
70 string16 text; 86 string16 text;
71 const gfx::Font* font; 87 const gfx::Font* font;
72 SkColor color; 88 SkColor color;
(...skipping 12 matching lines...) Expand all
85 int pixel_width; 101 int pixel_width;
86 Classifications classifications; // Classification pieces within this run, 102 Classifications classifications; // Classification pieces within this run,
87 // in logical order. 103 // in logical order.
88 }; 104 };
89 typedef std::vector<RunData> Runs; 105 typedef std::vector<RunData> Runs;
90 106
91 // Predicate functions for use when sorting the runs. 107 // Predicate functions for use when sorting the runs.
92 static bool SortRunsLogically(const RunData& lhs, const RunData& rhs); 108 static bool SortRunsLogically(const RunData& lhs, const RunData& rhs);
93 static bool SortRunsVisually(const RunData& lhs, const RunData& rhs); 109 static bool SortRunsVisually(const RunData& lhs, const RunData& rhs);
94 110
111 static int icon_size_;
112
95 ResultViewState GetState() const; 113 ResultViewState GetState() const;
96 114
97 const SkBitmap* GetIcon() const; 115 const SkBitmap* GetIcon() const;
98 116
99 // Draws the specified |text| into the canvas, using highlighting provided by
100 // |classifications|. If |force_dim| is true, ACMatchClassification::DIM is
101 // added to all of the classifications. Returns the x position to the right
102 // of the string.
103 int DrawString(gfx::Canvas* canvas,
104 const string16& text,
105 const ACMatchClassifications& classifications,
106 bool force_dim,
107 int x,
108 int y);
109
110 // Elides |runs| to fit in |remaining_width|. The runs in |runs| should be in 117 // Elides |runs| to fit in |remaining_width|. The runs in |runs| should be in
111 // logical order. 118 // logical order.
112 // 119 //
113 // When we need to elide a run, the ellipsis will be placed at the end of that 120 // When we need to elide a run, the ellipsis will be placed at the end of that
114 // run. This means that if we elide a run whose visual direction is opposite 121 // run. This means that if we elide a run whose visual direction is opposite
115 // that of the drawing context, the ellipsis will not be at the "end" of the 122 // that of the drawing context, the ellipsis will not be at the "end" of the
116 // drawn string. For example, if in an LTR context we have the LTR run 123 // drawn string. For example, if in an LTR context we have the LTR run
117 // "LTR_STRING" and the RTL run "RTL_STRING", the unelided text would be drawn 124 // "LTR_STRING" and the RTL run "RTL_STRING", the unelided text would be drawn
118 // like: 125 // like:
119 // LTR_STRING GNIRTS_LTR 126 // LTR_STRING GNIRTS_LTR
(...skipping 14 matching lines...) Expand all
134 int ellipsis_width_; 141 int ellipsis_width_;
135 142
136 // A context used for mirroring regions. 143 // A context used for mirroring regions.
137 class MirroringContext; 144 class MirroringContext;
138 scoped_ptr<MirroringContext> mirroring_context_; 145 scoped_ptr<MirroringContext> mirroring_context_;
139 146
140 // Layout rects for various sub-components of the view. 147 // Layout rects for various sub-components of the view.
141 gfx::Rect icon_bounds_; 148 gfx::Rect icon_bounds_;
142 gfx::Rect text_bounds_; 149 gfx::Rect text_bounds_;
143 150
144 static int icon_size_;
145
146 AutocompleteMatch match_; 151 AutocompleteMatch match_;
147 152
148 DISALLOW_COPY_AND_ASSIGN(AutocompleteResultView); 153 DISALLOW_COPY_AND_ASSIGN(AutocompleteResultView);
149 }; 154 };
150 155
151 #endif // CHROME_BROWSER_UI_VIEWS_AUTOCOMPLETE_AUTOCOMPLETE_RESULT_VIEW_H_ 156 #endif // CHROME_BROWSER_UI_VIEWS_AUTOCOMPLETE_AUTOCOMPLETE_RESULT_VIEW_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698