| 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/gfx/chrome_canvas.h" | 7 #include "app/gfx/canvas.h" |
| 8 #include "app/l10n_util.h" | 8 #include "app/l10n_util.h" |
| 9 #include "app/l10n_util_win.h" | 9 #include "app/l10n_util_win.h" |
| 10 #include "app/resource_bundle.h" | 10 #include "app/resource_bundle.h" |
| 11 #include "chrome/app/chrome_dll_resource.h" | 11 #include "chrome/app/chrome_dll_resource.h" |
| 12 #include "grit/generated_resources.h" | 12 #include "grit/generated_resources.h" |
| 13 #include "views/widget/root_view.h" | 13 #include "views/widget/root_view.h" |
| 14 | 14 |
| 15 // FullscreenExitView ---------------------------------------------------------- | 15 // FullscreenExitView ---------------------------------------------------------- |
| 16 | 16 |
| 17 class FullscreenExitBubble::FullscreenExitView : public views::View { | 17 class FullscreenExitBubble::FullscreenExitView : public views::View { |
| 18 public: | 18 public: |
| 19 FullscreenExitView(FullscreenExitBubble* bubble, | 19 FullscreenExitView(FullscreenExitBubble* bubble, |
| 20 views::WidgetWin* popup, | 20 views::WidgetWin* popup, |
| 21 const std::wstring& accelerator); | 21 const std::wstring& accelerator); |
| 22 virtual ~FullscreenExitView(); | 22 virtual ~FullscreenExitView(); |
| 23 | 23 |
| 24 // views::View | 24 // views::View |
| 25 virtual gfx::Size GetPreferredSize(); | 25 virtual gfx::Size GetPreferredSize(); |
| 26 | 26 |
| 27 private: | 27 private: |
| 28 static const int kPaddingPixels; // Number of pixels around all sides of link | 28 static const int kPaddingPixels; // Number of pixels around all sides of link |
| 29 | 29 |
| 30 // views::View | 30 // views::View |
| 31 virtual void Layout(); | 31 virtual void Layout(); |
| 32 virtual void Paint(ChromeCanvas* canvas); | 32 virtual void Paint(gfx::Canvas* canvas); |
| 33 | 33 |
| 34 // Handle to the HWND that contains us. | 34 // Handle to the HWND that contains us. |
| 35 views::WidgetWin* popup_; | 35 views::WidgetWin* popup_; |
| 36 | 36 |
| 37 // Clickable hint text to show in the bubble. | 37 // Clickable hint text to show in the bubble. |
| 38 views::Link link_; | 38 views::Link link_; |
| 39 }; | 39 }; |
| 40 | 40 |
| 41 const int FullscreenExitBubble::FullscreenExitView::kPaddingPixels = 8; | 41 const int FullscreenExitBubble::FullscreenExitView::kPaddingPixels = 8; |
| 42 | 42 |
| (...skipping 21 matching lines...) Expand all Loading... |
| 64 return preferred_size; | 64 return preferred_size; |
| 65 } | 65 } |
| 66 | 66 |
| 67 void FullscreenExitBubble::FullscreenExitView::Layout() { | 67 void FullscreenExitBubble::FullscreenExitView::Layout() { |
| 68 gfx::Size link_preferred_size(link_.GetPreferredSize()); | 68 gfx::Size link_preferred_size(link_.GetPreferredSize()); |
| 69 link_.SetBounds(kPaddingPixels, | 69 link_.SetBounds(kPaddingPixels, |
| 70 height() - kPaddingPixels - link_preferred_size.height(), | 70 height() - kPaddingPixels - link_preferred_size.height(), |
| 71 link_preferred_size.width(), link_preferred_size.height()); | 71 link_preferred_size.width(), link_preferred_size.height()); |
| 72 } | 72 } |
| 73 | 73 |
| 74 void FullscreenExitBubble::FullscreenExitView::Paint(ChromeCanvas* canvas) { | 74 void FullscreenExitBubble::FullscreenExitView::Paint(gfx::Canvas* canvas) { |
| 75 // Create a round-bottomed rect to fill the whole View. | 75 // Create a round-bottomed rect to fill the whole View. |
| 76 CRect parent_rect; | 76 CRect parent_rect; |
| 77 SkRect rect; | 77 SkRect rect; |
| 78 SkScalar padding = SkIntToScalar(kPaddingPixels); | 78 SkScalar padding = SkIntToScalar(kPaddingPixels); |
| 79 // The "-padding" top coordinate ensures that the rect is always tall enough | 79 // The "-padding" top coordinate ensures that the rect is always tall enough |
| 80 // to contain the complete rounded corner radius. If we set this to 0, as the | 80 // to contain the complete rounded corner radius. If we set this to 0, as the |
| 81 // popup slides offscreen (in reality, squishes to 0 height), the corners will | 81 // popup slides offscreen (in reality, squishes to 0 height), the corners will |
| 82 // flatten out as the height becomes less than the corner radius. | 82 // flatten out as the height becomes less than the corner radius. |
| 83 rect.set(0, -padding, SkIntToScalar(width()), SkIntToScalar(height())); | 83 rect.set(0, -padding, SkIntToScalar(width()), SkIntToScalar(height())); |
| 84 SkScalar rad[8] = { 0, 0, 0, 0, padding, padding, padding, padding }; | 84 SkScalar rad[8] = { 0, 0, 0, 0, padding, padding, padding, padding }; |
| (...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 258 bool ignore_animation_state) const { | 258 bool ignore_animation_state) const { |
| 259 gfx::Size size(view_->GetPreferredSize()); | 259 gfx::Size size(view_->GetPreferredSize()); |
| 260 if (!ignore_animation_state) { | 260 if (!ignore_animation_state) { |
| 261 size.set_height(static_cast<int>(static_cast<double>(size.height()) * | 261 size.set_height(static_cast<int>(static_cast<double>(size.height()) * |
| 262 size_animation_->GetCurrentValue())); | 262 size_animation_->GetCurrentValue())); |
| 263 } | 263 } |
| 264 gfx::Point origin((root_view_->width() - size.width()) / 2, 0); | 264 gfx::Point origin((root_view_->width() - size.width()) / 2, 0); |
| 265 views::View::ConvertPointToScreen(root_view_, &origin); | 265 views::View::ConvertPointToScreen(root_view_, &origin); |
| 266 return gfx::Rect(origin, size); | 266 return gfx::Rect(origin, size); |
| 267 } | 267 } |
| OLD | NEW |