Views Omnibox: tolerate minor click-to-select-all dragging.
[chromium-blink-merge.git] / ui / app_list / views / contents_view.h
blob9c4de68ee536789367f87b2101d2b75e9c3a192c
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/views/view.h"
13 namespace content {
14 class WebContents;
17 namespace views {
18 class BoundsAnimator;
19 class ViewModel;
22 namespace app_list {
24 class AppsGridView;
25 class ApplicationDragAndDropHost;
26 class AppListFolderItem;
27 class AppListMainView;
28 class AppListModel;
29 class AppListViewDelegate;
30 class AppsContainerView;
31 class PaginationModel;
33 // 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 // exclusive. ContentsView manages a show state to choose one set to show
36 // and animates the transition between show states.
37 class ContentsView : public views::View {
38 public:
39 ContentsView(AppListMainView* app_list_main_view,
40 PaginationModel* pagination_model,
41 AppListModel* model,
42 AppListViewDelegate* view_delegate);
43 virtual ~ContentsView();
45 // The app list gets closed and drag and drop operations need to be cancelled.
46 void CancelDrag();
48 // If |drag_and_drop| is not NULL it will be called upon drag and drop
49 // operations outside the application list.
50 void SetDragAndDropHostOfCurrentAppList(
51 ApplicationDragAndDropHost* drag_and_drop_host);
53 void ShowSearchResults(bool show);
54 void ShowFolderContent(AppListFolderItem* folder);
55 void CancelAutoLaunch();
57 void Prerender();
59 AppsContainerView* apps_container_view() { return apps_container_view_; }
61 // Overridden from views::View:
62 virtual gfx::Size GetPreferredSize() OVERRIDE;
63 virtual void Layout() OVERRIDE;
64 virtual bool OnKeyPressed(const ui::KeyEvent& event) OVERRIDE;
65 virtual bool OnMouseWheel(const ui::MouseWheelEvent& event) OVERRIDE;
67 private:
68 enum ShowState {
69 SHOW_APPS,
70 SHOW_SEARCH_RESULTS,
73 // Sets show state.
74 void SetShowState(ShowState show_state);
76 // Invoked when show state is changed.
77 void ShowStateChanged();
79 void CalculateIdealBounds();
80 void AnimateToIdealBounds();
82 // Overridden from ui::EventHandler:
83 virtual void OnGestureEvent(ui::GestureEvent* event) OVERRIDE;
84 virtual void OnScrollEvent(ui::ScrollEvent* event) OVERRIDE;
86 ShowState show_state_;
87 PaginationModel* pagination_model_; // Owned by AppListController.
89 AppsContainerView* apps_container_view_; // Owned by the views hierarchy.
91 AppListViewDelegate* view_delegate_; // Owned by AppListView
93 scoped_ptr<views::ViewModel> view_model_;
94 scoped_ptr<views::BoundsAnimator> bounds_animator_;
96 DISALLOW_COPY_AND_ASSIGN(ContentsView);
99 } // namespace app_list
101 #endif // UI_APP_LIST_VIEWS_CONTENTS_VIEW_H_