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 3 // found in the LICENSE file. 4 5 #ifndef CHROME_BROWSER_UI_VIEWS_FULLSCREEN_EXIT_BUBBLE_H__ 6 #define CHROME_BROWSER_UI_VIEWS_FULLSCREEN_EXIT_BUBBLE_H__ 7 #pragma once 8 9 #include "base/memory/scoped_ptr.h" 10 #include "base/timer.h" 11 #include "chrome/browser/command_updater.h" 12 #include "ui/base/animation/animation_delegate.h" 13 #include "views/controls/link.h" 14 15 namespace ui { 16 class SlideAnimation; 17 } 18 19 #if defined(OS_LINUX) 20 namespace views { 21 class WidgetGtk; 22 } 23 #endif 24 25 // FullscreenExitBubble is responsible for showing a bubble atop the screen in 26 // fullscreen mode, telling users how to exit and providing a click target. 27 // The bubble auto-hides, and re-shows when the user moves to the screen top. 28 29 class FullscreenExitBubble : public views::LinkController, 30 public ui::AnimationDelegate { 31 public: 32 explicit FullscreenExitBubble( 33 views::Widget* frame, 34 CommandUpdater::CommandUpdaterDelegate* delegate); 35 virtual ~FullscreenExitBubble(); 36 37 private: 38 class FullscreenExitView; 39 40 static const double kOpacity; // Opacity of the bubble, 0.0 - 1.0 41 static const int kInitialDelayMs; // Initial time bubble remains onscreen 42 static const int kIdleTimeMs; // Time before mouse idle triggers hide 43 static const int kPositionCheckHz; // How fast to check the mouse position 44 static const int kSlideInRegionHeightPx; 45 // Height of region triggering slide-in 46 static const int kSlideInDurationMs; // Duration of slide-in animation 47 static const int kSlideOutDurationMs; // Duration of slide-out animation 48 49 // views::LinkController 50 virtual void LinkActivated(views::Link* source, int event_flags); 51 52 // ui::AnimationDelegate 53 virtual void AnimationProgressed(const ui::Animation* animation); 54 virtual void AnimationEnded(const ui::Animation* animation); 55 56 // Called repeatedly to get the current mouse position and animate the bubble 57 // on or off the screen as appropriate. 58 void CheckMousePosition(); 59 60 // Hides the bubble. This is a separate function so it can be called by a 61 // timer. 62 void Hide(); 63 64 // Returns the current desirable rect for the popup window. If 65 // |ignore_animation_state| is true this returns the rect assuming the popup 66 // is fully onscreen. 67 gfx::Rect GetPopupRect(bool ignore_animation_state) const; 68 69 // The root view containing us. 70 views::View* root_view_; 71 72 // Someone who can toggle fullscreen mode on and off when the user requests 73 // it. 74 CommandUpdater::CommandUpdaterDelegate* delegate_; 75 76 views::Widget* popup_; 77 78 // The contents of the popup. 79 FullscreenExitView* view_; 80 81 // Animation controlling sliding into/out of the top of the screen. 82 scoped_ptr<ui::SlideAnimation> size_animation_; 83 84 // Timer to delay before allowing the bubble to hide after it's initially 85 // shown. 86 base::OneShotTimer<FullscreenExitBubble> initial_delay_; 87 88 // Timer to see how long the mouse has been idle. 89 base::OneShotTimer<FullscreenExitBubble> idle_timeout_; 90 91 // Timer to poll the current mouse position. We can't just listen for mouse 92 // events without putting a non-empty HWND onscreen (or hooking Windows, which 93 // has other problems), so instead we run a low-frequency poller to see if the 94 // user has moved in or out of our show/hide regions. 95 base::RepeatingTimer<FullscreenExitBubble> mouse_position_checker_; 96 97 // The most recently seen mouse position, in screen coordinates. Used to see 98 // if the mouse has moved since our last check. 99 gfx::Point last_mouse_pos_; 100 101 DISALLOW_COPY_AND_ASSIGN(FullscreenExitBubble); 102 }; 103 104 #endif // CHROME_BROWSER_UI_VIEWS_FULLSCREEN_EXIT_BUBBLE_H__ 105