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

Side by Side Diff: ui/message_center/views/notification_view.cc

Issue 22891016: Add support for rect-based event targeting in views (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: comments addressed Created 7 years, 3 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 | Annotate | Revision Log
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 "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 667 matching lines...) Expand 10 before | Expand all | Expand 10 after
678 MessageView::OnFocus(); 678 MessageView::OnFocus();
679 ScrollRectToVisible(GetLocalBounds()); 679 ScrollRectToVisible(GetLocalBounds());
680 } 680 }
681 681
682 void NotificationView::ScrollRectToVisible(const gfx::Rect& rect) { 682 void NotificationView::ScrollRectToVisible(const gfx::Rect& rect) {
683 // Notification want to show the whole notification when a part of it (like 683 // Notification want to show the whole notification when a part of it (like
684 // a button) gets focused. 684 // a button) gets focused.
685 views::View::ScrollRectToVisible(GetLocalBounds()); 685 views::View::ScrollRectToVisible(GetLocalBounds());
686 } 686 }
687 687
688 views::View* NotificationView::GetEventHandlerForPoint( 688 views::View* NotificationView::GetEventHandlerForRect(const gfx::Rect& rect) {
689 const gfx::Point& point) { 689 if (!views::View::UsePointBasedTargeting(rect))
690 return views::View::GetEventHandlerForRect(rect);
691
690 // Want to return this for underlying views, otherwise GetCursor is not 692 // Want to return this for underlying views, otherwise GetCursor is not
691 // called. But buttons are exceptions, they'll have their own event handlings. 693 // called. But buttons are exceptions, they'll have their own event handlings.
692 std::vector<views::View*> buttons(action_buttons_); 694 std::vector<views::View*> buttons(action_buttons_);
693 buttons.push_back(close_button()); 695 buttons.push_back(close_button());
694 buttons.push_back(expand_button()); 696 buttons.push_back(expand_button());
695 697
696 for (size_t i = 0; i < buttons.size(); ++i) { 698 for (size_t i = 0; i < buttons.size(); ++i) {
697 gfx::Point point_in_child = point; 699 gfx::Rect rect_in_child = rect;
698 ConvertPointToTarget(this, buttons[i], &point_in_child); 700 ConvertRectToTarget(this, buttons[i], &rect_in_child);
699 if (buttons[i]->HitTestPoint(point_in_child)) 701 if (buttons[i]->HitTestRect(rect_in_child))
700 return buttons[i]->GetEventHandlerForPoint(point_in_child); 702 return buttons[i]->GetEventHandlerForRect(rect_in_child);
701 } 703 }
702 704
703 return this; 705 return this;
704 } 706 }
705 707
706 gfx::NativeCursor NotificationView::GetCursor(const ui::MouseEvent& event) { 708 gfx::NativeCursor NotificationView::GetCursor(const ui::MouseEvent& event) {
707 if (!message_center()->HasClickedListener(notification_id())) 709 if (!message_center()->HasClickedListener(notification_id()))
708 return views::View::GetCursor(event); 710 return views::View::GetCursor(event);
709 711
710 #if defined(USE_AURA) 712 #if defined(USE_AURA)
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
780 return message_view_ ? 782 return message_view_ ?
781 message_view_->GetLinesForWidthAndLimit(width, limit) : 0; 783 message_view_->GetLinesForWidthAndLimit(width, limit) : 0;
782 } 784 }
783 785
784 int NotificationView::GetMessageHeight(int width, int limit) { 786 int NotificationView::GetMessageHeight(int width, int limit) {
785 return message_view_ ? 787 return message_view_ ?
786 message_view_->GetSizeForWidthAndLines(width, limit).height() : 0; 788 message_view_->GetSizeForWidthAndLines(width, limit).height() : 0;
787 } 789 }
788 790
789 } // namespace message_center 791 } // namespace message_center
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698