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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/ui/views/frame/immersive_mode_controller_ash.h
diff --git a/chrome/browser/ui/views/frame/immersive_mode_controller_ash.h b/chrome/browser/ui/views/frame/immersive_mode_controller_ash.h
index 083628f91cc41d7f45e2cbb90580c75e2af4eca2..df3ae9e2b633c217b448dfda80e7ee4bfaac20be 100644
--- a/chrome/browser/ui/views/frame/immersive_mode_controller_ash.h
+++ b/chrome/browser/ui/views/frame/immersive_mode_controller_ash.h
@@ -9,18 +9,35 @@
#include "base/timer.h"
#include "ui/base/events/event_handler.h"
-#include "ui/gfx/native_widget_types.h"
+#include "ui/compositor/layer_animation_observer.h"
#include "ui/views/focus/focus_manager.h"
#include "ui/views/widget/widget_observer.h"
class BrowserView;
+namespace {
+class AnchoredWidgetManager;
+}
+
+namespace aura {
+class Window;
+}
+
+namespace gfx {
+class Transform;
+}
+
+namespace ui {
+class Layer;
+}
+
namespace views {
class View;
}
class ImmersiveModeControllerAsh : public ImmersiveModeController,
public ui::EventHandler,
+ public ui::ImplicitAnimationObserver,
public views::FocusChangeListener,
public views::WidgetObserver {
public:
@@ -34,6 +51,19 @@ class ImmersiveModeControllerAsh : public ImmersiveModeController,
void LockRevealedState();
void UnlockRevealedState();
+ // Shows the reveal view without any animations if immersive mode is enabled.
+ void MaybeRevealWithoutAnimation();
+
+ // Returns true if the top-of-window views are animating. This differs from
+ // when |reveal_state_| is SLIDING_OPEN / SLIDING_CLOSED when the controller
+ // is in the process of starting an animation via MaybeStartReveal() /
+ // MaybeEndReveal(). is_animating() starts returning true when the animation
+ // actually starts instead of at the start of the call to MaybeStartReveal()
+ // / MaybeEndReveal().
James Cook 2013/04/09 22:22:03 nit: "// /" looks weird, maybe just say "or"
+ bool is_animating() const {
+ return is_animating_;
+ }
+
// ImmersiveModeController overrides:
virtual void Init(BrowserView* browser_view) OVERRIDE;
virtual void SetEnabled(bool enabled) OVERRIDE;
@@ -46,6 +76,10 @@ class ImmersiveModeControllerAsh : public ImmersiveModeController,
virtual void CancelReveal() OVERRIDE;
virtual ImmersiveModeController::RevealedLock*
GetRevealedLock() OVERRIDE WARN_UNUSED_RESULT;
+ virtual void AnchorWidgetToTopContainer(views::Widget* widget,
+ int y_offset) OVERRIDE;
+ virtual void UnanchorWidgetFromTopContainer(views::Widget* widget) OVERRIDE;
+ virtual void OnTopContainerBoundsChanged() OVERRIDE;
// ui::EventHandler overrides:
virtual void OnMouseEvent(ui::MouseEvent* event) OVERRIDE;
@@ -61,6 +95,9 @@ class ImmersiveModeControllerAsh : public ImmersiveModeController,
virtual void OnWidgetActivationChanged(views::Widget* widget,
bool active) OVERRIDE;
+ // ui::ImplicitAnimationObserver override:
+ virtual void OnImplicitAnimationsCompleted() OVERRIDE;
+
// Testing interface.
void SetHideTabIndicatorsForTest(bool hide);
void StartRevealForTest(bool hovered);
@@ -100,7 +137,7 @@ class ImmersiveModeControllerAsh : public ImmersiveModeController,
// Temporarily reveals the top-of-window views while in immersive mode,
// hiding them when the cursor exits the area of the top views. If |animate|
// is not ANIMATE_NO, slides in the view, otherwise shows it immediately.
- void StartReveal(Animate animate);
+ void MaybeStartReveal(Animate animate);
// Enables or disables layer-based painting to allow smooth animations.
void EnablePaintToLayer(bool enable);
@@ -109,21 +146,29 @@ class ImmersiveModeControllerAsh : public ImmersiveModeController,
// tab strip style |immersive_style|.
void LayoutBrowserView(bool immersive_style);
- // Slides open the reveal view at the top of the screen.
- void AnimateSlideOpen(int duration_ms);
+ // Called when the animation to slide open the top-of-window views has
+ // completed.
void OnSlideOpenAnimationCompleted();
// Hides the top-of-window views if immersive mode is enabled and nothing is
// keeping them revealed. Optionally animates.
void MaybeEndReveal(Animate animate);
- // Hides the top-of-window views. Optionally animates.
- void EndReveal(Animate animate);
-
- // Slide out the reveal view.
- void AnimateSlideClosed(int duration_ms);
+ // Called when the animation to slide out the top-of-window views has
+ // completed.
void OnSlideClosedAnimationCompleted();
+ // Starts an animation for the top-of-window views and any anchored widgets
+ // of |duration_ms| to |target_transform|.
+ void DoAnimation(const gfx::Transform& target_transform, int duration_ms);
+
+ // Starts an animation for |layer| of |duration_ms| to |target_transform|.
+ // If non-NULL, sets |observer| to be notified when the animation completes.
+ void DoAnimation(ui::Layer* layer,
James Cook 2013/04/09 22:22:03 Consider calling this DoLayerAnimation or some oth
+ const gfx::Transform& target_transform,
+ int duration_ms,
+ ui::ImplicitAnimationObserver* observer);
+
// Browser view holding the views to be shown and hidden. Not owned.
BrowserView* browser_view_;
@@ -133,6 +178,8 @@ class ImmersiveModeControllerAsh : public ImmersiveModeController,
// State machine for the revealed/closed animations.
RevealState reveal_state_;
+ bool is_animating_;
+
int revealed_lock_count_;
// True if the miniature "tab indicators" should be hidden in the main browser
@@ -151,20 +198,14 @@ class ImmersiveModeControllerAsh : public ImmersiveModeController,
scoped_ptr<RevealedLock> focus_revealed_lock_;
// Native window for the browser, needed to clean up observers.
- gfx::NativeWindow native_window_;
+ aura::Window* native_window_;
James Cook 2013/04/09 22:22:03 Thanks for cleaning these up.
-#if defined(USE_AURA)
// Observer to disable immersive mode when window leaves the maximized state.
class WindowObserver;
scoped_ptr<WindowObserver> window_observer_;
-#endif
-
- // Animation observers. They must be separate because animations can be
- // aborted and have their observers triggered at any time and the state
- // machine needs to know which animation completed.
- class AnimationObserver;
- scoped_ptr<AnimationObserver> slide_open_observer_;
- scoped_ptr<AnimationObserver> slide_closed_observer_;
+
+ // Manages widgets which are anchored to the top-of-window views.
+ scoped_ptr<AnchoredWidgetManager> anchored_widget_manager_;
base::WeakPtrFactory<ImmersiveModeControllerAsh> weak_ptr_factory_;

Powered by Google App Engine
This is Rietveld 408576698