| 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_OMNIBOX_OMNIBOX_RESULT_VIEW_H_ | 5 #ifndef CHROME_BROWSER_UI_VIEWS_OMNIBOX_OMNIBOX_RESULT_VIEW_H_ |
| 6 #define CHROME_BROWSER_UI_VIEWS_OMNIBOX_OMNIBOX_RESULT_VIEW_H_ | 6 #define CHROME_BROWSER_UI_VIEWS_OMNIBOX_OMNIBOX_RESULT_VIEW_H_ |
| 7 | 7 |
| 8 #include <vector> |
| 9 |
| 8 #include "chrome/browser/autocomplete/autocomplete_match.h" | 10 #include "chrome/browser/autocomplete/autocomplete_match.h" |
| 9 #include "third_party/skia/include/core/SkColor.h" | 11 #include "third_party/skia/include/core/SkColor.h" |
| 10 #include "ui/base/animation/animation_delegate.h" | 12 #include "ui/base/animation/animation_delegate.h" |
| 11 #include "ui/base/animation/slide_animation.h" | 13 #include "ui/base/animation/slide_animation.h" |
| 12 #include "ui/gfx/font.h" | 14 #include "ui/gfx/font.h" |
| 13 #include "ui/gfx/rect.h" | 15 #include "ui/gfx/rect.h" |
| 14 #include "ui/views/controls/image_view.h" | 16 #include "ui/views/controls/image_view.h" |
| 15 #include "ui/views/view.h" | 17 #include "ui/views/view.h" |
| 16 | 18 |
| 17 class OmniboxResultViewModel; | 19 class OmniboxResultViewModel; |
| 18 | 20 |
| 19 namespace gfx { | 21 namespace gfx { |
| 20 class Canvas; | 22 class Canvas; |
| 23 class RenderText; |
| 21 } | 24 } |
| 22 | 25 |
| 23 class OmniboxResultView : public views::View, | 26 class OmniboxResultView : public views::View, |
| 24 private ui::AnimationDelegate { | 27 private ui::AnimationDelegate { |
| 25 public: | 28 public: |
| 26 // Keep these ordered from least dominant (normal) to most dominant | 29 // Keep these ordered from least dominant (normal) to most dominant |
| 27 // (selected). | 30 // (selected). |
| 28 enum ResultViewState { | 31 enum ResultViewState { |
| 29 NORMAL = 0, | 32 NORMAL = 0, |
| 30 HOVERED, | 33 HOVERED, |
| 31 SELECTED, | 34 SELECTED, |
| 32 NUM_STATES | 35 NUM_STATES |
| 33 }; | 36 }; |
| 34 | 37 |
| 35 enum ColorKind { | 38 enum ColorKind { |
| 36 BACKGROUND = 0, | 39 BACKGROUND = 0, |
| 37 TEXT, | 40 TEXT, |
| 38 DIMMED_TEXT, | 41 DIMMED_TEXT, |
| 39 URL, | 42 URL, |
| 40 DIVIDER, | 43 DIVIDER, |
| 41 NUM_KINDS | 44 NUM_KINDS |
| 42 }; | 45 }; |
| 43 | 46 |
| 44 OmniboxResultView(OmniboxResultViewModel* model, | 47 OmniboxResultView(OmniboxResultViewModel* model, |
| 45 int model_index, | 48 int model_index, |
| 46 const gfx::Font& font, | 49 const gfx::Font& font); |
| 47 const gfx::Font& bold_font); | |
| 48 virtual ~OmniboxResultView(); | 50 virtual ~OmniboxResultView(); |
| 49 | 51 |
| 50 SkColor GetColor(ResultViewState state, ColorKind kind) const; | 52 SkColor GetColor(ResultViewState state, ColorKind kind) const; |
| 51 | 53 |
| 52 // Updates the match used to paint the contents of this result view. We copy | 54 // Updates the match used to paint the contents of this result view. We copy |
| 53 // the match so that we can continue to paint the last result even after the | 55 // the match so that we can continue to paint the last result even after the |
| 54 // model has changed. | 56 // model has changed. |
| 55 void SetMatch(const AutocompleteMatch& match); | 57 void SetMatch(const AutocompleteMatch& match); |
| 56 | 58 |
| 57 void ShowKeyword(bool show_keyword); | 59 void ShowKeyword(bool show_keyword); |
| (...skipping 27 matching lines...) Expand all Loading... |
| 85 | 87 |
| 86 const gfx::Rect& text_bounds() const { return text_bounds_; } | 88 const gfx::Rect& text_bounds() const { return text_bounds_; } |
| 87 | 89 |
| 88 void set_edge_item_padding(int value) { edge_item_padding_ = value; } | 90 void set_edge_item_padding(int value) { edge_item_padding_ = value; } |
| 89 void set_item_padding(int value) { item_padding_ = value; } | 91 void set_item_padding(int value) { item_padding_ = value; } |
| 90 void set_minimum_text_vertical_padding(int value) { | 92 void set_minimum_text_vertical_padding(int value) { |
| 91 minimum_text_vertical_padding_ = value; | 93 minimum_text_vertical_padding_ = value; |
| 92 } | 94 } |
| 93 | 95 |
| 94 private: | 96 private: |
| 95 struct ClassificationData; | |
| 96 typedef std::vector<ClassificationData> Classifications; | |
| 97 | |
| 98 struct RunData; | 97 struct RunData; |
| 99 typedef std::vector<RunData> Runs; | 98 typedef std::vector<RunData> Runs; |
| 99 typedef std::vector<gfx::RenderText*> Classifications; |
| 100 | 100 |
| 101 // Common initialization code of the colors returned by GetColors(). | 101 // Common initialization code of the colors returned by GetColors(). |
| 102 static void CommonInitColors(const ui::NativeTheme* theme, | 102 static void CommonInitColors(const ui::NativeTheme* theme, |
| 103 SkColor colors[][NUM_KINDS]); | 103 SkColor colors[][NUM_KINDS]); |
| 104 | 104 |
| 105 // Predicate functions for use when sorting the runs. | 105 // Predicate functions for use when sorting the runs. |
| 106 static bool SortRunsLogically(const RunData& lhs, const RunData& rhs); | 106 static bool SortRunsLogically(const RunData& lhs, const RunData& rhs); |
| 107 static bool SortRunsVisually(const RunData& lhs, const RunData& rhs); | 107 static bool SortRunsVisually(const RunData& lhs, const RunData& rhs); |
| 108 | 108 |
| 109 gfx::ImageSkia GetIcon() const; | 109 gfx::ImageSkia GetIcon() const; |
| (...skipping 27 matching lines...) Expand all Loading... |
| 137 | 137 |
| 138 // Default values cached here, may be overridden using the setters above. | 138 // Default values cached here, may be overridden using the setters above. |
| 139 int edge_item_padding_; | 139 int edge_item_padding_; |
| 140 int item_padding_; | 140 int item_padding_; |
| 141 int minimum_text_vertical_padding_; | 141 int minimum_text_vertical_padding_; |
| 142 | 142 |
| 143 // This row's model and model index. | 143 // This row's model and model index. |
| 144 OmniboxResultViewModel* model_; | 144 OmniboxResultViewModel* model_; |
| 145 size_t model_index_; | 145 size_t model_index_; |
| 146 | 146 |
| 147 const gfx::Font normal_font_; | 147 const gfx::Font font_; |
| 148 const gfx::Font bold_font_; | 148 int font_height_; |
| 149 | 149 |
| 150 // Width of the ellipsis in the normal font. | 150 // Width of the ellipsis in the normal font. |
| 151 int ellipsis_width_; | 151 int ellipsis_width_; |
| 152 | 152 |
| 153 // A context used for mirroring regions. | 153 // A context used for mirroring regions. |
| 154 class MirroringContext; | 154 class MirroringContext; |
| 155 scoped_ptr<MirroringContext> mirroring_context_; | 155 scoped_ptr<MirroringContext> mirroring_context_; |
| 156 | 156 |
| 157 AutocompleteMatch match_; | 157 AutocompleteMatch match_; |
| 158 | 158 |
| 159 gfx::Rect text_bounds_; | 159 gfx::Rect text_bounds_; |
| 160 gfx::Rect icon_bounds_; | 160 gfx::Rect icon_bounds_; |
| 161 | 161 |
| 162 gfx::Rect keyword_text_bounds_; | 162 gfx::Rect keyword_text_bounds_; |
| 163 scoped_ptr<views::ImageView> keyword_icon_; | 163 scoped_ptr<views::ImageView> keyword_icon_; |
| 164 | 164 |
| 165 scoped_ptr<ui::SlideAnimation> animation_; | 165 scoped_ptr<ui::SlideAnimation> animation_; |
| 166 | 166 |
| 167 DISALLOW_COPY_AND_ASSIGN(OmniboxResultView); | 167 DISALLOW_COPY_AND_ASSIGN(OmniboxResultView); |
| 168 }; | 168 }; |
| 169 | 169 |
| 170 #endif // CHROME_BROWSER_UI_VIEWS_OMNIBOX_OMNIBOX_RESULT_VIEW_H_ | 170 #endif // CHROME_BROWSER_UI_VIEWS_OMNIBOX_OMNIBOX_RESULT_VIEW_H_ |
| OLD | NEW |