OLD | NEW |
| (Empty) |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef ASH_FRAME_CAPTION_BUTTONS_MAXIMIZE_BUBBLE_CONTROLLER_BUBBLE_H_ | |
6 #define ASH_FRAME_CAPTION_BUTTONS_MAXIMIZE_BUBBLE_CONTROLLER_BUBBLE_H_ | |
7 | |
8 #include "ash/wm/workspace/snap_types.h" | |
9 #include "ui/views/bubble/bubble_delegate.h" | |
10 #include "ui/views/mouse_watcher.h" | |
11 | |
12 namespace views { | |
13 class CustomButton; | |
14 } | |
15 | |
16 namespace ash { | |
17 | |
18 class BubbleContentsView; | |
19 class MaximizeBubbleBorder; | |
20 class MaximizeBubbleController; | |
21 | |
22 // The class which creates and manages the bubble menu element. | |
23 // It creates a 'bubble border' and the content accordingly. | |
24 // Note: Since the phantom window will show animations on top of the maximize | |
25 // button this menu gets created as a separate window and the phantom window | |
26 // will be created underneath this window. | |
27 class MaximizeBubbleControllerBubble : public views::BubbleDelegateView, | |
28 public views::MouseWatcherListener { | |
29 public: | |
30 static const SkColor kBubbleBackgroundColor; | |
31 static const int kLayoutSpacing; // The spacing between two buttons. | |
32 | |
33 MaximizeBubbleControllerBubble(MaximizeBubbleController* owner, | |
34 int appearance_delay_ms, | |
35 SnapType initial_snap_type); | |
36 virtual ~MaximizeBubbleControllerBubble(); | |
37 | |
38 // The window of the menu under which the phantom window will get created. | |
39 aura::Window* GetBubbleWindow(); | |
40 | |
41 // Overridden from views::BubbleDelegateView. | |
42 virtual gfx::Rect GetAnchorRect() OVERRIDE; | |
43 virtual bool CanActivate() const OVERRIDE; | |
44 | |
45 // Overridden from views::WidgetDelegateView. | |
46 virtual bool WidgetHasHitTestMask() const OVERRIDE; | |
47 virtual void GetWidgetHitTestMask(gfx::Path* mask) const OVERRIDE; | |
48 | |
49 // Implementation of MouseWatcherListener. | |
50 virtual void MouseMovedOutOfHost() OVERRIDE; | |
51 | |
52 // Implementation of MouseWatcherHost. | |
53 virtual bool Contains(const gfx::Point& screen_point, | |
54 views::MouseWatcherHost::MouseEventType type); | |
55 | |
56 // Overridden from views::View. | |
57 virtual gfx::Size GetPreferredSize() OVERRIDE; | |
58 | |
59 // Overridden from views::Widget::Observer. | |
60 virtual void OnWidgetDestroying(views::Widget* widget) OVERRIDE; | |
61 | |
62 // Called from the controller class to indicate that the menu should get | |
63 // destroyed. | |
64 virtual void ControllerRequestsCloseAndDelete(); | |
65 | |
66 // Called from the owning class to change the menu content to the given | |
67 // |snap_type| so that the user knows what is selected. | |
68 void SetSnapType(SnapType snap_type); | |
69 | |
70 // Get the owning MaximizeBubbleController. This might return NULL in case | |
71 // of an asynchronous shutdown. | |
72 MaximizeBubbleController* controller() const { return owner_; } | |
73 | |
74 // Added for unit test: Retrieve the button for an action. | |
75 // |state| can be either SNAP_LEFT, SNAP_RIGHT or SNAP_MINIMIZE. | |
76 views::CustomButton* GetButtonForUnitTest(SnapType state); | |
77 | |
78 private: | |
79 // True if the shut down has been initiated. | |
80 bool shutting_down_; | |
81 | |
82 // Our owning class. | |
83 MaximizeBubbleController* owner_; | |
84 | |
85 // The content accessor of the menu. | |
86 BubbleContentsView* contents_view_; | |
87 | |
88 // The bubble border (weak reference). | |
89 MaximizeBubbleBorder* bubble_border_; | |
90 | |
91 // The mouse watcher which takes care of out of window hover events. | |
92 scoped_ptr<views::MouseWatcher> mouse_watcher_; | |
93 | |
94 // The fade delay - if 0 it will show / hide immediately. | |
95 const int appearance_delay_ms_; | |
96 | |
97 DISALLOW_COPY_AND_ASSIGN(MaximizeBubbleControllerBubble); | |
98 }; | |
99 | |
100 } // namespace ash | |
101 | |
102 #endif // ASH_FRAME_CAPTION_BUTTONS_MAXIMIZE_BUBBLE_CONTROLLER_BUBBLE_H_ | |
OLD | NEW |