Chromium Code Reviews| 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" | 
| 11 #include "base/macros.h" | 11 #include "base/macros.h" | 
| 12 #include "base/scoped_observer.h" | |
| 12 #include "build/build_config.h" | 13 #include "build/build_config.h" | 
| 13 #include "ui/app_list/app_list_export.h" | 14 #include "ui/app_list/app_list_export.h" | 
| 14 #include "ui/app_list/speech_ui_model_observer.h" | 15 #include "ui/app_list/speech_ui_model_observer.h" | 
| 16 #include "ui/display/display_observer.h" | |
| 15 #include "ui/views/bubble/bubble_dialog_delegate.h" | 17 #include "ui/views/bubble/bubble_dialog_delegate.h" | 
| 16 #include "ui/views/widget/widget.h" | 18 #include "ui/views/widget/widget.h" | 
| 17 | 19 | 
| 20 namespace display { | |
| 21 class Screen; | |
| 22 } | |
| 23 | |
| 18 namespace app_list { | 24 namespace app_list { | 
| 19 class ApplicationDragAndDropHost; | 25 class ApplicationDragAndDropHost; | 
| 20 class AppListMainView; | 26 class AppListMainView; | 
| 21 class AppListModel; | 27 class AppListModel; | 
| 22 class AppListViewDelegate; | 28 class AppListViewDelegate; | 
| 23 class HideViewAnimationObserver; | 29 class HideViewAnimationObserver; | 
| 24 class PaginationModel; | 30 class PaginationModel; | 
| 25 class SearchBoxView; | 31 class SearchBoxView; | 
| 26 class SpeechView; | 32 class SpeechView; | 
| 27 | 33 | 
| 28 namespace test { | 34 namespace test { | 
| 29 class AppListViewTestApi; | 35 class AppListViewTestApi; | 
| 30 } | 36 } | 
| 31 | 37 | 
| 32 // AppListView is the top-level view and controller of app list UI. It creates | 38 // 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. | 39 // and hosts a AppsGridView and passes AppListModel to it for display. | 
| 34 class APP_LIST_EXPORT AppListView : public views::BubbleDialogDelegateView, | 40 class APP_LIST_EXPORT AppListView : public views::BubbleDialogDelegateView, | 
| 35 public SpeechUIModelObserver { | 41 public SpeechUIModelObserver, | 
| 42 public display::DisplayObserver { | |
| 36 public: | 43 public: | 
| 44 enum AppListState { INITIAL = 0, PEEKING, FULLSCREEN }; | |
| 
 
msw
2017/06/07 02:31:39
Comment on this enum and each of its states, the c
 
newcomer
2017/06/07 17:21:37
Done.
 
 | |
| 45 | |
| 37 // Does not take ownership of |delegate|. | 46 // Does not take ownership of |delegate|. | 
| 38 explicit AppListView(AppListViewDelegate* delegate); | 47 explicit AppListView(AppListViewDelegate* delegate); | 
| 39 ~AppListView() override; | 48 ~AppListView() override; | 
| 40 | 49 | 
| 41 // Initializes the widget as a bubble or fullscreen view depending on the | 50 // Initializes the widget as a bubble or fullscreen view depending on the | 
| 42 // presence of a cmd line switch. parent and initial_apps_page are used for | 51 // presence of a cmd line switch. parent and initial_apps_page are used for | 
| 43 // both the bubble and fullscreen initialization. | 52 // both the bubble and fullscreen initialization. | 
| 44 void Initialize(gfx::NativeView parent, int initial_apps_page); | 53 void Initialize(gfx::NativeView parent, int initial_apps_page); | 
| 45 | 54 | 
| 46 void SetBubbleArrow(views::BubbleBorder::Arrow arrow); | 55 void SetBubbleArrow(views::BubbleBorder::Arrow arrow); | 
| 47 | 56 | 
| 48 void MaybeSetAnchorPoint(const gfx::Point& anchor_point); | 57 void MaybeSetAnchorPoint(const gfx::Point& anchor_point); | 
| 49 | 58 | 
| 50 // If |drag_and_drop_host| is not NULL it will be called upon drag and drop | 59 // 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 | 60 // 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 | 61 // Initialize was called since the app list object needs to exist so that | 
| 53 // it can set the host. | 62 // it can set the host. | 
| 54 void SetDragAndDropHostOfCurrentAppList( | 63 void SetDragAndDropHostOfCurrentAppList( | 
| 55 ApplicationDragAndDropHost* drag_and_drop_host); | 64 ApplicationDragAndDropHost* drag_and_drop_host); | 
| 56 | 65 | 
| 57 // Shows the UI when there are no pending icon loads. Otherwise, starts a | 66 // 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. | 67 // timer to show the UI when a maximum allowed wait time has expired. | 
| 59 void ShowWhenReady(); | 68 void ShowWhenReady(); | 
| 60 | 69 | 
| 61 void CloseAppList(); | 70 void CloseAppList(); | 
| 
 
msw
2017/06/07 02:31:38
You could potentially replace this with SetState(C
 
newcomer
2017/06/07 17:21:38
Done.
 
 | |
| 62 | 71 | 
| 63 void UpdateBounds(); | 72 void UpdateBounds(); | 
| 64 | 73 | 
| 65 // Enables/disables a semi-transparent overlay over the app list (good for | 74 // Enables/disables a semi-transparent overlay over the app list (good for | 
| 66 // hiding the app list when a modal dialog is being shown). | 75 // hiding the app list when a modal dialog is being shown). | 
| 67 void SetAppListOverlayVisible(bool visible); | 76 void SetAppListOverlayVisible(bool visible); | 
| 68 | 77 | 
| 69 views::Widget* search_box_widget() const { return search_box_widget_; } | 78 views::Widget* search_box_widget() const { return search_box_widget_; } | 
| 70 | 79 | 
| 71 // Overridden from views::View: | 80 // Overridden from views::View: | 
| (...skipping 10 matching lines...) Expand all Loading... | |
| 82 AppListMainView* app_list_main_view() { return app_list_main_view_; } | 91 AppListMainView* app_list_main_view() { return app_list_main_view_; } | 
| 83 | 92 | 
| 84 // Gets the PaginationModel owned by this view's apps grid. | 93 // Gets the PaginationModel owned by this view's apps grid. | 
| 85 PaginationModel* GetAppsPaginationModel(); | 94 PaginationModel* GetAppsPaginationModel(); | 
| 86 | 95 | 
| 87 // Overridden from views::View: | 96 // Overridden from views::View: | 
| 88 bool AcceleratorPressed(const ui::Accelerator& accelerator) override; | 97 bool AcceleratorPressed(const ui::Accelerator& accelerator) override; | 
| 89 void Layout() override; | 98 void Layout() override; | 
| 90 void SchedulePaintInRect(const gfx::Rect& rect) override; | 99 void SchedulePaintInRect(const gfx::Rect& rect) override; | 
| 91 | 100 | 
| 101 // Changes the view to the peeking state or to the fullscreen state. | |
| 102 void ToFullscreen(); | |
| 
 
msw
2017/06/07 02:31:39
Remove these now that we have ChangeState/SetState
 
newcomer
2017/06/07 17:21:38
Done.
 
 | |
| 103 void ToPeeking(); | |
| 104 void ChangeState(AppListState new_state); | |
| 
 
msw
2017/06/07 02:31:39
Rename this SetState
 
newcomer
2017/06/07 17:21:38
Done.
 
 | |
| 105 | |
| 106 bool IsFullscreen() const; | |
| 
 
msw
2017/06/07 02:31:39
Change this to |AppListState app_list_state() cons
 
newcomer
2017/06/07 17:21:38
I think having both is a good idea. Thanks!
 
 | |
| 107 | |
| 92 private: | 108 private: | 
| 93 friend class test::AppListViewTestApi; | 109 friend class test::AppListViewTestApi; | 
| 94 | 110 | 
| 95 void InitContents(gfx::NativeView parent, int initial_apps_page); | 111 void InitContents(gfx::NativeView parent, int initial_apps_page); | 
| 96 | 112 | 
| 97 void InitChildWidgets(); | 113 void InitChildWidgets(); | 
| 98 | 114 | 
| 99 // Initializes the widget for fullscreen mode. | 115 // Initializes the widget for fullscreen mode. | 
| 100 void InitializeFullscreen(gfx::NativeView parent, int initial_apps_page); | 116 void InitializeFullscreen(gfx::NativeView parent, int initial_apps_page); | 
| 101 | 117 | 
| 102 // Initializes the widget as a bubble. | 118 // Initializes the widget as a bubble. | 
| 103 void InitializeBubble(gfx::NativeView parent, int initial_apps_page); | 119 void InitializeBubble(gfx::NativeView parent, int initial_apps_page); | 
| 104 | 120 | 
| 121 // Initializes |initial_drag_point_|. | |
| 122 void StartDrag(const gfx::Point& location); | |
| 123 | |
| 124 // Updates the bounds of the widget while maintaining the relative position | |
| 125 // of the top of the widget and the gesture. | |
| 126 void UpdateDrag(const gfx::Point& location); | |
| 127 | |
| 128 // Handles app list state transfers. If the drag was fast enough, ignore the | |
| 129 // release position and snap to the next state. | |
| 130 void EndDrag(const gfx::Point& location); | |
| 131 | |
| 105 // Overridden from views::BubbleDialogDelegateView: | 132 // Overridden from views::BubbleDialogDelegateView: | 
| 106 void OnBeforeBubbleWidgetInit(views::Widget::InitParams* params, | 133 void OnBeforeBubbleWidgetInit(views::Widget::InitParams* params, | 
| 107 views::Widget* widget) const override; | 134 views::Widget* widget) const override; | 
| 108 int GetDialogButtons() const override; | 135 int GetDialogButtons() const override; | 
| 109 | 136 | 
| 110 // Overridden from views::WidgetDelegateView: | 137 // Overridden from views::WidgetDelegateView: | 
| 111 views::View* GetInitiallyFocusedView() override; | 138 views::View* GetInitiallyFocusedView() override; | 
| 112 bool WidgetHasHitTestMask() const override; | 139 bool WidgetHasHitTestMask() const override; | 
| 113 void GetWidgetHitTestMask(gfx::Path* mask) const override; | 140 void GetWidgetHitTestMask(gfx::Path* mask) const override; | 
| 114 | 141 | 
| 142 // Overridden from ui::EventHandler: | |
| 143 void OnMouseEvent(ui::MouseEvent* event) override; | |
| 144 void OnGestureEvent(ui::GestureEvent* event) override; | |
| 145 | |
| 115 // Overridden from views::WidgetObserver: | 146 // Overridden from views::WidgetObserver: | 
| 116 void OnWidgetDestroying(views::Widget* widget) override; | 147 void OnWidgetDestroying(views::Widget* widget) override; | 
| 117 void OnWidgetVisibilityChanged(views::Widget* widget, bool visible) override; | 148 void OnWidgetVisibilityChanged(views::Widget* widget, bool visible) override; | 
| 118 | 149 | 
| 119 // Overridden from SpeechUIModelObserver: | 150 // Overridden from SpeechUIModelObserver: | 
| 120 void OnSpeechRecognitionStateChanged( | 151 void OnSpeechRecognitionStateChanged( | 
| 121 SpeechRecognitionState new_state) override; | 152 SpeechRecognitionState new_state) override; | 
| 122 | 153 | 
| 154 // Overridden from DisplayObserver: | |
| 155 void OnDisplayMetricsChanged(const display::Display& display, | |
| 156 uint32_t changed_metrics) override; | |
| 157 | |
| 123 AppListViewDelegate* delegate_; // Weak. Owned by AppListService. | 158 AppListViewDelegate* delegate_; // Weak. Owned by AppListService. | 
| 124 | 159 | 
| 125 AppListMainView* app_list_main_view_; | 160 AppListMainView* app_list_main_view_; | 
| 126 SpeechView* speech_view_; | 161 SpeechView* speech_view_; | 
| 162 views::Widget* fullscreen_widget_ = nullptr; // Owned by AppListView. | |
| 127 | 163 | 
| 128 views::View* search_box_focus_host_; // Owned by the views hierarchy. | 164 views::View* search_box_focus_host_; // Owned by the views hierarchy. | 
| 129 views::Widget* search_box_widget_; // Owned by the app list's widget. | 165 views::Widget* search_box_widget_; // Owned by the app list's widget. | 
| 130 SearchBoxView* search_box_view_; // Owned by |search_box_widget_|. | 166 SearchBoxView* search_box_view_; // Owned by |search_box_widget_|. | 
| 167 // Owned by the app list's widget. Null if the fullscreen app list is not | |
| 168 // enabled. | |
| 169 views::View* app_list_background_shield_ = nullptr; | |
| 170 // The gap between the initial gesture event and the top of the window. | |
| 171 gfx::Point initial_drag_point_; | |
| 172 // The velocity of the gesture event. | |
| 173 float last_fling_velocity_ = 0; | |
| 174 // The default y coordinate of the current state of the app list. Changes | |
| 175 // based on the app list state and screen orientation. | |
| 176 int default_peeking_y_ = 0; | |
| 
 
msw
2017/06/07 02:31:39
Remove this, it's no longer used.
 
newcomer
2017/06/07 17:21:38
Done.
 
 | |
| 177 bool is_fullscreen_app_list_ = false; | |
| 
 
msw
2017/06/07 02:31:39
Remove this, it's no longer used.
 
newcomer
2017/06/07 17:21:38
Done.
 
 | |
| 178 // Flag temporarily used to prevent repeated calls to | |
| 179 // features::IsFullscreenAppListEnabled. | |
| 180 bool is_fullscreen_app_list_enabled_ = false; | |
| 
 
msw
2017/06/07 02:31:39
Move this to a file-local function in cc file's an
 
newcomer
2017/06/07 17:21:38
Done.
 
 | |
| 181 // The desktop area, not including the shelf. | |
| 182 gfx::Rect display_work_area_bounds_; | |
| 
 
msw
2017/06/07 02:31:39
Remove this, it's no longer used.
 
newcomer
2017/06/07 17:21:38
Done.
 
 | |
| 183 // The bounds of the app list. The size should never change, only the | |
| 184 // position. | |
| 185 gfx::Rect fullscreen_widget_bounds_; | |
| 
 
msw
2017/06/07 02:31:39
Remove this, it's no longer used.
 
newcomer
2017/06/07 17:21:37
Done.
 
 | |
| 186 // The state of the app list, controlled via ChangeState(). | |
| 
 
msw
2017/06/07 02:31:39
Update ChangeState -> SetState if you accept that
 
newcomer
2017/06/07 17:21:37
Done.
 
 | |
| 187 AppListState app_list_state_; | |
| 
 
msw
2017/06/07 02:31:39
Initialize this value here or in the constructor.
 
newcomer
2017/06/07 17:21:38
Initialized in the constructor.
 
 | |
| 188 | |
| 189 // An observer that notifies AppListView when the display has changed. | |
| 190 ScopedObserver<display::Screen, display::DisplayObserver> display_observer_; | |
| 131 | 191 | 
| 132 // A semi-transparent white overlay that covers the app list while dialogs are | 192 // A semi-transparent white overlay that covers the app list while dialogs are | 
| 133 // open. | 193 // open. | 
| 134 views::View* overlay_view_; | 194 views::View* overlay_view_; | 
| 135 | 195 | 
| 136 std::unique_ptr<HideViewAnimationObserver> animation_observer_; | 196 std::unique_ptr<HideViewAnimationObserver> animation_observer_; | 
| 137 | 197 | 
| 138 // For UMA and testing. If non-null, triggered when the app list is painted. | 198 // For UMA and testing. If non-null, triggered when the app list is painted. | 
| 139 base::Closure next_paint_callback_; | 199 base::Closure next_paint_callback_; | 
| 140 | 200 | 
| 141 DISALLOW_COPY_AND_ASSIGN(AppListView); | 201 DISALLOW_COPY_AND_ASSIGN(AppListView); | 
| 142 }; | 202 }; | 
| 143 | 203 | 
| 144 } // namespace app_list | 204 } // namespace app_list | 
| 145 | 205 | 
| 146 #endif // UI_APP_LIST_VIEWS_APP_LIST_VIEW_H_ | 206 #endif // UI_APP_LIST_VIEWS_APP_LIST_VIEW_H_ | 
| OLD | NEW |