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

Side by Side Diff: ash/system/power/tray_power.cc

Issue 10411081: Fixup layout of power and sms notifications. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 7 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
« no previous file with comments | « ash/system/network/tray_sms.cc ('k') | ash/system/tray/tray_constants.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 "ash/system/power/tray_power.h" 5 #include "ash/system/power/tray_power.h"
6 6
7 #include "ash/ash_switches.h" 7 #include "ash/ash_switches.h"
8 #include "ash/shell.h" 8 #include "ash/shell.h"
9 #include "ash/system/date/date_view.h" 9 #include "ash/system/date/date_view.h"
10 #include "ash/system/power/power_supply_status.h" 10 #include "ash/system/power/power_supply_status.h"
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
124 // This view is used only for the popup. 124 // This view is used only for the popup.
125 class PowerStatusView : public views::View { 125 class PowerStatusView : public views::View {
126 public: 126 public:
127 enum ViewType { 127 enum ViewType {
128 VIEW_DEFAULT, 128 VIEW_DEFAULT,
129 VIEW_NOTIFICATION 129 VIEW_NOTIFICATION
130 }; 130 };
131 131
132 explicit PowerStatusView(ViewType view_type) { 132 explicit PowerStatusView(ViewType view_type) {
133 status_label_ = new views::Label; 133 status_label_ = new views::Label;
134 status_label_->SetHorizontalAlignment(views::Label::ALIGN_RIGHT); 134 status_label_->SetHorizontalAlignment(views::Label::ALIGN_LEFT);
135 time_label_ = new views::Label; 135 time_label_ = new views::Label;
136 time_label_->SetHorizontalAlignment(views::Label::ALIGN_RIGHT); 136 time_label_->SetHorizontalAlignment(views::Label::ALIGN_LEFT);
137 137
138 icon_ = new views::ImageView; 138 icon_ = new views::ImageView;
139 139
140 AddChildView(status_label_); 140 AddChildView(status_label_);
141 AddChildView(time_label_); 141 AddChildView(time_label_);
142 AddChildView(icon_); 142 AddChildView(icon_);
143 143
144 if (view_type == VIEW_DEFAULT) 144 if (view_type == VIEW_DEFAULT)
145 LayoutDefaultView(); 145 LayoutDefaultView();
146 else 146 else
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
192 layout->AddView(icon_, 1, 3); // 3 rows for icon 192 layout->AddView(icon_, 1, 3); // 3 rows for icon
193 193
194 layout->AddPaddingRow(0, kPaddingVertical/3); 194 layout->AddPaddingRow(0, kPaddingVertical/3);
195 layout->StartRow(0, 0); 195 layout->StartRow(0, 0);
196 layout->AddView(time_label_); 196 layout->AddView(time_label_);
197 197
198 layout->AddPaddingRow(0, kPaddingVertical); 198 layout->AddPaddingRow(0, kPaddingVertical);
199 } 199 }
200 200
201 void LayoutNotificationView() { 201 void LayoutNotificationView() {
202 const int msg_width = kTrayPopupWidth - kNotificationCloseButtonWidth -
203 kTrayPopupPaddingHorizontal - kNotificationIconWidth;
204
202 views::GridLayout* layout = new views::GridLayout(this); 205 views::GridLayout* layout = new views::GridLayout(this);
203 SetLayoutManager(layout); 206 SetLayoutManager(layout);
204 207
205 views::ColumnSet* columns = layout->AddColumnSet(0); 208 views::ColumnSet* columns = layout->AddColumnSet(0);
206 209
207 // Icon 210 // Icon
208 columns->AddColumn(views::GridLayout::FILL, views::GridLayout::FILL, 211 columns->AddColumn(views::GridLayout::FILL, views::GridLayout::FILL,
209 0, views::GridLayout::USE_PREF, 0, 0); 212 0 /* resize percent */,
213 views::GridLayout::FIXED,
214 kNotificationIconWidth, kNotificationIconWidth);
210 215
211 columns->AddPaddingColumn(0, kTrayPopupPaddingHorizontal/2); 216 columns->AddPaddingColumn(0, kTrayPopupPaddingHorizontal/2);
212 217
213 // Status + Time 218 // Status + Time
214 columns->AddColumn(views::GridLayout::FILL, views::GridLayout::FILL, 219 columns->AddColumn(views::GridLayout::FILL, views::GridLayout::FILL,
215 0, views::GridLayout::USE_PREF, 0, kLabelMinWidth); 220 0 /* resize percent */,
221 views::GridLayout::FIXED, msg_width, msg_width);
216 222
217 layout->AddPaddingRow(0, kPaddingVertical); 223 // Layout rows
224 layout->AddPaddingRow(0, kTrayPopupPaddingBetweenItems);
218 225
219 layout->StartRow(0, 0); 226 layout->StartRow(0, 0);
220 layout->AddView(icon_, 1, 3); // 3 rows for icon 227 layout->AddView(icon_, 1, 2); // 2 rows for icon
221 layout->AddView(status_label_); 228 layout->AddView(status_label_);
222 layout->AddPaddingRow(0, kPaddingVertical/3);
223 229
224 layout->StartRow(0, 0); 230 layout->StartRow(0, 0);
225 layout->SkipColumns(1); 231 layout->SkipColumns(1);
226 layout->AddView(time_label_); 232 layout->AddView(time_label_);
227 233
228 layout->AddPaddingRow(0, kPaddingVertical); 234 layout->AddPaddingRow(0, kPaddingVertical);
229 } 235 }
230 236
231 void UpdateText() { 237 void UpdateText() {
232 base::TimeDelta time = base::TimeDelta::FromSeconds( 238 base::TimeDelta time = base::TimeDelta::FromSeconds(
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after
414 return false; 420 return false;
415 case NOTIFICATION_CRITICAL: 421 case NOTIFICATION_CRITICAL:
416 return false; 422 return false;
417 } 423 }
418 NOTREACHED(); 424 NOTREACHED();
419 return false; 425 return false;
420 } 426 }
421 427
422 } // namespace internal 428 } // namespace internal
423 } // namespace ash 429 } // namespace ash
OLDNEW
« no previous file with comments | « ash/system/network/tray_sms.cc ('k') | ash/system/tray/tray_constants.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698