Beispiel #1
0
        /// <summary>
        /// Handle a blueprint requesting selection.
        /// </summary>
        /// <param name="blueprint">The blueprint.</param>
        /// <param name="e">The mouse event responsible for deselection.</param>
        /// <returns>Whether a deselection was performed.</returns>
        internal bool MouseUpSelectionRequested(SelectionBlueprint <T> blueprint, MouseButtonEvent e)
        {
            if (blueprint.IsSelected)
            {
                blueprint.ToggleSelection();
                return(true);
            }

            return(false);
        }
Beispiel #2
0
        private void ensureSelected(SelectionBlueprint blueprint)
        {
            if (blueprint.IsSelected)
            {
                return;
            }

            DeselectAll?.Invoke();
            blueprint.Select();
        }
Beispiel #3
0
        /// <summary>
        /// Handle a blueprint becoming selected.
        /// </summary>
        /// <param name="blueprint">The blueprint.</param>
        internal void HandleSelected(SelectionBlueprint blueprint)
        {
            selectedBlueprints.Add(blueprint);

            // there are potentially multiple SelectionHandlers active, but we only want to add hitobjects to the selected list once.
            if (!EditorBeatmap.SelectedHitObjects.Contains(blueprint.HitObject))
            {
                EditorBeatmap.SelectedHitObjects.Add(blueprint.HitObject);
            }
        }
        /// <summary>
        /// Handle a blueprint becoming deselected.
        /// </summary>
        /// <param name="blueprint">The blueprint.</param>
        internal void HandleDeselected(SelectionBlueprint blueprint)
        {
            selectedBlueprints.Remove(blueprint);

            // We don't want to update visibility if > 0, since we may be deselecting blueprints during drag-selection
            if (selectedBlueprints.Count == 0)
            {
                UpdateVisibility();
            }
        }
Beispiel #5
0
        /// <summary>
        /// Handle a blueprint becoming selected.
        /// </summary>
        /// <param name="blueprint">The blueprint.</param>
        internal virtual void HandleSelected(SelectionBlueprint <T> blueprint)
        {
            // there are potentially multiple SelectionHandlers active, but we only want to add items to the selected list once.
            if (!SelectedItems.Contains(blueprint.Item))
            {
                SelectedItems.Add(blueprint.Item);
            }

            selectedBlueprints.Add(blueprint);
        }
        public override bool Remove(SelectionBlueprint <HitObject> drawable)
        {
            if (!base.Remove(drawable))
            {
                return(false);
            }

            unbindStartTime(drawable);
            return(true);
        }
Beispiel #7
0
        /// <summary>
        /// Ensure the blueprint is in a selected state.
        /// </summary>
        /// <param name="blueprint">The blueprint to select.</param>
        /// <returns>Whether selection state was changed.</returns>
        private bool ensureSelected(SelectionBlueprint <T> blueprint)
        {
            if (blueprint.IsSelected)
            {
                return(false);
            }

            DeselectAll?.Invoke();
            blueprint.Select();
            return(true);
        }
        private void load()
        {
            blueprint       = CreateBlueprint();
            blueprint.Depth = float.MinValue;
            blueprint.SelectionRequested += (_, __) => blueprint.Select();

            Add(blueprint);

            AddStep("Select", () => blueprint.Select());
            AddStep("Deselect", () => blueprint.Deselect());
        }
Beispiel #9
0
 private void handleQuickDeletion(SelectionBlueprint blueprint)
 {
     if (!blueprint.IsSelected)
     {
         EditorBeatmap.Remove(blueprint.HitObject);
     }
     else
     {
         deleteSelected();
     }
 }
Beispiel #10
0
        /// <summary>
        /// Finishes the current movement of selected blueprints.
        /// </summary>
        /// <returns>Whether a movement was active.</returns>
        private bool finishSelectionMovement()
        {
            if (movementBlueprint == null)
            {
                return(false);
            }

            screenSpaceMovementStartPosition = null;
            movementBlueprint = null;

            return(true);
        }
Beispiel #11
0
        /// <summary>
        /// Finishes the current movement of selected blueprints.
        /// </summary>
        /// <returns>Whether a movement was active.</returns>
        private bool finishSelectionMovement()
        {
            if (movementBlueprint == null)
            {
                return(false);
            }

            movementBlueprintOriginalPosition = null;
            movementBlueprint = null;

            return(true);
        }
        private void bindStartTime(SelectionBlueprint <TimeTag> blueprint)
        {
            var bindable = blueprint.Item.TimeBindable.GetBoundCopy();

            bindable.BindValueChanged(_ =>
            {
                if (LoadState >= LoadState.Ready)
                {
                    SortInternal();
                }
            });

            startTimeMap[blueprint] = bindable;
        }
Beispiel #13
0
 /// <summary>
 /// Handle a blueprint requesting selection.
 /// </summary>
 /// <param name="blueprint">The blueprint.</param>
 /// <param name="state">The input state at the point of selection.</param>
 internal void HandleSelectionRequested(SelectionBlueprint blueprint, InputState state)
 {
     if (state.Keyboard.ShiftPressed && state.Mouse.IsPressed(MouseButton.Right))
     {
         EditorBeatmap.Remove(blueprint.HitObject);
     }
     else if (state.Keyboard.ControlPressed && state.Mouse.IsPressed(MouseButton.Left))
     {
         blueprint.ToggleSelection();
     }
     else
     {
         ensureSelected(blueprint);
     }
 }
Beispiel #14
0
        public override void HandleDrag(SelectionBlueprint blueprint, DragEvent dragEvent)
        {
            foreach (var h in SelectedHitObjects.OfType <OsuHitObject>())
            {
                if (h is Spinner)
                {
                    // Spinners don't support position adjustments
                    continue;
                }

                h.Position += dragEvent.Delta;
            }

            base.HandleDrag(blueprint, dragEvent);
        }
Beispiel #15
0
 /// <summary>
 /// Handle a blueprint requesting selection.
 /// </summary>
 /// <param name="blueprint">The blueprint.</param>
 /// <param name="state">The input state at the point of selection.</param>
 internal void HandleSelectionRequested(SelectionBlueprint blueprint, InputState state)
 {
     if (state.Keyboard.ShiftPressed && state.Mouse.IsPressed(MouseButton.Right))
     {
         handleQuickDeletion(blueprint);
     }
     else if (state.Keyboard.ControlPressed && state.Mouse.IsPressed(MouseButton.Left))
     {
         blueprint.ToggleSelection();
     }
     else
     {
         ensureSelected(blueprint);
     }
 }
Beispiel #16
0
        private void handleQuickDeletion(SelectionBlueprint <T> blueprint)
        {
            if (blueprint.HandleQuickDeletion())
            {
                return;
            }

            if (!blueprint.IsSelected)
            {
                DeleteItems(new[] { blueprint.Item });
            }
            else
            {
                DeleteSelected();
            }
        }
        internal override bool MouseDownSelectionRequested(SelectionBlueprint <HitObject> blueprint, MouseButtonEvent e)
        {
            if (e.ShiftPressed && e.Button == MouseButton.Left && pivot != null)
            {
                handleRangeSelection(blueprint, e.ControlPressed);
                return(true);
            }

            bool result = base.MouseDownSelectionRequested(blueprint, e);

            // ensure that the object wasn't removed by the base implementation before making it the new pivot.
            if (EditorBeatmap.HitObjects.Contains(blueprint.Item))
            {
                pivot = blueprint.Item;
            }
            return(result);
        }
Beispiel #18
0
        protected override bool OnDoubleClick(DoubleClickEvent e)
        {
            if (e.Button == MouseButton.Right)
            {
                return(false);
            }

            SelectionBlueprint clickedBlueprint = selectionHandler.SelectedBlueprints.FirstOrDefault(b => b.IsHovered);

            if (clickedBlueprint == null)
            {
                return(false);
            }

            adjustableClock?.Seek(clickedBlueprint.HitObject.StartTime);
            return(true);
        }
Beispiel #19
0
        /// <summary>
        /// Attempts to begin the movement of any selected blueprints.
        /// </summary>
        /// <returns>Whether movement began.</returns>
        private bool beginSelectionMovement()
        {
            Debug.Assert(movementBlueprint == null);

            // Any selected blueprint that is hovered can begin the movement of the group, however only the earliest hitobject is used for movement
            // A special case is added for when a click selection occurred before the drag
            if (!clickSelectionBegan && !selectionHandler.SelectedBlueprints.Any(b => b.IsHovered))
            {
                return(false);
            }

            // Movement is tracked from the blueprint of the earliest hitobject, since it only makes sense to distance snap from that hitobject
            movementBlueprint = selectionHandler.SelectedBlueprints.OrderBy(b => b.DrawableObject.HitObject.StartTime).First();
            screenSpaceMovementStartPosition = movementBlueprint.DrawableObject.ToScreenSpace(movementBlueprint.DrawableObject.OriginPosition);

            return(true);
        }
Beispiel #20
0
        /// <summary>
        /// Handle a blueprint requesting selection.
        /// </summary>
        /// <param name="blueprint">The blueprint.</param>
        /// <param name="e">The mouse event responsible for selection.</param>
        /// <returns>Whether a selection was performed.</returns>
        internal virtual bool MouseDownSelectionRequested(SelectionBlueprint <T> blueprint, MouseButtonEvent e)
        {
            if (e.ShiftPressed && e.Button == MouseButton.Right)
            {
                handleQuickDeletion(blueprint);
                return(true);
            }

            // while holding control, we only want to add to selection, not replace an existing selection.
            if (e.ControlPressed && e.Button == MouseButton.Left && !blueprint.IsSelected)
            {
                blueprint.ToggleSelection();
                return(true);
            }

            return(ensureSelected(blueprint));
        }
Beispiel #21
0
        /// <summary>
        /// Attempts to begin the movement of any selected blueprints.
        /// </summary>
        private void prepareSelectionMovement()
        {
            if (!SelectionHandler.SelectedBlueprints.Any())
            {
                return;
            }

            // Any selected blueprint that is hovered can begin the movement of the group, however only the earliest hitobject is used for movement
            // A special case is added for when a click selection occurred before the drag
            if (!clickSelectionBegan && !SelectionHandler.SelectedBlueprints.Any(b => b.IsHovered))
            {
                return;
            }

            // Movement is tracked from the blueprint of the earliest hitobject, since it only makes sense to distance snap from that hitobject
            movementBlueprint = SelectionHandler.SelectedBlueprints.OrderBy(b => b.HitObject.StartTime).First();
            movementBlueprintOriginalPosition = movementBlueprint.ScreenSpaceSelectionPoint; // todo: unsure if correct
        }
        /// <summary>
        /// Handle a blueprint requesting selection.
        /// </summary>
        /// <param name="blueprint">The blueprint.</param>
        /// <param name="e">The mouse event responsible for selection.</param>
        /// <returns>Whether a selection was performed.</returns>
        internal bool HandleSelectionRequested(SelectionBlueprint blueprint, MouseButtonEvent e)
        {
            if (e.ShiftPressed && e.Button == MouseButton.Right)
            {
                handleQuickDeletion(blueprint);
                return(false);
            }

            if (e.ControlPressed && e.Button == MouseButton.Left)
            {
                blueprint.ToggleSelection();
            }
            else
            {
                ensureSelected(blueprint);
            }

            return(true);
        }
Beispiel #23
0
        private void placementChanged(ValueChangedEvent <HitObject> obj)
        {
            if (obj.NewValue == null)
            {
                if (placementBlueprint != null)
                {
                    SelectionBlueprints.Remove(placementBlueprint);
                    placementBlueprint = null;
                }
            }
            else
            {
                placementBlueprint = CreateBlueprintFor(obj.NewValue);

                placementBlueprint.Colour = Color4.MediumPurple;

                SelectionBlueprints.Add(placementBlueprint);
            }
        }
Beispiel #24
0
        protected override bool OnClick(ClickEvent e)
        {
            if (e.Button == MouseButton.Right)
            {
                return(false);
            }

            // store for double-click handling
            clickedBlueprint = SelectionHandler.SelectedBlueprints.FirstOrDefault(b => b.IsHovered);

            // Deselection should only occur if no selected blueprints are hovered
            // A special case for when a blueprint was selected via this click is added since OnClick() may occur outside the hitobject and should not trigger deselection
            if (endClickSelection() || clickedBlueprint != null)
            {
                return(true);
            }

            deselectAll();
            return(true);
        }
        /// <summary>
        /// Handles a request for range selection (triggered when Shift is held down).
        /// </summary>
        /// <param name="blueprint">The blueprint which was clicked in range selection mode.</param>
        /// <param name="cumulative">
        /// Whether the selection should be cumulative.
        /// In cumulative mode, consecutive range selections will shift the pivot (which usually stays fixed for the duration of a range selection)
        /// and will never deselect an object that was previously selected.
        /// </param>
        private void handleRangeSelection(SelectionBlueprint <HitObject> blueprint, bool cumulative)
        {
            var clickedObject = blueprint.Item;

            Debug.Assert(pivot != null);

            double rangeStart = Math.Min(clickedObject.StartTime, pivot.StartTime);
            double rangeEnd   = Math.Max(clickedObject.GetEndTime(), pivot.GetEndTime());

            var newSelection = new HashSet <HitObject>(EditorBeatmap.HitObjects.Where(obj => isInRange(obj, rangeStart, rangeEnd)));

            if (cumulative)
            {
                pivot = clickedObject;
                newSelection.UnionWith(EditorBeatmap.SelectedHitObjects);
            }

            EditorBeatmap.SelectedHitObjects.Clear();
            EditorBeatmap.SelectedHitObjects.AddRange(newSelection);

            bool isInRange(HitObject hitObject, double start, double end)
            => hitObject.StartTime >= start && hitObject.GetEndTime() <= end;
        }
Beispiel #26
0
        /// <summary>
        /// Handle a blueprint requesting selection.
        /// </summary>
        /// <param name="blueprint">The blueprint.</param>
        /// <param name="state">The input state at the point of selection.</param>
        internal void HandleSelectionRequested(SelectionBlueprint blueprint, InputState state)
        {
            if (state.Keyboard.ControlPressed)
            {
                if (blueprint.IsSelected)
                {
                    blueprint.Deselect();
                }
                else
                {
                    blueprint.Select();
                }
            }
            else
            {
                if (blueprint.IsSelected)
                {
                    return;
                }

                DeselectAll?.Invoke();
                blueprint.Select();
            }
        }
Beispiel #27
0
 /// <summary>
 /// Handle a blueprint becoming deselected.
 /// </summary>
 /// <param name="blueprint">The blueprint.</param>
 internal virtual void HandleDeselected(SelectionBlueprint <T> blueprint)
 {
     SelectedItems.Remove(blueprint.Item);
     selectedBlueprints.Remove(blueprint);
 }
Beispiel #28
0
 private void onBlueprintDeselected(SelectionBlueprint blueprint)
 {
     SelectionHandler.HandleDeselected(blueprint);
     SelectionBlueprints.ChangeChildDepth(blueprint, 0);
 }
Beispiel #29
0
 private void onBlueprintDeselected(SelectionBlueprint blueprint)
 {
     selectionHandler.HandleDeselected(blueprint);
     SelectionBlueprints.ChangeChildDepth(blueprint, 0);
     beatmap.SelectedHitObjects.Remove(blueprint.HitObject);
 }
Beispiel #30
0
 private void onBlueprintSelected(SelectionBlueprint blueprint)
 {
     selectionHandler.HandleSelected(blueprint);
     SelectionBlueprints.ChangeChildDepth(blueprint, 1);
     beatmap.SelectedHitObjects.Add(blueprint.HitObject);
 }