16e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)// Copyright 2014 The Chromium Authors. All rights reserved.
26e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)// Use of this source code is governed by a BSD-style license that can be
36e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)// found in the LICENSE file.
46e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)
56e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)#ifndef ATHENA_WM_TITLE_DRAG_CONTROLLER_H_
66e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)#define ATHENA_WM_TITLE_DRAG_CONTROLLER_H_
76e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)
86e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)#include "base/macros.h"
96e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)#include "base/memory/scoped_ptr.h"
106e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)#include "base/memory/weak_ptr.h"
116e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)#include "ui/aura/window_tracker.h"
126e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)#include "ui/events/event_handler.h"
136e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)#include "ui/gfx/geometry/point.h"
146e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)
156e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)namespace aura {
166e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)class Window;
176e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)}
186e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)
196e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)namespace wm {
206e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)class Shadow;
216e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)}
226e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)
236e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)namespace athena {
246e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)
256e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)class TitleDragControllerDelegate {
266e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) public:
276e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)  virtual ~TitleDragControllerDelegate() {}
286e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)
296e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)  // Returns the window behind |window|. The returned window is the one that
306e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)  // would be revealed while |window|'s title is dragged.
316e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)  virtual aura::Window* GetWindowBehind(aura::Window* window) = 0;
326e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)
336e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)  // Notifies the delegate during various stages of the drag.
346e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)  virtual void OnTitleDragStarted(aura::Window* window) = 0;
356e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)  virtual void OnTitleDragCompleted(aura::Window* window) = 0;
366e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)  virtual void OnTitleDragCanceled(aura::Window* window) = 0;
376e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)};
386e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)
396e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)// Responsible for allowing dragging a window by its title bar.
406e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)class TitleDragController : public ui::EventHandler {
416e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) public:
426e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)  TitleDragController(aura::Window* container,
436e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)                      TitleDragControllerDelegate* delegate);
446e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)  virtual ~TitleDragController();
456e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)
466e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) private:
476e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)  void EndTransition(aura::Window* window, bool complete);
486e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)  void OnTransitionEnd(aura::Window* window, bool complete);
496e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)
506e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)  // ui::EventHandler:
516e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)  virtual void OnGestureEvent(ui::GestureEvent* gesture) OVERRIDE;
526e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)
536e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)  aura::Window* container_;
546e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)  TitleDragControllerDelegate* delegate_;
556e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)  gfx::Point drag_start_location_;
566e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)  scoped_ptr<wm::Shadow> shadow_;
576e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)  aura::WindowTracker tracker_;
586e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)
596e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)  base::WeakPtrFactory<TitleDragController> weak_ptr_;
606e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)
616e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)  DISALLOW_COPY_AND_ASSIGN(TitleDragController);
626e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)};
636e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)
646e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)}  // namespace athena
656e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)
666e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)#endif  // ATHENA_WM_TITLE_DRAG_CONTROLLER_H_
67