| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 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 | 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 #include "chrome/browser/views/fullscreen_exit_bubble.h" | 5 #include "chrome/browser/views/fullscreen_exit_bubble.h" |
| 6 | 6 |
| 7 #include "app/keyboard_codes.h" | 7 #include "app/keyboard_codes.h" |
| 8 #include "app/l10n_util.h" | 8 #include "app/l10n_util.h" |
| 9 #include "app/resource_bundle.h" | 9 #include "app/resource_bundle.h" |
| 10 #include "app/slide_animation.h" | |
| 11 #include "base/utf_string_conversions.h" | 10 #include "base/utf_string_conversions.h" |
| 12 #include "chrome/app/chrome_command_ids.h" | 11 #include "chrome/app/chrome_command_ids.h" |
| 13 #include "gfx/canvas_skia.h" | 12 #include "gfx/canvas_skia.h" |
| 14 #include "grit/generated_resources.h" | 13 #include "grit/generated_resources.h" |
| 14 #include "ui/base/animation/slide_animation.h" |
| 15 #include "views/screen.h" | 15 #include "views/screen.h" |
| 16 #include "views/widget/root_view.h" | 16 #include "views/widget/root_view.h" |
| 17 #include "views/window/window.h" | 17 #include "views/window/window.h" |
| 18 | 18 |
| 19 #if defined(OS_WIN) | 19 #if defined(OS_WIN) |
| 20 #include "app/l10n_util_win.h" | 20 #include "app/l10n_util_win.h" |
| 21 #include "views/widget/widget_win.h" | 21 #include "views/widget/widget_win.h" |
| 22 #elif defined(OS_LINUX) | 22 #elif defined(OS_LINUX) |
| 23 #include "views/widget/widget_gtk.h" | 23 #include "views/widget/widget_gtk.h" |
| 24 #endif | 24 #endif |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 136 const int FullscreenExitBubble::kSlideInRegionHeightPx = 4; | 136 const int FullscreenExitBubble::kSlideInRegionHeightPx = 4; |
| 137 const int FullscreenExitBubble::kSlideInDurationMs = 350; | 137 const int FullscreenExitBubble::kSlideInDurationMs = 350; |
| 138 const int FullscreenExitBubble::kSlideOutDurationMs = 700; | 138 const int FullscreenExitBubble::kSlideOutDurationMs = 700; |
| 139 | 139 |
| 140 FullscreenExitBubble::FullscreenExitBubble( | 140 FullscreenExitBubble::FullscreenExitBubble( |
| 141 views::Widget* frame, | 141 views::Widget* frame, |
| 142 CommandUpdater::CommandUpdaterDelegate* delegate) | 142 CommandUpdater::CommandUpdaterDelegate* delegate) |
| 143 : root_view_(frame->GetRootView()), | 143 : root_view_(frame->GetRootView()), |
| 144 delegate_(delegate), | 144 delegate_(delegate), |
| 145 popup_(NULL), | 145 popup_(NULL), |
| 146 size_animation_(new SlideAnimation(this)) { | 146 size_animation_(new ui::SlideAnimation(this)) { |
| 147 size_animation_->Reset(1); | 147 size_animation_->Reset(1); |
| 148 | 148 |
| 149 // Create the contents view. | 149 // Create the contents view. |
| 150 views::Accelerator accelerator(app::VKEY_UNKNOWN, false, false, false); | 150 views::Accelerator accelerator(app::VKEY_UNKNOWN, false, false, false); |
| 151 bool got_accelerator = frame->GetAccelerator(IDC_FULLSCREEN, &accelerator); | 151 bool got_accelerator = frame->GetAccelerator(IDC_FULLSCREEN, &accelerator); |
| 152 DCHECK(got_accelerator); | 152 DCHECK(got_accelerator); |
| 153 view_ = new FullscreenExitView(this, accelerator.GetShortcutText()); | 153 view_ = new FullscreenExitView(this, accelerator.GetShortcutText()); |
| 154 | 154 |
| 155 // Initialize the popup. | 155 // Initialize the popup. |
| 156 #if defined(OS_WIN) | 156 #if defined(OS_WIN) |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 191 // and then asynchronously close and delete itself. | 191 // and then asynchronously close and delete itself. |
| 192 popup_->Close(); | 192 popup_->Close(); |
| 193 MessageLoop::current()->DeleteSoon(FROM_HERE, popup_); | 193 MessageLoop::current()->DeleteSoon(FROM_HERE, popup_); |
| 194 } | 194 } |
| 195 | 195 |
| 196 void FullscreenExitBubble::LinkActivated(views::Link* source, int event_flags) { | 196 void FullscreenExitBubble::LinkActivated(views::Link* source, int event_flags) { |
| 197 delegate_->ExecuteCommand(IDC_FULLSCREEN); | 197 delegate_->ExecuteCommand(IDC_FULLSCREEN); |
| 198 } | 198 } |
| 199 | 199 |
| 200 void FullscreenExitBubble::AnimationProgressed( | 200 void FullscreenExitBubble::AnimationProgressed( |
| 201 const Animation* animation) { | 201 const ui::Animation* animation) { |
| 202 gfx::Rect popup_rect(GetPopupRect(false)); | 202 gfx::Rect popup_rect(GetPopupRect(false)); |
| 203 if (popup_rect.IsEmpty()) { | 203 if (popup_rect.IsEmpty()) { |
| 204 popup_->Hide(); | 204 popup_->Hide(); |
| 205 } else { | 205 } else { |
| 206 #if defined(OS_WIN) | 206 #if defined(OS_WIN) |
| 207 popup_->MoveWindow(popup_rect.x(), popup_rect.y(), popup_rect.width(), | 207 popup_->MoveWindow(popup_rect.x(), popup_rect.y(), popup_rect.width(), |
| 208 popup_rect.height()); | 208 popup_rect.height()); |
| 209 #elif defined(OS_LINUX) | 209 #elif defined(OS_LINUX) |
| 210 popup_->SetBounds(popup_rect); | 210 popup_->SetBounds(popup_rect); |
| 211 #endif | 211 #endif |
| 212 popup_->Show(); | 212 popup_->Show(); |
| 213 } | 213 } |
| 214 } | 214 } |
| 215 void FullscreenExitBubble::AnimationEnded( | 215 void FullscreenExitBubble::AnimationEnded( |
| 216 const Animation* animation) { | 216 const ui::Animation* animation) { |
| 217 AnimationProgressed(animation); | 217 AnimationProgressed(animation); |
| 218 } | 218 } |
| 219 | 219 |
| 220 void FullscreenExitBubble::CheckMousePosition() { | 220 void FullscreenExitBubble::CheckMousePosition() { |
| 221 // Desired behavior: | 221 // Desired behavior: |
| 222 // | 222 // |
| 223 // +------------+-----------------------------+------------+ | 223 // +------------+-----------------------------+------------+ |
| 224 // | _ _ _ _ | Exit full screen mode (F11) | _ _ _ _ | Slide-in region | 224 // | _ _ _ _ | Exit full screen mode (F11) | _ _ _ _ | Slide-in region |
| 225 // | _ _ _ _ \_____________________________/ _ _ _ _ | Neutral region | 225 // | _ _ _ _ \_____________________________/ _ _ _ _ | Neutral region |
| 226 // | | Slide-out region | 226 // | | Slide-out region |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 284 } | 284 } |
| 285 // NOTE: don't use the bounds of the root_view_. On linux changing window | 285 // NOTE: don't use the bounds of the root_view_. On linux changing window |
| 286 // size is async. Instead we use the size of the screen. | 286 // size is async. Instead we use the size of the screen. |
| 287 gfx::Rect screen_bounds = views::Screen::GetMonitorAreaNearestWindow( | 287 gfx::Rect screen_bounds = views::Screen::GetMonitorAreaNearestWindow( |
| 288 root_view_->GetWidget()->GetNativeView()); | 288 root_view_->GetWidget()->GetNativeView()); |
| 289 gfx::Point origin(screen_bounds.x() + | 289 gfx::Point origin(screen_bounds.x() + |
| 290 (screen_bounds.width() - size.width()) / 2, | 290 (screen_bounds.width() - size.width()) / 2, |
| 291 screen_bounds.y()); | 291 screen_bounds.y()); |
| 292 return gfx::Rect(origin, size); | 292 return gfx::Rect(origin, size); |
| 293 } | 293 } |
| OLD | NEW |