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 "build/build_config.h" | 12 #include "build/build_config.h" | 
| 13 #include "ui/app_list/app_list_export.h" | 13 #include "ui/app_list/app_list_export.h" | 
| 14 #include "ui/app_list/speech_ui_model_observer.h" | 14 #include "ui/app_list/speech_ui_model_observer.h" | 
| 15 #include "ui/display/display_observer.h" | |
| 15 #include "ui/views/bubble/bubble_dialog_delegate.h" | 16 #include "ui/views/bubble/bubble_dialog_delegate.h" | 
| 16 #include "ui/views/widget/widget.h" | 17 #include "ui/views/widget/widget.h" | 
| 17 | 18 | 
| 18 namespace app_list { | 19 namespace app_list { | 
| 19 class ApplicationDragAndDropHost; | 20 class ApplicationDragAndDropHost; | 
| 20 class AppListMainView; | 21 class AppListMainView; | 
| 21 class AppListModel; | 22 class AppListModel; | 
| 22 class AppListViewDelegate; | 23 class AppListViewDelegate; | 
| 23 class HideViewAnimationObserver; | 24 class HideViewAnimationObserver; | 
| 24 class PaginationModel; | 25 class PaginationModel; | 
| 25 class SearchBoxView; | 26 class SearchBoxView; | 
| 26 class SpeechView; | 27 class SpeechView; | 
| 27 | 28 | 
| 28 namespace test { | 29 namespace test { | 
| 29 class AppListViewTestApi; | 30 class AppListViewTestApi; | 
| 30 } | 31 } | 
| 31 | 32 | 
| 32 // AppListView is the top-level view and controller of app list UI. It creates | 33 // 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. | 34 // and hosts a AppsGridView and passes AppListModel to it for display. | 
| 34 class APP_LIST_EXPORT AppListView : public views::BubbleDialogDelegateView, | 35 class APP_LIST_EXPORT AppListView : public views::BubbleDialogDelegateView, | 
| 35 public SpeechUIModelObserver { | 36 public SpeechUIModelObserver, | 
| 37 public display::DisplayObserver { | |
| 36 public: | 38 public: | 
| 37 // Does not take ownership of |delegate|. | 39 // Does not take ownership of |delegate|. | 
| 38 explicit AppListView(AppListViewDelegate* delegate); | 40 explicit AppListView(AppListViewDelegate* delegate); | 
| 39 ~AppListView() override; | 41 ~AppListView() override; | 
| 40 | 42 | 
| 41 // Initializes the widget as a bubble or fullscreen view depending on the | 43 // 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 | 44 // presence of a cmd line switch. parent and initial_apps_page are used for | 
| 43 // both the bubble and fullscreen initialization. | 45 // both the bubble and fullscreen initialization. | 
| 44 void Initialize(gfx::NativeView parent, int initial_apps_page); | 46 void Initialize(gfx::NativeView parent, int initial_apps_page); | 
| 45 | 47 | 
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 79 gfx::NativeView child, | 81 gfx::NativeView child, | 
| 80 const gfx::Point& location) override; | 82 const gfx::Point& location) override; | 
| 81 | 83 | 
| 82 AppListMainView* app_list_main_view() { return app_list_main_view_; } | 84 AppListMainView* app_list_main_view() { return app_list_main_view_; } | 
| 83 | 85 | 
| 84 // Gets the PaginationModel owned by this view's apps grid. | 86 // Gets the PaginationModel owned by this view's apps grid. | 
| 85 PaginationModel* GetAppsPaginationModel(); | 87 PaginationModel* GetAppsPaginationModel(); | 
| 86 | 88 | 
| 87 // Overridden from views::View: | 89 // Overridden from views::View: | 
| 88 bool AcceleratorPressed(const ui::Accelerator& accelerator) override; | 90 bool AcceleratorPressed(const ui::Accelerator& accelerator) override; | 
| 91 | |
| 92 void ComputeConstants(); | |
| 
 
vadimt
2017/05/22 23:36:58
Please don't place it between views::View override
 
newcomer
2017/05/25 23:10:53
Done.
 
 | |
| 93 | |
| 89 void Layout() override; | 94 void Layout() override; | 
| 90 void SchedulePaintInRect(const gfx::Rect& rect) override; | 95 void SchedulePaintInRect(const gfx::Rect& rect) override; | 
| 91 | 96 | 
| 97 // Changes the view to the peeking state or to the fullscreen state. | |
| 98 void ToFullscreen(); | |
| 99 void ToPeeking(); | |
| 100 | |
| 101 bool IsFullscreen(); | |
| 
 
vadimt
2017/05/22 23:36:58
I assume there are 2 states Fullscreen and peeking
 
newcomer
2017/05/25 23:10:53
In the next CL there will be five states (INITIAL,
 
vadimt
2017/05/26 01:27:56
Acknowledged.
 
 | |
| 102 | |
| 92 private: | 103 private: | 
| 93 friend class test::AppListViewTestApi; | 104 friend class test::AppListViewTestApi; | 
| 94 | 105 | 
| 95 void InitContents(gfx::NativeView parent, int initial_apps_page); | 106 void InitContents(gfx::NativeView parent, int initial_apps_page); | 
| 96 | 107 | 
| 97 void InitChildWidgets(); | 108 void InitChildWidgets(); | 
| 98 | 109 | 
| 99 // Initializes the widget for fullscreen mode. | 110 // Initializes the widget for fullscreen mode. | 
| 100 void InitializeFullscreen(gfx::NativeView parent, int initial_apps_page); | 111 void InitializeFullscreen(gfx::NativeView parent, int initial_apps_page); | 
| 101 | 112 | 
| 102 // Initializes the widget as a bubble. | 113 // Initializes the widget as a bubble. | 
| 103 void InitializeBubble(gfx::NativeView parent, int initial_apps_page); | 114 void InitializeBubble(gfx::NativeView parent, int initial_apps_page); | 
| 104 | 115 | 
| 105 // Overridden from views::BubbleDialogDelegateView: | 116 // Overridden from views::BubbleDialogDelegateView: | 
| 106 void OnBeforeBubbleWidgetInit(views::Widget::InitParams* params, | 117 void OnBeforeBubbleWidgetInit(views::Widget::InitParams* params, | 
| 107 views::Widget* widget) const override; | 118 views::Widget* widget) const override; | 
| 108 int GetDialogButtons() const override; | 119 int GetDialogButtons() const override; | 
| 109 | 120 | 
| 110 // Overridden from views::WidgetDelegateView: | 121 // Overridden from views::WidgetDelegateView: | 
| 111 views::View* GetInitiallyFocusedView() override; | 122 views::View* GetInitiallyFocusedView() override; | 
| 112 bool WidgetHasHitTestMask() const override; | 123 bool WidgetHasHitTestMask() const override; | 
| 113 void GetWidgetHitTestMask(gfx::Path* mask) const override; | 124 void GetWidgetHitTestMask(gfx::Path* mask) const override; | 
| 114 | 125 | 
| 126 // Both OnMouseEvent and OnGestureEvent check to see if their events are | |
| 127 // drag events, if so the events are sent to HandleDrag which holds all | |
| 128 // AppListView drag logic. | |
| 129 void OnMouseEvent(ui::MouseEvent* event) override; | |
| 
 
vadimt
2017/05/22 23:36:58
You don't need comments for overrides. BTW are the
 
newcomer
2017/05/25 23:10:53
They are ui::EventHandler overrides. Done!
 
 | |
| 130 void OnGestureEvent(ui::GestureEvent* event) override; | |
| 131 | |
| 132 // Handles all drag logic for the app list view. Touch and Click events are | |
| 133 // filtered through OnMouseEvent and OnGestureEvent before being passed to | |
| 134 // HandleDrag. | |
| 135 void HandleDrag(gfx::Point location, ui::EventType type); | |
| 
 
vadimt
2017/05/22 23:36:58
Is this override? If so, add override keyword; els
 
newcomer
2017/05/25 23:10:53
Done.
 
 | |
| 136 | |
| 115 // Overridden from views::WidgetObserver: | 137 // Overridden from views::WidgetObserver: | 
| 116 void OnWidgetDestroying(views::Widget* widget) override; | 138 void OnWidgetDestroying(views::Widget* widget) override; | 
| 117 void OnWidgetVisibilityChanged(views::Widget* widget, bool visible) override; | 139 void OnWidgetVisibilityChanged(views::Widget* widget, bool visible) override; | 
| 118 | 140 | 
| 119 // Overridden from SpeechUIModelObserver: | 141 // Overridden from SpeechUIModelObserver: | 
| 120 void OnSpeechRecognitionStateChanged( | 142 void OnSpeechRecognitionStateChanged( | 
| 121 SpeechRecognitionState new_state) override; | 143 SpeechRecognitionState new_state) override; | 
| 122 | 144 | 
| 145 // Overridden from DisplayObserver: | |
| 146 void OnDisplayMetricsChanged(const display::Display& display, | |
| 147 uint32_t changed_metrics) override; | |
| 148 | |
| 123 AppListViewDelegate* delegate_; // Weak. Owned by AppListService. | 149 AppListViewDelegate* delegate_; // Weak. Owned by AppListService. | 
| 124 | 150 | 
| 125 AppListMainView* app_list_main_view_; | 151 AppListMainView* app_list_main_view_; | 
| 126 SpeechView* speech_view_; | 152 SpeechView* speech_view_; | 
| 153 views::Widget* fullscreen_widget_; | |
| 127 | 154 | 
| 128 views::View* search_box_focus_host_; // Owned by the views hierarchy. | 155 views::View* search_box_focus_host_; // Owned by the views hierarchy. | 
| 129 views::Widget* search_box_widget_; // Owned by the app list's widget. | 156 views::Widget* search_box_widget_; // Owned by the app list's widget. | 
| 130 SearchBoxView* search_box_view_; // Owned by |search_box_widget_|. | 157 SearchBoxView* search_box_view_; // Owned by |search_box_widget_|. | 
| 158 views::View* launcher_background_shield_; // Owned by the app list's widget. | |
| 
 
vadimt
2017/05/22 23:36:58
I assume all added fields can't be made const fiel
 
xiyuan
2017/05/24 18:28:18
Initialize it to nullptr,
i.e.
  views::View* lau
 
newcomer
2017/05/25 23:10:53
Correct.
 
newcomer
2017/05/25 23:10:53
Done.
 
 | |
| 159 | |
| 160 int initial_drag_separation_; | |
| 
 
vadimt
2017/05/22 23:36:58
I know that other fields don't have comments, but
 
newcomer
2017/05/25 23:10:53
Done.
 
 | |
| 161 float last_fling_velocity_; | |
| 162 int default_peeking_launcher_y_; | |
| 163 int launcher_threshold_; | |
| 164 bool is_fullscreen_launcher_; | |
| 165 gfx::Rect display_work_area_bounds_; | |
| 166 gfx::Rect fullscreen_widget_bounds_; | |
| 131 | 167 | 
| 132 // A semi-transparent white overlay that covers the app list while dialogs are | 168 // A semi-transparent white overlay that covers the app list while dialogs are | 
| 133 // open. | 169 // open. | 
| 134 views::View* overlay_view_; | 170 views::View* overlay_view_; | 
| 135 | 171 | 
| 136 std::unique_ptr<HideViewAnimationObserver> animation_observer_; | 172 std::unique_ptr<HideViewAnimationObserver> animation_observer_; | 
| 137 | 173 | 
| 138 // For UMA and testing. If non-null, triggered when the app list is painted. | 174 // For UMA and testing. If non-null, triggered when the app list is painted. | 
| 139 base::Closure next_paint_callback_; | 175 base::Closure next_paint_callback_; | 
| 140 | 176 | 
| 141 DISALLOW_COPY_AND_ASSIGN(AppListView); | 177 DISALLOW_COPY_AND_ASSIGN(AppListView); | 
| 142 }; | 178 }; | 
| 143 | 179 | 
| 144 } // namespace app_list | 180 } // namespace app_list | 
| 145 | 181 | 
| 146 #endif // UI_APP_LIST_VIEWS_APP_LIST_VIEW_H_ | 182 #endif // UI_APP_LIST_VIEWS_APP_LIST_VIEW_H_ | 
| OLD | NEW |