| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/system_info_default_view.h" | 5 #include "ash/system/date/system_info_default_view.h" |
| 6 | 6 |
| 7 #include "ash/system/date/date_view.h" | 7 #include "ash/system/date/date_view.h" |
| 8 #include "ash/system/power/power_status.h" | 8 #include "ash/system/power/power_status.h" |
| 9 #include "ash/system/power/power_status_view.h" | 9 #include "ash/system/power/power_status_view.h" |
| 10 #include "ash/system/tray/tray_constants.h" | 10 #include "ash/system/tray/tray_constants.h" |
| 11 #include "ash/system/tray/tray_popup_utils.h" | 11 #include "ash/system/tray/tray_popup_utils.h" |
| 12 #include "ash/system/tray/tri_view.h" | 12 #include "ash/system/tray/tri_view.h" |
| 13 #include "base/memory/ptr_util.h" | 13 #include "base/memory/ptr_util.h" |
| 14 #include "ui/views/controls/separator.h" | 14 #include "ui/views/controls/separator.h" |
| 15 #include "ui/views/layout/box_layout.h" | 15 #include "ui/views/layout/box_layout.h" |
| 16 #include "ui/views/layout/fill_layout.h" | 16 #include "ui/views/layout/fill_layout.h" |
| 17 | 17 |
| 18 namespace ash { | 18 namespace ash { |
| 19 | 19 |
| 20 // The minimum number of menu button widths that the date view should span | 20 // The minimum number of menu button widths that the date view should span |
| 21 // horizontally. | 21 // horizontally. |
| 22 const int kMinNumTileWidths = 2; | 22 const int kMinNumTileWidths = 2; |
| 23 | 23 |
| 24 // The maximum number of menu button widths that the date view should span | 24 // The maximum number of menu button widths that the date view should span |
| 25 // horizontally. | 25 // horizontally. |
| 26 const int kMaxNumTileWidths = 3; | 26 const int kMaxNumTileWidths = 3; |
| 27 | 27 |
| 28 SystemInfoDefaultView::SystemInfoDefaultView(SystemTrayItem* owner, | 28 SystemInfoDefaultView::SystemInfoDefaultView(SystemTrayItem* owner) |
| 29 LoginStatus login) | |
| 30 : date_view_(nullptr), | 29 : date_view_(nullptr), |
| 31 tri_view_(TrayPopupUtils::CreateMultiTargetRowView()) { | 30 tri_view_(TrayPopupUtils::CreateMultiTargetRowView()) { |
| 32 tri_view_->SetMinHeight(kTrayPopupSystemInfoRowHeight); | 31 tri_view_->SetMinHeight(kTrayPopupSystemInfoRowHeight); |
| 33 AddChildView(tri_view_); | 32 AddChildView(tri_view_); |
| 34 SetLayoutManager(new views::FillLayout); | 33 SetLayoutManager(new views::FillLayout); |
| 35 | 34 |
| 36 date_view_ = new tray::DateView(owner); | 35 date_view_ = new tray::DateView(owner); |
| 37 tri_view_->AddView(TriView::Container::START, date_view_); | 36 tri_view_->AddView(TriView::Container::START, date_view_); |
| 38 | 37 |
| 39 if (PowerStatus::Get()->IsBatteryPresent()) { | 38 if (PowerStatus::Get()->IsBatteryPresent()) { |
| 40 power_status_view_ = new ash::PowerStatusView(); | 39 power_status_view_ = new ash::PowerStatusView(); |
| 41 std::unique_ptr<views::BoxLayout> box_layout = | 40 std::unique_ptr<views::BoxLayout> box_layout = |
| 42 base::MakeUnique<views::BoxLayout>(views::BoxLayout::kHorizontal, 0, 0, | 41 base::MakeUnique<views::BoxLayout>(views::BoxLayout::kHorizontal, 0, 0, |
| 43 0); | 42 0); |
| 44 box_layout->set_cross_axis_alignment( | 43 box_layout->set_cross_axis_alignment( |
| 45 views::BoxLayout::CROSS_AXIS_ALIGNMENT_CENTER); | 44 views::BoxLayout::CROSS_AXIS_ALIGNMENT_CENTER); |
| 46 box_layout->set_inside_border_insets( | 45 box_layout->set_inside_border_insets( |
| 47 gfx::Insets(0, 0, 0, kTrayPopupLabelRightPadding)); | 46 gfx::Insets(0, 0, 0, kTrayPopupLabelRightPadding)); |
| 48 tri_view_->SetContainerLayout(TriView::Container::CENTER, | 47 tri_view_->SetContainerLayout(TriView::Container::CENTER, |
| 49 std::move(box_layout)); | 48 std::move(box_layout)); |
| 50 | 49 |
| 51 tri_view_->AddView(TriView::Container::CENTER, | 50 tri_view_->AddView(TriView::Container::CENTER, |
| 52 TrayPopupUtils::CreateVerticalSeparator()); | 51 TrayPopupUtils::CreateVerticalSeparator()); |
| 53 tri_view_->AddView(TriView::Container::CENTER, power_status_view_); | 52 tri_view_->AddView(TriView::Container::CENTER, power_status_view_); |
| 54 } | 53 } |
| 55 tri_view_->SetContainerVisible(TriView::Container::END, false); | 54 tri_view_->SetContainerVisible(TriView::Container::END, false); |
| 56 | 55 |
| 57 if (TrayPopupUtils::CanOpenWebUISettings(login)) | 56 if (TrayPopupUtils::CanOpenWebUISettings()) |
| 58 date_view_->SetAction(tray::DateView::DateAction::SHOW_DATE_SETTINGS); | 57 date_view_->SetAction(tray::DateView::DateAction::SHOW_DATE_SETTINGS); |
| 59 } | 58 } |
| 60 | 59 |
| 61 SystemInfoDefaultView::~SystemInfoDefaultView() {} | 60 SystemInfoDefaultView::~SystemInfoDefaultView() {} |
| 62 | 61 |
| 63 tray::DateView* SystemInfoDefaultView::GetDateView() { | 62 tray::DateView* SystemInfoDefaultView::GetDateView() { |
| 64 return date_view_; | 63 return date_view_; |
| 65 } | 64 } |
| 66 | 65 |
| 67 const tray::DateView* SystemInfoDefaultView::GetDateView() const { | 66 const tray::DateView* SystemInfoDefaultView::GetDateView() const { |
| (...skipping 18 matching lines...) Expand all Loading... |
| 86 num_extra_tile_widths = std::ceil(preferred_width_ratio); | 85 num_extra_tile_widths = std::ceil(preferred_width_ratio); |
| 87 } | 86 } |
| 88 num_extra_tile_widths = | 87 num_extra_tile_widths = |
| 89 std::max(kMinNumTileWidths - 1, | 88 std::max(kMinNumTileWidths - 1, |
| 90 std::min(num_extra_tile_widths, kMaxNumTileWidths - 1)); | 89 std::min(num_extra_tile_widths, kMaxNumTileWidths - 1)); |
| 91 | 90 |
| 92 return kMenuButtonSize + num_extra_tile_widths * snap_to_width; | 91 return kMenuButtonSize + num_extra_tile_widths * snap_to_width; |
| 93 } | 92 } |
| 94 | 93 |
| 95 } // namespace ash | 94 } // namespace ash |
| OLD | NEW |