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_WM_CAPTION_BUTTONS_FRAME_MAXIMIZE_BUTTON_H_ | 5 #ifndef ASH_WM_CAPTION_BUTTONS_FRAME_MAXIMIZE_BUTTON_H_ |
6 #define ASH_WM_CAPTION_BUTTONS_FRAME_MAXIMIZE_BUTTON_H_ | 6 #define ASH_WM_CAPTION_BUTTONS_FRAME_MAXIMIZE_BUTTON_H_ |
7 | 7 |
8 #include "ash/ash_export.h" | 8 #include "ash/ash_export.h" |
9 #include "ash/wm/caption_buttons/maximize_bubble_frame_state.h" | 9 #include "ash/wm/caption_buttons/maximize_bubble_frame_state.h" |
10 #include "ash/wm/workspace/snap_types.h" | 10 #include "ash/wm/workspace/snap_types.h" |
11 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
| 12 #include "base/observer_list.h" |
12 #include "base/timer/timer.h" | 13 #include "base/timer/timer.h" |
13 #include "ui/aura/window_observer.h" | 14 #include "ui/aura/window_observer.h" |
14 #include "ui/views/controls/button/image_button.h" | 15 #include "ui/views/controls/button/image_button.h" |
15 #include "ui/views/widget/widget_observer.h" | 16 #include "ui/views/widget/widget_observer.h" |
16 | 17 |
17 namespace views { | 18 namespace views { |
18 class Widget; | 19 class Widget; |
19 } | 20 } |
20 | 21 |
21 namespace ash { | 22 namespace ash { |
| 23 class FrameMaximizeButtonObserver; |
22 | 24 |
23 namespace internal { | 25 namespace internal { |
24 class PhantomWindowController; | 26 class PhantomWindowController; |
25 class SnapSizer; | 27 class SnapSizer; |
26 } | 28 } |
27 | 29 |
28 class MaximizeBubbleController; | 30 class MaximizeBubbleController; |
29 | 31 |
30 // Button used for the maximize control on the frame. Handles snapping logic. | 32 // Button used for the maximize control on the frame. Handles snapping logic. |
31 class ASH_EXPORT FrameMaximizeButton : public views::ImageButton, | 33 class ASH_EXPORT FrameMaximizeButton : public views::ImageButton, |
32 public views::WidgetObserver, | 34 public views::WidgetObserver, |
33 public aura::WindowObserver { | 35 public aura::WindowObserver { |
34 public: | 36 public: |
35 FrameMaximizeButton(views::ButtonListener* listener, | 37 FrameMaximizeButton(views::ButtonListener* listener, |
36 views::Widget* frame); | 38 views::Widget* frame); |
37 virtual ~FrameMaximizeButton(); | 39 virtual ~FrameMaximizeButton(); |
38 | 40 |
| 41 void AddObserver(FrameMaximizeButtonObserver* observer); |
| 42 void RemoveObserver(FrameMaximizeButtonObserver* observer); |
| 43 |
39 // Updates |snap_type_| based on a a given snap type. This is used by | 44 // Updates |snap_type_| based on a a given snap type. This is used by |
40 // external hover events from the button menu. | 45 // external hover events from the button menu. |
41 void SnapButtonHovered(SnapType type); | 46 void SnapButtonHovered(SnapType type); |
42 | 47 |
43 // The user clicked the |type| button and the action needs to be performed, | 48 // The user clicked the |type| button and the action needs to be performed, |
44 // which will at the same time close the window. | 49 // which will at the same time close the window. |
45 void ExecuteSnapAndCloseMenu(SnapType type); | 50 void ExecuteSnapAndCloseMenu(SnapType type); |
46 | 51 |
| 52 // Called by the MaximizeBubbleController when the maximize bubble is shown. |
| 53 void OnMaximizeBubbleShown(views::Widget* bubble); |
| 54 |
47 // Remove the maximize menu from the screen (and destroy it). | 55 // Remove the maximize menu from the screen (and destroy it). |
48 void DestroyMaximizeMenu(); | 56 void DestroyMaximizeMenu(); |
49 | 57 |
50 // Returns true when the user clicks and drags the button. | 58 // Returns true when the user clicks and drags the button. |
51 bool is_snap_enabled() const { return is_snap_enabled_; } | 59 bool is_snap_enabled() const { return is_snap_enabled_; } |
52 | 60 |
53 // WindowObserver overrides: | 61 // WindowObserver overrides: |
54 virtual void OnWindowBoundsChanged(aura::Window* window, | 62 virtual void OnWindowBoundsChanged(aura::Window* window, |
55 const gfx::Rect& old_bounds, | 63 const gfx::Rect& old_bounds, |
56 const gfx::Rect& new_bounds) OVERRIDE; | 64 const gfx::Rect& new_bounds) OVERRIDE; |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
168 | 176 |
169 scoped_ptr<EscapeEventFilter> escape_event_filter_; | 177 scoped_ptr<EscapeEventFilter> escape_event_filter_; |
170 | 178 |
171 base::OneShotTimer<FrameMaximizeButton> update_timer_; | 179 base::OneShotTimer<FrameMaximizeButton> update_timer_; |
172 | 180 |
173 scoped_ptr<MaximizeBubbleController> maximizer_; | 181 scoped_ptr<MaximizeBubbleController> maximizer_; |
174 | 182 |
175 // The delay of the bubble appearance. | 183 // The delay of the bubble appearance. |
176 int bubble_appearance_delay_ms_; | 184 int bubble_appearance_delay_ms_; |
177 | 185 |
| 186 ObserverList<FrameMaximizeButtonObserver> observer_list_; |
| 187 |
178 DISALLOW_COPY_AND_ASSIGN(FrameMaximizeButton); | 188 DISALLOW_COPY_AND_ASSIGN(FrameMaximizeButton); |
179 }; | 189 }; |
180 | 190 |
181 } // namespace ash | 191 } // namespace ash |
182 | 192 |
183 #endif // ASH_WM_CAPTION_BUTTONS_FRAME_MAXIMIZE_BUTTON_H_ | 193 #endif // ASH_WM_CAPTION_BUTTONS_FRAME_MAXIMIZE_BUTTON_H_ |
OLD | NEW |