Commit 29e3879d authored by minch's avatar minch Committed by Commit Bot

dark_mode: Live update of splitview.

- Live update the colors of splitview divider and splitview divider
  handler bar.
- Remove RoundedRectView. Replace it with CreateRoundedRectBackground.

Bug: 1131543
Change-Id: If0adeaa835aafb28b6d31ffb7a93f816a8900012
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2531188Reviewed-by: default avatarXiaoqian Dai <xdai@chromium.org>
Commit-Queue: Min Chen <minch@chromium.org>
Cr-Commit-Position: refs/heads/master@{#826470}
parent 966f5ccc
......@@ -1570,8 +1570,6 @@ component("ash") {
"wm/overview/overview_window_drag_controller.h",
"wm/overview/rounded_label_widget.cc",
"wm/overview/rounded_label_widget.h",
"wm/overview/rounded_rect_view.cc",
"wm/overview/rounded_rect_view.h",
"wm/overview/scoped_overview_animation_settings.cc",
"wm/overview/scoped_overview_animation_settings.h",
"wm/overview/scoped_overview_hide_windows.cc",
......
......@@ -40,8 +40,6 @@ constexpr SkColor kCircleColor = SK_ColorWHITE;
constexpr SkColor kLabelBackgroundColor = SkColorSetA(SK_ColorBLACK, 0xDE);
// Colors for split view.
constexpr SkColor kSplitviewDividerColor = SK_ColorBLACK;
constexpr SkColor kSplitviewDividerHandlerBarColor = SK_ColorWHITE;
constexpr SkColor kSplitviewLabelBackgroundColor =
SkColorSetA(SK_ColorBLACK, 0xDE);
constexpr SkColor kSplitviewLabelEnabledColor = SK_ColorWHITE;
......
......@@ -8,8 +8,8 @@
#include "ash/resources/vector_icons/vector_icons.h"
#include "ash/wm/overview/overview_constants.h"
#include "ash/wm/overview/rounded_rect_view.h"
#include "ui/gfx/paint_vector_icon.h"
#include "ui/views/background.h"
#include "ui/views/border.h"
#include "ui/views/controls/image_view.h"
#include "ui/views/layout/layout_provider.h"
......@@ -48,8 +48,9 @@ class DropTargetView::PlusIconView : public views::ImageView {
DropTargetView::DropTargetView(bool has_plus_icon) {
const int corner_radius =
views::LayoutProvider::Get()->GetCornerRadiusMetric(views::EMPHASIS_LOW);
background_view_ = AddChildView(std::make_unique<RoundedRectView>(
corner_radius, kDropTargetBackgroundColor));
background_view_ = AddChildView(std::make_unique<views::View>());
background_view_->SetBackground(views::CreateRoundedRectBackground(
kDropTargetBackgroundColor, corner_radius));
if (has_plus_icon)
plus_icon_ = AddChildView(std::make_unique<PlusIconView>());
......
......@@ -8,7 +8,6 @@
#include "ui/views/view.h"
namespace ash {
class RoundedRectView;
// DropTargetView represents a transparent view with border in overview. It
// includes a background view and plus icon. Dragged window in tablet mode can
......@@ -30,7 +29,7 @@ class DropTargetView : public views::View {
private:
class PlusIconView;
RoundedRectView* background_view_ = nullptr;
views::View* background_view_ = nullptr;
PlusIconView* plus_icon_ = nullptr;
};
......
......@@ -13,7 +13,6 @@
#include "ash/wm/overview/overview_constants.h"
#include "ash/wm/overview/overview_grid.h"
#include "ash/wm/overview/overview_item.h"
#include "ash/wm/overview/rounded_rect_view.h"
#include "ash/wm/window_preview_view.h"
#include "ash/wm/wm_highlight_item_border.h"
#include "ui/accessibility/ax_enums.mojom.h"
......
// Copyright 2017 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "ash/wm/overview/rounded_rect_view.h"
#include "ui/gfx/canvas.h"
namespace ash {
RoundedRectView::RoundedRectView(int corner_radius, SkColor background_color)
: corner_radius_(corner_radius), background_color_(background_color) {}
RoundedRectView::~RoundedRectView() = default;
void RoundedRectView::SetCornerRadius(int radius) {
if (corner_radius_ == radius)
return;
corner_radius_ = radius;
SchedulePaint();
}
void RoundedRectView::OnPaint(gfx::Canvas* canvas) {
views::View::OnPaint(canvas);
cc::PaintFlags flags;
flags.setStyle(cc::PaintFlags::kFill_Style);
flags.setColor(background_color_);
flags.setAntiAlias(true);
gfx::RectF bounds(GetLocalBounds());
canvas->DrawRoundRect(bounds, corner_radius_, flags);
}
} // namespace ash
// Copyright 2017 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef ASH_WM_OVERVIEW_ROUNDED_RECT_VIEW_H_
#define ASH_WM_OVERVIEW_ROUNDED_RECT_VIEW_H_
#include "ui/views/view.h"
namespace gfx {
class Canvas;
} // namespace gfx
namespace ash {
// A View having rounded corners and a specified background color which is
// only painted within the bounds defined by the rounded corners.
class RoundedRectView : public views::View {
public:
RoundedRectView(int corner_radius, SkColor background_color);
RoundedRectView(const RoundedRectView&) = delete;
RoundedRectView& operator=(const RoundedRectView&) = delete;
~RoundedRectView() override;
void SetCornerRadius(int radius);
// views::View:
void OnPaint(gfx::Canvas* canvas) override;
private:
int corner_radius_;
const SkColor background_color_;
};
} // namespace ash
#endif // ASH_WM_OVERVIEW_ROUNDED_RECT_VIEW_H_
......@@ -12,8 +12,6 @@
#include "ash/screen_util.h"
#include "ash/shell.h"
#include "ash/style/ash_color_provider.h"
#include "ash/style/default_color_constants.h"
#include "ash/style/default_colors.h"
#include "ash/wm/desks/desks_util.h"
#include "ash/wm/splitview/split_view_constants.h"
#include "ash/wm/splitview/split_view_controller.h"
......@@ -78,16 +76,11 @@ class DividerView : public views::View, public views::ViewTargeterDelegate {
explicit DividerView(SplitViewController* controller,
SplitViewDivider* divider)
: controller_(controller), divider_(divider) {
divider_view_ = new views::View();
divider_view_ = AddChildView(std::make_unique<views::View>());
divider_view_->SetPaintToLayer(ui::LAYER_SOLID_COLOR);
divider_view_->layer()->SetColor(DeprecatedGetBaseLayerColor(
AshColorProvider::BaseLayerType::kOpaque, kSplitviewDividerColor));
divider_handler_view_ = new SplitViewDividerHandlerView();
AddChildView(divider_view_);
AddChildView(divider_handler_view_);
divider_handler_view_ =
AddChildView(std::make_unique<SplitViewDividerHandlerView>());
SetEventTargeter(
std::unique_ptr<views::ViewTargeter>(new views::ViewTargeter(this)));
}
......@@ -184,6 +177,12 @@ class DividerView : public views::View, public views::ViewTargeterDelegate {
event->SetHandled();
}
void OnThemeChanged() override {
views::View::OnThemeChanged();
divider_view_->layer()->SetColor(AshColorProvider::Get()->GetBaseLayerColor(
AshColorProvider::BaseLayerType::kOpaque));
}
// views::ViewTargeterDelegate:
bool DoesIntersectRect(const views::View* target,
const gfx::Rect& rect) const override {
......
......@@ -6,16 +6,25 @@
#include "ash/display/screen_orientation_controller.h"
#include "ash/shell.h"
#include "ash/style/default_color_constants.h"
#include "ash/style/default_colors.h"
#include "ash/style/ash_color_provider.h"
#include "ash/wm/splitview/split_view_constants.h"
#include "ash/wm/splitview/split_view_utils.h"
#include "base/timer/timer.h"
#include "ui/gfx/animation/animation_delegate.h"
#include "ui/gfx/animation/slide_animation.h"
#include "ui/views/background.h"
namespace ash {
namespace {
SkColor GetBackgroundColor() {
return AshColorProvider::Get()->GetContentLayerColor(
AshColorProvider::ContentLayerType::kIconColorPrimary);
}
} // namespace
class SplitViewDividerHandlerView::SelectionAnimation
: public gfx::SlideAnimation,
public gfx::AnimationDelegate {
......@@ -41,7 +50,7 @@ class SplitViewDividerHandlerView::SelectionAnimation
// gfx::AnimationDelegate:
void AnimationProgressed(const gfx::Animation* animation) override {
UpdateWhiteHandlerBounds();
white_handler_view_->SetCornerRadius(CurrentValueBetween(
white_handler_view_->UpdateCornerRadius(CurrentValueBetween(
kSplitviewWhiteBarCornerRadius, kSplitviewWhiteBarRadius));
}
......@@ -108,12 +117,10 @@ class SplitViewDividerHandlerView::SpawningAnimation
};
SplitViewDividerHandlerView::SplitViewDividerHandlerView()
: RoundedRectView(kSplitviewWhiteBarCornerRadius,
DeprecatedGetContentLayerColor(
AshColorProvider::ContentLayerType::kIconColorPrimary,
kSplitviewDividerHandlerBarColor)),
selection_animation_(std::make_unique<SelectionAnimation>(this)) {
: selection_animation_(std::make_unique<SelectionAnimation>(this)) {
SetPaintToLayer();
SetBackground(views::CreateRoundedRectBackground(
GetBackgroundColor(), kSplitviewWhiteBarCornerRadius));
}
SplitViewDividerHandlerView::~SplitViewDividerHandlerView() = default;
......@@ -135,6 +142,10 @@ void SplitViewDividerHandlerView::Refresh(bool is_resizing) {
selection_animation_->Hide();
}
void SplitViewDividerHandlerView::UpdateCornerRadius(int radius) {
layer()->SetRoundedCornerRadius(gfx::RoundedCornersF{radius});
}
void SplitViewDividerHandlerView::SetBounds(int short_length,
int long_length,
int signed_offset) {
......@@ -152,7 +163,13 @@ void SplitViewDividerHandlerView::OnPaint(gfx::Canvas* canvas) {
views::View::OnPaint(canvas);
// It's needed to avoid artifacts when tapping on the divider quickly.
canvas->DrawColor(SK_ColorTRANSPARENT, SkBlendMode::kSrc);
RoundedRectView::OnPaint(canvas);
views::View::OnPaint(canvas);
}
void SplitViewDividerHandlerView::OnThemeChanged() {
views::View::OnThemeChanged();
background()->SetNativeControlColor(GetBackgroundColor());
SchedulePaint();
}
} // namespace ash
......@@ -9,7 +9,6 @@
#include "ash/ash_export.h"
#include "ash/public/cpp/ash_constants.h"
#include "ash/wm/overview/rounded_rect_view.h"
#include "base/macros.h"
#include "ui/gfx/canvas.h"
#include "ui/views/view.h"
......@@ -17,7 +16,7 @@
namespace ash {
// The white handler bar in the middle of the divider.
class ASH_EXPORT SplitViewDividerHandlerView : public RoundedRectView {
class ASH_EXPORT SplitViewDividerHandlerView : public views::View {
public:
SplitViewDividerHandlerView();
~SplitViewDividerHandlerView() override;
......@@ -36,6 +35,10 @@ class ASH_EXPORT SplitViewDividerHandlerView : public RoundedRectView {
// dragging.
void Refresh(bool is_resizing);
// Updates the corner radius of the handler bar to |radius|. Happens during
// the animation of starting and ending dragging.
void UpdateCornerRadius(int radius);
private:
class SelectionAnimation;
class SpawningAnimation;
......@@ -44,6 +47,7 @@ class ASH_EXPORT SplitViewDividerHandlerView : public RoundedRectView {
// views::View:
void OnPaint(gfx::Canvas* canvas) override;
void OnThemeChanged() override;
// Handles the animations for starting and ending dragging.
std::unique_ptr<SelectionAnimation> selection_animation_;
......
......@@ -16,7 +16,6 @@
#include "ash/style/ash_color_provider.h"
#include "ash/style/default_color_constants.h"
#include "ash/style/default_colors.h"
#include "ash/wm/overview/rounded_rect_view.h"
#include "ash/wm/splitview/split_view_constants.h"
#include "ash/wm/splitview/split_view_highlight_view.h"
#include "ash/wm/splitview/split_view_utils.h"
......@@ -29,6 +28,7 @@
#include "ui/base/l10n/l10n_util.h"
#include "ui/compositor/scoped_layer_animation_settings.h"
#include "ui/display/display_observer.h"
#include "ui/views/background.h"
#include "ui/views/controls/label.h"
#include "ui/views/layout/box_layout.h"
#include "ui/views/view.h"
......@@ -130,13 +130,14 @@ class SplitViewDragIndicators::RotatedImageLabelView : public views::View {
// Use |label_parent_| to add padding and rounded edges to the text. Create
// this extra view so that we can rotate the label, while having a slide
// animation at times on the whole thing.
label_parent_ = AddChildView(std::make_unique<RoundedRectView>(
kSplitviewLabelRoundRectRadiusDp,
DeprecatedGetBaseLayerColor(
AshColorProvider::BaseLayerType::kTransparent80,
kSplitviewLabelBackgroundColor)));
label_parent_ = AddChildView(std::make_unique<views::View>());
label_parent_->SetPaintToLayer();
label_parent_->layer()->SetFillsBoundsOpaquely(false);
label_parent_->SetBackground(views::CreateRoundedRectBackground(
DeprecatedGetBaseLayerColor(
AshColorProvider::BaseLayerType::kTransparent80,
kSplitviewLabelBackgroundColor),
kSplitviewLabelRoundRectRadiusDp));
label_parent_->SetLayoutManager(std::make_unique<views::BoxLayout>(
views::BoxLayout::Orientation::kVertical,
gfx::Insets(kSplitviewLabelVerticalInsetDp,
......@@ -223,7 +224,7 @@ class SplitViewDragIndicators::RotatedImageLabelView : public views::View {
// left/top one.
const bool is_right_or_bottom_;
RoundedRectView* label_parent_ = nullptr;
views::View* label_parent_ = nullptr;
views::Label* label_ = nullptr;
DISALLOW_COPY_AND_ASSIGN(RotatedImageLabelView);
......
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