Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(7)

Side by Side Diff: ash/wm/session_state_animator.h

Issue 10914016: ash: Extract animator from PowerButtonController (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Naming fixes Created 8 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
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.
4
5 #ifndef ASH_WM_SESSION_STATE_ANIMATOR_H_
6 #define ASH_WM_SESSION_STATE_ANIMATOR_H_
7
8 #include "ash/ash_export.h"
9 #include "ash/shell_observer.h"
10 #include "base/basictypes.h"
11 #include "base/memory/scoped_ptr.h"
12 #include "base/time.h"
13 #include "base/timer.h"
14 #include "ui/aura/root_window_observer.h"
15 #include "ui/aura/window.h"
16
17 namespace gfx {
18 class Rect;
19 class Size;
20 }
21
22 namespace ui {
23 class Layer;
24 }
25
26 namespace ash {
27
28 // Displays onscreen animations for session state changes (lock/unlock,sign out,
Daniel Erat 2012/08/31 17:02:12 nit: add space after "lock/unlock,"
Denis Kuznetsov (DE-MUC) 2012/09/28 11:52:43 Done.
29 // shut down).
30 class ASH_EXPORT SessionStateAnimator : public aura::RootWindowObserver {
31 public:
32 // Groups of containers that can be animated.
33 // Exposed here for TestApi::ContainerGroupIsAnimated().
Daniel Erat 2012/08/31 17:02:12 nit: remove this "Exposed here for" comment; it's
Denis Kuznetsov (DE-MUC) 2012/09/28 11:52:43 Done.
34 enum ContainerGroup {
35 ALL_CONTAINERS = 0,
36 SCREEN_LOCKER_CONTAINERS,
37 SCREEN_LOCKER_AND_RELATED_CONTAINERS,
38 ALL_BUT_SCREEN_LOCKER_AND_RELATED_CONTAINERS,
39 };
40
41 // Animations that can be applied to groups of containers.
42 // Exposed here for TestApi::ContainerGroupIsAnimated().
Daniel Erat 2012/08/31 17:02:12 ditto
Denis Kuznetsov (DE-MUC) 2012/09/28 11:52:43 Done.
43 enum AnimationType {
44 SLOW_CLOSE = 0,
45 UNDO_SLOW_CLOSE,
46 FAST_CLOSE,
47 FADE_IN,
48 HIDE,
49 RESTORE,
50 };
51
52 // Helper class used by tests to access internal state.
53 class ASH_EXPORT TestApi {
54 public:
55 explicit TestApi(SessionStateAnimator* animator)
56 : animator_(animator) {}
57
58 bool hide_background_layer_timer_is_running() const {
59 return animator_->hide_background_layer_timer_.IsRunning();
60 }
61
62 void trigger_hide_background_layer_timeout() {
tfarina 2012/09/01 11:02:30 This looks like more complex than a simple getter
Denis Kuznetsov (DE-MUC) 2012/09/28 11:52:43 Done, but there is a bunch of similar methods in
63 animator_->HideBackgroundLayer();
64 animator_->hide_background_layer_timer_.Stop();
65 }
66
67
68 bool ContainerGroupIsAnimated(ContainerGroup group,
69 AnimationType type) const;
70
71 // Returns true if |background_layer_| is non-NULL and visible.
72 bool BackgroundLayerIsVisible() const;
73
74 // Returns |background_layer_|'s bounds, or an empty rect if the layer is
75 // NULL.
76 gfx::Rect GetBackgroundLayerBounds() const;
77
78 private:
79 SessionStateAnimator* animator_; // not owned
80
81 DISALLOW_COPY_AND_ASSIGN(TestApi);
82 };
83
84 SessionStateAnimator();
85 virtual ~SessionStateAnimator();
86
87 // aura::RootWindowObserver overrides:
Daniel Erat 2012/08/31 17:02:12 nit: overridden methods should come after all othe
Denis Kuznetsov (DE-MUC) 2012/09/28 11:52:43 Done.
88 virtual void OnRootWindowResized(const aura::RootWindow* root,
89 const gfx::Size& old_size) OVERRIDE;
90 // Shows or hides |background_layer_|. The show method creates and
91 // initializes the layer if it doesn't already exist.
92 void ShowBackgroundLayer();
93 void HideBackgroundLayer();
94 void DropBackgroundLayer();
95
96 // Apply animation |type| to all containers described by |group|.
97 void StartAnimation(ContainerGroup group,
98 AnimationType type);
Daniel Erat 2012/08/31 17:02:12 nit: add a blank line between a method's signature
Denis Kuznetsov (DE-MUC) 2012/09/28 11:52:43 Done.
99 // Fills |containers| with the containers described by |group|.
100 void GetContainers(ContainerGroup group,
101 aura::Window::Windows* containers);
102 private:
103
Daniel Erat 2012/08/31 17:02:12 nit: remove all of these blank lines
Denis Kuznetsov (DE-MUC) 2012/09/28 11:52:43 Done.
104
105 // Layer that's stacked under all of the root window's children to provide a
106 // black background when we're scaling all of the other windows down.
107 // TODO(derat): Remove this in favor of having the compositor only clear the
108 // viewport when there are regions not covered by a layer:
109 // http://crbug.com/113445
110 scoped_ptr<ui::Layer> background_layer_;
111
112 // Started when we abort the pre-lock state. When it fires, we hide
113 // |background_layer_|, as the desktop background is now covering the whole
114 // screen.
115 base::OneShotTimer<SessionStateAnimator> hide_background_layer_timer_;
116
117 DISALLOW_COPY_AND_ASSIGN(SessionStateAnimator);
118 };
119
120 } // namespace ash
121
122 #endif // ASH_WM_SESSION_STATE_ANIMATOR_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698