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 <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/macros.h" | 10 #include "base/macros.h" |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
56 | 56 |
57 namespace { | 57 namespace { |
58 | 58 |
59 // Dimensions. | 59 // Dimensions. |
60 const int kProgressBarBottomPadding = 0; | 60 const int kProgressBarBottomPadding = 0; |
61 | 61 |
62 const int kCloseIconTopPadding = 5; | 62 const int kCloseIconTopPadding = 5; |
63 const int kCloseIconRightPadding = 5; | 63 const int kCloseIconRightPadding = 5; |
64 | 64 |
65 // static | 65 // static |
66 scoped_ptr<views::Border> MakeEmptyBorder(int top, | 66 std::unique_ptr<views::Border> MakeEmptyBorder(int top, |
67 int left, | 67 int left, |
68 int bottom, | 68 int bottom, |
69 int right) { | 69 int right) { |
70 return views::Border::CreateEmptyBorder(top, left, bottom, right); | 70 return views::Border::CreateEmptyBorder(top, left, bottom, right); |
71 } | 71 } |
72 | 72 |
73 // static | 73 // static |
74 scoped_ptr<views::Border> MakeTextBorder(int padding, int top, int bottom) { | 74 std::unique_ptr<views::Border> MakeTextBorder(int padding, |
| 75 int top, |
| 76 int bottom) { |
75 // Split the padding between the top and the bottom, then add the extra space. | 77 // Split the padding between the top and the bottom, then add the extra space. |
76 return MakeEmptyBorder(padding / 2 + top, | 78 return MakeEmptyBorder(padding / 2 + top, |
77 message_center::kTextLeftPadding, | 79 message_center::kTextLeftPadding, |
78 (padding + 1) / 2 + bottom, | 80 (padding + 1) / 2 + bottom, |
79 message_center::kTextRightPadding); | 81 message_center::kTextRightPadding); |
80 } | 82 } |
81 | 83 |
82 // static | 84 // static |
83 scoped_ptr<views::Border> MakeProgressBarBorder(int top, int bottom) { | 85 std::unique_ptr<views::Border> MakeProgressBarBorder(int top, int bottom) { |
84 return MakeEmptyBorder(top, | 86 return MakeEmptyBorder(top, |
85 message_center::kTextLeftPadding, | 87 message_center::kTextLeftPadding, |
86 bottom, | 88 bottom, |
87 message_center::kTextRightPadding); | 89 message_center::kTextRightPadding); |
88 } | 90 } |
89 | 91 |
90 // static | 92 // static |
91 scoped_ptr<views::Border> MakeSeparatorBorder(int top, | 93 std::unique_ptr<views::Border> MakeSeparatorBorder(int top, |
92 int left, | 94 int left, |
93 SkColor color) { | 95 SkColor color) { |
94 return views::Border::CreateSolidSidedBorder(top, left, 0, 0, color); | 96 return views::Border::CreateSolidSidedBorder(top, left, 0, 0, color); |
95 } | 97 } |
96 | 98 |
97 // ItemView //////////////////////////////////////////////////////////////////// | 99 // ItemView //////////////////////////////////////////////////////////////////// |
98 | 100 |
99 // ItemViews are responsible for drawing each list notification item's title and | 101 // ItemViews are responsible for drawing each list notification item's title and |
100 // message next to each other within a single column. | 102 // message next to each other within a single column. |
101 class ItemView : public views::View { | 103 class ItemView : public views::View { |
102 public: | 104 public: |
103 ItemView(const message_center::NotificationItem& item); | 105 ItemView(const message_center::NotificationItem& item); |
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
283 CreateOrUpdateViews(notification); | 285 CreateOrUpdateViews(notification); |
284 | 286 |
285 // Put together the different content and control views. Layering those allows | 287 // Put together the different content and control views. Layering those allows |
286 // for proper layout logic and it also allows the close button and small | 288 // for proper layout logic and it also allows the close button and small |
287 // image to overlap the content as needed to provide large enough click and | 289 // image to overlap the content as needed to provide large enough click and |
288 // touch areas (<http://crbug.com/168822> and <http://crbug.com/168856>). | 290 // touch areas (<http://crbug.com/168822> and <http://crbug.com/168856>). |
289 AddChildView(small_image()); | 291 AddChildView(small_image()); |
290 SetAccessibleName(notification); | 292 SetAccessibleName(notification); |
291 | 293 |
292 SetEventTargeter( | 294 SetEventTargeter( |
293 scoped_ptr<views::ViewTargeter>(new views::ViewTargeter(this))); | 295 std::unique_ptr<views::ViewTargeter>(new views::ViewTargeter(this))); |
294 } | 296 } |
295 | 297 |
296 NotificationView::~NotificationView() { | 298 NotificationView::~NotificationView() { |
297 } | 299 } |
298 | 300 |
299 gfx::Size NotificationView::GetPreferredSize() const { | 301 gfx::Size NotificationView::GetPreferredSize() const { |
300 int top_width = top_view_->GetPreferredSize().width() + | 302 int top_width = top_view_->GetPreferredSize().width() + |
301 icon_view_->GetPreferredSize().width(); | 303 icon_view_->GetPreferredSize().width(); |
302 int bottom_width = bottom_view_->GetPreferredSize().width(); | 304 int bottom_width = bottom_view_->GetPreferredSize().width(); |
303 int preferred_width = std::max(top_width, bottom_width) + GetInsets().width(); | 305 int preferred_width = std::max(top_width, bottom_width) + GetInsets().width(); |
(...skipping 534 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
838 void NotificationView::RequestFocusOnCloseButton() { | 840 void NotificationView::RequestFocusOnCloseButton() { |
839 if (close_button_) | 841 if (close_button_) |
840 close_button_->RequestFocus(); | 842 close_button_->RequestFocus(); |
841 } | 843 } |
842 | 844 |
843 bool NotificationView::IsPinned() { | 845 bool NotificationView::IsPinned() { |
844 return !close_button_; | 846 return !close_button_; |
845 } | 847 } |
846 | 848 |
847 } // namespace message_center | 849 } // namespace message_center |
OLD | NEW |