Commit d0bf4841 authored by Quan Nguyen's avatar Quan Nguyen Committed by Commit Bot

Upgrade ScrollableUsersListView GradientParams on wallpaper change

Bug: 839610
Change-Id: I4a4ee5e8c80a57a32f8368fe3716803c82148183
Reviewed-on: https://chromium-review.googlesource.com/1086068Reviewed-by: default avatarJacob Dufault <jdufault@chromium.org>
Commit-Queue: Quan Nguyen <qnnguyen@chromium.org>
Cr-Commit-Position: refs/heads/master@{#564957}
parent bf576b0f
...@@ -119,7 +119,7 @@ ScrollableUsersListView::ScrollableUsersListView( ...@@ -119,7 +119,7 @@ ScrollableUsersListView::ScrollableUsersListView(
const std::vector<mojom::LoginUserInfoPtr>& users, const std::vector<mojom::LoginUserInfoPtr>& users,
const ActionWithUser& on_tap_user, const ActionWithUser& on_tap_user,
LoginDisplayStyle display_style) LoginDisplayStyle display_style)
: views::ScrollView() { : views::ScrollView(), observer_(this) {
layout_params_ = GetLayoutParams(display_style); layout_params_ = GetLayoutParams(display_style);
gradient_params_ = GetGradientParams(display_style); gradient_params_ = GetGradientParams(display_style);
...@@ -154,6 +154,8 @@ ScrollableUsersListView::ScrollableUsersListView( ...@@ -154,6 +154,8 @@ ScrollableUsersListView::ScrollableUsersListView(
hover_notifier_ = std::make_unique<HoverNotifier>( hover_notifier_ = std::make_unique<HoverNotifier>(
this, base::BindRepeating(&ScrollableUsersListView::OnHover, this, base::BindRepeating(&ScrollableUsersListView::OnHover,
base::Unretained(this))); base::Unretained(this)));
observer_.Add(Shell::Get()->wallpaper_controller());
} }
ScrollableUsersListView::~ScrollableUsersListView() = default; ScrollableUsersListView::~ScrollableUsersListView() = default;
...@@ -216,6 +218,13 @@ void ScrollableUsersListView::OnPaintBackground(gfx::Canvas* canvas) { ...@@ -216,6 +218,13 @@ void ScrollableUsersListView::OnPaintBackground(gfx::Canvas* canvas) {
canvas->DrawRect(GetLocalBounds(), flags); canvas->DrawRect(GetLocalBounds(), flags);
} }
// When the active user is updated, the wallpaper changes. The gradient color
// should be updated in response to the new primary wallpaper color.
void ScrollableUsersListView::OnWallpaperColorsChanged() {
gradient_params_ = GetGradientParams(layout_params_.display_style);
SchedulePaint();
}
void ScrollableUsersListView::OnHover(bool has_hover) { void ScrollableUsersListView::OnHover(bool has_hover) {
scroll_bar_->SetThumbVisible(has_hover); scroll_bar_->SetThumbVisible(has_hover);
} }
......
...@@ -11,6 +11,9 @@ ...@@ -11,6 +11,9 @@
#include "ash/login/ui/login_display_style.h" #include "ash/login/ui/login_display_style.h"
#include "ash/login/ui/login_user_view.h" #include "ash/login/ui/login_user_view.h"
#include "ash/public/interfaces/login_user_info.mojom.h" #include "ash/public/interfaces/login_user_info.mojom.h"
#include "ash/wallpaper/wallpaper_controller.h"
#include "ash/wallpaper/wallpaper_controller_observer.h"
#include "base/scoped_observer.h"
#include "third_party/skia/include/core/SkColor.h" #include "third_party/skia/include/core/SkColor.h"
#include "ui/views/controls/scroll_view.h" #include "ui/views/controls/scroll_view.h"
...@@ -27,7 +30,8 @@ class ScrollBar; ...@@ -27,7 +30,8 @@ class ScrollBar;
// Scrollable list of the users. Stores the list of login user views. Can be // Scrollable list of the users. Stores the list of login user views. Can be
// styled with GradientParams that define gradient tinting at the top and at the // styled with GradientParams that define gradient tinting at the top and at the
// bottom. Can be styled with LayoutParams that define spacing and sizing. // bottom. Can be styled with LayoutParams that define spacing and sizing.
class ASH_EXPORT ScrollableUsersListView : public views::ScrollView { class ASH_EXPORT ScrollableUsersListView : public views::ScrollView,
public WallpaperControllerObserver {
public: public:
// TestApi is used for tests to get internal implementation details. // TestApi is used for tests to get internal implementation details.
class ASH_EXPORT TestApi { class ASH_EXPORT TestApi {
...@@ -67,6 +71,9 @@ class ASH_EXPORT ScrollableUsersListView : public views::ScrollView { ...@@ -67,6 +71,9 @@ class ASH_EXPORT ScrollableUsersListView : public views::ScrollView {
void Layout() override; void Layout() override;
void OnPaintBackground(gfx::Canvas* canvas) override; void OnPaintBackground(gfx::Canvas* canvas) override;
// ash::WallpaperControllerObserver:
void OnWallpaperColorsChanged() override;
private: private:
struct GradientParams { struct GradientParams {
// Start color for drawing linear gradient. // Start color for drawing linear gradient.
...@@ -108,6 +115,8 @@ class ASH_EXPORT ScrollableUsersListView : public views::ScrollView { ...@@ -108,6 +115,8 @@ class ASH_EXPORT ScrollableUsersListView : public views::ScrollView {
GradientParams gradient_params_; GradientParams gradient_params_;
LayoutParams layout_params_; LayoutParams layout_params_;
ScopedObserver<WallpaperController, WallpaperControllerObserver> observer_;
DISALLOW_COPY_AND_ASSIGN(ScrollableUsersListView); DISALLOW_COPY_AND_ASSIGN(ScrollableUsersListView);
}; };
......
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