Commit eaa6a968 authored by Tommy Steimel's avatar Tommy Steimel Committed by Commit Bot

GMC: Make the GMC dialog scrollable

This CL modifies the MediaNotificationListView to be a ScrollView so
that the Global Media Controls dialog becomes scrollable when there are
too many sessions to fit comfortably.

Bug: 991370
Change-Id: Id5e9b92e455e4298dfcb7fd409b096f348bff232
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1745389Reviewed-by: default avatarBecca Hughes <beccahughes@chromium.org>
Commit-Queue: Tommy Steimel <steimel@chromium.org>
Cr-Commit-Position: refs/heads/master@{#685404}
parent 5105f81d
...@@ -7,9 +7,17 @@ ...@@ -7,9 +7,17 @@
#include "chrome/browser/ui/views/global_media_controls/media_notification_container_impl.h" #include "chrome/browser/ui/views/global_media_controls/media_notification_container_impl.h"
#include "ui/views/layout/box_layout.h" #include "ui/views/layout/box_layout.h"
namespace {
constexpr int kMediaListMaxHeight = 478;
} // anonymous namespace
MediaNotificationListView::MediaNotificationListView() { MediaNotificationListView::MediaNotificationListView() {
SetLayoutManager(std::make_unique<views::BoxLayout>( SetContents(std::make_unique<views::View>());
contents()->SetLayoutManager(std::make_unique<views::BoxLayout>(
views::BoxLayout::Orientation::kVertical)); views::BoxLayout::Orientation::kVertical));
ClipHeightTo(0, kMediaListMaxHeight);
} }
MediaNotificationListView::~MediaNotificationListView() = default; MediaNotificationListView::~MediaNotificationListView() = default;
...@@ -20,7 +28,9 @@ void MediaNotificationListView::ShowNotification( ...@@ -20,7 +28,9 @@ void MediaNotificationListView::ShowNotification(
DCHECK(!base::Contains(notifications_, id)); DCHECK(!base::Contains(notifications_, id));
DCHECK_NE(nullptr, notification.get()); DCHECK_NE(nullptr, notification.get());
notifications_[id] = AddChildView(std::move(notification)); notifications_[id] = contents()->AddChildView(std::move(notification));
contents()->InvalidateLayout();
PreferredSizeChanged(); PreferredSizeChanged();
} }
...@@ -28,7 +38,9 @@ void MediaNotificationListView::HideNotification(const std::string& id) { ...@@ -28,7 +38,9 @@ void MediaNotificationListView::HideNotification(const std::string& id) {
if (!base::Contains(notifications_, id)) if (!base::Contains(notifications_, id))
return; return;
RemoveChildView(notifications_[id]); contents()->RemoveChildView(notifications_[id]);
notifications_.erase(id); notifications_.erase(id);
contents()->InvalidateLayout();
PreferredSizeChanged(); PreferredSizeChanged();
} }
...@@ -8,13 +8,13 @@ ...@@ -8,13 +8,13 @@
#include <map> #include <map>
#include <memory> #include <memory>
#include "ui/views/view.h" #include "ui/views/controls/scroll_view.h"
class MediaNotificationContainerImpl; class MediaNotificationContainerImpl;
// MediaNotificationListView is a container that holds a list of active media // MediaNotificationListView is a container that holds a list of active media
// sessions. // sessions.
class MediaNotificationListView : public views::View { class MediaNotificationListView : public views::ScrollView {
public: public:
MediaNotificationListView(); MediaNotificationListView();
~MediaNotificationListView() override; ~MediaNotificationListView() override;
......
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