autozoom_nudge.cc 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. // Copyright 2022 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/camera/autozoom_nudge.h"
  5. #include <memory>
  6. #include "ash/constants/notifier_catalogs.h"
  7. #include "ash/resources/vector_icons/vector_icons.h"
  8. #include "ash/strings/grit/ash_strings.h"
  9. #include "ash/style/ash_color_provider.h"
  10. #include "ash/system/tray/system_nudge_label.h"
  11. #include "ui/base/l10n/l10n_util.h"
  12. #include "ui/gfx/paint_vector_icon.h"
  13. namespace ash {
  14. namespace {
  15. // The size of the autozoom icon.
  16. constexpr int kAutozoomIconSize = 20;
  17. // The minimum width of the label.
  18. constexpr int kMinLabelWidth = 220;
  19. // The spacing between the icon and label in the nudge view.
  20. constexpr int kIconLabelSpacing = 16;
  21. // The padding which separates the nudge's border with its inner contents.
  22. constexpr int kNudgePadding = 16;
  23. constexpr char kAutozoomNudgeName[] = "AutozoomNudge";
  24. } // namespace
  25. AutozoomNudge::AutozoomNudge()
  26. : SystemNudge(kAutozoomNudgeName,
  27. NudgeCatalogName::kAutozoom,
  28. kAutozoomIconSize,
  29. kIconLabelSpacing,
  30. kNudgePadding,
  31. /*anchor_status_area=*/true,
  32. AshColorProvider::ContentLayerType::kIconColorProminent) {}
  33. AutozoomNudge::~AutozoomNudge() = default;
  34. std::unique_ptr<SystemNudgeLabel> AutozoomNudge::CreateLabelView() const {
  35. std::u16string label_text = l10n_util::GetStringUTF16(
  36. IDS_ASH_STATUS_TRAY_AUTOZOOM_EDUCATIONAL_NUDGE_TEXT);
  37. // Set the label's text.
  38. auto label = std::make_unique<SystemNudgeLabel>(label_text, kMinLabelWidth);
  39. label->set_font_size_delta(2);
  40. return label;
  41. }
  42. const gfx::VectorIcon& AutozoomNudge::GetIcon() const {
  43. return kUnifiedMenuAutozoomIcon;
  44. }
  45. std::u16string AutozoomNudge::GetAccessibilityText() const {
  46. return l10n_util::GetStringUTF16(
  47. IDS_ASH_STATUS_TRAY_AUTOZOOM_EDUCATIONAL_NUDGE_TEXT);
  48. }
  49. } // namespace ash