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

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

Issue 1816753002: Enable mash shelf tooltips. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address destructor comment. Created 4 years, 9 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
« no previous file with comments | « ash/shelf/shelf_tooltip_manager_unittest.cc ('k') | ash/shelf/shelf_view.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 <string> 8 #include <string>
9 #include <utility> 9 #include <utility>
10 #include <vector> 10 #include <vector>
11 11
12 #include "ash/shelf/shelf_button_host.h"
13 #include "ash/shelf/shelf_button_pressed_metric_tracker.h" 12 #include "ash/shelf/shelf_button_pressed_metric_tracker.h"
14 #include "ash/shelf/shelf_item_delegate.h" 13 #include "ash/shelf/shelf_item_delegate.h"
15 #include "ash/shelf/shelf_model_observer.h" 14 #include "ash/shelf/shelf_model_observer.h"
15 #include "ash/shelf/shelf_tooltip_manager.h"
16 #include "ash/wm/gestures/shelf_gesture_handler.h" 16 #include "ash/wm/gestures/shelf_gesture_handler.h"
17 #include "base/macros.h" 17 #include "base/macros.h"
18 #include "base/observer_list.h" 18 #include "base/observer_list.h"
19 #include "ui/app_list/views/app_list_drag_and_drop_host.h" 19 #include "ui/app_list/views/app_list_drag_and_drop_host.h"
20 #include "ui/views/animation/bounds_animator_observer.h" 20 #include "ui/views/animation/bounds_animator_observer.h"
21 #include "ui/views/context_menu_controller.h" 21 #include "ui/views/context_menu_controller.h"
22 #include "ui/views/controls/button/button.h" 22 #include "ui/views/controls/button/button.h"
23 #include "ui/views/focus/focus_manager.h" 23 #include "ui/views/focus/focus_manager.h"
24 #include "ui/views/view.h" 24 #include "ui/views/view.h"
25 #include "ui/views/view_model.h" 25 #include "ui/views/view_model.h"
(...skipping 11 matching lines...) Expand all
37 class Shelf; 37 class Shelf;
38 class ShelfDelegate; 38 class ShelfDelegate;
39 class ShelfIconObserver; 39 class ShelfIconObserver;
40 class ShelfItemDelegateManager; 40 class ShelfItemDelegateManager;
41 class ShelfModel; 41 class ShelfModel;
42 struct ShelfItem; 42 struct ShelfItem;
43 class DragImageView; 43 class DragImageView;
44 class OverflowBubble; 44 class OverflowBubble;
45 class OverflowButton; 45 class OverflowButton;
46 class ShelfButton; 46 class ShelfButton;
47 class ShelfTooltipManager;
48 47
49 namespace test { 48 namespace test {
50 class ShelfViewTestAPI; 49 class ShelfViewTestAPI;
51 } 50 }
52 51
53 extern const int SHELF_ALIGNMENT_UMA_ENUM_VALUE_BOTTOM; 52 extern const int SHELF_ALIGNMENT_UMA_ENUM_VALUE_BOTTOM;
54 extern const int SHELF_ALIGNMENT_UMA_ENUM_VALUE_LEFT; 53 extern const int SHELF_ALIGNMENT_UMA_ENUM_VALUE_LEFT;
55 extern const int SHELF_ALIGNMENT_UMA_ENUM_VALUE_RIGHT; 54 extern const int SHELF_ALIGNMENT_UMA_ENUM_VALUE_RIGHT;
56 extern const int SHELF_ALIGNMENT_UMA_ENUM_VALUE_COUNT; 55 extern const int SHELF_ALIGNMENT_UMA_ENUM_VALUE_COUNT;
57 56
58 class ASH_EXPORT ShelfView : public views::View, 57 class ASH_EXPORT ShelfView : public views::View,
59 public ShelfModelObserver, 58 public ShelfModelObserver,
60 public views::ButtonListener, 59 public views::ButtonListener,
61 public ShelfButtonHost,
62 public views::ContextMenuController, 60 public views::ContextMenuController,
63 public views::FocusTraversable, 61 public views::FocusTraversable,
64 public views::BoundsAnimatorObserver, 62 public views::BoundsAnimatorObserver,
65 public app_list::ApplicationDragAndDropHost { 63 public app_list::ApplicationDragAndDropHost {
66 public: 64 public:
67 ShelfView(ShelfModel* model, ShelfDelegate* delegate, Shelf* shelf); 65 ShelfView(ShelfModel* model, ShelfDelegate* delegate, Shelf* shelf);
68 ~ShelfView() override; 66 ~ShelfView() override;
69 67
70 ShelfTooltipManager* tooltip_manager() { return tooltip_.get(); }
71
72 Shelf* shelf() const { return shelf_; } 68 Shelf* shelf() const { return shelf_; }
73 ShelfModel* model() const { return model_; } 69 ShelfModel* model() const { return model_; }
74 70
75 void Init(); 71 void Init();
76 72
77 void OnShelfAlignmentChanged(); 73 void OnShelfAlignmentChanged();
78 void SchedulePaintForAllButtons(); 74 void SchedulePaintForAllButtons();
79 75
80 // Returns the ideal bounds of the specified item, or an empty rect if id 76 // Returns the ideal bounds of the specified item, or an empty rect if id
81 // isn't know. If the item is in an overflow shelf, the overflow icon location 77 // isn't know. If the item is in an overflow shelf, the overflow icon location
(...skipping 17 matching lines...) Expand all
99 void set_owner_overflow_bubble(OverflowBubble* owner) { 95 void set_owner_overflow_bubble(OverflowBubble* owner) {
100 owner_overflow_bubble_ = owner; 96 owner_overflow_bubble_ = owner;
101 } 97 }
102 98
103 views::View* GetAppListButtonView() const; 99 views::View* GetAppListButtonView() const;
104 100
105 // Returns true if the mouse cursor exits the area for launcher tooltip. 101 // Returns true if the mouse cursor exits the area for launcher tooltip.
106 // There are thin gaps between launcher buttons but the tooltip shouldn't hide 102 // There are thin gaps between launcher buttons but the tooltip shouldn't hide
107 // in the gaps, but the tooltip should hide if the mouse moved totally outside 103 // in the gaps, but the tooltip should hide if the mouse moved totally outside
108 // of the buttons area. 104 // of the buttons area.
109 bool ShouldHideTooltip(const gfx::Point& cursor_location); 105 bool ShouldHideTooltip(const gfx::Point& cursor_location) const;
106
107 // Returns true if a tooltip should be shown for the shelf item |view|.
108 bool ShouldShowTooltipForView(const views::View* view) const;
109
110 // Returns the title of the shelf item |view|.
111 base::string16 GetTitleForView(const views::View* view) const;
110 112
111 // Returns rectangle bounding all visible launcher items. Used screen 113 // Returns rectangle bounding all visible launcher items. Used screen
112 // coordinate system. 114 // coordinate system.
113 gfx::Rect GetVisibleItemsBoundsInScreen(); 115 gfx::Rect GetVisibleItemsBoundsInScreen();
114 116
115 // Overridden from FocusTraversable: 117 // Overridden from FocusTraversable:
116 views::FocusSearch* GetFocusSearch() override; 118 views::FocusSearch* GetFocusSearch() override;
117 FocusTraversable* GetFocusTraversableParent() override; 119 FocusTraversable* GetFocusTraversableParent() override;
118 View* GetFocusTraversableParentView() override; 120 View* GetFocusTraversableParentView() override;
119 121
120 // Overridden from app_list::ApplicationDragAndDropHost: 122 // Overridden from app_list::ApplicationDragAndDropHost:
121 void CreateDragIconProxy(const gfx::Point& location_in_screen_coordinates, 123 void CreateDragIconProxy(const gfx::Point& location_in_screen_coordinates,
122 const gfx::ImageSkia& icon, 124 const gfx::ImageSkia& icon,
123 views::View* replaced_view, 125 views::View* replaced_view,
124 const gfx::Vector2d& cursor_offset_from_center, 126 const gfx::Vector2d& cursor_offset_from_center,
125 float scale_factor) override; 127 float scale_factor) override;
126 void UpdateDragIconProxy( 128 void UpdateDragIconProxy(
127 const gfx::Point& location_in_screen_coordinates) override; 129 const gfx::Point& location_in_screen_coordinates) override;
128 void DestroyDragIconProxy() override; 130 void DestroyDragIconProxy() override;
129 bool StartDrag(const std::string& app_id, 131 bool StartDrag(const std::string& app_id,
130 const gfx::Point& location_in_screen_coordinates) override; 132 const gfx::Point& location_in_screen_coordinates) override;
131 bool Drag(const gfx::Point& location_in_screen_coordinates) override; 133 bool Drag(const gfx::Point& location_in_screen_coordinates) override;
132 void EndDrag(bool cancel) override; 134 void EndDrag(bool cancel) override;
133 135
136 // The shelf buttons use the Pointer interface to enable item reordering.
137 enum Pointer { NONE, DRAG_AND_DROP, MOUSE, TOUCH };
138 void PointerPressedOnButton(views::View* view,
139 Pointer pointer,
140 const ui::LocatedEvent& event);
141 void PointerDraggedOnButton(views::View* view,
142 Pointer pointer,
143 const ui::LocatedEvent& event);
144 void PointerReleasedOnButton(views::View* view,
145 Pointer pointer,
146 bool canceled);
147
134 // Return the view model for test purposes. 148 // Return the view model for test purposes.
135 const views::ViewModel* view_model_for_test() const { 149 const views::ViewModel* view_model_for_test() const {
136 return view_model_.get(); 150 return view_model_.get();
137 } 151 }
138 152
139 private: 153 private:
140 friend class ash::test::ShelfViewTestAPI; 154 friend class ash::test::ShelfViewTestAPI;
141 155
142 class FadeOutAnimationDelegate; 156 class FadeOutAnimationDelegate;
143 class StartFadeAnimationDelegate; 157 class StartFadeAnimationDelegate;
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
239 void StartFadeInLastVisibleItem(); 253 void StartFadeInLastVisibleItem();
240 254
241 // Updates the visible range of overflow items in |overflow_view|. 255 // Updates the visible range of overflow items in |overflow_view|.
242 void UpdateOverflowRange(ShelfView* overflow_view) const; 256 void UpdateOverflowRange(ShelfView* overflow_view) const;
243 257
244 // Overridden from views::View: 258 // Overridden from views::View:
245 gfx::Size GetPreferredSize() const override; 259 gfx::Size GetPreferredSize() const override;
246 void OnBoundsChanged(const gfx::Rect& previous_bounds) override; 260 void OnBoundsChanged(const gfx::Rect& previous_bounds) override;
247 FocusTraversable* GetPaneFocusTraversable() override; 261 FocusTraversable* GetPaneFocusTraversable() override;
248 void GetAccessibleState(ui::AXViewState* state) override; 262 void GetAccessibleState(ui::AXViewState* state) override;
263 void ViewHierarchyChanged(
264 const ViewHierarchyChangedDetails& details) override;
249 265
250 // Overridden from ui::EventHandler: 266 // Overridden from ui::EventHandler:
251 void OnGestureEvent(ui::GestureEvent* event) override; 267 void OnGestureEvent(ui::GestureEvent* event) override;
252 268
253 // Overridden from ShelfModelObserver: 269 // Overridden from ShelfModelObserver:
254 void ShelfItemAdded(int model_index) override; 270 void ShelfItemAdded(int model_index) override;
255 void ShelfItemRemoved(int model_index, ShelfID id) override; 271 void ShelfItemRemoved(int model_index, ShelfID id) override;
256 void ShelfItemChanged(int model_index, const ShelfItem& old_item) override; 272 void ShelfItemChanged(int model_index, const ShelfItem& old_item) override;
257 void ShelfItemMoved(int start_index, int target_index) override; 273 void ShelfItemMoved(int start_index, int target_index) override;
258 274
259 // Overridden from ShelfButtonHost:
260 void PointerPressedOnButton(views::View* view,
261 Pointer pointer,
262 const ui::LocatedEvent& event) override;
263 void PointerDraggedOnButton(views::View* view,
264 Pointer pointer,
265 const ui::LocatedEvent& event) override;
266 void PointerReleasedOnButton(views::View* view,
267 Pointer pointer,
268 bool canceled) override;
269 void MouseMovedOverButton(views::View* view) override;
270 void MouseEnteredButton(views::View* view) override;
271 void MouseExitedButton(views::View* view) override;
272 base::string16 GetAccessibleName(const views::View* view) override;
273
274 // Overridden from views::ButtonListener: 275 // Overridden from views::ButtonListener:
275 void ButtonPressed(views::Button* sender, const ui::Event& event) override; 276 void ButtonPressed(views::Button* sender, const ui::Event& event) override;
276 277
277 // Show a list of all running items for this shelf |item|; it only shows a 278 // Show a list of all running items for this shelf |item|; it only shows a
278 // menu if there are multiple running items. |source| specifies the view 279 // menu if there are multiple running items. |source| specifies the view
279 // responsible for showing the menu, and the bubble will point towards it. 280 // responsible for showing the menu, and the bubble will point towards it.
280 // The |event_flags| are the flags of the event which triggered this menu. 281 // The |event_flags| are the flags of the event which triggered this menu.
281 void ShowListMenuForView(const ShelfItem& item, 282 void ShowListMenuForView(const ShelfItem& item,
282 views::View* source, 283 views::View* source,
283 const ui::Event& event); 284 const ui::Event& event);
(...skipping 18 matching lines...) Expand all
302 void OnBoundsAnimatorDone(views::BoundsAnimator* animator) override; 303 void OnBoundsAnimatorDone(views::BoundsAnimator* animator) override;
303 304
304 // Returns true if the (press down) |event| is a repost event from an event 305 // Returns true if the (press down) |event| is a repost event from an event
305 // which just closed the menu of a shelf item. If it occurs on the same shelf 306 // which just closed the menu of a shelf item. If it occurs on the same shelf
306 // item, we should ignore the call. 307 // item, we should ignore the call.
307 bool IsRepostEvent(const ui::Event& event); 308 bool IsRepostEvent(const ui::Event& event);
308 309
309 // Convenience accessor to model_->items(). 310 // Convenience accessor to model_->items().
310 const ShelfItem* ShelfItemForView(const views::View* view) const; 311 const ShelfItem* ShelfItemForView(const views::View* view) const;
311 312
312 // Returns true if a tooltip should be shown for |view|.
313 bool ShouldShowTooltipForView(const views::View* view) const;
314
315 // Get the distance from the given |coordinate| to the closest point on this 313 // Get the distance from the given |coordinate| to the closest point on this
316 // launcher/shelf. 314 // launcher/shelf.
317 int CalculateShelfDistance(const gfx::Point& coordinate) const; 315 int CalculateShelfDistance(const gfx::Point& coordinate) const;
318 316
319 // The model; owned by Launcher. 317 // The model; owned by Launcher.
320 ShelfModel* model_; 318 ShelfModel* model_;
321 319
322 // Delegate; owned by Launcher. 320 // Delegate; owned by Launcher.
323 ShelfDelegate* delegate_; 321 ShelfDelegate* delegate_;
324 322
(...skipping 12 matching lines...) Expand all
337 mutable int last_visible_index_; 335 mutable int last_visible_index_;
338 336
339 scoped_ptr<views::BoundsAnimator> bounds_animator_; 337 scoped_ptr<views::BoundsAnimator> bounds_animator_;
340 338
341 OverflowButton* overflow_button_; 339 OverflowButton* overflow_button_;
342 340
343 scoped_ptr<OverflowBubble> overflow_bubble_; 341 scoped_ptr<OverflowBubble> overflow_bubble_;
344 342
345 OverflowBubble* owner_overflow_bubble_; 343 OverflowBubble* owner_overflow_bubble_;
346 344
347 scoped_ptr<ShelfTooltipManager> tooltip_; 345 ShelfTooltipManager tooltip_;
348 346
349 // Pointer device that initiated the current drag operation. If there is no 347 // Pointer device that initiated the current drag operation. If there is no
350 // current dragging operation, this is NONE. 348 // current dragging operation, this is NONE.
351 Pointer drag_pointer_; 349 Pointer drag_pointer_;
352 350
353 // The view being dragged. This is set immediately when the mouse is pressed. 351 // The view being dragged. This is set immediately when the mouse is pressed.
354 // |dragging_| is set only if the mouse is dragged far enough. 352 // |dragging_| is set only if the mouse is dragged far enough.
355 ShelfButton* drag_view_; 353 ShelfButton* drag_view_;
356 354
357 // Position of the mouse down event in |drag_view_|'s coordinates. 355 // Position of the mouse down event in |drag_view_|'s coordinates.
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
442 440
443 // Tracks UMA metrics based on shelf button press actions. 441 // Tracks UMA metrics based on shelf button press actions.
444 ShelfButtonPressedMetricTracker shelf_button_pressed_metric_tracker_; 442 ShelfButtonPressedMetricTracker shelf_button_pressed_metric_tracker_;
445 443
446 DISALLOW_COPY_AND_ASSIGN(ShelfView); 444 DISALLOW_COPY_AND_ASSIGN(ShelfView);
447 }; 445 };
448 446
449 } // namespace ash 447 } // namespace ash
450 448
451 #endif // ASH_SHELF_SHELF_VIEW_H_ 449 #endif // ASH_SHELF_SHELF_VIEW_H_
OLDNEW
« no previous file with comments | « ash/shelf/shelf_tooltip_manager_unittest.cc ('k') | ash/shelf/shelf_view.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698