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

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

Issue 6731036: Enabled pressing TAB to cycle through the Omnibox results. (Closed) Base URL: http://src.chromium.org/svn/trunk/src/
Patch Set: '' Created 9 years, 4 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 <string>
10
9 #include "chrome/browser/autocomplete/autocomplete_match.h" 11 #include "chrome/browser/autocomplete/autocomplete_match.h"
10 #include "third_party/skia/include/core/SkColor.h" 12 #include "third_party/skia/include/core/SkColor.h"
11 #include "ui/gfx/font.h" 13 #include "ui/gfx/font.h"
12 #include "ui/gfx/rect.h" 14 #include "ui/gfx/rect.h"
13 #include "views/view.h" 15 #include "views/view.h"
14 16
15 class AutocompleteResultViewModel; 17 class AutocompleteResultViewModel;
16 namespace gfx { 18 namespace gfx {
17 class Canvas; 19 class Canvas;
18 } 20 }
19 21
20 class AutocompleteResultView : public views::View { 22 class AutocompleteResultView : public views::View {
21 public: 23 public:
24 // The result view's class name.
25 static const char kViewClassName[];
26
22 enum ResultViewState { 27 enum ResultViewState {
23 NORMAL = 0, 28 NORMAL = 0,
24 SELECTED, 29 SELECTED,
25 HOVERED, 30 HOVERED,
26 NUM_STATES 31 NUM_STATES
27 }; 32 };
28 33
29 enum ColorKind { 34 enum ColorKind {
30 BACKGROUND = 0, 35 BACKGROUND = 0,
31 TEXT, 36 TEXT,
32 DIMMED_TEXT, 37 DIMMED_TEXT,
33 URL, 38 URL,
34 NUM_KINDS 39 NUM_KINDS
35 }; 40 };
36 41
37 AutocompleteResultView(AutocompleteResultViewModel* model, 42 AutocompleteResultView(AutocompleteResultViewModel* model,
38 int model_index, 43 int model_index,
39 const gfx::Font& font, 44 const gfx::Font& font,
40 const gfx::Font& bold_font); 45 const gfx::Font& bold_font);
41 virtual ~AutocompleteResultView(); 46 virtual ~AutocompleteResultView();
42 47
43 static SkColor GetColor(ResultViewState state, ColorKind kind); 48 static SkColor GetColor(ResultViewState state, ColorKind kind);
44 49
45 // Updates the match used to paint the contents of this result view. We copy 50 // Updates the match used to paint the contents of this result view. We copy
46 // the match so that we can continue to paint the last result even after the 51 // the match so that we can continue to paint the last result even after the
47 // model has changed. 52 // model has changed.
48 void SetMatch(const AutocompleteMatch& match); 53 void SetMatch(const AutocompleteMatch& match);
49 54
55 // Returns the size necessary to show just the icon and an ellipsis.
56 gfx::Size GetCollapsedSize();
57
58 // views::View:
59 virtual gfx::Size GetPreferredSize() OVERRIDE;
60 virtual std::string GetClassName() const OVERRIDE;
61
50 protected: 62 protected:
51 virtual void PaintMatch(gfx::Canvas* canvas, 63 virtual void PaintMatch(gfx::Canvas* canvas,
52 const AutocompleteMatch& match, 64 const AutocompleteMatch& match,
53 int x); 65 int x);
54 66
55 // Returns the height of the text portion of the result view. In the base 67 // Returns the height of the text portion of the result view. In the base
56 // class, this is the height of one line of text. 68 // class, this is the height of one line of text.
57 virtual int GetTextHeight() const; 69 virtual int GetTextHeight() const;
58 70
59 // Draws the specified |text| into the canvas, using highlighting provided by 71 // Draws the specified |text| into the canvas, using highlighting provided by
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
93 // "LTR_STRING" and the RTL run "RTL_STRING", the unelided text would be drawn 105 // "LTR_STRING" and the RTL run "RTL_STRING", the unelided text would be drawn
94 // like: 106 // like:
95 // LTR_STRING GNIRTS_LTR 107 // LTR_STRING GNIRTS_LTR
96 // If we need to elide the RTL run, then it will be drawn like: 108 // If we need to elide the RTL run, then it will be drawn like:
97 // LTR_STRING ...RTS_LTR 109 // LTR_STRING ...RTS_LTR
98 // Instead of: 110 // Instead of:
99 // LTR_STRING RTS_LTR... 111 // LTR_STRING RTS_LTR...
100 void Elide(Runs* runs, int remaining_width) const; 112 void Elide(Runs* runs, int remaining_width) const;
101 113
102 // views::View: 114 // views::View:
103 virtual gfx::Size GetPreferredSize() OVERRIDE;
104 virtual void Layout() OVERRIDE; 115 virtual void Layout() OVERRIDE;
105 virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE; 116 virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE;
106 117
107 static int default_icon_size_; 118 static int default_icon_size_;
108 119
109 // This row's model and model index. 120 // This row's model and model index.
110 AutocompleteResultViewModel* model_; 121 AutocompleteResultViewModel* model_;
111 size_t model_index_; 122 size_t model_index_;
112 123
113 const gfx::Font normal_font_; 124 const gfx::Font normal_font_;
114 const gfx::Font bold_font_; 125 const gfx::Font bold_font_;
115 126
116 // Width of the ellipsis in the normal font. 127 // Width of the ellipsis in the normal font.
117 int ellipsis_width_; 128 int ellipsis_width_;
118 129
119 // A context used for mirroring regions. 130 // A context used for mirroring regions.
120 class MirroringContext; 131 class MirroringContext;
121 scoped_ptr<MirroringContext> mirroring_context_; 132 scoped_ptr<MirroringContext> mirroring_context_;
122 133
123 AutocompleteMatch match_; 134 AutocompleteMatch match_;
124 135
125 gfx::Rect text_bounds_; 136 gfx::Rect text_bounds_;
126 gfx::Rect icon_bounds_; 137 gfx::Rect icon_bounds_;
127 138
128 DISALLOW_COPY_AND_ASSIGN(AutocompleteResultView); 139 DISALLOW_COPY_AND_ASSIGN(AutocompleteResultView);
129 }; 140 };
130 141
131 #endif // CHROME_BROWSER_UI_VIEWS_AUTOCOMPLETE_AUTOCOMPLETE_RESULT_VIEW_H_ 142 #endif // CHROME_BROWSER_UI_VIEWS_AUTOCOMPLETE_AUTOCOMPLETE_RESULT_VIEW_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698