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 <utility> | 8 #include <utility> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
56 public views::ButtonListener, | 56 public views::ButtonListener, |
57 public ShelfButtonHost, | 57 public ShelfButtonHost, |
58 public views::ContextMenuController, | 58 public views::ContextMenuController, |
59 public views::FocusTraversable, | 59 public views::FocusTraversable, |
60 public views::BoundsAnimatorObserver, | 60 public views::BoundsAnimatorObserver, |
61 public app_list::ApplicationDragAndDropHost { | 61 public app_list::ApplicationDragAndDropHost { |
62 public: | 62 public: |
63 ShelfView(ShelfModel* model, | 63 ShelfView(ShelfModel* model, |
64 ShelfDelegate* delegate, | 64 ShelfDelegate* delegate, |
65 ShelfLayoutManager* manager); | 65 ShelfLayoutManager* manager); |
66 virtual ~ShelfView(); | 66 ~ShelfView() override; |
67 | 67 |
68 ShelfTooltipManager* tooltip_manager() { return tooltip_.get(); } | 68 ShelfTooltipManager* tooltip_manager() { return tooltip_.get(); } |
69 | 69 |
70 ShelfLayoutManager* shelf_layout_manager() { return layout_manager_; } | 70 ShelfLayoutManager* shelf_layout_manager() { return layout_manager_; } |
71 | 71 |
72 ShelfModel* model() { return model_; } | 72 ShelfModel* model() { return model_; } |
73 | 73 |
74 void Init(); | 74 void Init(); |
75 | 75 |
76 void OnShelfAlignmentChanged(); | 76 void OnShelfAlignmentChanged(); |
(...skipping 28 matching lines...) Expand all Loading... |
105 // There are thin gaps between launcher buttons but the tooltip shouldn't hide | 105 // There are thin gaps between launcher buttons but the tooltip shouldn't hide |
106 // in the gaps, but the tooltip should hide if the mouse moved totally outside | 106 // in the gaps, but the tooltip should hide if the mouse moved totally outside |
107 // of the buttons area. | 107 // of the buttons area. |
108 bool ShouldHideTooltip(const gfx::Point& cursor_location); | 108 bool ShouldHideTooltip(const gfx::Point& cursor_location); |
109 | 109 |
110 // Returns rectangle bounding all visible launcher items. Used screen | 110 // Returns rectangle bounding all visible launcher items. Used screen |
111 // coordinate system. | 111 // coordinate system. |
112 gfx::Rect GetVisibleItemsBoundsInScreen(); | 112 gfx::Rect GetVisibleItemsBoundsInScreen(); |
113 | 113 |
114 // Overridden from FocusTraversable: | 114 // Overridden from FocusTraversable: |
115 virtual views::FocusSearch* GetFocusSearch() override; | 115 views::FocusSearch* GetFocusSearch() override; |
116 virtual FocusTraversable* GetFocusTraversableParent() override; | 116 FocusTraversable* GetFocusTraversableParent() override; |
117 virtual View* GetFocusTraversableParentView() override; | 117 View* GetFocusTraversableParentView() override; |
118 | 118 |
119 // Overridden from app_list::ApplicationDragAndDropHost: | 119 // Overridden from app_list::ApplicationDragAndDropHost: |
120 virtual void CreateDragIconProxy( | 120 void CreateDragIconProxy(const gfx::Point& location_in_screen_coordinates, |
121 const gfx::Point& location_in_screen_coordinates, | 121 const gfx::ImageSkia& icon, |
122 const gfx::ImageSkia& icon, | 122 views::View* replaced_view, |
123 views::View* replaced_view, | 123 const gfx::Vector2d& cursor_offset_from_center, |
124 const gfx::Vector2d& cursor_offset_from_center, | 124 float scale_factor) override; |
125 float scale_factor) override; | 125 void UpdateDragIconProxy( |
126 virtual void UpdateDragIconProxy( | |
127 const gfx::Point& location_in_screen_coordinates) override; | 126 const gfx::Point& location_in_screen_coordinates) override; |
128 virtual void DestroyDragIconProxy() override; | 127 void DestroyDragIconProxy() override; |
129 virtual bool StartDrag( | 128 bool StartDrag(const std::string& app_id, |
130 const std::string& app_id, | 129 const gfx::Point& location_in_screen_coordinates) override; |
131 const gfx::Point& location_in_screen_coordinates) override; | 130 bool Drag(const gfx::Point& location_in_screen_coordinates) override; |
132 virtual bool Drag(const gfx::Point& location_in_screen_coordinates) override; | 131 void EndDrag(bool cancel) override; |
133 virtual void EndDrag(bool cancel) override; | |
134 | 132 |
135 // Return the view model for test purposes. | 133 // Return the view model for test purposes. |
136 const views::ViewModel* view_model_for_test() const { | 134 const views::ViewModel* view_model_for_test() const { |
137 return view_model_.get(); | 135 return view_model_.get(); |
138 } | 136 } |
139 | 137 |
140 private: | 138 private: |
141 friend class ash::test::ShelfViewTestAPI; | 139 friend class ash::test::ShelfViewTestAPI; |
142 | 140 |
143 class FadeOutAnimationDelegate; | 141 class FadeOutAnimationDelegate; |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
238 // Invoked after the fading out animation for item deletion is ended. | 236 // Invoked after the fading out animation for item deletion is ended. |
239 void OnFadeOutAnimationEnded(); | 237 void OnFadeOutAnimationEnded(); |
240 | 238 |
241 // Fade in last visible item. | 239 // Fade in last visible item. |
242 void StartFadeInLastVisibleItem(); | 240 void StartFadeInLastVisibleItem(); |
243 | 241 |
244 // Updates the visible range of overflow items in |overflow_view|. | 242 // Updates the visible range of overflow items in |overflow_view|. |
245 void UpdateOverflowRange(ShelfView* overflow_view) const; | 243 void UpdateOverflowRange(ShelfView* overflow_view) const; |
246 | 244 |
247 // Overridden from views::View: | 245 // Overridden from views::View: |
248 virtual gfx::Size GetPreferredSize() const override; | 246 gfx::Size GetPreferredSize() const override; |
249 virtual void OnBoundsChanged(const gfx::Rect& previous_bounds) override; | 247 void OnBoundsChanged(const gfx::Rect& previous_bounds) override; |
250 virtual FocusTraversable* GetPaneFocusTraversable() override; | 248 FocusTraversable* GetPaneFocusTraversable() override; |
251 virtual void GetAccessibleState(ui::AXViewState* state) override; | 249 void GetAccessibleState(ui::AXViewState* state) override; |
252 | 250 |
253 // Overridden from ui::EventHandler: | 251 // Overridden from ui::EventHandler: |
254 virtual void OnGestureEvent(ui::GestureEvent* event) override; | 252 void OnGestureEvent(ui::GestureEvent* event) override; |
255 | 253 |
256 // Overridden from ShelfModelObserver: | 254 // Overridden from ShelfModelObserver: |
257 virtual void ShelfItemAdded(int model_index) override; | 255 void ShelfItemAdded(int model_index) override; |
258 virtual void ShelfItemRemoved(int model_index, ShelfID id) override; | 256 void ShelfItemRemoved(int model_index, ShelfID id) override; |
259 virtual void ShelfItemChanged(int model_index, | 257 void ShelfItemChanged(int model_index, const ShelfItem& old_item) override; |
260 const ShelfItem& old_item) override; | 258 void ShelfItemMoved(int start_index, int target_index) override; |
261 virtual void ShelfItemMoved(int start_index, int target_index) override; | 259 void ShelfStatusChanged() override; |
262 virtual void ShelfStatusChanged() override; | |
263 | 260 |
264 // Overridden from ShelfButtonHost: | 261 // Overridden from ShelfButtonHost: |
265 virtual void PointerPressedOnButton(views::View* view, | 262 void PointerPressedOnButton(views::View* view, |
266 Pointer pointer, | 263 Pointer pointer, |
267 const ui::LocatedEvent& event) override; | 264 const ui::LocatedEvent& event) override; |
268 virtual void PointerDraggedOnButton(views::View* view, | 265 void PointerDraggedOnButton(views::View* view, |
269 Pointer pointer, | 266 Pointer pointer, |
270 const ui::LocatedEvent& event) override; | 267 const ui::LocatedEvent& event) override; |
271 virtual void PointerReleasedOnButton(views::View* view, | 268 void PointerReleasedOnButton(views::View* view, |
272 Pointer pointer, | 269 Pointer pointer, |
273 bool canceled) override; | 270 bool canceled) override; |
274 virtual void MouseMovedOverButton(views::View* view) override; | 271 void MouseMovedOverButton(views::View* view) override; |
275 virtual void MouseEnteredButton(views::View* view) override; | 272 void MouseEnteredButton(views::View* view) override; |
276 virtual void MouseExitedButton(views::View* view) override; | 273 void MouseExitedButton(views::View* view) override; |
277 virtual base::string16 GetAccessibleName(const views::View* view) override; | 274 base::string16 GetAccessibleName(const views::View* view) override; |
278 | 275 |
279 // Overridden from views::ButtonListener: | 276 // Overridden from views::ButtonListener: |
280 virtual void ButtonPressed(views::Button* sender, | 277 void ButtonPressed(views::Button* sender, const ui::Event& event) override; |
281 const ui::Event& event) override; | |
282 | 278 |
283 // Show the list of all running items for this |item|. It will return true | 279 // Show the list of all running items for this |item|. It will return true |
284 // when the menu was shown and false if there were no possible items to | 280 // when the menu was shown and false if there were no possible items to |
285 // choose from. |source| specifies the view which is responsible for showing | 281 // choose from. |source| specifies the view which is responsible for showing |
286 // the menu, and the bubble will point towards it. | 282 // the menu, and the bubble will point towards it. |
287 // The |event_flags| are the flags of the event which triggered this menu. | 283 // The |event_flags| are the flags of the event which triggered this menu. |
288 bool ShowListMenuForView(const ShelfItem& item, | 284 bool ShowListMenuForView(const ShelfItem& item, |
289 views::View* source, | 285 views::View* source, |
290 const ui::Event& event); | 286 const ui::Event& event); |
291 | 287 |
292 // Overridden from views::ContextMenuController: | 288 // Overridden from views::ContextMenuController: |
293 virtual void ShowContextMenuForView(views::View* source, | 289 void ShowContextMenuForView(views::View* source, |
294 const gfx::Point& point, | 290 const gfx::Point& point, |
295 ui::MenuSourceType source_type) override; | 291 ui::MenuSourceType source_type) override; |
296 | 292 |
297 // Show either a context or normal click menu of given |menu_model|. | 293 // Show either a context or normal click menu of given |menu_model|. |
298 // If |context_menu| is set, the displayed menu is a context menu and not | 294 // If |context_menu| is set, the displayed menu is a context menu and not |
299 // a menu listing one or more running applications. | 295 // a menu listing one or more running applications. |
300 // The |click_point| is only used for |context_menu|'s. | 296 // The |click_point| is only used for |context_menu|'s. |
301 void ShowMenu(ui::MenuModel* menu_model, | 297 void ShowMenu(ui::MenuModel* menu_model, |
302 views::View* source, | 298 views::View* source, |
303 const gfx::Point& click_point, | 299 const gfx::Point& click_point, |
304 bool context_menu, | 300 bool context_menu, |
305 ui::MenuSourceType source_type); | 301 ui::MenuSourceType source_type); |
306 | 302 |
307 // Overridden from views::BoundsAnimatorObserver: | 303 // Overridden from views::BoundsAnimatorObserver: |
308 virtual void OnBoundsAnimatorProgressed( | 304 void OnBoundsAnimatorProgressed(views::BoundsAnimator* animator) override; |
309 views::BoundsAnimator* animator) override; | 305 void OnBoundsAnimatorDone(views::BoundsAnimator* animator) override; |
310 virtual void OnBoundsAnimatorDone(views::BoundsAnimator* animator) override; | |
311 | 306 |
312 // Returns false if the click which closed the previous menu is the click | 307 // Returns false if the click which closed the previous menu is the click |
313 // which triggered this event. | 308 // which triggered this event. |
314 bool IsUsableEvent(const ui::Event& event); | 309 bool IsUsableEvent(const ui::Event& event); |
315 | 310 |
316 // Convenience accessor to model_->items(). | 311 // Convenience accessor to model_->items(). |
317 const ShelfItem* ShelfItemForView(const views::View* view) const; | 312 const ShelfItem* ShelfItemForView(const views::View* view) const; |
318 | 313 |
319 // Returns true if a tooltip should be shown for |view|. | 314 // Returns true if a tooltip should be shown for |view|. |
320 bool ShouldShowTooltipForView(const views::View* view) const; | 315 bool ShouldShowTooltipForView(const views::View* view) const; |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
439 | 434 |
440 // True when ripped item from overflow bubble is entered into Shelf. | 435 // True when ripped item from overflow bubble is entered into Shelf. |
441 bool dragged_off_from_overflow_to_shelf_; | 436 bool dragged_off_from_overflow_to_shelf_; |
442 | 437 |
443 DISALLOW_COPY_AND_ASSIGN(ShelfView); | 438 DISALLOW_COPY_AND_ASSIGN(ShelfView); |
444 }; | 439 }; |
445 | 440 |
446 } // namespace ash | 441 } // namespace ash |
447 | 442 |
448 #endif // ASH_SHELF_SHELF_VIEW_H_ | 443 #endif // ASH_SHELF_SHELF_VIEW_H_ |
OLD | NEW |