| 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_POPUP_CONTENTS_VIEW_H_ | 5 #ifndef CHROME_BROWSER_UI_VIEWS_OMNIBOX_OMNIBOX_POPUP_CONTENTS_VIEW_H_ |
| 6 #define CHROME_BROWSER_UI_VIEWS_OMNIBOX_OMNIBOX_POPUP_CONTENTS_VIEW_H_ | 6 #define CHROME_BROWSER_UI_VIEWS_OMNIBOX_OMNIBOX_POPUP_CONTENTS_VIEW_H_ |
| 7 | 7 |
| 8 #include <stddef.h> | 8 #include <stddef.h> |
| 9 | 9 |
| 10 #include "base/macros.h" | 10 #include "base/macros.h" |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 51 gfx::Rect GetTargetBounds() override; | 51 gfx::Rect GetTargetBounds() override; |
| 52 void PaintUpdatesNow() override; | 52 void PaintUpdatesNow() override; |
| 53 void OnDragCanceled() override; | 53 void OnDragCanceled() override; |
| 54 | 54 |
| 55 // gfx::AnimationDelegate: | 55 // gfx::AnimationDelegate: |
| 56 void AnimationProgressed(const gfx::Animation* animation) override; | 56 void AnimationProgressed(const gfx::Animation* animation) override; |
| 57 | 57 |
| 58 // views::View: | 58 // views::View: |
| 59 void Layout() override; | 59 void Layout() override; |
| 60 views::View* GetTooltipHandlerForPoint(const gfx::Point& point) override; | 60 views::View* GetTooltipHandlerForPoint(const gfx::Point& point) override; |
| 61 void OnBoundsChanged(const gfx::Rect& previous_bounds) override; |
| 61 bool OnMousePressed(const ui::MouseEvent& event) override; | 62 bool OnMousePressed(const ui::MouseEvent& event) override; |
| 62 bool OnMouseDragged(const ui::MouseEvent& event) override; | 63 bool OnMouseDragged(const ui::MouseEvent& event) override; |
| 63 void OnMouseReleased(const ui::MouseEvent& event) override; | 64 void OnMouseReleased(const ui::MouseEvent& event) override; |
| 64 void OnMouseCaptureLost() override; | 65 void OnMouseCaptureLost() override; |
| 65 void OnMouseMoved(const ui::MouseEvent& event) override; | 66 void OnMouseMoved(const ui::MouseEvent& event) override; |
| 66 void OnMouseEntered(const ui::MouseEvent& event) override; | 67 void OnMouseEntered(const ui::MouseEvent& event) override; |
| 67 void OnMouseExited(const ui::MouseEvent& event) override; | 68 void OnMouseExited(const ui::MouseEvent& event) override; |
| 68 void OnGestureEvent(ui::GestureEvent* event) override; | 69 void OnGestureEvent(ui::GestureEvent* event) override; |
| 69 | 70 void ViewHierarchyChanged( |
| 71 const ViewHierarchyChangedDetails& details) override; |
| 72 bool experiment_started_ = false; |
| 70 bool IsSelectedIndex(size_t index) const; | 73 bool IsSelectedIndex(size_t index) const; |
| 71 bool IsHoveredIndex(size_t index) const; | 74 bool IsHoveredIndex(size_t index) const; |
| 72 gfx::Image GetIconIfExtensionMatch(size_t index) const; | 75 gfx::Image GetIconIfExtensionMatch(size_t index) const; |
| 73 bool IsStarredMatch(const AutocompleteMatch& match) const; | 76 bool IsStarredMatch(const AutocompleteMatch& match) const; |
| 74 | 77 |
| 75 int max_match_contents_width() const { return max_match_contents_width_; } | 78 int max_match_contents_width() const { return max_match_contents_width_; } |
| 76 | 79 |
| 77 protected: | 80 protected: |
| 78 OmniboxPopupContentsView(const gfx::FontList& font_list, | 81 OmniboxPopupContentsView(const gfx::FontList& font_list, |
| 79 OmniboxView* omnibox_view, | 82 OmniboxView* omnibox_view, |
| 80 OmniboxEditModel* edit_model, | 83 OmniboxEditModel* edit_model, |
| 81 LocationBarView* location_bar_view); | 84 LocationBarView* location_bar_view); |
| 82 ~OmniboxPopupContentsView() override; | 85 ~OmniboxPopupContentsView() override; |
| 83 | 86 |
| 84 LocationBarView* location_bar_view() { return location_bar_view_; } | 87 LocationBarView* location_bar_view() { return location_bar_view_; } |
| 85 | 88 |
| 86 // Calculates the height needed to show all the results in the model. | 89 // Calculates the height needed to show all the results in the model. |
| 87 virtual int CalculatePopupHeight(); | 90 virtual int CalculatePopupHeight(); |
| 88 virtual OmniboxResultView* CreateResultView(int model_index, | 91 virtual OmniboxResultView* CreateResultView(int model_index, |
| 89 const gfx::FontList& font_list); | 92 const gfx::FontList& font_list); |
| 90 | 93 |
| 91 private: | 94 private: |
| 92 class AutocompletePopupWidget; | 95 class AutocompletePopupWidget; |
| 93 | 96 |
| 94 // views::View: | 97 // views::View: |
| 95 const char* GetClassName() const override; | 98 const char* GetClassName() const override; |
| 96 void OnPaint(gfx::Canvas* canvas) override; | |
| 97 void PaintChildren(const ui::PaintContext& context) override; | 99 void PaintChildren(const ui::PaintContext& context) override; |
| 98 | 100 |
| 99 // views::ViewTargeterDelegate: | 101 // views::ViewTargeterDelegate: |
| 100 views::View* TargetForRect(views::View* root, const gfx::Rect& rect) override; | 102 views::View* TargetForRect(views::View* root, const gfx::Rect& rect) override; |
| 101 | 103 |
| 102 // Call immediately after construction. | 104 // Call immediately after construction. |
| 103 void Init(); | 105 void Init(); |
| 104 | 106 |
| 105 // 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. |
| 106 bool HasMatchAt(size_t index) const; | 108 bool HasMatchAt(size_t index) const; |
| (...skipping 27 matching lines...) Expand all Loading... |
| 134 base::WeakPtr<AutocompletePopupWidget> popup_; | 136 base::WeakPtr<AutocompletePopupWidget> popup_; |
| 135 | 137 |
| 136 // The edit view that invokes us. | 138 // The edit view that invokes us. |
| 137 OmniboxView* omnibox_view_; | 139 OmniboxView* omnibox_view_; |
| 138 | 140 |
| 139 LocationBarView* location_bar_view_; | 141 LocationBarView* location_bar_view_; |
| 140 | 142 |
| 141 // The font list used for result rows, based on the omnibox font list. | 143 // The font list used for result rows, based on the omnibox font list. |
| 142 gfx::FontList font_list_; | 144 gfx::FontList font_list_; |
| 143 | 145 |
| 146 // The ninebox layer that draws a drop shadow above and below the popup. |
| 147 std::unique_ptr<ui::Layer> shadow_layer_; |
| 148 |
| 144 // If the user cancels a dragging action (i.e. by pressing ESC), we don't have | 149 // If the user cancels a dragging action (i.e. by pressing ESC), we don't have |
| 145 // a convenient way to release mouse capture. Instead we use this flag to | 150 // a convenient way to release mouse capture. Instead we use this flag to |
| 146 // simply ignore all remaining drag events, and the eventual mouse release | 151 // simply ignore all remaining drag events, and the eventual mouse release |
| 147 // event. Since OnDragCanceled() can be called when we're not dragging, this | 152 // event. Since OnDragCanceled() can be called when we're not dragging, this |
| 148 // flag is reset to false on a mouse pressed event, to make sure we don't | 153 // flag is reset to false on a mouse pressed event, to make sure we don't |
| 149 // erroneously ignore the next drag. | 154 // erroneously ignore the next drag. |
| 150 bool ignore_mouse_drag_; | 155 bool ignore_mouse_drag_; |
| 151 | 156 |
| 152 // The popup sizes vertically using an animation when the popup is getting | 157 // The popup sizes vertically using an animation when the popup is getting |
| 153 // shorter (not larger, that makes it look "slow"). | 158 // shorter (not larger, that makes it look "slow"). |
| 154 gfx::SlideAnimation size_animation_; | 159 gfx::SlideAnimation size_animation_; |
| 155 gfx::Rect start_bounds_; | 160 gfx::Rect start_bounds_; |
| 156 gfx::Rect target_bounds_; | 161 gfx::Rect target_bounds_; |
| 157 | 162 |
| 158 int start_margin_; | 163 int start_margin_; |
| 159 int end_margin_; | 164 int end_margin_; |
| 160 | 165 |
| 161 // When the dropdown is not wide enough while displaying postfix suggestions, | 166 // When the dropdown is not wide enough while displaying postfix suggestions, |
| 162 // we use the width of widest match contents to shift the suggestions so that | 167 // we use the width of widest match contents to shift the suggestions so that |
| 163 // the widest suggestion just reaches the end edge. | 168 // the widest suggestion just reaches the end edge. |
| 164 int max_match_contents_width_; | 169 int max_match_contents_width_; |
| 165 | 170 |
| 166 DISALLOW_COPY_AND_ASSIGN(OmniboxPopupContentsView); | 171 DISALLOW_COPY_AND_ASSIGN(OmniboxPopupContentsView); |
| 167 }; | 172 }; |
| 168 | 173 |
| 169 #endif // CHROME_BROWSER_UI_VIEWS_OMNIBOX_OMNIBOX_POPUP_CONTENTS_VIEW_H_ | 174 #endif // CHROME_BROWSER_UI_VIEWS_OMNIBOX_OMNIBOX_POPUP_CONTENTS_VIEW_H_ |
| OLD | NEW |