Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(89)

Side by Side Diff: ui/app_list/views/app_list_view.h

Issue 2898743002: Draggable peeking/fullscreen launcher with transparent background. (Closed)
Patch Set: adressed comments. Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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"
17 #include "ui/display/screen.h"
xiyuan 2017/05/26 18:27:32 Can this be moved to cc?
newcomer 2017/05/26 23:20:22 Done. Forward declared Screen.
15 #include "ui/views/bubble/bubble_dialog_delegate.h" 18 #include "ui/views/bubble/bubble_dialog_delegate.h"
16 #include "ui/views/widget/widget.h" 19 #include "ui/views/widget/widget.h"
17 20
18 namespace app_list { 21 namespace app_list {
19 class ApplicationDragAndDropHost; 22 class ApplicationDragAndDropHost;
20 class AppListMainView; 23 class AppListMainView;
21 class AppListModel; 24 class AppListModel;
22 class AppListViewDelegate; 25 class AppListViewDelegate;
23 class HideViewAnimationObserver; 26 class HideViewAnimationObserver;
24 class PaginationModel; 27 class PaginationModel;
25 class SearchBoxView; 28 class SearchBoxView;
26 class SpeechView; 29 class SpeechView;
27 30
28 namespace test { 31 namespace test {
29 class AppListViewTestApi; 32 class AppListViewTestApi;
30 } 33 }
31 34
32 // AppListView is the top-level view and controller of app list UI. It creates 35 // 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. 36 // and hosts a AppsGridView and passes AppListModel to it for display.
34 class APP_LIST_EXPORT AppListView : public views::BubbleDialogDelegateView, 37 class APP_LIST_EXPORT AppListView : public views::BubbleDialogDelegateView,
35 public SpeechUIModelObserver { 38 public SpeechUIModelObserver,
39 public display::DisplayObserver {
36 public: 40 public:
37 // Does not take ownership of |delegate|. 41 // Does not take ownership of |delegate|.
38 explicit AppListView(AppListViewDelegate* delegate); 42 explicit AppListView(AppListViewDelegate* delegate);
39 ~AppListView() override; 43 ~AppListView() override;
40 44
41 // Initializes the widget as a bubble or fullscreen view depending on the 45 // 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 46 // presence of a cmd line switch. parent and initial_apps_page are used for
43 // both the bubble and fullscreen initialization. 47 // both the bubble and fullscreen initialization.
44 void Initialize(gfx::NativeView parent, int initial_apps_page); 48 void Initialize(gfx::NativeView parent, int initial_apps_page);
45 49
46 void SetBubbleArrow(views::BubbleBorder::Arrow arrow); 50 void SetBubbleArrow(views::BubbleBorder::Arrow arrow);
47 51
48 void MaybeSetAnchorPoint(const gfx::Point& anchor_point); 52 void MaybeSetAnchorPoint(const gfx::Point& anchor_point);
49 53
50 // If |drag_and_drop_host| is not NULL it will be called upon drag and drop 54 // 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 55 // 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 56 // Initialize was called since the app list object needs to exist so that
53 // it can set the host. 57 // it can set the host.
54 void SetDragAndDropHostOfCurrentAppList( 58 void SetDragAndDropHostOfCurrentAppList(
55 ApplicationDragAndDropHost* drag_and_drop_host); 59 ApplicationDragAndDropHost* drag_and_drop_host);
56 60
57 // Shows the UI when there are no pending icon loads. Otherwise, starts a 61 // 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. 62 // timer to show the UI when a maximum allowed wait time has expired.
59 void ShowWhenReady(); 63 void ShowWhenReady();
60 64
61 void CloseAppList(); 65 void CloseAppList();
62 66
63 void UpdateBounds(); 67 void UpdateBounds();
64 68
69 void UpdateDimensions();
70
65 // Enables/disables a semi-transparent overlay over the app list (good for 71 // Enables/disables a semi-transparent overlay over the app list (good for
66 // hiding the app list when a modal dialog is being shown). 72 // hiding the app list when a modal dialog is being shown).
67 void SetAppListOverlayVisible(bool visible); 73 void SetAppListOverlayVisible(bool visible);
68 74
69 views::Widget* search_box_widget() const { return search_box_widget_; } 75 views::Widget* search_box_widget() const { return search_box_widget_; }
70 76
71 // Overridden from views::View: 77 // Overridden from views::View:
72 gfx::Size GetPreferredSize() const override; 78 gfx::Size GetPreferredSize() const override;
73 void OnPaint(gfx::Canvas* canvas) override; 79 void OnPaint(gfx::Canvas* canvas) override;
74 const char* GetClassName() const override; 80 const char* GetClassName() const override;
75 81
76 // WidgetDelegate overrides: 82 // WidgetDelegate overrides:
77 bool ShouldHandleSystemCommands() const override; 83 bool ShouldHandleSystemCommands() const override;
78 bool ShouldDescendIntoChildForEventHandling( 84 bool ShouldDescendIntoChildForEventHandling(
79 gfx::NativeView child, 85 gfx::NativeView child,
80 const gfx::Point& location) override; 86 const gfx::Point& location) override;
81 87
82 AppListMainView* app_list_main_view() { return app_list_main_view_; } 88 AppListMainView* app_list_main_view() { return app_list_main_view_; }
83 89
84 // Gets the PaginationModel owned by this view's apps grid. 90 // Gets the PaginationModel owned by this view's apps grid.
85 PaginationModel* GetAppsPaginationModel(); 91 PaginationModel* GetAppsPaginationModel();
86 92
87 // Overridden from views::View: 93 // Overridden from views::View:
88 bool AcceleratorPressed(const ui::Accelerator& accelerator) override; 94 bool AcceleratorPressed(const ui::Accelerator& accelerator) override;
89 void Layout() override; 95 void Layout() override;
90 void SchedulePaintInRect(const gfx::Rect& rect) override; 96 void SchedulePaintInRect(const gfx::Rect& rect) override;
91 97
98 // Changes the view to the peeking state or to the fullscreen state.
99 void ToFullscreen();
100 void ToPeeking();
101
102 bool IsFullscreen() const;
103
92 private: 104 private:
93 friend class test::AppListViewTestApi; 105 friend class test::AppListViewTestApi;
94 106
95 void InitContents(gfx::NativeView parent, int initial_apps_page); 107 void InitContents(gfx::NativeView parent, int initial_apps_page);
96 108
97 void InitChildWidgets(); 109 void InitChildWidgets();
98 110
99 // Initializes the widget for fullscreen mode. 111 // Initializes the widget for fullscreen mode.
100 void InitializeFullscreen(gfx::NativeView parent, int initial_apps_page); 112 void InitializeFullscreen(gfx::NativeView parent, int initial_apps_page);
101 113
102 // Initializes the widget as a bubble. 114 // Initializes the widget as a bubble.
103 void InitializeBubble(gfx::NativeView parent, int initial_apps_page); 115 void InitializeBubble(gfx::NativeView parent, int initial_apps_page);
104 116
117 // Handles all drag logic for the app list view. Touch and Click events are
118 // filtered through OnMouseEvent and OnGestureEvent before being passed to
119 // HandleDrag.
120 void HandleDrag(gfx::Point location, ui::EventType type);
vadimt 2017/05/26 17:58:55 const gfx::Point&
xiyuan 2017/05/26 18:27:32 gfx::Point -> const gfx::Point&
newcomer 2017/05/26 23:20:22 Done.
newcomer 2017/05/26 23:20:22 Done.
121
105 // Overridden from views::BubbleDialogDelegateView: 122 // Overridden from views::BubbleDialogDelegateView:
106 void OnBeforeBubbleWidgetInit(views::Widget::InitParams* params, 123 void OnBeforeBubbleWidgetInit(views::Widget::InitParams* params,
107 views::Widget* widget) const override; 124 views::Widget* widget) const override;
108 int GetDialogButtons() const override; 125 int GetDialogButtons() const override;
109 126
110 // Overridden from views::WidgetDelegateView: 127 // Overridden from views::WidgetDelegateView:
111 views::View* GetInitiallyFocusedView() override; 128 views::View* GetInitiallyFocusedView() override;
112 bool WidgetHasHitTestMask() const override; 129 bool WidgetHasHitTestMask() const override;
113 void GetWidgetHitTestMask(gfx::Path* mask) const override; 130 void GetWidgetHitTestMask(gfx::Path* mask) const override;
114 131
132 // Overridden from ui::EventHandler
xiyuan 2017/05/26 18:27:32 nit: end with ":" like other overridden comments
newcomer 2017/05/26 23:20:22 Done.
133 void OnMouseEvent(ui::MouseEvent* event) override;
134 void OnGestureEvent(ui::GestureEvent* event) override;
135
115 // Overridden from views::WidgetObserver: 136 // Overridden from views::WidgetObserver:
116 void OnWidgetDestroying(views::Widget* widget) override; 137 void OnWidgetDestroying(views::Widget* widget) override;
117 void OnWidgetVisibilityChanged(views::Widget* widget, bool visible) override; 138 void OnWidgetVisibilityChanged(views::Widget* widget, bool visible) override;
118 139
119 // Overridden from SpeechUIModelObserver: 140 // Overridden from SpeechUIModelObserver:
120 void OnSpeechRecognitionStateChanged( 141 void OnSpeechRecognitionStateChanged(
121 SpeechRecognitionState new_state) override; 142 SpeechRecognitionState new_state) override;
122 143
144 // Overridden from DisplayObserver:
145 void OnDisplayMetricsChanged(const display::Display& display,
146 uint32_t changed_metrics) override;
147
123 AppListViewDelegate* delegate_; // Weak. Owned by AppListService. 148 AppListViewDelegate* delegate_; // Weak. Owned by AppListService.
124 149
125 AppListMainView* app_list_main_view_; 150 AppListMainView* app_list_main_view_;
126 SpeechView* speech_view_; 151 SpeechView* speech_view_;
152 views::Widget* fullscreen_widget_ = nullptr; // Owned by AppListView.
127 153
128 views::View* search_box_focus_host_; // Owned by the views hierarchy. 154 views::View* search_box_focus_host_; // Owned by the views hierarchy.
129 views::Widget* search_box_widget_; // Owned by the app list's widget. 155 views::Widget* search_box_widget_; // Owned by the app list's widget.
130 SearchBoxView* search_box_view_; // Owned by |search_box_widget_|. 156 SearchBoxView* search_box_view_; // Owned by |search_box_widget_|.
157 // Owned by the app list's widget.
158 views::View* launcher_background_shield_ = nullptr;
159 // The gap between the initial gesture event and the top of the window.
160 int initial_drag_separation_ = 0;
161 // The velocity of the gesture event.
162 float last_fling_velocity_ = 0;
163 // The height of the peeking launcher, which changes based on screen
164 // orientation.
165 int default_peeking_launcher_y_ = 0;
166 // The DIP delta that must be exceeded for the launcher to snap to the next
167 // state.
168 int launcher_threshold_ = 0;
169 bool is_fullscreen_launcher_ = false;
170 // The desktop area, not including the shelf.
171 gfx::Rect display_work_area_bounds_;
172 // The bounds of the launcher. The size should never change, only the
173 // position.
174 gfx::Rect fullscreen_widget_bounds_;
175
176 ScopedObserver<display::Screen, display::DisplayObserver> display_observer_;
vadimt 2017/05/26 17:58:55 Comments for all new fields (in .h files). Everywh
newcomer 2017/05/26 23:20:22 Done.
131 177
132 // A semi-transparent white overlay that covers the app list while dialogs are 178 // A semi-transparent white overlay that covers the app list while dialogs are
133 // open. 179 // open.
134 views::View* overlay_view_; 180 views::View* overlay_view_;
135 181
136 std::unique_ptr<HideViewAnimationObserver> animation_observer_; 182 std::unique_ptr<HideViewAnimationObserver> animation_observer_;
137 183
138 // For UMA and testing. If non-null, triggered when the app list is painted. 184 // For UMA and testing. If non-null, triggered when the app list is painted.
139 base::Closure next_paint_callback_; 185 base::Closure next_paint_callback_;
140 186
141 DISALLOW_COPY_AND_ASSIGN(AppListView); 187 DISALLOW_COPY_AND_ASSIGN(AppListView);
142 }; 188 };
143 189
144 } // namespace app_list 190 } // namespace app_list
145 191
146 #endif // UI_APP_LIST_VIEWS_APP_LIST_VIEW_H_ 192 #endif // UI_APP_LIST_VIEWS_APP_LIST_VIEW_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698