OLD | NEW |
| (Empty) |
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_APP_LIST_VIEW_H_ | |
6 #define UI_APP_LIST_APP_LIST_VIEW_H_ | |
7 | |
8 #include "base/memory/scoped_ptr.h" | |
9 #include "base/memory/scoped_vector.h" | |
10 #include "base/timer.h" | |
11 #include "ui/app_list/app_list_export.h" | |
12 #include "ui/app_list/apps_grid_view_delegate.h" | |
13 #include "ui/app_list/search_box_view_delegate.h" | |
14 #include "ui/app_list/search_result_list_view_delegate.h" | |
15 #include "ui/views/bubble/bubble_delegate.h" | |
16 | |
17 namespace views { | |
18 class Widget; | |
19 } | |
20 | |
21 namespace app_list { | |
22 | |
23 class AppListModel; | |
24 class AppListItemModel; | |
25 class AppListViewDelegate; | |
26 class ContentsView; | |
27 class PaginationModel; | |
28 class SearchBoxView; | |
29 | |
30 // AppListView is the top-level view and controller of app list UI. It creates | |
31 // and hosts a AppsGridView and passes AppListModel to it for display. | |
32 class APP_LIST_EXPORT AppListView : public views::BubbleDelegateView, | |
33 public AppsGridViewDelegate, | |
34 public SearchBoxViewDelegate, | |
35 public SearchResultListViewDelegate { | |
36 public: | |
37 // Takes ownership of |delegate|. | |
38 explicit AppListView(AppListViewDelegate* delegate); | |
39 virtual ~AppListView(); | |
40 | |
41 // Initializes the widget. | |
42 void InitAsBubble(gfx::NativeView parent, | |
43 PaginationModel* pagination_model, | |
44 views::View* anchor, | |
45 const gfx::Point& anchor_point, | |
46 views::BubbleBorder::ArrowLocation arrow_location); | |
47 | |
48 void SetBubbleArrowLocation( | |
49 views::BubbleBorder::ArrowLocation arrow_location); | |
50 | |
51 void SetAnchorPoint(const gfx::Point& anchor_point); | |
52 | |
53 // Shows the UI when there are no pending icon loads. Otherwise, starts a | |
54 // timer to show the UI when a maximum allowed wait time has expired. | |
55 void ShowWhenReady(); | |
56 | |
57 void Close(); | |
58 | |
59 void UpdateBounds(); | |
60 | |
61 private: | |
62 class IconLoader; | |
63 | |
64 // Loads icon image for the apps in the selected page of |pagination_model|. | |
65 // |anchor| is used to determine the image scale factor to use. | |
66 void PreloadIcons(PaginationModel* pagination_model, | |
67 views::View* anchor); | |
68 | |
69 // Invoked when |icon_loading_wait_timer_| fires. | |
70 void OnIconLoadingWaitTimer(); | |
71 | |
72 // Invoked from an IconLoader when icon loading is finished. | |
73 void OnItemIconLoaded(IconLoader* loader); | |
74 | |
75 // Overridden from views::WidgetDelegateView: | |
76 virtual views::View* GetInitiallyFocusedView() OVERRIDE; | |
77 virtual bool WidgetHasHitTestMask() const OVERRIDE; | |
78 virtual void GetWidgetHitTestMask(gfx::Path* mask) const OVERRIDE; | |
79 | |
80 // Overridden from views::View: | |
81 virtual bool AcceleratorPressed(const ui::Accelerator& accelerator) OVERRIDE; | |
82 | |
83 // Overridden from AppsGridViewDelegate: | |
84 virtual void ActivateApp(AppListItemModel* item, int event_flags) OVERRIDE; | |
85 | |
86 // Overridden from SearchBoxViewDelegate: | |
87 virtual void QueryChanged(SearchBoxView* sender) OVERRIDE; | |
88 | |
89 // Overridden from SearchResultListViewDelegate: | |
90 virtual void OpenResult(const SearchResult& result, | |
91 int event_flags) OVERRIDE; | |
92 virtual void InvokeResultAction(const SearchResult& result, | |
93 int action_index, | |
94 int event_flags) OVERRIDE; | |
95 | |
96 // Overridden from views::WidgetObserver: | |
97 virtual void OnWidgetClosing(views::Widget* widget) OVERRIDE; | |
98 virtual void OnWidgetActivationChanged(views::Widget* widget, bool active) | |
99 OVERRIDE; | |
100 | |
101 scoped_ptr<AppListModel> model_; | |
102 scoped_ptr<AppListViewDelegate> delegate_; | |
103 | |
104 SearchBoxView* search_box_view_; // Owned by views hierarchy. | |
105 ContentsView* contents_view_; // Owned by views hierarchy. | |
106 | |
107 // A timer that fires when maximum allowed time to wait for icon loading has | |
108 // passed. | |
109 base::OneShotTimer<AppListView> icon_loading_wait_timer_; | |
110 | |
111 ScopedVector<IconLoader> pending_icon_loaders_; | |
112 | |
113 DISALLOW_COPY_AND_ASSIGN(AppListView); | |
114 }; | |
115 | |
116 } // namespace app_list | |
117 | |
118 #endif // UI_APP_LIST_APP_LIST_VIEW_H_ | |
OLD | NEW |