search_result_inline_icon_view.h 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  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. #ifndef ASH_APP_LIST_VIEWS_SEARCH_RESULT_INLINE_ICON_VIEW_H_
  5. #define ASH_APP_LIST_VIEWS_SEARCH_RESULT_INLINE_ICON_VIEW_H_
  6. #include <string>
  7. #include "ash/ash_export.h"
  8. #include "ui/gfx/vector_icon_types.h"
  9. #include "ui/views/view.h"
  10. namespace views {
  11. class ImageView;
  12. class Label;
  13. } // namespace views
  14. namespace ash {
  15. // Displays a rounded rect bubble containing styled text xor a vector icon.
  16. class ASH_EXPORT SearchResultInlineIconView : public views::View {
  17. public:
  18. SearchResultInlineIconView();
  19. SearchResultInlineIconView(const SearchResultInlineIconView&) = delete;
  20. SearchResultInlineIconView& operator=(const SearchResultInlineIconView&) =
  21. delete;
  22. ~SearchResultInlineIconView() override;
  23. // Setup the `SearchResultInlineIconView` to show an icon or iconified text.
  24. // Showing both in the same view is not supported.
  25. void SetIcon(const gfx::VectorIcon& icon);
  26. void SetText(const std::u16string& text);
  27. private:
  28. class SizedLabel;
  29. // views::View:
  30. void OnPaint(gfx::Canvas* canvas) override;
  31. void OnThemeChanged() override;
  32. // Cached icon used to recolor icon_image_ when OnThemeChanged() is called.
  33. const gfx::VectorIcon* icon_ = nullptr;
  34. views::ImageView* icon_image_ = nullptr; // Owned by views hierarchy.
  35. views::Label* label_ = nullptr; // Owned by views hierarchy.
  36. };
  37. } // namespace ash
  38. #endif // ASH_APP_LIST_VIEWS_SEARCH_RESULT_INLINE_ICON_VIEW_H_