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/overview/window_selector_item.h" | 5 #include "ash/wm/overview/window_selector_item.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "ash/screen_util.h" | 10 #include "ash/screen_util.h" |
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
205 if (transform_window->window() == window) { | 205 if (transform_window->window() == window) { |
206 transform_window->window()->RemoveObserver(this); | 206 transform_window->window()->RemoveObserver(this); |
207 transform_window->OnWindowDestroyed(); | 207 transform_window->OnWindowDestroyed(); |
208 transform_windows_.erase(iter); | 208 transform_windows_.erase(iter); |
209 window_found = true; | 209 window_found = true; |
210 break; | 210 break; |
211 } | 211 } |
212 } | 212 } |
213 CHECK(window_found); | 213 CHECK(window_found); |
214 | 214 |
215 | |
216 // If empty WindowSelectorItem will be destroyed immediately after this by | 215 // If empty WindowSelectorItem will be destroyed immediately after this by |
217 // its owner. | 216 // its owner. |
218 if (empty()) | 217 if (empty()) |
219 return; | 218 return; |
220 | 219 |
221 UpdateCloseButtonAccessibilityName(); | 220 UpdateCloseButtonAccessibilityName(); |
222 window_label_.reset(); | 221 window_label_.reset(); |
223 UpdateWindowLabels(target_bounds_, | 222 UpdateWindowLabels(target_bounds_, |
224 OverviewAnimationType::OVERVIEW_ANIMATION_NONE); | 223 OverviewAnimationType::OVERVIEW_ANIMATION_NONE); |
225 UpdateCloseButtonLayout(OverviewAnimationType::OVERVIEW_ANIMATION_NONE); | 224 UpdateCloseButtonLayout(OverviewAnimationType::OVERVIEW_ANIMATION_NONE); |
(...skipping 19 matching lines...) Expand all Loading... |
245 | 244 |
246 UpdateWindowLabels(target_bounds, animation_type); | 245 UpdateWindowLabels(target_bounds, animation_type); |
247 | 246 |
248 gfx::Rect inset_bounds(target_bounds); | 247 gfx::Rect inset_bounds(target_bounds); |
249 inset_bounds.Inset(kWindowMargin, kWindowMargin); | 248 inset_bounds.Inset(kWindowMargin, kWindowMargin); |
250 SetItemBounds(root_window, inset_bounds, animation_type); | 249 SetItemBounds(root_window, inset_bounds, animation_type); |
251 | 250 |
252 // SetItemBounds is called before UpdateCloseButtonLayout so the close button | 251 // SetItemBounds is called before UpdateCloseButtonLayout so the close button |
253 // can properly use the updated windows bounds. | 252 // can properly use the updated windows bounds. |
254 UpdateCloseButtonLayout(animation_type); | 253 UpdateCloseButtonLayout(animation_type); |
| 254 SetCloseWindowDistanceMinimum(target_bounds_.size().width() / 2); |
255 UpdateSelectorButtons(); | 255 UpdateSelectorButtons(); |
256 } | 256 } |
257 | 257 |
258 void WindowSelectorItem::RecomputeWindowTransforms() { | 258 void WindowSelectorItem::RecomputeWindowTransforms() { |
259 if (in_bounds_update_ || target_bounds_.IsEmpty()) | 259 if (in_bounds_update_ || target_bounds_.IsEmpty()) |
260 return; | 260 return; |
261 DCHECK(root_window_); | 261 DCHECK(root_window_); |
262 base::AutoReset<bool> auto_reset_in_bounds_update(&in_bounds_update_, true); | 262 base::AutoReset<bool> auto_reset_in_bounds_update(&in_bounds_update_, true); |
263 gfx::Rect inset_bounds(target_bounds_); | 263 gfx::Rect inset_bounds(target_bounds_); |
264 inset_bounds.Inset(kWindowMargin, kWindowMargin); | 264 inset_bounds.Inset(kWindowMargin, kWindowMargin); |
(...skipping 23 matching lines...) Expand all Loading... |
288 // TODO(flackr): Maybe add the new title to a vector of titles so that we can | 288 // TODO(flackr): Maybe add the new title to a vector of titles so that we can |
289 // filter any of the titles the window had while in the overview session. | 289 // filter any of the titles the window had while in the overview session. |
290 if (window == SelectionWindow()) { | 290 if (window == SelectionWindow()) { |
291 window_label_view_->SetText(window->title()); | 291 window_label_view_->SetText(window->title()); |
292 UpdateCloseButtonAccessibilityName(); | 292 UpdateCloseButtonAccessibilityName(); |
293 } | 293 } |
294 UpdateCloseButtonLayout(OverviewAnimationType::OVERVIEW_ANIMATION_NONE); | 294 UpdateCloseButtonLayout(OverviewAnimationType::OVERVIEW_ANIMATION_NONE); |
295 UpdateSelectorButtons(); | 295 UpdateSelectorButtons(); |
296 } | 296 } |
297 | 297 |
| 298 void WindowSelectorItem::Scroll(int delta_x) { |
| 299 for (TransformWindows::iterator iter = transform_windows_.begin(); |
| 300 iter != transform_windows_.end(); |
| 301 iter++) { |
| 302 (*iter)->Scroll(delta_x); |
| 303 } |
| 304 } |
| 305 |
| 306 void WindowSelectorItem::CancelScroll() { |
| 307 for (TransformWindows::iterator iter = transform_windows_.begin(); |
| 308 iter != transform_windows_.end(); |
| 309 iter++) { |
| 310 (*iter)->CancelScroll(); |
| 311 } |
| 312 } |
| 313 |
298 void WindowSelectorItem::Select() { | 314 void WindowSelectorItem::Select() { |
299 aura::Window* selection_window = SelectionWindow(); | 315 aura::Window* selection_window = SelectionWindow(); |
300 if (selection_window) | 316 if (selection_window) |
301 wm::GetWindowState(selection_window)->Activate(); | 317 wm::GetWindowState(selection_window)->Activate(); |
302 } | 318 } |
303 | 319 |
| 320 void WindowSelectorItem::Close() { |
| 321 for (TransformWindows::iterator iter = transform_windows_.begin(); |
| 322 iter != transform_windows_.end(); |
| 323 iter++) { |
| 324 (*iter)->Close(); |
| 325 } |
| 326 } |
| 327 |
304 void WindowSelectorItem::SetItemBounds(aura::Window* root_window, | 328 void WindowSelectorItem::SetItemBounds(aura::Window* root_window, |
305 const gfx::Rect& target_bounds, | 329 const gfx::Rect& target_bounds, |
306 OverviewAnimationType animation_type) { | 330 OverviewAnimationType animation_type) { |
307 gfx::Rect bounding_rect; | 331 gfx::Rect bounding_rect; |
308 for (auto* transform_window : transform_windows_) { | 332 for (auto* transform_window : transform_windows_) { |
309 bounding_rect.Union( | 333 bounding_rect.Union( |
310 transform_window->GetTargetBoundsInScreen()); | 334 transform_window->GetTargetBoundsInScreen()); |
311 } | 335 } |
312 gfx::Rect bounds = | 336 gfx::Rect bounds = |
313 ScopedTransformOverviewWindow::ShrinkRectToFitPreservingAspectRatio( | 337 ScopedTransformOverviewWindow::ShrinkRectToFitPreservingAspectRatio( |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
394 window_label_view_->SetText(title); | 418 window_label_view_->SetText(title); |
395 views::BoxLayout* layout = new views::BoxLayout(views::BoxLayout::kVertical, | 419 views::BoxLayout* layout = new views::BoxLayout(views::BoxLayout::kVertical, |
396 0, | 420 0, |
397 kVerticalLabelPadding, | 421 kVerticalLabelPadding, |
398 0); | 422 0); |
399 window_label_view_->SetLayoutManager(layout); | 423 window_label_view_->SetLayoutManager(layout); |
400 window_label_->SetContentsView(window_label_view_); | 424 window_label_->SetContentsView(window_label_view_); |
401 window_label_->Show(); | 425 window_label_->Show(); |
402 } | 426 } |
403 | 427 |
| 428 void WindowSelectorItem::SetCloseWindowDistanceMinimum(int distance) { |
| 429 selector_item_activate_window_button_->SetCloseWindowDistanceMinimum( |
| 430 distance); |
| 431 for (TransformWindows::iterator iter = transform_windows_.begin(); |
| 432 iter != transform_windows_.end(); |
| 433 ++iter) { |
| 434 (*iter)->activate_button()->SetCloseWindowDistanceMinimum(distance); |
| 435 } |
| 436 } |
| 437 |
404 void WindowSelectorItem::UpdateSelectorButtons() { | 438 void WindowSelectorItem::UpdateSelectorButtons() { |
405 CHECK(!transform_windows_.empty()); | 439 CHECK(!transform_windows_.empty()); |
406 | 440 |
407 selector_item_activate_window_button_->SetBounds(target_bounds()); | 441 selector_item_activate_window_button_->SetBounds(target_bounds()); |
408 selector_item_activate_window_button_->SetAccessibleName( | 442 selector_item_activate_window_button_->SetAccessibleName( |
409 transform_windows_.front()->window()->title()); | 443 transform_windows_.front()->window()->title()); |
410 | 444 |
411 for (auto* transform_window : transform_windows_) { | 445 for (auto* transform_window : transform_windows_) { |
412 TransparentActivateWindowButton* activate_button = | 446 TransparentActivateWindowButton* activate_button = |
413 transform_window->activate_button(); | 447 transform_window->activate_button(); |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
448 SelectionWindow()->title())); | 482 SelectionWindow()->title())); |
449 } | 483 } |
450 | 484 |
451 ScopedTransformOverviewWindow* | 485 ScopedTransformOverviewWindow* |
452 WindowSelectorItem::SelectionTransformWindow() const { | 486 WindowSelectorItem::SelectionTransformWindow() const { |
453 CHECK(!transform_windows_.empty()); | 487 CHECK(!transform_windows_.empty()); |
454 return transform_windows_.front(); | 488 return transform_windows_.front(); |
455 } | 489 } |
456 | 490 |
457 } // namespace ash | 491 } // namespace ash |
OLD | NEW |