holding_space_item_chip_view.h 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  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. #ifndef ASH_SYSTEM_HOLDING_SPACE_HOLDING_SPACE_ITEM_CHIP_VIEW_H_
  5. #define ASH_SYSTEM_HOLDING_SPACE_HOLDING_SPACE_ITEM_CHIP_VIEW_H_
  6. #include "ash/ash_export.h"
  7. #include "ash/public/cpp/holding_space/holding_space_image.h"
  8. #include "ash/system/holding_space/holding_space_animation_registry.h"
  9. #include "ash/system/holding_space/holding_space_item_view.h"
  10. #include "ui/base/metadata/metadata_header_macros.h"
  11. #include "ui/views/metadata/view_factory.h"
  12. namespace views {
  13. class ImageButton;
  14. class Label;
  15. } // namespace views
  16. namespace ash {
  17. class HoldingSpaceItem;
  18. class HoldingSpaceViewDelegate;
  19. class ProgressIndicator;
  20. class RoundedImageView;
  21. // A button with an image derived from a file's thumbnail and file's name as the
  22. // label.
  23. class ASH_EXPORT HoldingSpaceItemChipView : public HoldingSpaceItemView {
  24. public:
  25. METADATA_HEADER(HoldingSpaceItemChipView);
  26. HoldingSpaceItemChipView(HoldingSpaceViewDelegate* delegate,
  27. const HoldingSpaceItem* item);
  28. HoldingSpaceItemChipView(const HoldingSpaceItemChipView&) = delete;
  29. HoldingSpaceItemChipView& operator=(const HoldingSpaceItemChipView&) = delete;
  30. ~HoldingSpaceItemChipView() override;
  31. private:
  32. // HoldingSpaceItemView:
  33. views::View* GetTooltipHandlerForPoint(const gfx::Point& point) override;
  34. std::u16string GetTooltipText(const gfx::Point& point) const override;
  35. void OnHoldingSpaceItemUpdated(const HoldingSpaceItem* item,
  36. uint32_t updated_fields) override;
  37. void OnPrimaryActionVisibilityChanged(bool visible) override;
  38. void OnSelectionUiChanged() override;
  39. void OnMouseEvent(ui::MouseEvent* event) override;
  40. void OnThemeChanged() override;
  41. // Invoked during `label`'s paint sequence to paint its optional mask. Note
  42. // that `label` is only masked when the `primary_action_container()` is
  43. // visible to avoid overlapping.
  44. void OnPaintLabelMask(views::Label* label, gfx::Canvas* canvas);
  45. // Invoked when the secondary action is pressed. This will be one of either
  46. // `secondary_action_pause_` or `secondary_action_resume_`.
  47. void OnSecondaryActionPressed();
  48. void UpdateImage();
  49. void UpdateImageAndProgressIndicatorVisibility();
  50. void UpdateImageTransform();
  51. void UpdateLabels();
  52. void UpdateSecondaryAction();
  53. // Owned by view hierarchy.
  54. RoundedImageView* image_ = nullptr;
  55. views::Label* primary_label_ = nullptr;
  56. views::Label* secondary_label_ = nullptr;
  57. views::View* secondary_action_container_ = nullptr;
  58. views::ImageButton* secondary_action_pause_ = nullptr;
  59. views::ImageButton* secondary_action_resume_ = nullptr;
  60. ProgressIndicator* progress_indicator_ = nullptr;
  61. base::CallbackListSubscription image_skia_changed_subscription_;
  62. base::CallbackListSubscription progress_ring_animation_changed_subscription_;
  63. };
  64. BEGIN_VIEW_BUILDER(/* no export */,
  65. HoldingSpaceItemChipView,
  66. HoldingSpaceItemView)
  67. END_VIEW_BUILDER
  68. } // namespace ash
  69. DEFINE_VIEW_BUILDER(/* no export */, ash::HoldingSpaceItemChipView)
  70. #endif // ASH_SYSTEM_HOLDING_SPACE_HOLDING_SPACE_ITEM_CHIP_VIEW_H_