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 "ui/message_center/views/notification_view.h" | 5 #include "ui/message_center/views/notification_view.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/strings/string_util.h" | 8 #include "base/strings/string_util.h" |
9 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
10 #include "grit/ui_resources.h" | 10 #include "grit/ui_resources.h" |
(...skipping 10 matching lines...) Expand all Loading... |
21 #include "ui/message_center/notification.h" | 21 #include "ui/message_center/notification.h" |
22 #include "ui/message_center/notification_types.h" | 22 #include "ui/message_center/notification_types.h" |
23 #include "ui/message_center/views/bounded_label.h" | 23 #include "ui/message_center/views/bounded_label.h" |
24 #include "ui/native_theme/native_theme.h" | 24 #include "ui/native_theme/native_theme.h" |
25 #include "ui/views/controls/button/image_button.h" | 25 #include "ui/views/controls/button/image_button.h" |
26 #include "ui/views/controls/image_view.h" | 26 #include "ui/views/controls/image_view.h" |
27 #include "ui/views/controls/label.h" | 27 #include "ui/views/controls/label.h" |
28 #include "ui/views/controls/progress_bar.h" | 28 #include "ui/views/controls/progress_bar.h" |
29 #include "ui/views/layout/box_layout.h" | 29 #include "ui/views/layout/box_layout.h" |
30 #include "ui/views/layout/fill_layout.h" | 30 #include "ui/views/layout/fill_layout.h" |
| 31 #include "ui/views/rect_based_targeting_utils.h" |
31 #include "ui/views/widget/widget.h" | 32 #include "ui/views/widget/widget.h" |
32 | 33 |
33 #if defined(USE_AURA) | 34 #if defined(USE_AURA) |
34 #include "ui/base/cursor/cursor.h" | 35 #include "ui/base/cursor/cursor.h" |
35 #endif | 36 #endif |
36 | 37 |
37 namespace { | 38 namespace { |
38 | 39 |
39 // Dimensions. | 40 // Dimensions. |
40 const int kIconSize = message_center::kNotificationIconSize; | 41 const int kIconSize = message_center::kNotificationIconSize; |
(...skipping 645 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
686 MessageView::OnFocus(); | 687 MessageView::OnFocus(); |
687 ScrollRectToVisible(GetLocalBounds()); | 688 ScrollRectToVisible(GetLocalBounds()); |
688 } | 689 } |
689 | 690 |
690 void NotificationView::ScrollRectToVisible(const gfx::Rect& rect) { | 691 void NotificationView::ScrollRectToVisible(const gfx::Rect& rect) { |
691 // Notification want to show the whole notification when a part of it (like | 692 // Notification want to show the whole notification when a part of it (like |
692 // a button) gets focused. | 693 // a button) gets focused. |
693 views::View::ScrollRectToVisible(GetLocalBounds()); | 694 views::View::ScrollRectToVisible(GetLocalBounds()); |
694 } | 695 } |
695 | 696 |
696 views::View* NotificationView::GetEventHandlerForPoint( | 697 views::View* NotificationView::GetEventHandlerForRect(const gfx::Rect& rect) { |
697 const gfx::Point& point) { | 698 if (!views::UsePointBasedTargeting(rect)) |
| 699 return views::View::GetEventHandlerForRect(rect); |
| 700 |
698 // Want to return this for underlying views, otherwise GetCursor is not | 701 // Want to return this for underlying views, otherwise GetCursor is not |
699 // called. But buttons are exceptions, they'll have their own event handlings. | 702 // called. But buttons are exceptions, they'll have their own event handlings. |
700 std::vector<views::View*> buttons(action_buttons_); | 703 std::vector<views::View*> buttons(action_buttons_); |
701 buttons.push_back(close_button()); | 704 buttons.push_back(close_button()); |
702 buttons.push_back(expand_button()); | 705 buttons.push_back(expand_button()); |
703 | 706 |
704 for (size_t i = 0; i < buttons.size(); ++i) { | 707 for (size_t i = 0; i < buttons.size(); ++i) { |
705 gfx::Point point_in_child = point; | 708 gfx::Rect rect_in_child = rect; |
706 ConvertPointToTarget(this, buttons[i], &point_in_child); | 709 ConvertRectToTarget(this, buttons[i], &rect_in_child); |
707 if (buttons[i]->HitTestPoint(point_in_child)) | 710 if (buttons[i]->HitTestRect(rect_in_child)) |
708 return buttons[i]->GetEventHandlerForPoint(point_in_child); | 711 return buttons[i]->GetEventHandlerForRect(rect_in_child); |
709 } | 712 } |
710 | 713 |
711 return this; | 714 return this; |
712 } | 715 } |
713 | 716 |
714 gfx::NativeCursor NotificationView::GetCursor(const ui::MouseEvent& event) { | 717 gfx::NativeCursor NotificationView::GetCursor(const ui::MouseEvent& event) { |
715 if (!message_center()->HasClickedListener(notification_id())) | 718 if (!message_center()->HasClickedListener(notification_id())) |
716 return views::View::GetCursor(event); | 719 return views::View::GetCursor(event); |
717 | 720 |
718 #if defined(USE_AURA) | 721 #if defined(USE_AURA) |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
788 return message_view_ ? | 791 return message_view_ ? |
789 message_view_->GetLinesForWidthAndLimit(width, limit) : 0; | 792 message_view_->GetLinesForWidthAndLimit(width, limit) : 0; |
790 } | 793 } |
791 | 794 |
792 int NotificationView::GetMessageHeight(int width, int limit) { | 795 int NotificationView::GetMessageHeight(int width, int limit) { |
793 return message_view_ ? | 796 return message_view_ ? |
794 message_view_->GetSizeForWidthAndLines(width, limit).height() : 0; | 797 message_view_->GetSizeForWidthAndLines(width, limit).height() : 0; |
795 } | 798 } |
796 | 799 |
797 } // namespace message_center | 800 } // namespace message_center |
OLD | NEW |