| 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_OMNIBOX_OMNIBOX_RESULT_VIEW_H_ |
| 6 #define CHROME_BROWSER_UI_VIEWS_AUTOCOMPLETE_AUTOCOMPLETE_RESULT_VIEW_H_ | 6 #define CHROME_BROWSER_UI_VIEWS_OMNIBOX_OMNIBOX_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" |
| 11 #include "ui/base/animation/animation_delegate.h" | 11 #include "ui/base/animation/animation_delegate.h" |
| 12 #include "ui/base/animation/slide_animation.h" | 12 #include "ui/base/animation/slide_animation.h" |
| 13 #include "ui/gfx/font.h" | 13 #include "ui/gfx/font.h" |
| 14 #include "ui/gfx/rect.h" | 14 #include "ui/gfx/rect.h" |
| 15 #include "ui/views/controls/image_view.h" | 15 #include "ui/views/controls/image_view.h" |
| 16 #include "ui/views/view.h" | 16 #include "ui/views/view.h" |
| 17 | 17 |
| 18 class AutocompleteResultViewModel; | 18 class OmniboxResultViewModel; |
| 19 | 19 |
| 20 namespace gfx { | 20 namespace gfx { |
| 21 class Canvas; | 21 class Canvas; |
| 22 } | 22 } |
| 23 | 23 |
| 24 class AutocompleteResultView : public views::View, | 24 class OmniboxResultView : public views::View, |
| 25 private ui::AnimationDelegate { | 25 private ui::AnimationDelegate { |
| 26 public: | 26 public: |
| 27 // Keep these ordered from least dominant (normal) to most dominant | 27 // Keep these ordered from least dominant (normal) to most dominant |
| 28 // (selected). | 28 // (selected). |
| 29 enum ResultViewState { | 29 enum ResultViewState { |
| 30 NORMAL = 0, | 30 NORMAL = 0, |
| 31 HOVERED, | 31 HOVERED, |
| 32 SELECTED, | 32 SELECTED, |
| 33 NUM_STATES | 33 NUM_STATES |
| 34 }; | 34 }; |
| 35 | 35 |
| 36 enum ColorKind { | 36 enum ColorKind { |
| 37 BACKGROUND = 0, | 37 BACKGROUND = 0, |
| 38 TEXT, | 38 TEXT, |
| 39 DIMMED_TEXT, | 39 DIMMED_TEXT, |
| 40 URL, | 40 URL, |
| 41 DIVIDER, | 41 DIVIDER, |
| 42 NUM_KINDS | 42 NUM_KINDS |
| 43 }; | 43 }; |
| 44 | 44 |
| 45 AutocompleteResultView(AutocompleteResultViewModel* model, | 45 OmniboxResultView(OmniboxResultViewModel* model, |
| 46 int model_index, | 46 int model_index, |
| 47 const gfx::Font& font, | 47 const gfx::Font& font, |
| 48 const gfx::Font& bold_font); | 48 const gfx::Font& bold_font); |
| 49 virtual ~AutocompleteResultView(); | 49 virtual ~OmniboxResultView(); |
| 50 | 50 |
| 51 static SkColor GetColor(ResultViewState state, ColorKind kind); | 51 static SkColor GetColor(ResultViewState state, ColorKind kind); |
| 52 | 52 |
| 53 // Updates the match used to paint the contents of this result view. We copy | 53 // Updates the match used to paint the contents of this result view. We copy |
| 54 // the match so that we can continue to paint the last result even after the | 54 // the match so that we can continue to paint the last result even after the |
| 55 // model has changed. | 55 // model has changed. |
| 56 void SetMatch(const AutocompleteMatch& match); | 56 void SetMatch(const AutocompleteMatch& match); |
| 57 | 57 |
| 58 void ShowKeyword(bool show_keyword); | 58 void ShowKeyword(bool show_keyword); |
| 59 | 59 |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 131 virtual void AnimationProgressed(const ui::Animation* animation) OVERRIDE; | 131 virtual void AnimationProgressed(const ui::Animation* animation) OVERRIDE; |
| 132 | 132 |
| 133 static int default_icon_size_; | 133 static int default_icon_size_; |
| 134 | 134 |
| 135 // Default values cached here, may be overridden using the setters above. | 135 // Default values cached here, may be overridden using the setters above. |
| 136 int edge_item_padding_; | 136 int edge_item_padding_; |
| 137 int item_padding_; | 137 int item_padding_; |
| 138 int minimum_text_vertical_padding_; | 138 int minimum_text_vertical_padding_; |
| 139 | 139 |
| 140 // This row's model and model index. | 140 // This row's model and model index. |
| 141 AutocompleteResultViewModel* model_; | 141 OmniboxResultViewModel* model_; |
| 142 size_t model_index_; | 142 size_t model_index_; |
| 143 | 143 |
| 144 const gfx::Font normal_font_; | 144 const gfx::Font normal_font_; |
| 145 const gfx::Font bold_font_; | 145 const gfx::Font bold_font_; |
| 146 | 146 |
| 147 // Width of the ellipsis in the normal font. | 147 // Width of the ellipsis in the normal font. |
| 148 int ellipsis_width_; | 148 int ellipsis_width_; |
| 149 | 149 |
| 150 // A context used for mirroring regions. | 150 // A context used for mirroring regions. |
| 151 class MirroringContext; | 151 class MirroringContext; |
| 152 scoped_ptr<MirroringContext> mirroring_context_; | 152 scoped_ptr<MirroringContext> mirroring_context_; |
| 153 | 153 |
| 154 AutocompleteMatch match_; | 154 AutocompleteMatch match_; |
| 155 | 155 |
| 156 gfx::Rect text_bounds_; | 156 gfx::Rect text_bounds_; |
| 157 gfx::Rect icon_bounds_; | 157 gfx::Rect icon_bounds_; |
| 158 | 158 |
| 159 gfx::Rect keyword_text_bounds_; | 159 gfx::Rect keyword_text_bounds_; |
| 160 scoped_ptr<views::ImageView> keyword_icon_; | 160 scoped_ptr<views::ImageView> keyword_icon_; |
| 161 | 161 |
| 162 scoped_ptr<ui::SlideAnimation> animation_; | 162 scoped_ptr<ui::SlideAnimation> animation_; |
| 163 | 163 |
| 164 DISALLOW_COPY_AND_ASSIGN(AutocompleteResultView); | 164 DISALLOW_COPY_AND_ASSIGN(OmniboxResultView); |
| 165 }; | 165 }; |
| 166 | 166 |
| 167 #endif // CHROME_BROWSER_UI_VIEWS_AUTOCOMPLETE_AUTOCOMPLETE_RESULT_VIEW_H_ | 167 #endif // CHROME_BROWSER_UI_VIEWS_OMNIBOX_OMNIBOX_RESULT_VIEW_H_ |
| OLD | NEW |