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

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

Issue 2480813003: Reduce views::Border creation verbosity by promoting factory functions (Closed)
Patch Set: fix bad merge Created 4 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
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 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
44 delete icon_; // This removes the icon from this view's children. 44 delete icon_; // This removes the icon from this view's children.
45 if (image.isNull()) { 45 if (image.isNull()) {
46 icon_ = NULL; 46 icon_ = NULL;
47 } else { 47 } else {
48 icon_ = new views::ImageView(); 48 icon_ = new views::ImageView();
49 icon_->SetImageSize(gfx::Size(message_center::kNotificationButtonIconSize, 49 icon_->SetImageSize(gfx::Size(message_center::kNotificationButtonIconSize,
50 message_center::kNotificationButtonIconSize)); 50 message_center::kNotificationButtonIconSize));
51 icon_->SetImage(image); 51 icon_->SetImage(image);
52 icon_->SetHorizontalAlignment(views::ImageView::LEADING); 52 icon_->SetHorizontalAlignment(views::ImageView::LEADING);
53 icon_->SetVerticalAlignment(views::ImageView::LEADING); 53 icon_->SetVerticalAlignment(views::ImageView::LEADING);
54 icon_->SetBorder(views::Border::CreateEmptyBorder( 54 icon_->SetBorder(views::CreateEmptyBorder(
55 message_center::kButtonIconTopPadding, 0, 0, 0)); 55 message_center::kButtonIconTopPadding, 0, 0, 0));
56 AddChildViewAt(icon_, 0); 56 AddChildViewAt(icon_, 0);
57 } 57 }
58 } 58 }
59 59
60 void NotificationButton::SetTitle(const base::string16& title) { 60 void NotificationButton::SetTitle(const base::string16& title) {
61 if (title_ != NULL) 61 if (title_ != NULL)
62 delete title_; // This removes the title from this view's children. 62 delete title_; // This removes the title from this view's children.
63 if (title.empty()) { 63 if (title.empty()) {
64 title_ = NULL; 64 title_ = NULL;
65 } else { 65 } else {
66 title_ = new views::Label(title); 66 title_ = new views::Label(title);
67 title_->SetHorizontalAlignment(gfx::ALIGN_LEFT); 67 title_->SetHorizontalAlignment(gfx::ALIGN_LEFT);
68 title_->SetEnabledColor(message_center::kRegularTextColor); 68 title_->SetEnabledColor(message_center::kRegularTextColor);
69 title_->SetBackgroundColor(kRegularTextBackgroundColor); 69 title_->SetBackgroundColor(kRegularTextBackgroundColor);
70 title_->SetBorder( 70 title_->SetBorder(
71 views::Border::CreateEmptyBorder(kButtonTitleTopPadding, 0, 0, 0)); 71 views::CreateEmptyBorder(kButtonTitleTopPadding, 0, 0, 0));
72 AddChildView(title_); 72 AddChildView(title_);
73 } 73 }
74 SetAccessibleName(title); 74 SetAccessibleName(title);
75 } 75 }
76 76
77 gfx::Size NotificationButton::GetPreferredSize() const { 77 gfx::Size NotificationButton::GetPreferredSize() const {
78 return gfx::Size(message_center::kNotificationWidth, 78 return gfx::Size(message_center::kNotificationWidth,
79 message_center::kButtonHeight); 79 message_center::kButtonHeight);
80 } 80 }
81 81
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
113 if (state() == STATE_HOVERED || state() == STATE_PRESSED) { 113 if (state() == STATE_HOVERED || state() == STATE_PRESSED) {
114 set_background(views::Background::CreateSolidBackground( 114 set_background(views::Background::CreateSolidBackground(
115 message_center::kHoveredButtonBackgroundColor)); 115 message_center::kHoveredButtonBackgroundColor));
116 } else { 116 } else {
117 set_background(views::Background::CreateSolidBackground( 117 set_background(views::Background::CreateSolidBackground(
118 kNotificationBackgroundColor)); 118 kNotificationBackgroundColor));
119 } 119 }
120 } 120 }
121 121
122 } // namespace message_center 122 } // namespace message_center
OLDNEW
« no previous file with comments | « ui/message_center/views/message_list_view.cc ('k') | ui/message_center/views/notification_view.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698