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
3// found in the LICENSE file.
4
5#include "ash/wm/overview/window_selector_window.h"
6
7#include "ui/aura/window.h"
8
9namespace ash {
10
11WindowSelectorWindow::WindowSelectorWindow(aura::Window* window)
12    : transform_window_(window) {
13}
14
15WindowSelectorWindow::~WindowSelectorWindow() {
16}
17
18aura::Window* WindowSelectorWindow::GetRootWindow() {
19  return transform_window_.window()->GetRootWindow();
20}
21
22bool WindowSelectorWindow::HasSelectableWindow(const aura::Window* window) {
23  return transform_window_.window() == window;
24}
25
26aura::Window* WindowSelectorWindow::TargetedWindow(const aura::Window* target) {
27  if (transform_window_.Contains(target))
28    return transform_window_.window();
29  return NULL;
30}
31
32void WindowSelectorWindow::RestoreWindowOnExit(aura::Window* window) {
33  transform_window_.RestoreWindowOnExit();
34}
35
36aura::Window* WindowSelectorWindow::SelectionWindow() {
37  return transform_window_.window();
38}
39
40void WindowSelectorWindow::RemoveWindow(const aura::Window* window) {
41  DCHECK_EQ(transform_window_.window(), window);
42  transform_window_.OnWindowDestroyed();
43}
44
45bool WindowSelectorWindow::empty() const {
46  return transform_window_.window() == NULL;
47}
48
49void WindowSelectorWindow::PrepareForOverview() {
50  transform_window_.PrepareForOverview();
51}
52
53void WindowSelectorWindow::SetItemBounds(aura::Window* root_window,
54                                         const gfx::Rect& target_bounds,
55                                         bool animate) {
56  gfx::Rect src_rect = transform_window_.GetBoundsInScreen();
57  set_bounds(ScopedTransformOverviewWindow::
58      ShrinkRectToFitPreservingAspectRatio(src_rect, target_bounds));
59  transform_window_.SetTransform(root_window,
60      ScopedTransformOverviewWindow::GetTransformForRect(src_rect, bounds()),
61      animate);
62}
63
64}  // namespace ash
65