Consolidate bubble border code.
[chromium-blink-merge.git] / ui / app_list / app_list_view.h
blob8ffecb93fdf499cf5e6514d126ea9e2ba1d07c80
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_APP_LIST_VIEW_H_
6 #define UI_APP_LIST_APP_LIST_VIEW_H_
8 #include "base/memory/scoped_ptr.h"
9 #include "ui/app_list/app_list_export.h"
10 #include "ui/app_list/search_box_view_delegate.h"
11 #include "ui/app_list/search_result_list_view_delegate.h"
12 #include "ui/views/bubble/bubble_delegate.h"
13 #include "ui/views/controls/button/button.h"
15 namespace app_list {
17 class AppListModel;
18 class AppListViewDelegate;
19 class ContentsView;
20 class PaginationModel;
21 class SearchBoxView;
23 // AppListView is the top-level view and controller of app list UI. It creates
24 // and hosts a AppsGridView and passes AppListModel to it for display.
25 class APP_LIST_EXPORT AppListView : public views::BubbleDelegateView,
26 public views::ButtonListener,
27 public SearchBoxViewDelegate,
28 public SearchResultListViewDelegate {
29 public:
30 // Takes ownership of |delegate|.
31 explicit AppListView(AppListViewDelegate* delegate);
32 virtual ~AppListView();
34 // Initializes the widget.
35 void InitAsBubble(gfx::NativeView parent,
36 PaginationModel* pagination_model,
37 views::View* anchor,
38 const gfx::Point& anchor_point,
39 views::BubbleBorder::ArrowLocation arrow_location);
41 void SetBubbleArrowLocation(
42 views::BubbleBorder::ArrowLocation arrow_location);
44 void Close();
46 void UpdateBounds();
48 private:
49 // Creates models to use.
50 void CreateModel();
52 // Overridden from views::WidgetDelegateView:
53 virtual views::View* GetInitiallyFocusedView() OVERRIDE;
54 virtual gfx::ImageSkia GetWindowAppIcon() OVERRIDE;
55 virtual bool HasHitTestMask() const OVERRIDE;
56 virtual void GetHitTestMask(gfx::Path* mask) const OVERRIDE;
58 // Overridden from views::View:
59 virtual bool OnKeyPressed(const ui::KeyEvent& event) OVERRIDE;
61 // Overridden from views::ButtonListener:
62 virtual void ButtonPressed(views::Button* sender,
63 const ui::Event& event) OVERRIDE;
65 // Overridden from SearchBoxViewDelegate:
66 virtual void QueryChanged(SearchBoxView* sender) OVERRIDE;
68 // Overridden from SearchResultListViewDelegate:
69 virtual void OpenResult(const SearchResult& result,
70 int event_flags) OVERRIDE;
71 virtual void InvokeResultAction(const SearchResult& result,
72 int action_index,
73 int event_flags) OVERRIDE;
75 scoped_ptr<AppListModel> model_;
76 scoped_ptr<AppListViewDelegate> delegate_;
78 SearchBoxView* search_box_view_; // Owned by views hierarchy.
79 ContentsView* contents_view_; // Owned by views hierarchy.
81 DISALLOW_COPY_AND_ASSIGN(AppListView);
84 } // namespace app_list
86 #endif // UI_APP_LIST_APP_LIST_VIEW_H_