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_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 PointerEvent; | 13 class PointerEvent; |
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::PointerWatcher, | 28 class OverflowBubble : public views::PointerWatcher, |
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::PointerWatcher: | 49 // views::PointerWatcher: |
52 void OnPointerEventObserved(const ui::PointerEvent& event, | 50 void OnPointerEventObserved(const ui::PointerEvent& 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 | 53 |
56 // Overridden from views::WidgetObserver: | 54 // Overridden from views::WidgetObserver: |
57 void OnWidgetDestroying(views::Widget* widget) override; | 55 void OnWidgetDestroying(views::Widget* widget) override; |
58 | 56 |
59 WmShelf* wm_shelf_; | 57 WmShelf* wm_shelf_; |
60 OverflowBubbleView* bubble_; // Owned by views hierarchy. | 58 OverflowBubbleView* bubble_; // Owned by views hierarchy. |
61 views::View* anchor_; // Owned by ShelfView. | 59 OverflowButton* button_; // Owned by ShelfView. |
62 | 60 |
63 // ShelfView containing the overflow items. Owned by |bubble_|. | 61 // ShelfView containing the overflow items. Owned by |bubble_|. |
64 ShelfView* shelf_view_; | 62 ShelfView* shelf_view_; |
65 | 63 |
66 DISALLOW_COPY_AND_ASSIGN(OverflowBubble); | 64 DISALLOW_COPY_AND_ASSIGN(OverflowBubble); |
67 }; | 65 }; |
68 | 66 |
69 } // namespace ash | 67 } // namespace ash |
70 | 68 |
71 #endif // ASH_COMMON_SHELF_OVERFLOW_BUBBLE_H_ | 69 #endif // ASH_COMMON_SHELF_OVERFLOW_BUBBLE_H_ |
OLD | NEW |