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