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

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: patch for landing Created 7 years, 1 month 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
« no previous file with comments | « ui/message_center/views/notification_view.h ('k') | ui/views/view.h » ('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 "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 677 matching lines...) Expand 10 before | Expand all | Expand 10 after
688 MessageView::OnFocus(); 688 MessageView::OnFocus();
689 ScrollRectToVisible(GetLocalBounds()); 689 ScrollRectToVisible(GetLocalBounds());
690 } 690 }
691 691
692 void NotificationView::ScrollRectToVisible(const gfx::Rect& rect) { 692 void NotificationView::ScrollRectToVisible(const gfx::Rect& rect) {
693 // Notification want to show the whole notification when a part of it (like 693 // Notification want to show the whole notification when a part of it (like
694 // a button) gets focused. 694 // a button) gets focused.
695 views::View::ScrollRectToVisible(GetLocalBounds()); 695 views::View::ScrollRectToVisible(GetLocalBounds());
696 } 696 }
697 697
698 views::View* NotificationView::GetEventHandlerForPoint( 698 views::View* NotificationView::GetEventHandlerForRect(const gfx::Rect& rect) {
699 const gfx::Point& point) { 699 // TODO(tdanderson): Modify this function to support rect-based event
700 // targeting. Using the center point of |rect| preserves this function's
701 // expected behavior for the time being.
702 gfx::Point point = rect.CenterPoint();
703
700 // Want to return this for underlying views, otherwise GetCursor is not 704 // Want to return this for underlying views, otherwise GetCursor is not
701 // called. But buttons are exceptions, they'll have their own event handlings. 705 // called. But buttons are exceptions, they'll have their own event handlings.
702 std::vector<views::View*> buttons(action_buttons_); 706 std::vector<views::View*> buttons(action_buttons_);
703 buttons.push_back(close_button()); 707 buttons.push_back(close_button());
704 buttons.push_back(expand_button()); 708 buttons.push_back(expand_button());
705 709
706 for (size_t i = 0; i < buttons.size(); ++i) { 710 for (size_t i = 0; i < buttons.size(); ++i) {
707 gfx::Point point_in_child = point; 711 gfx::Point point_in_child = point;
708 ConvertPointToTarget(this, buttons[i], &point_in_child); 712 ConvertPointToTarget(this, buttons[i], &point_in_child);
709 if (buttons[i]->HitTestPoint(point_in_child)) 713 if (buttons[i]->HitTestPoint(point_in_child))
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
790 return message_view_ ? 794 return message_view_ ?
791 message_view_->GetLinesForWidthAndLimit(width, limit) : 0; 795 message_view_->GetLinesForWidthAndLimit(width, limit) : 0;
792 } 796 }
793 797
794 int NotificationView::GetMessageHeight(int width, int limit) { 798 int NotificationView::GetMessageHeight(int width, int limit) {
795 return message_view_ ? 799 return message_view_ ?
796 message_view_->GetSizeForWidthAndLines(width, limit).height() : 0; 800 message_view_->GetSizeForWidthAndLines(width, limit).height() : 0;
797 } 801 }
798 802
799 } // namespace message_center 803 } // namespace message_center
OLDNEW
« no previous file with comments | « ui/message_center/views/notification_view.h ('k') | ui/views/view.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698