| OLD | NEW |
| 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_tray.h" | 5 #include "ash/system/web_notification/web_notification_tray.h" |
| 6 | 6 |
| 7 #include "ash/system/status_area_widget.h" | 7 #include "ash/system/status_area_widget.h" |
| 8 #include "ash/system/tray/tray_bubble_view.h" | 8 #include "ash/system/tray/tray_bubble_view.h" |
| 9 #include "ash/system/tray/tray_constants.h" | 9 #include "ash/system/tray/tray_constants.h" |
| 10 #include "ash/system/tray/tray_views.h" | 10 #include "ash/system/tray/tray_views.h" |
| (...skipping 474 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 485 // views::View overrides. | 485 // views::View overrides. |
| 486 virtual bool OnMousePressed(const ui::MouseEvent& event) OVERRIDE { | 486 virtual bool OnMousePressed(const ui::MouseEvent& event) OVERRIDE { |
| 487 if (event.flags() & ui::EF_RIGHT_MOUSE_BUTTON) { | 487 if (event.flags() & ui::EF_RIGHT_MOUSE_BUTTON) { |
| 488 ShowMenu(event.location()); | 488 ShowMenu(event.location()); |
| 489 return true; | 489 return true; |
| 490 } | 490 } |
| 491 tray_->OnClicked(notification_.id); | 491 tray_->OnClicked(notification_.id); |
| 492 return true; | 492 return true; |
| 493 } | 493 } |
| 494 | 494 |
| 495 virtual ui::GestureStatus OnGestureEvent( | 495 virtual ui::EventResult OnGestureEvent( |
| 496 const ui::GestureEvent& event) OVERRIDE { | 496 const ui::GestureEvent& event) OVERRIDE { |
| 497 if (event.type() == ui::ET_GESTURE_TAP) { | 497 if (event.type() == ui::ET_GESTURE_TAP) { |
| 498 tray_->OnClicked(notification_.id); | 498 tray_->OnClicked(notification_.id); |
| 499 return ui::GESTURE_STATUS_CONSUMED; | 499 return ui::ER_CONSUMED; |
| 500 } | 500 } |
| 501 | 501 |
| 502 if (event.type() == ui::ET_GESTURE_LONG_PRESS) { | 502 if (event.type() == ui::ET_GESTURE_LONG_PRESS) { |
| 503 ShowMenu(event.location()); | 503 ShowMenu(event.location()); |
| 504 return ui::GESTURE_STATUS_CONSUMED; | 504 return ui::ER_CONSUMED; |
| 505 } | 505 } |
| 506 | 506 |
| 507 if (event.type() == ui::ET_SCROLL_FLING_START) { | 507 if (event.type() == ui::ET_SCROLL_FLING_START) { |
| 508 // The threshold for the fling velocity is computed empirically. | 508 // The threshold for the fling velocity is computed empirically. |
| 509 // The unit is in pixels/second. | 509 // The unit is in pixels/second. |
| 510 const float kFlingThresholdForClose = 800.f; | 510 const float kFlingThresholdForClose = 800.f; |
| 511 if (fabsf(event.details().velocity_x()) > kFlingThresholdForClose) { | 511 if (fabsf(event.details().velocity_x()) > kFlingThresholdForClose) { |
| 512 SlideOutAndClose(event.details().velocity_x() < 0 ? SLIDE_LEFT : | 512 SlideOutAndClose(event.details().velocity_x() < 0 ? SLIDE_LEFT : |
| 513 SLIDE_RIGHT); | 513 SLIDE_RIGHT); |
| 514 } else if (scroller_) { | 514 } else if (scroller_) { |
| 515 RestoreVisualState(); | 515 RestoreVisualState(); |
| 516 scroller_->OnGestureEvent(event); | 516 scroller_->OnGestureEvent(event); |
| 517 } | 517 } |
| 518 return ui::GESTURE_STATUS_CONSUMED; | 518 return ui::ER_CONSUMED; |
| 519 } | 519 } |
| 520 | 520 |
| 521 if (!event.IsScrollGestureEvent()) | 521 if (!event.IsScrollGestureEvent()) |
| 522 return ui::GESTURE_STATUS_UNKNOWN; | 522 return ui::ER_UNHANDLED; |
| 523 | 523 |
| 524 if (event.type() == ui::ET_GESTURE_SCROLL_BEGIN) { | 524 if (event.type() == ui::ET_GESTURE_SCROLL_BEGIN) { |
| 525 gesture_scroll_amount_ = 0.f; | 525 gesture_scroll_amount_ = 0.f; |
| 526 } else if (event.type() == ui::ET_GESTURE_SCROLL_UPDATE) { | 526 } else if (event.type() == ui::ET_GESTURE_SCROLL_UPDATE) { |
| 527 // The scroll-update events include the incremental scroll amount. | 527 // The scroll-update events include the incremental scroll amount. |
| 528 gesture_scroll_amount_ += event.details().scroll_x(); | 528 gesture_scroll_amount_ += event.details().scroll_x(); |
| 529 | 529 |
| 530 ui::Transform transform; | 530 ui::Transform transform; |
| 531 transform.SetTranslateX(gesture_scroll_amount_); | 531 transform.SetTranslateX(gesture_scroll_amount_); |
| 532 layer()->SetTransform(transform); | 532 layer()->SetTransform(transform); |
| 533 layer()->SetOpacity( | 533 layer()->SetOpacity( |
| 534 1.f - std::min(fabsf(gesture_scroll_amount_) / width(), 1.f)); | 534 1.f - std::min(fabsf(gesture_scroll_amount_) / width(), 1.f)); |
| 535 | 535 |
| 536 } else if (event.type() == ui::ET_GESTURE_SCROLL_END) { | 536 } else if (event.type() == ui::ET_GESTURE_SCROLL_END) { |
| 537 const float kScrollRatioForClosingNotification = 0.5f; | 537 const float kScrollRatioForClosingNotification = 0.5f; |
| 538 float scrolled_ratio = fabsf(gesture_scroll_amount_) / width(); | 538 float scrolled_ratio = fabsf(gesture_scroll_amount_) / width(); |
| 539 if (scrolled_ratio >= kScrollRatioForClosingNotification) | 539 if (scrolled_ratio >= kScrollRatioForClosingNotification) |
| 540 SlideOutAndClose(gesture_scroll_amount_ < 0 ? SLIDE_LEFT : SLIDE_RIGHT); | 540 SlideOutAndClose(gesture_scroll_amount_ < 0 ? SLIDE_LEFT : SLIDE_RIGHT); |
| 541 else | 541 else |
| 542 RestoreVisualState(); | 542 RestoreVisualState(); |
| 543 } | 543 } |
| 544 | 544 |
| 545 if (scroller_) | 545 if (scroller_) |
| 546 scroller_->OnGestureEvent(event); | 546 scroller_->OnGestureEvent(event); |
| 547 return ui::GESTURE_STATUS_CONSUMED; | 547 return ui::ER_CONSUMED; |
| 548 } | 548 } |
| 549 | 549 |
| 550 // Overridden from ButtonListener. | 550 // Overridden from ButtonListener. |
| 551 virtual void ButtonPressed(views::Button* sender, | 551 virtual void ButtonPressed(views::Button* sender, |
| 552 const ui::Event& event) OVERRIDE { | 552 const ui::Event& event) OVERRIDE { |
| 553 if (sender == close_button_) | 553 if (sender == close_button_) |
| 554 tray_->SendRemoveNotification(notification_.id); | 554 tray_->SendRemoveNotification(notification_.id); |
| 555 } | 555 } |
| 556 | 556 |
| 557 // Overridden from ImplicitAnimationObserver. | 557 // Overridden from ImplicitAnimationObserver. |
| (...skipping 839 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1397 return message_center_bubble()->MessageViewsForTest(); | 1397 return message_center_bubble()->MessageViewsForTest(); |
| 1398 } | 1398 } |
| 1399 | 1399 |
| 1400 size_t WebNotificationTray::GetPopupNotificationCountForTest() const { | 1400 size_t WebNotificationTray::GetPopupNotificationCountForTest() const { |
| 1401 if (!popup_bubble()) | 1401 if (!popup_bubble()) |
| 1402 return 0; | 1402 return 0; |
| 1403 return popup_bubble()->MessageViewsForTest(); | 1403 return popup_bubble()->MessageViewsForTest(); |
| 1404 } | 1404 } |
| 1405 | 1405 |
| 1406 } // namespace ash | 1406 } // namespace ash |
| OLD | NEW |