blob: 373cb0c901ebfe62c92452eab58965cebcc99a0d [file] [log] [blame]
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include <memory>
#include <vector>
#include "ash/ash_export.h"
#include "base/gtest_prod_util.h"
#include "base/macros.h"
#include "ui/gfx/geometry/rect.h"
namespace aura {
class Window;
namespace ui {
class LayerTreeOwner;
namespace ash {
// DragWindowController is responsible for showing a semi-transparent window
// while dragging a window across displays.
class ASH_EXPORT DragWindowController {
// Computes the opacity for drag window based on how much of the area
// of the window is visible.
static float GetDragWindowOpacity(const gfx::Rect& window_bounds,
const gfx::Rect& visible_bounds);
explicit DragWindowController(aura::Window* window);
virtual ~DragWindowController();
// This is used to update the bounds and opacity for the drag window
// immediately.
// This also creates/destorys the drag window when necessary.
void Update(const gfx::Rect& bounds_in_screen,
const gfx::Point& drag_location_in_screen);
class DragWindowDetails;
FRIEND_TEST_ALL_PREFIXES(DragWindowResizerTest, DragWindowController);
// Returns the currently active drag windows.
int GetDragWindowsCountForTest() const;
// Returns the drag window/layer owner for given index of the
// currently active drag windows list.
const aura::Window* GetDragWindowForTest(size_t index) const;
const ui::LayerTreeOwner* GetDragLayerOwnerForTest(size_t index) const;
// Call Layer::OnPaintLayer on all layers under the drag_windows_.
void RequestLayerPaintForTest();
// Window the drag window is placed beneath.
aura::Window* window_;
std::vector<std::unique_ptr<DragWindowDetails>> drag_windows_;
} // namespace ash