| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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_COMMON_SHELF_OVERFLOW_BUBBLE_H_ | 5 #ifndef ASH_COMMON_SHELF_OVERFLOW_BUBBLE_H_ |
| 6 #define ASH_COMMON_SHELF_OVERFLOW_BUBBLE_H_ | 6 #define ASH_COMMON_SHELF_OVERFLOW_BUBBLE_H_ |
| 7 | 7 |
| 8 #include "base/macros.h" | 8 #include "base/macros.h" |
| 9 #include "ui/views/pointer_watcher.h" | 9 #include "ui/views/pointer_down_watcher.h" |
| 10 #include "ui/views/widget/widget_observer.h" | 10 #include "ui/views/widget/widget_observer.h" |
| 11 | 11 |
| 12 namespace ui { | 12 namespace ui { |
| 13 class LocatedEvent; | 13 class LocatedEvent; |
| 14 } | 14 } |
| 15 | 15 |
| 16 namespace views { | 16 namespace views { |
| 17 class View; | 17 class View; |
| 18 } | 18 } |
| 19 | 19 |
| 20 namespace ash { | 20 namespace ash { |
| 21 class OverflowBubbleView; | 21 class OverflowBubbleView; |
| 22 class ShelfView; | 22 class ShelfView; |
| 23 class WmShelf; | 23 class WmShelf; |
| 24 | 24 |
| 25 // OverflowBubble shows shelf items that won't fit on the main shelf in a | 25 // OverflowBubble shows shelf items that won't fit on the main shelf in a |
| 26 // separate bubble. | 26 // separate bubble. |
| 27 class OverflowBubble : public views::PointerWatcher, | 27 class OverflowBubble : public views::PointerDownWatcher, |
| 28 public views::WidgetObserver { | 28 public views::WidgetObserver { |
| 29 public: | 29 public: |
| 30 // |wm_shelf| is the shelf that spawns the bubble. | 30 // |wm_shelf| is the shelf that spawns the bubble. |
| 31 explicit OverflowBubble(WmShelf* wm_shelf); | 31 explicit OverflowBubble(WmShelf* wm_shelf); |
| 32 ~OverflowBubble() override; | 32 ~OverflowBubble() override; |
| 33 | 33 |
| 34 // Shows an bubble pointing to |anchor| with |shelf_view| as its content. | 34 // Shows an bubble pointing to |anchor| with |shelf_view| as its content. |
| 35 // This |shelf_view| is different than the main shelf's view and only contains | 35 // This |shelf_view| is different than the main shelf's view and only contains |
| 36 // the overflow items. | 36 // the overflow items. |
| 37 void Show(views::View* anchor, ShelfView* shelf_view); | 37 void Show(views::View* anchor, ShelfView* shelf_view); |
| 38 | 38 |
| 39 void Hide(); | 39 void Hide(); |
| 40 | 40 |
| 41 // Hides the bubble and schedules paint for overflow button. | 41 // Hides the bubble and schedules paint for overflow button. |
| 42 void HideBubbleAndRefreshButton(); | 42 void HideBubbleAndRefreshButton(); |
| 43 | 43 |
| 44 bool IsShowing() const { return !!bubble_; } | 44 bool IsShowing() const { return !!bubble_; } |
| 45 ShelfView* shelf_view() { return shelf_view_; } | 45 ShelfView* shelf_view() { return shelf_view_; } |
| 46 OverflowBubbleView* bubble_view() { return bubble_; } | 46 OverflowBubbleView* bubble_view() { return bubble_; } |
| 47 | 47 |
| 48 private: | 48 private: |
| 49 void ProcessPressedEvent(const gfx::Point& event_location_in_screen); | 49 void ProcessPressedEvent(const gfx::Point& event_location_in_screen); |
| 50 | 50 |
| 51 // views::PointerWatcher: | 51 // views::PointerDownWatcher: |
| 52 void OnMousePressed(const ui::MouseEvent& event, | 52 void OnMousePressed(const ui::MouseEvent& event, |
| 53 const gfx::Point& location_in_screen, | 53 const gfx::Point& location_in_screen, |
| 54 views::Widget* target) override; | 54 views::Widget* target) override; |
| 55 void OnTouchPressed(const ui::TouchEvent& event, | 55 void OnTouchPressed(const ui::TouchEvent& event, |
| 56 const gfx::Point& location_in_screen, | 56 const gfx::Point& location_in_screen, |
| 57 views::Widget* target) override; | 57 views::Widget* target) override; |
| 58 | 58 |
| 59 // Overridden from views::WidgetObserver: | 59 // Overridden from views::WidgetObserver: |
| 60 void OnWidgetDestroying(views::Widget* widget) override; | 60 void OnWidgetDestroying(views::Widget* widget) override; |
| 61 | 61 |
| 62 WmShelf* wm_shelf_; | 62 WmShelf* wm_shelf_; |
| 63 OverflowBubbleView* bubble_; // Owned by views hierarchy. | 63 OverflowBubbleView* bubble_; // Owned by views hierarchy. |
| 64 views::View* anchor_; // Owned by ShelfView. | 64 views::View* anchor_; // Owned by ShelfView. |
| 65 ShelfView* shelf_view_; // Owned by |bubble_|. | 65 ShelfView* shelf_view_; // Owned by |bubble_|. |
| 66 | 66 |
| 67 DISALLOW_COPY_AND_ASSIGN(OverflowBubble); | 67 DISALLOW_COPY_AND_ASSIGN(OverflowBubble); |
| 68 }; | 68 }; |
| 69 | 69 |
| 70 } // namespace ash | 70 } // namespace ash |
| 71 | 71 |
| 72 #endif // ASH_COMMON_SHELF_OVERFLOW_BUBBLE_H_ | 72 #endif // ASH_COMMON_SHELF_OVERFLOW_BUBBLE_H_ |
| OLD | NEW |