Commit 58a681f2 authored by Jazz Xu's avatar Jazz Xu Committed by Commit Bot

CrOS GMC: Layout and UI adjustments.

This CL adjusts layout to match the spec, adds ink drop to action
buttons, and adds a drop down icon next to title label.

Bug: 1133026
Change-Id: I46a8af315c98b43e2b557908dfebf810c1666ef0
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2436419Reviewed-by: default avatarTommy Steimel <steimel@chromium.org>
Reviewed-by: default avatarTetsui Ohkubo <tetsui@chromium.org>
Commit-Queue: Jazz Xu <jazzhsu@chromium.org>
Cr-Commit-Position: refs/heads/master@{#811905}
parent 4fed2d53
...@@ -17,7 +17,6 @@ ...@@ -17,7 +17,6 @@
#include "ash/system/tray/tray_bubble_wrapper.h" #include "ash/system/tray/tray_bubble_wrapper.h"
#include "ash/system/tray/tray_constants.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_popup_item_style.h"
#include "ash/system/tray/tray_utils.h" #include "ash/system/tray/tray_utils.h"
#include "base/strings/string_util.h" #include "base/strings/string_util.h"
#include "components/prefs/pref_change_registrar.h" #include "components/prefs/pref_change_registrar.h"
...@@ -37,6 +36,9 @@ namespace ash { ...@@ -37,6 +36,9 @@ namespace ash {
namespace { namespace {
constexpr int kTitleFontSizeIncrease = 4;
constexpr int kTitleViewHeight = 56;
constexpr gfx::Insets kTitleViewInsets = gfx::Insets(0, 16, 0, 16); constexpr gfx::Insets kTitleViewInsets = gfx::Insets(0, 16, 0, 16);
// Minimum screen diagonal (in inches) for pinning global media controls // Minimum screen diagonal (in inches) for pinning global media controls
...@@ -82,7 +84,7 @@ class GlobalMediaControlsTitleView : public views::View { ...@@ -82,7 +84,7 @@ class GlobalMediaControlsTitleView : public views::View {
auto* box_layout = SetLayoutManager(std::make_unique<views::BoxLayout>( auto* box_layout = SetLayoutManager(std::make_unique<views::BoxLayout>(
views::BoxLayout::Orientation::kHorizontal, kTitleViewInsets)); views::BoxLayout::Orientation::kHorizontal, kTitleViewInsets));
box_layout->set_minimum_cross_axis_size(kTrayPopupItemMinHeight); box_layout->set_minimum_cross_axis_size(kTitleViewHeight);
box_layout->set_cross_axis_alignment( box_layout->set_cross_axis_alignment(
views::BoxLayout::CrossAxisAlignment::kCenter); views::BoxLayout::CrossAxisAlignment::kCenter);
...@@ -90,9 +92,11 @@ class GlobalMediaControlsTitleView : public views::View { ...@@ -90,9 +92,11 @@ class GlobalMediaControlsTitleView : public views::View {
title_label->SetText( title_label->SetText(
l10n_util::GetStringUTF16(IDS_ASH_GLOBAL_MEDIA_CONTROLS_TITLE)); l10n_util::GetStringUTF16(IDS_ASH_GLOBAL_MEDIA_CONTROLS_TITLE));
title_label->SetHorizontalAlignment(gfx::ALIGN_LEFT); title_label->SetHorizontalAlignment(gfx::ALIGN_LEFT);
TrayPopupItemStyle style(TrayPopupItemStyle::FontStyle::SMALL_TITLE, title_label->SetEnabledColor(AshColorProvider::Get()->GetContentLayerColor(
true /* use_unified_theme */); AshColorProvider::ContentLayerType::kTextColorPrimary));
style.SetupLabel(title_label); title_label->SetAutoColorReadabilityEnabled(false);
title_label->SetFontList(views::Label::GetDefaultFontList().Derive(
kTitleFontSizeIncrease, gfx::Font::NORMAL, gfx::Font::Weight::MEDIUM));
// Media tray should always be pinned to shelf when we are opening the // Media tray should always be pinned to shelf when we are opening the
// dialog. // dialog.
......
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
namespace ash { namespace ash {
namespace { namespace {
constexpr int kContainerHeight = 80; constexpr int kContainerHeight = 72;
constexpr gfx::Insets kContainerInsets = gfx::Insets(0, 16, 16, 16); constexpr gfx::Insets kContainerInsets = gfx::Insets(0, 16, 16, 16);
} // namespace } // namespace
......
...@@ -27,7 +27,7 @@ namespace { ...@@ -27,7 +27,7 @@ namespace {
constexpr int kHideControlsDelay = 2000; /* in milliseconds */ constexpr int kHideControlsDelay = 2000; /* in milliseconds */
constexpr int kHideArtworkDelay = 2000; /* in milliseconds */ constexpr int kHideArtworkDelay = 2000; /* in milliseconds */
constexpr int kArtworkCornerRadius = 4; constexpr int kArtworkCornerRadius = 4;
constexpr int kArtworkHeight = 48; constexpr int kArtworkHeight = 40;
class MockMediaControlsDelegate class MockMediaControlsDelegate
: public UnifiedMediaControlsController::Delegate { : public UnifiedMediaControlsController::Delegate {
...@@ -266,7 +266,7 @@ TEST_F(UnifiedMediaControlsControllerTest, UpdateArtwork) { ...@@ -266,7 +266,7 @@ TEST_F(UnifiedMediaControlsControllerTest, UpdateArtwork) {
controller()->MediaControllerImageChanged( controller()->MediaControllerImageChanged(
media_session::mojom::MediaSessionImageType::kArtwork, artwork); media_session::mojom::MediaSessionImageType::kArtwork, artwork);
{ {
gfx::Rect expect_bounds(0, 12, 48, 24); gfx::Rect expect_bounds(0, 10, 40, 20);
gfx::Rect artwork_bounds = artwork_view()->GetImageBounds(); gfx::Rect artwork_bounds = artwork_view()->GetImageBounds();
EXPECT_EQ(artwork_bounds, expect_bounds); EXPECT_EQ(artwork_bounds, expect_bounds);
...@@ -281,7 +281,7 @@ TEST_F(UnifiedMediaControlsControllerTest, UpdateArtwork) { ...@@ -281,7 +281,7 @@ TEST_F(UnifiedMediaControlsControllerTest, UpdateArtwork) {
controller()->MediaControllerImageChanged( controller()->MediaControllerImageChanged(
media_session::mojom::MediaSessionImageType::kArtwork, artwork); media_session::mojom::MediaSessionImageType::kArtwork, artwork);
{ {
gfx::Rect expect_bounds(12, 0, 24, 48); gfx::Rect expect_bounds(10, 0, 20, 40);
gfx::Rect artwork_bounds = artwork_view()->GetImageBounds(); gfx::Rect artwork_bounds = artwork_view()->GetImageBounds();
EXPECT_EQ(artwork_bounds, expect_bounds); EXPECT_EQ(artwork_bounds, expect_bounds);
...@@ -296,7 +296,7 @@ TEST_F(UnifiedMediaControlsControllerTest, UpdateArtwork) { ...@@ -296,7 +296,7 @@ TEST_F(UnifiedMediaControlsControllerTest, UpdateArtwork) {
controller()->MediaControllerImageChanged( controller()->MediaControllerImageChanged(
media_session::mojom::MediaSessionImageType::kArtwork, artwork); media_session::mojom::MediaSessionImageType::kArtwork, artwork);
{ {
gfx::Rect expect_bounds(14, 0, 20, kArtworkHeight); gfx::Rect expect_bounds(10, 0, 20, kArtworkHeight);
gfx::Rect artwork_bounds = artwork_view()->GetImageBounds(); gfx::Rect artwork_bounds = artwork_view()->GetImageBounds();
EXPECT_EQ(artwork_bounds, expect_bounds); EXPECT_EQ(artwork_bounds, expect_bounds);
......
...@@ -4,16 +4,22 @@ ...@@ -4,16 +4,22 @@
#include "ash/system/media/unified_media_controls_view.h" #include "ash/system/media/unified_media_controls_view.h"
#include "ash/resources/vector_icons/vector_icons.h"
#include "ash/strings/grit/ash_strings.h" #include "ash/strings/grit/ash_strings.h"
#include "ash/style/ash_color_provider.h" #include "ash/style/ash_color_provider.h"
#include "ash/system/media/unified_media_controls_controller.h" #include "ash/system/media/unified_media_controls_controller.h"
#include "ash/system/tray/tray_constants.h" #include "ash/system/tray/tray_constants.h"
#include "ash/system/tray/tray_popup_utils.h"
#include "components/media_message_center/media_notification_util.h" #include "components/media_message_center/media_notification_util.h"
#include "components/vector_icons/vector_icons.h" #include "components/vector_icons/vector_icons.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/animation/flood_fill_ink_drop_ripple.h"
#include "ui/views/animation/ink_drop_highlight.h"
#include "ui/views/animation/ink_drop_impl.h"
#include "ui/views/background.h" #include "ui/views/background.h"
#include "ui/views/border.h" #include "ui/views/border.h"
#include "ui/views/controls/highlight_path_generator.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/layout/box_layout.h" #include "ui/views/layout/box_layout.h"
...@@ -25,16 +31,18 @@ using media_session::mojom::MediaSessionAction; ...@@ -25,16 +31,18 @@ using media_session::mojom::MediaSessionAction;
namespace { namespace {
constexpr int kMediaControlsCornerRadius = 8; constexpr int kMediaControlsCornerRadius = 8;
constexpr int kMediaControlsViewPadding = 8; constexpr int kMediaControlsViewPadding = 16;
constexpr int kMediaButtonsPadding = 4; constexpr int kMediaButtonsPadding = 8;
constexpr int kMediaButtonIconSize = 18; constexpr int kMediaButtonIconSize = 20;
constexpr int kArtworkCornerRadius = 4; constexpr int kArtworkCornerRadius = 4;
constexpr int kTitleRowHeight = 20;
constexpr int kTrackTitleFontSizeIncrease = 1;
constexpr gfx::Insets kTrackColumnInsets = gfx::Insets(0, 8, 0, 0); constexpr gfx::Insets kTrackColumnInsets = gfx::Insets(1, 0, 1, 0);
constexpr gfx::Insets kMediaControlsViewInsets = gfx::Insets(8, 8, 8, 8); constexpr gfx::Insets kMediaControlsViewInsets = gfx::Insets(8, 8, 8, 12);
constexpr gfx::Size kArtworkSize = gfx::Size(48, 48); constexpr gfx::Size kArtworkSize = gfx::Size(40, 40);
constexpr gfx::Size kMediaButtonSize = gfx::Size(36, 36); constexpr gfx::Size kMediaButtonSize = gfx::Size(32, 32);
gfx::Size ScaleSizeToFitView(const gfx::Size& size, gfx::Size ScaleSizeToFitView(const gfx::Size& size,
const gfx::Size& view_size) { const gfx::Size& view_size) {
...@@ -93,6 +101,9 @@ UnifiedMediaControlsView::MediaActionButton::MediaActionButton( ...@@ -93,6 +101,9 @@ UnifiedMediaControlsView::MediaActionButton::MediaActionButton(
SetImageVerticalAlignment(views::ImageButton::ALIGN_MIDDLE); SetImageVerticalAlignment(views::ImageButton::ALIGN_MIDDLE);
SetPreferredSize(kMediaButtonSize); SetPreferredSize(kMediaButtonSize);
SetAction(action, accessible_name); SetAction(action, accessible_name);
TrayPopupUtils::ConfigureTrayPopupButton(this);
views::InstallCircleHighlightPathGenerator(this);
} }
void UnifiedMediaControlsView::MediaActionButton::SetAction( void UnifiedMediaControlsView::MediaActionButton::SetAction(
...@@ -107,6 +118,25 @@ void UnifiedMediaControlsView::MediaActionButton::SetAction( ...@@ -107,6 +118,25 @@ void UnifiedMediaControlsView::MediaActionButton::SetAction(
AshColorProvider::ContentLayerType::kIconColorPrimary))); AshColorProvider::ContentLayerType::kIconColorPrimary)));
} }
std::unique_ptr<views::InkDrop>
UnifiedMediaControlsView::MediaActionButton::CreateInkDrop() {
auto ink_drop = TrayPopupUtils::CreateInkDrop(this);
ink_drop->SetShowHighlightOnHover(true);
return ink_drop;
}
std::unique_ptr<views::InkDropHighlight>
UnifiedMediaControlsView::MediaActionButton::CreateInkDropHighlight() const {
return TrayPopupUtils::CreateInkDropHighlight(this);
}
std::unique_ptr<views::InkDropRipple>
UnifiedMediaControlsView::MediaActionButton::CreateInkDropRipple() const {
return TrayPopupUtils::CreateInkDropRipple(
TrayPopupInkDropStyle::FILL_BOUNDS, this,
GetInkDropCenterBasedOnLastEvent());
}
UnifiedMediaControlsView::UnifiedMediaControlsView( UnifiedMediaControlsView::UnifiedMediaControlsView(
UnifiedMediaControlsController* controller) UnifiedMediaControlsController* controller)
: views::Button(this), controller_(controller) { : views::Button(this), controller_(controller) {
...@@ -129,6 +159,12 @@ UnifiedMediaControlsView::UnifiedMediaControlsView( ...@@ -129,6 +159,12 @@ UnifiedMediaControlsView::UnifiedMediaControlsView(
track_column->SetLayoutManager(std::make_unique<views::BoxLayout>( track_column->SetLayoutManager(std::make_unique<views::BoxLayout>(
views::BoxLayout::Orientation::kVertical, kTrackColumnInsets)); views::BoxLayout::Orientation::kVertical, kTrackColumnInsets));
auto title_row = std::make_unique<views::View>();
auto* title_row_layout =
title_row->SetLayoutManager(std::make_unique<views::BoxLayout>(
views::BoxLayout::Orientation::kHorizontal, gfx::Insets()));
title_row_layout->set_minimum_cross_axis_size(kTitleRowHeight);
auto config_label = [](views::Label* label) { auto config_label = [](views::Label* label) {
label->SetHorizontalAlignment(gfx::HorizontalAlignment::ALIGN_LEFT); label->SetHorizontalAlignment(gfx::HorizontalAlignment::ALIGN_LEFT);
label->SetAutoColorReadabilityEnabled(false); label->SetAutoColorReadabilityEnabled(false);
...@@ -139,7 +175,21 @@ UnifiedMediaControlsView::UnifiedMediaControlsView( ...@@ -139,7 +175,21 @@ UnifiedMediaControlsView::UnifiedMediaControlsView(
config_label(title_label.get()); config_label(title_label.get());
title_label->SetEnabledColor(AshColorProvider::Get()->GetContentLayerColor( title_label->SetEnabledColor(AshColorProvider::Get()->GetContentLayerColor(
AshColorProvider::ContentLayerType::kTextColorPrimary)); AshColorProvider::ContentLayerType::kTextColorPrimary));
title_label_ = track_column->AddChildView(std::move(title_label)); title_label->SetFontList(
views::Label::GetDefaultFontList().DeriveWithSizeDelta(
kTrackTitleFontSizeIncrease));
title_label_ = title_row->AddChildView(std::move(title_label));
auto drop_down_icon = std::make_unique<views::ImageView>();
drop_down_icon->SetPreferredSize(gfx::Size(kTitleRowHeight, kTitleRowHeight));
drop_down_icon->SetImage(CreateVectorIcon(
kUnifiedMenuMoreIcon,
AshColorProvider::Get()->GetContentLayerColor(
AshColorProvider::ContentLayerType::kIconColorPrimary)));
title_row->AddChildView(std::move(drop_down_icon));
title_row_layout->SetFlexForView(title_label_, 1);
track_column->AddChildView(std::move(title_row));
auto artist_label = std::make_unique<views::Label>(); auto artist_label = std::make_unique<views::Label>();
config_label(artist_label.get()); config_label(artist_label.get());
......
...@@ -57,6 +57,12 @@ class ASH_EXPORT UnifiedMediaControlsView : public views::Button, ...@@ -57,6 +57,12 @@ class ASH_EXPORT UnifiedMediaControlsView : public views::Button,
void SetAction(media_session::mojom::MediaSessionAction action, void SetAction(media_session::mojom::MediaSessionAction action,
const base::string16& accessible_name); const base::string16& accessible_name);
// views::ImageButton:
std::unique_ptr<views::InkDrop> CreateInkDrop() override;
std::unique_ptr<views::InkDropHighlight> CreateInkDropHighlight()
const override;
std::unique_ptr<views::InkDropRipple> CreateInkDropRipple() const override;
}; };
SkPath GetArtworkClipPath(); SkPath GetArtworkClipPath();
......
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