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 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/ink_drop_button_listener.h" | |
| 15 #include "ash/shelf/shelf_button_pressed_metric_tracker.h" | 16 #include "ash/shelf/shelf_button_pressed_metric_tracker.h" |
| 16 #include "ash/shelf/shelf_tooltip_manager.h" | 17 #include "ash/shelf/shelf_tooltip_manager.h" |
| 17 #include "ash/wm/gestures/shelf_gesture_handler.h" | 18 #include "ash/wm/gestures/shelf_gesture_handler.h" |
| 18 #include "base/macros.h" | 19 #include "base/macros.h" |
| 19 #include "base/observer_list.h" | 20 #include "base/observer_list.h" |
| 20 #include "ui/app_list/views/app_list_drag_and_drop_host.h" | 21 #include "ui/app_list/views/app_list_drag_and_drop_host.h" |
| 21 #include "ui/views/animation/bounds_animator_observer.h" | 22 #include "ui/views/animation/bounds_animator_observer.h" |
| 23 #include "ui/views/animation/ink_drop_state.h" | |
| 22 #include "ui/views/context_menu_controller.h" | 24 #include "ui/views/context_menu_controller.h" |
| 23 #include "ui/views/controls/button/button.h" | 25 #include "ui/views/controls/button/button.h" |
| 24 #include "ui/views/focus/focus_manager.h" | 26 #include "ui/views/focus/focus_manager.h" |
| 25 #include "ui/views/view.h" | 27 #include "ui/views/view.h" |
| 26 #include "ui/views/view_model.h" | 28 #include "ui/views/view_model.h" |
| 27 | 29 |
| 28 namespace ui { | 30 namespace ui { |
| 29 class MenuModel; | 31 class MenuModel; |
| 30 } | 32 } |
| 31 | 33 |
| (...skipping 19 matching lines...) Expand all Loading... | |
| 51 class ShelfViewTestAPI; | 53 class ShelfViewTestAPI; |
| 52 } | 54 } |
| 53 | 55 |
| 54 extern const int SHELF_ALIGNMENT_UMA_ENUM_VALUE_BOTTOM; | 56 extern const int SHELF_ALIGNMENT_UMA_ENUM_VALUE_BOTTOM; |
| 55 extern const int SHELF_ALIGNMENT_UMA_ENUM_VALUE_LEFT; | 57 extern const int SHELF_ALIGNMENT_UMA_ENUM_VALUE_LEFT; |
| 56 extern const int SHELF_ALIGNMENT_UMA_ENUM_VALUE_RIGHT; | 58 extern const int SHELF_ALIGNMENT_UMA_ENUM_VALUE_RIGHT; |
| 57 extern const int SHELF_ALIGNMENT_UMA_ENUM_VALUE_COUNT; | 59 extern const int SHELF_ALIGNMENT_UMA_ENUM_VALUE_COUNT; |
| 58 | 60 |
| 59 class ASH_EXPORT ShelfView : public views::View, | 61 class ASH_EXPORT ShelfView : public views::View, |
| 60 public ShelfModelObserver, | 62 public ShelfModelObserver, |
| 61 public views::ButtonListener, | 63 public InkDropButtonListener, |
| 62 public views::ContextMenuController, | 64 public views::ContextMenuController, |
| 63 public views::FocusTraversable, | 65 public views::FocusTraversable, |
| 64 public views::BoundsAnimatorObserver, | 66 public views::BoundsAnimatorObserver, |
| 65 public app_list::ApplicationDragAndDropHost { | 67 public app_list::ApplicationDragAndDropHost { |
| 66 public: | 68 public: |
| 67 ShelfView(ShelfModel* model, | 69 ShelfView(ShelfModel* model, |
| 68 ShelfDelegate* delegate, | 70 ShelfDelegate* delegate, |
| 69 WmShelf* wm_shelf, | 71 WmShelf* wm_shelf, |
| 70 Shelf* shelf); | 72 Shelf* shelf); |
| 71 ~ShelfView() override; | 73 ~ShelfView() override; |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 131 const gfx::Vector2d& cursor_offset_from_center, | 133 const gfx::Vector2d& cursor_offset_from_center, |
| 132 float scale_factor) override; | 134 float scale_factor) override; |
| 133 void UpdateDragIconProxy( | 135 void UpdateDragIconProxy( |
| 134 const gfx::Point& location_in_screen_coordinates) override; | 136 const gfx::Point& location_in_screen_coordinates) override; |
| 135 void DestroyDragIconProxy() override; | 137 void DestroyDragIconProxy() override; |
| 136 bool StartDrag(const std::string& app_id, | 138 bool StartDrag(const std::string& app_id, |
| 137 const gfx::Point& location_in_screen_coordinates) override; | 139 const gfx::Point& location_in_screen_coordinates) override; |
| 138 bool Drag(const gfx::Point& location_in_screen_coordinates) override; | 140 bool Drag(const gfx::Point& location_in_screen_coordinates) override; |
| 139 void EndDrag(bool cancel) override; | 141 void EndDrag(bool cancel) override; |
| 140 | 142 |
| 143 // Returns true if the event on the shelf item is going to activate the item. | |
|
bruthig
2016/06/14 14:37:33
nit: event -> |event|
mohsen
2016/06/14 20:40:30
Done.
| |
| 144 // Used to determine whether a pending ink drop should be shown or not. | |
| 145 bool ShouldEventActivateButton(views::View* view, const ui::Event& event); | |
| 146 | |
| 141 // The shelf buttons use the Pointer interface to enable item reordering. | 147 // The shelf buttons use the Pointer interface to enable item reordering. |
| 142 enum Pointer { NONE, DRAG_AND_DROP, MOUSE, TOUCH }; | 148 enum Pointer { NONE, DRAG_AND_DROP, MOUSE, TOUCH }; |
| 143 void PointerPressedOnButton(views::View* view, | 149 void PointerPressedOnButton(views::View* view, |
| 144 Pointer pointer, | 150 Pointer pointer, |
| 145 const ui::LocatedEvent& event); | 151 const ui::LocatedEvent& event); |
| 146 void PointerDraggedOnButton(views::View* view, | 152 void PointerDraggedOnButton(views::View* view, |
| 147 Pointer pointer, | 153 Pointer pointer, |
| 148 const ui::LocatedEvent& event); | 154 const ui::LocatedEvent& event); |
| 149 void PointerReleasedOnButton(views::View* view, | 155 void PointerReleasedOnButton(views::View* view, |
| 150 Pointer pointer, | 156 Pointer pointer, |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 164 struct IdealBounds { | 170 struct IdealBounds { |
| 165 gfx::Rect overflow_bounds; | 171 gfx::Rect overflow_bounds; |
| 166 }; | 172 }; |
| 167 | 173 |
| 168 enum RemovableState { | 174 enum RemovableState { |
| 169 REMOVABLE, // Item can be removed when dragged away. | 175 REMOVABLE, // Item can be removed when dragged away. |
| 170 DRAGGABLE, // Item can be dragged, but will snap always back to origin. | 176 DRAGGABLE, // Item can be dragged, but will snap always back to origin. |
| 171 NOT_REMOVABLE, // Item is fixed and can never be removed. | 177 NOT_REMOVABLE, // Item is fixed and can never be removed. |
| 172 }; | 178 }; |
| 173 | 179 |
| 180 // Minimum distance before drag starts. | |
| 181 static const int kMinimumDragDistance; | |
| 182 | |
| 174 // Returns true when this ShelfView is used for Overflow Bubble. | 183 // Returns true when this ShelfView is used for Overflow Bubble. |
| 175 // In this mode, it does not show app list, panel and overflow button. | 184 // In this mode, it does not show app list, panel and overflow button. |
| 176 // Note: | 185 // Note: |
| 177 // * When Shelf can contain only one item (overflow button) due to very | 186 // * When Shelf can contain only one item (overflow button) due to very |
| 178 // small resolution screen, overflow bubble can show app list and panel | 187 // small resolution screen, overflow bubble can show app list and panel |
| 179 // button. | 188 // button. |
| 180 bool is_overflow_mode() const { return overflow_mode_; } | 189 bool is_overflow_mode() const { return overflow_mode_; } |
| 181 | 190 |
| 182 bool dragging() const { return drag_pointer_ != NONE; } | 191 bool dragging() const { return drag_pointer_ != NONE; } |
| 183 | 192 |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 270 | 279 |
| 271 // Overridden from ui::EventHandler: | 280 // Overridden from ui::EventHandler: |
| 272 void OnGestureEvent(ui::GestureEvent* event) override; | 281 void OnGestureEvent(ui::GestureEvent* event) override; |
| 273 | 282 |
| 274 // Overridden from ShelfModelObserver: | 283 // Overridden from ShelfModelObserver: |
| 275 void ShelfItemAdded(int model_index) override; | 284 void ShelfItemAdded(int model_index) override; |
| 276 void ShelfItemRemoved(int model_index, ShelfID id) override; | 285 void ShelfItemRemoved(int model_index, ShelfID id) override; |
| 277 void ShelfItemChanged(int model_index, const ShelfItem& old_item) override; | 286 void ShelfItemChanged(int model_index, const ShelfItem& old_item) override; |
| 278 void ShelfItemMoved(int start_index, int target_index) override; | 287 void ShelfItemMoved(int start_index, int target_index) override; |
| 279 | 288 |
| 280 // Overridden from views::ButtonListener: | 289 // Overridden from InkDropButtonListener: |
| 281 void ButtonPressed(views::Button* sender, const ui::Event& event) override; | 290 void ButtonPressed(views::Button* sender, |
| 291 const ui::Event& event, | |
| 292 views::InkDrop* ink_drop) override; | |
| 282 | 293 |
| 283 // Show a list of all running items for this shelf |item|; it only shows a | 294 // 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 | 295 // menu if there are multiple running items. |source| specifies the view |
| 285 // responsible for showing the menu, and the bubble will point towards it. | 296 // 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. | 297 // The |event_flags| are the flags of the event which triggered this menu. |
| 287 void ShowListMenuForView(const ShelfItem& item, | 298 // Returns |true| if a menu is shown. |
| 299 bool ShowListMenuForView(const ShelfItem& item, | |
| 288 views::View* source, | 300 views::View* source, |
| 289 const ui::Event& event); | 301 const ui::Event& event, |
| 302 views::InkDrop* ink_drop); | |
| 290 | 303 |
| 291 // Overridden from views::ContextMenuController: | 304 // Overridden from views::ContextMenuController: |
| 292 void ShowContextMenuForView(views::View* source, | 305 void ShowContextMenuForView(views::View* source, |
| 293 const gfx::Point& point, | 306 const gfx::Point& point, |
| 294 ui::MenuSourceType source_type) override; | 307 ui::MenuSourceType source_type) override; |
| 295 | 308 |
| 296 // Show either a context or normal click menu of given |menu_model|. | 309 // 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 | 310 // If |context_menu| is set, the displayed menu is a context menu and not |
| 298 // a menu listing one or more running applications. | 311 // a menu listing one or more running applications. |
| 299 // The |click_point| is only used for |context_menu|'s. | 312 // The |click_point| is only used for |context_menu|'s. |
| (...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 432 bool overflow_mode_; | 445 bool overflow_mode_; |
| 433 | 446 |
| 434 // Holds a pointer to main ShelfView when a ShelfView is in overflow mode. | 447 // Holds a pointer to main ShelfView when a ShelfView is in overflow mode. |
| 435 ShelfView* main_shelf_; | 448 ShelfView* main_shelf_; |
| 436 | 449 |
| 437 // True when ripped item from overflow bubble is entered into Shelf. | 450 // True when ripped item from overflow bubble is entered into Shelf. |
| 438 bool dragged_off_from_overflow_to_shelf_; | 451 bool dragged_off_from_overflow_to_shelf_; |
| 439 | 452 |
| 440 // True if the event is a repost event from a event which has just closed the | 453 // True if the event is a repost event from a event which has just closed the |
| 441 // menu of the same shelf item. | 454 // menu of the same shelf item. |
| 442 bool is_repost_event_; | 455 bool is_repost_event_on_same_item_; |
| 443 | 456 |
| 444 // Record the index for the last pressed shelf item. This variable is used to | 457 // 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 | 458 // check if a repost event occurs on the same shelf item as previous one. If |
| 446 // so, the repost event should be ignored. | 459 // so, the repost event should be ignored. |
| 447 int last_pressed_index_; | 460 int last_pressed_index_; |
| 448 | 461 |
| 449 // Tracks UMA metrics based on shelf button press actions. | 462 // Tracks UMA metrics based on shelf button press actions. |
| 450 ShelfButtonPressedMetricTracker shelf_button_pressed_metric_tracker_; | 463 ShelfButtonPressedMetricTracker shelf_button_pressed_metric_tracker_; |
| 451 | 464 |
| 452 DISALLOW_COPY_AND_ASSIGN(ShelfView); | 465 DISALLOW_COPY_AND_ASSIGN(ShelfView); |
| 453 }; | 466 }; |
| 454 | 467 |
| 455 } // namespace ash | 468 } // namespace ash |
| 456 | 469 |
| 457 #endif // ASH_SHELF_SHELF_VIEW_H_ | 470 #endif // ASH_SHELF_SHELF_VIEW_H_ |
| OLD | NEW |