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 #include "ash/wm/caption_buttons/alternate_frame_size_button.h" | 5 #include "ash/wm/caption_buttons/alternate_frame_size_button.h" |
6 | 6 |
7 #include "ash/metrics/user_metrics_recorder.h" | 7 #include "ash/metrics/user_metrics_recorder.h" |
8 #include "ash/shell.h" | 8 #include "ash/shell.h" |
9 #include "ash/touch/touch_uma.h" | 9 #include "ash/touch/touch_uma.h" |
10 #include "ash/wm/window_state.h" | 10 #include "ash/wm/window_state.h" |
| 11 #include "ash/wm/workspace/phantom_window_controller.h" |
11 #include "ash/wm/workspace/snap_sizer.h" | 12 #include "ash/wm/workspace/snap_sizer.h" |
12 #include "ui/gfx/vector2d.h" | 13 #include "ui/gfx/vector2d.h" |
13 #include "ui/views/widget/widget.h" | 14 #include "ui/views/widget/widget.h" |
14 | 15 |
15 namespace { | 16 namespace { |
16 | 17 |
17 // The default delay between the user pressing the size button and the buttons | 18 // The default delay between the user pressing the size button and the buttons |
18 // adjacent to the size button morphing into buttons for snapping left and | 19 // adjacent to the size button morphing into buttons for snapping left and |
19 // right. | 20 // right. |
20 const int kSetButtonsToSnapModeDelayMs = 150; | 21 const int kSetButtonsToSnapModeDelayMs = 150; |
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
169 break; | 170 break; |
170 case CAPTION_BUTTON_ICON_MAXIMIZE_RESTORE: | 171 case CAPTION_BUTTON_ICON_MAXIMIZE_RESTORE: |
171 // snap_type_ = SNAP_NONE | 172 // snap_type_ = SNAP_NONE |
172 break; | 173 break; |
173 case CAPTION_BUTTON_ICON_MINIMIZE: | 174 case CAPTION_BUTTON_ICON_MINIMIZE: |
174 case CAPTION_BUTTON_ICON_CLOSE: | 175 case CAPTION_BUTTON_ICON_CLOSE: |
175 NOTREACHED(); | 176 NOTREACHED(); |
176 break; | 177 break; |
177 } | 178 } |
178 } | 179 } |
| 180 |
| 181 if (snap_type_ == SNAP_LEFT || snap_type_ == SNAP_RIGHT) { |
| 182 if (!phantom_window_controller_.get()) { |
| 183 phantom_window_controller_.reset( |
| 184 new internal::PhantomWindowController(frame_->GetNativeWindow())); |
| 185 } |
| 186 |
| 187 using internal::SnapSizer; |
| 188 SnapSizer snap_sizer(wm::GetWindowState(frame_->GetNativeWindow()), |
| 189 gfx::Point(), |
| 190 snap_type_ == SNAP_LEFT ? |
| 191 SnapSizer::LEFT_EDGE : SnapSizer::RIGHT_EDGE, |
| 192 SnapSizer::OTHER_INPUT); |
| 193 phantom_window_controller_->Show(snap_sizer.target_bounds()); |
| 194 } else { |
| 195 if (phantom_window_controller_.get()) |
| 196 phantom_window_controller_->StartFadeOut(); |
| 197 } |
179 } | 198 } |
180 | 199 |
181 bool AlternateFrameSizeButton::CommitSnap(const ui::LocatedEvent& event) { | 200 bool AlternateFrameSizeButton::CommitSnap(const ui::LocatedEvent& event) { |
182 // The position of |event| may be different than the position of the previous | 201 // The position of |event| may be different than the position of the previous |
183 // event. | 202 // event. |
184 UpdatePressedButton(event); | 203 UpdatePressedButton(event); |
185 | 204 |
186 if (in_snap_mode_ && | 205 if (in_snap_mode_ && |
187 (snap_type_ == SNAP_LEFT || snap_type_ == SNAP_RIGHT)) { | 206 (snap_type_ == SNAP_LEFT || snap_type_ == SNAP_RIGHT)) { |
188 using internal::SnapSizer; | 207 using internal::SnapSizer; |
(...skipping 10 matching lines...) Expand all Loading... |
199 SetButtonsToNormalMode(AlternateFrameSizeButtonDelegate::ANIMATE_YES); | 218 SetButtonsToNormalMode(AlternateFrameSizeButtonDelegate::ANIMATE_YES); |
200 return false; | 219 return false; |
201 } | 220 } |
202 | 221 |
203 void AlternateFrameSizeButton::SetButtonsToNormalMode( | 222 void AlternateFrameSizeButton::SetButtonsToNormalMode( |
204 AlternateFrameSizeButtonDelegate::Animate animate) { | 223 AlternateFrameSizeButtonDelegate::Animate animate) { |
205 in_snap_mode_ = false; | 224 in_snap_mode_ = false; |
206 snap_type_ = SNAP_NONE; | 225 snap_type_ = SNAP_NONE; |
207 set_buttons_to_snap_mode_timer_.Stop(); | 226 set_buttons_to_snap_mode_timer_.Stop(); |
208 delegate_->SetButtonsToNormal(animate); | 227 delegate_->SetButtonsToNormal(animate); |
| 228 phantom_window_controller_.reset(); |
209 } | 229 } |
210 | 230 |
211 } // namespace ash | 231 } // namespace ash |
OLD | NEW |