Only fsync leveldb's directory when the manifest is being updated.
[chromium-blink-merge.git] / ash / wm / workspace / phantom_window_controller.h
blobd7622fcc556104e4cae233effd3d40050ca57834
1 // Copyright (c) 2012 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 #ifndef ASH_WM_WORKSPACE_PHANTOM_WINDOW_CONTROLLER_H_
6 #define ASH_WM_WORKSPACE_PHANTOM_WINDOW_CONTROLLER_H_
8 #include "ash/ash_export.h"
9 #include "base/basictypes.h"
10 #include "base/gtest_prod_util.h"
11 #include "base/memory/scoped_ptr.h"
12 #include "ui/base/animation/animation_delegate.h"
13 #include "ui/gfx/rect.h"
15 namespace aura {
16 class Window;
19 namespace ui {
20 class SlideAnimation;
23 namespace views {
24 class Widget;
27 namespace ash {
28 namespace internal {
30 // PhantomWindowController is responsible for showing a phantom representation
31 // of a window. It's used used during dragging a window to show a snap location.
32 class ASH_EXPORT PhantomWindowController : public ui::AnimationDelegate {
33 public:
34 explicit PhantomWindowController(aura::Window* window);
35 virtual ~PhantomWindowController();
37 // Bounds last passed to Show().
38 const gfx::Rect& bounds() const { return bounds_; }
40 // Shows the phantom window at the specified location (coordinates of the
41 // parent). If |layer| is non-NULL, it is shown on top of the phantom window.
42 // |layer| is owned by the caller.
43 // This does not immediately show the window.
44 void Show(const gfx::Rect& bounds);
46 // Hides the phantom.
47 void Hide();
49 // Returns true if the phantom is showing.
50 bool IsShowing() const;
52 // If set, the phantom window is stacked below this window, otherwise it
53 // is stacked above the window passed to the constructor.
54 void set_phantom_below_window(aura::Window* phantom_below_window) {
55 phantom_below_window_ = phantom_below_window;
58 // ui::AnimationDelegate overrides:
59 virtual void AnimationProgressed(const ui::Animation* animation) OVERRIDE;
61 private:
62 FRIEND_TEST_ALL_PREFIXES(WorkspaceWindowResizerTest, PhantomStyle);
64 // Creates and shows the |phantom_widget_| at |bounds|.
65 // |layer| is shown on top of the phantom window if it is non-NULL.
66 // |layer| is not owned by this object.
67 void CreatePhantomWidget(const gfx::Rect& bounds);
69 // Window the phantom is placed beneath.
70 aura::Window* window_;
72 // If set, the phantom window should get stacked below this window.
73 aura::Window* phantom_below_window_;
75 // Initially the bounds of |window_|. Each time Show() is invoked
76 // |start_bounds_| is then reset to the bounds of |phantom_widget_| and
77 // |bounds_| is set to the value passed into Show(). The animation animates
78 // between these two values.
79 gfx::Rect start_bounds_;
80 gfx::Rect bounds_;
82 views::Widget* phantom_widget_;
84 // Used to transition the bounds.
85 scoped_ptr<ui::SlideAnimation> animation_;
87 DISALLOW_COPY_AND_ASSIGN(PhantomWindowController);
90 } // namespace internal
91 } // namespace ash
93 #endif // ASH_WM_WORKSPACE_PHANTOM_WINDOW_CONTROLLER_H_