diff options
author | davemoore@chromium.org <davemoore@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-05-05 19:37:06 +0000 |
---|---|---|
committer | davemoore@chromium.org <davemoore@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-05-05 19:37:06 +0000 |
commit | b6a468984baba97e4e89218e45f3b16252dc1195 (patch) | |
tree | 085fe9a40099bad69dd4ad6f727f6a987c5df37f /ash | |
parent | 0b89f748bd42806289e54d51f59b0d138ddb2d38 (diff) | |
download | chromium_src-b6a468984baba97e4e89218e45f3b16252dc1195.zip chromium_src-b6a468984baba97e4e89218e45f3b16252dc1195.tar.gz chromium_src-b6a468984baba97e4e89218e45f3b16252dc1195.tar.bz2 |
Remove LauncherItemWillChange
Replace the icon animation with code that checks if we're transitioning
to an empty icon.
BUG=125950
TEST=None
Review URL: http://codereview.chromium.org/10310027
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@135552 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ash')
-rw-r--r-- | ash/launcher/launcher_model.cc | 5 | ||||
-rw-r--r-- | ash/launcher/launcher_model.h | 4 | ||||
-rw-r--r-- | ash/launcher/launcher_model_observer.h | 3 | ||||
-rw-r--r-- | ash/launcher/launcher_model_unittest.cc | 2 | ||||
-rw-r--r-- | ash/launcher/launcher_view.cc | 7 | ||||
-rw-r--r-- | ash/launcher/launcher_view.h | 1 | ||||
-rw-r--r-- | ash/launcher/tabbed_launcher_button.cc | 71 | ||||
-rw-r--r-- | ash/launcher/tabbed_launcher_button.h | 12 |
8 files changed, 34 insertions, 71 deletions
diff --git a/ash/launcher/launcher_model.cc b/ash/launcher/launcher_model.cc index ed5cec6..b5761b0 100644 --- a/ash/launcher/launcher_model.cc +++ b/ash/launcher/launcher_model.cc @@ -61,11 +61,6 @@ void LauncherModel::Set(int index, const LauncherItem& item) { LauncherItemChanged(index, old_item)); } -void LauncherModel::SetPendingUpdate(int index) { - FOR_EACH_OBSERVER(LauncherModelObserver, observers_, - LauncherItemWillChange(index)); -} - int LauncherModel::ItemIndexByID(LauncherID id) { LauncherItems::const_iterator i = ItemByID(id); return i == items_.end() ? -1 : static_cast<int>(i - items_.begin()); diff --git a/ash/launcher/launcher_model.h b/ash/launcher/launcher_model.h index e7b533f..7262724 100644 --- a/ash/launcher/launcher_model.h +++ b/ash/launcher/launcher_model.h @@ -40,10 +40,6 @@ class ASH_EXPORT LauncherModel { // id and type. void Set(int index, const LauncherItem& item); - // Sends LauncherItemWillChange() to the observers. Used when the images are - // going to change for an item, but not for a while. - void SetPendingUpdate(int index); - // Returns the index of the item by id. int ItemIndexByID(int id); diff --git a/ash/launcher/launcher_model_observer.h b/ash/launcher/launcher_model_observer.h index d4aecac..c307c7b 100644 --- a/ash/launcher/launcher_model_observer.h +++ b/ash/launcher/launcher_model_observer.h @@ -30,9 +30,6 @@ class ASH_EXPORT LauncherModelObserver { // before the change. virtual void LauncherItemChanged(int index, const LauncherItem& old_item) = 0; - // Signals that LauncherItemChanged() is going to be sent in the near future. - virtual void LauncherItemWillChange(int index) = 0; - protected: virtual ~LauncherModelObserver() {} }; diff --git a/ash/launcher/launcher_model_unittest.cc b/ash/launcher/launcher_model_unittest.cc index 55025eb..16ff40c 100644 --- a/ash/launcher/launcher_model_unittest.cc +++ b/ash/launcher/launcher_model_unittest.cc @@ -48,8 +48,6 @@ class TestLauncherModelObserver : public LauncherModelObserver { virtual void LauncherItemMoved(int start_index, int target_index) OVERRIDE { moved_count_++; } - virtual void LauncherItemWillChange(int index) OVERRIDE { - } private: void AddToResult(const std::string& format, int count, std::string* result) { diff --git a/ash/launcher/launcher_view.cc b/ash/launcher/launcher_view.cc index f5833ba..4c9e846 100644 --- a/ash/launcher/launcher_view.cc +++ b/ash/launcher/launcher_view.cc @@ -774,13 +774,6 @@ void LauncherView::LauncherItemMoved(int start_index, int target_index) { OnLauncherIconPositionsChanged()); } -void LauncherView::LauncherItemWillChange(int index) { - const LauncherItem& item(model_->items()[index]); - views::View* view = view_model_->view_at(index); - if (item.type == TYPE_TABBED) - static_cast<TabbedLauncherButton*>(view)->PrepareForImageChange(); -} - void LauncherView::MousePressedOnButton(views::View* view, const views::MouseEvent& event) { if (view_model_->GetIndexOfView(view) == -1 || view_model_->view_size() <= 1) diff --git a/ash/launcher/launcher_view.h b/ash/launcher/launcher_view.h index 59cf6ba..fef3920 100644 --- a/ash/launcher/launcher_view.h +++ b/ash/launcher/launcher_view.h @@ -133,7 +133,6 @@ class ASH_EXPORT LauncherView : public views::View, virtual void LauncherItemChanged(int model_index, const ash::LauncherItem& old_item) OVERRIDE; virtual void LauncherItemMoved(int start_index, int target_index) OVERRIDE; - virtual void LauncherItemWillChange(int index) OVERRIDE; // Overridden from LauncherButtonHost: virtual void MousePressedOnButton(views::View* view, diff --git a/ash/launcher/tabbed_launcher_button.cc b/ash/launcher/tabbed_launcher_button.cc index 1980daa..398e210 100644 --- a/ash/launcher/tabbed_launcher_button.cc +++ b/ash/launcher/tabbed_launcher_button.cc @@ -21,8 +21,7 @@ namespace internal { TabbedLauncherButton::IconView::IconView( TabbedLauncherButton* host) - : host_(host), - show_image_(true) { + : host_(host) { if (!browser_image_) { ResourceBundle& rb = ResourceBundle::GetSharedInstance(); @@ -49,9 +48,7 @@ TabbedLauncherButton::IconView::~IconView() { void TabbedLauncherButton::IconView::AnimationEnded( const ui::Animation* animation) { AnimationProgressed(animation); - // Hide the image when the animation is done. We'll show it again the next - // time SetImages is invoked. - show_image_ = false; + animating_image_ = SkBitmap(); } void TabbedLauncherButton::IconView::AnimationProgressed( @@ -60,45 +57,47 @@ void TabbedLauncherButton::IconView::AnimationProgressed( SchedulePaint(); } -void TabbedLauncherButton::IconView::PrepareForImageChange() { - if (!show_image_ || (animation_.get() && animation_->is_animating())) - return; - - // Pause for 500ms, then ease out for 200ms. - ui::MultiAnimation::Parts animation_parts; - animation_parts.push_back(ui::MultiAnimation::Part(500, ui::Tween::ZERO)); - animation_parts.push_back(ui::MultiAnimation::Part(200, ui::Tween::EASE_OUT)); - animation_.reset(new ui::MultiAnimation(animation_parts)); - animation_->set_continuous(false); - animation_->set_delegate(this); - animation_->Start(); -} - void TabbedLauncherButton::IconView::SetTabImage(const SkBitmap& image) { - animation_.reset(); - // Only non incognito icons show the tab image. - show_image_ = host_->is_incognito() == STATE_NOT_INCOGNITO; - image_ = image; - SchedulePaint(); + if (image.empty()) { + if (!image_.empty()) { + // Pause for 500ms, then ease out for 200ms. + ui::MultiAnimation::Parts animation_parts; + animation_parts.push_back(ui::MultiAnimation::Part(500, ui::Tween::ZERO)); + animation_parts.push_back( + ui::MultiAnimation::Part(200, ui::Tween::EASE_OUT)); + animation_.reset(new ui::MultiAnimation(animation_parts)); + animation_->set_continuous(false); + animation_->set_delegate(this); + animation_->Start(); + animating_image_ = image_; + image_ = image; + } + } else { + animation_.reset(); + SchedulePaint(); + image_ = image; + } } void TabbedLauncherButton::IconView::OnPaint(gfx::Canvas* canvas) { LauncherButton::IconView::OnPaint(canvas); - if (image_.empty() || !show_image_) + // Only non incognito icons show the tab image. + if (host_->is_incognito() != STATE_NOT_INCOGNITO) return; - bool save_layer = (animation_.get() && animation_->is_animating() && - animation_->current_part_index() == 1); - if (save_layer) + if ((animation_.get() && animation_->is_animating() && + animation_->current_part_index() == 1)) { + int x = (width() - animating_image_.width()) / 2; + int y = (height() - animating_image_.height()) / 2; canvas->SaveLayerAlpha(animation_->CurrentValueBetween(255, 0)); - - int x = (width() - image_.width()) / 2; - int y = (height() - image_.height()) / 2; - canvas->DrawBitmapInt(image_, x, y); - - if (save_layer) + canvas->DrawBitmapInt(animating_image_, x, y); canvas->Restore(); + } else { + int x = (width() - image_.width()) / 2; + int y = (height() - image_.height()) / 2; + canvas->DrawBitmapInt(image_, x, y); + } } // static @@ -128,10 +127,6 @@ TabbedLauncherButton::TabbedLauncherButton(views::ButtonListener* listener, TabbedLauncherButton::~TabbedLauncherButton() { } -void TabbedLauncherButton::PrepareForImageChange() { - tabbed_icon_view()->PrepareForImageChange(); -} - void TabbedLauncherButton::SetTabImage(const SkBitmap& image) { tabbed_icon_view()->SetTabImage(image); } diff --git a/ash/launcher/tabbed_launcher_button.h b/ash/launcher/tabbed_launcher_button.h index f5d0c0d..ac9fbcd 100644 --- a/ash/launcher/tabbed_launcher_button.h +++ b/ash/launcher/tabbed_launcher_button.h @@ -37,9 +37,6 @@ class TabbedLauncherButton : public LauncherButton { IncognitoState is_incognito); virtual ~TabbedLauncherButton(); - // Notification that the images are about to change. Kicks off an animation. - void PrepareForImageChange(); - // Sets the images to display for this entry. void SetTabImage(const SkBitmap& image); @@ -68,9 +65,6 @@ class TabbedLauncherButton : public LauncherButton { virtual void AnimationEnded(const ui::Animation* animation) OVERRIDE; virtual void AnimationProgressed(const ui::Animation* animation) OVERRIDE; - // Notification that the images are about to change. Kicks off an animation. - void PrepareForImageChange(); - // Sets the image to display for this entry. void SetTabImage(const SkBitmap& image); @@ -81,15 +75,11 @@ class TabbedLauncherButton : public LauncherButton { private: TabbedLauncherButton* host_; SkBitmap image_; + SkBitmap animating_image_; // Used to animate image. scoped_ptr<ui::MultiAnimation> animation_; - // Should |image_| be shown? This is set to false soon after - // PrepareForImageChange() is invoked without a following call to - // SetImages(). - bool show_image_; - // Background images. Which one is chosen depends on the type of the window. static SkBitmap* browser_image_; static SkBitmap* incognito_browser_image_; |