| 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/material_design/material_design_controller.h" | 7 #include "ash/common/material_design/material_design_controller.h" |
| 8 #include "ash/common/system/tray/system_tray_controller.h" | 8 #include "ash/common/system/tray/system_tray_controller.h" |
| 9 #include "ash/common/system/tray/tray_constants.h" | 9 #include "ash/common/system/tray/tray_constants.h" |
| 10 #include "ash/common/system/tray/tray_utils.h" | 10 #include "ash/common/system/tray/tray_utils.h" |
| 11 #include "ash/common/wm_shell.h" | 11 #include "ash/common/wm_shell.h" |
| 12 #include "base/i18n/rtl.h" | 12 #include "base/i18n/rtl.h" |
| 13 #include "base/i18n/time_formatting.h" | 13 #include "base/i18n/time_formatting.h" |
| 14 #include "base/strings/utf_string_conversions.h" | 14 #include "base/strings/utf_string_conversions.h" |
| 15 #include "base/time/time.h" | 15 #include "base/time/time.h" |
| 16 #include "grit/ash_strings.h" | 16 #include "grit/ash_strings.h" |
| 17 #include "third_party/icu/source/i18n/unicode/datefmt.h" | 17 #include "third_party/icu/source/i18n/unicode/datefmt.h" |
| 18 #include "third_party/icu/source/i18n/unicode/dtptngen.h" | 18 #include "third_party/icu/source/i18n/unicode/dtptngen.h" |
| 19 #include "third_party/icu/source/i18n/unicode/smpdtfmt.h" | 19 #include "third_party/icu/source/i18n/unicode/smpdtfmt.h" |
| 20 #include "ui/accessibility/ax_view_state.h" | 20 #include "ui/accessibility/ax_view_state.h" |
| 21 #include "ui/base/l10n/l10n_util.h" | 21 #include "ui/base/l10n/l10n_util.h" |
| 22 #include "ui/views/background.h" |
| 22 #include "ui/views/border.h" | 23 #include "ui/views/border.h" |
| 23 #include "ui/views/controls/label.h" | 24 #include "ui/views/controls/label.h" |
| 24 #include "ui/views/layout/box_layout.h" | 25 #include "ui/views/layout/box_layout.h" |
| 26 #include "ui/views/layout/fill_layout.h" |
| 25 #include "ui/views/layout/grid_layout.h" | 27 #include "ui/views/layout/grid_layout.h" |
| 26 #include "ui/views/widget/widget.h" | 28 #include "ui/views/widget/widget.h" |
| 27 | 29 |
| 28 namespace ash { | 30 namespace ash { |
| 29 namespace tray { | 31 namespace tray { |
| 30 namespace { | 32 namespace { |
| 31 | 33 |
| 32 // Amount of slop to add into the timer to make sure we're into the next minute | 34 // Amount of slop to add into the timer to make sure we're into the next minute |
| 33 // when the timer goes off. | 35 // when the timer goes off. |
| 34 const int kTimerSlopSeconds = 1; | 36 const int kTimerSlopSeconds = 1; |
| (...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 283 bool TimeView::OnMousePressed(const ui::MouseEvent& event) { | 285 bool TimeView::OnMousePressed(const ui::MouseEvent& event) { |
| 284 // Let the event fall through. | 286 // Let the event fall through. |
| 285 return false; | 287 return false; |
| 286 } | 288 } |
| 287 | 289 |
| 288 void TimeView::UpdateClockLayout(TrayDate::ClockLayout clock_layout) { | 290 void TimeView::UpdateClockLayout(TrayDate::ClockLayout clock_layout) { |
| 289 SetBorderFromLayout(clock_layout); | 291 SetBorderFromLayout(clock_layout); |
| 290 if (clock_layout == TrayDate::HORIZONTAL_CLOCK) { | 292 if (clock_layout == TrayDate::HORIZONTAL_CLOCK) { |
| 291 RemoveChildView(vertical_label_hours_.get()); | 293 RemoveChildView(vertical_label_hours_.get()); |
| 292 RemoveChildView(vertical_label_minutes_.get()); | 294 RemoveChildView(vertical_label_minutes_.get()); |
| 293 SetLayoutManager( | 295 SetLayoutManager(new views::FillLayout()); |
| 294 new views::BoxLayout(views::BoxLayout::kHorizontal, 0, 0, 0)); | |
| 295 AddChildView(horizontal_label_.get()); | 296 AddChildView(horizontal_label_.get()); |
| 296 } else { | 297 } else { |
| 297 const bool is_material_design = MaterialDesignController::IsShelfMaterial(); | 298 const bool is_material_design = MaterialDesignController::IsShelfMaterial(); |
| 298 RemoveChildView(horizontal_label_.get()); | 299 RemoveChildView(horizontal_label_.get()); |
| 299 views::GridLayout* layout = new views::GridLayout(this); | 300 views::GridLayout* layout = new views::GridLayout(this); |
| 300 SetLayoutManager(layout); | 301 SetLayoutManager(layout); |
| 301 const int kColumnId = 0; | 302 const int kColumnId = 0; |
| 302 views::ColumnSet* columns = layout->AddColumnSet(kColumnId); | 303 views::ColumnSet* columns = layout->AddColumnSet(kColumnId); |
| 303 columns->AddPaddingColumn(0, kVerticalClockLeftPadding); | 304 columns->AddPaddingColumn(0, kVerticalClockLeftPadding); |
| 304 columns->AddColumn(views::GridLayout::TRAILING, views::GridLayout::CENTER, | 305 columns->AddColumn(views::GridLayout::TRAILING, views::GridLayout::CENTER, |
| 305 0, views::GridLayout::USE_PREF, 0, 0); | 306 0, views::GridLayout::USE_PREF, 0, 0); |
| 306 layout->AddPaddingRow( | 307 layout->AddPaddingRow( |
| 307 0, is_material_design ? kClockLeadingPadding | 308 0, is_material_design ? kClockLeadingPadding |
| 308 : kTrayLabelItemVerticalPaddingVerticalAlignment); | 309 : kTrayLabelItemVerticalPaddingVerticalAlignment); |
| 309 layout->StartRow(0, kColumnId); | 310 layout->StartRow(0, kColumnId); |
| 310 layout->AddView(vertical_label_hours_.get()); | 311 layout->AddView(vertical_label_hours_.get()); |
| 311 layout->StartRow(0, kColumnId); | 312 layout->StartRow(0, kColumnId); |
| 312 layout->AddView(vertical_label_minutes_.get()); | 313 layout->AddView(vertical_label_minutes_.get()); |
| 313 layout->AddPaddingRow(0, | 314 layout->AddPaddingRow(0, |
| 314 is_material_design | 315 is_material_design |
| 315 ? GetTrayConstant(TRAY_IMAGE_ITEM_PADDING) + | 316 ? GetTrayConstant(TRAY_IMAGE_ITEM_PADDING) + |
| 316 kVerticalClockMinutesTopOffsetMD | 317 kVerticalClockMinutesTopOffsetMD |
| 317 : kTrayLabelItemVerticalPaddingVerticalAlignment); | 318 : kTrayLabelItemVerticalPaddingVerticalAlignment); |
| 318 } | 319 } |
| 319 Layout(); | 320 Layout(); |
| 320 } | 321 } |
| 321 | 322 |
| 322 void TimeView::SetBorderFromLayout(TrayDate::ClockLayout clock_layout) { | 323 void TimeView::SetBorderFromLayout(TrayDate::ClockLayout clock_layout) { |
| 324 if (MaterialDesignController::IsShelfMaterial()) |
| 325 return; |
| 326 |
| 323 if (clock_layout == TrayDate::HORIZONTAL_CLOCK) { | 327 if (clock_layout == TrayDate::HORIZONTAL_CLOCK) { |
| 324 bool is_material_design = MaterialDesignController::IsShelfMaterial(); | 328 SetBorder(views::Border::CreateEmptyBorder( |
| 325 const int time_view_left_padding = | 329 0, kTrayLabelItemHorizontalPaddingBottomAlignment, 0, |
| 326 is_material_design ? kClockLeadingPadding | 330 kTrayLabelItemHorizontalPaddingBottomAlignment)); |
| 327 : kTrayLabelItemHorizontalPaddingBottomAlignment; | |
| 328 const int time_view_right_padding = | |
| 329 is_material_design ? GetTrayConstant(TRAY_IMAGE_ITEM_PADDING) | |
| 330 : kTrayLabelItemHorizontalPaddingBottomAlignment; | |
| 331 SetBorder(views::Border::CreateEmptyBorder(0, time_view_left_padding, 0, | |
| 332 time_view_right_padding)); | |
| 333 } else { | 331 } else { |
| 334 SetBorder(views::Border::NullBorder()); | 332 SetBorder(views::Border::NullBorder()); |
| 335 } | 333 } |
| 336 } | 334 } |
| 337 | 335 |
| 338 void TimeView::SetupLabels() { | 336 void TimeView::SetupLabels() { |
| 339 horizontal_label_.reset(new views::Label()); | 337 horizontal_label_.reset(new views::Label()); |
| 340 SetupLabel(horizontal_label_.get()); | 338 SetupLabel(horizontal_label_.get()); |
| 341 vertical_label_hours_.reset(new views::Label()); | 339 vertical_label_hours_.reset(new views::Label()); |
| 342 SetupLabel(vertical_label_hours_.get()); | 340 SetupLabel(vertical_label_hours_.get()); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 353 } | 351 } |
| 354 | 352 |
| 355 void TimeView::SetupLabel(views::Label* label) { | 353 void TimeView::SetupLabel(views::Label* label) { |
| 356 label->set_owned_by_client(); | 354 label->set_owned_by_client(); |
| 357 SetupLabelForTray(label); | 355 SetupLabelForTray(label); |
| 358 label->SetElideBehavior(gfx::NO_ELIDE); | 356 label->SetElideBehavior(gfx::NO_ELIDE); |
| 359 } | 357 } |
| 360 | 358 |
| 361 } // namespace tray | 359 } // namespace tray |
| 362 } // namespace ash | 360 } // namespace ash |
| OLD | NEW |