summaryrefslogtreecommitdiffstats
path: root/ash
diff options
context:
space:
mode:
authorsadrul@chromium.org <sadrul@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-04-23 21:51:00 +0000
committersadrul@chromium.org <sadrul@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-04-23 21:51:00 +0000
commit5d1491d00579750acfc8e3939b26cc8a598e2125 (patch)
treeb7a642bde96b3df5f17fa3002dc86c10a8dee1f2 /ash
parent74cb8e591479014f1b715cba0aa89f8fcb256251 (diff)
downloadchromium_src-5d1491d00579750acfc8e3939b26cc8a598e2125.zip
chromium_src-5d1491d00579750acfc8e3939b26cc8a598e2125.tar.gz
chromium_src-5d1491d00579750acfc8e3939b26cc8a598e2125.tar.bz2
ash: Animate changes in the uber tray.
Specifically, animate when a view in the tray hides/shows itself. For now, the tray does not animate when the size of a view changes (e.g. date-view changes size because it's 10:00). BUG=117209 TEST=none Review URL: https://chromiumcodereview.appspot.com/9969068 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@133526 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ash')
-rw-r--r--ash/ash.gyp2
-rw-r--r--ash/system/audio/tray_volume.cc4
-rw-r--r--ash/system/date/tray_date.cc7
-rw-r--r--ash/system/ime/tray_ime.cc8
-rw-r--r--ash/system/ime/tray_ime.h4
-rw-r--r--ash/system/network/tray_network.cc9
-rw-r--r--ash/system/tray/system_tray.cc55
-rw-r--r--ash/system/tray/system_tray_item.h4
-rw-r--r--ash/system/tray/tray_image_item.cc17
-rw-r--r--ash/system/tray/tray_image_item.h6
-rw-r--r--ash/system/tray/tray_item_view.cc114
-rw-r--r--ash/system/tray/tray_item_view.h79
-rw-r--r--ash/system/tray_accessibility.cc4
-rw-r--r--ash/system/tray_caps_lock.cc4
-rw-r--r--ash/system/tray_update.cc2
-rw-r--r--ash/system/user/tray_user.cc20
16 files changed, 254 insertions, 85 deletions
diff --git a/ash/ash.gyp b/ash/ash.gyp
index 172059f..cc24271 100644
--- a/ash/ash.gyp
+++ b/ash/ash.gyp
@@ -160,6 +160,8 @@
'system/tray/tray_image_item.h',
'system/tray/tray_item_more.cc',
'system/tray/tray_item_more.h',
+ 'system/tray/tray_item_view.cc',
+ 'system/tray/tray_item_view.h',
'system/tray/tray_views.cc',
'system/tray/tray_views.h',
'system/tray_accessibility.cc',
diff --git a/ash/system/audio/tray_volume.cc b/ash/system/audio/tray_volume.cc
index b33d713..bd7606c 100644
--- a/ash/system/audio/tray_volume.cc
+++ b/ash/system/audio/tray_volume.cc
@@ -192,8 +192,8 @@ void TrayVolume::DestroyDetailedView() {
}
void TrayVolume::OnVolumeChanged(float percent) {
- if (image_view())
- image_view()->SetVisible(GetInitialVisibility());
+ if (tray_view())
+ tray_view()->SetVisible(GetInitialVisibility());
if (volume_view_.get()) {
volume_view_->SetVolumeLevel(percent);
diff --git a/ash/system/date/tray_date.cc b/ash/system/date/tray_date.cc
index d38e191..bead970 100644
--- a/ash/system/date/tray_date.cc
+++ b/ash/system/date/tray_date.cc
@@ -8,6 +8,7 @@
#include "ash/system/date/date_view.h"
#include "ash/system/tray/system_tray_delegate.h"
#include "ash/system/tray/tray_constants.h"
+#include "ash/system/tray/tray_item_view.h"
#include "ash/system/tray/tray_views.h"
#include "base/i18n/time_formatting.h"
#include "base/stringprintf.h"
@@ -24,7 +25,6 @@
#include "ui/views/controls/button/text_button.h"
#include "ui/views/controls/image_view.h"
#include "ui/views/controls/label.h"
-#include "ui/views/layout/fill_layout.h"
#include "ui/views/layout/box_layout.h"
#include "ui/views/view.h"
#include "ui/views/widget/widget.h"
@@ -49,7 +49,10 @@ views::View* TrayDate::CreateTrayView(user::LoginStatus status) {
gfx::Font font = date_tray_->label()->font();
date_tray_->label()->SetFont(
font.DeriveFont(0, font.GetStyle() & ~gfx::Font::BOLD));
- return date_tray_.get();
+
+ views::View* view = new TrayItemView;
+ view->AddChildView(date_tray_.get());
+ return view;
}
views::View* TrayDate::CreateDefaultView(user::LoginStatus status) {
diff --git a/ash/system/ime/tray_ime.cc b/ash/system/ime/tray_ime.cc
index e260389..40767c0 100644
--- a/ash/system/ime/tray_ime.cc
+++ b/ash/system/ime/tray_ime.cc
@@ -11,6 +11,7 @@
#include "ash/system/tray/system_tray_delegate.h"
#include "ash/system/tray/tray_constants.h"
#include "ash/system/tray/tray_item_more.h"
+#include "ash/system/tray/tray_item_view.h"
#include "ash/system/tray/tray_views.h"
#include "base/logging.h"
#include "base/utf_string_conversions.h"
@@ -186,13 +187,14 @@ TrayIME::~TrayIME() {
}
void TrayIME::UpdateTrayLabel(const IMEInfo& current, size_t count) {
- tray_label_->SetText(current.short_name);
+ tray_label_->label()->SetText(current.short_name);
tray_label_->SetVisible(count > 1);
}
views::View* TrayIME::CreateTrayView(user::LoginStatus status) {
- tray_label_.reset(new views::Label);
- SetupLabelForTray(tray_label_.get());
+ tray_label_.reset(new TrayItemView);
+ tray_label_->CreateLabel();
+ SetupLabelForTray(tray_label_->label());
tray_label_->set_border(
views::Border::CreateEmptyBorder(0, 2, 0, 2));
return tray_label_.get();
diff --git a/ash/system/ime/tray_ime.h b/ash/system/ime/tray_ime.h
index 264944e..cc635f7 100644
--- a/ash/system/ime/tray_ime.h
+++ b/ash/system/ime/tray_ime.h
@@ -25,6 +25,8 @@ class IMEDefaultView;
class IMEDetailedView;
};
+class TrayItemView;
+
class TrayIME : public SystemTrayItem,
public IMEObserver {
public:
@@ -45,7 +47,7 @@ class TrayIME : public SystemTrayItem,
// Overridden from IMEObserver.
virtual void OnIMERefresh() OVERRIDE;
- scoped_ptr<views::Label> tray_label_;
+ scoped_ptr<TrayItemView> tray_label_;
scoped_ptr<tray::IMEDefaultView> default_;
scoped_ptr<tray::IMEDetailedView> detailed_;
diff --git a/ash/system/network/tray_network.cc b/ash/system/network/tray_network.cc
index 41f5826..f3aedef 100644
--- a/ash/system/network/tray_network.cc
+++ b/ash/system/network/tray_network.cc
@@ -10,6 +10,7 @@
#include "ash/system/tray/system_tray_delegate.h"
#include "ash/system/tray/tray_constants.h"
#include "ash/system/tray/tray_item_more.h"
+#include "ash/system/tray/tray_item_view.h"
#include "ash/system/tray/tray_views.h"
#include "base/utf_string_conversions.h"
#include "grit/ash_strings.h"
@@ -98,7 +99,7 @@ enum ColorTheme {
DARK,
};
-class NetworkTrayView : public views::View {
+class NetworkTrayView : public TrayItemView {
public:
NetworkTrayView(ColorTheme size, bool tray_icon)
: color_theme_(size), tray_icon_(tray_icon) {
@@ -136,8 +137,6 @@ class NetworkDefaultView : public TrayItemMore {
public:
explicit NetworkDefaultView(SystemTrayItem* owner)
: TrayItemMore(owner) {
- icon_ = new NetworkTrayView(DARK, false /* tray_icon */);
- ReplaceIcon(icon_);
Update();
}
@@ -147,14 +146,12 @@ class NetworkDefaultView : public TrayItemMore {
NetworkIconInfo info;
Shell::GetInstance()->tray_delegate()->
GetMostRelevantNetworkIcon(&info, true);
- icon_->Update(info);
+ SetImage(&info.image);
SetLabel(info.description);
SetAccessibleName(info.description);
}
private:
- NetworkTrayView* icon_;
-
DISALLOW_COPY_AND_ASSIGN(NetworkDefaultView);
};
diff --git a/ash/system/tray/system_tray.cc b/ash/system/tray/system_tray.cc
index 2ce03de..5870e55 100644
--- a/ash/system/tray/system_tray.cc
+++ b/ash/system/tray/system_tray.cc
@@ -58,64 +58,13 @@ const int kShadowHeight = 3;
const int kLeftPadding = 4;
const int kBottomLineHeight = 1;
-const int kTrayIconHeight = 29;
-
const SkColor kShadowColor = SkColorSetARGB(25, 0, 0, 0);
const SkColor kTrayBackgroundAlpha = 100;
const SkColor kTrayBackgroundHoverAlpha = 150;
-// Container for items in the tray. It makes sure the widget is updated
-// correctly when the visibility/size of the tray item changes.
-// TODO: setup animation.
-class TrayItemContainer : public views::View {
- public:
- explicit TrayItemContainer(views::View* view) : child_(view) {
- AddChildView(child_);
- SetVisible(child_->visible());
- }
-
- virtual ~TrayItemContainer() {}
-
- private:
- // Makes sure the widget relayouts after the size/visibility of the view
- // changes.
- void ApplyChange() {
- // Forcing the widget to the new size is sufficient. The positing is taken
- // care of by the layout manager (ShelfLayoutManager).
- GetWidget()->SetSize(GetWidget()->GetContentsView()->GetPreferredSize());
- }
-
- // Overridden from views::View.
- virtual void Layout() {
- child_->SetBoundsRect(gfx::Rect(size()));
- }
-
- virtual gfx::Size GetPreferredSize() OVERRIDE {
- gfx::Size size = child_->GetPreferredSize();
- size.set_height(kTrayIconHeight);
- return size;
- }
-
- virtual void ChildPreferredSizeChanged(views::View* child) OVERRIDE {
- ApplyChange();
- }
-
- virtual void ChildVisibilityChanged(views::View* child) OVERRIDE {
- if (visible() == child_->visible())
- return;
- SetVisible(child_->visible());
- ApplyChange();
- }
-
- views::View* child_;
-
- DISALLOW_COPY_AND_ASSIGN(TrayItemContainer);
-};
-
// A view with some special behaviour for tray items in the popup:
// - changes background color on hover.
-// - TODO: accessibility
class TrayPopupItemContainer : public views::View {
public:
explicit TrayPopupItemContainer(views::View* view) : hover_(false) {
@@ -499,7 +448,7 @@ void SystemTray::AddTrayItem(SystemTrayItem* item) {
SystemTrayDelegate* delegate = Shell::GetInstance()->tray_delegate();
views::View* tray_item = item->CreateTrayView(delegate->GetUserLoginStatus());
if (tray_item) {
- container_->AddChildViewAt(new TrayItemContainer(tray_item), 0);
+ container_->AddChildViewAt(tray_item, 0);
PreferredSizeChanged();
}
}
@@ -558,7 +507,7 @@ void SystemTray::UpdateAfterLoginStatusChange(user::LoginStatus login_status) {
++it) {
views::View* view = (*it)->CreateTrayView(login_status);
if (view)
- container_->AddChildViewAt(new TrayItemContainer(view), 0);
+ container_->AddChildViewAt(view, 0);
}
SetVisible(true);
PreferredSizeChanged();
diff --git a/ash/system/tray/system_tray_item.h b/ash/system/tray/system_tray_item.h
index 9fd438a..88f586d 100644
--- a/ash/system/tray/system_tray_item.h
+++ b/ash/system/tray/system_tray_item.h
@@ -24,6 +24,10 @@ class ASH_EXPORT SystemTrayItem {
// Returns a view to be displayed in the system tray. If this returns NULL,
// then this item is not displayed in the tray.
+ // NOTE: The returned view should almost always be a TrayItemView, which
+ // automatically resizes the widget when the size of the view changes, and
+ // adds animation when the visibility of the view changes. If a view wants to
+ // avoid these behaviour, then it should not be a TrayItemView.
virtual views::View* CreateTrayView(user::LoginStatus status) = 0;
// Returns a view for the item to be displayed in the list. This view can be
diff --git a/ash/system/tray/tray_image_item.cc b/ash/system/tray/tray_image_item.cc
index 4ceff22..9e92e0c 100644
--- a/ash/system/tray/tray_image_item.cc
+++ b/ash/system/tray/tray_image_item.cc
@@ -4,9 +4,11 @@
#include "ash/system/tray/tray_image_item.h"
+#include "ash/system/tray/tray_item_view.h"
#include "ui/base/resource/resource_bundle.h"
#include "ui/gfx/image/image.h"
#include "ui/views/controls/image_view.h"
+#include "ui/views/layout/fill_layout.h"
namespace ash {
namespace internal {
@@ -17,12 +19,17 @@ TrayImageItem::TrayImageItem(int resource_id)
TrayImageItem::~TrayImageItem() {}
+views::View* TrayImageItem::tray_view() {
+ return tray_view_.get();
+}
+
views::View* TrayImageItem::CreateTrayView(user::LoginStatus status) {
- image_view_.reset(new views::ImageView);
- image_view_->SetImage(ui::ResourceBundle::GetSharedInstance().
+ tray_view_.reset(new TrayItemView);
+ tray_view_->CreateImageView();
+ tray_view_->image_view()->SetImage(ui::ResourceBundle::GetSharedInstance().
GetImageNamed(resource_id_).ToSkBitmap());
- image_view_->SetVisible(GetInitialVisibility());
- return image_view_.get();
+ tray_view_->SetVisible(GetInitialVisibility());
+ return tray_view_.get();
}
views::View* TrayImageItem::CreateDefaultView(user::LoginStatus status) {
@@ -34,7 +41,7 @@ views::View* TrayImageItem::CreateDetailedView(user::LoginStatus status) {
}
void TrayImageItem::DestroyTrayView() {
- image_view_.reset();
+ tray_view_.reset();
}
void TrayImageItem::DestroyDefaultView() {
diff --git a/ash/system/tray/tray_image_item.h b/ash/system/tray/tray_image_item.h
index c5f0273..714e8750 100644
--- a/ash/system/tray/tray_image_item.h
+++ b/ash/system/tray/tray_image_item.h
@@ -15,12 +15,14 @@ class ImageView;
namespace ash {
namespace internal {
+class TrayItemView;
+
class TrayImageItem : public SystemTrayItem {
public:
explicit TrayImageItem(int resource_id);
virtual ~TrayImageItem();
- views::ImageView* image_view() { return image_view_.get(); }
+ views::View* tray_view();
protected:
virtual bool GetInitialVisibility() = 0;
@@ -35,7 +37,7 @@ class TrayImageItem : public SystemTrayItem {
private:
int resource_id_;
- scoped_ptr<views::ImageView> image_view_;
+ scoped_ptr<TrayItemView> tray_view_;
DISALLOW_COPY_AND_ASSIGN(TrayImageItem);
};
diff --git a/ash/system/tray/tray_item_view.cc b/ash/system/tray/tray_item_view.cc
new file mode 100644
index 0000000..22a605b
--- /dev/null
+++ b/ash/system/tray/tray_item_view.cc
@@ -0,0 +1,114 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "ash/system/tray/tray_item_view.h"
+
+#include "ui/base/animation/slide_animation.h"
+#include "ui/gfx/compositor/layer.h"
+#include "ui/views/controls/image_view.h"
+#include "ui/views/controls/label.h"
+#include "ui/views/layout/fill_layout.h"
+#include "ui/views/widget/widget.h"
+
+namespace {
+const int kTrayIconHeight = 29;
+const int kTrayItemAnimationDurationMS = 200;
+}
+
+namespace ash {
+namespace internal {
+
+TrayItemView::TrayItemView()
+ : label_(NULL),
+ image_view_(NULL) {
+ SetPaintToLayer(true);
+ SetFillsBoundsOpaquely(false);
+ SetLayoutManager(new views::FillLayout);
+}
+
+TrayItemView::~TrayItemView() {}
+
+void TrayItemView::CreateLabel() {
+ label_ = new views::Label;
+ AddChildView(label_);
+}
+
+void TrayItemView::CreateImageView() {
+ image_view_ = new views::ImageView;
+ AddChildView(image_view_);
+}
+
+void TrayItemView::SetVisible(bool set_visible) {
+ if (!GetWidget()) {
+ views::View::SetVisible(set_visible);
+ return;
+ }
+
+ if (!animation_.get()) {
+ animation_.reset(new ui::SlideAnimation(this));
+ animation_->SetSlideDuration(GetAnimationDurationMS());
+ animation_->SetTweenType(ui::Tween::LINEAR);
+ animation_->Reset(visible() ? 1.0 : 0.0);
+ }
+
+ if (!set_visible) {
+ animation_->Hide();
+ AnimationProgressed(animation_.get());
+ } else {
+ animation_->Show();
+ AnimationProgressed(animation_.get());
+ views::View::SetVisible(true);
+ }
+}
+
+void TrayItemView::ApplyChange() {
+ // Forcing the widget to the new size is sufficient. The positioning is
+ // taken care of by the layout manager (ShelfLayoutManager).
+ GetWidget()->SetSize(GetWidget()->GetContentsView()->GetPreferredSize());
+}
+
+gfx::Size TrayItemView::DesiredSize() {
+ return views::View::GetPreferredSize();
+}
+
+int TrayItemView::GetAnimationDurationMS() {
+ return kTrayItemAnimationDurationMS;
+}
+
+void TrayItemView::PreferredSizeChanged() {
+ views::View::PreferredSizeChanged();
+ ApplyChange();
+}
+
+gfx::Size TrayItemView::GetPreferredSize() {
+ gfx::Size size = DesiredSize();
+ size.set_height(kTrayIconHeight);
+ if (!animation_.get() || !animation_->is_animating())
+ return size;
+ size.set_width(std::max(1,
+ static_cast<int>(size.width() * animation_->GetCurrentValue())));
+ return size;
+}
+
+void TrayItemView::AnimationProgressed(const ui::Animation* animation) {
+ ui::Transform transform;
+ transform.SetScale(animation->GetCurrentValue(),
+ animation->GetCurrentValue());
+ transform.ConcatTranslate(0, animation->CurrentValueBetween(
+ static_cast<double>(height()) / 2, 0.));
+ layer()->SetTransform(transform);
+ ApplyChange();
+}
+
+void TrayItemView::AnimationEnded(const ui::Animation* animation) {
+ if (animation->GetCurrentValue() < 0.1)
+ views::View::SetVisible(false);
+}
+
+void TrayItemView::AnimationCanceled(const ui::Animation* animation) {
+ AnimationEnded(animation);
+}
+
+} // namespace internal
+} // namespace ash
diff --git a/ash/system/tray/tray_item_view.h b/ash/system/tray/tray_item_view.h
new file mode 100644
index 0000000..62f7013
--- /dev/null
+++ b/ash/system/tray/tray_item_view.h
@@ -0,0 +1,79 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef ASH_SYSTEM_TRAY_TRAY_ITEM_VIEW_H_
+#define ASH_SYSTEM_TRAY_TRAY_ITEM_VIEW_H_
+#pragma once
+
+#include "ui/base/animation/animation_delegate.h"
+#include "ui/views/view.h"
+
+namespace ui {
+class SlideAnimation;
+}
+
+namespace views {
+class ImageView;
+class Label;
+}
+
+namespace ash {
+namespace internal {
+
+// Base-class for items in the tray. It makes sure the widget is updated
+// correctly when the visibility/size of the tray item changes. It also adds
+// animation when showing/hiding the item in the tray.
+class TrayItemView : public views::View,
+ public ui::AnimationDelegate {
+ public:
+ TrayItemView();
+ virtual ~TrayItemView();
+
+ // Conveniece function for creating a child Label or ImageView.
+ void CreateLabel();
+ void CreateImageView();
+
+ views::Label* label() { return label_; }
+ views::ImageView* image_view() { return image_view_; }
+
+ // Overridden from views::View.
+ virtual void SetVisible(bool visible) OVERRIDE;
+
+ protected:
+ // Makes sure the widget relayouts after the size/visibility of the view
+ // changes.
+ void ApplyChange();
+
+ // This should return the desired size of the view. For most views, this
+ // returns GetPreferredSize. But since this class overrides GetPreferredSize
+ // for animation purposes, we allow a different way to get this size, and do
+ // not allow GetPreferredSize to be overridden.
+ virtual gfx::Size DesiredSize();
+
+ // The default animation duration is 200ms. But each view can customize this.
+ virtual int GetAnimationDurationMS();
+
+ // Overridden from views::View.
+ virtual void PreferredSizeChanged() OVERRIDE;
+
+ private:
+ // Overridden from views::View.
+ virtual gfx::Size GetPreferredSize() OVERRIDE;
+
+ // Overridden from ui::AnimationDelegate.
+ virtual void AnimationProgressed(const ui::Animation* animation) OVERRIDE;
+ virtual void AnimationEnded(const ui::Animation* animation) OVERRIDE;
+ virtual void AnimationCanceled(const ui::Animation* animation) OVERRIDE;
+
+ scoped_ptr<ui::SlideAnimation> animation_;
+ views::Label* label_;
+ views::ImageView* image_view_;
+
+ DISALLOW_COPY_AND_ASSIGN(TrayItemView);
+};
+
+} // namespace internal
+} // namespace ash
+
+#endif // ASH_SYSTEM_TRAY_TRAY_ITEM_VIEW_H_
diff --git a/ash/system/tray_accessibility.cc b/ash/system/tray_accessibility.cc
index 941ae21..1332d71 100644
--- a/ash/system/tray_accessibility.cc
+++ b/ash/system/tray_accessibility.cc
@@ -55,8 +55,8 @@ void TrayAccessibility::DestroyDetailedView() {
void TrayAccessibility::OnAccessibilityModeChanged(bool enabled,
int string_id) {
- if (image_view())
- image_view()->SetVisible(enabled);
+ if (tray_view())
+ tray_view()->SetVisible(enabled);
if (enabled) {
string_id_ = string_id;
diff --git a/ash/system/tray_caps_lock.cc b/ash/system/tray_caps_lock.cc
index b2eb228..195ff0c 100644
--- a/ash/system/tray_caps_lock.cc
+++ b/ash/system/tray_caps_lock.cc
@@ -55,8 +55,8 @@ void TrayCapsLock::DestroyDetailedView() {
void TrayCapsLock::OnCapsLockChanged(bool enabled,
int string_id) {
- if (image_view())
- image_view()->SetVisible(enabled);
+ if (tray_view())
+ tray_view()->SetVisible(enabled);
if (enabled) {
string_id_ = string_id;
diff --git a/ash/system/tray_update.cc b/ash/system/tray_update.cc
index e23f8c2..8d13995 100644
--- a/ash/system/tray_update.cc
+++ b/ash/system/tray_update.cc
@@ -78,7 +78,7 @@ void TrayUpdate::DestroyDefaultView() {
}
void TrayUpdate::OnUpdateRecommended() {
- image_view()->SetVisible(true);
+ tray_view()->SetVisible(true);
}
} // namespace internal
diff --git a/ash/system/user/tray_user.cc b/ash/system/user/tray_user.cc
index d50d12e..0895d3b 100644
--- a/ash/system/user/tray_user.cc
+++ b/ash/system/user/tray_user.cc
@@ -7,6 +7,7 @@
#include "ash/shell.h"
#include "ash/system/tray/system_tray_delegate.h"
#include "ash/system/tray/tray_constants.h"
+#include "ash/system/tray/tray_item_view.h"
#include "ash/system/tray/tray_views.h"
#include "base/utf_string_conversions.h"
#include "grit/ash_strings.h"
@@ -183,7 +184,7 @@ class UserView : public views::View,
};
// A custom image view with rounded edges.
-class RoundedImageView : public views::View {
+class RoundedImageView : public TrayItemView {
public:
// Constructs a new rounded image view with rounded corners of radius
// |corner_radius|.
@@ -202,19 +203,26 @@ class RoundedImageView : public views::View {
// Try to get the best image quality for the avatar.
resized_ = skia::ImageOperations::Resize(image_,
skia::ImageOperations::RESIZE_BEST, size.width(), size.height());
- PreferredSizeChanged();
- SchedulePaint();
+ if (GetWidget() && visible()) {
+ PreferredSizeChanged();
+ SchedulePaint();
+ }
}
- // Overridden from views::View.
- virtual gfx::Size GetPreferredSize() OVERRIDE {
+ // Overridden from TrayItemView.
+ virtual gfx::Size DesiredSize() OVERRIDE {
return gfx::Size(image_size_.width() + GetInsets().width(),
image_size_.height() + GetInsets().height());
}
+ virtual int GetAnimationDurationMS() OVERRIDE {
+ return 750;
+ }
+
+ // Overridden from views::View.
virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE {
View::OnPaint(canvas);
- gfx::Rect image_bounds(GetPreferredSize());
+ gfx::Rect image_bounds(DesiredSize());
image_bounds.Inset(GetInsets());
const SkScalar kRadius = SkIntToScalar(corner_radius_);
SkPath path;