clipboard_history_label.cc 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. // Copyright 2020 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/clipboard/views/clipboard_history_label.h"
  5. #include "ash/clipboard/views/clipboard_history_view_constants.h"
  6. #include "ash/public/cpp/style/scoped_light_mode_as_default.h"
  7. #include "ash/style/ash_color_provider.h"
  8. namespace ash {
  9. ClipboardHistoryLabel::ClipboardHistoryLabel(const std::u16string& text)
  10. : views::Label(text) {
  11. SetPreferredSize(
  12. gfx::Size(INT_MAX, ClipboardHistoryViews::kLabelPreferredHeight));
  13. SetFontList(views::style::GetFont(views::style::CONTEXT_TOUCH_MENU,
  14. views::style::STYLE_PRIMARY));
  15. SetMultiLine(false);
  16. SetHorizontalAlignment(gfx::ALIGN_LEFT);
  17. SetAutoColorReadabilityEnabled(false);
  18. }
  19. const char* ClipboardHistoryLabel::GetClassName() const {
  20. return "ClipboardHistoryLabel";
  21. }
  22. void ClipboardHistoryLabel::OnThemeChanged() {
  23. views::Label::OnThemeChanged();
  24. // Use the light mode as default because the light mode is the default mode of
  25. // the native theme which decides the context menu's background color.
  26. // TODO(andrewxu): remove this line after https://crbug.com/1143009 is fixed.
  27. ash::ScopedLightModeAsDefault scoped_light_mode_as_default;
  28. SetEnabledColor(ash::AshColorProvider::Get()->GetContentLayerColor(
  29. ash::AshColorProvider::ContentLayerType::kTextColorPrimary));
  30. }
  31. } // namespace ash