OLD | NEW |
---|---|
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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_FULLSCREEN_EXIT_BUBBLE_H_ | 5 #ifndef CHROME_BROWSER_UI_FULLSCREEN_EXIT_BUBBLE_H_ |
6 #define CHROME_BROWSER_UI_FULLSCREEN_EXIT_BUBBLE_H_ | 6 #define CHROME_BROWSER_UI_FULLSCREEN_EXIT_BUBBLE_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
10 #include "base/timer.h" | 10 #include "base/timer.h" |
11 #include "chrome/browser/command_updater.h" | 11 #include "chrome/browser/command_updater.h" |
12 #include "googleurl/src/gurl.h" | |
12 #include "ui/base/animation/animation_delegate.h" | 13 #include "ui/base/animation/animation_delegate.h" |
13 #include "ui/gfx/point.h" | 14 #include "ui/gfx/point.h" |
14 | 15 |
16 class Browser; | |
17 | |
15 namespace ui { | 18 namespace ui { |
16 class SlideAnimation; | 19 class SlideAnimation; |
17 } | 20 } |
18 | 21 |
19 namespace gfx { | 22 namespace gfx { |
20 class Rect; | 23 class Rect; |
21 } | 24 } |
22 | 25 |
23 class FullscreenExitBubble : public ui::AnimationDelegate { | 26 class FullscreenExitBubble : public ui::AnimationDelegate { |
24 public: | 27 public: |
25 explicit FullscreenExitBubble( | 28 explicit FullscreenExitBubble(Browser* browser); |
26 CommandUpdater::CommandUpdaterDelegate* delegate); | |
27 virtual ~FullscreenExitBubble(); | 29 virtual ~FullscreenExitBubble(); |
28 | 30 |
29 protected: | 31 protected: |
30 static const double kOpacity; // Opacity of the bubble, 0.0 - 1.0 | 32 static const double kOpacity; // Opacity of the bubble, 0.0 - 1.0 |
31 static const int kPaddingPx; // Amount of padding around the link | 33 static const int kPaddingPx; // Amount of padding around the link |
32 static const int kInitialDelayMs; // Initial time bubble remains onscreen | 34 static const int kInitialDelayMs; // Initial time bubble remains onscreen |
33 static const int kIdleTimeMs; // Time before mouse idle triggers hide | 35 static const int kIdleTimeMs; // Time before mouse idle triggers hide |
34 static const int kPositionCheckHz; // How fast to check the mouse position | 36 static const int kPositionCheckHz; // How fast to check the mouse position |
35 static const int kSlideInRegionHeightPx; | 37 static const int kSlideInRegionHeightPx; |
38 // Space between the popup and the top of the screen. | |
39 static const int kPopupTopPx; | |
36 // Height of region triggering slide-in | 40 // Height of region triggering slide-in |
37 static const int kSlideInDurationMs; // Duration of slide-in animation | 41 static const int kSlideInDurationMs; // Duration of slide-in animation |
38 static const int kSlideOutDurationMs; // Duration of slide-out animation | 42 static const int kSlideOutDurationMs; // Duration of slide-out animation |
39 | 43 |
40 // Returns the current desirable rect for the popup window. If | 44 // Returns the current desirable rect for the popup window. If |
41 // |ignore_animation_state| is true this returns the rect assuming the popup | 45 // |ignore_animation_state| is true this returns the rect assuming the popup |
42 // is fully onscreen. | 46 // is fully onscreen. |
43 virtual gfx::Rect GetPopupRect(bool ignore_animation_state) const = 0; | 47 virtual gfx::Rect GetPopupRect(bool ignore_animation_state) const = 0; |
44 | 48 |
45 virtual gfx::Point GetCursorScreenPoint() = 0; | 49 virtual gfx::Point GetCursorScreenPoint() = 0; |
46 | 50 |
Peter Kasting
2011/10/11 23:08:32
Nit: Just remove blank lines between related funct
koz (OOO until 15th September)
2011/10/12 05:38:23
Done.
| |
47 virtual bool WindowContainsPoint(gfx::Point pos) = 0; | 51 virtual bool WindowContainsPoint(gfx::Point pos) = 0; |
48 | 52 |
49 // Returns true if the window is active. | 53 // Returns true if the window is active. |
50 virtual bool IsWindowActive() = 0; | 54 virtual bool IsWindowActive() = 0; |
51 | 55 |
52 // Hides the bubble. This is a separate function so it can be called by a | 56 // Hides the bubble. This is a separate function so it can be called by a |
53 // timer. | 57 // timer. |
54 virtual void Hide() = 0; | 58 virtual void Hide() = 0; |
55 | 59 |
56 // Shows the bubble. | 60 // Shows the bubble. |
57 virtual void Show() = 0; | 61 virtual void Show() = 0; |
58 | 62 |
59 virtual bool IsAnimating() = 0; | 63 virtual bool IsAnimating() = 0; |
60 | 64 |
61 // Called repeatedly to get the current mouse position and animate the bubble | 65 // Called repeatedly to get the current mouse position and animate the bubble |
62 // on or off the screen as appropriate. | 66 // on or off the screen as appropriate. |
63 void CheckMousePosition(); | 67 void CheckMousePosition(); |
64 | 68 |
65 void StartWatchingMouse(); | 69 void StartWatchingMouse(); |
66 | 70 |
67 void ToggleFullscreen(); | 71 void ToggleFullscreen(); |
68 | 72 |
73 void AcceptFullscreen(const GURL& url); | |
74 | |
75 void CancelFullscreen(); | |
76 | |
77 // The browser this bubble is in. | |
78 Browser* browser_; | |
79 | |
69 private: | 80 private: |
70 // Someone who can toggle fullscreen mode on and off when the user requests | |
71 // it. | |
72 CommandUpdater::CommandUpdaterDelegate* delegate_; | |
73 | |
74 // Timer to delay before allowing the bubble to hide after it's initially | 81 // Timer to delay before allowing the bubble to hide after it's initially |
75 // shown. | 82 // shown. |
76 base::OneShotTimer<FullscreenExitBubble> initial_delay_; | 83 base::OneShotTimer<FullscreenExitBubble> initial_delay_; |
77 | 84 |
78 // Timer to see how long the mouse has been idle. | 85 // Timer to see how long the mouse has been idle. |
79 base::OneShotTimer<FullscreenExitBubble> idle_timeout_; | 86 base::OneShotTimer<FullscreenExitBubble> idle_timeout_; |
80 | 87 |
81 // Timer to poll the current mouse position. We can't just listen for mouse | 88 // Timer to poll the current mouse position. We can't just listen for mouse |
82 // events without putting a non-empty HWND onscreen (or hooking Windows, which | 89 // events without putting a non-empty HWND onscreen (or hooking Windows, which |
83 // has other problems), so instead we run a low-frequency poller to see if the | 90 // has other problems), so instead we run a low-frequency poller to see if the |
84 // user has moved in or out of our show/hide regions. | 91 // user has moved in or out of our show/hide regions. |
85 base::RepeatingTimer<FullscreenExitBubble> mouse_position_checker_; | 92 base::RepeatingTimer<FullscreenExitBubble> mouse_position_checker_; |
86 | 93 |
87 // The most recently seen mouse position, in screen coordinates. Used to see | 94 // The most recently seen mouse position, in screen coordinates. Used to see |
88 // if the mouse has moved since our last check. | 95 // if the mouse has moved since our last check. |
89 gfx::Point last_mouse_pos_; | 96 gfx::Point last_mouse_pos_; |
90 }; | 97 }; |
91 | 98 |
92 #endif // CHROME_BROWSER_UI_FULLSCREEN_EXIT_BUBBLE_H_ | 99 #endif // CHROME_BROWSER_UI_FULLSCREEN_EXIT_BUBBLE_H_ |
OLD | NEW |