screen_captures_section.cc 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  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/system/holding_space/screen_captures_section.h"
  5. #include "ash/bubble/bubble_utils.h"
  6. #include "ash/public/cpp/holding_space/holding_space_constants.h"
  7. #include "ash/public/cpp/holding_space/holding_space_item.h"
  8. #include "ash/strings/grit/ash_strings.h"
  9. #include "ash/system/holding_space/holding_space_item_screen_capture_view.h"
  10. #include "ui/base/l10n/l10n_util.h"
  11. #include "ui/compositor/layer.h"
  12. #include "ui/views/accessibility/view_accessibility.h"
  13. #include "ui/views/controls/label.h"
  14. #include "ui/views/layout/flex_layout.h"
  15. #include "ui/views/view_class_properties.h"
  16. namespace ash {
  17. ScreenCapturesSection::ScreenCapturesSection(HoldingSpaceViewDelegate* delegate)
  18. : HoldingSpaceItemViewsSection(delegate,
  19. /*supported_types=*/
  20. {HoldingSpaceItem::Type::kScreenshot,
  21. HoldingSpaceItem::Type::kScreenRecording},
  22. /*max_count=*/kMaxScreenCaptures) {}
  23. ScreenCapturesSection::~ScreenCapturesSection() = default;
  24. const char* ScreenCapturesSection::GetClassName() const {
  25. return "ScreenCapturesSection";
  26. }
  27. std::unique_ptr<views::View> ScreenCapturesSection::CreateHeader() {
  28. auto header = bubble_utils::CreateLabel(
  29. bubble_utils::LabelStyle::kHeader,
  30. l10n_util::GetStringUTF16(IDS_ASH_HOLDING_SPACE_SCREEN_CAPTURES_TITLE));
  31. header->SetHorizontalAlignment(gfx::HorizontalAlignment::ALIGN_LEFT);
  32. header->SetPaintToLayer();
  33. header->layer()->SetFillsBoundsOpaquely(false);
  34. return header;
  35. }
  36. std::unique_ptr<views::View> ScreenCapturesSection::CreateContainer() {
  37. auto container = std::make_unique<views::View>();
  38. container->SetLayoutManager(std::make_unique<views::FlexLayout>())
  39. ->SetOrientation(views::LayoutOrientation::kHorizontal)
  40. .SetDefault(views::kMarginsKey,
  41. gfx::Insets::TLBR(0, 0, 0,
  42. kHoldingSpaceSectionContainerChildSpacing));
  43. return container;
  44. }
  45. std::unique_ptr<HoldingSpaceItemView> ScreenCapturesSection::CreateView(
  46. const HoldingSpaceItem* item) {
  47. return std::make_unique<HoldingSpaceItemScreenCaptureView>(delegate(), item);
  48. }
  49. } // namespace ash