OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2009 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 CHROME_BROWSER_VIEWS_FULLSCREEN_EXIT_BUBBLE_H__ |
| 6 #define CHROME_BROWSER_VIEWS_FULLSCREEN_EXIT_BUBBLE_H__ |
| 7 |
| 8 #include "base/scoped_ptr.h" |
| 9 #include "chrome/browser/command_updater.h" |
| 10 #include "chrome/common/slide_animation.h" |
| 11 #include "chrome/views/link.h" |
| 12 #include "chrome/views/widget_win.h" |
| 13 |
| 14 // FullscreenExitBubble is responsible for showing a bubble atop the screen in |
| 15 // fullscreen mode, telling users how to exit and providing a click target. |
| 16 // The bubble auto-hides, and re-shows when the user moves to the screen top. |
| 17 |
| 18 class FullscreenExitBubble : public views::LinkController, |
| 19 public AnimationDelegate { |
| 20 public: |
| 21 explicit FullscreenExitBubble( |
| 22 views::Widget* frame, |
| 23 CommandUpdater::CommandUpdaterDelegate* delegate); |
| 24 virtual ~FullscreenExitBubble(); |
| 25 |
| 26 private: |
| 27 class FullscreenExitView; |
| 28 |
| 29 static const double kOpacity; // Opacity of the bubble, 0.0 - 1.0 |
| 30 static const int kInitialDelayMs; // Initial time bubble remains onscreen |
| 31 static const int kPositionCheckHz; // How fast to check the mouse position |
| 32 static const int kSlideInRegionHeightPx; |
| 33 // Height of region triggering slide-in |
| 34 static const int kSlideInDurationMs; // Duration of slide-in animation |
| 35 static const int kSlideOutDurationMs; // Duration of slide-out animation |
| 36 |
| 37 // views::LinkController |
| 38 virtual void LinkActivated(views::Link* source, int event_flags); |
| 39 |
| 40 // AnimationDelegate |
| 41 virtual void AnimationProgressed(const Animation* animation); |
| 42 virtual void AnimationEnded(const Animation* animation); |
| 43 |
| 44 // Called after the initial delay to start checking the mouse position. |
| 45 void AfterInitialDelay(); |
| 46 |
| 47 // Called repeatedly to get the current mouse position and animate the bubble |
| 48 // on or off the screen as appropriate. |
| 49 void CheckMousePosition(); |
| 50 |
| 51 // Returns the current desirable rect for the popup window. If |
| 52 // |ignore_animation_state| is true this returns the rect assuming the popup |
| 53 // is fully onscreen. |
| 54 gfx::Rect GetPopupRect(bool ignore_animation_state) const; |
| 55 |
| 56 // The root view containing us. |
| 57 views::View* root_view_; |
| 58 |
| 59 // Someone who can toggle fullscreen mode on and off when the user requests |
| 60 // it. |
| 61 CommandUpdater::CommandUpdaterDelegate* delegate_; |
| 62 |
| 63 // We use an HWND for the popup so that it may float above any plugins in the |
| 64 // page. |
| 65 views::WidgetWin* popup_; |
| 66 |
| 67 // The contents of the popup. |
| 68 FullscreenExitView* view_; |
| 69 |
| 70 // Animation controlling sliding into/out of the top of the screen. |
| 71 scoped_ptr<SlideAnimation> size_animation_; |
| 72 |
| 73 // Timer to delay before starting the mouse checking/bubble hiding code. |
| 74 base::OneShotTimer<FullscreenExitBubble> initial_delay_; |
| 75 |
| 76 // Timer to poll the current mouse position. We can't just listen for mouse |
| 77 // events without putting a non-empty HWND onscreen (or hooking Windows, which |
| 78 // has other problems), so instead we run a low-frequency poller to see if the |
| 79 // user has moved in or out of our show/hide regions. |
| 80 base::RepeatingTimer<FullscreenExitBubble> mouse_position_checker_; |
| 81 |
| 82 DISALLOW_COPY_AND_ASSIGN(FullscreenExitBubble); |
| 83 }; |
| 84 |
| 85 #endif // CHROME_BROWSER_VIEWS_FULLSCREEN_EXIT_BUBBLE_H__ |
OLD | NEW |