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

Side by Side Diff: chrome/browser/ui/views/frame/immersive_mode_controller_ash.h

Issue 13866026: Adds functionality to anchor widgets to the top-of-window views in immersive mode (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Created 7 years, 8 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
1 // Copyright 2012 The Chromium Authors. All rights reserved. 1 // Copyright 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CHROME_BROWSER_UI_VIEWS_FRAME_IMMERSIVE_MODE_CONTROLLER_ASH_H_ 5 #ifndef CHROME_BROWSER_UI_VIEWS_FRAME_IMMERSIVE_MODE_CONTROLLER_ASH_H_
6 #define CHROME_BROWSER_UI_VIEWS_FRAME_IMMERSIVE_MODE_CONTROLLER_ASH_H_ 6 #define CHROME_BROWSER_UI_VIEWS_FRAME_IMMERSIVE_MODE_CONTROLLER_ASH_H_
7 7
8 #include "chrome/browser/ui/views/frame/immersive_mode_controller.h" 8 #include "chrome/browser/ui/views/frame/immersive_mode_controller.h"
9 9
10 #include "base/timer.h" 10 #include "base/timer.h"
11 #include "ui/base/events/event_handler.h" 11 #include "ui/base/events/event_handler.h"
12 #include "ui/gfx/native_widget_types.h" 12 #include "ui/compositor/layer_animation_observer.h"
13 #include "ui/views/focus/focus_manager.h" 13 #include "ui/views/focus/focus_manager.h"
14 #include "ui/views/widget/widget_observer.h" 14 #include "ui/views/widget/widget_observer.h"
15 15
16 class BrowserView; 16 class BrowserView;
17 17
18 namespace {
19 class AnchoredWidgetManager;
20 }
21
22 namespace aura {
23 class Window;
24 }
25
26 namespace gfx {
27 class Transform;
28 }
29
30 namespace ui {
31 class Layer;
32 }
33
18 namespace views { 34 namespace views {
19 class View; 35 class View;
20 } 36 }
21 37
22 class ImmersiveModeControllerAsh : public ImmersiveModeController, 38 class ImmersiveModeControllerAsh : public ImmersiveModeController,
23 public ui::EventHandler, 39 public ui::EventHandler,
40 public ui::ImplicitAnimationObserver,
24 public views::FocusChangeListener, 41 public views::FocusChangeListener,
25 public views::WidgetObserver { 42 public views::WidgetObserver {
26 public: 43 public:
27 ImmersiveModeControllerAsh(); 44 ImmersiveModeControllerAsh();
28 virtual ~ImmersiveModeControllerAsh(); 45 virtual ~ImmersiveModeControllerAsh();
29 46
30 // These methods are used to increment and decrement |revealed_lock_count_|. 47 // These methods are used to increment and decrement |revealed_lock_count_|.
31 // If immersive mode is enabled, a transition from 1 to 0 in 48 // If immersive mode is enabled, a transition from 1 to 0 in
32 // |revealed_lock_count_| closes the top-of-window views and a transition 49 // |revealed_lock_count_| closes the top-of-window views and a transition
33 // from 0 to 1 in |revealed_lock_count_| reveals the top-of-window views. 50 // from 0 to 1 in |revealed_lock_count_| reveals the top-of-window views.
34 void LockRevealedState(); 51 void LockRevealedState();
35 void UnlockRevealedState(); 52 void UnlockRevealedState();
36 53
54 // Shows the reveal view without any animations if immersive mode is enabled.
55 void MaybeRevealWithoutAnimation();
56
37 // ImmersiveModeController overrides: 57 // ImmersiveModeController overrides:
38 virtual void Init(BrowserView* browser_view) OVERRIDE; 58 virtual void Init(BrowserView* browser_view) OVERRIDE;
39 virtual void SetEnabled(bool enabled) OVERRIDE; 59 virtual void SetEnabled(bool enabled) OVERRIDE;
40 virtual bool IsEnabled() const OVERRIDE; 60 virtual bool IsEnabled() const OVERRIDE;
41 virtual bool ShouldHideTabIndicators() const OVERRIDE; 61 virtual bool ShouldHideTabIndicators() const OVERRIDE;
42 virtual bool ShouldHideTopViews() const OVERRIDE; 62 virtual bool ShouldHideTopViews() const OVERRIDE;
43 virtual bool IsRevealed() const OVERRIDE; 63 virtual bool IsRevealed() const OVERRIDE;
44 virtual void MaybeStackViewAtTop() OVERRIDE; 64 virtual void MaybeStackViewAtTop() OVERRIDE;
45 virtual ImmersiveModeController::RevealedLock* 65 virtual ImmersiveModeController::RevealedLock*
46 GetRevealedLock() OVERRIDE WARN_UNUSED_RESULT; 66 GetRevealedLock() OVERRIDE WARN_UNUSED_RESULT;
67 virtual void AnchorWidgetToTopContainer(views::Widget* widget,
68 int y_offset) OVERRIDE;
69 virtual void UnanchorWidgetFromTopContainer(views::Widget* widget) OVERRIDE;
70 virtual void OnTopContainerBoundsChanged() OVERRIDE;
47 71
48 // ui::EventHandler overrides: 72 // ui::EventHandler overrides:
49 virtual void OnMouseEvent(ui::MouseEvent* event) OVERRIDE; 73 virtual void OnMouseEvent(ui::MouseEvent* event) OVERRIDE;
50 74
51 // views::FocusChangeObserver overrides: 75 // views::FocusChangeObserver overrides:
52 virtual void OnWillChangeFocus(views::View* focused_before, 76 virtual void OnWillChangeFocus(views::View* focused_before,
53 views::View* focused_now) OVERRIDE; 77 views::View* focused_now) OVERRIDE;
54 virtual void OnDidChangeFocus(views::View* focused_before, 78 virtual void OnDidChangeFocus(views::View* focused_before,
55 views::View* focused_now) OVERRIDE; 79 views::View* focused_now) OVERRIDE;
56 80
57 // views::WidgetObserver overrides: 81 // views::WidgetObserver overrides:
58 virtual void OnWidgetDestroying(views::Widget* widget) OVERRIDE; 82 virtual void OnWidgetDestroying(views::Widget* widget) OVERRIDE;
59 virtual void OnWidgetActivationChanged(views::Widget* widget, 83 virtual void OnWidgetActivationChanged(views::Widget* widget,
60 bool active) OVERRIDE; 84 bool active) OVERRIDE;
61 85
86 // ui::ImplicitAnimationObserver override:
87 virtual void OnImplicitAnimationsCompleted() OVERRIDE;
88
62 // Testing interface. 89 // Testing interface.
63 void SetHideTabIndicatorsForTest(bool hide); 90 void SetHideTabIndicatorsForTest(bool hide);
64 void StartRevealForTest(bool hovered); 91 void StartRevealForTest(bool hovered);
65 void SetMouseHoveredForTest(bool hovered); 92 void SetMouseHoveredForTest(bool hovered);
66 93
67 private: 94 private:
68 enum Animate { 95 enum Animate {
69 ANIMATE_NO, 96 ANIMATE_NO,
70 ANIMATE_SLOW, 97 ANIMATE_SLOW,
71 ANIMATE_FAST, 98 ANIMATE_FAST,
(...skipping 16 matching lines...) Expand all
88 // Acquire the mouse revealed lock if it is not already held. 115 // Acquire the mouse revealed lock if it is not already held.
89 void AcquireMouseRevealedLock(); 116 void AcquireMouseRevealedLock();
90 117
91 // Update |focus_revealed_lock_| based on the currently active view and the 118 // Update |focus_revealed_lock_| based on the currently active view and the
92 // currently active widget. 119 // currently active widget.
93 void UpdateFocusRevealedLock(); 120 void UpdateFocusRevealedLock();
94 121
95 // Returns the animation duration given |animate|. 122 // Returns the animation duration given |animate|.
96 int GetAnimationDuration(Animate animate) const; 123 int GetAnimationDuration(Animate animate) const;
97 124
98 // Reveals the top-of-window views if immersive mode is enabled.
99 void MaybeStartReveal();
100
101 // Temporarily reveals the top-of-window views while in immersive mode, 125 // Temporarily reveals the top-of-window views while in immersive mode,
102 // hiding them when the cursor exits the area of the top views. If |animate| 126 // hiding them when the cursor exits the area of the top views. If |animate|
103 // is not ANIMATE_NO, slides in the view, otherwise shows it immediately. 127 // is not ANIMATE_NO, slides in the view, otherwise shows it immediately.
104 void StartReveal(Animate animate); 128 void MaybeStartReveal(Animate animate);
105 129
106 // Enables or disables layer-based painting to allow smooth animations. 130 // Enables or disables layer-based painting to allow smooth animations.
107 void EnablePaintToLayer(bool enable); 131 void EnablePaintToLayer(bool enable);
108 132
109 // Updates layout for |browser_view_| including window caption controls and 133 // Updates layout for |browser_view_| including window caption controls and
110 // tab strip style |immersive_style|. 134 // tab strip style |immersive_style|.
111 void LayoutBrowserView(bool immersive_style); 135 void LayoutBrowserView(bool immersive_style);
112 136
113 // Slides open the reveal view at the top of the screen. 137 // Called when the animation to slide open the top-of-window views has
114 void AnimateSlideOpen(int duration_ms); 138 // completed.
115 void OnSlideOpenAnimationCompleted(); 139 void OnSlideOpenAnimationCompleted();
116 140
117 // Hides the top-of-window views if immersive mode is enabled and nothing is 141 // Hides the top-of-window views if immersive mode is enabled and nothing is
118 // keeping them revealed. Optionally animates. 142 // keeping them revealed. Optionally animates.
119 void MaybeEndReveal(Animate animate); 143 void MaybeEndReveal(Animate animate);
120 144
121 // Hides the top-of-window views. Optionally animates. 145 // Called when the animation to slide out the top-of-window views has
122 void EndReveal(Animate animate); 146 // completed.
147 void OnSlideClosedAnimationCompleted();
123 148
124 // Slide out the reveal view. 149 // Starts an animation for the top-of-window views and any anchored widgets
125 void AnimateSlideClosed(int duration_ms); 150 // of |duration_ms| to |target_transform|.
126 void OnSlideClosedAnimationCompleted(); 151 void DoAnimation(const gfx::Transform& target_transform, int duration_ms);
152
153 // Starts an animation for |layer| of |duration_ms| to |target_transform|.
154 // If non-NULL, sets |observer| to be notified when the animation completes.
155 void DoLayerAnimation(ui::Layer* layer,
156 const gfx::Transform& target_transform,
157 int duration_ms,
158 ui::ImplicitAnimationObserver* observer);
127 159
128 // Browser view holding the views to be shown and hidden. Not owned. 160 // Browser view holding the views to be shown and hidden. Not owned.
129 BrowserView* browser_view_; 161 BrowserView* browser_view_;
130 162
131 // True when in immersive mode. 163 // True when in immersive mode.
132 bool enabled_; 164 bool enabled_;
133 165
134 // State machine for the revealed/closed animations. 166 // State machine for the revealed/closed animations.
135 RevealState reveal_state_; 167 RevealState reveal_state_;
136 168
137 int revealed_lock_count_; 169 int revealed_lock_count_;
138 170
139 // True if the miniature "tab indicators" should be hidden in the main browser 171 // True if the miniature "tab indicators" should be hidden in the main browser
140 // view when immersive mode is enabled. 172 // view when immersive mode is enabled.
141 bool hide_tab_indicators_; 173 bool hide_tab_indicators_;
142 174
143 // Timer to track cursor being held at the top. 175 // Timer to track cursor being held at the top.
144 base::OneShotTimer<ImmersiveModeController> top_timer_; 176 base::OneShotTimer<ImmersiveModeController> top_timer_;
145 177
146 // Lock which keeps the top-of-window views revealed based on the current 178 // Lock which keeps the top-of-window views revealed based on the current
147 // mouse state. 179 // mouse state.
148 scoped_ptr<RevealedLock> mouse_revealed_lock_; 180 scoped_ptr<RevealedLock> mouse_revealed_lock_;
149 181
150 // Lock which keeps the top-of-window views revealed based on the focused view 182 // Lock which keeps the top-of-window views revealed based on the focused view
151 // and the active widget. 183 // and the active widget.
152 scoped_ptr<RevealedLock> focus_revealed_lock_; 184 scoped_ptr<RevealedLock> focus_revealed_lock_;
153 185
154 // Native window for the browser, needed to clean up observers. 186 // Native window for the browser, needed to clean up observers.
155 gfx::NativeWindow native_window_; 187 aura::Window* native_window_;
156 188
157 #if defined(USE_AURA)
158 // Observer to disable immersive mode when window leaves the maximized state. 189 // Observer to disable immersive mode when window leaves the maximized state.
159 class WindowObserver; 190 class WindowObserver;
160 scoped_ptr<WindowObserver> window_observer_; 191 scoped_ptr<WindowObserver> window_observer_;
161 #endif
162 192
163 // Animation observers. They must be separate because animations can be 193 // Manages widgets which are anchored to the top-of-window views.
164 // aborted and have their observers triggered at any time and the state 194 scoped_ptr<AnchoredWidgetManager> anchored_widget_manager_;
165 // machine needs to know which animation completed.
166 class AnimationObserver;
167 scoped_ptr<AnimationObserver> slide_open_observer_;
168 scoped_ptr<AnimationObserver> slide_closed_observer_;
169 195
170 base::WeakPtrFactory<ImmersiveModeControllerAsh> weak_ptr_factory_; 196 base::WeakPtrFactory<ImmersiveModeControllerAsh> weak_ptr_factory_;
171 197
172 DISALLOW_COPY_AND_ASSIGN(ImmersiveModeControllerAsh); 198 DISALLOW_COPY_AND_ASSIGN(ImmersiveModeControllerAsh);
173 }; 199 };
174 200
175 #endif // CHROME_BROWSER_UI_VIEWS_FRAME_IMMERSIVE_MODE_CONTROLLER_ASH_H_ 201 #endif // CHROME_BROWSER_UI_VIEWS_FRAME_IMMERSIVE_MODE_CONTROLLER_ASH_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698