OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 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/caption_buttons/snap_types.h" | 10 #include "ash/wm/caption_buttons/snap_types.h" |
11 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
12 #include "base/timer/timer.h" | 12 #include "base/timer/timer.h" |
13 #include "ui/aura/window_observer.h" | 13 #include "ui/aura/window_observer.h" |
14 #include "ui/views/controls/button/image_button.h" | 14 #include "ui/views/controls/button/image_button.h" |
15 #include "ui/views/widget/widget_observer.h" | 15 #include "ui/views/widget/widget_observer.h" |
16 | 16 |
17 namespace views { | 17 namespace views { |
18 class NonClientFrameView; | 18 class Widget; |
19 } | 19 } |
20 | 20 |
21 namespace ash { | 21 namespace ash { |
22 | 22 |
23 namespace internal { | 23 namespace internal { |
24 class PhantomWindowController; | 24 class PhantomWindowController; |
25 class SnapSizer; | 25 class SnapSizer; |
26 } | 26 } |
27 | 27 |
28 class MaximizeBubbleController; | 28 class MaximizeBubbleController; |
29 | 29 |
30 // Button used for the maximize control on the frame. Handles snapping logic. | 30 // Button used for the maximize control on the frame. Handles snapping logic. |
31 class ASH_EXPORT FrameMaximizeButton : public views::ImageButton, | 31 class ASH_EXPORT FrameMaximizeButton : public views::ImageButton, |
32 public views::WidgetObserver, | 32 public views::WidgetObserver, |
33 public aura::WindowObserver { | 33 public aura::WindowObserver { |
34 public: | 34 public: |
35 FrameMaximizeButton(views::ButtonListener* listener, | 35 FrameMaximizeButton(views::ButtonListener* listener, |
36 views::NonClientFrameView* frame); | 36 views::Widget* frame); |
37 virtual ~FrameMaximizeButton(); | 37 virtual ~FrameMaximizeButton(); |
38 | 38 |
39 // Updates |snap_type_| based on a a given snap type. This is used by | 39 // Updates |snap_type_| based on a a given snap type. This is used by |
40 // external hover events from the button menu. | 40 // external hover events from the button menu. |
41 void SnapButtonHovered(SnapType type); | 41 void SnapButtonHovered(SnapType type); |
42 | 42 |
43 // The user clicked the |type| button and the action needs to be performed, | 43 // The user clicked the |type| button and the action needs to be performed, |
44 // which will at the same time close the window. | 44 // which will at the same time close the window. |
45 void ExecuteSnapAndCloseMenu(SnapType type); | 45 void ExecuteSnapAndCloseMenu(SnapType type); |
46 | 46 |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
131 // Converts location to screen coordinates and returns it. These are the | 131 // Converts location to screen coordinates and returns it. These are the |
132 // coordinates used by the SnapSizer. | 132 // coordinates used by the SnapSizer. |
133 gfx::Point LocationForSnapSizer(const gfx::Point& location) const; | 133 gfx::Point LocationForSnapSizer(const gfx::Point& location) const; |
134 | 134 |
135 // Snaps the window to the current snap position. | 135 // Snaps the window to the current snap position. |
136 void Snap(const internal::SnapSizer& snap_sizer); | 136 void Snap(const internal::SnapSizer& snap_sizer); |
137 | 137 |
138 // Determine the maximize type of this window. | 138 // Determine the maximize type of this window. |
139 MaximizeBubbleFrameState GetMaximizeBubbleFrameState() const; | 139 MaximizeBubbleFrameState GetMaximizeBubbleFrameState() const; |
140 | 140 |
141 // Frame that the maximize button acts on. | 141 // Widget that the maximize button acts on. |
James Cook
2013/09/16 16:08:07
Maybe comment why you need to cache the widget, ra
| |
142 views::NonClientFrameView* frame_; | 142 views::Widget* frame_; |
143 | |
144 // True if we have put observers on |frame_|. | |
145 bool observing_frame_; | |
143 | 146 |
144 // Renders the snap position. | 147 // Renders the snap position. |
145 scoped_ptr<internal::PhantomWindowController> phantom_window_; | 148 scoped_ptr<internal::PhantomWindowController> phantom_window_; |
146 | 149 |
147 // Is snapping enabled? Set on press so that in drag we know whether we | 150 // Is snapping enabled? Set on press so that in drag we know whether we |
148 // should show the snap locations. | 151 // should show the snap locations. |
149 bool is_snap_enabled_; | 152 bool is_snap_enabled_; |
150 | 153 |
151 // Did the user drag far enough to trigger snapping? | 154 // Did the user drag far enough to trigger snapping? |
152 bool exceeded_drag_threshold_; | 155 bool exceeded_drag_threshold_; |
153 | 156 |
154 // Remember the widget on which we have put some an observers, | |
155 // so that we can remove it upon destruction. | |
156 views::Widget* widget_; | |
157 | |
158 // Location of the press. | 157 // Location of the press. |
159 gfx::Point press_location_; | 158 gfx::Point press_location_; |
160 | 159 |
161 // True if the press was triggered by a gesture/touch. | 160 // True if the press was triggered by a gesture/touch. |
162 bool press_is_gesture_; | 161 bool press_is_gesture_; |
163 | 162 |
164 // Current snap type. | 163 // Current snap type. |
165 SnapType snap_type_; | 164 SnapType snap_type_; |
166 | 165 |
167 scoped_ptr<internal::SnapSizer> snap_sizer_; | 166 scoped_ptr<internal::SnapSizer> snap_sizer_; |
168 | 167 |
169 scoped_ptr<EscapeEventFilter> escape_event_filter_; | 168 scoped_ptr<EscapeEventFilter> escape_event_filter_; |
170 | 169 |
171 base::OneShotTimer<FrameMaximizeButton> update_timer_; | 170 base::OneShotTimer<FrameMaximizeButton> update_timer_; |
172 | 171 |
173 scoped_ptr<MaximizeBubbleController> maximizer_; | 172 scoped_ptr<MaximizeBubbleController> maximizer_; |
174 | 173 |
175 // The delay of the bubble appearance. | 174 // The delay of the bubble appearance. |
176 int bubble_appearance_delay_ms_; | 175 int bubble_appearance_delay_ms_; |
177 | 176 |
178 DISALLOW_COPY_AND_ASSIGN(FrameMaximizeButton); | 177 DISALLOW_COPY_AND_ASSIGN(FrameMaximizeButton); |
179 }; | 178 }; |
180 | 179 |
181 } // namespace ash | 180 } // namespace ash |
182 | 181 |
183 #endif // ASH_WM_CAPTION_BUTTONS_FRAME_MAXIMIZE_BUTTON_H_ | 182 #endif // ASH_WM_CAPTION_BUTTONS_FRAME_MAXIMIZE_BUTTON_H_ |
OLD | NEW |