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_SHELF_OVERFLOW_BUBBLE_VIEW_H_ | 5 #ifndef ASH_COMMON_SHELF_OVERFLOW_BUBBLE_VIEW_H_ |
6 #define ASH_SHELF_OVERFLOW_BUBBLE_VIEW_H_ | 6 #define ASH_COMMON_SHELF_OVERFLOW_BUBBLE_VIEW_H_ |
7 | 7 |
8 #include "ash/ash_export.h" | 8 #include "ash/ash_export.h" |
9 #include "base/compiler_specific.h" | |
10 #include "base/macros.h" | 9 #include "base/macros.h" |
11 #include "ui/views/bubble/bubble_dialog_delegate.h" | 10 #include "ui/views/bubble/bubble_dialog_delegate.h" |
12 | 11 |
| 12 namespace views { |
| 13 class View; |
| 14 } |
| 15 |
13 namespace ash { | 16 namespace ash { |
14 class ShelfView; | 17 class WmShelf; |
15 | 18 |
16 namespace test { | 19 namespace test { |
17 class OverflowBubbleViewTestAPI; | 20 class OverflowBubbleViewTestAPI; |
18 } | 21 } |
19 | 22 |
20 // OverflowBubbleView hosts a ShelfView to display overflown items. | 23 // OverflowBubbleView hosts a ShelfView to display overflown items. |
21 // Exports to access this class from OverflowBubbleViewTestAPI. | 24 // Exports to access this class from OverflowBubbleViewTestAPI. |
22 class ASH_EXPORT OverflowBubbleView : public views::BubbleDialogDelegateView { | 25 class ASH_EXPORT OverflowBubbleView : public views::BubbleDialogDelegateView { |
23 public: | 26 public: |
24 OverflowBubbleView(); | 27 explicit OverflowBubbleView(WmShelf* wm_shelf); |
25 ~OverflowBubbleView() override; | 28 ~OverflowBubbleView() override; |
26 | 29 |
27 void InitOverflowBubble(views::View* anchor, ShelfView* shelf_view); | 30 // |anchor| is the overflow button on the main shelf. |shelf_view| is the |
| 31 // ShelfView containing the overflow items. |
| 32 void InitOverflowBubble(views::View* anchor, views::View* shelf_view); |
28 | 33 |
29 // views::BubbleDialogDelegateView overrides: | 34 // views::BubbleDialogDelegateView overrides: |
30 int GetDialogButtons() const override; | 35 int GetDialogButtons() const override; |
| 36 void OnBeforeBubbleWidgetInit(views::Widget::InitParams* params, |
| 37 views::Widget* bubble_widget) const override; |
31 gfx::Rect GetBubbleBounds() override; | 38 gfx::Rect GetBubbleBounds() override; |
32 | 39 |
33 private: | 40 private: |
34 friend class test::OverflowBubbleViewTestAPI; | 41 friend class test::OverflowBubbleViewTestAPI; |
35 | 42 |
36 bool IsHorizontalAlignment() const; | 43 bool IsHorizontalAlignment() const; |
37 | 44 |
38 const gfx::Size GetContentsSize() const; | 45 const gfx::Size GetContentsSize() const; |
39 | 46 |
40 // Gets arrow location based on shelf alignment. | 47 // Gets arrow location based on shelf alignment. |
41 views::BubbleBorder::Arrow GetBubbleArrow() const; | 48 views::BubbleBorder::Arrow GetBubbleArrow() const; |
42 | 49 |
43 void ScrollByXOffset(int x_offset); | 50 void ScrollByXOffset(int x_offset); |
44 void ScrollByYOffset(int y_offset); | 51 void ScrollByYOffset(int y_offset); |
45 | 52 |
46 // views::View overrides: | 53 // views::View overrides: |
47 gfx::Size GetPreferredSize() const override; | 54 gfx::Size GetPreferredSize() const override; |
48 void Layout() override; | 55 void Layout() override; |
49 void ChildPreferredSizeChanged(views::View* child) override; | 56 void ChildPreferredSizeChanged(views::View* child) override; |
50 bool OnMouseWheel(const ui::MouseWheelEvent& event) override; | 57 bool OnMouseWheel(const ui::MouseWheelEvent& event) override; |
51 | 58 |
52 // ui::EventHandler overrides: | 59 // ui::EventHandler overrides: |
53 void OnScrollEvent(ui::ScrollEvent* event) override; | 60 void OnScrollEvent(ui::ScrollEvent* event) override; |
54 | 61 |
55 ShelfView* shelf_view_; // Owned by views hierarchy. | 62 WmShelf* wm_shelf_; |
| 63 views::View* shelf_view_; // Owned by views hierarchy. |
56 gfx::Vector2d scroll_offset_; | 64 gfx::Vector2d scroll_offset_; |
57 | 65 |
58 DISALLOW_COPY_AND_ASSIGN(OverflowBubbleView); | 66 DISALLOW_COPY_AND_ASSIGN(OverflowBubbleView); |
59 }; | 67 }; |
60 | 68 |
61 } // namespace ash | 69 } // namespace ash |
62 | 70 |
63 #endif // ASH_SHELF_OVERFLOW_BUBBLE_VIEW_H_ | 71 #endif // ASH_COMMON_SHELF_OVERFLOW_BUBBLE_VIEW_H_ |
OLD | NEW |