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

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: tab strip problems addressed Created 7 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 | 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 675 matching lines...) Expand 10 before | Expand all | Expand 10 after
686 MessageView::OnFocus(); 686 MessageView::OnFocus();
687 ScrollRectToVisible(GetLocalBounds()); 687 ScrollRectToVisible(GetLocalBounds());
688 } 688 }
689 689
690 void NotificationView::ScrollRectToVisible(const gfx::Rect& rect) { 690 void NotificationView::ScrollRectToVisible(const gfx::Rect& rect) {
691 // Notification want to show the whole notification when a part of it (like 691 // Notification want to show the whole notification when a part of it (like
692 // a button) gets focused. 692 // a button) gets focused.
693 views::View::ScrollRectToVisible(GetLocalBounds()); 693 views::View::ScrollRectToVisible(GetLocalBounds());
694 } 694 }
695 695
696 views::View* NotificationView::GetEventHandlerForPoint( 696 views::View* NotificationView::GetEventHandlerForRect(const gfx::Rect& rect) {
697 const gfx::Point& point) { 697 if (!views::View::UsePointBasedTargeting(rect))
698 return views::View::GetEventHandlerForRect(rect);
699
698 // Want to return this for underlying views, otherwise GetCursor is not 700 // Want to return this for underlying views, otherwise GetCursor is not
699 // called. But buttons are exceptions, they'll have their own event handlings. 701 // called. But buttons are exceptions, they'll have their own event handlings.
700 std::vector<views::View*> buttons(action_buttons_); 702 std::vector<views::View*> buttons(action_buttons_);
701 buttons.push_back(close_button()); 703 buttons.push_back(close_button());
702 buttons.push_back(expand_button()); 704 buttons.push_back(expand_button());
703 705
704 for (size_t i = 0; i < buttons.size(); ++i) { 706 for (size_t i = 0; i < buttons.size(); ++i) {
705 gfx::Point point_in_child = point; 707 gfx::Rect rect_in_child = rect;
706 ConvertPointToTarget(this, buttons[i], &point_in_child); 708 ConvertRectToTarget(this, buttons[i], &rect_in_child);
707 if (buttons[i]->HitTestPoint(point_in_child)) 709 if (buttons[i]->HitTestRect(rect_in_child))
708 return buttons[i]->GetEventHandlerForPoint(point_in_child); 710 return buttons[i]->GetEventHandlerForRect(rect_in_child);
709 } 711 }
710 712
711 return this; 713 return this;
712 } 714 }
713 715
714 gfx::NativeCursor NotificationView::GetCursor(const ui::MouseEvent& event) { 716 gfx::NativeCursor NotificationView::GetCursor(const ui::MouseEvent& event) {
715 if (!message_center()->HasClickedListener(notification_id())) 717 if (!message_center()->HasClickedListener(notification_id()))
716 return views::View::GetCursor(event); 718 return views::View::GetCursor(event);
717 719
718 #if defined(USE_AURA) 720 #if defined(USE_AURA)
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
788 return message_view_ ? 790 return message_view_ ?
789 message_view_->GetLinesForWidthAndLimit(width, limit) : 0; 791 message_view_->GetLinesForWidthAndLimit(width, limit) : 0;
790 } 792 }
791 793
792 int NotificationView::GetMessageHeight(int width, int limit) { 794 int NotificationView::GetMessageHeight(int width, int limit) {
793 return message_view_ ? 795 return message_view_ ?
794 message_view_->GetSizeForWidthAndLines(width, limit).height() : 0; 796 message_view_->GetSizeForWidthAndLines(width, limit).height() : 0;
795 } 797 }
796 798
797 } // namespace message_center 799 } // namespace message_center
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698