<commit_before>// Copyright (c) 2007-2018 ppy Pty Ltd <<EMAIL>>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE

using OpenTK;
using osu.Framework.Allocation;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Shapes;
using osu.Framework.Input.Events;
using osu.Framework.Timing;
using osu.Game.Beatmaps;
using osu.Game.Graphics;

namespace osu.Game.Screens.Edit.Components.Timelines.Summary.Parts
{
    /// <summary>
    /// The part of the timeline that displays the current position of the song.
    /// </summary>
    public class MarkerPart : TimelinePart
    {
        private readonly Drawable marker;

        private readonly IAdjustableClock adjustableClock;

        public MarkerPart(IAdjustableClock adjustableClock)
        {
            this.adjustableClock = adjustableClock;

            Add(marker = new MarkerVisualisation());
        }

        protected override bool OnDragStart(DragStartEvent e) => true;
        protected override bool OnDragEnd(DragEndEvent e) => true;
        protected override bool OnDrag(DragEvent e)
        {
            seekToPosition(e.ScreenSpaceMousePosition);
            return true;
        }

        protected override bool OnMouseDown(MouseDownEvent e)
        {
            seekToPosition(e.ScreenSpaceMousePosition);
            return true;
        }

        /// <summary>
        /// Seeks the <see cref="SummaryTimeline"/> to the time closest to a position on the screen relative to the <see cref="SummaryTimeline"/>.
        /// </summary>
        /// <param name="screenPosition">The position in screen coordinates.</param>
        private void seekToPosition(Vector2 screenPosition)
        {
            if (Beatmap.Value == null)
                return;

            float markerPos = MathHelper.Clamp(ToLocalSpace(screenPosition).X, 0, DrawWidth);
            adjustableClock.Seek(markerPos / DrawWidth * Beatmap.Value.Track.Length);
        }

        protected override void Update()
        {
            base.Update();
            marker.X = (float)adjustableClock.CurrentTime;<commit_msg>Debounce editor summary timeline seeks<commit_after>// Copyright (c) 2007-2018 ppy Pty Ltd <<EMAIL>>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE

using OpenTK;
using osu.Framework.Allocation;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Shapes;
using osu.Framework.Input.Events;
using osu.Framework.Threading;
using osu.Framework.Timing;
using osu.Game.Beatmaps;
using osu.Game.Graphics;

namespace osu.Game.Screens.Edit.Components.Timelines.Summary.Parts
{
    /// <summary>
    /// The part of the timeline that displays the current position of the song.
    /// </summary>
    public class MarkerPart : TimelinePart
    {
        private readonly Drawable marker;

        private readonly IAdjustableClock adjustableClock;

        public MarkerPart(IAdjustableClock adjustableClock)
        {
            this.adjustableClock = adjustableClock;

            Add(marker = new MarkerVisualisation());
        }

        protected override bool OnDragStart(DragStartEvent e) => true;
        protected override bool OnDragEnd(DragEndEvent e) => true;
        protected override bool OnDrag(DragEvent e)
        {
            seekToPosition(e.ScreenSpaceMousePosition);
            return true;
        }

        protected override bool OnMouseDown(MouseDownEvent e)
        {
            seekToPosition(e.ScreenSpaceMousePosition);
            return true;
        }

        private ScheduledDelegate scheduledSeek;

        /// <summary>
        /// Seeks the <see cref="SummaryTimeline"/> to the time closest to a position on the screen relative to the <see cref="SummaryTimeline"/>.
        /// </summary>
        /// <param name="screenPosition">The position in screen coordinates.</param>
        private void seekToPosition(Vector2 screenPosition)
        {
            scheduledSeek?.Cancel();
            scheduledSeek = Schedule(() =>
            {
                if (Beatmap.Value == null)
                    return;

                float markerPos = MathHelper.Clamp(ToLocalSpace(screenPosition).X, 0, DrawWidth);
                adjustableClock.Seek(markerPos / DrawWidth * Beatmap.Value.Track.Length);
            });
        }

        protected override void Update()
        {
            base.Update();
            marker.X = (float)adjustableClock.CurrentTime;
{'fraction_non_alphanumeric': 0.09300791556728233, 'fraction_numerical': 0.0043975373790677225, 'mean_word_length': 2.4436033308099923, 'pattern_counts': {'":': 0, '<': 23, '<?xml version=': 0, '>': 28, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1117143', 'n_tokens_mistral': 1228, 'n_tokens_neox': 1173, 'n_words': 305}