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

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

Issue 145033006: views: Make View::set_border() take a scoped_ptr<>. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Remove ClearBorder() Created 6 years, 11 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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_button.h" 5 #include "ui/message_center/views/notification_button.h"
6 6
7 #include "ui/gfx/canvas.h" 7 #include "ui/gfx/canvas.h"
8 #include "ui/message_center/message_center_style.h" 8 #include "ui/message_center/message_center_style.h"
9 #include "ui/message_center/views/constants.h" 9 #include "ui/message_center/views/constants.h"
10 #include "ui/views/background.h" 10 #include "ui/views/background.h"
(...skipping 30 matching lines...) Expand all
41 delete icon_; // This removes the icon from this view's children. 41 delete icon_; // This removes the icon from this view's children.
42 if (image.isNull()) { 42 if (image.isNull()) {
43 icon_ = NULL; 43 icon_ = NULL;
44 } else { 44 } else {
45 icon_ = new views::ImageView(); 45 icon_ = new views::ImageView();
46 icon_->SetImageSize(gfx::Size(message_center::kNotificationButtonIconSize, 46 icon_->SetImageSize(gfx::Size(message_center::kNotificationButtonIconSize,
47 message_center::kNotificationButtonIconSize)); 47 message_center::kNotificationButtonIconSize));
48 icon_->SetImage(image); 48 icon_->SetImage(image);
49 icon_->SetHorizontalAlignment(views::ImageView::LEADING); 49 icon_->SetHorizontalAlignment(views::ImageView::LEADING);
50 icon_->SetVerticalAlignment(views::ImageView::LEADING); 50 icon_->SetVerticalAlignment(views::ImageView::LEADING);
51 icon_->set_border(views::Border::CreateEmptyBorder( 51 icon_->SetBorder(views::Border::CreateEmptyBorder(
52 message_center::kButtonIconTopPadding, 0, 0, 0)); 52 message_center::kButtonIconTopPadding, 0, 0, 0));
53 AddChildViewAt(icon_, 0); 53 AddChildViewAt(icon_, 0);
54 } 54 }
55 } 55 }
56 56
57 void NotificationButton::SetTitle(const base::string16& title) { 57 void NotificationButton::SetTitle(const base::string16& title) {
58 if (title_ != NULL) 58 if (title_ != NULL)
59 delete title_; // This removes the title from this view's children. 59 delete title_; // This removes the title from this view's children.
60 if (title.empty()) { 60 if (title.empty()) {
61 title_ = NULL; 61 title_ = NULL;
62 } else { 62 } else {
63 title_ = new views::Label(title); 63 title_ = new views::Label(title);
64 title_->SetHorizontalAlignment(gfx::ALIGN_LEFT); 64 title_->SetHorizontalAlignment(gfx::ALIGN_LEFT);
65 title_->SetEnabledColor(message_center::kRegularTextColor); 65 title_->SetEnabledColor(message_center::kRegularTextColor);
66 title_->SetBackgroundColor(kRegularTextBackgroundColor); 66 title_->SetBackgroundColor(kRegularTextBackgroundColor);
67 title_->set_border(views::Border::CreateEmptyBorder( 67 title_->SetBorder(
68 kButtonTitleTopPadding, 0, 0, 0)); 68 views::Border::CreateEmptyBorder(kButtonTitleTopPadding, 0, 0, 0));
69 AddChildView(title_); 69 AddChildView(title_);
70 } 70 }
71 SetAccessibleName(title); 71 SetAccessibleName(title);
72 } 72 }
73 73
74 gfx::Size NotificationButton::GetPreferredSize() { 74 gfx::Size NotificationButton::GetPreferredSize() {
75 return gfx::Size(message_center::kNotificationWidth, 75 return gfx::Size(message_center::kNotificationWidth,
76 message_center::kButtonHeight); 76 message_center::kButtonHeight);
77 } 77 }
78 78
(...skipping 22 matching lines...) Expand all
101 void NotificationButton::StateChanged() { 101 void NotificationButton::StateChanged() {
102 if (state() == STATE_HOVERED || state() == STATE_PRESSED) { 102 if (state() == STATE_HOVERED || state() == STATE_PRESSED) {
103 set_background(views::Background::CreateSolidBackground( 103 set_background(views::Background::CreateSolidBackground(
104 message_center::kHoveredButtonBackgroundColor)); 104 message_center::kHoveredButtonBackgroundColor));
105 } else { 105 } else {
106 set_background(NULL); 106 set_background(NULL);
107 } 107 }
108 } 108 }
109 109
110 } // namespace message_center 110 } // namespace message_center
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698