OLD | NEW |
| (Empty) |
1 // Copyright (c) 2012 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_WM_MAXIMIZE_BUBBLE_CONTROLLER_H_ | |
6 #define ASH_WM_MAXIMIZE_BUBBLE_CONTROLLER_H_ | |
7 | |
8 #include "ash/ash_export.h" | |
9 #include "ash/wm/workspace/maximize_bubble_frame_state.h" | |
10 #include "ash/wm/workspace/snap_types.h" | |
11 #include "base/memory/scoped_ptr.h" | |
12 | |
13 namespace aura { | |
14 class Window; | |
15 } | |
16 | |
17 namespace base { | |
18 class Timer; | |
19 } | |
20 | |
21 namespace views { | |
22 class CustomButton; | |
23 } | |
24 | |
25 namespace ash { | |
26 | |
27 class FrameMaximizeButton; | |
28 | |
29 // A class which shows a helper UI for the maximize button after a delay. | |
30 class ASH_EXPORT MaximizeBubbleController { | |
31 public: | |
32 class Bubble; | |
33 | |
34 MaximizeBubbleController(FrameMaximizeButton* frame_maximize_button, | |
35 MaximizeBubbleFrameState maximize_type, | |
36 int appearance_delay_ms); | |
37 // Called from the outside to destroy the interface to the UI visuals. | |
38 // The visuals will then delete when possible (maybe asynchronously). | |
39 virtual ~MaximizeBubbleController(); | |
40 | |
41 // Update the UI visuals to reflect the previewed |snap_type| snapping state. | |
42 void SetSnapType(SnapType snap_type); | |
43 | |
44 // To achieve proper Z-sorting with the snap animation, this window will be | |
45 // presented above the phantom window. | |
46 aura::Window* GetBubbleWindow(); | |
47 | |
48 // Reset the delay of the menu creation (if it was not created yet). | |
49 void DelayCreation(); | |
50 | |
51 // Called to tell the owning FrameMaximizeButton that a button was clicked. | |
52 void OnButtonClicked(SnapType snap_type); | |
53 | |
54 // Called to tell the the owning FrameMaximizeButton that the hover status | |
55 // for a button has changed. |snap_type| can be either SNAP_LEFT, SNAP_RIGHT, | |
56 // SNAP_MINIMIZE or SNAP_NONE. | |
57 void OnButtonHover(SnapType snap_type); | |
58 | |
59 // Get the owning FrameMaximizeButton. | |
60 FrameMaximizeButton* frame_maximize_button() { | |
61 return frame_maximize_button_; | |
62 } | |
63 | |
64 // The status of the associated window: Maximized or normal. | |
65 MaximizeBubbleFrameState maximize_type() const { return maximize_type_; } | |
66 | |
67 // A unit test function to return buttons of the sub menu. |state| can be | |
68 // either SNAP_LEFT, SNAP_RIGHT or SNAP_MINIMIZE. | |
69 views::CustomButton* GetButtonForUnitTest(SnapType state); | |
70 | |
71 protected: | |
72 // Called from the the Bubble class to destroy itself: It tells the owning | |
73 // object that it will destroy itself asynchronously. The owner will then | |
74 // destroy |this|. | |
75 void RequestDestructionThroughOwner(); | |
76 | |
77 private: | |
78 // The function which creates the bubble once the delay is elapsed. | |
79 void CreateBubble(); | |
80 | |
81 // The owning button which is also the anchor for the menu. | |
82 FrameMaximizeButton* frame_maximize_button_; | |
83 | |
84 // The bubble menu. | |
85 Bubble* bubble_; | |
86 | |
87 // The current maximize state of the owning window. | |
88 const MaximizeBubbleFrameState maximize_type_; | |
89 | |
90 // The timer for the delayed creation of the menu. | |
91 scoped_ptr<base::Timer> timer_; | |
92 | |
93 // The appearance delay in ms (delay and fade in & fade out delay). | |
94 const int appearance_delay_ms_; | |
95 | |
96 DISALLOW_COPY_AND_ASSIGN(MaximizeBubbleController); | |
97 }; | |
98 | |
99 } // namespace ash | |
100 | |
101 #endif // ASH_WM_MAXIMIZE_BUBBLE_CONTROLLER_H_ | |
OLD | NEW |