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 |
30 : public views::View, | |
31 public views::ButtonListener { | |
27 public: | 32 public: |
28 FullscreenExitView(FullscreenExitBubbleViews* bubble, | 33 FullscreenExitView(FullscreenExitBubbleViews* bubble, |
29 const std::wstring& accelerator); | 34 const std::wstring& accelerator, |
35 const GURL& url, | |
36 bool ask_permission); | |
30 virtual ~FullscreenExitView(); | 37 virtual ~FullscreenExitView(); |
31 | 38 |
32 // views::View | 39 // views::View |
33 virtual gfx::Size GetPreferredSize(); | 40 virtual gfx::Size GetPreferredSize(); |
34 | 41 |
42 // views::ButtonListener | |
43 virtual void ButtonPressed(views::Button* sender, const views::Event& event); | |
44 | |
45 // Hide the accept and deny buttons, exposing the exit link. | |
46 void HideButtons(); | |
47 | |
35 private: | 48 private: |
49 string16 GetMessage(const GURL& url); | |
50 | |
51 // Space between the site info label and the buttons / link. | |
52 static const int kMiddlePaddingPx = 30; | |
Peter Kasting
2011/10/13 23:48:06
Nit: Some compilers get angsty about defining clas
koz (OOO until 15th September)
2011/10/14 00:35:16
Done.
koz (OOO until 15th September)
2011/10/14 00:35:16
Done.
| |
53 | |
36 // views::View | 54 // views::View |
37 virtual void Layout(); | 55 virtual void Layout(); |
38 virtual void OnPaint(gfx::Canvas* canvas); | 56 |
57 FullscreenExitBubbleViews* bubble_; | |
39 | 58 |
40 // Clickable hint text to show in the bubble. | 59 // Clickable hint text to show in the bubble. |
41 views::Link link_; | 60 views::Link link_; |
61 views::Label message_label_; | |
62 views::NativeTextButton* accept_button_; | |
63 views::NativeTextButton* deny_button_; | |
64 | |
65 bool show_buttons_; | |
42 }; | 66 }; |
43 | 67 |
44 FullscreenExitBubbleViews::FullscreenExitView::FullscreenExitView( | 68 FullscreenExitBubbleViews::FullscreenExitView::FullscreenExitView( |
45 FullscreenExitBubbleViews* bubble, | 69 FullscreenExitBubbleViews* bubble, |
46 const std::wstring& accelerator) { | 70 const std::wstring& accelerator, |
71 const GURL& url, | |
72 bool ask_permission) | |
73 : bubble_(bubble), | |
74 accept_button_(NULL), | |
75 deny_button_(NULL), | |
76 show_buttons_(ask_permission) { | |
77 views::BubbleBorder* bubble_border = | |
78 new views::BubbleBorder(views::BubbleBorder::NONE); | |
79 bubble_border->set_background_color(Bubble::kBackgroundColor); | |
80 set_background(new views::BubbleBackground(bubble_border)); | |
81 set_border(bubble_border); | |
82 set_focusable(false); | |
83 | |
84 message_label_.set_parent_owned(false); | |
85 message_label_.SetText(GetMessage(url)); | |
86 message_label_.SetFont(ResourceBundle::GetSharedInstance().GetFont( | |
87 ResourceBundle::MediumFont)); | |
88 message_label_.SetBackgroundColor(background()->get_color()); | |
Peter Kasting
2011/10/13 23:48:06
Nit: You should call enabled_color() before callin
koz (OOO until 15th September)
2011/10/14 01:06:13
Done.
| |
89 | |
47 link_.set_parent_owned(false); | 90 link_.set_parent_owned(false); |
91 link_.set_collapse_when_hidden(false); | |
92 link_.set_focusable(false); | |
48 #if !defined(OS_CHROMEOS) | 93 #if !defined(OS_CHROMEOS) |
49 link_.SetText( | 94 link_.SetText( |
50 l10n_util::GetStringFUTF16(IDS_EXIT_FULLSCREEN_MODE, | 95 l10n_util::GetStringFUTF16(IDS_EXIT_FULLSCREEN_MODE, |
51 WideToUTF16(accelerator))); | 96 WideToUTF16(accelerator))); |
52 #else | 97 #else |
53 link_.SetText(l10n_util::GetStringUTF16(IDS_EXIT_FULLSCREEN_MODE)); | 98 link_.SetText(l10n_util::GetStringUTF16(IDS_EXIT_FULLSCREEN_MODE)); |
54 #endif | 99 #endif |
55 link_.set_listener(bubble); | 100 link_.set_listener(bubble); |
56 link_.SetFont(ResourceBundle::GetSharedInstance().GetFont( | 101 link_.SetFont(ResourceBundle::GetSharedInstance().GetFont( |
57 ResourceBundle::LargeFont)); | 102 ResourceBundle::MediumFont)); |
58 link_.SetBackgroundColor(SK_ColorBLACK); | 103 link_.SetBackgroundColor(background()->get_color()); |
59 link_.SetEnabledColor(SK_ColorWHITE); | 104 link_.SetPressedColor(message_label_.enabled_color()); |
Peter Kasting
2011/10/13 23:48:06
You still want to SetEnabledColor() here like the
koz (OOO until 15th September)
2011/10/14 01:06:13
Done.
| |
60 link_.SetPressedColor(SK_ColorWHITE); | 105 |
106 AddChildView(&message_label_); | |
Peter Kasting
2011/10/13 23:48:06
Nit: Go ahead and do this right after setting up |
koz (OOO until 15th September)
2011/10/14 01:06:13
We've moved message_label_'s SetBackgroundColor()
| |
61 AddChildView(&link_); | 107 AddChildView(&link_); |
108 | |
109 accept_button_ = new views::NativeTextButton(this, | |
110 UTF16ToWide(l10n_util::GetStringUTF16(IDS_FULLSCREEN_INFOBAR_ALLOW))); | |
111 AddChildView(accept_button_); | |
112 | |
113 deny_button_ = new views::NativeTextButton(this, | |
114 UTF16ToWide(l10n_util::GetStringUTF16(IDS_FULLSCREEN_INFOBAR_DENY))); | |
115 AddChildView(deny_button_); | |
116 accept_button_->set_focusable(false); | |
Peter Kasting
2011/10/13 23:48:06
Nit: Can you put these two set_focusable() calls a
koz (OOO until 15th September)
2011/10/14 01:06:13
Done.
| |
117 deny_button_->set_focusable(false); | |
118 link_.SetVisible(false); | |
Peter Kasting
2011/10/13 23:48:06
Nit: Put this up with the rest of the |link_| setu
koz (OOO until 15th September)
2011/10/14 01:06:13
Done.
| |
119 if (!show_buttons_) | |
Peter Kasting
2011/10/13 23:48:06
Nit: Blank line above this
koz (OOO until 15th September)
2011/10/14 01:06:13
Done.
| |
120 HideButtons(); | |
121 } | |
122 | |
123 string16 FullscreenExitBubbleViews::FullscreenExitView::GetMessage( | |
124 const GURL& url) { | |
125 if (url.is_empty()) { | |
126 return l10n_util::GetStringUTF16( | |
127 IDS_FULLSCREEN_INFOBAR_USER_ENTERED_FULLSCREEN); | |
128 } | |
129 if (url.SchemeIsFile()) | |
130 return l10n_util::GetStringUTF16(IDS_FULLSCREEN_INFOBAR_FILE_PAGE_NAME); | |
131 return l10n_util::GetStringFUTF16(IDS_FULLSCREEN_INFOBAR_REQUEST_PERMISSION, | |
132 UTF8ToUTF16(url.host())); | |
62 } | 133 } |
63 | 134 |
64 FullscreenExitBubbleViews::FullscreenExitView::~FullscreenExitView() { | 135 FullscreenExitBubbleViews::FullscreenExitView::~FullscreenExitView() { |
65 } | 136 } |
66 | 137 |
138 void FullscreenExitBubbleViews::FullscreenExitView::ButtonPressed( | |
139 views::Button* sender, const views::Event& event) { | |
140 if (sender == accept_button_) | |
141 bubble_->OnAcceptFullscreen(); | |
142 else | |
143 bubble_->OnCancelFullscreen(); | |
144 } | |
145 | |
146 void FullscreenExitBubbleViews::FullscreenExitView::HideButtons() { | |
147 show_buttons_ = false; | |
148 accept_button_->SetVisible(false); | |
149 deny_button_->SetVisible(false); | |
150 link_.SetVisible(true); | |
151 } | |
152 | |
67 gfx::Size FullscreenExitBubbleViews::FullscreenExitView::GetPreferredSize() { | 153 gfx::Size FullscreenExitBubbleViews::FullscreenExitView::GetPreferredSize() { |
68 gfx::Size preferred_size(link_.GetPreferredSize()); | 154 gfx::Size link_preferred_size(link_.GetPreferredSize()); |
Peter Kasting
2011/10/13 23:48:06
Nit: Feel free to remove "preferred_" out of all t
koz (OOO until 15th September)
2011/10/14 01:06:13
Done.
| |
69 preferred_size.Enlarge(kPaddingPx * 2, kPaddingPx * 2); | 155 gfx::Size site_info_preferred_size(message_label_.GetPreferredSize()); |
70 return preferred_size; | 156 gfx::Size accept_preferred_size(accept_button_->GetPreferredSize()); |
157 gfx::Size deny_preferred_size(deny_button_->GetPreferredSize()); | |
158 gfx::Insets insets(GetInsets()); | |
159 | |
160 int buttons_width = accept_preferred_size.width() + kPaddingPx + | |
161 deny_preferred_size.width(); | |
162 int button_box_width = std::max(buttons_width, link_preferred_size.width()); | |
163 int width = kPaddingPx + site_info_preferred_size.width() + kMiddlePaddingPx + | |
164 button_box_width + kPaddingPx; | |
165 | |
166 gfx::Size result(width + insets.width(), | |
167 kPaddingPx * 2 + accept_preferred_size.height() + insets.height()); | |
168 return result; | |
71 } | 169 } |
72 | 170 |
73 void FullscreenExitBubbleViews::FullscreenExitView::Layout() { | 171 void FullscreenExitBubbleViews::FullscreenExitView::Layout() { |
74 gfx::Size link_preferred_size(link_.GetPreferredSize()); | 172 gfx::Size link_preferred_size(link_.GetPreferredSize()); |
75 link_.SetBounds(kPaddingPx, | 173 gfx::Size site_info_preferred_size(message_label_.GetPreferredSize()); |
76 height() - kPaddingPx - link_preferred_size.height(), | 174 gfx::Size accept_preferred_size(accept_button_->GetPreferredSize()); |
77 link_preferred_size.width(), link_preferred_size.height()); | 175 gfx::Size deny_preferred_size(deny_button_->GetPreferredSize()); |
78 } | 176 gfx::Insets insets(GetInsets()); |
79 | 177 |
80 void FullscreenExitBubbleViews::FullscreenExitView::OnPaint( | 178 int inner_height = height() - insets.height(); |
Peter Kasting
2011/10/13 23:48:06
Nit: One small issue with this layout is that it l
koz (OOO until 15th September)
2011/10/14 01:06:13
The bubble size doesn't actually get animated - th
Peter Kasting
2011/10/14 01:23:19
I missed that, oops.
Does that do the right thing
jeremya
2011/10/14 02:01:49
We manually set the y-coordinate of the contained
Peter Kasting
2011/10/14 17:36:52
I see. Dang, this is really confusing. There nee
| |
81 gfx::Canvas* canvas) { | 179 int button_box_x = insets.left() + kPaddingPx + |
82 // Create a round-bottomed rect to fill the whole View. | 180 site_info_preferred_size.width() + kMiddlePaddingPx; |
83 SkRect rect; | 181 int site_info_y = insets.top() + |
84 SkScalar padding = SkIntToScalar(kPaddingPx); | 182 (inner_height - site_info_preferred_size.height()) / 2; |
85 // The "-padding" top coordinate ensures that the rect is always tall enough | 183 int link_x = width() - insets.right() - kPaddingPx - |
86 // to contain the complete rounded corner radius. If we set this to 0, as the | 184 link_preferred_size.width(); |
87 // popup slides offscreen (in reality, squishes to 0 height), the corners will | 185 int link_y = insets.top() + (inner_height - link_preferred_size.height()) / 2; |
88 // flatten out as the height becomes less than the corner radius. | |
89 rect.set(0, -padding, SkIntToScalar(width()), SkIntToScalar(height())); | |
90 SkScalar rad[8] = { 0, 0, 0, 0, padding, padding, padding, padding }; | |
91 SkPath path; | |
92 path.addRoundRect(rect, rad, SkPath::kCW_Direction); | |
93 | 186 |
94 // Fill it black. | 187 message_label_.SetBounds(insets.left() + kPaddingPx, |
Peter Kasting
2011/10/13 23:48:06
Nit: I think if you just use SetPosition() all the
koz (OOO until 15th September)
2011/10/14 01:06:13
Done.
| |
95 SkPaint paint; | 188 site_info_y, |
96 paint.setStyle(SkPaint::kFill_Style); | 189 site_info_preferred_size.width(), |
97 paint.setFlags(SkPaint::kAntiAlias_Flag); | 190 site_info_preferred_size.height()); |
98 paint.setColor(SK_ColorBLACK); | 191 link_.SetBounds(link_x, |
99 canvas->GetSkCanvas()->drawPath(path, paint); | 192 link_y, |
193 link_preferred_size.width(), | |
194 link_preferred_size.height()); | |
195 if (show_buttons_) { | |
196 accept_button_->SetBounds(button_box_x, | |
197 insets.top() + kPaddingPx, | |
198 accept_preferred_size.width(), | |
199 accept_preferred_size.height()); | |
200 deny_button_->SetBounds( | |
201 button_box_x + accept_preferred_size.width() + kPaddingPx, | |
202 insets.top() + kPaddingPx, | |
203 deny_preferred_size.width(), | |
204 deny_preferred_size.height()); | |
205 } | |
100 } | 206 } |
101 | 207 |
102 // FullscreenExitBubbleViews --------------------------------------------------- | 208 // FullscreenExitBubbleViews --------------------------------------------------- |
103 | 209 |
104 FullscreenExitBubbleViews::FullscreenExitBubbleViews( | 210 FullscreenExitBubbleViews::FullscreenExitBubbleViews(views::Widget* frame, |
105 views::Widget* frame, | 211 Browser* browser, |
106 CommandUpdater::CommandUpdaterDelegate* delegate) | 212 const GURL& url, |
107 : FullscreenExitBubble(delegate), | 213 bool ask_permission) |
214 : FullscreenExitBubble(browser), | |
108 root_view_(frame->GetRootView()), | 215 root_view_(frame->GetRootView()), |
109 popup_(NULL), | 216 popup_(NULL), |
110 size_animation_(new ui::SlideAnimation(this)) { | 217 size_animation_(new ui::SlideAnimation(this)), |
218 url_(url) { | |
111 size_animation_->Reset(1); | 219 size_animation_->Reset(1); |
112 | 220 |
113 // Create the contents view. | 221 // Create the contents view. |
114 views::Accelerator accelerator(ui::VKEY_UNKNOWN, false, false, false); | 222 views::Accelerator accelerator(ui::VKEY_UNKNOWN, false, false, false); |
115 bool got_accelerator = frame->GetAccelerator(IDC_FULLSCREEN, &accelerator); | 223 bool got_accelerator = frame->GetAccelerator(IDC_FULLSCREEN, &accelerator); |
116 DCHECK(got_accelerator); | 224 DCHECK(got_accelerator); |
117 view_ = new FullscreenExitView( | 225 view_ = new FullscreenExitView(this, |
118 this, UTF16ToWideHack(accelerator.GetShortcutText())); | 226 UTF16ToWideHack(accelerator.GetShortcutText()), url, ask_permission); |
119 | 227 |
120 // Initialize the popup. | 228 // Initialize the popup. |
121 popup_ = new views::Widget; | 229 popup_ = new views::Widget; |
122 views::Widget::InitParams params(views::Widget::InitParams::TYPE_POPUP); | 230 views::Widget::InitParams params(views::Widget::InitParams::TYPE_POPUP); |
123 params.transparent = true; | 231 params.transparent = true; |
124 params.can_activate = false; | 232 params.can_activate = false; |
125 params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; | 233 params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; |
126 params.parent = frame->GetNativeView(); | 234 params.parent = frame->GetNativeView(); |
127 params.bounds = GetPopupRect(false); | 235 params.bounds = GetPopupRect(false); |
128 popup_->Init(params); | 236 popup_->Init(params); |
237 gfx::Size size = GetPopupRect(true).size(); | |
129 popup_->SetContentsView(view_); | 238 popup_->SetContentsView(view_); |
130 popup_->SetOpacity(static_cast<unsigned char>(0xff * kOpacity)); | 239 // We set layout manager to NULL to prevent the widget from sizing its |
240 // contents to the same size as itself. This prevents the widget contents from | |
241 // shrinking while we animate the height of the popup to give the impression | |
242 // that it is sliding off the top of the screen. | |
243 popup_->GetRootView()->SetLayoutManager(NULL); | |
244 view_->SetBounds(0, 0, size.width(), size.height()); | |
131 popup_->Show(); // This does not activate the popup. | 245 popup_->Show(); // This does not activate the popup. |
132 | 246 |
133 StartWatchingMouse(); | 247 if (!ask_permission) |
248 StartWatchingMouse(); | |
134 } | 249 } |
135 | 250 |
136 FullscreenExitBubbleViews::~FullscreenExitBubbleViews() { | 251 FullscreenExitBubbleViews::~FullscreenExitBubbleViews() { |
137 // This is tricky. We may be in an ATL message handler stack, in which case | 252 // This is tricky. We may be in an ATL message handler stack, in which case |
138 // the popup cannot be deleted yet. We also can't set the popup's ownership | 253 // the popup cannot be deleted yet. We also can't set the popup's ownership |
139 // model to NATIVE_WIDGET_OWNS_WIDGET because if the user closed the last tab | 254 // model to NATIVE_WIDGET_OWNS_WIDGET because if the user closed the last tab |
140 // while in fullscreen mode, Windows has already destroyed the popup HWND by | 255 // while in fullscreen mode, Windows has already destroyed the popup HWND by |
141 // the time we get here, and thus either the popup will already have been | 256 // the time we get here, and thus either the popup will already have been |
142 // deleted (if we set this in our constructor) or the popup will never get | 257 // deleted (if we set this in our constructor) or the popup will never get |
143 // another OnFinalMessage() call (if not, as currently). So instead, we tell | 258 // another OnFinalMessage() call (if not, as currently). So instead, we tell |
144 // the popup to synchronously hide, and then asynchronously close and delete | 259 // the popup to synchronously hide, and then asynchronously close and delete |
145 // itself. | 260 // itself. |
146 popup_->Close(); | 261 popup_->Close(); |
147 MessageLoop::current()->DeleteSoon(FROM_HERE, popup_); | 262 MessageLoop::current()->DeleteSoon(FROM_HERE, popup_); |
148 } | 263 } |
149 | 264 |
150 void FullscreenExitBubbleViews::LinkClicked( | 265 void FullscreenExitBubbleViews::LinkClicked( |
151 views::Link* source, int event_flags) { | 266 views::Link* source, int event_flags) { |
152 ToggleFullscreen(); | 267 ToggleFullscreen(); |
153 } | 268 } |
154 | 269 |
270 void FullscreenExitBubbleViews::OnAcceptFullscreen() { | |
271 AcceptFullscreen(url_); | |
272 view_->HideButtons(); | |
273 StartWatchingMouse(); | |
274 } | |
275 | |
276 void FullscreenExitBubbleViews::OnCancelFullscreen() { | |
277 CancelFullscreen(); | |
278 } | |
279 | |
155 void FullscreenExitBubbleViews::AnimationProgressed( | 280 void FullscreenExitBubbleViews::AnimationProgressed( |
156 const ui::Animation* animation) { | 281 const ui::Animation* animation) { |
157 gfx::Rect popup_rect(GetPopupRect(false)); | 282 gfx::Rect popup_rect(GetPopupRect(false)); |
158 if (popup_rect.IsEmpty()) { | 283 if (popup_rect.IsEmpty()) { |
159 popup_->Hide(); | 284 popup_->Hide(); |
160 } else { | 285 } else { |
161 popup_->SetBounds(popup_rect); | 286 popup_->SetBounds(popup_rect); |
287 view_->SetY(popup_rect.height() - view_->height()); | |
162 popup_->Show(); | 288 popup_->Show(); |
163 } | 289 } |
164 } | 290 } |
291 | |
165 void FullscreenExitBubbleViews::AnimationEnded( | 292 void FullscreenExitBubbleViews::AnimationEnded( |
166 const ui::Animation* animation) { | 293 const ui::Animation* animation) { |
167 AnimationProgressed(animation); | 294 AnimationProgressed(animation); |
168 } | 295 } |
169 | 296 |
170 void FullscreenExitBubbleViews::Hide() { | 297 void FullscreenExitBubbleViews::Hide() { |
171 size_animation_->SetSlideDuration(kSlideOutDurationMs); | 298 size_animation_->SetSlideDuration(kSlideOutDurationMs); |
172 size_animation_->Hide(); | 299 size_animation_->Hide(); |
173 } | 300 } |
174 | 301 |
(...skipping 17 matching lines...) Expand all Loading... | |
192 gfx::Point FullscreenExitBubbleViews::GetCursorScreenPoint() { | 319 gfx::Point FullscreenExitBubbleViews::GetCursorScreenPoint() { |
193 gfx::Point cursor_pos = gfx::Screen::GetCursorScreenPoint(); | 320 gfx::Point cursor_pos = gfx::Screen::GetCursorScreenPoint(); |
194 gfx::Point transformed_pos(cursor_pos); | 321 gfx::Point transformed_pos(cursor_pos); |
195 views::View::ConvertPointToView(NULL, root_view_, &transformed_pos); | 322 views::View::ConvertPointToView(NULL, root_view_, &transformed_pos); |
196 return transformed_pos; | 323 return transformed_pos; |
197 } | 324 } |
198 | 325 |
199 gfx::Rect FullscreenExitBubbleViews::GetPopupRect( | 326 gfx::Rect FullscreenExitBubbleViews::GetPopupRect( |
200 bool ignore_animation_state) const { | 327 bool ignore_animation_state) const { |
201 gfx::Size size(view_->GetPreferredSize()); | 328 gfx::Size size(view_->GetPreferredSize()); |
202 if (!ignore_animation_state) { | |
203 size.set_height(static_cast<int>(static_cast<double>(size.height()) * | |
204 size_animation_->GetCurrentValue())); | |
205 } | |
206 // NOTE: don't use the bounds of the root_view_. On linux changing window | 329 // NOTE: don't use the bounds of the root_view_. On linux changing window |
207 // size is async. Instead we use the size of the screen. | 330 // size is async. Instead we use the size of the screen. |
208 gfx::Rect screen_bounds = gfx::Screen::GetMonitorAreaNearestWindow( | 331 gfx::Rect screen_bounds = gfx::Screen::GetMonitorAreaNearestWindow( |
209 root_view_->GetWidget()->GetNativeView()); | 332 root_view_->GetWidget()->GetNativeView()); |
210 gfx::Point origin(screen_bounds.x() + | 333 gfx::Point origin(screen_bounds.x() + |
211 (screen_bounds.width() - size.width()) / 2, | 334 (screen_bounds.width() - size.width()) / 2, |
212 screen_bounds.y()); | 335 kPopupTopPx + screen_bounds.y()); |
336 if (!ignore_animation_state) { | |
337 int total_height = size.height() + kPopupTopPx; | |
338 int animation_height = | |
Peter Kasting
2011/10/13 23:48:06
Nit: Another way to wrap this is:
int animati
koz (OOO until 15th September)
2011/10/14 01:06:13
How about popup_bottom?
Peter Kasting
2011/10/14 01:23:19
That would be fine if this were the onscreen y-coo
| |
339 size_animation_->CurrentValueBetween(static_cast<double>(total_height), | |
340 0.0f); | |
341 int y_offset = std::min(animation_height, kPopupTopPx); | |
342 size.set_height(size.height() - animation_height + y_offset); | |
343 origin.set_y(origin.y() - y_offset); | |
344 } | |
213 return gfx::Rect(origin, size); | 345 return gfx::Rect(origin, size); |
214 } | 346 } |
OLD | NEW |