Commit 47f4522f authored by Sammie Quon's avatar Sammie Quon Committed by Commit Bot

capture_mode: Add drop shadow for capture region outline and circles.

Test: manual
Bug: 1120132
Change-Id: I288ba34d7843dde8077a0c998d02d080b11e5412
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2426466
Commit-Queue: Sammie Quon <sammiequon@chromium.org>
Reviewed-by: default avatarAhmed Fakhry <afakhry@chromium.org>
Cr-Commit-Position: refs/heads/master@{#810347}
parent 8de0413e
...@@ -26,6 +26,8 @@ ...@@ -26,6 +26,8 @@
#include "ui/gfx/geometry/rect.h" #include "ui/gfx/geometry/rect.h"
#include "ui/gfx/paint_vector_icon.h" #include "ui/gfx/paint_vector_icon.h"
#include "ui/gfx/scoped_canvas.h" #include "ui/gfx/scoped_canvas.h"
#include "ui/gfx/shadow_value.h"
#include "ui/gfx/skia_paint_util.h"
#include "ui/views/controls/button/label_button.h" #include "ui/views/controls/button/label_button.h"
#include "ui/views/controls/label.h" #include "ui/views/controls/label.h"
...@@ -33,7 +35,7 @@ namespace ash { ...@@ -33,7 +35,7 @@ namespace ash {
namespace { namespace {
constexpr int kBorderStrokePx = 2; constexpr int kBorderStrokePx = 1;
// The visual radius of the drag affordance circles which are shown while // The visual radius of the drag affordance circles which are shown while
// resizing a drag region. // resizing a drag region.
...@@ -49,6 +51,19 @@ constexpr SkColor kRegionBorderColor = SK_ColorWHITE; ...@@ -49,6 +51,19 @@ constexpr SkColor kRegionBorderColor = SK_ColorWHITE;
// Blue300 at 30%. // Blue300 at 30%.
constexpr SkColor kCaptureRegionColor = SkColorSetA(gfx::kGoogleBlue300, 77); constexpr SkColor kCaptureRegionColor = SkColorSetA(gfx::kGoogleBlue300, 77);
// Values for the shadows of the capture region components.
constexpr gfx::ShadowValue kRegionOutlineShadow(gfx::Vector2d(0, 0),
2,
SkColorSetARGB(41, 0, 0, 0));
constexpr gfx::ShadowValue kRegionAffordanceCircleShadow1(
gfx::Vector2d(0, 1),
2,
SkColorSetARGB(76, 0, 0, 0));
constexpr gfx::ShadowValue kRegionAffordanceCircleShadow2(
gfx::Vector2d(0, 2),
6,
SkColorSetARGB(38, 0, 0, 0));
// Mouse cursor warping is disabled when the capture source is a custom region. // Mouse cursor warping is disabled when the capture source is a custom region.
// Sets the mouse warp status to |enable| and return the original value. // Sets the mouse warp status to |enable| and return the original value.
bool SetMouseWarpEnabled(bool enable) { bool SetMouseWarpEnabled(bool enable) {
...@@ -273,7 +288,14 @@ void CaptureModeSession::PaintCaptureRegion(gfx::Canvas* canvas) { ...@@ -273,7 +288,14 @@ void CaptureModeSession::PaintCaptureRegion(gfx::Canvas* canvas) {
region.Inset(-kBorderStrokePx, -kBorderStrokePx); region.Inset(-kBorderStrokePx, -kBorderStrokePx);
canvas->FillRect(region, SK_ColorTRANSPARENT, SkBlendMode::kClear); canvas->FillRect(region, SK_ColorTRANSPARENT, SkBlendMode::kClear);
canvas->DrawRect(gfx::RectF(region), kRegionBorderColor);
// Draw the region border.
cc::PaintFlags border_flags;
border_flags.setColor(kRegionBorderColor);
border_flags.setStyle(cc::PaintFlags::kStroke_Style);
border_flags.setStrokeWidth(kBorderStrokePx);
border_flags.setLooper(gfx::CreateShadowDrawLooper({kRegionOutlineShadow}));
canvas->DrawRect(gfx::RectF(region), border_flags);
if (is_select_phase_) if (is_select_phase_)
return; return;
...@@ -283,19 +305,24 @@ void CaptureModeSession::PaintCaptureRegion(gfx::Canvas* canvas) { ...@@ -283,19 +305,24 @@ void CaptureModeSession::PaintCaptureRegion(gfx::Canvas* canvas) {
return; return;
// Draw the drag affordance circles. // Draw the drag affordance circles.
// TODO(sammiequon): Draw a drop shadow for the affordance circles and the cc::PaintFlags circle_flags;
// border. circle_flags.setColor(kRegionBorderColor);
cc::PaintFlags flags; circle_flags.setStyle(cc::PaintFlags::kFill_Style);
flags.setColor(kRegionBorderColor); circle_flags.setLooper(gfx::CreateShadowDrawLooper(
flags.setStyle(cc::PaintFlags::kFill_Style); {kRegionAffordanceCircleShadow1, kRegionAffordanceCircleShadow2}));
canvas->DrawCircle(region.origin(), kAffordanceCircleRadiusDp, flags);
canvas->DrawCircle(region.top_center(), kAffordanceCircleRadiusDp, flags); auto draw_circle = [&canvas, &circle_flags](const gfx::Point& location) {
canvas->DrawCircle(region.top_right(), kAffordanceCircleRadiusDp, flags); canvas->DrawCircle(location, kAffordanceCircleRadiusDp, circle_flags);
canvas->DrawCircle(region.left_center(), kAffordanceCircleRadiusDp, flags); };
canvas->DrawCircle(region.right_center(), kAffordanceCircleRadiusDp, flags);
canvas->DrawCircle(region.bottom_left(), kAffordanceCircleRadiusDp, flags); draw_circle(region.origin());
canvas->DrawCircle(region.bottom_center(), kAffordanceCircleRadiusDp, flags); draw_circle(region.top_center());
canvas->DrawCircle(region.bottom_right(), kAffordanceCircleRadiusDp, flags); draw_circle(region.top_right());
draw_circle(region.right_center());
draw_circle(region.bottom_right());
draw_circle(region.bottom_center());
draw_circle(region.bottom_left());
draw_circle(region.left_center());
} }
void CaptureModeSession::OnLocatedEvent(ui::LocatedEvent* event, void CaptureModeSession::OnLocatedEvent(ui::LocatedEvent* event,
......
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