Updating trunk VERSION from 2139.0 to 2140.0
[chromium-blink-merge.git] / ash / wm / overview / window_selector_window.cc
blobca2ecabb9ec8320da8bef895c7697161468f041c
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.
5 #include "ash/wm/overview/window_selector_window.h"
7 #include "ash/screen_util.h"
8 #include "ash/shell.h"
9 #include "ash/shell_window_ids.h"
10 #include "ash/wm/overview/scoped_transform_overview_window.h"
11 #include "ui/aura/window.h"
12 #include "ui/compositor/scoped_layer_animation_settings.h"
13 #include "ui/gfx/rect.h"
14 #include "ui/gfx/transform.h"
15 #include "ui/views/controls/button/image_button.h"
16 #include "ui/views/widget/widget.h"
18 namespace ash {
20 WindowSelectorWindow::WindowSelectorWindow(aura::Window* window)
21 : transform_window_(window) {
22 window->AddObserver(this);
25 WindowSelectorWindow::~WindowSelectorWindow() {
26 if (transform_window_.window())
27 transform_window_.window()->RemoveObserver(this);
30 aura::Window* WindowSelectorWindow::GetRootWindow() {
31 return transform_window_.window()->GetRootWindow();
34 bool WindowSelectorWindow::HasSelectableWindow(const aura::Window* window) {
35 return transform_window_.window() == window;
38 bool WindowSelectorWindow::Contains(const aura::Window* target) {
39 return transform_window_.Contains(target);
42 void WindowSelectorWindow::RestoreWindowOnExit(aura::Window* window) {
43 transform_window_.RestoreWindowOnExit();
46 aura::Window* WindowSelectorWindow::SelectionWindow() {
47 return transform_window_.window();
50 void WindowSelectorWindow::RemoveWindow(const aura::Window* window) {
51 DCHECK_EQ(transform_window_.window(), window);
52 transform_window_.window()->RemoveObserver(this);
53 transform_window_.OnWindowDestroyed();
54 WindowSelectorItem::RemoveWindow(window);
57 bool WindowSelectorWindow::empty() const {
58 return transform_window_.window() == NULL;
61 void WindowSelectorWindow::PrepareForOverview() {
62 transform_window_.PrepareForOverview();
65 void WindowSelectorWindow::SetItemBounds(aura::Window* root_window,
66 const gfx::Rect& target_bounds,
67 bool animate) {
68 gfx::Rect src_rect = transform_window_.GetBoundsInScreen();
69 set_bounds(ScopedTransformOverviewWindow::
70 ShrinkRectToFitPreservingAspectRatio(src_rect, target_bounds));
71 transform_window_.SetTransform(root_window,
72 ScopedTransformOverviewWindow::GetTransformForRect(src_rect, bounds()),
73 animate);
76 void WindowSelectorWindow::SetOpacity(float opacity) {
77 transform_window_.window()->layer()->SetOpacity(opacity);
78 WindowSelectorItem::SetOpacity(opacity);
81 } // namespace ash