Commit 0bd94959 authored by Jan Wilken Dörrie's avatar Jan Wilken Dörrie Committed by Commit Bot

Revert "Create separate class to handle creation of holding space bubble"

This reverts commit 349707ef.

Reason for revert: Suspected culprit of https://crbug.com/1132219.

Original change's description:
> Create separate class to handle creation of holding space bubble
>
> This class will own pinned_files_container and recent_files_container.
> It will also be responsible for setting the max size for the pinned
> files container based on available screen space and update it when
> screen space changes.
>
> Bug: 1131268
> Change-Id: If09810570e59f7beeac0667e84d4cd558ee67bc0
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2427081
> Commit-Queue: Ahmed Mehfooz <amehfooz@chromium.org>
> Reviewed-by: David Black <dmblack@google.com>
> Reviewed-by: Xiyuan Xia <xiyuan@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#810423}

TBR=xiyuan@chromium.org,dmblack@google.com,amehfooz@chromium.org

Change-Id: Ia221abfb393dcd7f9cdfa7e539133477bd7852ca
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: 1131268
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2429275Reviewed-by: default avatarJan Wilken Dörrie <jdoerrie@chromium.org>
Commit-Queue: Jan Wilken Dörrie <jdoerrie@chromium.org>
Cr-Commit-Position: refs/heads/master@{#810524}
parent 8a93e523
...@@ -936,8 +936,6 @@ component("ash") { ...@@ -936,8 +936,6 @@ component("ash") {
"system/holding_space/holding_space_item_views_container.h", "system/holding_space/holding_space_item_views_container.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/holding_space_tray_bubble.cc",
"system/holding_space/holding_space_tray_bubble.h",
"system/holding_space/pinned_files_container.cc", "system/holding_space/pinned_files_container.cc",
"system/holding_space/pinned_files_container.h", "system/holding_space/pinned_files_container.h",
"system/holding_space/recent_files_container.cc", "system/holding_space/recent_files_container.cc",
......
...@@ -12,7 +12,6 @@ ...@@ -12,7 +12,6 @@
namespace ash { namespace ash {
// Appearance. // Appearance.
constexpr int kHoldingSpaceBubbleWidth = 360;
constexpr gfx::Insets kHoldingSpaceContainerPadding(16); constexpr gfx::Insets kHoldingSpaceContainerPadding(16);
constexpr int kHoldingSpaceContainerChildSpacing = 16; constexpr int kHoldingSpaceContainerChildSpacing = 16;
constexpr int kHoldingSpaceContainerSpacing = 8; constexpr int kHoldingSpaceContainerSpacing = 8;
......
...@@ -13,20 +13,42 @@ ...@@ -13,20 +13,42 @@
#include "ash/shelf/shelf.h" #include "ash/shelf/shelf.h"
#include "ash/shell.h" #include "ash/shell.h"
#include "ash/strings/grit/ash_strings.h" #include "ash/strings/grit/ash_strings.h"
#include "ash/system/holding_space/holding_space_tray_bubble.h" #include "ash/system/holding_space/pinned_files_container.h"
#include "ash/system/holding_space/recent_files_container.h"
#include "ash/system/tray/tray_bubble_wrapper.h"
#include "ash/system/tray/tray_constants.h"
#include "ash/system/tray/tray_container.h" #include "ash/system/tray/tray_container.h"
#include "ash/system/tray/tray_utils.h"
#include "ash/system/unified/unified_system_tray_view.h"
#include "ui/base/l10n/l10n_util.h" #include "ui/base/l10n/l10n_util.h"
#include "ui/gfx/paint_vector_icon.h" #include "ui/gfx/paint_vector_icon.h"
#include "ui/views/controls/image_view.h" #include "ui/views/controls/image_view.h"
#include "ui/views/controls/label.h" #include "ui/views/controls/label.h"
#include "ui/views/controls/separator.h"
#include "ui/views/layout/fill_layout.h" #include "ui/views/layout/fill_layout.h"
#include "ui/views/vector_icons.h" #include "ui/views/vector_icons.h"
namespace ash { namespace ash {
namespace { namespace {
// Padding for tray icon (dp; the button that shows the palette menu). // Padding for tray icon (dp; the button that shows the palette menu).
constexpr int kTrayIconMainAxisInset = 6; constexpr int kTrayIconMainAxisInset = 6;
// Width of the holding space bubble itself (dp).
constexpr int kHoldingSpaceWidth = 360;
void SetupChildLayer(views::View* child) {
child->SetPaintToLayer(ui::LAYER_SOLID_COLOR);
auto* layer = child->layer();
layer->SetRoundedCornerRadius(gfx::RoundedCornersF{kUnifiedTrayCornerRadius});
layer->SetColor(UnifiedSystemTrayView::GetBackgroundColor());
layer->SetBackgroundBlur(kUnifiedMenuBackgroundBlur);
layer->SetFillsBoundsOpaquely(false);
layer->SetIsFastRoundedCorner(true);
}
} // namespace } // namespace
HoldingSpaceTray::HoldingSpaceTray(Shelf* shelf) : TrayBackgroundView(shelf) { HoldingSpaceTray::HoldingSpaceTray(Shelf* shelf) : TrayBackgroundView(shelf) {
...@@ -41,7 +63,20 @@ HoldingSpaceTray::HoldingSpaceTray(Shelf* shelf) : TrayBackgroundView(shelf) { ...@@ -41,7 +63,20 @@ HoldingSpaceTray::HoldingSpaceTray(Shelf* shelf) : TrayBackgroundView(shelf) {
tray_container()->SetMargin(kTrayIconMainAxisInset, 0); tray_container()->SetMargin(kTrayIconMainAxisInset, 0);
} }
HoldingSpaceTray::~HoldingSpaceTray() = default; HoldingSpaceTray::~HoldingSpaceTray() {
if (bubble_) {
// View hierarchy must not outlive `this`.
bubble_->bubble_view()->ResetDelegate();
bubble_->GetBubbleWidget()->CloseNow();
}
}
bool HoldingSpaceTray::ContainsPointInScreen(const gfx::Point& point) {
if (GetBoundsInScreen().Contains(point))
return true;
return bubble_ && bubble_->bubble_view()->GetBoundsInScreen().Contains(point);
}
void HoldingSpaceTray::ClickedOutsideBubble() { void HoldingSpaceTray::ClickedOutsideBubble() {
CloseBubble(); CloseBubble();
...@@ -72,7 +107,7 @@ void HoldingSpaceTray::HideBubble(const TrayBubbleView* bubble_view) { ...@@ -72,7 +107,7 @@ void HoldingSpaceTray::HideBubble(const TrayBubbleView* bubble_view) {
void HoldingSpaceTray::AnchorUpdated() { void HoldingSpaceTray::AnchorUpdated() {
if (bubble_) if (bubble_)
bubble_->AnchorUpdated(); bubble_->bubble_view()->UpdateBubble();
} }
bool HoldingSpaceTray::PerformAction(const ui::Event& event) { bool HoldingSpaceTray::PerformAction(const ui::Event& event) {
...@@ -101,11 +136,51 @@ void HoldingSpaceTray::ShowBubble(bool show_by_click) { ...@@ -101,11 +136,51 @@ void HoldingSpaceTray::ShowBubble(bool show_by_click) {
DCHECK(tray_container()); DCHECK(tray_container());
bubble_ = std::make_unique<HoldingSpaceTrayBubble>(this, show_by_click); TrayBubbleView::InitParams init_params;
init_params.delegate = this;
init_params.parent_window = GetBubbleWindowContainer();
init_params.anchor_view = GetBubbleAnchor();
init_params.shelf_alignment = shelf()->alignment();
init_params.preferred_width = kHoldingSpaceWidth;
init_params.close_on_deactivate = true;
init_params.show_by_click = show_by_click;
init_params.has_shadow = false;
// Create and customize bubble view.
TrayBubbleView* bubble_view = new TrayBubbleView(init_params);
bubble_view->set_anchor_view_insets(GetBubbleAnchorInsets());
bubble_view->set_margins(GetSecondaryBubbleInsets());
// Add pinned files container.
pinned_files_container_ = bubble_view->AddChildView(
std::make_unique<PinnedFilesContainer>(&delegate_));
SetupChildLayer(pinned_files_container_);
// Separator between the two containers, gives illusion of 2 separate bubbles.
auto* separator =
bubble_view->AddChildView(std::make_unique<views::Separator>());
separator->SetBorder(views::CreateEmptyBorder(
gfx::Insets(kHoldingSpaceContainerSpacing, 0, 0, 0)));
recent_files_container_ = bubble_view->AddChildView(
std::make_unique<RecentFilesContainer>(&delegate_));
SetupChildLayer(recent_files_container_);
// Show the bubble.
bubble_ = std::make_unique<TrayBubbleWrapper>(this, bubble_view,
false /* is_persistent */);
// Set bubble frame to be invisible.
bubble_->GetBubbleWidget()->non_client_view()->frame_view()->SetVisible(
false);
SetIsActive(true); SetIsActive(true);
} }
TrayBubbleView* HoldingSpaceTray::GetBubbleView() {
return bubble_ ? bubble_->bubble_view() : nullptr;
}
const char* HoldingSpaceTray::GetClassName() const { const char* HoldingSpaceTray::GetClassName() const {
return "HoldingSpaceTray"; return "HoldingSpaceTray";
} }
......
...@@ -8,15 +8,24 @@ ...@@ -8,15 +8,24 @@
#include <memory> #include <memory>
#include "ash/ash_export.h" #include "ash/ash_export.h"
#include "ash/system/holding_space/holding_space_tray_bubble.h" #include "ash/system/holding_space/holding_space_item_view_delegate.h"
#include "ash/system/tray/tray_background_view.h" #include "ash/system/tray/tray_background_view.h"
#include "base/memory/weak_ptr.h" #include "base/memory/weak_ptr.h"
namespace gfx {
class Point;
}
namespace views { namespace views {
class ImageView; class ImageView;
} }
namespace ash { namespace ash {
class PinnedFilesContainer;
class RecentFilesContainer;
class TrayBubbleWrapper;
// The HoldingSpaceTray shows the tray button in the bottom area of the screen. // The HoldingSpaceTray shows the tray button in the bottom area of the screen.
// This class also controls the lifetime for all of the tools available in the // This class also controls the lifetime for all of the tools available in the
// palette. HoldingSpaceTray has one instance per-display. // palette. HoldingSpaceTray has one instance per-display.
...@@ -27,6 +36,10 @@ class ASH_EXPORT HoldingSpaceTray : public TrayBackgroundView { ...@@ -27,6 +36,10 @@ class ASH_EXPORT HoldingSpaceTray : public TrayBackgroundView {
HoldingSpaceTray& operator=(const HoldingSpaceTray& other) = delete; HoldingSpaceTray& operator=(const HoldingSpaceTray& other) = delete;
~HoldingSpaceTray() override; ~HoldingSpaceTray() override;
// Returns true if the tray contains the given point. This is useful
// for determining if an event should be propagated through to the palette.
bool ContainsPointInScreen(const gfx::Point& point);
// TrayBackgroundView: // TrayBackgroundView:
void ClickedOutsideBubble() override; void ClickedOutsideBubble() override;
base::string16 GetAccessibleNameForTray() override; base::string16 GetAccessibleNameForTray() override;
...@@ -37,6 +50,7 @@ class ASH_EXPORT HoldingSpaceTray : public TrayBackgroundView { ...@@ -37,6 +50,7 @@ class ASH_EXPORT HoldingSpaceTray : public TrayBackgroundView {
bool PerformAction(const ui::Event& event) override; bool PerformAction(const ui::Event& event) override;
void CloseBubble() override; void CloseBubble() override;
void ShowBubble(bool show_by_click) override; void ShowBubble(bool show_by_click) override;
TrayBubbleView* GetBubbleView() override;
const char* GetClassName() const override; const char* GetClassName() const override;
private: private:
...@@ -45,7 +59,14 @@ class ASH_EXPORT HoldingSpaceTray : public TrayBackgroundView { ...@@ -45,7 +59,14 @@ class ASH_EXPORT HoldingSpaceTray : public TrayBackgroundView {
bool ShouldEnableExtraKeyboardAccessibility() override; bool ShouldEnableExtraKeyboardAccessibility() override;
void HideBubble(const TrayBubbleView* bubble_view) override; void HideBubble(const TrayBubbleView* bubble_view) override;
std::unique_ptr<HoldingSpaceTrayBubble> bubble_; // The singleton delegate for `HoldingSpaceItemView`s that implements support
// for context menu, drag-and-drop, and multiple selection.
HoldingSpaceItemViewDelegate delegate_;
std::unique_ptr<TrayBubbleWrapper> bubble_;
PinnedFilesContainer* pinned_files_container_ = nullptr;
RecentFilesContainer* recent_files_container_ = nullptr;
// Weak pointer, will be parented by TrayContainer for its lifetime. // Weak pointer, will be parented by TrayContainer for its lifetime.
views::ImageView* icon_ = nullptr; views::ImageView* icon_ = nullptr;
......
// 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_tray_bubble.h"
#include "ash/public/cpp/holding_space/holding_space_constants.h"
#include "ash/public/cpp/shelf_config.h"
#include "ash/shelf/shelf.h"
#include "ash/system/holding_space/holding_space_tray.h"
#include "ash/system/holding_space/pinned_files_container.h"
#include "ash/system/holding_space/recent_files_container.h"
#include "ash/system/tray/tray_bubble_wrapper.h"
#include "ash/system/tray/tray_constants.h"
#include "ash/system/tray/tray_utils.h"
#include "ash/system/unified/unified_system_tray_view.h"
#include "ui/views/controls/separator.h"
namespace ash {
namespace {
void SetupViewLayer(views::View* view) {
view->SetPaintToLayer(ui::LAYER_SOLID_COLOR);
auto* layer = view->layer();
layer->SetRoundedCornerRadius(gfx::RoundedCornersF{kUnifiedTrayCornerRadius});
layer->SetColor(UnifiedSystemTrayView::GetBackgroundColor());
layer->SetBackgroundBlur(kUnifiedMenuBackgroundBlur);
layer->SetFillsBoundsOpaquely(false);
layer->SetIsFastRoundedCorner(true);
}
} // namespace
HoldingSpaceTrayBubble::HoldingSpaceTrayBubble(
HoldingSpaceTray* holding_space_tray,
bool show_by_click) {
TrayBubbleView::InitParams init_params;
init_params.delegate = holding_space_tray;
init_params.parent_window = holding_space_tray->GetBubbleWindowContainer();
init_params.anchor_view = holding_space_tray->GetBubbleAnchor();
init_params.shelf_alignment = holding_space_tray->shelf()->alignment();
init_params.preferred_width = kHoldingSpaceBubbleWidth;
init_params.close_on_deactivate = true;
init_params.show_by_click = show_by_click;
init_params.has_shadow = false;
// Create and customize bubble view.
TrayBubbleView* bubble_view = new TrayBubbleView(init_params);
bubble_view->set_anchor_view_insets(
holding_space_tray->GetBubbleAnchorInsets());
bubble_view->set_margins(GetSecondaryBubbleInsets());
// Add pinned files container.
pinned_files_container_ = bubble_view->AddChildView(
std::make_unique<PinnedFilesContainer>(&delegate_));
SetupViewLayer(pinned_files_container_);
// Separator between the two containers, gives illusion of 2 separate bubbles.
auto* separator =
bubble_view->AddChildView(std::make_unique<views::Separator>());
separator->SetBorder(views::CreateEmptyBorder(
gfx::Insets(kHoldingSpaceContainerSpacing, 0, 0, 0)));
recent_files_container_ = bubble_view->AddChildView(
std::make_unique<RecentFilesContainer>(&delegate_));
SetupViewLayer(recent_files_container_);
// Show the bubble.
bubble_wrapper_ = std::make_unique<TrayBubbleWrapper>(
holding_space_tray, bubble_view, false /* is_persistent */);
// Set bubble frame to be invisible.
bubble_wrapper_->GetBubbleWidget()
->non_client_view()
->frame_view()
->SetVisible(false);
}
HoldingSpaceTrayBubble::~HoldingSpaceTrayBubble() {
bubble_wrapper_->bubble_view()->ResetDelegate();
bubble_wrapper_->GetBubbleWidget()->CloseNow();
}
void HoldingSpaceTrayBubble::AnchorUpdated() {
bubble_wrapper_->bubble_view()->UpdateBubble();
}
} // 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_TRAY_BUBBLE_H_
#define ASH_SYSTEM_HOLDING_SPACE_HOLDING_SPACE_TRAY_BUBBLE_H_
#include <memory>
#include "ash/ash_export.h"
#include "ash/system/holding_space/holding_space_item_view_delegate.h"
#include "ash/system/tray/tray_bubble_wrapper.h"
namespace ash {
class HoldingSpaceTray;
class PinnedFilesContainer;
class RecentFilesContainer;
class ASH_EXPORT HoldingSpaceTrayBubble {
public:
HoldingSpaceTrayBubble(HoldingSpaceTray* holding_space_tray,
bool show_by_click);
HoldingSpaceTrayBubble(const HoldingSpaceTrayBubble&) = delete;
HoldingSpaceTrayBubble& operator=(const HoldingSpaceTrayBubble&) = delete;
~HoldingSpaceTrayBubble();
void AnchorUpdated();
private:
// The singleton delegate for `HoldingSpaceItemView`s that implements support
// for context menu, drag-and-drop, and multiple selection.
HoldingSpaceItemViewDelegate delegate_;
PinnedFilesContainer* pinned_files_container_ = nullptr;
RecentFilesContainer* recent_files_container_ = nullptr;
std::unique_ptr<TrayBubbleWrapper> bubble_wrapper_;
};
} // namespace ash
#endif // ASH_SYSTEM_HOLDING_SPACE_HOLDING_SPACE_TRAY_BUBBLE_H_
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