Commit 158b343f authored by Jennifer Apacible's avatar Jennifer Apacible Committed by Commit Bot

[Picture in Picture] Make close button fixed size.

This change updates the close button to be a fixed size regardless of
the window size.

Bug: 870186
Change-Id: Ib9de9508cef6f1faea272be7a223a15e86d7ac87
Reviewed-on: https://chromium-review.googlesource.com/1159987Reviewed-by: default avatarMounir Lamouri <mlamouri@chromium.org>
Commit-Queue: apacible <apacible@chromium.org>
Cr-Commit-Position: refs/heads/master@{#580237}
parent 4a21433f
......@@ -40,6 +40,7 @@ const int kOverlayBorderThickness = 5;
const float kPlayPauseControlRatioToWindow = 0.3;
const int kCloseButtonMargin = 8;
const int kCloseButtonSize = 24;
const int kMinPlayPauseButtonSize = 48;
......@@ -129,7 +130,6 @@ class OverlayWindowWidgetDelegate : public views::WidgetDelegate {
OverlayWindowViews::OverlayWindowViews(
content::PictureInPictureWindowController* controller)
: controller_(controller),
close_button_size_(gfx::Size()),
play_pause_button_size_(gfx::Size()),
window_background_view_(new views::View()),
video_view_(new views::View()),
......@@ -224,7 +224,16 @@ void OverlayWindowViews::SetUpViews() {
views::ImageButton::ALIGN_MIDDLE);
close_controls_view_->SetBackgroundImageAlignment(
views::ImageButton::ALIGN_LEFT, views::ImageButton::ALIGN_TOP);
UpdateCloseControlsSize();
close_controls_view_->SetSize(gfx::Size(kCloseButtonSize, kCloseButtonSize));
close_controls_view_->SetImage(
views::Button::STATE_NORMAL,
gfx::CreateVectorIcon(views::kIcCloseIcon,
std::round(kCloseButtonSize * 2.0 / 3.0),
kControlIconColor));
const gfx::ImageSkia close_background = gfx::CreateVectorIcon(
kPictureInPictureControlBackgroundIcon, kCloseButtonSize, kBgColor);
close_controls_view_->SetBackgroundImage(kBgColor, &close_background,
&close_background);
// Accessibility.
close_controls_view_->SetFocusForPlatform(); // Make button focusable.
......@@ -311,11 +320,9 @@ void OverlayWindowViews::UpdateControlsBounds() {
controls_background_view_->SetBoundsRect(
gfx::Rect(gfx::Point(0, 0), GetBounds().size()));
close_controls_view_->SetBoundsRect(
gfx::Rect(gfx::Point(GetBounds().size().width() -
close_button_size_.width() - kCloseButtonMargin,
kCloseButtonMargin),
close_button_size_));
close_controls_view_->SetPosition(gfx::Point(
GetBounds().size().width() - kCloseButtonSize - kCloseButtonMargin,
kCloseButtonMargin));
play_pause_controls_view_->SetBoundsRect(gfx::Rect(
gfx::Point(
......@@ -324,33 +331,6 @@ void OverlayWindowViews::UpdateControlsBounds() {
play_pause_button_size_));
}
void OverlayWindowViews::UpdateCloseControlsSize() {
const gfx::Size window_size = GetBounds().size();
// |close_button_size_| can only be three sizes, dependent on the width of
// |this|.
int new_close_button_dimension = 24;
if (window_size.width() > 640 && window_size.width() <= 1440) {
new_close_button_dimension = 48;
} else if (window_size.width() > 1440) {
new_close_button_dimension = 72;
}
close_button_size_.SetSize(new_close_button_dimension,
new_close_button_dimension);
close_controls_view_->SetSize(close_button_size_);
close_controls_view_->SetImage(
views::Button::STATE_NORMAL,
gfx::CreateVectorIcon(views::kIcCloseIcon,
std::round(close_button_size_.width() * 2.0 / 3.0),
kControlIconColor));
const gfx::ImageSkia close_background =
gfx::CreateVectorIcon(kPictureInPictureControlBackgroundIcon,
close_button_size_.width(), kBgColor);
close_controls_view_->SetBackgroundImage(kBgColor, &close_background,
&close_background);
}
void OverlayWindowViews::UpdatePlayPauseControlsSize() {
const gfx::Size window_size = GetBounds().size();
......@@ -587,7 +567,6 @@ void OverlayWindowViews::OnNativeWidgetMove() {
void OverlayWindowViews::OnNativeWidgetSizeChanged(const gfx::Size& new_size) {
// Update the view layers to scale to |new_size|.
UpdateCloseControlsSize();
UpdatePlayPauseControlsSize();
UpdateVideoLayerSizeWithAspectRatio(new_size);
......
......@@ -92,11 +92,6 @@ class OverlayWindowViews : public content::OverlayWindow,
// Updates the bounds of the controls.
void UpdateControlsBounds();
// Update the size of |close_controls_view_| as the size of the window
// changes. This will scale to one of three sizes, based off the current width
// of the window.
void UpdateCloseControlsSize();
// Update the size of |play_pause_controls_view_| as the size of the window
// changes.
void UpdatePlayPauseControlsSize();
......@@ -125,8 +120,7 @@ class OverlayWindowViews : public content::OverlayWindow,
gfx::Size min_size_;
gfx::Size max_size_;
// Current sizes of |close_controls_view_| and |play_pause_controls_view_|.
gfx::Size close_button_size_;
// Current size of |play_pause_controls_view_|.
gfx::Size play_pause_button_size_;
// Current bounds of the Picture-in-Picture window.
......
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