| 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_POPUP_CONTENTS_VIEW_H_ | 5 #ifndef CHROME_BROWSER_UI_VIEWS_AUTOCOMPLETE_AUTOCOMPLETE_POPUP_CONTENTS_VIEW_H_ |
| 6 #define CHROME_BROWSER_UI_VIEWS_AUTOCOMPLETE_AUTOCOMPLETE_POPUP_CONTENTS_VIEW_H_ | 6 #define CHROME_BROWSER_UI_VIEWS_AUTOCOMPLETE_AUTOCOMPLETE_POPUP_CONTENTS_VIEW_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include "chrome/browser/autocomplete/autocomplete.h" | 9 #include "chrome/browser/autocomplete/autocomplete.h" |
| 10 #include "chrome/browser/autocomplete/autocomplete_popup_model.h" | 10 #include "chrome/browser/autocomplete/autocomplete_popup_model.h" |
| (...skipping 12 matching lines...) Expand all Loading... |
| 23 #endif | 23 #endif |
| 24 | 24 |
| 25 class AutocompleteEditModel; | 25 class AutocompleteEditModel; |
| 26 class AutocompleteEditViewWin; | 26 class AutocompleteEditViewWin; |
| 27 struct AutocompleteMatch; | 27 struct AutocompleteMatch; |
| 28 class AutocompleteResultView; | 28 class AutocompleteResultView; |
| 29 class BubbleBorder; | 29 class BubbleBorder; |
| 30 class Profile; | 30 class Profile; |
| 31 | 31 |
| 32 namespace gfx { | 32 namespace gfx { |
| 33 class CanvasSkia; |
| 33 class Insets; | 34 class Insets; |
| 34 } | 35 } |
| 35 | 36 |
| 36 // A view representing the contents of the autocomplete popup. | 37 // A view representing the contents of the autocomplete popup. |
| 37 class AutocompletePopupContentsView : public views::View, | 38 class AutocompletePopupContentsView : public views::View, |
| 38 public AutocompleteResultViewModel, | 39 public AutocompleteResultViewModel, |
| 39 public AutocompletePopupView, | 40 public AutocompletePopupView, |
| 40 public ui::AnimationDelegate { | 41 public ui::AnimationDelegate { |
| 41 public: | 42 public: |
| 42 AutocompletePopupContentsView(const gfx::Font& font, | 43 AutocompletePopupContentsView(const gfx::Font& font, |
| (...skipping 18 matching lines...) Expand all Loading... |
| 61 // Overridden from AutocompleteResultViewModel: | 62 // Overridden from AutocompleteResultViewModel: |
| 62 virtual bool IsSelectedIndex(size_t index) const; | 63 virtual bool IsSelectedIndex(size_t index) const; |
| 63 virtual bool IsHoveredIndex(size_t index) const; | 64 virtual bool IsHoveredIndex(size_t index) const; |
| 64 virtual const SkBitmap* GetSpecialIcon(size_t index) const; | 65 virtual const SkBitmap* GetSpecialIcon(size_t index) const; |
| 65 | 66 |
| 66 // Overridden from ui::AnimationDelegate: | 67 // Overridden from ui::AnimationDelegate: |
| 67 virtual void AnimationProgressed(const ui::Animation* animation); | 68 virtual void AnimationProgressed(const ui::Animation* animation); |
| 68 | 69 |
| 69 // Overridden from views::View: | 70 // Overridden from views::View: |
| 70 virtual void OnPaint(gfx::Canvas* canvas); | 71 virtual void OnPaint(gfx::Canvas* canvas); |
| 71 virtual void PaintChildren(gfx::Canvas* canvas) { | 72 virtual void PaintChildren(gfx::CanvasSkia* canvas); |
| 72 // We paint our children inside OnPaint(). | |
| 73 } | |
| 74 virtual void Layout(); | 73 virtual void Layout(); |
| 74 virtual void LayoutChildren(); |
| 75 virtual void OnMouseEntered(const views::MouseEvent& event); | 75 virtual void OnMouseEntered(const views::MouseEvent& event); |
| 76 virtual void OnMouseMoved(const views::MouseEvent& event); | 76 virtual void OnMouseMoved(const views::MouseEvent& event); |
| 77 virtual void OnMouseExited(const views::MouseEvent& event); | 77 virtual void OnMouseExited(const views::MouseEvent& event); |
| 78 virtual bool OnMousePressed(const views::MouseEvent& event); | 78 virtual bool OnMousePressed(const views::MouseEvent& event); |
| 79 virtual void OnMouseReleased(const views::MouseEvent& event, bool canceled); | 79 virtual void OnMouseReleased(const views::MouseEvent& event, bool canceled); |
| 80 virtual bool OnMouseDragged(const views::MouseEvent& event); | 80 virtual bool OnMouseDragged(const views::MouseEvent& event); |
| 81 virtual views::View* GetViewForPoint(const gfx::Point& point); | 81 virtual views::View* GetViewForPoint(const gfx::Point& point); |
| 82 | 82 |
| 83 protected: | 83 protected: |
| 84 // Calculates the height needed to show all the results in the model. | 84 // Calculates the height needed to show all the results in the model. |
| 85 virtual int CalculatePopupHeight(); | 85 virtual int CalculatePopupHeight(); |
| 86 virtual AutocompleteResultView* CreateResultView( | 86 virtual AutocompleteResultView* CreateResultView( |
| 87 AutocompleteResultViewModel* model, | 87 AutocompleteResultViewModel* model, |
| 88 int model_index, | 88 int model_index, |
| 89 const gfx::Font& font, | 89 const gfx::Font& font, |
| 90 const gfx::Font& bold_font); | 90 const gfx::Font& bold_font); |
| 91 | 91 |
| 92 scoped_ptr<AutocompletePopupModel> model_; |
| 93 |
| 94 // The "Opt-in to Instant" promo view, if there is one. |
| 95 views::View* opt_in_view_; |
| 96 |
| 92 private: | 97 private: |
| 93 #if defined(OS_WIN) | 98 #if defined(OS_WIN) |
| 94 typedef AutocompletePopupWin AutocompletePopupClass; | 99 typedef AutocompletePopupWin AutocompletePopupClass; |
| 95 #else | 100 #else |
| 96 typedef AutocompletePopupGtk AutocompletePopupClass; | 101 typedef AutocompletePopupGtk AutocompletePopupClass; |
| 97 #endif | 102 #endif |
| 98 class InstantOptInView; | 103 class InstantOptInView; |
| 99 | 104 |
| 100 // Returns true if the model has a match at the specified index. | 105 // Returns true if the model has a match at the specified index. |
| 101 bool HasMatchAt(size_t index) const; | 106 bool HasMatchAt(size_t index) const; |
| (...skipping 26 matching lines...) Expand all Loading... |
| 128 // Invoked if the user clicks on one of the opt-in buttons. Removes the opt-in | 133 // Invoked if the user clicks on one of the opt-in buttons. Removes the opt-in |
| 129 // view. | 134 // view. |
| 130 void UserPressedOptIn(bool opt_in); | 135 void UserPressedOptIn(bool opt_in); |
| 131 | 136 |
| 132 // The popup that contains this view. We create this, but it deletes itself | 137 // The popup that contains this view. We create this, but it deletes itself |
| 133 // when its window is destroyed. This is a WeakPtr because it's possible for | 138 // when its window is destroyed. This is a WeakPtr because it's possible for |
| 134 // the OS to destroy the window and thus delete this object before we're | 139 // the OS to destroy the window and thus delete this object before we're |
| 135 // deleted, or without our knowledge. | 140 // deleted, or without our knowledge. |
| 136 base::WeakPtr<AutocompletePopupClass> popup_; | 141 base::WeakPtr<AutocompletePopupClass> popup_; |
| 137 | 142 |
| 138 // The provider of our result set. | |
| 139 scoped_ptr<AutocompletePopupModel> model_; | |
| 140 | |
| 141 // The edit view that invokes us. | 143 // The edit view that invokes us. |
| 142 AutocompleteEditView* edit_view_; | 144 AutocompleteEditView* edit_view_; |
| 143 | 145 |
| 144 // An object that the popup positions itself against. | 146 // An object that the popup positions itself against. |
| 145 const views::View* location_bar_; | 147 const views::View* location_bar_; |
| 146 | 148 |
| 147 // Our border, which can compute our desired bounds. | 149 // Our border, which can compute our desired bounds. |
| 148 const BubbleBorder* bubble_border_; | 150 const BubbleBorder* bubble_border_; |
| 149 | 151 |
| 150 // The font that we should use for result rows. This is based on the font used | 152 // The font that we should use for result rows. This is based on the font used |
| (...skipping 10 matching lines...) Expand all Loading... |
| 161 // flag is reset to false on a mouse pressed event, to make sure we don't | 163 // flag is reset to false on a mouse pressed event, to make sure we don't |
| 162 // erroneously ignore the next drag. | 164 // erroneously ignore the next drag. |
| 163 bool ignore_mouse_drag_; | 165 bool ignore_mouse_drag_; |
| 164 | 166 |
| 165 // The popup sizes vertically using an animation when the popup is getting | 167 // The popup sizes vertically using an animation when the popup is getting |
| 166 // shorter (not larger, that makes it look "slow"). | 168 // shorter (not larger, that makes it look "slow"). |
| 167 ui::SlideAnimation size_animation_; | 169 ui::SlideAnimation size_animation_; |
| 168 gfx::Rect start_bounds_; | 170 gfx::Rect start_bounds_; |
| 169 gfx::Rect target_bounds_; | 171 gfx::Rect target_bounds_; |
| 170 | 172 |
| 171 // If non-NULL the instant opt-in-view is visible. | |
| 172 views::View* opt_in_view_; | |
| 173 | |
| 174 DISALLOW_COPY_AND_ASSIGN(AutocompletePopupContentsView); | 173 DISALLOW_COPY_AND_ASSIGN(AutocompletePopupContentsView); |
| 175 }; | 174 }; |
| 176 | 175 |
| 177 #endif // CHROME_BROWSER_UI_VIEWS_AUTOCOMPLETE_AUTOCOMPLETE_POPUP_CONTENTS_VIEW
_H_ | 176 #endif // CHROME_BROWSER_UI_VIEWS_AUTOCOMPLETE_AUTOCOMPLETE_POPUP_CONTENTS_VIEW
_H_ |
| OLD | NEW |