OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef UI_APP_LIST_VIEWS_APP_LIST_VIEW_H_ | 5 #ifndef UI_APP_LIST_VIEWS_APP_LIST_VIEW_H_ |
6 #define UI_APP_LIST_VIEWS_APP_LIST_VIEW_H_ | 6 #define UI_APP_LIST_VIEWS_APP_LIST_VIEW_H_ |
7 | 7 |
8 #include <memory> | 8 #include <memory> |
9 | 9 |
10 #include "base/callback.h" | 10 #include "base/callback.h" |
(...skipping 20 matching lines...) Expand all Loading... |
31 | 31 |
32 // AppListView is the top-level view and controller of app list UI. It creates | 32 // AppListView is the top-level view and controller of app list UI. It creates |
33 // and hosts a AppsGridView and passes AppListModel to it for display. | 33 // and hosts a AppsGridView and passes AppListModel to it for display. |
34 class APP_LIST_EXPORT AppListView : public views::BubbleDialogDelegateView, | 34 class APP_LIST_EXPORT AppListView : public views::BubbleDialogDelegateView, |
35 public SpeechUIModelObserver { | 35 public SpeechUIModelObserver { |
36 public: | 36 public: |
37 // Does not take ownership of |delegate|. | 37 // Does not take ownership of |delegate|. |
38 explicit AppListView(AppListViewDelegate* delegate); | 38 explicit AppListView(AppListViewDelegate* delegate); |
39 ~AppListView() override; | 39 ~AppListView() override; |
40 | 40 |
41 // Initializes the widget as a bubble or fullscreen view depending on the | 41 // Initializes the widget. |
42 // presence of a cmd line switch. parent and initial_apps_page are used for | 42 void InitAsBubble(gfx::NativeView parent, int initial_apps_page); |
43 // both the bubble and fullscreen initialization. | |
44 void Initialize(gfx::NativeView parent, int initial_apps_page); | |
45 | 43 |
46 void SetBubbleArrow(views::BubbleBorder::Arrow arrow); | 44 void SetBubbleArrow(views::BubbleBorder::Arrow arrow); |
47 | 45 |
48 void MaybeSetAnchorPoint(const gfx::Point& anchor_point); | 46 void SetAnchorPoint(const gfx::Point& anchor_point); |
49 | 47 |
50 // If |drag_and_drop_host| is not NULL it will be called upon drag and drop | 48 // If |drag_and_drop_host| is not NULL it will be called upon drag and drop |
51 // operations outside the application list. This has to be called after | 49 // operations outside the application list. This has to be called after |
52 // Initialize was called since the app list object needs to exist so that | 50 // InitAsBubble was called since the app list object needs to exist so that |
53 // it can set the host. | 51 // it can set the host. |
54 void SetDragAndDropHostOfCurrentAppList( | 52 void SetDragAndDropHostOfCurrentAppList( |
55 ApplicationDragAndDropHost* drag_and_drop_host); | 53 ApplicationDragAndDropHost* drag_and_drop_host); |
56 | 54 |
57 // Shows the UI when there are no pending icon loads. Otherwise, starts a | 55 // Shows the UI when there are no pending icon loads. Otherwise, starts a |
58 // timer to show the UI when a maximum allowed wait time has expired. | 56 // timer to show the UI when a maximum allowed wait time has expired. |
59 void ShowWhenReady(); | 57 void ShowWhenReady(); |
60 | 58 |
61 void CloseAppList(); | 59 void CloseAppList(); |
62 | 60 |
63 void UpdateBounds(); | 61 void UpdateBounds(); |
64 | 62 |
65 // Enables/disables a semi-transparent overlay over the app list (good for | 63 // Enables/disables a semi-transparent overlay over the app list (good for |
66 // hiding the app list when a modal dialog is being shown). | 64 // hiding the app list when a modal dialog is being shown). |
67 void SetAppListOverlayVisible(bool visible); | 65 void SetAppListOverlayVisible(bool visible); |
68 | 66 |
69 views::Widget* search_box_widget() const { return search_box_widget_; } | 67 views::Widget* search_box_widget() const { return search_box_widget_; } |
70 | 68 |
71 // Overridden from views::View: | 69 // Overridden from views::View: |
72 gfx::Size GetPreferredSize() const override; | 70 gfx::Size GetPreferredSize() const override; |
73 void OnPaint(gfx::Canvas* canvas) override; | 71 void OnPaint(gfx::Canvas* canvas) override; |
74 const char* GetClassName() const override; | |
75 | 72 |
76 // WidgetDelegate overrides: | 73 // WidgetDelegate overrides: |
77 bool ShouldHandleSystemCommands() const override; | 74 bool ShouldHandleSystemCommands() const override; |
78 bool ShouldDescendIntoChildForEventHandling( | 75 bool ShouldDescendIntoChildForEventHandling( |
79 gfx::NativeView child, | 76 gfx::NativeView child, |
80 const gfx::Point& location) override; | 77 const gfx::Point& location) override; |
81 | 78 |
82 AppListMainView* app_list_main_view() { return app_list_main_view_; } | 79 AppListMainView* app_list_main_view() { return app_list_main_view_; } |
83 | 80 |
84 // Gets the PaginationModel owned by this view's apps grid. | 81 // Gets the PaginationModel owned by this view's apps grid. |
85 PaginationModel* GetAppsPaginationModel(); | 82 PaginationModel* GetAppsPaginationModel(); |
86 | 83 |
87 // Overridden from views::View: | 84 // Overridden from views::View: |
88 bool AcceleratorPressed(const ui::Accelerator& accelerator) override; | 85 bool AcceleratorPressed(const ui::Accelerator& accelerator) override; |
89 void Layout() override; | 86 void Layout() override; |
90 void SchedulePaintInRect(const gfx::Rect& rect) override; | 87 void SchedulePaintInRect(const gfx::Rect& rect) override; |
91 | 88 |
92 private: | 89 private: |
93 friend class test::AppListViewTestApi; | 90 friend class test::AppListViewTestApi; |
94 | 91 |
95 void InitContents(gfx::NativeView parent, int initial_apps_page); | 92 void InitContents(gfx::NativeView parent, int initial_apps_page); |
96 | 93 |
97 void InitChildWidgets(); | 94 void InitChildWidgets(); |
98 | 95 |
99 // Initializes the widget for fullscreen mode. | |
100 void InitializeFullscreen(gfx::NativeView parent, int initial_apps_page); | |
101 | |
102 // Initializes the widget as a bubble. | |
103 void InitializeBubble(gfx::NativeView parent, int initial_apps_page); | |
104 | |
105 // Overridden from views::BubbleDialogDelegateView: | 96 // Overridden from views::BubbleDialogDelegateView: |
106 void OnBeforeBubbleWidgetInit(views::Widget::InitParams* params, | 97 void OnBeforeBubbleWidgetInit(views::Widget::InitParams* params, |
107 views::Widget* widget) const override; | 98 views::Widget* widget) const override; |
108 int GetDialogButtons() const override; | 99 int GetDialogButtons() const override; |
109 | 100 |
110 // Overridden from views::WidgetDelegateView: | 101 // Overridden from views::WidgetDelegateView: |
111 views::View* GetInitiallyFocusedView() override; | 102 views::View* GetInitiallyFocusedView() override; |
112 bool WidgetHasHitTestMask() const override; | 103 bool WidgetHasHitTestMask() const override; |
113 void GetWidgetHitTestMask(gfx::Path* mask) const override; | 104 void GetWidgetHitTestMask(gfx::Path* mask) const override; |
114 | 105 |
115 // Overridden from views::WidgetObserver: | 106 // Overridden from views::WidgetObserver: |
116 void OnWidgetDestroying(views::Widget* widget) override; | 107 void OnWidgetDestroying(views::Widget* widget) override; |
117 void OnWidgetVisibilityChanged(views::Widget* widget, bool visible) override; | 108 void OnWidgetVisibilityChanged(views::Widget* widget, bool visible) override; |
118 | 109 |
119 // Overridden from SpeechUIModelObserver: | 110 // Overridden from SpeechUIModelObserver: |
120 void OnSpeechRecognitionStateChanged( | 111 void OnSpeechRecognitionStateChanged( |
121 SpeechRecognitionState new_state) override; | 112 SpeechRecognitionState new_state) override; |
122 | 113 |
123 AppListViewDelegate* delegate_; // Weak. Owned by AppListService. | 114 AppListViewDelegate* delegate_; // Weak. Owned by AppListService. |
124 | 115 |
125 AppListMainView* app_list_main_view_; | 116 AppListMainView* app_list_main_view_; |
126 SpeechView* speech_view_; | 117 SpeechView* speech_view_; |
127 | 118 |
128 views::View* search_box_focus_host_; // Owned by the views hierarchy. | 119 views::View* search_box_focus_host_; // Owned by the views hierarchy. |
129 views::Widget* search_box_widget_; // Owned by the app list's widget. | 120 views::Widget* search_box_widget_; // Owned by the app list's widget. |
130 SearchBoxView* search_box_view_; // Owned by |search_box_widget_|. | 121 SearchBoxView* search_box_view_; // Owned by |search_box_widget_|. |
131 | 122 |
132 // A semi-transparent white overlay that covers the app list while dialogs are | 123 // A semi-transparent white overlay that covers the app list while dialogs are |
133 // open. | 124 // open. |
134 views::View* overlay_view_; | 125 views::View* overlay_view_; |
135 | 126 |
136 std::unique_ptr<HideViewAnimationObserver> animation_observer_; | 127 std::unique_ptr<HideViewAnimationObserver> animation_observer_; |
137 | 128 |
138 // For UMA and testing. If non-null, triggered when the app list is painted. | 129 // For UMA and testing. If non-null, triggered when the app list is painted. |
139 base::Closure next_paint_callback_; | 130 base::Closure next_paint_callback_; |
140 | 131 |
141 DISALLOW_COPY_AND_ASSIGN(AppListView); | 132 DISALLOW_COPY_AND_ASSIGN(AppListView); |
142 }; | 133 }; |
143 | 134 |
144 } // namespace app_list | 135 } // namespace app_list |
145 | 136 |
146 #endif // UI_APP_LIST_VIEWS_APP_LIST_VIEW_H_ | 137 #endif // UI_APP_LIST_VIEWS_APP_LIST_VIEW_H_ |
OLD | NEW |