
Automated patch, intended to be effectively a no-op. Context: https://groups.google.com/a/chromium.org/g/cxx/c/nBD_1LaanTc/m/ghh-ZZhWAwAJ?utm_medium=email&utm_source=footer As of https://crrev.com/1204351, absl::optional is now a type alias for std::optional. We should migrate toward it. Script: ``` function replace { echo "Replacing $1 by $2" git grep -l "$1" \ | cut -f1 -d: \ | grep \ -e "^ash" \ | sort \ | uniq \ | grep \ -e "\.h" \ -e "\.cc" \ -e "\.mm" \ -e "\.py" \ | xargs sed -i "s/$1/$2/g" } replace "absl::make_optional" "std::make_optional" replace "absl::optional" "std::optional" replace "absl::nullopt" "std::nullopt" replace "absl::in_place" "std::in_place" replace "absl::in_place_t" "std::in_place_t" replace "\"third_party\/abseil-cpp\/absl\/types\/optional.h\"" "<optional>" git cl format ``` Bug: chromium:1500249 AX-Relnotes: n/a. Change-Id: I7087c89bc345e825ebcb8c66325f4dcc9d72c3b5 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5062951 Auto-Submit: Arthur Sonzogni <arthursonzogni@chromium.org> Owners-Override: danakj <danakj@chromium.org> Commit-Queue: Arthur Sonzogni <arthursonzogni@chromium.org> Commit-Queue: danakj <danakj@chromium.org> Reviewed-by: danakj <danakj@chromium.org> Cr-Commit-Position: refs/heads/main@{#1230002}
96 lines
3.5 KiB
C++
96 lines
3.5 KiB
C++
// Copyright 2019 The Chromium Authors
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
// found in the LICENSE file.
|
|
|
|
#ifndef ASH_SHELF_SWIPE_HOME_TO_OVERVIEW_CONTROLLER_H_
|
|
#define ASH_SHELF_SWIPE_HOME_TO_OVERVIEW_CONTROLLER_H_
|
|
|
|
#include <optional>
|
|
|
|
#include "ash/ash_export.h"
|
|
#include "base/functional/callback_helpers.h"
|
|
#include "base/timer/timer.h"
|
|
#include "ui/gfx/geometry/point_f.h"
|
|
|
|
namespace ash {
|
|
|
|
// Used by ShelfLayoutManager to handle gesture drag events while the
|
|
// handler is in kSwipeHomeToOverview mode. The controller handles swipe gesture
|
|
// from hot seat on the home screen. The gesture, if detected, transitions the
|
|
// home screen to the overview UI.
|
|
class ASH_EXPORT SwipeHomeToOverviewController {
|
|
public:
|
|
// The minimum vertical distance between gesture location and the bottom of
|
|
// work area for the gesture to trigger transition to overview.
|
|
static constexpr int kVerticalThresholdForOverviewTransition = 56;
|
|
|
|
// The max pointer velocity at which home transitions to overview.
|
|
static constexpr int kMovementVelocityThreshold = 10;
|
|
|
|
// The constructor that uses default tick clock for
|
|
// |overview_transition_timer_|. Should be preferred outside of test
|
|
// environment.
|
|
explicit SwipeHomeToOverviewController(int64_t display_id);
|
|
|
|
// |display_id| - the ID of display on which the gesture started.
|
|
// |tick_clock| - the tick clock that should be used by
|
|
// |overview_transition_timer_|.
|
|
SwipeHomeToOverviewController(int64_t display_id,
|
|
const base::TickClock* tick_clock);
|
|
|
|
SwipeHomeToOverviewController(const SwipeHomeToOverviewController&) = delete;
|
|
SwipeHomeToOverviewController& operator=(
|
|
const SwipeHomeToOverviewController&) = delete;
|
|
|
|
~SwipeHomeToOverviewController();
|
|
|
|
// Called during swiping up on the shelf.
|
|
void Drag(const gfx::PointF& location_in_screen,
|
|
float scroll_x,
|
|
float scroll_y);
|
|
void EndDrag(const gfx::PointF& location_in_screen,
|
|
std::optional<float> velocity_y);
|
|
void CancelDrag();
|
|
|
|
base::OneShotTimer* overview_transition_timer_for_testing() {
|
|
return &overview_transition_timer_;
|
|
}
|
|
|
|
private:
|
|
enum class State { kInitial, kTrackingDrag, kFinished };
|
|
|
|
// Starts |overview_transition_timer_|. No-op if the timer is already running.
|
|
void ScheduleFinalizeDragAndShowOverview();
|
|
|
|
// Finalizes the drag sequence, and starts overview session.
|
|
// Note that the controller might keep getting drag updates as the user keeps
|
|
// moving the pointer - those events will be ignored.
|
|
void FinalizeDragAndShowOverview();
|
|
|
|
// Finalizes the drag sequence by staying on the home screen.
|
|
// |go_back| - if the gesture should invoke home screen back action.
|
|
void FinalizeDragAndStayOnHomeScreen(bool go_back);
|
|
|
|
const int64_t display_id_;
|
|
|
|
State state_ = State::kInitial;
|
|
|
|
// The y in-screen coordinate at which drag, when stopped, will cause
|
|
// transition to overview. Overview session will be started iff the drag stops
|
|
// above this line.
|
|
// The value is set when the controller transitions to kStarted state.
|
|
int overview_transition_threshold_y_ = 0;
|
|
|
|
// Home screen is scaled down depending on gesture vertical distance from the
|
|
// shelf - this is the target gesture vertical location at which home screen
|
|
// should be scaled by the target scale factor.
|
|
int scaling_threshold_y_ = 0;
|
|
|
|
// The timer to run FinalizeDragAndShowOverview().
|
|
base::OneShotTimer overview_transition_timer_;
|
|
};
|
|
|
|
} // namespace ash
|
|
|
|
#endif // ASH_SHELF_SWIPE_HOME_TO_OVERVIEW_CONTROLLER_H_
|