Commit ba288888 authored by David Black's avatar David Black Committed by Commit Bot

Prep for content forward holding space tray icon.

This CL pulls the holding space tray icon out into a separate class.
Moving forward, the new HoldingSpaceTrayIcon will be modified to add
support for a content forward UI and accompanying motion spec. Changes
will be gated by a new feature flag (or param to the existing flag).

No changes should be visible to the user as a result of this CL.

Bug: 1142572
Change-Id: I21f85f37eeb595f7aa9ac3c79a171634b22e939b
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2499376Reviewed-by: default avatarToni Baržić <tbarzic@chromium.org>
Commit-Queue: David Black <dmblack@google.com>
Cr-Commit-Position: refs/heads/master@{#821343}
parent 96efd35d
...@@ -970,6 +970,8 @@ component("ash") { ...@@ -970,6 +970,8 @@ component("ash") {
"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.cc",
"system/holding_space/holding_space_tray_bubble.h", "system/holding_space/holding_space_tray_bubble.h",
"system/holding_space/holding_space_tray_icon.cc",
"system/holding_space/holding_space_tray_icon.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",
......
...@@ -36,7 +36,8 @@ constexpr int kHoldingSpaceScreenCaptureSpacing = 8; ...@@ -36,7 +36,8 @@ constexpr int kHoldingSpaceScreenCaptureSpacing = 8;
constexpr gfx::Size kHoldingSpaceScreenCaptureSize(104, 80); constexpr gfx::Size kHoldingSpaceScreenCaptureSize(104, 80);
constexpr gfx::Insets kHoldingSpaceScreenCapturesContainerPadding(8, 0); constexpr gfx::Insets kHoldingSpaceScreenCapturesContainerPadding(8, 0);
constexpr float kHoldingSpaceSelectedOverlayOpacity = 0.24f; constexpr float kHoldingSpaceSelectedOverlayOpacity = 0.24f;
constexpr int kHoldingSpaceTrayMainAxisMargin = 6; constexpr int kHoldingSpaceTrayIconMainAxisMargin = 6;
constexpr int kHoldingSpaceTrayIconSize = 20;
// Context menu commands. // Context menu commands.
enum HoldingSpaceCommandId { enum HoldingSpaceCommandId {
......
...@@ -6,24 +6,17 @@ ...@@ -6,24 +6,17 @@
#include <memory> #include <memory>
#include "ash/accessibility/accessibility_controller_impl.h" #include "ash/accessibility/accessibility_controller_impl.h"
#include "ash/public/cpp/holding_space/holding_space_constants.h"
#include "ash/public/cpp/holding_space/holding_space_metrics.h" #include "ash/public/cpp/holding_space/holding_space_metrics.h"
#include "ash/public/cpp/holding_space/holding_space_prefs.h" #include "ash/public/cpp/holding_space/holding_space_prefs.h"
#include "ash/public/cpp/shelf_config.h"
#include "ash/public/cpp/system_tray_client.h" #include "ash/public/cpp/system_tray_client.h"
#include "ash/resources/vector_icons/vector_icons.h"
#include "ash/session/session_controller_impl.h" #include "ash/session/session_controller_impl.h"
#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/holding_space_tray_bubble.h"
#include "ash/system/holding_space/holding_space_tray_icon.h"
#include "ash/system/tray/tray_container.h" #include "ash/system/tray/tray_container.h"
#include "ui/base/l10n/l10n_util.h" #include "ui/base/l10n/l10n_util.h"
#include "ui/gfx/paint_vector_icon.h"
#include "ui/views/controls/image_view.h"
#include "ui/views/controls/label.h"
#include "ui/views/layout/fill_layout.h"
#include "ui/views/vector_icons.h"
namespace ash { namespace ash {
...@@ -31,14 +24,10 @@ HoldingSpaceTray::HoldingSpaceTray(Shelf* shelf) : TrayBackgroundView(shelf) { ...@@ -31,14 +24,10 @@ HoldingSpaceTray::HoldingSpaceTray(Shelf* shelf) : TrayBackgroundView(shelf) {
controller_observer_.Add(HoldingSpaceController::Get()); controller_observer_.Add(HoldingSpaceController::Get());
SetVisible(false); SetVisible(false);
SetLayoutManager(std::make_unique<views::FillLayout>()); // Icon.
auto* container = tray_container();
icon_ = tray_container()->AddChildView(std::make_unique<views::ImageView>()); icon_ = container->AddChildView(std::make_unique<HoldingSpaceTrayIcon>());
icon_->SetTooltipText(l10n_util::GetStringUTF16(IDS_ASH_HOLDING_SPACE_TITLE)); container->SetMargin(icon_->GetPreferredMainAxisMargin(), 0);
icon_->SetImage(CreateVectorIcon(kHoldingSpaceIcon,
ShelfConfig::Get()->shelf_icon_color()));
tray_container()->SetMargin(kHoldingSpaceTrayMainAxisMargin, 0);
} }
HoldingSpaceTray::~HoldingSpaceTray() = default; HoldingSpaceTray::~HoldingSpaceTray() = default;
...@@ -52,7 +41,7 @@ base::string16 HoldingSpaceTray::GetAccessibleNameForTray() { ...@@ -52,7 +41,7 @@ base::string16 HoldingSpaceTray::GetAccessibleNameForTray() {
} }
void HoldingSpaceTray::HandleLocaleChange() { void HoldingSpaceTray::HandleLocaleChange() {
icon_->SetTooltipText(l10n_util::GetStringUTF16(IDS_ASH_HOLDING_SPACE_TITLE)); icon_->OnLocaleChanged();
} }
void HoldingSpaceTray::HideBubbleWithView(const TrayBubbleView* bubble_view) {} void HoldingSpaceTray::HideBubbleWithView(const TrayBubbleView* bubble_view) {}
......
...@@ -18,11 +18,10 @@ ...@@ -18,11 +18,10 @@
#include "base/scoped_observer.h" #include "base/scoped_observer.h"
#include "ui/views/widget/widget_observer.h" #include "ui/views/widget/widget_observer.h"
namespace views {
class ImageView;
} // namespace views
namespace ash { namespace ash {
class HoldingSpaceTrayIcon;
// 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.
...@@ -69,11 +68,9 @@ class ASH_EXPORT HoldingSpaceTray : public TrayBackgroundView, ...@@ -69,11 +68,9 @@ class ASH_EXPORT HoldingSpaceTray : public TrayBackgroundView,
void OnWidgetDragWillStart(views::Widget* widget) override; void OnWidgetDragWillStart(views::Widget* widget) override;
void OnWidgetDestroying(views::Widget* widget) override; void OnWidgetDestroying(views::Widget* widget) override;
HoldingSpaceTrayIcon* icon_ = nullptr; // Owned by `TrayContainer`.
std::unique_ptr<HoldingSpaceTrayBubble> bubble_; std::unique_ptr<HoldingSpaceTrayBubble> bubble_;
// Weak pointer, will be parented by TrayContainer for its lifetime.
views::ImageView* icon_ = nullptr;
ScopedObserver<HoldingSpaceController, HoldingSpaceControllerObserver> ScopedObserver<HoldingSpaceController, HoldingSpaceControllerObserver>
controller_observer_{this}; controller_observer_{this};
ScopedObserver<HoldingSpaceModel, HoldingSpaceModelObserver> model_observer_{ ScopedObserver<HoldingSpaceModel, HoldingSpaceModelObserver> model_observer_{
......
// 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_icon.h"
#include "ash/public/cpp/holding_space/holding_space_constants.h"
#include "ash/public/cpp/shelf_config.h"
#include "ash/resources/vector_icons/vector_icons.h"
#include "ash/strings/grit/ash_strings.h"
#include "ui/base/l10n/l10n_util.h"
#include "ui/gfx/paint_vector_icon.h"
#include "ui/views/controls/image_view.h"
#include "ui/views/layout/fill_layout.h"
#include "ui/views/metadata/metadata_impl_macros.h"
namespace ash {
HoldingSpaceTrayIcon::HoldingSpaceTrayIcon() {
InitLayout();
}
HoldingSpaceTrayIcon::~HoldingSpaceTrayIcon() = default;
int HoldingSpaceTrayIcon::GetPreferredMainAxisMargin() const {
return kHoldingSpaceTrayIconMainAxisMargin;
}
void HoldingSpaceTrayIcon::OnLocaleChanged() {
TooltipTextChanged();
}
base::string16 HoldingSpaceTrayIcon::GetTooltipText(
const gfx::Point& point) const {
return l10n_util::GetStringUTF16(IDS_ASH_HOLDING_SPACE_TITLE);
}
void HoldingSpaceTrayIcon::InitLayout() {
SetLayoutManager(std::make_unique<views::FillLayout>());
// Image.
auto* image_view = AddChildView(std::make_unique<views::ImageView>());
image_view->SetImage(
gfx::CreateVectorIcon(kHoldingSpaceIcon, kHoldingSpaceTrayIconSize,
ShelfConfig::Get()->shelf_icon_color()));
// Disallow events on `image_view` so that tooltips will be retrieved from
// `this`. Moving forward, `image_view` will not exist as we transition to a
// more content forward tray icon.
image_view->SetCanProcessEventsWithinSubtree(false);
}
BEGIN_METADATA(HoldingSpaceTrayIcon, views::View)
END_METADATA
} // 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_ICON_H_
#define ASH_SYSTEM_HOLDING_SPACE_HOLDING_SPACE_TRAY_ICON_H_
#include "ash/ash_export.h"
#include "ui/views/metadata/metadata_header_macros.h"
#include "ui/views/view.h"
namespace ash {
// TODO(crbug.com/1142572): Implement content forward icon w/ motion spec.
// The icon used to represent holding space in its tray in the shelf.
class ASH_EXPORT HoldingSpaceTrayIcon : public views::View {
public:
METADATA_HEADER(HoldingSpaceTrayIcon);
HoldingSpaceTrayIcon();
HoldingSpaceTrayIcon(const HoldingSpaceTrayIcon&) = delete;
HoldingSpaceTrayIcon& operator=(const HoldingSpaceTrayIcon&) = delete;
~HoldingSpaceTrayIcon() override;
// Returns the preferred main axis margin for this view.
int GetPreferredMainAxisMargin() const;
// Invoked when the system locale has changed.
void OnLocaleChanged();
private:
// views::View:
base::string16 GetTooltipText(const gfx::Point& point) const override;
void InitLayout();
};
} // namespace ash
#endif // ASH_SYSTEM_HOLDING_SPACE_HOLDING_SPACE_TRAY_ICON_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