Commit 560122c9 authored by Matthew Mourgos's avatar Matthew Mourgos Committed by Commit Bot

cros: Add outlines for top icons within folder ghost image view.

Bug: 914094
Change-Id: Ifa8cff6cc777838a36c8774d1e04755396b3c68e
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1677596
Commit-Queue: Matthew Mourgos <mmourgos@chromium.org>
Reviewed-by: default avatarAlex Newcomer <newcomer@chromium.org>
Cr-Commit-Position: refs/heads/master@{#672737}
parent b2a1cf83
...@@ -3334,10 +3334,11 @@ void AppsGridView::CreateGhostImageView() { ...@@ -3334,10 +3334,11 @@ void AppsGridView::CreateGhostImageView() {
// GhostImageView that will fade in. // GhostImageView that will fade in.
last_ghost_view_ = current_ghost_view_; last_ghost_view_ = current_ghost_view_;
current_ghost_view_ = new GhostImageView( current_ghost_view_ =
drag_view_, IsFolderItem(drag_view_->item()) /* is_folder */, new GhostImageView(IsFolderItem(drag_view_->item()) /* is_folder */,
folder_delegate_, GetExpectedTileBounds(reorder_placeholder_), folder_delegate_, reorder_placeholder_.page);
reorder_placeholder_.page); current_ghost_view_->Init(drag_view_,
GetExpectedTileBounds(reorder_placeholder_));
AddChildView(current_ghost_view_); AddChildView(current_ghost_view_);
current_ghost_view_->FadeIn(); current_ghost_view_->FadeIn();
} }
......
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
#include "ash/app_list/model/app_list_folder_item.h" #include "ash/app_list/model/app_list_folder_item.h"
#include "ash/app_list/model/app_list_item_list.h" #include "ash/app_list/model/app_list_item_list.h"
#include "ash/app_list/views/app_list_item_view.h" #include "ash/app_list/views/app_list_item_view.h"
#include "ash/public/cpp/app_list/app_list_config.h"
#include "third_party/skia/include/core/SkPaint.h" #include "third_party/skia/include/core/SkPaint.h"
#include "ui/compositor/scoped_layer_animation_settings.h" #include "ui/compositor/scoped_layer_animation_settings.h"
#include "ui/gfx/animation/tween.h" #include "ui/gfx/animation/tween.h"
...@@ -28,7 +29,6 @@ constexpr int kRootGridGhostColor = gfx::kGoogleGrey200; ...@@ -28,7 +29,6 @@ constexpr int kRootGridGhostColor = gfx::kGoogleGrey200;
constexpr int kInFolderGhostColor = gfx::kGoogleGrey700; constexpr int kInFolderGhostColor = gfx::kGoogleGrey700;
constexpr base::TimeDelta kGhostFadeInOutLength = constexpr base::TimeDelta kGhostFadeInOutLength =
base::TimeDelta::FromMilliseconds(180); base::TimeDelta::FromMilliseconds(180);
constexpr int kInnerFolderGhostIconRadius = 14;
constexpr gfx::Tween::Type kGhostTween = gfx::Tween::FAST_OUT_SLOW_IN; constexpr gfx::Tween::Type kGhostTween = gfx::Tween::FAST_OUT_SLOW_IN;
constexpr int kAlphaGradient = 2; constexpr int kAlphaGradient = 2;
constexpr int kAlphaChannelFilter = 180; constexpr int kAlphaChannelFilter = 180;
...@@ -43,37 +43,45 @@ constexpr int kGhostImagePadding = 5; ...@@ -43,37 +43,45 @@ constexpr int kGhostImagePadding = 5;
} // namespace } // namespace
GhostImageView::GhostImageView(AppListItemView* drag_view, GhostImageView::GhostImageView(bool is_folder, bool is_in_folder, int page)
bool is_folder,
bool is_in_folder,
const gfx::Rect& drop_target_bounds,
int page)
: is_hiding_(false), : is_hiding_(false),
is_in_folder_(is_in_folder), is_in_folder_(is_in_folder),
is_folder_(is_folder), is_folder_(is_folder),
page_(page), page_(page) {}
drop_target_bounds_(drop_target_bounds),
icon_bounds_(drag_view->GetIconBounds()) { GhostImageView::~GhostImageView() {
StopObservingImplicitAnimations();
}
void GhostImageView::Init(AppListItemView* drag_view,
const gfx::Rect& drop_target_bounds) {
SetPaintToLayer(); SetPaintToLayer();
layer()->SetFillsBoundsOpaquely(false); layer()->SetFillsBoundsOpaquely(false);
layer()->SetOpacity(0.0f); layer()->SetOpacity(0.0f);
SetBoundsRect(drop_target_bounds); SetBoundsRect(drop_target_bounds);
icon_bounds_ = drag_view->GetIconBounds();
if (is_folder_) { if (is_folder_) {
AppListFolderItem* folder_item = AppListFolderItem* folder_item =
static_cast<AppListFolderItem*>(drag_view->item()); static_cast<AppListFolderItem*>(drag_view->item());
num_items_ = std::min(FolderImage::kNumFolderTopItems, num_items_ = std::min(FolderImage::kNumFolderTopItems,
folder_item->item_list()->item_count()); folder_item->item_list()->item_count());
// Create an outline for each item within the folder icon.
for (size_t i = 0; i < num_items_.value(); i++) {
gfx::ImageSkia inner_icon_outline =
gfx::ImageSkiaOperations::CreateResizedImage(
folder_item->item_list()->item_at(i)->icon(),
skia::ImageOperations::RESIZE_BEST,
AppListConfig::instance().item_icon_in_folder_icon_size());
inner_folder_icon_outlines_.push_back(GetIconOutline(inner_icon_outline));
}
} else { } else {
// Create outline of app icon and set |outline_| to it. // Create outline of app icon and set |outline_| to it.
outline_ = GetIconOutline(drag_view->GetIconImage()); outline_ = GetIconOutline(drag_view->GetIconImage());
} }
} }
GhostImageView::~GhostImageView() {
StopObservingImplicitAnimations();
}
void GhostImageView::FadeOut() { void GhostImageView::FadeOut() {
if (is_hiding_) if (is_hiding_)
return; return;
...@@ -87,7 +95,7 @@ void GhostImageView::FadeIn() { ...@@ -87,7 +95,7 @@ void GhostImageView::FadeIn() {
void GhostImageView::SetTransitionOffset( void GhostImageView::SetTransitionOffset(
const gfx::Vector2d& transition_offset) { const gfx::Vector2d& transition_offset) {
SetPosition(drop_target_bounds_.origin() + transition_offset); SetPosition(bounds().origin() + transition_offset);
} }
const char* GhostImageView::GetClassName() const { const char* GhostImageView::GetClassName() const {
...@@ -138,9 +146,10 @@ void GhostImageView::OnPaint(gfx::Canvas* canvas) { ...@@ -138,9 +146,10 @@ void GhostImageView::OnPaint(gfx::Canvas* canvas) {
FolderImage::GetTopIconsBounds(icon_bounds_, num_items_.value()); FolderImage::GetTopIconsBounds(icon_bounds_, num_items_.value());
// Draw ghost items within the ghost folder circle. // Draw ghost items within the ghost folder circle.
for (gfx::Rect bounds : top_icon_bounds) { for (size_t i = 0; i < num_items_.value(); i++) {
canvas->DrawCircle(gfx::PointF(bounds.CenterPoint()), canvas->DrawImageInt(inner_folder_icon_outlines_[i],
kInnerFolderGhostIconRadius, circle_flags); top_icon_bounds[i].x() - kGhostImagePadding,
top_icon_bounds[i].y() - kGhostImagePadding);
} }
} else { } else {
canvas->DrawImageInt(outline_, icon_bounds_.x() - kGhostImagePadding, canvas->DrawImageInt(outline_, icon_bounds_.x() - kGhostImagePadding,
...@@ -162,6 +171,7 @@ gfx::ImageSkia GhostImageView::GetIconOutline( ...@@ -162,6 +171,7 @@ gfx::ImageSkia GhostImageView::GetIconOutline(
const gfx::ImageSkia& original_icon) { const gfx::ImageSkia& original_icon) {
gfx::ImageSkia icon_outline; gfx::ImageSkia icon_outline;
original_icon.EnsureRepsForSupportedScales();
for (gfx::ImageSkiaRep rep : original_icon.image_reps()) { for (gfx::ImageSkiaRep rep : original_icon.image_reps()) {
// Only generate the outline for the ImageSkiaRep with the highest supported // Only generate the outline for the ImageSkiaRep with the highest supported
// scale. // scale.
......
...@@ -20,13 +20,12 @@ class AppListItemView; ...@@ -20,13 +20,12 @@ class AppListItemView;
class GhostImageView : public views::ImageView, class GhostImageView : public views::ImageView,
public ui::ImplicitAnimationObserver { public ui::ImplicitAnimationObserver {
public: public:
GhostImageView(AppListItemView* drag_view, GhostImageView(bool is_folder, bool is_in_folder, int page);
bool is_folder,
bool is_in_folder,
const gfx::Rect& drop_target_bounds,
int page);
~GhostImageView() override; ~GhostImageView() override;
// Initialize the GhostImageView.
void Init(AppListItemView* drag_view, const gfx::Rect& drop_target_bounds);
// Begins the fade out animation. // Begins the fade out animation.
void FadeOut(); void FadeOut();
...@@ -67,10 +66,6 @@ class GhostImageView : public views::ImageView, ...@@ -67,10 +66,6 @@ class GhostImageView : public views::ImageView,
// Page this this view belongs to, used to calculate transition offset. // Page this this view belongs to, used to calculate transition offset.
int page_; int page_;
// Bounds for the location of the GhostImageView in parent AppGridView's
// coordinates.
gfx::Rect drop_target_bounds_;
// Icon bounds used to determine size and placement of the GhostImageView. // Icon bounds used to determine size and placement of the GhostImageView.
gfx::Rect icon_bounds_; gfx::Rect icon_bounds_;
...@@ -80,6 +75,10 @@ class GhostImageView : public views::ImageView, ...@@ -80,6 +75,10 @@ class GhostImageView : public views::ImageView,
// The outline of the dragged item's icon. Used as the ghost image. // The outline of the dragged item's icon. Used as the ghost image.
gfx::ImageSkia outline_; gfx::ImageSkia outline_;
// The outlines of the top icons within a folder. Used for the folder ghost
// image.
std::vector<gfx::ImageSkia> inner_folder_icon_outlines_;
DISALLOW_COPY_AND_ASSIGN(GhostImageView); DISALLOW_COPY_AND_ASSIGN(GhostImageView);
}; };
......
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