Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 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 | 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/ui/views/fullscreen_exit_bubble_views.h" | 5 #include "chrome/browser/ui/views/fullscreen_exit_bubble_views.h" |
| 6 | 6 |
| 7 #include "base/message_loop.h" | 7 #include "base/message_loop.h" |
| 8 #include "base/utf_string_conversions.h" | 8 #include "base/utf_string_conversions.h" |
| 9 #include "chrome/app/chrome_command_ids.h" | 9 #include "chrome/app/chrome_command_ids.h" |
| 10 #include "chrome/browser/ui/views/bubble/bubble.h" | |
| 10 #include "grit/generated_resources.h" | 11 #include "grit/generated_resources.h" |
| 11 #include "ui/base/animation/slide_animation.h" | 12 #include "ui/base/animation/slide_animation.h" |
| 12 #include "ui/base/keycodes/keyboard_codes.h" | 13 #include "ui/base/keycodes/keyboard_codes.h" |
| 13 #include "ui/base/l10n/l10n_util.h" | 14 #include "ui/base/l10n/l10n_util.h" |
| 14 #include "ui/base/resource/resource_bundle.h" | 15 #include "ui/base/resource/resource_bundle.h" |
| 15 #include "ui/gfx/canvas_skia.h" | 16 #include "ui/gfx/canvas_skia.h" |
| 16 #include "ui/gfx/screen.h" | 17 #include "ui/gfx/screen.h" |
| 18 #include "views/bubble/bubble_border.h" | |
| 19 #include "views/controls/button/text_button.h" | |
| 17 #include "views/controls/link.h" | 20 #include "views/controls/link.h" |
| 18 #include "views/widget/widget.h" | 21 #include "views/widget/widget.h" |
| 19 | 22 |
| 20 #if defined(OS_WIN) | 23 #if defined(OS_WIN) |
| 21 #include "ui/base/l10n/l10n_util_win.h" | 24 #include "ui/base/l10n/l10n_util_win.h" |
| 22 #endif | 25 #endif |
| 23 | 26 |
| 24 // FullscreenExitView ---------------------------------------------------------- | 27 // FullscreenExitView ---------------------------------------------------------- |
| 25 | 28 |
| 26 class FullscreenExitBubbleViews::FullscreenExitView : public views::View { | 29 class FullscreenExitBubbleViews::FullscreenExitView : public views::View, |
| 30 public views::ButtonListener { | |
|
Peter Kasting
2011/10/11 23:08:32
Nit: Must be aligned with other parent class decla
koz (OOO until 15th September)
2011/10/12 05:38:23
Done.
| |
| 27 public: | 31 public: |
| 28 FullscreenExitView(FullscreenExitBubbleViews* bubble, | 32 FullscreenExitView(FullscreenExitBubbleViews* bubble, |
| 29 const std::wstring& accelerator); | 33 const std::wstring& accelerator, |
| 34 const GURL& url, | |
| 35 bool ask_permission); | |
| 30 virtual ~FullscreenExitView(); | 36 virtual ~FullscreenExitView(); |
| 31 | 37 |
| 32 // views::View | 38 // views::View |
| 33 virtual gfx::Size GetPreferredSize(); | 39 virtual gfx::Size GetPreferredSize(); |
| 34 | 40 |
| 41 // views::ButtonListener | |
|
Peter Kasting
2011/10/11 23:08:32
Nit: Can this be private?
koz (OOO until 15th September)
2011/10/12 05:38:23
Done.
| |
| 42 virtual void ButtonPressed(views::Button* sender, const views::Event& event); | |
| 43 | |
| 44 virtual void HideButtons(); | |
|
Peter Kasting
2011/10/11 23:08:32
Nit: Is this really virtual? Seems like no? Also
koz (OOO until 15th September)
2011/10/12 05:38:23
Done.
| |
| 45 | |
| 35 private: | 46 private: |
| 47 string16 GetMessage(const GURL& url); | |
| 48 // Space between the site info label and the buttons / link. | |
|
Peter Kasting
2011/10/11 23:08:32
Nit: Blank line above this
koz (OOO until 15th September)
2011/10/12 05:38:23
Done.
| |
| 49 static const int kMiddlePaddingPx = 30; | |
| 50 | |
| 36 // views::View | 51 // views::View |
| 37 virtual void Layout(); | 52 virtual void Layout(); |
| 38 virtual void OnPaint(gfx::Canvas* canvas); | 53 // virtual void OnPaint(gfx::Canvas* canvas); |
|
Peter Kasting
2011/10/11 23:08:32
Don't comment out declarations -- remove it entire
koz (OOO until 15th September)
2011/10/12 05:38:23
Done.
| |
| 54 | |
| 55 FullscreenExitBubbleViews* bubble_; | |
| 39 | 56 |
| 40 // Clickable hint text to show in the bubble. | 57 // Clickable hint text to show in the bubble. |
| 41 views::Link link_; | 58 views::Link link_; |
| 59 views::Label message_label_; | |
| 60 views::NativeTextButton* accept_button_; | |
| 61 views::NativeTextButton* deny_button_; | |
| 62 | |
| 63 bool show_buttons_; | |
| 42 }; | 64 }; |
| 43 | 65 |
| 44 FullscreenExitBubbleViews::FullscreenExitView::FullscreenExitView( | 66 FullscreenExitBubbleViews::FullscreenExitView::FullscreenExitView( |
| 45 FullscreenExitBubbleViews* bubble, | 67 FullscreenExitBubbleViews* bubble, |
| 46 const std::wstring& accelerator) { | 68 const std::wstring& accelerator, |
| 69 const GURL& url, | |
| 70 bool ask_permission) | |
| 71 : bubble_(bubble), | |
| 72 accept_button_(NULL), | |
| 73 deny_button_(NULL), | |
| 74 show_buttons_(ask_permission) { | |
| 75 set_focusable(false); | |
| 47 link_.set_parent_owned(false); | 76 link_.set_parent_owned(false); |
| 77 link_.set_collapse_when_hidden(false); | |
| 78 link_.set_focusable(false); | |
| 48 #if !defined(OS_CHROMEOS) | 79 #if !defined(OS_CHROMEOS) |
| 49 link_.SetText( | 80 link_.SetText( |
| 50 l10n_util::GetStringFUTF16(IDS_EXIT_FULLSCREEN_MODE, | 81 l10n_util::GetStringFUTF16(IDS_EXIT_FULLSCREEN_MODE, |
| 51 WideToUTF16(accelerator))); | 82 WideToUTF16(accelerator))); |
| 52 #else | 83 #else |
| 53 link_.SetText(l10n_util::GetStringUTF16(IDS_EXIT_FULLSCREEN_MODE)); | 84 link_.SetText(l10n_util::GetStringUTF16(IDS_EXIT_FULLSCREEN_MODE)); |
| 54 #endif | 85 #endif |
| 55 link_.set_listener(bubble); | 86 link_.set_listener(bubble); |
| 56 link_.SetFont(ResourceBundle::GetSharedInstance().GetFont( | 87 link_.SetFont(ResourceBundle::GetSharedInstance().GetFont( |
| 57 ResourceBundle::LargeFont)); | 88 ResourceBundle::MediumFont)); |
| 58 link_.SetNormalColor(SK_ColorWHITE); | 89 link_.SetNormalColor(SK_ColorBLACK); |
|
Peter Kasting
2011/10/11 23:08:32
There are potential accessibility issues here. Yo
koz (OOO until 15th September)
2011/10/12 05:38:23
Cool. I'll make this change once your patch lands.
Peter Kasting
2011/10/12 23:09:21
This has now landed.
| |
| 59 link_.SetHighlightedColor(SK_ColorWHITE); | 90 link_.SetHighlightedColor(SK_ColorBLACK); |
| 91 | |
| 92 message_label_.set_parent_owned(false); | |
| 93 message_label_.SetText( | |
| 94 GetMessage(url)); | |
| 95 message_label_.SetFont(ResourceBundle::GetSharedInstance().GetFont( | |
| 96 ResourceBundle::MediumFont)); | |
| 97 AddChildView(&message_label_); | |
| 60 AddChildView(&link_); | 98 AddChildView(&link_); |
| 99 | |
| 100 views::BubbleBorder* bubble_border = | |
|
Peter Kasting
2011/10/11 23:08:32
Nit: Instead of manually creating a bubble border,
koz (OOO until 15th September)
2011/10/12 05:38:23
There were a few reasons why we abandoned our atte
| |
| 101 new views::BubbleBorder(views::BubbleBorder::NONE); | |
| 102 bubble_border->set_background_color(Bubble::kBackgroundColor); | |
| 103 set_background(new views::BubbleBackground(bubble_border)); | |
| 104 set_border(bubble_border); | |
| 105 | |
| 106 accept_button_ = new views::NativeTextButton(this, | |
| 107 UTF16ToWide(l10n_util::GetStringUTF16(IDS_FULLSCREEN_INFOBAR_ALLOW))); | |
| 108 AddChildView(accept_button_); | |
| 109 | |
| 110 deny_button_ = new views::NativeTextButton(this, | |
| 111 UTF16ToWide(l10n_util::GetStringUTF16(IDS_FULLSCREEN_INFOBAR_DENY))); | |
| 112 AddChildView(deny_button_); | |
| 113 accept_button_->set_focusable(false); | |
| 114 deny_button_->set_focusable(false); | |
| 115 link_.SetVisible(false); | |
| 116 if (!show_buttons_) { | |
|
Peter Kasting
2011/10/11 23:08:32
Nit: No {}
koz (OOO until 15th September)
2011/10/12 05:38:23
Done.
| |
| 117 HideButtons(); | |
| 118 } | |
| 119 } | |
| 120 | |
| 121 string16 FullscreenExitBubbleViews::FullscreenExitView::GetMessage( | |
| 122 const GURL& url) { | |
| 123 UTF16ToWide( | |
|
Peter Kasting
2011/10/11 23:08:32
This line is erroneous.
koz (OOO until 15th September)
2011/10/12 05:38:23
Done.
| |
| 124 if (url.empty()) { | |
| 125 return l10n_util::GetStringUTF16( | |
| 126 IDS_FULLSCREEN_INFOBAR_USER_ENTERED_FULLSCREEN); | |
| 127 } else if (url.SchemeIsFile()) { | |
|
Peter Kasting
2011/10/11 23:08:32
Nit: No else after return (2 places)
koz (OOO until 15th September)
2011/10/12 05:38:23
Done.
| |
| 128 return l10n_util::GetStringUTF16(IDS_FULLSCREEN_INFOBAR_FILE_PAGE_NAME); | |
| 129 } else { | |
| 130 return | |
| 131 l10n_util::GetStringFUTF16(IDS_FULLSCREEN_INFOBAR_REQUEST_PERMISSION, | |
| 132 UTF8ToUTF16(url.host())); | |
| 133 } | |
| 61 } | 134 } |
| 62 | 135 |
| 63 FullscreenExitBubbleViews::FullscreenExitView::~FullscreenExitView() { | 136 FullscreenExitBubbleViews::FullscreenExitView::~FullscreenExitView() { |
| 64 } | 137 } |
| 65 | 138 |
| 139 void FullscreenExitBubbleViews::FullscreenExitView::ButtonPressed( | |
| 140 views::Button* sender, const views::Event& event) { | |
| 141 if (sender == accept_button_) | |
| 142 bubble_->OnAcceptFullscreen(); | |
| 143 else | |
| 144 bubble_->OnCancelFullscreen(); | |
| 145 } | |
| 146 | |
| 147 void FullscreenExitBubbleViews::FullscreenExitView::HideButtons() { | |
| 148 show_buttons_ = false; | |
| 149 accept_button_->SetVisible(false); | |
| 150 deny_button_->SetVisible(false); | |
| 151 link_.SetVisible(true); | |
| 152 } | |
| 153 | |
| 66 gfx::Size FullscreenExitBubbleViews::FullscreenExitView::GetPreferredSize() { | 154 gfx::Size FullscreenExitBubbleViews::FullscreenExitView::GetPreferredSize() { |
| 67 gfx::Size preferred_size(link_.GetPreferredSize()); | 155 gfx::Size link_preferred_size(link_.GetPreferredSize()); |
| 68 preferred_size.Enlarge(kPaddingPx * 2, kPaddingPx * 2); | 156 gfx::Size site_info_preferred_size(message_label_.GetPreferredSize()); |
| 69 return preferred_size; | 157 gfx::Size accept_preferred_size(accept_button_->GetPreferredSize()); |
| 158 gfx::Size deny_preferred_size(deny_button_->GetPreferredSize()); | |
| 159 gfx::Insets insets(GetInsets()); | |
| 160 | |
| 161 int buttons_width = accept_preferred_size.width() + kPaddingPx + | |
| 162 deny_preferred_size.width(); | |
| 163 int button_box_width = std::max(buttons_width, link_preferred_size.width()); | |
| 164 int width = kPaddingPx + site_info_preferred_size.width() + kMiddlePaddingPx + | |
| 165 button_box_width + kPaddingPx; | |
| 166 | |
| 167 gfx::Size result(width + insets.width(), | |
| 168 kPaddingPx * 2 + accept_preferred_size.height() + insets.height()); | |
| 169 return result; | |
| 70 } | 170 } |
| 71 | 171 |
| 72 void FullscreenExitBubbleViews::FullscreenExitView::Layout() { | 172 void FullscreenExitBubbleViews::FullscreenExitView::Layout() { |
| 73 gfx::Size link_preferred_size(link_.GetPreferredSize()); | 173 gfx::Size link_preferred_size(link_.GetPreferredSize()); |
|
Peter Kasting
2011/10/11 23:08:32
Did you consider using a layout manager like GridL
koz (OOO until 15th September)
2011/10/12 05:38:23
I'm not sure if that would work here as we need to
| |
| 74 link_.SetBounds(kPaddingPx, | 174 gfx::Size site_info_preferred_size(message_label_.GetPreferredSize()); |
| 75 height() - kPaddingPx - link_preferred_size.height(), | 175 gfx::Size accept_preferred_size(accept_button_->GetPreferredSize()); |
| 176 gfx::Size deny_preferred_size(deny_button_->GetPreferredSize()); | |
| 177 gfx::Insets insets(GetInsets()); | |
| 178 | |
| 179 int inner_height = height() - insets.height(); | |
| 180 int button_box_x = insets.left() + kPaddingPx + | |
| 181 site_info_preferred_size.width() + kMiddlePaddingPx; | |
| 182 int site_info_y = insets.top() + | |
| 183 (inner_height - site_info_preferred_size.height()) / 2; | |
| 184 int link_x = width() - insets.right() - kPaddingPx - | |
| 185 link_preferred_size.width(); | |
| 186 int link_y = insets.top() + (inner_height - link_preferred_size.height()) / 2; | |
| 187 | |
| 188 message_label_.SetBounds(insets.left() + kPaddingPx, | |
| 189 site_info_y, | |
| 190 site_info_preferred_size.width(), | |
| 191 site_info_preferred_size.height()); | |
| 192 link_.SetBounds(link_x, | |
|
Peter Kasting
2011/10/11 23:08:32
Nit: Wrapping here is odd
koz (OOO until 15th September)
2011/10/12 05:38:23
Done.
| |
| 193 link_y, | |
| 76 link_preferred_size.width(), link_preferred_size.height()); | 194 link_preferred_size.width(), link_preferred_size.height()); |
| 77 } | 195 if (show_buttons_) { |
| 78 | 196 accept_button_->SetBounds(button_box_x, |
| 79 void FullscreenExitBubbleViews::FullscreenExitView::OnPaint( | 197 insets.top() + kPaddingPx, |
| 80 gfx::Canvas* canvas) { | 198 accept_preferred_size.width(), |
| 81 // Create a round-bottomed rect to fill the whole View. | 199 accept_preferred_size.height()); |
| 82 SkRect rect; | 200 deny_button_->SetBounds( |
| 83 SkScalar padding = SkIntToScalar(kPaddingPx); | 201 button_box_x + accept_preferred_size.width() + kPaddingPx, |
| 84 // The "-padding" top coordinate ensures that the rect is always tall enough | 202 insets.top() + kPaddingPx, |
| 85 // to contain the complete rounded corner radius. If we set this to 0, as the | 203 deny_preferred_size.width(), |
| 86 // popup slides offscreen (in reality, squishes to 0 height), the corners will | 204 deny_preferred_size.height()); |
| 87 // flatten out as the height becomes less than the corner radius. | 205 } |
| 88 rect.set(0, -padding, SkIntToScalar(width()), SkIntToScalar(height())); | |
| 89 SkScalar rad[8] = { 0, 0, 0, 0, padding, padding, padding, padding }; | |
| 90 SkPath path; | |
| 91 path.addRoundRect(rect, rad, SkPath::kCW_Direction); | |
| 92 | |
| 93 // Fill it black. | |
| 94 SkPaint paint; | |
| 95 paint.setStyle(SkPaint::kFill_Style); | |
| 96 paint.setFlags(SkPaint::kAntiAlias_Flag); | |
| 97 paint.setColor(SK_ColorBLACK); | |
| 98 canvas->GetSkCanvas()->drawPath(path, paint); | |
| 99 } | 206 } |
| 100 | 207 |
| 101 // FullscreenExitBubbleViews --------------------------------------------------- | 208 // FullscreenExitBubbleViews --------------------------------------------------- |
| 102 | 209 |
| 103 FullscreenExitBubbleViews::FullscreenExitBubbleViews( | 210 FullscreenExitBubbleViews::FullscreenExitBubbleViews( |
| 104 views::Widget* frame, | 211 views::Widget* frame, |
|
Peter Kasting
2011/10/11 23:08:32
Nit: Move up to previous line and align other args
koz (OOO until 15th September)
2011/10/12 05:38:23
Done.
| |
| 105 CommandUpdater::CommandUpdaterDelegate* delegate) | 212 Browser* browser, |
| 106 : FullscreenExitBubble(delegate), | 213 const GURL& url, |
| 214 bool ask_permission) | |
| 215 : FullscreenExitBubble(browser), | |
| 107 root_view_(frame->GetRootView()), | 216 root_view_(frame->GetRootView()), |
| 108 popup_(NULL), | 217 popup_(NULL), |
| 109 size_animation_(new ui::SlideAnimation(this)) { | 218 size_animation_(new ui::SlideAnimation(this)), |
| 219 url_(url) { | |
| 110 size_animation_->Reset(1); | 220 size_animation_->Reset(1); |
| 111 | 221 |
| 112 // Create the contents view. | 222 // Create the contents view. |
| 113 views::Accelerator accelerator(ui::VKEY_UNKNOWN, false, false, false); | 223 views::Accelerator accelerator(ui::VKEY_UNKNOWN, false, false, false); |
| 114 bool got_accelerator = frame->GetAccelerator(IDC_FULLSCREEN, &accelerator); | 224 bool got_accelerator = frame->GetAccelerator(IDC_FULLSCREEN, &accelerator); |
| 115 DCHECK(got_accelerator); | 225 DCHECK(got_accelerator); |
| 116 view_ = new FullscreenExitView( | 226 view_ = new FullscreenExitView( |
| 117 this, UTF16ToWideHack(accelerator.GetShortcutText())); | 227 this, UTF16ToWideHack(accelerator.GetShortcutText()), url, |
|
Peter Kasting
2011/10/11 23:08:32
Nit: I think you can fit this all on 2 lines if yo
koz (OOO until 15th September)
2011/10/12 05:38:23
Done.
| |
| 228 ask_permission); | |
| 118 | 229 |
| 119 // Initialize the popup. | 230 // Initialize the popup. |
| 120 popup_ = new views::Widget; | 231 popup_ = new views::Widget; |
| 121 views::Widget::InitParams params(views::Widget::InitParams::TYPE_POPUP); | 232 views::Widget::InitParams params(views::Widget::InitParams::TYPE_POPUP); |
| 122 params.transparent = true; | 233 params.transparent = true; |
| 123 params.can_activate = false; | 234 params.can_activate = false; |
| 124 params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; | 235 params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; |
| 125 params.parent = frame->GetNativeView(); | 236 params.parent = frame->GetNativeView(); |
| 126 params.bounds = GetPopupRect(false); | 237 params.bounds = GetPopupRect(false); |
| 127 popup_->Init(params); | 238 popup_->Init(params); |
| 239 gfx::Size size = GetPopupRect(true).size(); | |
| 128 popup_->SetContentsView(view_); | 240 popup_->SetContentsView(view_); |
| 129 popup_->SetOpacity(static_cast<unsigned char>(0xff * kOpacity)); | 241 popup_->GetRootView()->SetLayoutManager(NULL); |
|
Peter Kasting
2011/10/11 23:08:32
If you're removing this you should kill the kOpaci
koz (OOO until 15th September)
2011/10/12 05:38:23
I've removed the constant (thanks), but as I talke
|
Peter Kasting
2011/10/11 23:08:32
Why is this needed?
koz (OOO until 15th September)
2011/10/12 05:38:23
I've added a comment.
|
| 242 view_->SetBounds(0, 0, size.width(), size.height()); | |
| 130 popup_->Show(); // This does not activate the popup. | 243 popup_->Show(); // This does not activate the popup. |
| 131 | 244 |
| 132 StartWatchingMouse(); | 245 if (!ask_permission) |
| 246 StartWatchingMouse(); | |
| 133 } | 247 } |
| 134 | 248 |
| 135 FullscreenExitBubbleViews::~FullscreenExitBubbleViews() { | 249 FullscreenExitBubbleViews::~FullscreenExitBubbleViews() { |
| 136 // This is tricky. We may be in an ATL message handler stack, in which case | 250 // This is tricky. We may be in an ATL message handler stack, in which case |
| 137 // the popup cannot be deleted yet. We also can't set the popup's ownership | 251 // the popup cannot be deleted yet. We also can't set the popup's ownership |
| 138 // model to NATIVE_WIDGET_OWNS_WIDGET because if the user closed the last tab | 252 // model to NATIVE_WIDGET_OWNS_WIDGET because if the user closed the last tab |
| 139 // while in fullscreen mode, Windows has already destroyed the popup HWND by | 253 // while in fullscreen mode, Windows has already destroyed the popup HWND by |
| 140 // the time we get here, and thus either the popup will already have been | 254 // the time we get here, and thus either the popup will already have been |
| 141 // deleted (if we set this in our constructor) or the popup will never get | 255 // deleted (if we set this in our constructor) or the popup will never get |
| 142 // another OnFinalMessage() call (if not, as currently). So instead, we tell | 256 // another OnFinalMessage() call (if not, as currently). So instead, we tell |
| 143 // the popup to synchronously hide, and then asynchronously close and delete | 257 // the popup to synchronously hide, and then asynchronously close and delete |
| 144 // itself. | 258 // itself. |
| 145 popup_->Close(); | 259 popup_->Close(); |
| 146 MessageLoop::current()->DeleteSoon(FROM_HERE, popup_); | 260 MessageLoop::current()->DeleteSoon(FROM_HERE, popup_); |
| 147 } | 261 } |
| 148 | 262 |
| 149 void FullscreenExitBubbleViews::LinkClicked( | 263 void FullscreenExitBubbleViews::LinkClicked( |
| 150 views::Link* source, int event_flags) { | 264 views::Link* source, int event_flags) { |
| 151 ToggleFullscreen(); | 265 ToggleFullscreen(); |
| 152 } | 266 } |
| 153 | 267 |
| 268 void FullscreenExitBubbleViews::OnAcceptFullscreen() { | |
| 269 AcceptFullscreen(url_); | |
| 270 view_->HideButtons(); | |
| 271 StartWatchingMouse(); | |
| 272 } | |
| 273 | |
| 274 void FullscreenExitBubbleViews::OnCancelFullscreen() { | |
| 275 CancelFullscreen(); | |
| 276 } | |
| 277 | |
| 154 void FullscreenExitBubbleViews::AnimationProgressed( | 278 void FullscreenExitBubbleViews::AnimationProgressed( |
| 155 const ui::Animation* animation) { | 279 const ui::Animation* animation) { |
| 156 gfx::Rect popup_rect(GetPopupRect(false)); | 280 gfx::Rect popup_rect(GetPopupRect(false)); |
| 157 if (popup_rect.IsEmpty()) { | 281 if (popup_rect.IsEmpty()) { |
| 158 popup_->Hide(); | 282 popup_->Hide(); |
| 159 } else { | 283 } else { |
| 160 popup_->SetBounds(popup_rect); | 284 popup_->SetBounds(popup_rect); |
| 285 view_->SetY(popup_rect.height() - view_->height()); | |
| 161 popup_->Show(); | 286 popup_->Show(); |
| 162 } | 287 } |
| 163 } | 288 } |
| 289 | |
| 164 void FullscreenExitBubbleViews::AnimationEnded( | 290 void FullscreenExitBubbleViews::AnimationEnded( |
| 165 const ui::Animation* animation) { | 291 const ui::Animation* animation) { |
| 166 AnimationProgressed(animation); | 292 AnimationProgressed(animation); |
| 167 } | 293 } |
| 168 | 294 |
| 169 void FullscreenExitBubbleViews::Hide() { | 295 void FullscreenExitBubbleViews::Hide() { |
| 170 size_animation_->SetSlideDuration(kSlideOutDurationMs); | 296 size_animation_->SetSlideDuration(kSlideOutDurationMs); |
| 171 size_animation_->Hide(); | 297 size_animation_->Hide(); |
| 172 } | 298 } |
| 173 | 299 |
| (...skipping 17 matching lines...) Expand all Loading... | |
| 191 gfx::Point FullscreenExitBubbleViews::GetCursorScreenPoint() { | 317 gfx::Point FullscreenExitBubbleViews::GetCursorScreenPoint() { |
| 192 gfx::Point cursor_pos = gfx::Screen::GetCursorScreenPoint(); | 318 gfx::Point cursor_pos = gfx::Screen::GetCursorScreenPoint(); |
| 193 gfx::Point transformed_pos(cursor_pos); | 319 gfx::Point transformed_pos(cursor_pos); |
| 194 views::View::ConvertPointToView(NULL, root_view_, &transformed_pos); | 320 views::View::ConvertPointToView(NULL, root_view_, &transformed_pos); |
| 195 return transformed_pos; | 321 return transformed_pos; |
| 196 } | 322 } |
| 197 | 323 |
| 198 gfx::Rect FullscreenExitBubbleViews::GetPopupRect( | 324 gfx::Rect FullscreenExitBubbleViews::GetPopupRect( |
| 199 bool ignore_animation_state) const { | 325 bool ignore_animation_state) const { |
| 200 gfx::Size size(view_->GetPreferredSize()); | 326 gfx::Size size(view_->GetPreferredSize()); |
| 201 if (!ignore_animation_state) { | |
| 202 size.set_height(static_cast<int>(static_cast<double>(size.height()) * | |
| 203 size_animation_->GetCurrentValue())); | |
| 204 } | |
| 205 // NOTE: don't use the bounds of the root_view_. On linux changing window | 327 // NOTE: don't use the bounds of the root_view_. On linux changing window |
| 206 // size is async. Instead we use the size of the screen. | 328 // size is async. Instead we use the size of the screen. |
| 207 gfx::Rect screen_bounds = gfx::Screen::GetMonitorAreaNearestWindow( | 329 gfx::Rect screen_bounds = gfx::Screen::GetMonitorAreaNearestWindow( |
| 208 root_view_->GetWidget()->GetNativeView()); | 330 root_view_->GetWidget()->GetNativeView()); |
| 209 gfx::Point origin(screen_bounds.x() + | 331 gfx::Point origin(screen_bounds.x() + |
| 210 (screen_bounds.width() - size.width()) / 2, | 332 (screen_bounds.width() - size.width()) / 2, |
| 211 screen_bounds.y()); | 333 kPopupTopPx + screen_bounds.y()); |
| 334 if (!ignore_animation_state) { | |
| 335 int total_height = size.height() + kPopupTopPx; | |
| 336 int animation_height = static_cast<int>( | |
|
Peter Kasting
2011/10/11 23:08:32
Nit: Use size_animation_.CurrentValueBetween().
koz (OOO until 15th September)
2011/10/12 05:38:23
Done.
| |
| 337 static_cast<double>(total_height) * | |
| 338 (1.0f - size_animation_->GetCurrentValue())); | |
| 339 int offset_delta, height_delta; | |
| 340 if (animation_height <= kPopupTopPx) { | |
|
Peter Kasting
2011/10/11 23:08:32
Nit: Simpler:
int y_offset = std::min(animation
koz (OOO until 15th September)
2011/10/12 05:38:23
Yes, that would be the best way to do it, but we w
Peter Kasting
2011/10/12 07:38:40
Test and see. Grab two monitors and tell Windows
| |
| 341 offset_delta = animation_height; | |
| 342 height_delta = 0; | |
| 343 } else { | |
| 344 offset_delta = kPopupTopPx; | |
| 345 height_delta = animation_height - kPopupTopPx; | |
| 346 } | |
| 347 | |
| 348 size.set_height(size.height() - height_delta); | |
| 349 origin.set_y(origin.y() - offset_delta); | |
| 350 } | |
| 212 return gfx::Rect(origin, size); | 351 return gfx::Rect(origin, size); |
| 213 } | 352 } |
| OLD | NEW |