Chromium Code Reviews| Index: ash/common/system/date/date_view.cc |
| diff --git a/ash/common/system/date/date_view.cc b/ash/common/system/date/date_view.cc |
| index 716a61fea402fb205d3b736313df776cada84e19..6850f414c4ce98a9d6b791e30e6fc2cf1b2a1bb1 100644 |
| --- a/ash/common/system/date/date_view.cc |
| +++ b/ash/common/system/date/date_view.cc |
| @@ -4,6 +4,7 @@ |
| #include "ash/common/system/date/date_view.h" |
| +#include "ash/common/material_design/material_design_controller.h" |
| #include "ash/common/system/tray/system_tray_delegate.h" |
| #include "ash/common/system/tray/tray_constants.h" |
| #include "ash/common/system/tray/tray_utils.h" |
| @@ -41,7 +42,10 @@ const int kVerticalClockLeftPadding = 9; |
| // Offset used to bring the minutes line closer to the hours line in the |
| // vertical clock. |
| -const int kVerticalClockMinutesTopOffset = -4; |
| +const int kVerticalClockMinutesTopOffset = -2; |
|
tdanderson
2016/10/05 21:34:29
This constant is used on line 346 which can be exe
yiyix
2016/10/05 22:46:47
You are right. I forget about the non-md path.
|
| + |
| +// Padding used to draw the tray background around the clock. |
| +const int kClockOnTrayBackgroundPadding = 8; |
|
tdanderson
2016/10/05 21:34:28
Since this is only used for a vertical shelf, can
yiyix
2016/10/05 22:46:47
It is used for both horizontal and vertical aligne
|
| base::string16 FormatDate(const base::Time& time) { |
| icu::UnicodeString date_string; |
| @@ -287,6 +291,7 @@ void TimeView::UpdateClockLayout(TrayDate::ClockLayout clock_layout) { |
| new views::BoxLayout(views::BoxLayout::kHorizontal, 0, 0, 0)); |
| AddChildView(horizontal_label_.get()); |
| } else { |
| + bool is_material_design = MaterialDesignController::IsShelfMaterial(); |
|
tdanderson
2016/10/05 21:34:28
nit: const
yiyix
2016/10/05 22:46:47
Done.
|
| RemoveChildView(horizontal_label_.get()); |
| views::GridLayout* layout = new views::GridLayout(this); |
| SetLayoutManager(layout); |
| @@ -295,23 +300,36 @@ void TimeView::UpdateClockLayout(TrayDate::ClockLayout clock_layout) { |
| columns->AddPaddingColumn(0, kVerticalClockLeftPadding); |
| columns->AddColumn(views::GridLayout::TRAILING, views::GridLayout::CENTER, |
| 0, views::GridLayout::USE_PREF, 0, 0); |
| - layout->AddPaddingRow(0, kTrayLabelItemVerticalPaddingVerticalAlignment); |
| + layout->AddPaddingRow( |
| + 0, is_material_design ? kClockOnTrayBackgroundPadding |
| + : kTrayLabelItemVerticalPaddingVerticalAlignment); |
| layout->StartRow(0, kColumnId); |
| layout->AddView(vertical_label_hours_.get()); |
| layout->StartRow(0, kColumnId); |
| layout->AddView(vertical_label_minutes_.get()); |
| - layout->AddPaddingRow(0, kTrayLabelItemVerticalPaddingVerticalAlignment); |
| + layout->AddPaddingRow(0, |
| + is_material_design |
| + ? GetTrayConstant(TRAY_IMAGE_ITEM_PADDING) + |
| + kVerticalClockMinutesTopOffset |
| + : kTrayLabelItemVerticalPaddingVerticalAlignment); |
| } |
| Layout(); |
| } |
| void TimeView::SetBorderFromLayout(TrayDate::ClockLayout clock_layout) { |
| - if (clock_layout == TrayDate::HORIZONTAL_CLOCK) |
| - SetBorder(views::Border::CreateEmptyBorder( |
| - 0, kTrayLabelItemHorizontalPaddingBottomAlignment, 0, |
| - kTrayLabelItemHorizontalPaddingBottomAlignment)); |
| - else |
| + if (clock_layout == TrayDate::HORIZONTAL_CLOCK) { |
| + bool is_material_design = MaterialDesignController::IsShelfMaterial(); |
| + const int time_view_left_padding = |
| + is_material_design ? kClockOnTrayBackgroundPadding |
| + : kTrayLabelItemHorizontalPaddingBottomAlignment; |
| + const int time_view_right_padding = |
| + is_material_design ? GetTrayConstant(TRAY_IMAGE_ITEM_PADDING) |
| + : kTrayLabelItemHorizontalPaddingBottomAlignment; |
| + SetBorder(views::Border::CreateEmptyBorder(0, time_view_left_padding, 0, |
| + time_view_right_padding)); |
| + } else { |
|
tdanderson
2016/10/05 21:34:28
Thanks for adding the {} !
yiyix
2016/10/05 22:46:47
:)
|
| SetBorder(views::Border::NullBorder()); |
| + } |
| } |
| void TimeView::SetupLabels() { |