| Index: content/browser/web_contents/aura/overscroll_window_animation.h
|
| diff --git a/content/browser/web_contents/aura/overscroll_window_animation.h b/content/browser/web_contents/aura/overscroll_window_animation.h
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..a396f79e148e47408a30bd15b844844a90edf7ad
|
| --- /dev/null
|
| +++ b/content/browser/web_contents/aura/overscroll_window_animation.h
|
| @@ -0,0 +1,111 @@
|
| +// Copyright 2015 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.
|
| +
|
| +#ifndef CONTENT_BROWSER_WEB_CONTENTS_AURA_OVERSCROLL_WINDOW_ANIMATION_H_
|
| +#define CONTENT_BROWSER_WEB_CONTENTS_AURA_OVERSCROLL_WINDOW_ANIMATION_H_
|
| +
|
| +#include "content/browser/renderer_host/overscroll_controller_delegate.h"
|
| +#include "content/common/content_export.h"
|
| +#include "ui/compositor/layer_animation_observer.h"
|
| +
|
| +namespace aura {
|
| +class Window;
|
| +}
|
| +
|
| +namespace ui {
|
| +class Layer;
|
| +class LayerAnimator;
|
| +}
|
| +
|
| +namespace content {
|
| +
|
| +class ShadowLayerDelegate;
|
| +class WebContentsImpl;
|
| +
|
| +// Manages the animations during an overscroll navigation by handling overscroll
|
| +// events.
|
| +class CONTENT_EXPORT OverscrollWindowAnimation
|
| + : public OverscrollControllerDelegate,
|
| + ui::ImplicitAnimationObserver {
|
| + public:
|
| + enum Direction { SLIDE_FRONT, SLIDE_BACK, SLIDE_NONE };
|
| +
|
| + // Delegate class that interfaces with the window animation, responsible for
|
| + // navigation.
|
| + class Delegate {
|
| + public:
|
| + virtual ~Delegate() {}
|
| +
|
| + // The following two functions create a slide window and transfer back its
|
| + // ownership.
|
| + virtual scoped_ptr<aura::Window> CreateFrontWindow() = 0;
|
| + virtual scoped_ptr<aura::Window> CreateBackWindow() = 0;
|
| +
|
| + // Returns the live window that participates in the overscroll gesture.
|
| + virtual aura::Window* GetTargetWindow() const = 0;
|
| +
|
| + // Called when we know the animation is going to complete successfully.
|
| + virtual void OnOverscrollCompleting() = 0;
|
| +
|
| + // Called when the animation has been completed.
|
| + virtual void OnOverscrollCompleted(
|
| + scoped_ptr<aura::Window> window) = 0;
|
| +
|
| + // Called when the overscroll gesture has been aborted.
|
| + virtual void OnOverscrollAborted() = 0;
|
| + };
|
| +
|
| + explicit OverscrollWindowAnimation(Delegate* delegate);
|
| +
|
| + ~OverscrollWindowAnimation() override;
|
| +
|
| + // Returns true if we are currently handling a slide animation.
|
| + bool is_active() const { return !!window_; }
|
| +
|
| + // Overridden from OverscrollControllerDelegate:
|
| + gfx::Rect GetVisibleBounds() const override;
|
| +
|
| + bool OnOverscrollUpdate(float delta_x, float delta_y) override;
|
| +
|
| + void OnOverscrollComplete(OverscrollMode overscroll_mode) override;
|
| +
|
| + void OnOverscrollModeChange(OverscrollMode old_mode,
|
| + OverscrollMode new_mode) override;
|
| +
|
| + private:
|
| + // Starts the overscroll cancelled animation.
|
| + void CancelOverscroll();
|
| +
|
| + // Moves the animated window according to the given scroll deltas. Returns
|
| + // true if the update moved the window.
|
| + bool UpdateForScroll(float delta_x);
|
| +
|
| + // Returns a translation on the x axis for the given overscroll.
|
| + float GetTranslationForOverscroll(float delta_x);
|
| +
|
| + // Returns the layer that is animated for the overscroll gesture.
|
| + ui::Layer* GetFrontLayer() const;
|
| +
|
| + // ui::ImplicitAnimationObserver:
|
| + void OnImplicitAnimationsCompleted() override;
|
| +
|
| + // Owns the new window created on the overscroll gesture.
|
| + scoped_ptr<aura::Window> window_;
|
| +
|
| + // Shadow shown under the animated layer.
|
| + scoped_ptr<ShadowLayerDelegate> shadow_;
|
| +
|
| + // Delegate that provides the animation target and handles navigation.
|
| + Delegate* delegate_;
|
| +
|
| + // The current overscroll direction.
|
| + Direction direction_;
|
| +
|
| + // Indicates if the current overscroll gesture has been cancelled.
|
| + bool overscroll_cancelled_;
|
| +};
|
| +
|
| +} // namespace content
|
| +
|
| +#endif // CONTENT_BROWSER_WEB_CONTENTS_AURA_OVERSCROLL_WINDOW_ANIMATION_H_
|
|
|