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_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" |
| 11 #include "chrome/browser/autocomplete/autocomplete_popup_view.h" | 11 #include "chrome/browser/autocomplete/autocomplete_popup_view.h" |
| 12 #include "chrome/browser/ui/views/autocomplete/autocomplete_result_view_model.h" | 12 #include "chrome/browser/ui/views/autocomplete/autocomplete_result_view_model.h" |
| 13 #include "ui/base/animation/animation_delegate.h" | 13 #include "ui/base/animation/animation_delegate.h" |
| 14 #include "ui/base/animation/slide_animation.h" | 14 #include "ui/base/animation/slide_animation.h" |
| 15 #include "ui/gfx/canvas_skia.h" | |
|
oshima
2011/02/16 20:00:27
isn't forward decl enough?
varunjain
2011/02/16 23:12:37
Done.
| |
| 15 #include "ui/gfx/font.h" | 16 #include "ui/gfx/font.h" |
| 16 #include "views/view.h" | 17 #include "views/view.h" |
| 17 #include "webkit/glue/window_open_disposition.h" | 18 #include "webkit/glue/window_open_disposition.h" |
| 18 | 19 |
| 19 #if defined(OS_WIN) | 20 #if defined(OS_WIN) |
| 20 #include "chrome/browser/ui/views/autocomplete/autocomplete_popup_win.h" | 21 #include "chrome/browser/ui/views/autocomplete/autocomplete_popup_win.h" |
| 21 #else | 22 #else |
| 22 #include "chrome/browser/ui/views/autocomplete/autocomplete_popup_gtk.h" | 23 #include "chrome/browser/ui/views/autocomplete/autocomplete_popup_gtk.h" |
| 23 #endif | 24 #endif |
| 24 | 25 |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 62 // Overridden from AutocompleteResultViewModel: | 63 // Overridden from AutocompleteResultViewModel: |
| 63 virtual bool IsSelectedIndex(size_t index) const; | 64 virtual bool IsSelectedIndex(size_t index) const; |
| 64 virtual bool IsHoveredIndex(size_t index) const; | 65 virtual bool IsHoveredIndex(size_t index) const; |
| 65 virtual const SkBitmap* GetSpecialIcon(size_t index) const; | 66 virtual const SkBitmap* GetSpecialIcon(size_t index) const; |
| 66 | 67 |
| 67 // Overridden from ui::AnimationDelegate: | 68 // Overridden from ui::AnimationDelegate: |
| 68 virtual void AnimationProgressed(const ui::Animation* animation); | 69 virtual void AnimationProgressed(const ui::Animation* animation); |
| 69 | 70 |
| 70 // Overridden from views::View: | 71 // Overridden from views::View: |
| 71 virtual void OnPaint(gfx::Canvas* canvas); | 72 virtual void OnPaint(gfx::Canvas* canvas); |
| 72 virtual void PaintChildren(gfx::Canvas* canvas) { | 73 virtual void PaintChildren(gfx::CanvasSkia* canvas); |
| 73 // We paint our children inside OnPaint(). | |
| 74 } | |
| 75 virtual void Layout(); | 74 virtual void Layout(); |
| 75 virtual void LayoutChildren(); | |
| 76 virtual void OnMouseEntered(const views::MouseEvent& event); | 76 virtual void OnMouseEntered(const views::MouseEvent& event); |
| 77 virtual void OnMouseMoved(const views::MouseEvent& event); | 77 virtual void OnMouseMoved(const views::MouseEvent& event); |
| 78 virtual void OnMouseExited(const views::MouseEvent& event); | 78 virtual void OnMouseExited(const views::MouseEvent& event); |
| 79 virtual bool OnMousePressed(const views::MouseEvent& event); | 79 virtual bool OnMousePressed(const views::MouseEvent& event); |
| 80 virtual void OnMouseReleased(const views::MouseEvent& event, bool canceled); | 80 virtual void OnMouseReleased(const views::MouseEvent& event, bool canceled); |
| 81 virtual bool OnMouseDragged(const views::MouseEvent& event); | 81 virtual bool OnMouseDragged(const views::MouseEvent& event); |
| 82 virtual views::View* GetViewForPoint(const gfx::Point& point); | 82 virtual views::View* GetViewForPoint(const gfx::Point& point); |
| 83 | 83 |
| 84 protected: | 84 protected: |
| 85 // Calculates the height needed to show all the results in the model. | 85 // Calculates the height needed to show all the results in the model. |
| 86 virtual int CalculatePopupHeight(); | 86 virtual int CalculatePopupHeight(); |
| 87 virtual AutocompleteResultView* CreateResultView( | 87 virtual AutocompleteResultView* CreateResultView( |
| 88 AutocompleteResultViewModel* model, | 88 AutocompleteResultViewModel* model, |
| 89 int model_index, | 89 int model_index, |
| 90 const gfx::Font& font, | 90 const gfx::Font& font, |
| 91 const gfx::Font& bold_font); | 91 const gfx::Font& bold_font); |
| 92 | 92 |
| 93 // The provider of our result set. | |
|
Peter Kasting
2011/02/16 21:50:22
Nit: No need for this comment
varunjain
2011/02/16 23:12:37
Done.
| |
| 94 scoped_ptr<AutocompletePopupModel> model_; | |
| 95 | |
| 96 // If non-NULL the instant opt-in-view is visible. | |
|
Peter Kasting
2011/02/16 21:50:22
Nit: How about:
// The "Opt-in to Instant" promo
varunjain
2011/02/16 23:12:37
Done.
| |
| 97 views::View* opt_in_view_; | |
| 98 | |
| 93 private: | 99 private: |
| 94 #if defined(OS_WIN) | 100 #if defined(OS_WIN) |
| 95 typedef AutocompletePopupWin AutocompletePopupClass; | 101 typedef AutocompletePopupWin AutocompletePopupClass; |
| 96 #else | 102 #else |
| 97 typedef AutocompletePopupGtk AutocompletePopupClass; | 103 typedef AutocompletePopupGtk AutocompletePopupClass; |
| 98 #endif | 104 #endif |
| 99 class InstantOptInView; | 105 class InstantOptInView; |
| 100 | 106 |
| 101 // Returns true if the model has a match at the specified index. | 107 // Returns true if the model has a match at the specified index. |
| 102 bool HasMatchAt(size_t index) const; | 108 bool HasMatchAt(size_t index) const; |
| (...skipping 26 matching lines...) Expand all Loading... | |
| 129 // Invoked if the user clicks on one of the opt-in buttons. Removes the opt-in | 135 // Invoked if the user clicks on one of the opt-in buttons. Removes the opt-in |
| 130 // view. | 136 // view. |
| 131 void UserPressedOptIn(bool opt_in); | 137 void UserPressedOptIn(bool opt_in); |
| 132 | 138 |
| 133 // The popup that contains this view. We create this, but it deletes itself | 139 // The popup that contains this view. We create this, but it deletes itself |
| 134 // when its window is destroyed. This is a WeakPtr because it's possible for | 140 // when its window is destroyed. This is a WeakPtr because it's possible for |
| 135 // the OS to destroy the window and thus delete this object before we're | 141 // the OS to destroy the window and thus delete this object before we're |
| 136 // deleted, or without our knowledge. | 142 // deleted, or without our knowledge. |
| 137 base::WeakPtr<AutocompletePopupClass> popup_; | 143 base::WeakPtr<AutocompletePopupClass> popup_; |
| 138 | 144 |
| 139 // The provider of our result set. | |
| 140 scoped_ptr<AutocompletePopupModel> model_; | |
| 141 | |
| 142 // The edit view that invokes us. | 145 // The edit view that invokes us. |
| 143 AutocompleteEditView* edit_view_; | 146 AutocompleteEditView* edit_view_; |
| 144 | 147 |
| 145 // An object that the popup positions itself against. | 148 // An object that the popup positions itself against. |
| 146 const views::View* location_bar_; | 149 const views::View* location_bar_; |
| 147 | 150 |
| 148 // Our border, which can compute our desired bounds. | 151 // Our border, which can compute our desired bounds. |
| 149 const BubbleBorder* bubble_border_; | 152 const BubbleBorder* bubble_border_; |
| 150 | 153 |
| 151 // The font that we should use for result rows. This is based on the font used | 154 // The font that we should use for result rows. This is based on the font used |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 162 // flag is reset to false on a mouse pressed event, to make sure we don't | 165 // flag is reset to false on a mouse pressed event, to make sure we don't |
| 163 // erroneously ignore the next drag. | 166 // erroneously ignore the next drag. |
| 164 bool ignore_mouse_drag_; | 167 bool ignore_mouse_drag_; |
| 165 | 168 |
| 166 // The popup sizes vertically using an animation when the popup is getting | 169 // The popup sizes vertically using an animation when the popup is getting |
| 167 // shorter (not larger, that makes it look "slow"). | 170 // shorter (not larger, that makes it look "slow"). |
| 168 ui::SlideAnimation size_animation_; | 171 ui::SlideAnimation size_animation_; |
| 169 gfx::Rect start_bounds_; | 172 gfx::Rect start_bounds_; |
| 170 gfx::Rect target_bounds_; | 173 gfx::Rect target_bounds_; |
| 171 | 174 |
| 172 // If non-NULL the instant opt-in-view is visible. | |
| 173 views::View* opt_in_view_; | |
| 174 | |
| 175 DISALLOW_COPY_AND_ASSIGN(AutocompletePopupContentsView); | 175 DISALLOW_COPY_AND_ASSIGN(AutocompletePopupContentsView); |
| 176 }; | 176 }; |
| 177 | 177 |
| 178 #endif // CHROME_BROWSER_UI_VIEWS_AUTOCOMPLETE_AUTOCOMPLETE_POPUP_CONTENTS_VIEW _H_ | 178 #endif // CHROME_BROWSER_UI_VIEWS_AUTOCOMPLETE_AUTOCOMPLETE_POPUP_CONTENTS_VIEW _H_ |
| OLD | NEW |