Chromium Code Reviews| OLD | NEW |
|---|---|
| 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/common/system/date/date_view.h" | 5 #include "ash/common/system/date/date_view.h" |
| 6 | 6 |
| 7 #include "ash/common/system/tray/system_tray_delegate.h" | 7 #include "ash/common/system/tray/system_tray_delegate.h" |
| 8 #include "ash/common/system/tray/tray_constants.h" | 8 #include "ash/common/system/tray/tray_constants.h" |
| 9 #include "ash/common/system/tray/tray_utils.h" | 9 #include "ash/common/system/tray/tray_utils.h" |
| 10 #include "ash/common/wm_shell.h" | 10 #include "ash/common/wm_shell.h" |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 64 icu::SimpleDateFormat simple_formatter(generated_pattern, status); | 64 icu::SimpleDateFormat simple_formatter(generated_pattern, status); |
| 65 DCHECK(U_SUCCESS(status)); | 65 DCHECK(U_SUCCESS(status)); |
| 66 icu::UnicodeString date_string; | 66 icu::UnicodeString date_string; |
| 67 simple_formatter.format(static_cast<UDate>(time.ToDoubleT() * 1000), | 67 simple_formatter.format(static_cast<UDate>(time.ToDoubleT() * 1000), |
| 68 date_string, status); | 68 date_string, status); |
| 69 DCHECK(U_SUCCESS(status)); | 69 DCHECK(U_SUCCESS(status)); |
| 70 return base::string16(date_string.getBuffer(), | 70 return base::string16(date_string.getBuffer(), |
| 71 static_cast<size_t>(date_string.length())); | 71 static_cast<size_t>(date_string.length())); |
| 72 } | 72 } |
| 73 | 73 |
| 74 views::Label* CreateLabel() { | |
| 75 views::Label* label = new views::Label; | |
| 76 label->SetHorizontalAlignment(gfx::ALIGN_LEFT); | |
|
Evan Stade
2016/08/18 00:38:02
This alignment is not necessary for the time label
| |
| 77 label->SetBackgroundColor(SkColorSetARGB(0, 255, 255, 255)); | |
| 78 return label; | |
| 79 } | |
| 80 | |
| 81 } // namespace | 74 } // namespace |
| 82 | 75 |
| 83 BaseDateTimeView::~BaseDateTimeView() { | 76 BaseDateTimeView::~BaseDateTimeView() { |
| 84 timer_.Stop(); | 77 timer_.Stop(); |
| 85 } | 78 } |
| 86 | 79 |
| 87 void BaseDateTimeView::UpdateText() { | 80 void BaseDateTimeView::UpdateText() { |
| 88 base::Time now = base::Time::Now(); | 81 base::Time now = base::Time::Now(); |
| 89 UpdateTextInternal(now); | 82 UpdateTextInternal(now); |
| 90 SchedulePaint(); | 83 SchedulePaint(); |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 138 } | 131 } |
| 139 | 132 |
| 140 void BaseDateTimeView::OnLocaleChanged() { | 133 void BaseDateTimeView::OnLocaleChanged() { |
| 141 UpdateText(); | 134 UpdateText(); |
| 142 } | 135 } |
| 143 | 136 |
| 144 /////////////////////////////////////////////////////////////////////////////// | 137 /////////////////////////////////////////////////////////////////////////////// |
| 145 | 138 |
| 146 DateView::DateView() : action_(TrayDate::NONE) { | 139 DateView::DateView() : action_(TrayDate::NONE) { |
| 147 SetLayoutManager(new views::BoxLayout(views::BoxLayout::kVertical, 0, 0, 0)); | 140 SetLayoutManager(new views::BoxLayout(views::BoxLayout::kVertical, 0, 0, 0)); |
| 148 date_label_ = CreateLabel(); | 141 date_label_ = new views::Label(); |
| 142 date_label_->SetHorizontalAlignment(gfx::ALIGN_LEFT); | |
| 149 date_label_->SetEnabledColor(kHeaderTextColorNormal); | 143 date_label_->SetEnabledColor(kHeaderTextColorNormal); |
| 150 UpdateTextInternal(base::Time::Now()); | 144 UpdateTextInternal(base::Time::Now()); |
| 151 AddChildView(date_label_); | 145 AddChildView(date_label_); |
| 152 } | 146 } |
| 153 | 147 |
| 154 DateView::~DateView() {} | 148 DateView::~DateView() {} |
| 155 | 149 |
| 156 void DateView::SetAction(TrayDate::DateAction action) { | 150 void DateView::SetAction(TrayDate::DateAction action) { |
| 157 if (action == action_) | 151 if (action == action_) |
| 158 return; | 152 return; |
| (...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 308 void TimeView::SetBorderFromLayout(TrayDate::ClockLayout clock_layout) { | 302 void TimeView::SetBorderFromLayout(TrayDate::ClockLayout clock_layout) { |
| 309 if (clock_layout == TrayDate::HORIZONTAL_CLOCK) | 303 if (clock_layout == TrayDate::HORIZONTAL_CLOCK) |
| 310 SetBorder(views::Border::CreateEmptyBorder( | 304 SetBorder(views::Border::CreateEmptyBorder( |
| 311 0, kTrayLabelItemHorizontalPaddingBottomAlignment, 0, | 305 0, kTrayLabelItemHorizontalPaddingBottomAlignment, 0, |
| 312 kTrayLabelItemHorizontalPaddingBottomAlignment)); | 306 kTrayLabelItemHorizontalPaddingBottomAlignment)); |
| 313 else | 307 else |
| 314 SetBorder(views::Border::NullBorder()); | 308 SetBorder(views::Border::NullBorder()); |
| 315 } | 309 } |
| 316 | 310 |
| 317 void TimeView::SetupLabels() { | 311 void TimeView::SetupLabels() { |
| 318 horizontal_label_.reset(CreateLabel()); | 312 horizontal_label_.reset(new views::Label()); |
| 319 SetupLabel(horizontal_label_.get()); | 313 SetupLabel(horizontal_label_.get()); |
| 320 vertical_label_hours_.reset(CreateLabel()); | 314 vertical_label_hours_.reset(new views::Label()); |
| 321 SetupLabel(vertical_label_hours_.get()); | 315 SetupLabel(vertical_label_hours_.get()); |
| 322 vertical_label_minutes_.reset(CreateLabel()); | 316 vertical_label_minutes_.reset(new views::Label()); |
| 323 SetupLabel(vertical_label_minutes_.get()); | 317 SetupLabel(vertical_label_minutes_.get()); |
| 318 // TODO(estade): this should use the NativeTheme's secondary text color. | |
| 324 vertical_label_minutes_->SetEnabledColor(kVerticalClockMinuteColor); | 319 vertical_label_minutes_->SetEnabledColor(kVerticalClockMinuteColor); |
| 325 // Pull the minutes up closer to the hours by using a negative top border. | 320 // Pull the minutes up closer to the hours by using a negative top border. |
| 326 vertical_label_minutes_->SetBorder(views::Border::CreateEmptyBorder( | 321 vertical_label_minutes_->SetBorder(views::Border::CreateEmptyBorder( |
| 327 kVerticalClockMinutesTopOffset, 0, 0, 0)); | 322 kVerticalClockMinutesTopOffset, 0, 0, 0)); |
| 328 } | 323 } |
| 329 | 324 |
| 330 void TimeView::SetupLabel(views::Label* label) { | 325 void TimeView::SetupLabel(views::Label* label) { |
| 331 label->set_owned_by_client(); | 326 label->set_owned_by_client(); |
| 332 SetupLabelForTray(label); | 327 SetupLabelForTray(label); |
| 333 label->SetElideBehavior(gfx::NO_ELIDE); | 328 label->SetElideBehavior(gfx::NO_ELIDE); |
| 334 } | 329 } |
| 335 | 330 |
| 336 } // namespace tray | 331 } // namespace tray |
| 337 } // namespace ash | 332 } // namespace ash |
| OLD | NEW |