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() {
base::Unretained(this)));
}
void DragHandle::SetColorAndOpacity(SkColor color, float opacity) {
layer()->SetColor(color);
layer()->SetOpacity(opacity);
}
void DragHandle::HideDragHandleNudge(
contextual_tooltip::DismissNudgeReason reason) {
StopDragHandleNudgeShowTimer();
......@@ -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) {
if (!features::AreContextualNudgesEnabled() ||
!gesture_nudge_target_visibility_) {
......
......@@ -37,8 +37,6 @@ class ASH_EXPORT DragHandle : public views::View,
DragHandle& operator=(const DragHandle&) = delete;
void SetColorAndOpacity(SkColor color, float opacity);
// views::ViewTargeterDelegate:
bool DoesIntersectRect(const views::View* target,
const gfx::Rect& rect) const override;
......@@ -64,6 +62,8 @@ class ASH_EXPORT DragHandle : public views::View,
// contextual nudge will remain visible while the gesture is in progress.
void SetWindowDragFromShelfInProgress(bool gesture_in_progress);
void UpdateColor();
// views::View:
void OnGestureEvent(ui::GestureEvent* event) override;
gfx::Rect GetAnchorBoundsInScreen() const override;
......
......@@ -146,7 +146,7 @@ class ShelfWidget::DelegateView : public views::WidgetDelegate,
void UpdateBackgroundBlur();
void UpdateOpaqueBackground();
void UpdateDragHandle(bool update_color);
void UpdateDragHandle();
// This will be called when the parent local bounds change.
void OnBoundsChanged(const gfx::Rect& old_bounds) override;
......@@ -267,7 +267,7 @@ void ShelfWidget::DelegateView::HideOpaqueBackground() {
void ShelfWidget::DelegateView::ShowOpaqueBackground() {
hide_background_for_transitions_ = false;
UpdateOpaqueBackground();
UpdateDragHandle(false /*update_color*/);
UpdateDragHandle();
UpdateBackgroundBlur();
}
......@@ -358,32 +358,12 @@ void ShelfWidget::DelegateView::UpdateOpaqueBackground() {
}
opaque_background()->SetBounds(opaque_background_bounds);
UpdateDragHandle(false /*update_color*/);
UpdateDragHandle();
UpdateBackgroundBlur();
SchedulePaint();
}
void ShelfWidget::DelegateView::UpdateDragHandle(bool update_color) {
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);
}
}
void ShelfWidget::DelegateView::UpdateDragHandle() {
if (shelf_widget_->login_shelf_view_->GetVisible()) {
drag_handle_->SetVisible(
shelf_widget_->login_shelf_gesture_controller_.get());
......@@ -531,13 +511,13 @@ bool ShelfWidget::SetLoginShelfSwipeHandler(
std::make_unique<LoginShelfGestureController>(
shelf_, delegate_view_->drag_handle(), nudge_text, fling_callback,
std::move(exit_callback));
delegate_view_->UpdateDragHandle(false /*update_color*/);
delegate_view_->UpdateDragHandle();
return true;
}
void ShelfWidget::ClearLoginShelfSwipeHandler() {
login_shelf_gesture_controller_.reset();
delegate_view_->UpdateDragHandle(false /*update_color*/);
delegate_view_->UpdateDragHandle();
}
ui::Layer* ShelfWidget::GetOpaqueBackground() {
......@@ -947,9 +927,10 @@ void ShelfWidget::OnSessionStateChanged(session_manager::SessionState state) {
shelf_window->parent()->StackChildAtBottom(shelf_window);
}
shelf_layout_manager_->SetDimmed(false);
// Depending on session state change, the drag handle visibiliy and color
// might have to be changed.
delegate_view_->UpdateDragHandle(true /*update_color*/);
delegate_view_->UpdateDragHandle();
// Update drag handle's color on session state changes since the color mode
// might change on session state changes.
delegate_view_->drag_handle()->UpdateColor();
login_shelf_view_->UpdateAfterSessionChange();
}
......
......@@ -258,6 +258,10 @@ SkColor AshColorProvider::GetContentLayerColor(ContentLayerType type) const {
case ContentLayerType::kAppStateIndicatorColorInactive:
return GetDisabledColor(
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 {
// Color for app state indicator.
kAppStateIndicatorColor,
kAppStateIndicatorColorInactive,
// Color for the shelf drag handle in tablet mode.
kShelfHandleColor,
};
// 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