Chromium Code Reviews| Index: ui/views/controls/slide_out_view.cc |
| diff --git a/ui/views/controls/slide_out_view.cc b/ui/views/controls/slide_out_view.cc |
| index 2ecf3cda6bc0b182cb5364872211b1fd3dbe8bfc..f45011a60f4dc4d853fa47a95ee114338c9bcf37 100644 |
| --- a/ui/views/controls/slide_out_view.cc |
| +++ b/ui/views/controls/slide_out_view.cc |
| @@ -7,13 +7,15 @@ |
| #include "ui/compositor/layer.h" |
| #include "ui/compositor/scoped_layer_animation_settings.h" |
| #include "ui/gfx/transform.h" |
| +#include "ui/views/controls/slide_out_view_impl.h" |
| namespace views { |
| SlideOutView::SlideOutView() |
| : gesture_scroll_amount_(0.f) { |
| - SetPaintToLayer(true); |
| - SetFillsBoundsOpaquely(false); |
| + if (get_use_acceleration_when_possible()) { |
|
msw
2013/01/17 02:28:30
nit: remove unnecessary braces.
dewittj
2013/01/17 21:25:18
Gone.
|
| + impl_.reset(new SlideOutViewImpl(this)); |
| + } |
| } |
| SlideOutView::~SlideOutView() { |
| @@ -43,11 +45,8 @@ void SlideOutView::OnGestureEvent(ui::GestureEvent* event) { |
| // The scroll-update events include the incremental scroll amount. |
| gesture_scroll_amount_ += event->details().scroll_x(); |
| - gfx::Transform transform; |
| - transform.Translate(gesture_scroll_amount_, 0.0); |
| - layer()->SetTransform(transform); |
| - layer()->SetOpacity( |
| - 1.f - std::min(fabsf(gesture_scroll_amount_) / width(), 1.f)); |
| + if (impl_) |
| + impl_->TransformView(gesture_scroll_amount_); |
| } else if (event->type() == ui::ET_GESTURE_SCROLL_END) { |
| const float kScrollRatioForClosingNotification = 0.5f; |
| float scrolled_ratio = fabsf(gesture_scroll_amount_) / width(); |
| @@ -64,26 +63,13 @@ void SlideOutView::OnGestureEvent(ui::GestureEvent* event) { |
| void SlideOutView::RestoreVisualState() { |
| // Restore the layer state. |
| - const int kSwipeRestoreDurationMS = 150; |
| - ui::ScopedLayerAnimationSettings settings(layer()->GetAnimator()); |
| - settings.SetTransitionDuration( |
| - base::TimeDelta::FromMilliseconds(kSwipeRestoreDurationMS)); |
| - layer()->SetTransform(gfx::Transform()); |
| - layer()->SetOpacity(1.f); |
| + if (impl_) |
| + impl_->RestoreView(); |
| } |
| void SlideOutView::SlideOutAndClose(SlideDirection direction) { |
| - const int kSwipeOutTotalDurationMS = 150; |
| - int swipe_out_duration = kSwipeOutTotalDurationMS * layer()->opacity(); |
| - ui::ScopedLayerAnimationSettings settings(layer()->GetAnimator()); |
| - settings.SetTransitionDuration( |
| - base::TimeDelta::FromMilliseconds(swipe_out_duration)); |
| - settings.AddObserver(this); |
| - |
| - gfx::Transform transform; |
| - transform.Translate(direction == SLIDE_LEFT ? -width() : width(), 0.0); |
| - layer()->SetTransform(transform); |
| - layer()->SetOpacity(0.f); |
| + if (impl_) |
| + impl_->HideView(direction); |
| } |
| void SlideOutView::OnImplicitAnimationsCompleted() { |