Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 "base/memory/ref_counted.h" | |
| 9 #include "chrome/browser/autocomplete/autocomplete_match.h" | 10 #include "chrome/browser/autocomplete/autocomplete_match.h" |
| 10 #include "third_party/skia/include/core/SkColor.h" | 11 #include "third_party/skia/include/core/SkColor.h" |
| 12 #include "ui/base/animation/animation_delegate.h" | |
| 13 #include "ui/base/animation/slide_animation.h" | |
| 11 #include "ui/gfx/font.h" | 14 #include "ui/gfx/font.h" |
| 12 #include "ui/gfx/rect.h" | 15 #include "ui/gfx/rect.h" |
| 13 #include "views/view.h" | 16 #include "views/view.h" |
| 14 | 17 |
| 15 class AutocompleteResultViewModel; | 18 class AutocompleteResultViewModel; |
| 16 namespace gfx { | 19 namespace gfx { |
| 17 class Canvas; | 20 class Canvas; |
| 18 } | 21 } |
| 19 | 22 |
| 20 class AutocompleteResultView : public views::View { | 23 class AutocompleteResultView : public views::View, |
| 24 private ui::AnimationDelegate { | |
| 21 public: | 25 public: |
| 22 enum ResultViewState { | 26 enum ResultViewState { |
| 23 NORMAL = 0, | 27 NORMAL = 0, |
| 24 SELECTED, | 28 SELECTED, |
| 25 HOVERED, | 29 HOVERED, |
| 26 NUM_STATES | 30 NUM_STATES |
| 27 }; | 31 }; |
| 28 | 32 |
| 29 enum ColorKind { | 33 enum ColorKind { |
| 30 BACKGROUND = 0, | 34 BACKGROUND = 0, |
| 31 TEXT, | 35 TEXT, |
| 32 DIMMED_TEXT, | 36 DIMMED_TEXT, |
| 33 URL, | 37 URL, |
| 34 NUM_KINDS | 38 NUM_KINDS |
| 35 }; | 39 }; |
| 36 | 40 |
| 37 AutocompleteResultView(AutocompleteResultViewModel* model, | 41 AutocompleteResultView(AutocompleteResultViewModel* model, |
| 38 int model_index, | 42 int model_index, |
| 39 const gfx::Font& font, | 43 const gfx::Font& font, |
| 40 const gfx::Font& bold_font); | 44 const gfx::Font& bold_font); |
| 41 virtual ~AutocompleteResultView(); | 45 virtual ~AutocompleteResultView(); |
| 42 | 46 |
| 43 // Updates the match used to paint the contents of this result view. We copy | 47 // Updates the match used to paint the contents of this result view. We copy |
| 44 // the match so that we can continue to paint the last result even after the | 48 // the match so that we can continue to paint the last result even after the |
| 45 // model has changed. | 49 // model has changed. |
| 46 void set_match(const AutocompleteMatch& match) { match_ = match; } | 50 void SetMatch(const AutocompleteMatch& match); |
| 47 const gfx::Font& normal_font() const { return normal_font_; } | 51 const gfx::Font& normal_font() const { return normal_font_; } |
| 48 const gfx::Font& bold_font() const { return bold_font_; } | 52 const gfx::Font& bold_font() const { return bold_font_; } |
| 49 const gfx::Rect& text_bounds() const { return text_bounds_; } | 53 const gfx::Rect& text_bounds() const { return text_bounds_; } |
| 50 void set_text_bounds(const gfx::Rect& tb) { text_bounds_ = tb; } | 54 void set_text_bounds(const gfx::Rect& tb) { text_bounds_ = tb; } |
| 51 | 55 |
| 52 // Overridden from views::View: | 56 // Overridden from views::View: |
| 53 virtual void OnPaint(gfx::Canvas* canvas); | 57 virtual void OnPaint(gfx::Canvas* canvas); |
| 54 virtual void Layout(); | 58 virtual void Layout(); |
| 55 virtual gfx::Size GetPreferredSize(); | 59 virtual gfx::Size GetPreferredSize(); |
| 56 | 60 |
| (...skipping 15 matching lines...) Expand all Loading... | |
| 72 int DrawString(gfx::Canvas* canvas, | 76 int DrawString(gfx::Canvas* canvas, |
| 73 const string16& text, | 77 const string16& text, |
| 74 const ACMatchClassifications& classifications, | 78 const ACMatchClassifications& classifications, |
| 75 bool force_dim, | 79 bool force_dim, |
| 76 int x, | 80 int x, |
| 77 int y); | 81 int y); |
| 78 | 82 |
| 79 int icon_vertical_padding_; | 83 int icon_vertical_padding_; |
| 80 int text_vertical_padding_; | 84 int text_vertical_padding_; |
| 81 | 85 |
| 86 // ui::AnimationDelegate: | |
| 87 virtual void AnimationProgressed(const ui::Animation* animation) OVERRIDE; | |
| 88 virtual void AnimationCanceled(const ui::Animation* animation) OVERRIDE; | |
|
Peter Kasting
2011/04/11 23:17:33
You want to override AnimationEnded(), not Animati
| |
| 89 | |
| 82 private: | 90 private: |
| 83 struct ClassificationData; | 91 struct ClassificationData; |
| 84 typedef std::vector<ClassificationData> Classifications; | 92 typedef std::vector<ClassificationData> Classifications; |
| 85 | 93 |
| 86 struct RunData; | 94 struct RunData; |
| 87 typedef std::vector<RunData> Runs; | 95 typedef std::vector<RunData> Runs; |
| 88 | 96 |
| 89 // Predicate functions for use when sorting the runs. | 97 // Predicate functions for use when sorting the runs. |
| 90 static bool SortRunsLogically(const RunData& lhs, const RunData& rhs); | 98 static bool SortRunsLogically(const RunData& lhs, const RunData& rhs); |
| 91 static bool SortRunsVisually(const RunData& lhs, const RunData& rhs); | 99 static bool SortRunsVisually(const RunData& lhs, const RunData& rhs); |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 123 int ellipsis_width_; | 131 int ellipsis_width_; |
| 124 | 132 |
| 125 // A context used for mirroring regions. | 133 // A context used for mirroring regions. |
| 126 class MirroringContext; | 134 class MirroringContext; |
| 127 scoped_ptr<MirroringContext> mirroring_context_; | 135 scoped_ptr<MirroringContext> mirroring_context_; |
| 128 | 136 |
| 129 // Layout rects for various sub-components of the view. | 137 // Layout rects for various sub-components of the view. |
| 130 gfx::Rect icon_bounds_; | 138 gfx::Rect icon_bounds_; |
| 131 gfx::Rect text_bounds_; | 139 gfx::Rect text_bounds_; |
| 132 | 140 |
| 141 class IconLabelView; | |
| 142 scoped_ptr<IconLabelView> search_view_; | |
| 143 | |
| 133 AutocompleteMatch match_; | 144 AutocompleteMatch match_; |
| 145 scoped_refptr<AutocompleteMatch::Keyword> keyword_; | |
| 146 | |
| 147 scoped_ptr<ui::SlideAnimation> animation_; | |
| 148 | |
| 149 bool search_expanded_; | |
| 134 | 150 |
| 135 DISALLOW_COPY_AND_ASSIGN(AutocompleteResultView); | 151 DISALLOW_COPY_AND_ASSIGN(AutocompleteResultView); |
| 136 }; | 152 }; |
| 137 | 153 |
| 138 #endif // CHROME_BROWSER_UI_VIEWS_AUTOCOMPLETE_AUTOCOMPLETE_RESULT_VIEW_H_ | 154 #endif // CHROME_BROWSER_UI_VIEWS_AUTOCOMPLETE_AUTOCOMPLETE_RESULT_VIEW_H_ |
| OLD | NEW |