Chromium Code Reviews| Index: chrome/browser/ui/views/fullscreen_exit_bubble_views.cc |
| diff --git a/chrome/browser/ui/views/fullscreen_exit_bubble.cc b/chrome/browser/ui/views/fullscreen_exit_bubble_views.cc |
| similarity index 56% |
| rename from chrome/browser/ui/views/fullscreen_exit_bubble.cc |
| rename to chrome/browser/ui/views/fullscreen_exit_bubble_views.cc |
| index 43bbe78d5f90e1f3b2a7090a976d913822885c63..22696f9ee24862d23e64e6d8a457c99b1b61fabb 100644 |
| --- a/chrome/browser/ui/views/fullscreen_exit_bubble.cc |
| +++ b/chrome/browser/ui/views/fullscreen_exit_bubble_views.cc |
| @@ -2,7 +2,7 @@ |
| // Use of this source code is governed by a BSD-style license that can be |
| // found in the LICENSE file. |
| -#include "chrome/browser/ui/views/fullscreen_exit_bubble.h" |
| +#include "chrome/browser/ui/views/fullscreen_exit_bubble_views.h" |
| #include "base/message_loop.h" |
| #include "base/utf_string_conversions.h" |
| @@ -16,6 +16,7 @@ |
| #include "ui/gfx/screen.h" |
| #include "views/controls/link.h" |
| #include "views/widget/widget.h" |
| +#include "ui/gfx/screen.h" |
|
tony
2011/08/02 17:04:25
Looks like we already have this include.
jeremya
2011/08/03 07:32:30
Done.
|
| #if defined(OS_WIN) |
| #include "ui/base/l10n/l10n_util_win.h" |
| @@ -23,9 +24,9 @@ |
| // FullscreenExitView ---------------------------------------------------------- |
| -class FullscreenExitBubble::FullscreenExitView : public views::View { |
| +class FullscreenExitBubbleViews::FullscreenExitView : public views::View { |
| public: |
| - FullscreenExitView(FullscreenExitBubble* bubble, |
| + FullscreenExitView(FullscreenExitBubbleViews* bubble, |
| const std::wstring& accelerator); |
| virtual ~FullscreenExitView(); |
| @@ -43,10 +44,10 @@ class FullscreenExitBubble::FullscreenExitView : public views::View { |
| views::Link link_; |
| }; |
| -const int FullscreenExitBubble::FullscreenExitView::kPaddingPixels = 8; |
| +const int FullscreenExitBubbleViews::FullscreenExitView::kPaddingPixels = 8; |
| -FullscreenExitBubble::FullscreenExitView::FullscreenExitView( |
| - FullscreenExitBubble* bubble, |
| +FullscreenExitBubbleViews::FullscreenExitView::FullscreenExitView( |
| + FullscreenExitBubbleViews* bubble, |
| const std::wstring& accelerator) { |
| link_.set_parent_owned(false); |
| #if !defined(OS_CHROMEOS) |
| @@ -65,23 +66,23 @@ FullscreenExitBubble::FullscreenExitView::FullscreenExitView( |
| AddChildView(&link_); |
| } |
| -FullscreenExitBubble::FullscreenExitView::~FullscreenExitView() { |
| +FullscreenExitBubbleViews::FullscreenExitView::~FullscreenExitView() { |
| } |
| -gfx::Size FullscreenExitBubble::FullscreenExitView::GetPreferredSize() { |
| +gfx::Size FullscreenExitBubbleViews::FullscreenExitView::GetPreferredSize() { |
| gfx::Size preferred_size(link_.GetPreferredSize()); |
| preferred_size.Enlarge(kPaddingPixels * 2, kPaddingPixels * 2); |
| return preferred_size; |
| } |
| -void FullscreenExitBubble::FullscreenExitView::Layout() { |
| +void FullscreenExitBubbleViews::FullscreenExitView::Layout() { |
| gfx::Size link_preferred_size(link_.GetPreferredSize()); |
| link_.SetBounds(kPaddingPixels, |
| height() - kPaddingPixels - link_preferred_size.height(), |
| link_preferred_size.width(), link_preferred_size.height()); |
| } |
| -void FullscreenExitBubble::FullscreenExitView::OnPaint(gfx::Canvas* canvas) { |
| +void FullscreenExitBubbleViews::FullscreenExitView::OnPaint(gfx::Canvas* canvas) { |
| // Create a round-bottomed rect to fill the whole View. |
| SkRect rect; |
| SkScalar padding = SkIntToScalar(kPaddingPixels); |
| @@ -102,23 +103,15 @@ void FullscreenExitBubble::FullscreenExitView::OnPaint(gfx::Canvas* canvas) { |
| canvas->AsCanvasSkia()->drawPath(path, paint); |
| } |
| -// FullscreenExitBubble -------------------------------------------------------- |
| - |
| -const double FullscreenExitBubble::kOpacity = 0.7; |
| -const int FullscreenExitBubble::kInitialDelayMs = 2300; |
| -const int FullscreenExitBubble::kIdleTimeMs = 2300; |
| -const int FullscreenExitBubble::kPositionCheckHz = 10; |
| -const int FullscreenExitBubble::kSlideInRegionHeightPx = 4; |
| -const int FullscreenExitBubble::kSlideInDurationMs = 350; |
| -const int FullscreenExitBubble::kSlideOutDurationMs = 700; |
| +// FullscreenExitBubbleViews -------------------------------------------------------- |
|
tony
2011/08/02 17:04:25
80 cols
jeremya
2011/08/03 07:32:30
Done.
|
| -FullscreenExitBubble::FullscreenExitBubble( |
| +FullscreenExitBubbleViews::FullscreenExitBubbleViews( |
| views::Widget* frame, |
| CommandUpdater::CommandUpdaterDelegate* delegate) |
| - : root_view_(frame->GetRootView()), |
| - delegate_(delegate), |
| - popup_(NULL), |
| - size_animation_(new ui::SlideAnimation(this)) { |
| + : FullscreenExitBubble(delegate), |
| + root_view_(frame->GetRootView()), |
| + size_animation_(new ui::SlideAnimation(this)), |
| + popup_(NULL) { |
|
tony
2011/08/02 17:04:25
I'm surprised you're able to reorder these. I tho
jeremya
2011/08/03 07:32:30
Since I didn't reorder them for any particular rea
|
| size_animation_->Reset(1); |
| // Create the contents view. |
| @@ -141,18 +134,10 @@ FullscreenExitBubble::FullscreenExitBubble( |
| popup_->SetOpacity(static_cast<unsigned char>(0xff * kOpacity)); |
| popup_->Show(); // This does not activate the popup. |
| - // Start the initial delay timer and begin watching the mouse. |
| - initial_delay_.Start(base::TimeDelta::FromMilliseconds(kInitialDelayMs), this, |
| - &FullscreenExitBubble::CheckMousePosition); |
| - gfx::Point cursor_pos = gfx::Screen::GetCursorScreenPoint(); |
| - last_mouse_pos_ = cursor_pos; |
| - views::View::ConvertPointToView(NULL, root_view_, &last_mouse_pos_); |
| - mouse_position_checker_.Start( |
| - base::TimeDelta::FromMilliseconds(1000 / kPositionCheckHz), this, |
| - &FullscreenExitBubble::CheckMousePosition); |
| + StartWatchingMouse(); |
| } |
| -FullscreenExitBubble::~FullscreenExitBubble() { |
| +FullscreenExitBubbleViews::~FullscreenExitBubbleViews() { |
| // This is tricky. We may be in an ATL message handler stack, in which case |
| // the popup cannot be deleted yet. We also can't set the popup's ownership |
| // model to NATIVE_WIDGET_OWNS_WIDGET because if the user closed the last tab |
| @@ -166,11 +151,12 @@ FullscreenExitBubble::~FullscreenExitBubble() { |
| MessageLoop::current()->DeleteSoon(FROM_HERE, popup_); |
| } |
| -void FullscreenExitBubble::LinkClicked(views::Link* source, int event_flags) { |
| - delegate_->ExecuteCommand(IDC_FULLSCREEN); |
| +void FullscreenExitBubbleViews::LinkClicked( |
| + views::Link* source, int event_flags) { |
| + ToggleFullscreen(); |
| } |
| -void FullscreenExitBubble::AnimationProgressed( |
| +void FullscreenExitBubbleViews::AnimationProgressed( |
| const ui::Animation* animation) { |
| gfx::Rect popup_rect(GetPopupRect(false)); |
| if (popup_rect.IsEmpty()) { |
| @@ -180,70 +166,41 @@ void FullscreenExitBubble::AnimationProgressed( |
| popup_->Show(); |
| } |
| } |
| -void FullscreenExitBubble::AnimationEnded( |
| +void FullscreenExitBubbleViews::AnimationEnded( |
| const ui::Animation* animation) { |
| AnimationProgressed(animation); |
| } |
| -void FullscreenExitBubble::CheckMousePosition() { |
| - // Desired behavior: |
| - // |
| - // +------------+-----------------------------+------------+ |
| - // | _ _ _ _ | Exit full screen mode (F11) | _ _ _ _ | Slide-in region |
| - // | _ _ _ _ \_____________________________/ _ _ _ _ | Neutral region |
| - // | | Slide-out region |
| - // : : |
| - // |
| - // * If app is not active, we hide the popup. |
| - // * If the mouse is offscreen or in the slide-out region, we hide the popup. |
| - // * If the mouse goes idle, we hide the popup. |
| - // * If the mouse is in the slide-in-region and not idle, we show the popup. |
| - // * If the mouse is in the neutral region and not idle, and the popup is |
| - // currently sliding out, we show it again. This facilitates users |
| - // correcting us if they try to mouse horizontally towards the popup and |
| - // unintentionally drop too low. |
| - // * Otherwise, we do nothing, because the mouse is in the neutral region and |
| - // either the popup is hidden or the mouse is not idle, so we don't want to |
| - // change anything's state. |
| +void FullscreenExitBubbleViews::Hide() { |
| + size_animation_->SetSlideDuration(kSlideOutDurationMs); |
| + size_animation_->Hide(); |
| +} |
| - gfx::Point cursor_pos = gfx::Screen::GetCursorScreenPoint(); |
| - gfx::Point transformed_pos(cursor_pos); |
| - views::View::ConvertPointToView(NULL, root_view_, &transformed_pos); |
| +void FullscreenExitBubbleViews::Show() { |
| + size_animation_->SetSlideDuration(kSlideInDurationMs); |
| + size_animation_->Show(); |
| +} |
| - // Check to see whether the mouse is idle. |
| - if (transformed_pos != last_mouse_pos_) { |
| - // The mouse moved; reset the idle timer. |
| - idle_timeout_.Stop(); // If the timer isn't running, this is a no-op. |
| - idle_timeout_.Start(base::TimeDelta::FromMilliseconds(kIdleTimeMs), this, |
| - &FullscreenExitBubble::CheckMousePosition); |
| - } |
| - last_mouse_pos_ = transformed_pos; |
| +bool FullscreenExitBubbleViews::IsAnimating() { |
| + return size_animation_->GetCurrentValue() != 0; |
| +} |
| - if ((!root_view_->GetWidget()->IsActive()) || |
| - !root_view_->HitTest(transformed_pos) || |
| - (cursor_pos.y() >= GetPopupRect(true).bottom()) || |
| - !idle_timeout_.IsRunning()) { |
| - // The cursor is offscreen, in the slide-out region, or idle. |
| - Hide(); |
| - } else if ((cursor_pos.y() < kSlideInRegionHeightPx) || |
| - (size_animation_->GetCurrentValue() != 0)) { |
| - // The cursor is not idle, and either it's in the slide-in region or it's in |
| - // the neutral region and we're sliding out. |
| - size_animation_->SetSlideDuration(kSlideInDurationMs); |
| - size_animation_->Show(); |
| - } |
| +bool FullscreenExitBubbleViews::IsWindowActive() { |
| + return root_view_->GetWidget()->IsActive(); |
| } |
| -void FullscreenExitBubble::Hide() { |
| - // Allow the bubble to hide if the window is deactivated or our initial delay |
| - // finishes. |
| - if ((!root_view_->GetWidget()->IsActive()) || !initial_delay_.IsRunning()) { |
| - size_animation_->SetSlideDuration(kSlideOutDurationMs); |
| - size_animation_->Hide(); |
| - } |
| +bool FullscreenExitBubbleViews::WindowContainsPoint(gfx::Point pos) { |
| + return root_view_->HitTest(pos); |
| +} |
| + |
| +gfx::Point FullscreenExitBubbleViews::GetCursorScreenPoint() { |
| + gfx::Point cursor_pos = gfx::Screen::GetCursorScreenPoint(); |
| + gfx::Point transformed_pos(cursor_pos); |
| + views::View::ConvertPointToView(NULL, root_view_, &transformed_pos); |
| + return transformed_pos; |
| } |
| -gfx::Rect FullscreenExitBubble::GetPopupRect( |
| +gfx::Rect FullscreenExitBubbleViews::GetPopupRect( |
| bool ignore_animation_state) const { |
| gfx::Size size(view_->GetPreferredSize()); |
| if (!ignore_animation_state) { |