Home | History | Annotate | Download | only in views
      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.
      4 
      5 #ifndef UI_APP_LIST_VIEWS_CONTENTS_VIEW_H_
      6 #define UI_APP_LIST_VIEWS_CONTENTS_VIEW_H_
      7 
      8 #include "base/basictypes.h"
      9 #include "base/compiler_specific.h"
     10 #include "base/memory/scoped_ptr.h"
     11 #include "ui/views/view.h"
     12 
     13 namespace content {
     14 class WebContents;
     15 }
     16 
     17 namespace views {
     18 class BoundsAnimator;
     19 class ViewModel;
     20 }
     21 
     22 namespace app_list {
     23 
     24 class AppsGridView;
     25 class ApplicationDragAndDropHost;
     26 class AppListFolderItem;
     27 class AppListMainView;
     28 class AppListModel;
     29 class AppListViewDelegate;
     30 class AppsContainerView;
     31 class PaginationModel;
     32 
     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                content::WebContents* start_page_contents);
     43   virtual ~ContentsView();
     44 
     45   // The app list gets closed and drag and drop operations need to be cancelled.
     46   void CancelDrag();
     47 
     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);
     52 
     53   void ShowSearchResults(bool show);
     54   void ShowFolderContent(AppListFolderItem* folder);
     55 
     56   void Prerender();
     57 
     58   AppsContainerView* apps_container_view() { return apps_container_view_; }
     59 
     60  private:
     61   enum ShowState {
     62     SHOW_APPS,
     63     SHOW_SEARCH_RESULTS,
     64   };
     65 
     66   // Sets show state.
     67   void SetShowState(ShowState show_state);
     68 
     69   // Invoked when show state is changed.
     70   void ShowStateChanged();
     71 
     72   void CalculateIdealBounds();
     73   void AnimateToIdealBounds();
     74 
     75   // Overridden from views::View:
     76   virtual gfx::Size GetPreferredSize() OVERRIDE;
     77   virtual void Layout() OVERRIDE;
     78   virtual bool OnKeyPressed(const ui::KeyEvent& event) OVERRIDE;
     79   virtual bool OnMouseWheel(const ui::MouseWheelEvent& event) OVERRIDE;
     80 
     81   // Overridden from ui::EventHandler:
     82   virtual void OnGestureEvent(ui::GestureEvent* event) OVERRIDE;
     83   virtual void OnScrollEvent(ui::ScrollEvent* event) OVERRIDE;
     84 
     85   ShowState show_state_;
     86   PaginationModel* pagination_model_;  // Owned by AppListController.
     87 
     88   AppsContainerView* apps_container_view_;  // Owned by the views hierarchy.
     89 
     90   scoped_ptr<views::ViewModel> view_model_;
     91   scoped_ptr<views::BoundsAnimator> bounds_animator_;
     92 
     93   DISALLOW_COPY_AND_ASSIGN(ContentsView);
     94 };
     95 
     96 }  // namespace app_list
     97 
     98 #endif  // UI_APP_LIST_VIEWS_CONTENTS_VIEW_H_
     99