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

Unified Diff: ui/views/controls/slide_out_view.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: Take out Impl, address nits. 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
« no previous file with comments | « ui/views/controls/slide_out_view.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..648ff0994645090ebd35584cfe52001170423dd9 100644
--- a/ui/views/controls/slide_out_view.cc
+++ b/ui/views/controls/slide_out_view.cc
@@ -12,8 +12,11 @@ namespace views {
SlideOutView::SlideOutView()
: gesture_scroll_amount_(0.f) {
- SetPaintToLayer(true);
- SetFillsBoundsOpaquely(false);
+ // Only use accelerated compositing when it is available on the platform.
msw 2013/01/17 22:45:39 nit: this comment seems redundant, but it's okay i
dewittj 2013/01/18 18:30:48 Changed it to be more helpful.
+ if (get_use_acceleration_when_possible()) {
+ SetPaintToLayer(true);
+ SetFillsBoundsOpaquely(false);
+ }
}
SlideOutView::~SlideOutView() {
@@ -43,11 +46,14 @@ 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 (get_use_acceleration_when_possible()) {
+ 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));
+ }
+
} else if (event->type() == ui::ET_GESTURE_SCROLL_END) {
const float kScrollRatioForClosingNotification = 0.5f;
float scrolled_ratio = fabsf(gesture_scroll_amount_) / width();
@@ -64,26 +70,33 @@ void SlideOutView::OnGestureEvent(ui::GestureEvent* event) {
void SlideOutView::RestoreVisualState() {
// Restore the layer state.
sadrul 2013/01/18 17:53:11 Move the comment inside the if. You could also ea
dewittj 2013/01/18 18:30:48 Done.
- const int kSwipeRestoreDurationMS = 150;
- ui::ScopedLayerAnimationSettings settings(layer()->GetAnimator());
- settings.SetTransitionDuration(
- base::TimeDelta::FromMilliseconds(kSwipeRestoreDurationMS));
- layer()->SetTransform(gfx::Transform());
- layer()->SetOpacity(1.f);
+ if (get_use_acceleration_when_possible()) {
+ const int kSwipeRestoreDurationMS = 150;
+ ui::ScopedLayerAnimationSettings settings(layer()->GetAnimator());
+ settings.SetTransitionDuration(
+ base::TimeDelta::FromMilliseconds(kSwipeRestoreDurationMS));
+ layer()->SetTransform(gfx::Transform());
+ layer()->SetOpacity(1.f);
+ }
}
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 (get_use_acceleration_when_possible()) {
+ 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);
+ } else {
+ // No animations, so don't wait to fire the OnSlideOut event.
+ OnSlideOut();
+ }
}
void SlideOutView::OnImplicitAnimationsCompleted() {
« no previous file with comments | « ui/views/controls/slide_out_view.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698