Commit b3fcdfa7 authored by Ahmed Mehfooz's avatar Ahmed Mehfooz Committed by Commit Bot

Add screenshots skeleton code in holding space tray

Bug: 1124145
Change-Id: I620444d44648a2b1d408f12a1b9137c23012e72c
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2388859
Commit-Queue: Ahmed Mehfooz <amehfooz@chromium.org>
Reviewed-by: default avatarDavid Black <dmblack@google.com>
Reviewed-by: default avatarXiyuan Xia <xiyuan@chromium.org>
Cr-Commit-Position: refs/heads/master@{#804042}
parent c96cc95a
...@@ -921,6 +921,8 @@ component("ash") { ...@@ -921,6 +921,8 @@ component("ash") {
"system/holding_space/holding_space_item_chip_view.h", "system/holding_space/holding_space_item_chip_view.h",
"system/holding_space/holding_space_item_chips_container.cc", "system/holding_space/holding_space_item_chips_container.cc",
"system/holding_space/holding_space_item_chips_container.h", "system/holding_space/holding_space_item_chips_container.h",
"system/holding_space/holding_space_screenshot_view.cc",
"system/holding_space/holding_space_screenshot_view.h",
"system/holding_space/holding_space_tray.cc", "system/holding_space/holding_space_tray.cc",
"system/holding_space/holding_space_tray.h", "system/holding_space/holding_space_tray.h",
"system/holding_space/pinned_files_container.cc", "system/holding_space/pinned_files_container.cc",
......
// Copyright 2020 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "ash/system/holding_space/holding_space_screenshot_view.h"
#include "ash/public/cpp/holding_space/holding_space_image.h"
#include "ash/public/cpp/holding_space/holding_space_item.h"
#include "ash/system/tray/tray_constants.h"
#include "ash/system/user/rounded_image_view.h"
#include "ui/views/layout/fill_layout.h"
namespace ash {
HoldingSpaceScreenshotView::HoldingSpaceScreenshotView(
const HoldingSpaceItem* item)
: item_(item) {
SetLayoutManager(std::make_unique<views::FillLayout>());
SetPaintToLayer();
layer()->SetFillsBoundsOpaquely(false);
SetFocusBehavior(FocusBehavior::ALWAYS);
image_ =
AddChildView(std::make_unique<tray::RoundedImageView>(kTrayItemSize / 2));
Update();
}
HoldingSpaceScreenshotView::~HoldingSpaceScreenshotView() = default;
const char* HoldingSpaceScreenshotView::GetClassName() const {
return "HoldingSpaceScreenshotView";
}
void HoldingSpaceScreenshotView::Update() {
image_->SetImage(item_->image().image_skia(), kHoldingSpaceScreenshotSize);
}
} // namespace ash
// Copyright 2020 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef ASH_SYSTEM_HOLDING_SPACE_HOLDING_SPACE_SCREENSHOT_VIEW_H_
#define ASH_SYSTEM_HOLDING_SPACE_HOLDING_SPACE_SCREENSHOT_VIEW_H_
#include "ash/ash_export.h"
#include "ui/views/view.h"
namespace ash {
class HoldingSpaceItem;
namespace tray {
class RoundedImageView;
} // namespace tray
class ASH_EXPORT HoldingSpaceScreenshotView : public views::View {
public:
explicit HoldingSpaceScreenshotView(const HoldingSpaceItem* item);
HoldingSpaceScreenshotView(const HoldingSpaceScreenshotView&) = delete;
HoldingSpaceScreenshotView& operator=(const HoldingSpaceScreenshotView&) =
delete;
~HoldingSpaceScreenshotView() override;
// views::View:
const char* GetClassName() const override;
private:
void Update();
const HoldingSpaceItem* const item_;
tray::RoundedImageView* image_ = nullptr;
};
} // namespace ash
#endif // ASH_SYSTEM_HOLDING_SPACE_HOLDING_SPACE_SCREENSHOT_VIEW_H_
...@@ -4,7 +4,11 @@ ...@@ -4,7 +4,11 @@
#include "ash/system/holding_space/recent_files_container.h" #include "ash/system/holding_space/recent_files_container.h"
#include "ash/public/cpp/holding_space/holding_space_controller.h"
#include "ash/public/cpp/holding_space/holding_space_item.h"
#include "ash/public/cpp/holding_space/holding_space_model.h"
#include "ash/strings/grit/ash_strings.h" #include "ash/strings/grit/ash_strings.h"
#include "ash/system/holding_space/holding_space_screenshot_view.h"
#include "ash/system/tray/tray_constants.h" #include "ash/system/tray/tray_constants.h"
#include "ash/system/tray/tray_popup_item_style.h" #include "ash/system/tray/tray_popup_item_style.h"
#include "ui/base/l10n/l10n_util.h" #include "ui/base/l10n/l10n_util.h"
...@@ -30,9 +34,19 @@ RecentFilesContainer::RecentFilesContainer() { ...@@ -30,9 +34,19 @@ RecentFilesContainer::RecentFilesContainer() {
true /* use_unified_theme */); true /* use_unified_theme */);
style.SetupLabel(screenshots_label); style.SetupLabel(screenshots_label);
auto* screenshots_separator = screenshots_container_ = AddChildView(std::make_unique<views::View>());
AddChildView(std::make_unique<views::Separator>()); screenshots_container_->SetLayoutManager(std::make_unique<views::BoxLayout>(
screenshots_separator->SetBorder(views::CreateEmptyBorder(72, 0, 0, 0)); views::BoxLayout::Orientation::kHorizontal, gfx::Insets(16, 0, 24, 0),
8));
// TODO(amehfooz): Populate containers if and when holding space model is
// attached, below is a temporary solution.
for (const auto& item : HoldingSpaceController::Get()->model()->items()) {
if (item->type() == HoldingSpaceItem::Type::kScreenshot) {
screenshots_container_->AddChildView(
std::make_unique<HoldingSpaceScreenshotView>(item.get()));
}
}
auto* recent_downloads_label = AddChildView(std::make_unique<views::Label>( auto* recent_downloads_label = AddChildView(std::make_unique<views::Label>(
l10n_util::GetStringUTF16(IDS_ASH_HOLDING_SPACE_RECENT_DOWNLOADS_TITLE))); l10n_util::GetStringUTF16(IDS_ASH_HOLDING_SPACE_RECENT_DOWNLOADS_TITLE)));
......
...@@ -19,6 +19,9 @@ class RecentFilesContainer : public views::View { ...@@ -19,6 +19,9 @@ class RecentFilesContainer : public views::View {
// views::View: // views::View:
const char* GetClassName() const override; const char* GetClassName() const override;
private:
views::View* screenshots_container_ = nullptr;
}; };
} // namespace ash } // namespace ash
......
...@@ -242,7 +242,9 @@ constexpr int kHoldingSpaceChipCornerRadius = 8; ...@@ -242,7 +242,9 @@ constexpr int kHoldingSpaceChipCornerRadius = 8;
constexpr int kHoldingSpaceContainerSeparation = 8; constexpr int kHoldingSpaceContainerSeparation = 8;
constexpr int kHoldingSpaceColumnWidth = 160; constexpr int kHoldingSpaceColumnWidth = 160;
constexpr int kHoldingSpaceColumnPadding = 8; constexpr int kHoldingSpaceColumnPadding = 8;
constexpr gfx::Size kHoldingSpaceScreenshotSize(104, 80);
constexpr int kHoldingSpaceRowPadding = 8; constexpr int kHoldingSpaceRowPadding = 8;
// Constants used for media tray. // Constants used for media tray.
constexpr int kMediaTrayPadding = 8; constexpr int kMediaTrayPadding = 8;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment