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

Side by Side Diff: ash/shelf/shelf_view.h

Issue 2033553003: Add MD ink drop ripple to shelf app items (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Added tests Created 4 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 ASH_SHELF_SHELF_VIEW_H_ 5 #ifndef ASH_SHELF_SHELF_VIEW_H_
6 #define ASH_SHELF_SHELF_VIEW_H_ 6 #define ASH_SHELF_SHELF_VIEW_H_
7 7
8 #include <memory> 8 #include <memory>
9 #include <string> 9 #include <string>
10 #include <utility> 10 #include <utility>
11 #include <vector> 11 #include <vector>
12 12
13 #include "ash/common/shelf/shelf_item_delegate.h" 13 #include "ash/common/shelf/shelf_item_delegate.h"
14 #include "ash/common/shelf/shelf_model_observer.h" 14 #include "ash/common/shelf/shelf_model_observer.h"
15 #include "ash/shelf/shelf_button_pressed_metric_tracker.h" 15 #include "ash/shelf/shelf_button_pressed_metric_tracker.h"
16 #include "ash/shelf/shelf_tooltip_manager.h" 16 #include "ash/shelf/shelf_tooltip_manager.h"
17 #include "ash/wm/gestures/shelf_gesture_handler.h" 17 #include "ash/wm/gestures/shelf_gesture_handler.h"
18 #include "base/macros.h" 18 #include "base/macros.h"
19 #include "base/observer_list.h" 19 #include "base/observer_list.h"
20 #include "ui/app_list/views/app_list_drag_and_drop_host.h" 20 #include "ui/app_list/views/app_list_drag_and_drop_host.h"
21 #include "ui/views/animation/bounds_animator_observer.h" 21 #include "ui/views/animation/bounds_animator_observer.h"
22 #include "ui/views/animation/ink_drop_state.h"
22 #include "ui/views/context_menu_controller.h" 23 #include "ui/views/context_menu_controller.h"
23 #include "ui/views/controls/button/button.h" 24 #include "ui/views/controls/button/button.h"
24 #include "ui/views/focus/focus_manager.h" 25 #include "ui/views/focus/focus_manager.h"
25 #include "ui/views/view.h" 26 #include "ui/views/view.h"
26 #include "ui/views/view_model.h" 27 #include "ui/views/view_model.h"
27 28
28 namespace ui { 29 namespace ui {
29 class MenuModel; 30 class MenuModel;
30 } 31 }
31 32
(...skipping 19 matching lines...) Expand all
51 class ShelfViewTestAPI; 52 class ShelfViewTestAPI;
52 } 53 }
53 54
54 extern const int SHELF_ALIGNMENT_UMA_ENUM_VALUE_BOTTOM; 55 extern const int SHELF_ALIGNMENT_UMA_ENUM_VALUE_BOTTOM;
55 extern const int SHELF_ALIGNMENT_UMA_ENUM_VALUE_LEFT; 56 extern const int SHELF_ALIGNMENT_UMA_ENUM_VALUE_LEFT;
56 extern const int SHELF_ALIGNMENT_UMA_ENUM_VALUE_RIGHT; 57 extern const int SHELF_ALIGNMENT_UMA_ENUM_VALUE_RIGHT;
57 extern const int SHELF_ALIGNMENT_UMA_ENUM_VALUE_COUNT; 58 extern const int SHELF_ALIGNMENT_UMA_ENUM_VALUE_COUNT;
58 59
59 class ASH_EXPORT ShelfView : public views::View, 60 class ASH_EXPORT ShelfView : public views::View,
60 public ShelfModelObserver, 61 public ShelfModelObserver,
61 public views::ButtonListener,
James Cook 2016/06/13 19:55:35 optional: You could also introduce an InkDropButto
mohsen 2016/06/14 06:24:38 Good idea. Done.
62 public views::ContextMenuController, 62 public views::ContextMenuController,
63 public views::FocusTraversable, 63 public views::FocusTraversable,
64 public views::BoundsAnimatorObserver, 64 public views::BoundsAnimatorObserver,
65 public app_list::ApplicationDragAndDropHost { 65 public app_list::ApplicationDragAndDropHost {
66 public: 66 public:
67 ShelfView(ShelfModel* model, 67 ShelfView(ShelfModel* model,
68 ShelfDelegate* delegate, 68 ShelfDelegate* delegate,
69 WmShelf* wm_shelf, 69 WmShelf* wm_shelf,
70 Shelf* shelf); 70 Shelf* shelf);
71 ~ShelfView() override; 71 ~ShelfView() override;
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
131 const gfx::Vector2d& cursor_offset_from_center, 131 const gfx::Vector2d& cursor_offset_from_center,
132 float scale_factor) override; 132 float scale_factor) override;
133 void UpdateDragIconProxy( 133 void UpdateDragIconProxy(
134 const gfx::Point& location_in_screen_coordinates) override; 134 const gfx::Point& location_in_screen_coordinates) override;
135 void DestroyDragIconProxy() override; 135 void DestroyDragIconProxy() override;
136 bool StartDrag(const std::string& app_id, 136 bool StartDrag(const std::string& app_id,
137 const gfx::Point& location_in_screen_coordinates) override; 137 const gfx::Point& location_in_screen_coordinates) override;
138 bool Drag(const gfx::Point& location_in_screen_coordinates) override; 138 bool Drag(const gfx::Point& location_in_screen_coordinates) override;
139 void EndDrag(bool cancel) override; 139 void EndDrag(bool cancel) override;
140 140
141 // Returns true if the event on the shelf item is not going to activate the
142 // item. Used to determine whether a pending ink drop should be shown or not.
143 bool ShouldIgnoreEventOnButton(views::View* view, const ui::Event& event);
James Cook 2016/06/13 19:55:35 Consider inverting the boolean sense of this and c
mohsen 2016/06/14 06:24:38 Done.
144
141 // The shelf buttons use the Pointer interface to enable item reordering. 145 // The shelf buttons use the Pointer interface to enable item reordering.
142 enum Pointer { NONE, DRAG_AND_DROP, MOUSE, TOUCH }; 146 enum Pointer { NONE, DRAG_AND_DROP, MOUSE, TOUCH };
143 void PointerPressedOnButton(views::View* view, 147 void PointerPressedOnButton(views::View* view,
144 Pointer pointer, 148 Pointer pointer,
145 const ui::LocatedEvent& event); 149 const ui::LocatedEvent& event);
146 void PointerDraggedOnButton(views::View* view, 150 void PointerDraggedOnButton(views::View* view,
147 Pointer pointer, 151 Pointer pointer,
148 const ui::LocatedEvent& event); 152 const ui::LocatedEvent& event);
149 void PointerReleasedOnButton(views::View* view, 153 void PointerReleasedOnButton(views::View* view,
150 Pointer pointer, 154 Pointer pointer,
151 bool canceled); 155 bool canceled);
152 156
157 // TODO(mohsen): |ink_drop| is used to do appropriate ink drop animation based
158 // on the action performed. A better approach would be to return a value
159 // indicating the type of action performed such that the button can animate
160 // the ink drop. Currently it is not possible because showing menu is
161 // synchronous and blocks the call. Fix this after menu is converted to
James Cook 2016/06/13 19:55:35 Are you actually planning to convert menus to be a
mohsen 2016/06/14 06:24:38 Yes, there is a plan to convert all menus to be as
162 // asynchronous. Long-term, the return value can be merged into
163 // ButtonListener.
164 void ButtonPressed(views::Button* sender,
165 const ui::Event& event,
166 views::InkDrop* ink_drop);
167
153 // Return the view model for test purposes. 168 // Return the view model for test purposes.
154 const views::ViewModel* view_model_for_test() const { 169 const views::ViewModel* view_model_for_test() const {
155 return view_model_.get(); 170 return view_model_.get();
156 } 171 }
157 172
158 private: 173 private:
159 friend class ash::test::ShelfViewTestAPI; 174 friend class ash::test::ShelfViewTestAPI;
160 175
161 class FadeOutAnimationDelegate; 176 class FadeOutAnimationDelegate;
162 class StartFadeAnimationDelegate; 177 class StartFadeAnimationDelegate;
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
270 285
271 // Overridden from ui::EventHandler: 286 // Overridden from ui::EventHandler:
272 void OnGestureEvent(ui::GestureEvent* event) override; 287 void OnGestureEvent(ui::GestureEvent* event) override;
273 288
274 // Overridden from ShelfModelObserver: 289 // Overridden from ShelfModelObserver:
275 void ShelfItemAdded(int model_index) override; 290 void ShelfItemAdded(int model_index) override;
276 void ShelfItemRemoved(int model_index, ShelfID id) override; 291 void ShelfItemRemoved(int model_index, ShelfID id) override;
277 void ShelfItemChanged(int model_index, const ShelfItem& old_item) override; 292 void ShelfItemChanged(int model_index, const ShelfItem& old_item) override;
278 void ShelfItemMoved(int start_index, int target_index) override; 293 void ShelfItemMoved(int start_index, int target_index) override;
279 294
280 // Overridden from views::ButtonListener:
281 void ButtonPressed(views::Button* sender, const ui::Event& event) override;
282
283 // Show a list of all running items for this shelf |item|; it only shows a 295 // Show a list of all running items for this shelf |item|; it only shows a
284 // menu if there are multiple running items. |source| specifies the view 296 // menu if there are multiple running items. |source| specifies the view
285 // responsible for showing the menu, and the bubble will point towards it. 297 // responsible for showing the menu, and the bubble will point towards it.
286 // The |event_flags| are the flags of the event which triggered this menu. 298 // The |event_flags| are the flags of the event which triggered this menu.
287 void ShowListMenuForView(const ShelfItem& item, 299 // Returns |true| if a menu is shown.
300 bool ShowListMenuForView(const ShelfItem& item,
288 views::View* source, 301 views::View* source,
289 const ui::Event& event); 302 const ui::Event& event,
303 views::InkDrop* ink_drop);
290 304
291 // Overridden from views::ContextMenuController: 305 // Overridden from views::ContextMenuController:
292 void ShowContextMenuForView(views::View* source, 306 void ShowContextMenuForView(views::View* source,
293 const gfx::Point& point, 307 const gfx::Point& point,
294 ui::MenuSourceType source_type) override; 308 ui::MenuSourceType source_type) override;
295 309
296 // Show either a context or normal click menu of given |menu_model|. 310 // Show either a context or normal click menu of given |menu_model|.
297 // If |context_menu| is set, the displayed menu is a context menu and not 311 // If |context_menu| is set, the displayed menu is a context menu and not
298 // a menu listing one or more running applications. 312 // a menu listing one or more running applications.
299 // The |click_point| is only used for |context_menu|'s. 313 // The |click_point| is only used for |context_menu|'s.
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
432 bool overflow_mode_; 446 bool overflow_mode_;
433 447
434 // Holds a pointer to main ShelfView when a ShelfView is in overflow mode. 448 // Holds a pointer to main ShelfView when a ShelfView is in overflow mode.
435 ShelfView* main_shelf_; 449 ShelfView* main_shelf_;
436 450
437 // True when ripped item from overflow bubble is entered into Shelf. 451 // True when ripped item from overflow bubble is entered into Shelf.
438 bool dragged_off_from_overflow_to_shelf_; 452 bool dragged_off_from_overflow_to_shelf_;
439 453
440 // True if the event is a repost event from a event which has just closed the 454 // True if the event is a repost event from a event which has just closed the
441 // menu of the same shelf item. 455 // menu of the same shelf item.
442 bool is_repost_event_; 456 bool is_repost_event_on_same_item_;
443 457
444 // Record the index for the last pressed shelf item. This variable is used to 458 // Record the index for the last pressed shelf item. This variable is used to
445 // check if a repost event occurs on the same shelf item as previous one. If 459 // check if a repost event occurs on the same shelf item as previous one. If
446 // so, the repost event should be ignored. 460 // so, the repost event should be ignored.
447 int last_pressed_index_; 461 int last_pressed_index_;
448 462
449 // Tracks UMA metrics based on shelf button press actions. 463 // Tracks UMA metrics based on shelf button press actions.
450 ShelfButtonPressedMetricTracker shelf_button_pressed_metric_tracker_; 464 ShelfButtonPressedMetricTracker shelf_button_pressed_metric_tracker_;
451 465
452 DISALLOW_COPY_AND_ASSIGN(ShelfView); 466 DISALLOW_COPY_AND_ASSIGN(ShelfView);
453 }; 467 };
454 468
455 } // namespace ash 469 } // namespace ash
456 470
457 #endif // ASH_SHELF_SHELF_VIEW_H_ 471 #endif // ASH_SHELF_SHELF_VIEW_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698