summaryrefslogtreecommitdiffstats
path: root/chrome/browser/views/info_bubble.cc
diff options
context:
space:
mode:
authorfinnur@chromium.org <finnur@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-05-14 21:40:42 +0000
committerfinnur@chromium.org <finnur@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-05-14 21:40:42 +0000
commit346edb98d6c7796d35b888f4d7ee1231996a9761 (patch)
treec169146f18faa67776d66e86de09d646f8982436 /chrome/browser/views/info_bubble.cc
parent47a961eba1c75bf86b2dbdb9d39ac63101890328 (diff)
downloadchromium_src-346edb98d6c7796d35b888f4d7ee1231996a9761.zip
chromium_src-346edb98d6c7796d35b888f4d7ee1231996a9761.tar.gz
chromium_src-346edb98d6c7796d35b888f4d7ee1231996a9761.tar.bz2
Add fade-out animation to the app launcher.
BUG=None TEST=App launcher panel should fade away instead of disappearing immediately. Review URL: http://codereview.chromium.org/2109003 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@47318 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/views/info_bubble.cc')
-rw-r--r--chrome/browser/views/info_bubble.cc48
1 files changed, 45 insertions, 3 deletions
diff --git a/chrome/browser/views/info_bubble.cc b/chrome/browser/views/info_bubble.cc
index d184c46..e672004 100644
--- a/chrome/browser/views/info_bubble.cc
+++ b/chrome/browser/views/info_bubble.cc
@@ -22,6 +22,9 @@
#include "third_party/cros/chromeos_wm_ipc_enums.h"
#endif
+// How long the fade should last for.
+static const int kHideFadeDurationMS = 200;
+
// Background color of the bubble.
#if defined(OS_WIN)
const SkColor InfoBubble::kBackgroundColor =
@@ -93,7 +96,6 @@ gfx::Rect BorderContents::GetMonitorBounds(const gfx::Rect& rect) {
scoped_ptr<WindowSizer::MonitorInfoProvider> monitor_provider(
WindowSizer::CreateDefaultMonitorInfoProvider());
return monitor_provider->GetMonitorWorkAreaMatching(rect);
-
}
void BorderContents::Paint(gfx::Canvas* canvas) {
@@ -198,7 +200,6 @@ BorderWidget::BorderWidget() : border_contents_(NULL) {
set_window_ex_style(WS_EX_TOOLWINDOW | WS_EX_LAYERED);
}
-
void BorderWidget::Init(BorderContents* border_contents, HWND owner) {
DCHECK(!border_contents_);
border_contents_ = border_contents;
@@ -259,9 +260,31 @@ InfoBubble* InfoBubble::Show(views::Widget* parent,
}
void InfoBubble::Close() {
+ if (!delegate_ || !delegate_->FadeOutOnClose())
+ Close(false);
+ else
+ FadeOut();
+}
+
+void InfoBubble::AnimationEnded(const Animation* animation) {
Close(false);
}
+void InfoBubble::AnimationProgressed(const Animation* animation) {
+#if defined(OS_WIN)
+ unsigned char opacity = static_cast<unsigned char>(
+ animation_->GetCurrentValue() * 255);
+ SetLayeredWindowAttributes(GetNativeView(), 0,
+ static_cast<byte>(opacity), LWA_ALPHA);
+
+ // Also fade out the bubble border window.
+ border_->SetOpacity(opacity);
+ border_->border_contents()->SchedulePaint();
+#else
+ NOTIMPLEMENTED();
+#endif
+}
+
InfoBubble::InfoBubble()
:
#if defined(OS_LINUX)
@@ -400,7 +423,10 @@ void InfoBubble::SizeToContents() {
void InfoBubble::OnActivate(UINT action, BOOL minimized, HWND window) {
// The popup should close when it is deactivated.
if (action == WA_INACTIVE && !closed_) {
- Close();
+ if (!delegate_ || !delegate_->FadeOutOnClose())
+ Close();
+ else
+ FadeOut();
} else if (action == WA_ACTIVE) {
DCHECK(GetRootView()->GetChildViewCount() > 0);
GetRootView()->GetChildViewAt(0)->RequestFocus();
@@ -428,6 +454,22 @@ void InfoBubble::Close(bool closed_by_escape) {
#endif
}
+void InfoBubble::FadeOut() {
+#if defined(OS_WIN)
+ // The contents window cannot be created layered, since its content doesn't
+ // always work inside a layered window, but when animating it is ok to set
+ // that style on the window for the purpose of fading it out.
+ SetWindowLong(GWL_EXSTYLE, GetWindowLong(GWL_EXSTYLE) | WS_EX_LAYERED);
+#endif
+
+ animation_.reset(new SlideAnimation(this));
+ animation_->SetDuration(kHideFadeDurationMS);
+ animation_->SetTweenType(Tween::LINEAR);
+
+ animation_->Reset(1.0);
+ animation_->Hide();
+}
+
bool InfoBubble::AcceleratorPressed(const views::Accelerator& accelerator) {
if (!delegate_ || delegate_->CloseOnEscape()) {
Close(true);