blob: 5512405f4d5278407fea98127dcab2556dabc1ec [file] [log] [blame]
// Copyright 2014 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 "base/macros.h"
#include "base/memory/scoped_ptr.h"
#include "base/memory/weak_ptr.h"
#include "ui/aura/window_tracker.h"
#include "ui/events/event_handler.h"
#include "ui/gfx/geometry/point.h"
namespace aura {
class Window;
namespace wm {
class Shadow;
namespace athena {
class TitleDragControllerDelegate {
virtual ~TitleDragControllerDelegate() {}
// Returns the window behind |window|. The returned window is the one that
// would be revealed while |window|'s title is dragged.
virtual aura::Window* GetWindowBehind(aura::Window* window) = 0;
// Notifies the delegate during various stages of the drag.
virtual void OnTitleDragStarted(aura::Window* window) = 0;
virtual void OnTitleDragCompleted(aura::Window* window) = 0;
virtual void OnTitleDragCanceled(aura::Window* window) = 0;
// Responsible for allowing dragging a window by its title bar.
class TitleDragController : public ui::EventHandler {
TitleDragController(aura::Window* container,
TitleDragControllerDelegate* delegate);
~TitleDragController() override;
void EndTransition(aura::Window* window, bool complete);
void OnTransitionEnd(aura::Window* window, bool complete);
// ui::EventHandler:
void OnGestureEvent(ui::GestureEvent* gesture) override;
aura::Window* container_;
TitleDragControllerDelegate* delegate_;
gfx::Point drag_start_location_;
scoped_ptr<wm::Shadow> shadow_;
aura::WindowTracker tracker_;
base::WeakPtrFactory<TitleDragController> weak_ptr_;
} // namespace athena