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