Commit 4db6cc59 authored by minch's avatar minch Committed by Commit Bot

dark_mode: Add kShelfHandle.

Bug: 1129526
Change-Id: I47be5d06e9ce30157c2a737789186f9c157d9602
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2416933
Commit-Queue: Min Chen <minch@chromium.org>
Reviewed-by: default avatarAhmed Fakhry <afakhry@chromium.org>
Cr-Commit-Position: refs/heads/master@{#808668}
parent 7a9d7a2a
...@@ -170,11 +170,6 @@ void DragHandle::ScheduleShowDragHandleNudge() { ...@@ -170,11 +170,6 @@ void DragHandle::ScheduleShowDragHandleNudge() {
base::Unretained(this))); base::Unretained(this)));
} }
void DragHandle::SetColorAndOpacity(SkColor color, float opacity) {
layer()->SetColor(color);
layer()->SetOpacity(opacity);
}
void DragHandle::HideDragHandleNudge( void DragHandle::HideDragHandleNudge(
contextual_tooltip::DismissNudgeReason reason) { contextual_tooltip::DismissNudgeReason reason) {
StopDragHandleNudgeShowTimer(); StopDragHandleNudgeShowTimer();
...@@ -223,6 +218,11 @@ void DragHandle::SetWindowDragFromShelfInProgress(bool gesture_in_progress) { ...@@ -223,6 +218,11 @@ void DragHandle::SetWindowDragFromShelfInProgress(bool gesture_in_progress) {
} }
} }
void DragHandle::UpdateColor() {
layer()->SetColor(AshColorProvider::Get()->GetContentLayerColor(
AshColorProvider::ContentLayerType::kShelfHandleColor));
}
void DragHandle::OnGestureEvent(ui::GestureEvent* event) { void DragHandle::OnGestureEvent(ui::GestureEvent* event) {
if (!features::AreContextualNudgesEnabled() || if (!features::AreContextualNudgesEnabled() ||
!gesture_nudge_target_visibility_) { !gesture_nudge_target_visibility_) {
......
...@@ -37,8 +37,6 @@ class ASH_EXPORT DragHandle : public views::View, ...@@ -37,8 +37,6 @@ class ASH_EXPORT DragHandle : public views::View,
DragHandle& operator=(const DragHandle&) = delete; DragHandle& operator=(const DragHandle&) = delete;
void SetColorAndOpacity(SkColor color, float opacity);
// views::ViewTargeterDelegate: // views::ViewTargeterDelegate:
bool DoesIntersectRect(const views::View* target, bool DoesIntersectRect(const views::View* target,
const gfx::Rect& rect) const override; const gfx::Rect& rect) const override;
...@@ -64,6 +62,8 @@ class ASH_EXPORT DragHandle : public views::View, ...@@ -64,6 +62,8 @@ class ASH_EXPORT DragHandle : public views::View,
// contextual nudge will remain visible while the gesture is in progress. // contextual nudge will remain visible while the gesture is in progress.
void SetWindowDragFromShelfInProgress(bool gesture_in_progress); void SetWindowDragFromShelfInProgress(bool gesture_in_progress);
void UpdateColor();
// views::View: // views::View:
void OnGestureEvent(ui::GestureEvent* event) override; void OnGestureEvent(ui::GestureEvent* event) override;
gfx::Rect GetAnchorBoundsInScreen() const override; gfx::Rect GetAnchorBoundsInScreen() const override;
......
...@@ -146,7 +146,7 @@ class ShelfWidget::DelegateView : public views::WidgetDelegate, ...@@ -146,7 +146,7 @@ class ShelfWidget::DelegateView : public views::WidgetDelegate,
void UpdateBackgroundBlur(); void UpdateBackgroundBlur();
void UpdateOpaqueBackground(); void UpdateOpaqueBackground();
void UpdateDragHandle(bool update_color); void UpdateDragHandle();
// This will be called when the parent local bounds change. // This will be called when the parent local bounds change.
void OnBoundsChanged(const gfx::Rect& old_bounds) override; void OnBoundsChanged(const gfx::Rect& old_bounds) override;
...@@ -267,7 +267,7 @@ void ShelfWidget::DelegateView::HideOpaqueBackground() { ...@@ -267,7 +267,7 @@ void ShelfWidget::DelegateView::HideOpaqueBackground() {
void ShelfWidget::DelegateView::ShowOpaqueBackground() { void ShelfWidget::DelegateView::ShowOpaqueBackground() {
hide_background_for_transitions_ = false; hide_background_for_transitions_ = false;
UpdateOpaqueBackground(); UpdateOpaqueBackground();
UpdateDragHandle(false /*update_color*/); UpdateDragHandle();
UpdateBackgroundBlur(); UpdateBackgroundBlur();
} }
...@@ -358,32 +358,12 @@ void ShelfWidget::DelegateView::UpdateOpaqueBackground() { ...@@ -358,32 +358,12 @@ void ShelfWidget::DelegateView::UpdateOpaqueBackground() {
} }
opaque_background()->SetBounds(opaque_background_bounds); opaque_background()->SetBounds(opaque_background_bounds);
UpdateDragHandle(false /*update_color*/); UpdateDragHandle();
UpdateBackgroundBlur(); UpdateBackgroundBlur();
SchedulePaint(); SchedulePaint();
} }
void ShelfWidget::DelegateView::UpdateDragHandle(bool update_color) { void ShelfWidget::DelegateView::UpdateDragHandle() {
if (update_color) {
if (Shell::Get()->session_controller()->IsUserSessionBlocked()) {
const bool is_oobe =
Shell::Get()->session_controller()->GetSessionState() ==
session_manager::SessionState::OOBE;
// For login shelf, let the drag handle match the login shelf nudge color.
drag_handle_->SetColorAndOpacity(
is_oobe ? gfx::kGoogleGrey700 : gfx::kGoogleGrey100, 1.0f);
} else {
const AshColorProvider::RippleAttributes ripple_attributes =
AshColorProvider::Get()->GetRippleAttributes(
ShelfConfig::Get()->GetDefaultShelfColor());
// TODO(manucornet): Figure out why we need a manual opacity adjustment
// to make this color look the same as the status area highlight.
drag_handle_->SetColorAndOpacity(
ripple_attributes.base_color,
ripple_attributes.inkdrop_opacity + 0.075);
}
}
if (shelf_widget_->login_shelf_view_->GetVisible()) { if (shelf_widget_->login_shelf_view_->GetVisible()) {
drag_handle_->SetVisible( drag_handle_->SetVisible(
shelf_widget_->login_shelf_gesture_controller_.get()); shelf_widget_->login_shelf_gesture_controller_.get());
...@@ -531,13 +511,13 @@ bool ShelfWidget::SetLoginShelfSwipeHandler( ...@@ -531,13 +511,13 @@ bool ShelfWidget::SetLoginShelfSwipeHandler(
std::make_unique<LoginShelfGestureController>( std::make_unique<LoginShelfGestureController>(
shelf_, delegate_view_->drag_handle(), nudge_text, fling_callback, shelf_, delegate_view_->drag_handle(), nudge_text, fling_callback,
std::move(exit_callback)); std::move(exit_callback));
delegate_view_->UpdateDragHandle(false /*update_color*/); delegate_view_->UpdateDragHandle();
return true; return true;
} }
void ShelfWidget::ClearLoginShelfSwipeHandler() { void ShelfWidget::ClearLoginShelfSwipeHandler() {
login_shelf_gesture_controller_.reset(); login_shelf_gesture_controller_.reset();
delegate_view_->UpdateDragHandle(false /*update_color*/); delegate_view_->UpdateDragHandle();
} }
ui::Layer* ShelfWidget::GetOpaqueBackground() { ui::Layer* ShelfWidget::GetOpaqueBackground() {
...@@ -947,9 +927,10 @@ void ShelfWidget::OnSessionStateChanged(session_manager::SessionState state) { ...@@ -947,9 +927,10 @@ void ShelfWidget::OnSessionStateChanged(session_manager::SessionState state) {
shelf_window->parent()->StackChildAtBottom(shelf_window); shelf_window->parent()->StackChildAtBottom(shelf_window);
} }
shelf_layout_manager_->SetDimmed(false); shelf_layout_manager_->SetDimmed(false);
// Depending on session state change, the drag handle visibiliy and color delegate_view_->UpdateDragHandle();
// might have to be changed. // Update drag handle's color on session state changes since the color mode
delegate_view_->UpdateDragHandle(true /*update_color*/); // might change on session state changes.
delegate_view_->drag_handle()->UpdateColor();
login_shelf_view_->UpdateAfterSessionChange(); login_shelf_view_->UpdateAfterSessionChange();
} }
......
...@@ -258,6 +258,10 @@ SkColor AshColorProvider::GetContentLayerColor(ContentLayerType type) const { ...@@ -258,6 +258,10 @@ SkColor AshColorProvider::GetContentLayerColor(ContentLayerType type) const {
case ContentLayerType::kAppStateIndicatorColorInactive: case ContentLayerType::kAppStateIndicatorColorInactive:
return GetDisabledColor( return GetDisabledColor(
GetContentLayerColor(ContentLayerType::kAppStateIndicatorColor)); GetContentLayerColor(ContentLayerType::kAppStateIndicatorColor));
case ContentLayerType::kShelfHandleColor: {
return is_dark_mode ? SkColorSetA(SK_ColorWHITE, 0x24)
: SkColorSetA(SK_ColorBLACK, 0x24);
}
} }
} }
......
...@@ -131,6 +131,9 @@ class ASH_EXPORT AshColorProvider : public SessionObserver { ...@@ -131,6 +131,9 @@ class ASH_EXPORT AshColorProvider : public SessionObserver {
// Color for app state indicator. // Color for app state indicator.
kAppStateIndicatorColor, kAppStateIndicatorColor,
kAppStateIndicatorColorInactive, kAppStateIndicatorColorInactive,
// Color for the shelf drag handle in tablet mode.
kShelfHandleColor,
}; };
// Types of ash styled buttons. // Types of ash styled buttons.
......
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