Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(381)

Unified Diff: ui/views/controls/slide_out_view_impl_aura.cc

Issue 11836003: Allow message center and related bubbles to render on Windows. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Remove ifdefs. Created 7 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: ui/views/controls/slide_out_view_impl_aura.cc
diff --git a/ui/views/controls/slide_out_view_impl_aura.cc b/ui/views/controls/slide_out_view_impl_aura.cc
new file mode 100644
index 0000000000000000000000000000000000000000..b91b90a7c3d66dcec568ccc69b06004fe3fb73f1
--- /dev/null
+++ b/ui/views/controls/slide_out_view_impl_aura.cc
@@ -0,0 +1,57 @@
+// 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 "ui/views/controls/slide_out_view_impl.h"
+
+#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.h"
+
+namespace views {
+
+SlideOutViewImpl::SlideOutViewImpl(SlideOutView* view)
+ : view_(view) {
+ view->SetPaintToLayer(true);
+ view->SetFillsBoundsOpaquely(false);
+}
+
+SlideOutViewImpl::~SlideOutViewImpl() {
+}
+
+void SlideOutViewImpl::TransformView(float scroll_amount) {
+ gfx::Transform transform;
msw 2013/01/17 02:28:30 Perhaps it's just me, but I'd rather see these imp
sadrul 2013/01/17 03:27:22 I agree. That would be simpler.
dewittj 2013/01/17 21:25:18 Done.
+ transform.Translate(scroll_amount, 0.0);
+ view_->layer()->SetTransform(transform);
+ view_->layer()->SetOpacity(
+ 1.f - std::min(fabsf(scroll_amount) / view_->width(), 1.f));
+}
+
+void SlideOutViewImpl::RestoreView() {
+ const int kSwipeRestoreDurationMS = 150;
+ ui::ScopedLayerAnimationSettings settings(view_->layer()->GetAnimator());
+ settings.SetTransitionDuration(
+ base::TimeDelta::FromMilliseconds(kSwipeRestoreDurationMS));
+ view_->layer()->SetTransform(gfx::Transform());
+ view_->layer()->SetOpacity(1.f);
+}
+
+void SlideOutViewImpl::HideView(SlideOutView::SlideDirection direction) {
+ const int kSwipeOutTotalDurationMS = 150;
+ int swipe_out_duration = kSwipeOutTotalDurationMS * view_->layer()->opacity();
+ ui::ScopedLayerAnimationSettings settings(view_->layer()->GetAnimator());
+ settings.SetTransitionDuration(
+ base::TimeDelta::FromMilliseconds(swipe_out_duration));
+ settings.AddObserver(view_);
+
+ gfx::Transform transform;
+ if (direction == SlideOutView::SLIDE_LEFT)
+ transform.Translate(-view_->width(), 0.0);
+ else
+ transform.Translate(view_->width(), 0.0);
+ view_->layer()->SetTransform(transform);
+ view_->layer()->SetOpacity(0.f);
+}
+
+} // namespace views

Powered by Google App Engine
This is Rietveld 408576698