| 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_popup_item_style.h" | 10 #include "ash/common/system/tray/tray_popup_item_style.h" |
| 11 #include "ash/common/system/tray/tray_popup_utils.h" | 11 #include "ash/common/system/tray/tray_popup_utils.h" |
| 12 #include "ash/common/system/tray/tray_utils.h" | 12 #include "ash/common/system/tray/tray_utils.h" |
| 13 #include "ash/common/wm_shell.h" | 13 #include "ash/common/wm_shell.h" |
| 14 #include "base/i18n/rtl.h" | 14 #include "base/i18n/rtl.h" |
| 15 #include "base/i18n/time_formatting.h" | 15 #include "base/i18n/time_formatting.h" |
| 16 #include "base/strings/utf_string_conversions.h" | 16 #include "base/strings/utf_string_conversions.h" |
| 17 #include "base/time/time.h" | 17 #include "base/time/time.h" |
| 18 #include "grit/ash_strings.h" | 18 #include "grit/ash_strings.h" |
| 19 #include "third_party/icu/source/i18n/unicode/datefmt.h" | 19 #include "third_party/icu/source/i18n/unicode/datefmt.h" |
| 20 #include "third_party/icu/source/i18n/unicode/dtptngen.h" | 20 #include "third_party/icu/source/i18n/unicode/dtptngen.h" |
| 21 #include "third_party/icu/source/i18n/unicode/smpdtfmt.h" | 21 #include "third_party/icu/source/i18n/unicode/smpdtfmt.h" |
| 22 #include "ui/accessibility/ax_node_data.h" | 22 #include "ui/accessibility/ax_node_data.h" |
| 23 #include "ui/base/l10n/l10n_util.h" | 23 #include "ui/base/l10n/l10n_util.h" |
| 24 #include "ui/views/background.h" | |
| 25 #include "ui/views/border.h" | 24 #include "ui/views/border.h" |
| 26 #include "ui/views/controls/button/button.h" | 25 #include "ui/views/controls/button/button.h" |
| 27 #include "ui/views/controls/label.h" | 26 #include "ui/views/controls/label.h" |
| 28 #include "ui/views/layout/box_layout.h" | 27 #include "ui/views/layout/box_layout.h" |
| 29 #include "ui/views/layout/fill_layout.h" | 28 #include "ui/views/layout/fill_layout.h" |
| 30 #include "ui/views/layout/grid_layout.h" | 29 #include "ui/views/layout/grid_layout.h" |
| 31 #include "ui/views/widget/widget.h" | 30 #include "ui/views/widget/widget.h" |
| 32 | 31 |
| 33 namespace ash { | 32 namespace ash { |
| 34 namespace tray { | 33 namespace tray { |
| 35 namespace { | 34 namespace { |
| 36 | 35 |
| 37 // Amount of slop to add into the timer to make sure we're into the next minute | 36 // Amount of slop to add into the timer to make sure we're into the next minute |
| 38 // when the timer goes off. | 37 // when the timer goes off. |
| 39 const int kTimerSlopSeconds = 1; | 38 const int kTimerSlopSeconds = 1; |
| 40 | 39 |
| 41 // Text color of the vertical clock minutes. | 40 // Text color of the vertical clock minutes. |
| 42 const SkColor kVerticalClockMinuteColor = SkColorSetRGB(0xBA, 0xBA, 0xBA); | 41 const SkColor kVerticalClockMinuteColor = SkColorSetRGB(0xBA, 0xBA, 0xBA); |
| 43 | 42 |
| 44 // Padding between the left edge of the shelf and the left edge of the vertical | 43 // Padding between the left edge of the shelf and the left edge of the vertical |
| 45 // clock. | 44 // clock. |
| 46 const int kVerticalClockLeftPadding = 9; | 45 const int kVerticalClockLeftPadding = 9; |
| 47 | 46 |
| 48 // Offset used to bring the minutes line closer to the hours line in the | 47 // Offset used to bring the minutes line closer to the hours line in the |
| 49 // vertical clock. | 48 // vertical clock. |
| 50 const int kVerticalClockMinutesTopOffset = -4; | 49 const int kVerticalClockMinutesTopOffset = -4; |
| 51 const int kVerticalClockMinutesTopOffsetMD = -2; | 50 const int kVerticalClockMinutesTopOffsetMD = -2; |
| 52 | 51 |
| 53 // Leading padding used to draw the tray background to the left of the clock | 52 // Leading padding used to draw the tray background to the left of the clock |
| 54 // when the shelf is horizontally aligned, and on the top when the shelf is | 53 // when the shelf is vertically aligned. |
| 55 // vertically aligned. | |
| 56 const int kClockLeadingPadding = 8; | 54 const int kClockLeadingPadding = 8; |
| 57 | 55 |
| 58 bool UseMd() { | 56 bool UseMd() { |
| 59 return MaterialDesignController::IsSystemTrayMenuMaterial(); | 57 return MaterialDesignController::IsSystemTrayMenuMaterial(); |
| 60 } | 58 } |
| 61 | 59 |
| 62 base::string16 FormatDateWithPattern(const base::Time& time, | 60 base::string16 FormatDateWithPattern(const base::Time& time, |
| 63 const char* pattern) { | 61 const char* pattern) { |
| 64 UErrorCode status = U_ZERO_ERROR; | 62 UErrorCode status = U_ZERO_ERROR; |
| 65 std::unique_ptr<icu::DateTimePatternGenerator> generator( | 63 std::unique_ptr<icu::DateTimePatternGenerator> generator( |
| (...skipping 303 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 369 layout->AddPaddingRow(0, | 367 layout->AddPaddingRow(0, |
| 370 is_material_design | 368 is_material_design |
| 371 ? GetTrayConstant(TRAY_IMAGE_ITEM_PADDING) + | 369 ? GetTrayConstant(TRAY_IMAGE_ITEM_PADDING) + |
| 372 kVerticalClockMinutesTopOffsetMD | 370 kVerticalClockMinutesTopOffsetMD |
| 373 : kTrayLabelItemVerticalPaddingVerticalAlignment); | 371 : kTrayLabelItemVerticalPaddingVerticalAlignment); |
| 374 } | 372 } |
| 375 Layout(); | 373 Layout(); |
| 376 } | 374 } |
| 377 | 375 |
| 378 void TimeView::SetBorderFromLayout(ClockLayout clock_layout) { | 376 void TimeView::SetBorderFromLayout(ClockLayout clock_layout) { |
| 379 if (MaterialDesignController::IsShelfMaterial()) | |
| 380 return; | |
| 381 | |
| 382 if (clock_layout == ClockLayout::HORIZONTAL_CLOCK) { | 377 if (clock_layout == ClockLayout::HORIZONTAL_CLOCK) { |
| 383 SetBorder(views::CreateEmptyBorder( | 378 SetBorder(views::CreateEmptyBorder(gfx::Insets( |
| 384 0, kTrayLabelItemHorizontalPaddingBottomAlignment, 0, | 379 0, UseMd() ? GetTrayConstant(TRAY_IMAGE_ITEM_PADDING) |
| 385 kTrayLabelItemHorizontalPaddingBottomAlignment)); | 380 : kTrayLabelItemHorizontalPaddingBottomAlignment))); |
| 386 } else { | 381 } else { |
| 387 SetBorder(views::NullBorder()); | 382 SetBorder(views::NullBorder()); |
| 388 } | 383 } |
| 389 } | 384 } |
| 390 | 385 |
| 391 void TimeView::SetupLabels() { | 386 void TimeView::SetupLabels() { |
| 392 horizontal_label_.reset(new views::Label()); | 387 horizontal_label_.reset(new views::Label()); |
| 393 SetupLabel(horizontal_label_.get()); | 388 SetupLabel(horizontal_label_.get()); |
| 394 vertical_label_hours_.reset(new views::Label()); | 389 vertical_label_hours_.reset(new views::Label()); |
| 395 SetupLabel(vertical_label_hours_.get()); | 390 SetupLabel(vertical_label_hours_.get()); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 406 } | 401 } |
| 407 | 402 |
| 408 void TimeView::SetupLabel(views::Label* label) { | 403 void TimeView::SetupLabel(views::Label* label) { |
| 409 label->set_owned_by_client(); | 404 label->set_owned_by_client(); |
| 410 SetupLabelForTray(label); | 405 SetupLabelForTray(label); |
| 411 label->SetElideBehavior(gfx::NO_ELIDE); | 406 label->SetElideBehavior(gfx::NO_ELIDE); |
| 412 } | 407 } |
| 413 | 408 |
| 414 } // namespace tray | 409 } // namespace tray |
| 415 } // namespace ash | 410 } // namespace ash |
| OLD | NEW |