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

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: Use stronger color. 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 18 matching lines...) Expand all
29 SELECTED, 29 SELECTED,
30 HOVERED, 30 HOVERED,
31 NUM_STATES 31 NUM_STATES
32 }; 32 };
33 33
34 enum ColorKind { 34 enum ColorKind {
35 BACKGROUND = 0, 35 BACKGROUND = 0,
36 TEXT, 36 TEXT,
37 DIMMED_TEXT, 37 DIMMED_TEXT,
38 URL, 38 URL,
39 DIVIDER,
39 NUM_KINDS 40 NUM_KINDS
40 }; 41 };
41 42
42 AutocompleteResultView(AutocompleteResultViewModel* model, 43 AutocompleteResultView(AutocompleteResultViewModel* model,
43 int model_index, 44 int model_index,
44 const gfx::Font& font, 45 const gfx::Font& font,
45 const gfx::Font& bold_font); 46 const gfx::Font& bold_font);
46 virtual ~AutocompleteResultView(); 47 virtual ~AutocompleteResultView();
47 48
48 static SkColor GetColor(ResultViewState state, ColorKind kind); 49 static SkColor GetColor(ResultViewState state, ColorKind kind);
49 50
50 // Updates the match used to paint the contents of this result view. We copy 51 // Updates the match used to paint the contents of this result view. We copy
51 // the match so that we can continue to paint the last result even after the 52 // the match so that we can continue to paint the last result even after the
52 // model has changed. 53 // model has changed.
53 void SetMatch(const AutocompleteMatch& match); 54 void SetMatch(const AutocompleteMatch& match);
54 55
55 void ShowKeyword(bool show_keyword); 56 void ShowKeyword(bool show_keyword);
56 57
57 void Invalidate(); 58 void Invalidate();
58 59
59 // views::View: 60 // views::View:
60 virtual gfx::Size GetPreferredSize() OVERRIDE; 61 virtual gfx::Size GetPreferredSize() OVERRIDE;
61 62
63 ResultViewState GetState() const;
64
62 protected: 65 protected:
63 virtual void PaintMatch(gfx::Canvas* canvas, 66 virtual void PaintMatch(gfx::Canvas* canvas,
64 const AutocompleteMatch& match, 67 const AutocompleteMatch& match,
65 int x); 68 int x);
66 69
67 // Returns the height of the text portion of the result view. In the base 70 // 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. 71 // class, this is the height of one line of text.
69 virtual int GetTextHeight() const; 72 virtual int GetTextHeight() const;
70 73
71 // Draws the specified |text| into the canvas, using highlighting provided by 74 // Draws the specified |text| into the canvas, using highlighting provided by
72 // |classifications|. If |force_dim| is true, ACMatchClassification::DIM is 75 // |classifications|. If |force_dim| is true, ACMatchClassification::DIM is
73 // added to all of the classifications. Returns the x position to the right 76 // added to all of the classifications. Returns the x position to the right
74 // of the string. 77 // of the string.
75 int DrawString(gfx::Canvas* canvas, 78 int DrawString(gfx::Canvas* canvas,
76 const string16& text, 79 const string16& text,
77 const ACMatchClassifications& classifications, 80 const ACMatchClassifications& classifications,
78 bool force_dim, 81 bool force_dim,
79 int x, 82 int x,
80 int y); 83 int y);
81 84
82 const gfx::Rect& text_bounds() const { return text_bounds_; } 85 const gfx::Rect& text_bounds() const { return text_bounds_; }
83 86
87 void set_edge_item_padding(int value) { edge_item_padding_ = value; }
88 void set_item_padding(int value) { item_padding_ = value; }
89 void set_minimum_text_vertical_padding(int value) {
90 minimum_text_vertical_padding_ = value;
91 }
92
84 private: 93 private:
85 struct ClassificationData; 94 struct ClassificationData;
86 typedef std::vector<ClassificationData> Classifications; 95 typedef std::vector<ClassificationData> Classifications;
87 96
88 struct RunData; 97 struct RunData;
89 typedef std::vector<RunData> Runs; 98 typedef std::vector<RunData> Runs;
90 99
91 // Predicate functions for use when sorting the runs. 100 // Predicate functions for use when sorting the runs.
92 static bool SortRunsLogically(const RunData& lhs, const RunData& rhs); 101 static bool SortRunsLogically(const RunData& lhs, const RunData& rhs);
93 static bool SortRunsVisually(const RunData& lhs, const RunData& rhs); 102 static bool SortRunsVisually(const RunData& lhs, const RunData& rhs);
94 103
95 ResultViewState GetState() const;
96 const SkBitmap* GetIcon() const; 104 const SkBitmap* GetIcon() const;
97 const SkBitmap* GetKeywordIcon() const; 105 const SkBitmap* GetKeywordIcon() const;
98 106
99 // Elides |runs| to fit in |remaining_width|. The runs in |runs| should be in 107 // Elides |runs| to fit in |remaining_width|. The runs in |runs| should be in
100 // logical order. 108 // logical order.
101 // 109 //
102 // When we need to elide a run, the ellipsis will be placed at the end of that 110 // 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 111 // 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 112 // 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 113 // 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 114 // "LTR_STRING" and the RTL run "RTL_STRING", the unelided text would be drawn
107 // like: 115 // like:
108 // LTR_STRING GNIRTS_LTR 116 // LTR_STRING GNIRTS_LTR
109 // If we need to elide the RTL run, then it will be drawn like: 117 // If we need to elide the RTL run, then it will be drawn like:
110 // LTR_STRING ...RTS_LTR 118 // LTR_STRING ...RTS_LTR
111 // Instead of: 119 // Instead of:
112 // LTR_STRING RTS_LTR... 120 // LTR_STRING RTS_LTR...
113 void Elide(Runs* runs, int remaining_width) const; 121 void Elide(Runs* runs, int remaining_width) const;
114 122
115 // views::View: 123 // views::View:
116 virtual void Layout() OVERRIDE; 124 virtual void Layout() OVERRIDE;
117 virtual void OnBoundsChanged(const gfx::Rect& previous_bounds) OVERRIDE; 125 virtual void OnBoundsChanged(const gfx::Rect& previous_bounds) OVERRIDE;
118 virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE; 126 virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE;
119 127
120 // ui::AnimationDelegate: 128 // ui::AnimationDelegate:
121 virtual void AnimationProgressed(const ui::Animation* animation) OVERRIDE; 129 virtual void AnimationProgressed(const ui::Animation* animation) OVERRIDE;
122 130
123 static int default_icon_size_; 131 static int default_icon_size_;
124 132
133 // Default values cached here, may be overridden by subclasses.
Peter Kasting 2012/05/11 23:01:41 Nit: "...may be overridden by using the setters ab
Jói 2012/05/14 18:29:45 Done.
134 int edge_item_padding_;
135 int item_padding_;
136 int minimum_text_vertical_padding_;
137
125 // This row's model and model index. 138 // This row's model and model index.
126 AutocompleteResultViewModel* model_; 139 AutocompleteResultViewModel* model_;
127 size_t model_index_; 140 size_t model_index_;
128 141
129 const gfx::Font normal_font_; 142 const gfx::Font normal_font_;
130 const gfx::Font bold_font_; 143 const gfx::Font bold_font_;
131 144
132 // Width of the ellipsis in the normal font. 145 // Width of the ellipsis in the normal font.
133 int ellipsis_width_; 146 int ellipsis_width_;
134 147
135 // A context used for mirroring regions. 148 // A context used for mirroring regions.
136 class MirroringContext; 149 class MirroringContext;
137 scoped_ptr<MirroringContext> mirroring_context_; 150 scoped_ptr<MirroringContext> mirroring_context_;
138 151
139 AutocompleteMatch match_; 152 AutocompleteMatch match_;
140 153
141 gfx::Rect text_bounds_; 154 gfx::Rect text_bounds_;
142 gfx::Rect icon_bounds_; 155 gfx::Rect icon_bounds_;
143 156
144 gfx::Rect keyword_text_bounds_; 157 gfx::Rect keyword_text_bounds_;
145 scoped_ptr<views::ImageView> keyword_icon_; 158 scoped_ptr<views::ImageView> keyword_icon_;
146 159
147 scoped_ptr<ui::SlideAnimation> animation_; 160 scoped_ptr<ui::SlideAnimation> animation_;
148 161
149 DISALLOW_COPY_AND_ASSIGN(AutocompleteResultView); 162 DISALLOW_COPY_AND_ASSIGN(AutocompleteResultView);
150 }; 163 };
151 164
152 #endif // CHROME_BROWSER_UI_VIEWS_AUTOCOMPLETE_AUTOCOMPLETE_RESULT_VIEW_H_ 165 #endif // CHROME_BROWSER_UI_VIEWS_AUTOCOMPLETE_AUTOCOMPLETE_RESULT_VIEW_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698