Chromium Code Reviews| 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_VIEWS_CONTENTS_VIEW_H_ | 5 #ifndef UI_APP_LIST_VIEWS_CONTENTS_VIEW_H_ | 
| 6 #define UI_APP_LIST_VIEWS_CONTENTS_VIEW_H_ | 6 #define UI_APP_LIST_VIEWS_CONTENTS_VIEW_H_ | 
| 7 | 7 | 
| 8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" | 
| 9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" | 
| 10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" | 
| (...skipping 11 matching lines...) Expand all Loading... | |
| 22 namespace app_list { | 22 namespace app_list { | 
| 23 | 23 | 
| 24 class AppsGridView; | 24 class AppsGridView; | 
| 25 class ApplicationDragAndDropHost; | 25 class ApplicationDragAndDropHost; | 
| 26 class AppListFolderItem; | 26 class AppListFolderItem; | 
| 27 class AppListMainView; | 27 class AppListMainView; | 
| 28 class AppListModel; | 28 class AppListModel; | 
| 29 class AppListViewDelegate; | 29 class AppListViewDelegate; | 
| 30 class AppsContainerView; | 30 class AppsContainerView; | 
| 31 class PaginationModel; | 31 class PaginationModel; | 
| 32 class StartPageView; | |
| 32 | 33 | 
| 33 // A view to manage sub views under the search box (apps grid view + page | 34 // A view to manage sub views under the search box (apps grid view + page | 
| 34 // switcher and search results). The two sets of sub views are mutually | 35 // switcher and search results). The two sets of sub views are mutually | 
| 35 // exclusive. ContentsView manages a show state to choose one set to show | 36 // exclusive. ContentsView manages a show state to choose one set to show | 
| 36 // and animates the transition between show states. | 37 // and animates the transition between show states. | 
| 37 class ContentsView : public views::View { | 38 class ContentsView : public views::View { | 
| 38 public: | 39 public: | 
| 39 enum ShowState { SHOW_APPS, SHOW_SEARCH_RESULTS, }; | 40 enum ShowState { | 
| 41 SHOW_APPS, | |
| 42 SHOW_SEARCH_RESULTS, | |
| 43 SHOW_START_PAGE, | |
| 44 }; | |
| 40 | 45 | 
| 41 ContentsView(AppListMainView* app_list_main_view, | 46 ContentsView(AppListMainView* app_list_main_view, | 
| 42 PaginationModel* pagination_model, | 47 PaginationModel* pagination_model, | 
| 43 AppListModel* model, | 48 AppListModel* model, | 
| 44 AppListViewDelegate* view_delegate); | 49 AppListViewDelegate* view_delegate); | 
| 45 virtual ~ContentsView(); | 50 virtual ~ContentsView(); | 
| 46 | 51 | 
| 47 // The app list gets closed and drag and drop operations need to be cancelled. | 52 // The app list gets closed and drag and drop operations need to be cancelled. | 
| 48 void CancelDrag(); | 53 void CancelDrag(); | 
| 49 | 54 | 
| 50 // If |drag_and_drop| is not NULL it will be called upon drag and drop | 55 // If |drag_and_drop| is not NULL it will be called upon drag and drop | 
| 51 // operations outside the application list. | 56 // operations outside the application list. | 
| 52 void SetDragAndDropHostOfCurrentAppList( | 57 void SetDragAndDropHostOfCurrentAppList( | 
| 53 ApplicationDragAndDropHost* drag_and_drop_host); | 58 ApplicationDragAndDropHost* drag_and_drop_host); | 
| 54 | 59 | 
| 55 void ShowSearchResults(bool show); | 60 void ShowSearchResults(bool show); | 
| 56 void ShowFolderContent(AppListFolderItem* folder); | 61 void ShowFolderContent(AppListFolderItem* folder); | 
| 57 | 62 | 
| 58 // Sets show state and animates the subviews to match the show state. | 63 // Sets show state and animates the subviews to match the show state. | 
| 59 void SetShowState(ShowState show_state); | 64 void SetShowState(ShowState show_state); | 
| 60 | 65 | 
| 61 void Prerender(); | 66 void Prerender(); | 
| 62 | 67 | 
| 63 AppsContainerView* apps_container_view() { return apps_container_view_; } | 68 AppsContainerView* apps_container_view() { return apps_container_view_; } | 
| 64 | 69 | 
| 70 ShowState show_state() { return show_state_; } | |
| 
 
xiyuan
2014/05/09 07:59:46
nit: make it a const method:
i.e. ShowState show_s
 
calamity
2014/05/12 03:00:42
Done.
 
 | |
| 71 | |
| 65 // Overridden from views::View: | 72 // Overridden from views::View: | 
| 66 virtual gfx::Size GetPreferredSize() OVERRIDE; | 73 virtual gfx::Size GetPreferredSize() OVERRIDE; | 
| 67 virtual void Layout() OVERRIDE; | 74 virtual void Layout() OVERRIDE; | 
| 68 virtual bool OnKeyPressed(const ui::KeyEvent& event) OVERRIDE; | 75 virtual bool OnKeyPressed(const ui::KeyEvent& event) OVERRIDE; | 
| 69 virtual bool OnMouseWheel(const ui::MouseWheelEvent& event) OVERRIDE; | 76 virtual bool OnMouseWheel(const ui::MouseWheelEvent& event) OVERRIDE; | 
| 70 | 77 | 
| 71 private: | 78 private: | 
| 72 // Invoked when show state is changed. | 79 // Invoked when show state is changed. | 
| 73 void ShowStateChanged(); | 80 void ShowStateChanged(); | 
| 74 | 81 | 
| 75 void CalculateIdealBounds(); | 82 void CalculateIdealBounds(); | 
| 76 void AnimateToIdealBounds(); | 83 void AnimateToIdealBounds(); | 
| 77 | 84 | 
| 78 // Overridden from ui::EventHandler: | 85 // Overridden from ui::EventHandler: | 
| 79 virtual void OnGestureEvent(ui::GestureEvent* event) OVERRIDE; | 86 virtual void OnGestureEvent(ui::GestureEvent* event) OVERRIDE; | 
| 80 virtual void OnScrollEvent(ui::ScrollEvent* event) OVERRIDE; | 87 virtual void OnScrollEvent(ui::ScrollEvent* event) OVERRIDE; | 
| 81 | 88 | 
| 82 ShowState show_state_; | 89 ShowState show_state_; | 
| 83 PaginationModel* pagination_model_; // Owned by AppListController. | 90 PaginationModel* pagination_model_; // Owned by AppListController. | 
| 84 | 91 | 
| 85 AppsContainerView* apps_container_view_; // Owned by the views hierarchy. | 92 AppsContainerView* apps_container_view_; // Owned by the views hierarchy. | 
| 93 AppListMainView* app_list_main_view_; // Parent view, owns this. | |
| 86 | 94 | 
| 87 scoped_ptr<views::ViewModel> view_model_; | 95 scoped_ptr<views::ViewModel> view_model_; | 
| 88 scoped_ptr<views::BoundsAnimator> bounds_animator_; | 96 scoped_ptr<views::BoundsAnimator> bounds_animator_; | 
| 89 | 97 | 
| 90 DISALLOW_COPY_AND_ASSIGN(ContentsView); | 98 DISALLOW_COPY_AND_ASSIGN(ContentsView); | 
| 91 }; | 99 }; | 
| 92 | 100 | 
| 93 } // namespace app_list | 101 } // namespace app_list | 
| 94 | 102 | 
| 95 #endif // UI_APP_LIST_VIEWS_CONTENTS_VIEW_H_ | 103 #endif // UI_APP_LIST_VIEWS_CONTENTS_VIEW_H_ | 
| OLD | NEW |