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

Side by Side Diff: ash/system/web_notification/web_notification_view.cc

Issue 11145005: Migrate ui::Transform to gfx::Transform (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Hopefully should work this time Created 8 years, 2 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 unified diff | Download patch
« no previous file with comments | « ash/system/tray/tray_item_view.cc ('k') | ash/wm/gestures/long_press_affordance_handler.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ash/system/web_notification/web_notification_view.h" 5 #include "ash/system/web_notification/web_notification_view.h"
6 6
7 #include "ash/system/tray/tray_constants.h" 7 #include "ash/system/tray/tray_constants.h"
8 #include "ash/system/tray/tray_views.h" 8 #include "ash/system/tray/tray_views.h"
9 #include "ash/system/web_notification/web_notification.h" 9 #include "ash/system/web_notification/web_notification.h"
10 #include "ash/system/web_notification/web_notification_tray.h" 10 #include "ash/system/web_notification/web_notification_tray.h"
(...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after
238 238
239 if (!event.IsScrollGestureEvent()) 239 if (!event.IsScrollGestureEvent())
240 return ui::ER_UNHANDLED; 240 return ui::ER_UNHANDLED;
241 241
242 if (event.type() == ui::ET_GESTURE_SCROLL_BEGIN) { 242 if (event.type() == ui::ET_GESTURE_SCROLL_BEGIN) {
243 gesture_scroll_amount_ = 0.f; 243 gesture_scroll_amount_ = 0.f;
244 } else if (event.type() == ui::ET_GESTURE_SCROLL_UPDATE) { 244 } else if (event.type() == ui::ET_GESTURE_SCROLL_UPDATE) {
245 // The scroll-update events include the incremental scroll amount. 245 // The scroll-update events include the incremental scroll amount.
246 gesture_scroll_amount_ += event.details().scroll_x(); 246 gesture_scroll_amount_ += event.details().scroll_x();
247 247
248 ui::Transform transform; 248 gfx::Transform transform;
249 transform.SetTranslateX(gesture_scroll_amount_); 249 transform.SetTranslateX(gesture_scroll_amount_);
250 layer()->SetTransform(transform); 250 layer()->SetTransform(transform);
251 layer()->SetOpacity( 251 layer()->SetOpacity(
252 1.f - std::min(fabsf(gesture_scroll_amount_) / width(), 1.f)); 252 1.f - std::min(fabsf(gesture_scroll_amount_) / width(), 1.f));
253 253
254 } else if (event.type() == ui::ET_GESTURE_SCROLL_END) { 254 } else if (event.type() == ui::ET_GESTURE_SCROLL_END) {
255 const float kScrollRatioForClosingNotification = 0.5f; 255 const float kScrollRatioForClosingNotification = 0.5f;
256 float scrolled_ratio = fabsf(gesture_scroll_amount_) / width(); 256 float scrolled_ratio = fabsf(gesture_scroll_amount_) / width();
257 if (scrolled_ratio >= kScrollRatioForClosingNotification) 257 if (scrolled_ratio >= kScrollRatioForClosingNotification)
258 SlideOutAndClose(gesture_scroll_amount_ < 0 ? SLIDE_LEFT : SLIDE_RIGHT); 258 SlideOutAndClose(gesture_scroll_amount_ < 0 ? SLIDE_LEFT : SLIDE_RIGHT);
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
291 views::MenuItemView::TOPRIGHT, 291 views::MenuItemView::TOPRIGHT,
292 views::MenuRunner::HAS_MNEMONICS)); 292 views::MenuRunner::HAS_MNEMONICS));
293 } 293 }
294 294
295 void WebNotificationView::RestoreVisualState() { 295 void WebNotificationView::RestoreVisualState() {
296 // Restore the layer state. 296 // Restore the layer state.
297 const int kSwipeRestoreDurationMS = 150; 297 const int kSwipeRestoreDurationMS = 150;
298 ui::ScopedLayerAnimationSettings settings(layer()->GetAnimator()); 298 ui::ScopedLayerAnimationSettings settings(layer()->GetAnimator());
299 settings.SetTransitionDuration( 299 settings.SetTransitionDuration(
300 base::TimeDelta::FromMilliseconds(kSwipeRestoreDurationMS)); 300 base::TimeDelta::FromMilliseconds(kSwipeRestoreDurationMS));
301 layer()->SetTransform(ui::Transform()); 301 layer()->SetTransform(gfx::Transform());
302 layer()->SetOpacity(1.f); 302 layer()->SetOpacity(1.f);
303 } 303 }
304 304
305 void WebNotificationView::SlideOutAndClose(SlideDirection direction) { 305 void WebNotificationView::SlideOutAndClose(SlideDirection direction) {
306 const int kSwipeOutTotalDurationMS = 150; 306 const int kSwipeOutTotalDurationMS = 150;
307 int swipe_out_duration = kSwipeOutTotalDurationMS * layer()->opacity(); 307 int swipe_out_duration = kSwipeOutTotalDurationMS * layer()->opacity();
308 ui::ScopedLayerAnimationSettings settings(layer()->GetAnimator()); 308 ui::ScopedLayerAnimationSettings settings(layer()->GetAnimator());
309 settings.SetTransitionDuration( 309 settings.SetTransitionDuration(
310 base::TimeDelta::FromMilliseconds(swipe_out_duration)); 310 base::TimeDelta::FromMilliseconds(swipe_out_duration));
311 settings.AddObserver(this); 311 settings.AddObserver(this);
312 312
313 ui::Transform transform; 313 gfx::Transform transform;
314 transform.SetTranslateX(direction == SLIDE_LEFT ? -width() : width()); 314 transform.SetTranslateX(direction == SLIDE_LEFT ? -width() : width());
315 layer()->SetTransform(transform); 315 layer()->SetTransform(transform);
316 layer()->SetOpacity(0.f); 316 layer()->SetOpacity(0.f);
317 } 317 }
318 318
319 } // namespace message_center 319 } // namespace message_center
320 320
321 } // namespace ash 321 } // namespace ash
OLDNEW
« no previous file with comments | « ash/system/tray/tray_item_view.cc ('k') | ash/wm/gestures/long_press_affordance_handler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698