Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(12)

Side by Side Diff: chrome/browser/ui/views/info_bubble.cc

Issue 6154001: Move animation code to new ui/base/animation directory.... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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/info_bubble.h" 5 #include "chrome/browser/views/info_bubble.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "app/keyboard_codes.h" 9 #include "app/keyboard_codes.h"
10 #include "app/slide_animation.h"
11 #include "chrome/browser/ui/window_sizer.h" 10 #include "chrome/browser/ui/window_sizer.h"
12 #include "chrome/common/notification_service.h" 11 #include "chrome/common/notification_service.h"
13 #include "gfx/canvas_skia.h" 12 #include "gfx/canvas_skia.h"
14 #include "gfx/color_utils.h" 13 #include "gfx/color_utils.h"
15 #include "gfx/path.h" 14 #include "gfx/path.h"
16 #include "third_party/skia/include/core/SkPaint.h" 15 #include "third_party/skia/include/core/SkPaint.h"
16 #include "ui/base/animation/slide_animation.h"
17 #include "views/fill_layout.h" 17 #include "views/fill_layout.h"
18 #include "views/widget/root_view.h" 18 #include "views/widget/root_view.h"
19 #include "views/widget/widget.h" 19 #include "views/widget/widget.h"
20 #include "views/window/client_view.h" 20 #include "views/window/client_view.h"
21 #include "views/window/window.h" 21 #include "views/window/window.h"
22 22
23 #if defined(OS_CHROMEOS) 23 #if defined(OS_CHROMEOS)
24 #include "chrome/browser/chromeos/wm_ipc.h" 24 #include "chrome/browser/chromeos/wm_ipc.h"
25 #include "third_party/cros/chromeos_wm_ipc_enums.h" 25 #include "third_party/cros/chromeos_wm_ipc_enums.h"
26 #endif 26 #endif
(...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after
275 return; 275 return;
276 276
277 show_status_ = kClosing; 277 show_status_ = kClosing;
278 278
279 if (fade_away_on_close_) 279 if (fade_away_on_close_)
280 FadeOut(); 280 FadeOut();
281 else 281 else
282 DoClose(false); 282 DoClose(false);
283 } 283 }
284 284
285 void InfoBubble::AnimationEnded(const Animation* animation) { 285 void InfoBubble::AnimationEnded(const ui::Animation* animation) {
286 if (static_cast<int>(animation_->GetCurrentValue()) == 0) { 286 if (static_cast<int>(animation_->GetCurrentValue()) == 0) {
287 // When fading out we just need to close the bubble at the end 287 // When fading out we just need to close the bubble at the end
288 DoClose(false); 288 DoClose(false);
289 } else { 289 } else {
290 #if defined(OS_WIN) 290 #if defined(OS_WIN)
291 // When fading in we need to remove the layered window style flag, since 291 // When fading in we need to remove the layered window style flag, since
292 // that style prevents some bubble content from working properly. 292 // that style prevents some bubble content from working properly.
293 SetWindowLong(GWL_EXSTYLE, GetWindowLong(GWL_EXSTYLE) & ~WS_EX_LAYERED); 293 SetWindowLong(GWL_EXSTYLE, GetWindowLong(GWL_EXSTYLE) & ~WS_EX_LAYERED);
294 #endif 294 #endif
295 } 295 }
296 } 296 }
297 297
298 void InfoBubble::AnimationProgressed(const Animation* animation) { 298 void InfoBubble::AnimationProgressed(const ui::Animation* animation) {
299 #if defined(OS_WIN) 299 #if defined(OS_WIN)
300 // Set the opacity for the main contents window. 300 // Set the opacity for the main contents window.
301 unsigned char opacity = static_cast<unsigned char>( 301 unsigned char opacity = static_cast<unsigned char>(
302 animation_->GetCurrentValue() * 255); 302 animation_->GetCurrentValue() * 255);
303 SetLayeredWindowAttributes(GetNativeView(), 0, 303 SetLayeredWindowAttributes(GetNativeView(), 0,
304 static_cast<byte>(opacity), LWA_ALPHA); 304 static_cast<byte>(opacity), LWA_ALPHA);
305 contents_->SchedulePaint(); 305 contents_->SchedulePaint();
306 306
307 // Also fade in/out the bubble border window. 307 // Also fade in/out the bubble border window.
308 border_->SetOpacity(opacity); 308 border_->SetOpacity(opacity);
(...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after
538 SetWindowLong(GWL_EXSTYLE, GetWindowLong(GWL_EXSTYLE) | WS_EX_LAYERED); 538 SetWindowLong(GWL_EXSTYLE, GetWindowLong(GWL_EXSTYLE) | WS_EX_LAYERED);
539 // This must be the very next call, otherwise we can get flicker on close. 539 // This must be the very next call, otherwise we can get flicker on close.
540 SetLayeredWindowAttributes(GetNativeView(), 0, 540 SetLayeredWindowAttributes(GetNativeView(), 0,
541 static_cast<byte>(255), LWA_ALPHA); 541 static_cast<byte>(255), LWA_ALPHA);
542 #endif 542 #endif
543 543
544 Fade(false); // |fade_in|. 544 Fade(false); // |fade_in|.
545 } 545 }
546 546
547 void InfoBubble::Fade(bool fade_in) { 547 void InfoBubble::Fade(bool fade_in) {
548 animation_.reset(new SlideAnimation(this)); 548 animation_.reset(new ui::SlideAnimation(this));
549 animation_->SetSlideDuration(kHideFadeDurationMS); 549 animation_->SetSlideDuration(kHideFadeDurationMS);
550 animation_->SetTweenType(Tween::LINEAR); 550 animation_->SetTweenType(ui::Tween::LINEAR);
551 551
552 animation_->Reset(fade_in ? 0.0 : 1.0); 552 animation_->Reset(fade_in ? 0.0 : 1.0);
553 if (fade_in) 553 if (fade_in)
554 animation_->Show(); 554 animation_->Show();
555 else 555 else
556 animation_->Hide(); 556 animation_->Hide();
557 } 557 }
558 558
559 bool InfoBubble::AcceleratorPressed(const views::Accelerator& accelerator) { 559 bool InfoBubble::AcceleratorPressed(const views::Accelerator& accelerator) {
560 if (!delegate_ || delegate_->CloseOnEscape()) { 560 if (!delegate_ || delegate_->CloseOnEscape()) {
561 DoClose(true); 561 DoClose(true);
562 return true; 562 return true;
563 } 563 }
564 return false; 564 return false;
565 } 565 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/info_bubble.h ('k') | chrome/browser/ui/views/infobars/extension_infobar.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698