| 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 <stddef.h> | 8 #include <stddef.h> |
| 9 | 9 |
| 10 #include <vector> | 10 #include <vector> |
| 11 | 11 |
| 12 #include "base/macros.h" | 12 #include "base/macros.h" |
| 13 #include "components/omnibox/browser/autocomplete_match.h" | 13 #include "components/omnibox/browser/autocomplete_match.h" |
| 14 #include "components/omnibox/browser/suggestion_answer.h" | 14 #include "components/omnibox/browser/suggestion_answer.h" |
| 15 #include "third_party/skia/include/core/SkColor.h" | 15 #include "third_party/skia/include/core/SkColor.h" |
| 16 #include "ui/gfx/animation/animation_delegate.h" | 16 #include "ui/gfx/animation/animation_delegate.h" |
| 17 #include "ui/gfx/animation/slide_animation.h" | 17 #include "ui/gfx/animation/slide_animation.h" |
| 18 #include "ui/gfx/font_list.h" | 18 #include "ui/gfx/font_list.h" |
| 19 #include "ui/gfx/geometry/rect.h" | 19 #include "ui/gfx/geometry/rect.h" |
| 20 #include "ui/views/controls/image_view.h" | 20 #include "ui/views/controls/image_view.h" |
| 21 #include "ui/views/view.h" | 21 #include "ui/views/view.h" |
| 22 | 22 |
| 23 class LocationBarView; | |
| 24 class OmniboxPopupContentsView; | 23 class OmniboxPopupContentsView; |
| 25 | 24 |
| 26 namespace gfx { | 25 namespace gfx { |
| 27 class Canvas; | 26 class Canvas; |
| 28 class RenderText; | 27 class RenderText; |
| 29 } | 28 } |
| 30 | 29 |
| 31 class OmniboxResultView : public views::View, | 30 class OmniboxResultView : public views::View, |
| 32 private gfx::AnimationDelegate { | 31 private gfx::AnimationDelegate { |
| 33 public: | 32 public: |
| 34 // Keep these ordered from least dominant (normal) to most dominant | 33 // Keep these ordered from least dominant (normal) to most dominant |
| 35 // (selected). | 34 // (selected). |
| 36 enum ResultViewState { | 35 enum ResultViewState { |
| 37 NORMAL = 0, | 36 NORMAL = 0, |
| 38 HOVERED, | 37 HOVERED, |
| 39 SELECTED, | 38 SELECTED, |
| 40 NUM_STATES | 39 NUM_STATES |
| 41 }; | 40 }; |
| 42 | 41 |
| 43 enum ColorKind { | 42 enum ColorKind { |
| 44 BACKGROUND = 0, | 43 BACKGROUND = 0, |
| 45 TEXT, | 44 TEXT, |
| 46 DIMMED_TEXT, | 45 DIMMED_TEXT, |
| 47 URL, | 46 URL, |
| 48 NUM_KINDS | 47 NUM_KINDS |
| 49 }; | 48 }; |
| 50 | 49 |
| 51 OmniboxResultView(OmniboxPopupContentsView* model, | 50 OmniboxResultView(OmniboxPopupContentsView* model, |
| 52 int model_index, | 51 int model_index, |
| 53 LocationBarView* location_bar_view, | |
| 54 const gfx::FontList& font_list); | 52 const gfx::FontList& font_list); |
| 55 ~OmniboxResultView() override; | 53 ~OmniboxResultView() override; |
| 56 | 54 |
| 57 SkColor GetColor(ResultViewState state, ColorKind kind) const; | 55 SkColor GetColor(ResultViewState state, ColorKind kind) const; |
| 58 | 56 |
| 59 // Updates the match used to paint the contents of this result view. We copy | 57 // Updates the match used to paint the contents of this result view. We copy |
| 60 // the match so that we can continue to paint the last result even after the | 58 // the match so that we can continue to paint the last result even after the |
| 61 // model has changed. | 59 // model has changed. |
| 62 void SetMatch(const AutocompleteMatch& match); | 60 void SetMatch(const AutocompleteMatch& match); |
| 63 | 61 |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 126 bool force_dim) const; | 124 bool force_dim) const; |
| 127 | 125 |
| 128 const gfx::Rect& text_bounds() const { return text_bounds_; } | 126 const gfx::Rect& text_bounds() const { return text_bounds_; } |
| 129 | 127 |
| 130 private: | 128 private: |
| 131 // views::View: | 129 // views::View: |
| 132 const char* GetClassName() const override; | 130 const char* GetClassName() const override; |
| 133 | 131 |
| 134 gfx::ImageSkia GetIcon() const; | 132 gfx::ImageSkia GetIcon() const; |
| 135 | 133 |
| 136 gfx::ImageSkia GetKeywordIcon() const; | |
| 137 | |
| 138 // Utility function for creating vector icons. | 134 // Utility function for creating vector icons. |
| 139 gfx::ImageSkia GetVectorIcon(gfx::VectorIconId icon_id) const; | 135 gfx::ImageSkia GetVectorIcon(gfx::VectorIconId icon_id) const; |
| 140 | 136 |
| 141 // Whether to render only the keyword match. Returns true if |match_| has an | 137 // Whether to render only the keyword match. Returns true if |match_| has an |
| 142 // associated keyword match that has been animated so close to the start that | 138 // associated keyword match that has been animated so close to the start that |
| 143 // the keyword match will hide even the icon of the regular match. | 139 // the keyword match will hide even the icon of the regular match. |
| 144 bool ShowOnlyKeywordMatch() const; | 140 bool ShowOnlyKeywordMatch() const; |
| 145 | 141 |
| 146 // Initializes |contents_rendertext_| if it is NULL. | 142 // Initializes |contents_rendertext_| if it is NULL. |
| 147 void InitContentsRenderTextIfNecessary() const; | 143 void InitContentsRenderTextIfNecessary() const; |
| (...skipping 29 matching lines...) Expand all Loading... |
| 177 const base::string16& text, | 173 const base::string16& text, |
| 178 int text_type) const; | 174 int text_type) const; |
| 179 | 175 |
| 180 // AppendAnswerText will break up the |text| into bold and non-bold pieces | 176 // AppendAnswerText will break up the |text| into bold and non-bold pieces |
| 181 // and pass each to this helper with the correct |is_bold| value. | 177 // and pass each to this helper with the correct |is_bold| value. |
| 182 void AppendAnswerTextHelper(gfx::RenderText* destination, | 178 void AppendAnswerTextHelper(gfx::RenderText* destination, |
| 183 const base::string16& text, | 179 const base::string16& text, |
| 184 int text_type, | 180 int text_type, |
| 185 bool is_bold) const; | 181 bool is_bold) const; |
| 186 | 182 |
| 187 static int default_icon_size_; | |
| 188 | |
| 189 // This row's model and model index. | 183 // This row's model and model index. |
| 190 OmniboxPopupContentsView* model_; | 184 OmniboxPopupContentsView* model_; |
| 191 size_t model_index_; | 185 size_t model_index_; |
| 192 | 186 |
| 193 LocationBarView* location_bar_view_; | |
| 194 | |
| 195 const gfx::FontList font_list_; | 187 const gfx::FontList font_list_; |
| 196 int font_height_; | 188 int font_height_; |
| 197 | 189 |
| 198 // A context used for mirroring regions. | 190 // A context used for mirroring regions. |
| 199 class MirroringContext; | 191 class MirroringContext; |
| 200 std::unique_ptr<MirroringContext> mirroring_context_; | 192 std::unique_ptr<MirroringContext> mirroring_context_; |
| 201 | 193 |
| 202 AutocompleteMatch match_; | 194 AutocompleteMatch match_; |
| 203 | 195 |
| 204 gfx::Rect text_bounds_; | 196 gfx::Rect text_bounds_; |
| (...skipping 14 matching lines...) Expand all Loading... |
| 219 mutable std::unique_ptr<gfx::RenderText> separator_rendertext_; | 211 mutable std::unique_ptr<gfx::RenderText> separator_rendertext_; |
| 220 mutable std::unique_ptr<gfx::RenderText> keyword_contents_rendertext_; | 212 mutable std::unique_ptr<gfx::RenderText> keyword_contents_rendertext_; |
| 221 mutable std::unique_ptr<gfx::RenderText> keyword_description_rendertext_; | 213 mutable std::unique_ptr<gfx::RenderText> keyword_description_rendertext_; |
| 222 | 214 |
| 223 mutable int separator_width_; | 215 mutable int separator_width_; |
| 224 | 216 |
| 225 DISALLOW_COPY_AND_ASSIGN(OmniboxResultView); | 217 DISALLOW_COPY_AND_ASSIGN(OmniboxResultView); |
| 226 }; | 218 }; |
| 227 | 219 |
| 228 #endif // CHROME_BROWSER_UI_VIEWS_OMNIBOX_OMNIBOX_RESULT_VIEW_H_ | 220 #endif // CHROME_BROWSER_UI_VIEWS_OMNIBOX_OMNIBOX_RESULT_VIEW_H_ |
| OLD | NEW |