Skip to content

Commit

Permalink
Capture Mode: update drag affordance logic
Browse files Browse the repository at this point in the history
Currently, drag affordances are shown in an inconsistent manner, so this
CL will clean that up by hiding the drag affordances whenever resizing
or moving is done. Also, this will remove the drag affordances when the
countdown animation begins.

Bug: 1170496
Test: manual
Change-Id: Ibf14c366e2583708cb3107b4a9c9d55e414e53df
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2648634
Reviewed-by: Sammie Quon <sammiequon@chromium.org>
Reviewed-by: Ahmed Fakhry <afakhry@chromium.org>
Commit-Queue: Richard Chui <richui@chromium.org>
Cr-Commit-Position: refs/heads/master@{#847260}
  • Loading branch information
Richard Chui authored and Chromium LUCI CQ committed Jan 26, 2021
1 parent ad937e6 commit 27baad0
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 16 deletions.
16 changes: 10 additions & 6 deletions ash/capture_mode/capture_mode_session.cc
Original file line number Diff line number Diff line change
Expand Up @@ -623,6 +623,9 @@ void CaptureModeSession::StartCountDown(
ui::LayerAnimator::IMMEDIATELY_ANIMATE_TO_NEW_TARGET);
capture_bar_layer->SetOpacity(0.f);

// Do a repaint to hide the affordance circles.
RepaintRegion();

// Fade out the shield if it's recording fullscreen.
if (controller_->source() == CaptureModeSource::kFullscreen) {
ui::ScopedLayerAnimationSettings shield_settings(layer()->GetAnimator());
Expand Down Expand Up @@ -876,12 +879,14 @@ void CaptureModeSession::PaintCaptureRegion(gfx::Canvas* canvas) {
radius, focus_ring_flags);
};

if (is_selecting_region_ ||
capture_mode_util::ShouldHideDragAffordance(fine_tune_position_)) {
if (is_selecting_region_ || fine_tune_position_ != FineTunePosition::kNone) {
maybe_draw_focus_ring(focused_fine_tune_position_);
return;
}

if (IsInCountDownAnimation())
return;

// Draw the drag affordance circles.
cc::PaintFlags circle_flags;
circle_flags.setColor(kRegionBorderColor);
Expand Down Expand Up @@ -1133,13 +1138,12 @@ void CaptureModeSession::OnLocatedEventPressed(
return;
}

if (fine_tune_position_ != FineTunePosition::kNone)
++num_capture_region_adjusted_;

// In order to hide the drag affordance circles on click, we need to repaint
// the capture region.
if (capture_mode_util::ShouldHideDragAffordance(fine_tune_position_))
if (fine_tune_position_ != FineTunePosition::kNone) {
++num_capture_region_adjusted_;
RepaintRegion();
}

if (fine_tune_position_ != FineTunePosition::kCenter &&
fine_tune_position_ != FineTunePosition::kNone) {
Expand Down
7 changes: 0 additions & 7 deletions ash/capture_mode/capture_mode_util.cc
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,6 @@ bool IsCornerFineTunePosition(FineTunePosition position) {
return false;
}

bool ShouldHideDragAffordance(FineTunePosition position) {
// Do not show affordance circles when repositioning the whole region or if
// resizing on a corner.
return position == FineTunePosition::kCenter ||
IsCornerFineTunePosition(position);
}

void SetStopRecordingButtonVisibility(aura::Window* root, bool visible) {
DCHECK(root);
DCHECK(root->IsRootWindow());
Expand Down
3 changes: 0 additions & 3 deletions ash/capture_mode/capture_mode_util.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,6 @@ ASH_EXPORT gfx::Point GetLocationForFineTunePosition(const gfx::Rect& rect,
// Return whether |position| is a corner.
bool IsCornerFineTunePosition(FineTunePosition position);

// Return whether drag affordance circles should be hidden.
bool ShouldHideDragAffordance(FineTunePosition position);

// Sets the visibility of the stop-recording button in the Shelf's status area
// widget of the given |root| window.
void SetStopRecordingButtonVisibility(aura::Window* root, bool visible);
Expand Down

0 comments on commit 27baad0

Please sign in to comment.