Index: ash/launcher/launcher_view.cc |
diff --git a/ash/launcher/launcher_view.cc b/ash/launcher/launcher_view.cc |
index f844b7ed87658bc4dd270de6ec7ca4b4de6bfad5..2f9060c6b08ffb793acd0decd7d6e4330f241be2 100644 |
--- a/ash/launcher/launcher_view.cc |
+++ b/ash/launcher/launcher_view.cc |
@@ -181,6 +181,7 @@ void ReflectItemStatus(const ash::LauncherItem& item, |
break; |
} |
} |
+ |
} // namespace |
// AnimationDelegate used when inserting a new item. This steadily decreased the |
@@ -225,7 +226,6 @@ class LauncherView::StartFadeAnimationDelegate : |
// AnimationDelegate overrides: |
virtual void AnimationEnded(const Animation* animation) OVERRIDE { |
- view_->SetVisible(true); |
launcher_view_->FadeIn(view_); |
} |
virtual void AnimationCanceled(const Animation* animation) OVERRIDE { |
@@ -239,22 +239,11 @@ class LauncherView::StartFadeAnimationDelegate : |
DISALLOW_COPY_AND_ASSIGN(StartFadeAnimationDelegate); |
}; |
-int LauncherView::TestAPI::GetButtonCount() { |
- return launcher_view_->view_model_->view_size(); |
-} |
- |
-LauncherButton* LauncherView::TestAPI::GetButton(int index) { |
- if (index == 0) |
- return NULL; |
- |
- return static_cast<LauncherButton*>( |
- launcher_view_->view_model_->view_at(index)); |
-} |
- |
LauncherView::LauncherView(LauncherModel* model, LauncherDelegate* delegate) |
: model_(model), |
delegate_(delegate), |
view_model_(new views::ViewModel), |
+ last_visible_index_(-1), |
overflow_button_(NULL), |
dragging_(NULL), |
drag_view_(NULL), |
@@ -364,30 +353,24 @@ void LauncherView::CalculateIdealBounds(IdealBounds* bounds) { |
} |
bounds->overflow_bounds.set_size(gfx::Size(kButtonWidth, kButtonHeight)); |
- int last_visible_index = DetermineLastVisibleIndex( |
+ last_visible_index_ = DetermineLastVisibleIndex( |
available_width - kLeadingInset - bounds->overflow_bounds.width() - |
kButtonSpacing - kButtonWidth); |
- bool show_overflow = |
- (last_visible_index + 1 != view_model_->view_size()); |
int app_list_index = view_model_->view_size() - 1; |
- if (overflow_button_->visible() != show_overflow) { |
- // Only change visibility of the views if the visibility of the overflow |
- // button changes. Otherwise we'll effect the insertion animation, which |
- // changes the visibility. |
- for (int i = 0; i <= last_visible_index; ++i) |
- view_model_->view_at(i)->SetVisible(true); |
- for (int i = last_visible_index + 1; i < view_model_->view_size(); ++i) { |
- if (i != app_list_index) |
- view_model_->view_at(i)->SetVisible(false); |
- } |
+ bool show_overflow = (last_visible_index_ + 1 < app_list_index); |
+ |
+ for (int i = 0; i < view_model_->view_size(); ++i) { |
+ view_model_->view_at(i)->SetVisible( |
+ i == app_list_index || i <= last_visible_index_); |
} |
+ |
overflow_button_->SetVisible(show_overflow); |
if (show_overflow) { |
DCHECK_NE(0, view_model_->view_size()); |
// We always want the app list visible. |
gfx::Rect app_list_bounds = view_model_->ideal_bounds(app_list_index); |
- x = last_visible_index == -1 ? |
- kLeadingInset : view_model_->ideal_bounds(last_visible_index).right(); |
+ x = last_visible_index_ == -1 ? |
+ kLeadingInset : view_model_->ideal_bounds(last_visible_index_).right(); |
app_list_bounds.set_x(x); |
view_model_->set_ideal_bounds(app_list_index, app_list_bounds); |
x = app_list_bounds.right() + kButtonSpacing; |
@@ -674,10 +657,10 @@ void LauncherView::LauncherItemAdded(int model_index) { |
views::View* view = CreateViewForItem(model_->items()[model_index]); |
AddChildView(view); |
// Hide the view, it'll be made visible when the animation is done. |
- view->SetVisible(false); |
+ view->layer()->SetOpacity(0); |
sky
2012/04/23 20:47:25
Add a comment as to why opacity is used here.
xiyuan
2012/04/23 21:01:21
Done.
|
view_model_->Add(view, model_index); |
- // Give the button it's ideal bounds. That way if we end up animating the |
+ // Give the button its ideal bounds. That way if we end up animating the |
// button before this animation completes it doesn't appear at some random |
// spot (because it was in the middle of animating from 0,0 0x0 to its |
// target). |
@@ -685,11 +668,11 @@ void LauncherView::LauncherItemAdded(int model_index) { |
CalculateIdealBounds(&ideal_bounds); |
view->SetBoundsRect(view_model_->ideal_bounds(model_index)); |
- // The first animation moves all the views to their target position. |view| is |
- // hidden, so it visually appears as though we are providing space for |
+ // The first animation moves all the views to their target position. |view| |
+ // is hidden, so it visually appears as though we are providing space for |
// it. When done we'll fade the view in. |
AnimateToIdealBounds(); |
- if (!overflow_button_->visible()) { |
+ if (model_index <= last_visible_index_) { |
bounds_animator_->SetAnimationDelegate( |
view, new StartFadeAnimationDelegate(this, view), true); |
} |