tray_info_label.cc 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. // Copyright 2017 The Chromium Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style license that can be
  3. // found in the LICENSE file.
  4. #include "ash/system/tray/tray_info_label.h"
  5. #include "ash/style/ash_color_provider.h"
  6. #include "ash/system/tray/tray_popup_utils.h"
  7. #include "ui/base/l10n/l10n_util.h"
  8. #include "ui/views/layout/fill_layout.h"
  9. namespace ash {
  10. TrayInfoLabel::TrayInfoLabel(int message_id)
  11. : label_(TrayPopupUtils::CreateDefaultLabel()) {
  12. SetLayoutManager(std::make_unique<views::FillLayout>());
  13. TriView* tri_view = TrayPopupUtils::CreateDefaultRowView();
  14. tri_view->SetInsets(gfx::Insets::TLBR(
  15. 0, kMenuExtraMarginFromLeftEdge + kTrayPopupItemMinStartWidth, 0,
  16. kTrayPopupPaddingHorizontal));
  17. tri_view->SetContainerVisible(TriView::Container::START, false);
  18. tri_view->SetContainerVisible(TriView::Container::END, false);
  19. tri_view->AddView(TriView::Container::CENTER, label_);
  20. AddChildView(tri_view);
  21. SetFocusBehavior(FocusBehavior::NEVER);
  22. Update(message_id);
  23. }
  24. TrayInfoLabel::~TrayInfoLabel() = default;
  25. void TrayInfoLabel::Update(int message_id) {
  26. label_->SetEnabledColor(AshColorProvider::Get()->GetContentLayerColor(
  27. AshColorProvider::ContentLayerType::kTextColorPrimary));
  28. TrayPopupUtils::SetLabelFontList(label_,
  29. TrayPopupUtils::FontStyle::kSystemInfo);
  30. label_->SetText(l10n_util::GetStringUTF16(message_id));
  31. }
  32. const char* TrayInfoLabel::GetClassName() const {
  33. return "TrayInfoLabel";
  34. }
  35. } // namespace ash