Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 Loading... | |
| 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 // Default values cached here, may be overridden by subclasses. | |
|
Peter Kasting
2012/05/04 23:33:31
Nit: The Google style guide says to use overrideab
Jói
2012/05/04 23:52:19
Wanted to avoid the virtual methods since these ge
Jói
2012/05/07 16:26:18
Done.
| |
| 93 int edge_item_padding_; | |
| 94 int item_padding_; | |
| 95 int minimum_text_vertical_padding_; | |
| 96 | |
| 84 private: | 97 private: |
| 85 struct ClassificationData; | 98 struct ClassificationData; |
| 86 typedef std::vector<ClassificationData> Classifications; | 99 typedef std::vector<ClassificationData> Classifications; |
| 87 | 100 |
| 88 struct RunData; | 101 struct RunData; |
| 89 typedef std::vector<RunData> Runs; | 102 typedef std::vector<RunData> Runs; |
| 90 | 103 |
| 91 // Predicate functions for use when sorting the runs. | 104 // Predicate functions for use when sorting the runs. |
| 92 static bool SortRunsLogically(const RunData& lhs, const RunData& rhs); | 105 static bool SortRunsLogically(const RunData& lhs, const RunData& rhs); |
| 93 static bool SortRunsVisually(const RunData& lhs, const RunData& rhs); | 106 static bool SortRunsVisually(const RunData& lhs, const RunData& rhs); |
| 94 | 107 |
| 95 ResultViewState GetState() const; | |
| 96 const SkBitmap* GetIcon() const; | 108 const SkBitmap* GetIcon() const; |
| 97 const SkBitmap* GetKeywordIcon() const; | 109 const SkBitmap* GetKeywordIcon() const; |
| 98 | 110 |
| 99 // Elides |runs| to fit in |remaining_width|. The runs in |runs| should be in | 111 // Elides |runs| to fit in |remaining_width|. The runs in |runs| should be in |
| 100 // logical order. | 112 // logical order. |
| 101 // | 113 // |
| 102 // When we need to elide a run, the ellipsis will be placed at the end of that | 114 // 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 | 115 // 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 | 116 // 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 | 117 // drawn string. For example, if in an LTR context we have the LTR run |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 143 | 155 |
| 144 gfx::Rect keyword_text_bounds_; | 156 gfx::Rect keyword_text_bounds_; |
| 145 scoped_ptr<views::ImageView> keyword_icon_; | 157 scoped_ptr<views::ImageView> keyword_icon_; |
| 146 | 158 |
| 147 scoped_ptr<ui::SlideAnimation> animation_; | 159 scoped_ptr<ui::SlideAnimation> animation_; |
| 148 | 160 |
| 149 DISALLOW_COPY_AND_ASSIGN(AutocompleteResultView); | 161 DISALLOW_COPY_AND_ASSIGN(AutocompleteResultView); |
| 150 }; | 162 }; |
| 151 | 163 |
| 152 #endif // CHROME_BROWSER_UI_VIEWS_AUTOCOMPLETE_AUTOCOMPLETE_RESULT_VIEW_H_ | 164 #endif // CHROME_BROWSER_UI_VIEWS_AUTOCOMPLETE_AUTOCOMPLETE_RESULT_VIEW_H_ |
| OLD | NEW |