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
3 // found in the LICENSE file.
5 #ifndef UI_APP_LIST_VIEWS_CONTENTS_VIEW_H_
6 #define UI_APP_LIST_VIEWS_CONTENTS_VIEW_H_
8 #include "base/basictypes.h"
9 #include "base/compiler_specific.h"
10 #include "base/memory/scoped_ptr.h"
11 #include "ui/app_list/app_list_export.h"
12 #include "ui/views/view.h"
26 class ApplicationDragAndDropHost
;
27 class AppListFolderItem
;
28 class AppListMainView
;
30 class AppListViewDelegate
;
31 class AppsContainerView
;
32 class PaginationModel
;
35 // A view to manage sub views under the search box (apps grid view + page
36 // switcher and search results). The two sets of sub views are mutually
37 // exclusive. ContentsView manages a show state to choose one set to show
38 // and animates the transition between show states.
39 class APP_LIST_EXPORT ContentsView
: public views::View
{
47 ContentsView(AppListMainView
* app_list_main_view
,
48 PaginationModel
* pagination_model
,
50 AppListViewDelegate
* view_delegate
);
51 virtual ~ContentsView();
53 // The app list gets closed and drag and drop operations need to be cancelled.
56 // If |drag_and_drop| is not NULL it will be called upon drag and drop
57 // operations outside the application list.
58 void SetDragAndDropHostOfCurrentAppList(
59 ApplicationDragAndDropHost
* drag_and_drop_host
);
61 void ShowSearchResults(bool show
);
62 void ShowFolderContent(AppListFolderItem
* folder
);
64 // Sets show state and animates the subviews to match the show state.
65 void SetShowState(ShowState show_state
);
69 AppsContainerView
* apps_container_view() { return apps_container_view_
; }
70 StartPageView
* start_page_view() { return start_page_view_
; }
72 ShowState
show_state() const { return show_state_
; }
74 // Overridden from views::View:
75 virtual gfx::Size
GetPreferredSize() const OVERRIDE
;
76 virtual void Layout() OVERRIDE
;
77 virtual bool OnKeyPressed(const ui::KeyEvent
& event
) OVERRIDE
;
78 virtual bool OnMouseWheel(const ui::MouseWheelEvent
& event
) OVERRIDE
;
81 // Invoked when show state is changed.
82 void ShowStateChanged();
84 void CalculateIdealBounds();
85 void AnimateToIdealBounds();
87 // Overridden from ui::EventHandler:
88 virtual void OnGestureEvent(ui::GestureEvent
* event
) OVERRIDE
;
89 virtual void OnScrollEvent(ui::ScrollEvent
* event
) OVERRIDE
;
91 ShowState show_state_
;
92 PaginationModel
* pagination_model_
; // Owned by AppListController.
94 AppsContainerView
* apps_container_view_
; // Owned by the views hierarchy.
95 StartPageView
* start_page_view_
; // Owned by the views hierarchy.
97 AppListMainView
* app_list_main_view_
; // Parent view, owns this.
99 scoped_ptr
<views::ViewModel
> view_model_
;
100 scoped_ptr
<views::BoundsAnimator
> bounds_animator_
;
102 DISALLOW_COPY_AND_ASSIGN(ContentsView
);
105 } // namespace app_list
107 #endif // UI_APP_LIST_VIEWS_CONTENTS_VIEW_H_