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

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

Issue 2898743002: Draggable peeking/fullscreen launcher with transparent background. (Closed)
Patch Set: Addressed 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"
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:
37 // Does not take ownership of |delegate|. 44 // Does not take ownership of |delegate|.
38 explicit AppListView(AppListViewDelegate* delegate); 45 explicit AppListView(AppListViewDelegate* delegate);
39 ~AppListView() override; 46 ~AppListView() override;
40 47
41 // Initializes the widget as a bubble or fullscreen view depending on the 48 // 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 49 // presence of a cmd line switch. parent and initial_apps_page are used for
43 // both the bubble and fullscreen initialization. 50 // both the bubble and fullscreen initialization.
44 void Initialize(gfx::NativeView parent, int initial_apps_page); 51 void Initialize(gfx::NativeView parent, int initial_apps_page);
45 52
46 void SetBubbleArrow(views::BubbleBorder::Arrow arrow); 53 void SetBubbleArrow(views::BubbleBorder::Arrow arrow);
47 54
48 void MaybeSetAnchorPoint(const gfx::Point& anchor_point); 55 void MaybeSetAnchorPoint(const gfx::Point& anchor_point);
49 56
50 // If |drag_and_drop_host| is not NULL it will be called upon drag and drop 57 // 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 58 // 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 59 // Initialize was called since the app list object needs to exist so that
53 // it can set the host. 60 // it can set the host.
54 void SetDragAndDropHostOfCurrentAppList( 61 void SetDragAndDropHostOfCurrentAppList(
55 ApplicationDragAndDropHost* drag_and_drop_host); 62 ApplicationDragAndDropHost* drag_and_drop_host);
56 63
57 // Shows the UI when there are no pending icon loads. Otherwise, starts a 64 // 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. 65 // timer to show the UI when a maximum allowed wait time has expired.
59 void ShowWhenReady(); 66 void ShowWhenReady();
60 67
61 void CloseAppList(); 68 void CloseAppList();
62 69
63 void UpdateBounds(); 70 void UpdateBounds();
64 71
72 void UpdateDimensions();
msw 2017/06/06 17:56:32 nit: UpdateSize? UpdateFullscreen?
newcomer 2017/06/06 23:26:28 Function removed as a side effect of other changes
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:
72 gfx::Size CalculatePreferredSize() const override; 81 gfx::Size CalculatePreferredSize() const override;
73 void OnPaint(gfx::Canvas* canvas) override; 82 void OnPaint(gfx::Canvas* canvas) override;
74 const char* GetClassName() const override; 83 const char* GetClassName() const override;
75 84
76 // WidgetDelegate overrides: 85 // WidgetDelegate overrides:
77 bool ShouldHandleSystemCommands() const override; 86 bool ShouldHandleSystemCommands() const override;
78 bool ShouldDescendIntoChildForEventHandling( 87 bool ShouldDescendIntoChildForEventHandling(
79 gfx::NativeView child, 88 gfx::NativeView child,
80 const gfx::Point& location) override; 89 const gfx::Point& location) override;
81 90
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/06 17:56:32 nit: combine these two to void SetFullscreen(bool
newcomer 2017/06/06 23:26:28 Settled offline, Introduced AppListState and Chang
103 void ToPeeking();
104
105 bool IsFullscreen() const;
106
92 private: 107 private:
93 friend class test::AppListViewTestApi; 108 friend class test::AppListViewTestApi;
94 109
95 void InitContents(gfx::NativeView parent, int initial_apps_page); 110 void InitContents(gfx::NativeView parent, int initial_apps_page);
96 111
97 void InitChildWidgets(); 112 void InitChildWidgets();
98 113
99 // Initializes the widget for fullscreen mode. 114 // Initializes the widget for fullscreen mode.
100 void InitializeFullscreen(gfx::NativeView parent, int initial_apps_page); 115 void InitializeFullscreen(gfx::NativeView parent, int initial_apps_page);
101 116
102 // Initializes the widget as a bubble. 117 // Initializes the widget as a bubble.
103 void InitializeBubble(gfx::NativeView parent, int initial_apps_page); 118 void InitializeBubble(gfx::NativeView parent, int initial_apps_page);
104 119
120 // Transfers drag events to Start/Update/EndDrag.
121 void HandleDrag(const gfx::Point& location, ui::EventType type);
122
123 // Initializes |initial_drag_separation_|.
124 void StartDrag(const gfx::Point& location);
125
126 // Updates the bounds of the widget while maintaining the relative position
127 // of the top of the widget and the gesture.
128 void UpdateDrag(const gfx::Point& location);
129
130 // Handles launcher state transfers. If the drag was fast enough, ignore the
131 // release position and snap to the next state.
132 void EndDrag(const gfx::Point& location);
133
105 // Overridden from views::BubbleDialogDelegateView: 134 // Overridden from views::BubbleDialogDelegateView:
106 void OnBeforeBubbleWidgetInit(views::Widget::InitParams* params, 135 void OnBeforeBubbleWidgetInit(views::Widget::InitParams* params,
107 views::Widget* widget) const override; 136 views::Widget* widget) const override;
108 int GetDialogButtons() const override; 137 int GetDialogButtons() const override;
109 138
110 // Overridden from views::WidgetDelegateView: 139 // Overridden from views::WidgetDelegateView:
111 views::View* GetInitiallyFocusedView() override; 140 views::View* GetInitiallyFocusedView() override;
112 bool WidgetHasHitTestMask() const override; 141 bool WidgetHasHitTestMask() const override;
113 void GetWidgetHitTestMask(gfx::Path* mask) const override; 142 void GetWidgetHitTestMask(gfx::Path* mask) const override;
114 143
144 // Overridden from ui::EventHandler:
145 void OnMouseEvent(ui::MouseEvent* event) override;
146 void OnGestureEvent(ui::GestureEvent* event) override;
147
115 // Overridden from views::WidgetObserver: 148 // Overridden from views::WidgetObserver:
116 void OnWidgetDestroying(views::Widget* widget) override; 149 void OnWidgetDestroying(views::Widget* widget) override;
117 void OnWidgetVisibilityChanged(views::Widget* widget, bool visible) override; 150 void OnWidgetVisibilityChanged(views::Widget* widget, bool visible) override;
118 151
119 // Overridden from SpeechUIModelObserver: 152 // Overridden from SpeechUIModelObserver:
120 void OnSpeechRecognitionStateChanged( 153 void OnSpeechRecognitionStateChanged(
121 SpeechRecognitionState new_state) override; 154 SpeechRecognitionState new_state) override;
122 155
156 // Overridden from DisplayObserver:
157 void OnDisplayMetricsChanged(const display::Display& display,
158 uint32_t changed_metrics) override;
159
123 AppListViewDelegate* delegate_; // Weak. Owned by AppListService. 160 AppListViewDelegate* delegate_; // Weak. Owned by AppListService.
124 161
125 AppListMainView* app_list_main_view_; 162 AppListMainView* app_list_main_view_;
126 SpeechView* speech_view_; 163 SpeechView* speech_view_;
164 views::Widget* fullscreen_widget_ = nullptr; // Owned by AppListView.
127 165
128 views::View* search_box_focus_host_; // Owned by the views hierarchy. 166 views::View* search_box_focus_host_; // Owned by the views hierarchy.
129 views::Widget* search_box_widget_; // Owned by the app list's widget. 167 views::Widget* search_box_widget_; // Owned by the app list's widget.
130 SearchBoxView* search_box_view_; // Owned by |search_box_widget_|. 168 SearchBoxView* search_box_view_; // Owned by |search_box_widget_|.
169 // Owned by the app list's widget. Null if the fullscreen launcher is not
msw 2017/06/06 17:56:32 nit: avoid using the term 'launcher' here and else
newcomer 2017/06/06 23:26:28 All of my changes that used 'launcher' have been c
170 // enabled.
171 views::View* launcher_background_shield_ = nullptr;
172 // The gap between the initial gesture event and the top of the window.
173 int initial_drag_separation_ = 0;
174 // The velocity of the gesture event.
175 float last_fling_velocity_ = 0;
176 // The default y coordinate of the current state of the launcher. Changes
177 // based on the launcher state and screen orientation.
msw 2017/06/06 17:56:32 Does this actually change based on the launcher st
newcomer 2017/06/06 23:26:28 Done.
178 int default_y_for_state_ = 0;
179 // The DIP delta that must be exceeded for the launcher to snap to the next
180 // state. Changes based on the launcher state.
181 int launcher_threshold_ = 0;
182 bool is_fullscreen_launcher_ = false;
183 // The desktop area, not including the shelf.
184 gfx::Rect display_work_area_bounds_;
185 // The bounds of the launcher. The size should never change, only the
186 // position.
187 gfx::Rect fullscreen_widget_bounds_;
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_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698