chromium/components/global_media_controls/public/views/media_progress_view.cc

// Copyright 2023 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "components/global_media_controls/public/views/media_progress_view.h"

#include "base/i18n/number_formatting.h"
#include "base/i18n/rtl.h"
#include "cc/paint/paint_flags.h"
#include "components/global_media_controls/media_view_utils.h"
#include "components/strings/grit/components_strings.h"
#include "services/media_session/public/mojom/media_session.mojom.h"
#include "third_party/skia/include/core/SkPath.h"
#include "ui/accessibility/ax_action_data.h"
#include "ui/base/l10n/l10n_util.h"
#include "ui/base/metadata/metadata_impl_macros.h"
#include "ui/gfx/canvas.h"
#include "ui/gfx/geometry/skia_conversions.h"
#include "ui/views/accessibility/view_accessibility.h"
#include "ui/views/widget/widget.h"

namespace global_media_controls {

namespace {

// The height of the whole view based on whether the progress line is squiggly
// or straight.
constexpr int kSquigglyProgressViewHeight =;
constexpr int kStraightProgressViewHeight =;

// The width of stroke to paint the progress foreground and background lines,
// and also the focus ring.
constexpr int kStrokeWidth =;

// The width of stroke to paint the progress foreground straight line when user
// is dragging the progress line.
constexpr int kLargeStrokeWidth =;

// The height of squiggly progress that user can click to seek to a new media
// position. This is slightly larger than the painted progress height.
constexpr int kProgressClickHeight =;

// Defines the x of where the painting of progress should start since we own the
// OnPaint() function.
constexpr int kWidthInset =;

// Defines the wave size of the squiggly progress.
constexpr int kProgressWavelength =;
constexpr int kProgressAmplitude =;

// Squiggly progress wave speed in pixels per second.
constexpr int kProgressPhaseSpeed =;

// The size of the rounded rectangle indicator at the end of the foreground
// squiggly or straight progress.
constexpr gfx::SizeF kSquigglyProgressIndicatorSize =;
constexpr gfx::SizeF kStraightProgressIndicatorSize =;

// The width of the gap between the progress indicator and the straight lines.
constexpr int kStraightProgressIndicatorGap =;

// Defines how long the animation for progress transitioning between squiggly
// and straight lines will take.
constexpr base::TimeDelta kSlideAnimationDuration =;

// Defines how frequently the progress will be updated.
constexpr base::TimeDelta kProgressUpdateFrequency =;

// Defines how long the progress colors should delay switching when the media
// playback rate is changing.
constexpr base::TimeDelta kSwitchProgressColorsDelayTime =;

// Defines how long to delay before considering the user is dragging the
// progress view rather than clicking.
constexpr base::TimeDelta kProgressDragStartedDelayTime =;

// Defines the radius of the focus ring around the progress.
constexpr float kFocusRingRadius =;

// Defines how much the current media position will change for increment.
constexpr base::TimeDelta kCurrentPositionChange =;

}  // namespace

MediaProgressView::MediaProgressView(
    bool use_squiggly_line,
    ui::ColorId playing_foreground_color_id,
    ui::ColorId playing_background_color_id,
    ui::ColorId paused_foreground_color_id,
    ui::ColorId paused_background_color_id,
    ui::ColorId focus_ring_color_id,
    base::RepeatingCallback<void(DragState)> drag_state_change_callback,
    base::RepeatingCallback<void(PlaybackStateChangeForDragging)>
        playback_state_change_for_dragging_callback,
    base::RepeatingCallback<void(double)> seek_callback,
    base::RepeatingCallback<void(base::TimeDelta)> on_update_progress_callback)
    :{}

MediaProgressView::~MediaProgressView() = default;

///////////////////////////////////////////////////////////////////////////////
// gfx::AnimationDelegate implementations:

void MediaProgressView::AnimationProgressed(const gfx::Animation* animation) {}

///////////////////////////////////////////////////////////////////////////////
// views::View implementations:

gfx::Size MediaProgressView::CalculatePreferredSize(
    const views::SizeBounds& available_size) const {}

void MediaProgressView::GetAccessibleNodeData(ui::AXNodeData* node_data) {}

bool MediaProgressView::HandleAccessibleAction(
    const ui::AXActionData& action_data) {}

void MediaProgressView::VisibilityChanged(View* starting_from,
                                          bool is_visible) {}

void MediaProgressView::AddedToWidget() {}

void MediaProgressView::OnPaint(gfx::Canvas* canvas) {}

void MediaProgressView::OnFocus() {}

void MediaProgressView::OnBlur() {}

bool MediaProgressView::OnMousePressed(const ui::MouseEvent& event) {}

bool MediaProgressView::OnMouseDragged(const ui::MouseEvent& event) {}

void MediaProgressView::OnMouseReleased(const ui::MouseEvent& event) {}

bool MediaProgressView::OnKeyPressed(const ui::KeyEvent& event) {}

void MediaProgressView::OnGestureEvent(ui::GestureEvent* event) {}

///////////////////////////////////////////////////////////////////////////////
// MediaProgressView implementations:

void MediaProgressView::UpdateProgress(
    const media_session::MediaPosition& media_position) {}

void MediaProgressView::MaybeNotifyAccessibilityValueChanged() {}

void MediaProgressView::OnProgressDragStarted(double location) {}

void MediaProgressView::DelayedProgressDragStarted(double location) {}

void MediaProgressView::OnProgressDragEnded() {}

void MediaProgressView::UpdateProgressColors(bool is_paused) {}

void MediaProgressView::HandleSeeking(double location) {}

double MediaProgressView::CalculateNewValue(base::TimeDelta new_position) {}

bool MediaProgressView::IsValidSeekPosition(int x, int y) {}

// Helper functions for testing:
double MediaProgressView::current_value_for_testing() const {}

bool MediaProgressView::is_paused_for_testing() const {}

bool MediaProgressView::is_live_for_testing() const {}

bool MediaProgressView::use_paused_colors_for_testing() const {}

void MediaProgressView::set_update_progress_timer_for_testing(
    std::unique_ptr<base::OneShotTimer> test_timer) {}

void MediaProgressView::set_switch_progress_colors_delay_timer_for_testing(
    std::unique_ptr<base::OneShotTimer> test_timer) {}

void MediaProgressView::set_progress_drag_started_delay_timer_for_testing(
    std::unique_ptr<base::OneShotTimer> test_timer) {}

BEGIN_METADATA()

}  // namespace global_media_controls