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

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: Further renaming 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 (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, kTrayLabelItemHorizontalPaddingBottomAlignment,
281 0, kTrayLabelItemHorizontalPaddingBottomAlignment)); 281 0, kTrayLabelItemHorizontalPaddingBottomAlignment));
282 else 282 else
283 set_border(NULL); 283 ClearBorder();
284 } 284 }
285 285
286 void TimeView::SetupLabels() { 286 void TimeView::SetupLabels() {
287 horizontal_label_.reset(CreateLabel()); 287 horizontal_label_.reset(CreateLabel());
288 SetupLabel(horizontal_label_.get()); 288 SetupLabel(horizontal_label_.get());
289 vertical_label_hours_.reset(CreateLabel()); 289 vertical_label_hours_.reset(CreateLabel());
290 SetupLabel(vertical_label_hours_.get()); 290 SetupLabel(vertical_label_hours_.get());
291 vertical_label_minutes_.reset(CreateLabel()); 291 vertical_label_minutes_.reset(CreateLabel());
292 SetupLabel(vertical_label_minutes_.get()); 292 SetupLabel(vertical_label_minutes_.get());
293 vertical_label_minutes_->SetEnabledColor(kVerticalClockMinuteColor); 293 vertical_label_minutes_->SetEnabledColor(kVerticalClockMinuteColor);
294 // Pull the minutes up closer to the hours by using a negative top border. 294 // Pull the minutes up closer to the hours by using a negative top border.
295 vertical_label_minutes_->set_border( 295 vertical_label_minutes_->SetBorder(
296 views::Border::CreateEmptyBorder( 296 views::Border::CreateEmptyBorder(
297 kVerticalClockMinutesTopOffset, 0, 0, 0)); 297 kVerticalClockMinutesTopOffset, 0, 0, 0));
298 } 298 }
299 299
300 void TimeView::SetupLabel(views::Label* label) { 300 void TimeView::SetupLabel(views::Label* label) {
301 label->set_owned_by_client(); 301 label->set_owned_by_client();
302 SetupLabelForTray(label); 302 SetupLabelForTray(label);
303 label->SetFontList(label->font_list().DeriveFontListWithSizeDeltaAndStyle( 303 label->SetFontList(label->font_list().DeriveFontListWithSizeDeltaAndStyle(
304 0, label->font_list().GetFontStyle() & ~gfx::Font::BOLD)); 304 0, label->font_list().GetFontStyle() & ~gfx::Font::BOLD));
305 } 305 }
306 306
307 } // namespace tray 307 } // namespace tray
308 } // namespace internal 308 } // namespace internal
309 } // namespace ash 309 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698