| 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 UI_APP_LIST_APP_LIST_VIEW_H_ | 5 #ifndef UI_APP_LIST_APP_LIST_VIEW_H_ |
| 6 #define UI_APP_LIST_APP_LIST_VIEW_H_ | 6 #define UI_APP_LIST_APP_LIST_VIEW_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
| 10 #include "ui/app_list/app_list_export.h" | 10 #include "ui/app_list/app_list_export.h" |
| 11 #include "ui/app_list/search_box_view_delegate.h" |
| 12 #include "ui/app_list/search_result_list_view_delegate.h" |
| 11 #include "ui/views/bubble/bubble_delegate.h" | 13 #include "ui/views/bubble/bubble_delegate.h" |
| 12 #include "ui/views/controls/button/button.h" | 14 #include "ui/views/controls/button/button.h" |
| 13 | 15 |
| 14 namespace views { | 16 namespace views { |
| 15 class View; | 17 class View; |
| 16 } | 18 } |
| 17 | 19 |
| 18 namespace app_list { | 20 namespace app_list { |
| 19 | 21 |
| 20 class AppListBubbleBorder; | 22 class AppListBubbleBorder; |
| 21 class AppListModel; | 23 class AppListModel; |
| 22 class AppListModelView; | 24 class AppsGridView; |
| 23 class AppListViewDelegate; | 25 class AppListViewDelegate; |
| 26 class PageSwitcher; |
| 24 class PaginationModel; | 27 class PaginationModel; |
| 28 class SearchBoxView; |
| 29 class SearchResultListView; |
| 25 | 30 |
| 26 // AppListView is the top-level view and controller of app list UI. It creates | 31 // AppListView is the top-level view and controller of app list UI. It creates |
| 27 // and hosts a AppListModelView and passes AppListModel to it for display. | 32 // and hosts a AppsGridView and passes AppListModel to it for display. |
| 28 class APP_LIST_EXPORT AppListView : public views::BubbleDelegateView, | 33 class APP_LIST_EXPORT AppListView : public views::BubbleDelegateView, |
| 29 public views::ButtonListener { | 34 public views::ButtonListener, |
| 35 public SearchBoxViewDelegate, |
| 36 public SearchResultListViewDelegate { |
| 30 public: | 37 public: |
| 31 // Takes ownership of |delegate|. | 38 // Takes ownership of |delegate|. |
| 32 explicit AppListView(AppListViewDelegate* delegate); | 39 explicit AppListView(AppListViewDelegate* delegate); |
| 33 virtual ~AppListView(); | 40 virtual ~AppListView(); |
| 34 | 41 |
| 35 // Initializes the widget. | 42 // Initializes the widget. |
| 36 void InitAsFullscreenWidget(gfx::NativeView parent, | 43 void InitAsFullscreenWidget(gfx::NativeView parent, |
| 37 const gfx::Rect& screen_bounds, | 44 const gfx::Rect& screen_bounds, |
| 38 const gfx::Rect& work_area); | 45 const gfx::Rect& work_area); |
| 39 void InitAsBubble(gfx::NativeView parent, views::View* anchor); | 46 void InitAsBubble(gfx::NativeView parent, views::View* anchor); |
| 40 | 47 |
| 41 void AnimateShow(int duration_ms); | 48 void AnimateShow(int duration_ms); |
| 42 void AnimateHide(int duration_ms); | 49 void AnimateHide(int duration_ms); |
| 43 | 50 |
| 44 void Close(); | 51 void Close(); |
| 45 void UpdateBounds(const gfx::Rect& screen_bounds, | 52 void UpdateBounds(const gfx::Rect& screen_bounds, |
| 46 const gfx::Rect& work_area); | 53 const gfx::Rect& work_area); |
| 47 | 54 |
| 55 SearchBoxView* search_box() const { return search_box_view_; } |
| 56 |
| 48 private: | 57 private: |
| 49 // Updates model using query text in search box. | 58 // Creates models to use. |
| 50 void UpdateModel(); | 59 void CreateModel(); |
| 51 | 60 |
| 52 // Overridden from views::WidgetDelegateView: | 61 // Overridden from views::WidgetDelegateView: |
| 53 virtual views::View* GetInitiallyFocusedView() OVERRIDE; | 62 virtual views::View* GetInitiallyFocusedView() OVERRIDE; |
| 54 | 63 |
| 55 // Overridden from views::View: | 64 // Overridden from views::View: |
| 65 virtual gfx::Size GetPreferredSize() OVERRIDE; |
| 56 virtual void Layout() OVERRIDE; | 66 virtual void Layout() OVERRIDE; |
| 57 virtual bool OnKeyPressed(const views::KeyEvent& event) OVERRIDE; | 67 virtual bool OnKeyPressed(const views::KeyEvent& event) OVERRIDE; |
| 58 virtual bool OnMousePressed(const views::MouseEvent& event) OVERRIDE; | 68 virtual bool OnMousePressed(const views::MouseEvent& event) OVERRIDE; |
| 59 | 69 |
| 60 // Overridden from views::ButtonListener: | 70 // Overridden from views::ButtonListener: |
| 61 virtual void ButtonPressed(views::Button* sender, | 71 virtual void ButtonPressed(views::Button* sender, |
| 62 const views::Event& event) OVERRIDE; | 72 const views::Event& event) OVERRIDE; |
| 63 | 73 |
| 64 // Overridden from views::BubbleDelegate: | 74 // Overridden from views::BubbleDelegate: |
| 65 virtual gfx::Rect GetBubbleBounds() OVERRIDE; | 75 virtual gfx::Rect GetBubbleBounds() OVERRIDE; |
| 66 | 76 |
| 77 // Overridden from SearchBoxViewDelegate: |
| 78 virtual void QueryChanged(SearchBoxView* sender) OVERRIDE; |
| 79 |
| 80 // Overridden from SearchResultListViewDelegate: |
| 81 virtual void OpenResult(const SearchResult& result, |
| 82 int event_flags) OVERRIDE; |
| 83 |
| 67 scoped_ptr<AppListModel> model_; | 84 scoped_ptr<AppListModel> model_; |
| 68 scoped_ptr<AppListViewDelegate> delegate_; | 85 scoped_ptr<AppListViewDelegate> delegate_; |
| 69 | 86 |
| 70 // PaginationModel for model view and page switcher. | 87 // PaginationModel for model view and page switcher. |
| 71 scoped_ptr<PaginationModel> pagination_model_; | 88 scoped_ptr<PaginationModel> pagination_model_; |
| 72 | 89 |
| 73 bool bubble_style_; | 90 bool bubble_style_; |
| 74 AppListBubbleBorder* bubble_border_; // Owned by views hierarchy. | 91 AppListBubbleBorder* bubble_border_; // Owned by views hierarchy. |
| 75 AppListModelView* model_view_; | 92 |
| 93 AppsGridView* apps_view_; // Owned by views hierarchy. |
| 94 PageSwitcher* page_switcher_view_; // Owned by views hierarchy. |
| 95 SearchBoxView* search_box_view_; // Owned by views hierarchy. |
| 96 SearchResultListView* search_results_view_; // Owned by views hierarchy. |
| 76 | 97 |
| 77 // Work area in screen coordinates to layout app list. This is used for | 98 // Work area in screen coordinates to layout app list. This is used for |
| 78 // full screen mode. | 99 // full screen mode. |
| 79 gfx::Rect work_area_; | 100 gfx::Rect work_area_; |
| 80 | 101 |
| 81 DISALLOW_COPY_AND_ASSIGN(AppListView); | 102 DISALLOW_COPY_AND_ASSIGN(AppListView); |
| 82 }; | 103 }; |
| 83 | 104 |
| 84 } // namespace app_list | 105 } // namespace app_list |
| 85 | 106 |
| 86 #endif // UI_APP_LIST_APP_LIST_VIEW_H_ | 107 #endif // UI_APP_LIST_APP_LIST_VIEW_H_ |
| OLD | NEW |