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

Side by Side Diff: ash/system/date/date_view.cc

Issue 145033006: views: Make View::set_border() take a scoped_ptr<>. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase to ToT 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
« no previous file with comments | « ash/system/date/date_view.h ('k') | ash/system/date/tray_date.cc » ('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/date/date_view.h" 5 #include "ash/system/date/date_view.h"
6 6
7 #include "ash/shell.h" 7 #include "ash/shell.h"
8 #include "ash/system/tray/system_tray_delegate.h" 8 #include "ash/system/tray/system_tray_delegate.h"
9 #include "ash/system/tray/tray_constants.h" 9 #include "ash/system/tray/tray_constants.h"
10 #include "ash/system/tray/tray_utils.h" 10 #include "ash/system/tray/tray_utils.h"
(...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after
241 bool TimeView::PerformAction(const ui::Event& event) { 241 bool TimeView::PerformAction(const ui::Event& event) {
242 return false; 242 return false;
243 } 243 }
244 244
245 bool TimeView::OnMousePressed(const ui::MouseEvent& event) { 245 bool TimeView::OnMousePressed(const ui::MouseEvent& event) {
246 // Let the event fall through. 246 // Let the event fall through.
247 return false; 247 return false;
248 } 248 }
249 249
250 void TimeView::UpdateClockLayout(TrayDate::ClockLayout clock_layout){ 250 void TimeView::UpdateClockLayout(TrayDate::ClockLayout clock_layout){
251 SetBorder(clock_layout); 251 SetBorderFromLayout(clock_layout);
252 if (clock_layout == TrayDate::HORIZONTAL_CLOCK) { 252 if (clock_layout == TrayDate::HORIZONTAL_CLOCK) {
253 RemoveChildView(vertical_label_hours_.get()); 253 RemoveChildView(vertical_label_hours_.get());
254 RemoveChildView(vertical_label_minutes_.get()); 254 RemoveChildView(vertical_label_minutes_.get());
255 SetLayoutManager( 255 SetLayoutManager(
256 new views::BoxLayout(views::BoxLayout::kHorizontal, 0, 0, 0)); 256 new views::BoxLayout(views::BoxLayout::kHorizontal, 0, 0, 0));
257 AddChildView(horizontal_label_.get()); 257 AddChildView(horizontal_label_.get());
258 } else { 258 } else {
259 RemoveChildView(horizontal_label_.get()); 259 RemoveChildView(horizontal_label_.get());
260 views::GridLayout* layout = new views::GridLayout(this); 260 views::GridLayout* layout = new views::GridLayout(this);
261 SetLayoutManager(layout); 261 SetLayoutManager(layout);
262 const int kColumnId = 0; 262 const int kColumnId = 0;
263 views::ColumnSet* columns = layout->AddColumnSet(kColumnId); 263 views::ColumnSet* columns = layout->AddColumnSet(kColumnId);
264 columns->AddPaddingColumn(0, kVerticalClockLeftPadding); 264 columns->AddPaddingColumn(0, kVerticalClockLeftPadding);
265 columns->AddColumn(views::GridLayout::TRAILING, views::GridLayout::CENTER, 265 columns->AddColumn(views::GridLayout::TRAILING, views::GridLayout::CENTER,
266 0, views::GridLayout::USE_PREF, 0, 0); 266 0, views::GridLayout::USE_PREF, 0, 0);
267 layout->AddPaddingRow(0, kTrayLabelItemVerticalPaddingVerticalAlignment); 267 layout->AddPaddingRow(0, kTrayLabelItemVerticalPaddingVerticalAlignment);
268 layout->StartRow(0, kColumnId); 268 layout->StartRow(0, kColumnId);
269 layout->AddView(vertical_label_hours_.get()); 269 layout->AddView(vertical_label_hours_.get());
270 layout->StartRow(0, kColumnId); 270 layout->StartRow(0, kColumnId);
271 layout->AddView(vertical_label_minutes_.get()); 271 layout->AddView(vertical_label_minutes_.get());
272 layout->AddPaddingRow(0, kTrayLabelItemVerticalPaddingVerticalAlignment); 272 layout->AddPaddingRow(0, kTrayLabelItemVerticalPaddingVerticalAlignment);
273 } 273 }
274 Layout(); 274 Layout();
275 } 275 }
276 276
277 void TimeView::SetBorder(TrayDate::ClockLayout clock_layout) { 277 void TimeView::SetBorderFromLayout(TrayDate::ClockLayout clock_layout) {
278 if (clock_layout == TrayDate::HORIZONTAL_CLOCK) 278 if (clock_layout == TrayDate::HORIZONTAL_CLOCK)
279 set_border(views::Border::CreateEmptyBorder( 279 SetBorder(views::Border::CreateEmptyBorder(
280 0, kTrayLabelItemHorizontalPaddingBottomAlignment, 280 0,
281 0, kTrayLabelItemHorizontalPaddingBottomAlignment)); 281 kTrayLabelItemHorizontalPaddingBottomAlignment,
282 0,
283 kTrayLabelItemHorizontalPaddingBottomAlignment));
282 else 284 else
283 set_border(NULL); 285 SetBorder(views::Border::NullBorder());
284 } 286 }
285 287
286 void TimeView::SetupLabels() { 288 void TimeView::SetupLabels() {
287 horizontal_label_.reset(CreateLabel()); 289 horizontal_label_.reset(CreateLabel());
288 SetupLabel(horizontal_label_.get()); 290 SetupLabel(horizontal_label_.get());
289 vertical_label_hours_.reset(CreateLabel()); 291 vertical_label_hours_.reset(CreateLabel());
290 SetupLabel(vertical_label_hours_.get()); 292 SetupLabel(vertical_label_hours_.get());
291 vertical_label_minutes_.reset(CreateLabel()); 293 vertical_label_minutes_.reset(CreateLabel());
292 SetupLabel(vertical_label_minutes_.get()); 294 SetupLabel(vertical_label_minutes_.get());
293 vertical_label_minutes_->SetEnabledColor(kVerticalClockMinuteColor); 295 vertical_label_minutes_->SetEnabledColor(kVerticalClockMinuteColor);
294 // Pull the minutes up closer to the hours by using a negative top border. 296 // Pull the minutes up closer to the hours by using a negative top border.
295 vertical_label_minutes_->set_border( 297 vertical_label_minutes_->SetBorder(views::Border::CreateEmptyBorder(
296 views::Border::CreateEmptyBorder( 298 kVerticalClockMinutesTopOffset, 0, 0, 0));
297 kVerticalClockMinutesTopOffset, 0, 0, 0));
298 } 299 }
299 300
300 void TimeView::SetupLabel(views::Label* label) { 301 void TimeView::SetupLabel(views::Label* label) {
301 label->set_owned_by_client(); 302 label->set_owned_by_client();
302 SetupLabelForTray(label); 303 SetupLabelForTray(label);
303 label->SetFontList(label->font_list().DeriveFontListWithSizeDeltaAndStyle( 304 label->SetFontList(label->font_list().DeriveFontListWithSizeDeltaAndStyle(
304 0, label->font_list().GetFontStyle() & ~gfx::Font::BOLD)); 305 0, label->font_list().GetFontStyle() & ~gfx::Font::BOLD));
305 } 306 }
306 307
307 } // namespace tray 308 } // namespace tray
308 } // namespace internal 309 } // namespace internal
309 } // namespace ash 310 } // namespace ash
OLDNEW
« no previous file with comments | « ash/system/date/date_view.h ('k') | ash/system/date/tray_date.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698