Commit 5c981f78 authored by Mia Bergeron's avatar Mia Bergeron Committed by Commit Bot

[Lock Screen Media Controls] Invalidate action buttons when necessary

This CL invalidates the action buttons if their visibility changes.
Previously, if a button's visibility changed, the space would remain
there. Now, if a button's visibility changes, the space is removed.
This way, there is always equal spacing between the visible buttons.

Change-Id: Ie73d1072ef61da2c65b7a89414b689a04d7cf858
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1752555Reviewed-by: default avatarXiyuan Xia <xiyuan@chromium.org>
Commit-Queue: Mia Bergeron <miaber@google.com>
Cr-Commit-Position: refs/heads/master@{#686560}
parent 7b021dae
...@@ -568,16 +568,19 @@ void LockScreenMediaControlsView::UpdateActionButtonsVisibility() { ...@@ -568,16 +568,19 @@ void LockScreenMediaControlsView::UpdateActionButtonsVisibility() {
media_message_center::GetTopVisibleActions(enabled_actions_, media_message_center::GetTopVisibleActions(enabled_actions_,
ignored_actions, kMaxActions); ignored_actions, kMaxActions);
bool should_invalidate = false;
for (auto* view : button_row_->children()) { for (auto* view : button_row_->children()) {
views::Button* action_button = views::Button::AsButton(view); views::Button* action_button = views::Button::AsButton(view);
bool should_show = base::Contains( bool should_show = base::Contains(
visible_actions, visible_actions,
media_message_center::GetActionFromButtonTag(*action_button)); media_message_center::GetActionFromButtonTag(*action_button));
should_invalidate |= should_show != action_button->GetVisible();
action_button->SetVisible(should_show); action_button->SetVisible(should_show);
} }
PreferredSizeChanged(); if (should_invalidate)
button_row_->InvalidateLayout();
} }
void LockScreenMediaControlsView::SetIsPlaying(bool playing) { void LockScreenMediaControlsView::SetIsPlaying(bool playing) {
......
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