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

Side by Side Diff: chrome/browser/ui/views/immersive_mode_controller.h

Issue 11411250: Immersive mode reveals the tabstrip/omnibox on top of web content (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: update comment Created 8 years 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 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 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_IMMERSIVE_MODE_CONTROLLER_H_ 5 #ifndef CHROME_BROWSER_UI_VIEWS_IMMERSIVE_MODE_CONTROLLER_H_
6 #define CHROME_BROWSER_UI_VIEWS_IMMERSIVE_MODE_CONTROLLER_H_ 6 #define CHROME_BROWSER_UI_VIEWS_IMMERSIVE_MODE_CONTROLLER_H_
7 7
8 #include "base/basictypes.h" 8 #include "base/basictypes.h"
9 #include "base/compiler_specific.h" 9 #include "base/compiler_specific.h"
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/compositor/layer_animation_observer.h"
12 #include "ui/views/mouse_watcher.h" 13 #include "ui/views/mouse_watcher.h"
13 14
14 class BrowserView; 15 class BrowserView;
16 class RevealView;
15 17
16 namespace views { 18 namespace views {
17 class MouseWatcher; 19 class MouseWatcher;
18 } 20 }
19 21
20 // Controller for an "immersive mode" similar to MacOS presentation mode where 22 // Controller for an "immersive mode" similar to MacOS presentation mode where
21 // the top-of-window views are hidden until the mouse hits the top of the screen 23 // the top-of-window views are hidden until the mouse hits the top of the screen
22 // and the tab strip is painted in a rectangular "light-bar" style. 24 // and the tab strip is painted in a rectangular "light-bar" style.
23 class ImmersiveModeController : public ui::EventHandler, 25 class ImmersiveModeController : public ui::EventHandler,
26 public ui::ImplicitAnimationObserver,
24 public views::MouseWatcherListener { 27 public views::MouseWatcherListener {
25 public: 28 public:
26 explicit ImmersiveModeController(BrowserView* browser_view); 29 explicit ImmersiveModeController(BrowserView* browser_view);
27 virtual ~ImmersiveModeController(); 30 virtual ~ImmersiveModeController();
28 31
29 // Enables or disables immersive mode. 32 // Enables or disables immersive mode.
30 void SetEnabled(bool enabled); 33 void SetEnabled(bool enabled);
31 bool enabled() const { return enabled_; } 34 bool enabled() const { return enabled_; }
32 35
33 // True when we are hiding the top views due to immersive mode. 36 // True when we are hiding the top views due to immersive mode.
34 bool ShouldHideTopViews() const { return enabled_ && hide_top_views_; } 37 bool ShouldHideTopViews() const { return enabled_ && !revealed_; }
35 38
36 // Temporarily reveals the top-of-window views while in immersive mode, 39 bool IsRevealed() const { return enabled_ && revealed_; }
37 // hiding them when the cursor exits the area of the top views.
38 // Visible for testing.
39 void RevealTopViews();
40 40
41 // ui::EventHandler overrides: 41 // ui::EventHandler overrides:
42 virtual ui::EventResult OnKeyEvent(ui::KeyEvent* event) OVERRIDE; 42 virtual ui::EventResult OnKeyEvent(ui::KeyEvent* event) OVERRIDE;
43 virtual ui::EventResult OnMouseEvent(ui::MouseEvent* event) OVERRIDE; 43 virtual ui::EventResult OnMouseEvent(ui::MouseEvent* event) OVERRIDE;
44 virtual ui::EventResult OnScrollEvent(ui::ScrollEvent* event) OVERRIDE; 44 virtual ui::EventResult OnScrollEvent(ui::ScrollEvent* event) OVERRIDE;
45 virtual ui::EventResult OnTouchEvent(ui::TouchEvent* event) OVERRIDE; 45 virtual ui::EventResult OnTouchEvent(ui::TouchEvent* event) OVERRIDE;
46 virtual ui::EventResult OnGestureEvent(ui::GestureEvent* event) OVERRIDE; 46 virtual ui::EventResult OnGestureEvent(ui::GestureEvent* event) OVERRIDE;
47 47
48 // ui::ImplicitAnimationObserver overrides:
49 virtual void OnImplicitAnimationsCompleted() OVERRIDE;
50
48 // views::MouseWatcherListener overrides: 51 // views::MouseWatcherListener overrides:
49 virtual void MouseMovedOutOfHost() OVERRIDE; 52 virtual void MouseMovedOutOfHost() OVERRIDE;
50 53
54 // Testing interface.
55 void StartRevealForTest();
56 void EndRevealForTest();
57
51 private: 58 private:
59 // Temporarily reveals the top-of-window views while in immersive mode,
60 // hiding them when the cursor exits the area of the top views.
61 void StartReveal();
62
63 // Slide in the reveal view.
64 void AnimateShowRevealView();
65
66 // Starts watching the mouse for when it leaves the RevealView.
67 void StartMouseWatcher();
68
69 // Hides the top-of-window views.
70 void EndReveal(bool animate);
71
72 // Slide out the reveal view. Deletes the view when complete.
73 void AnimateHideRevealView();
74
75 // Cleans up the reveal view when the slide-out completes.
76 void ResetRevealView();
77
52 // Browser view holding the views to be shown and hidden. Not owned. 78 // Browser view holding the views to be shown and hidden. Not owned.
53 BrowserView* browser_view_; 79 BrowserView* browser_view_;
54 80
55 // True when in immersive mode. 81 // True when in immersive mode.
56 bool enabled_; 82 bool enabled_;
57 83
58 // True when the top-of-window views are being hidden by immersive mode. 84 // True when the top-of-window views are being shown in a temporary reveal.
59 bool hide_top_views_; 85 bool revealed_;
86
87 // View holding the tabstrip and toolbar during a reveal.
88 scoped_ptr<RevealView> reveal_view_;
60 89
61 // Timer to track cursor being held at the top. 90 // Timer to track cursor being held at the top.
62 base::OneShotTimer<ImmersiveModeController> top_timer_; 91 base::OneShotTimer<ImmersiveModeController> top_timer_;
63 92
64 // Mouse watcher to detect when the cursor leaves the top-of-window views 93 // Mouse watcher to detect when the cursor leaves the top-of-window views
65 // in immersive mode, indicating that we should hide the views. 94 // in immersive mode, indicating that we should hide the views.
66 scoped_ptr<views::MouseWatcher> mouse_watcher_; 95 scoped_ptr<views::MouseWatcher> mouse_watcher_;
67 96
68 DISALLOW_COPY_AND_ASSIGN(ImmersiveModeController); 97 DISALLOW_COPY_AND_ASSIGN(ImmersiveModeController);
69 }; 98 };
70 99
71 #endif // CHROME_BROWSER_UI_VIEWS_IMMERSIVE_MODE_CONTROLLER_H_ 100 #endif // CHROME_BROWSER_UI_VIEWS_IMMERSIVE_MODE_CONTROLLER_H_
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/frame/browser_view_layout.cc ('k') | chrome/browser/ui/views/immersive_mode_controller.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698