Example #1
0
        protected override void LoadComplete()
        {
            base.LoadComplete();

            areaOffset.BindTo(handler.AreaOffset);
            areaOffset.BindValueChanged(val =>
            {
                usableAreaContainer.MoveTo(val.NewValue, 100, Easing.OutQuint);
                checkBounds();
            }, true);

            areaSize.BindTo(handler.AreaSize);
            areaSize.BindValueChanged(val =>
            {
                usableAreaContainer.ResizeTo(val.NewValue, 100, Easing.OutQuint);

                int x             = (int)val.NewValue.X;
                int y             = (int)val.NewValue.Y;
                int commonDivider = greatestCommonDivider(x, y);

                usableAreaText.Text = $"{(float)x / commonDivider}:{(float)y / commonDivider}";
                checkBounds();
            }, true);

            rotation.BindTo(handler.Rotation);
            rotation.BindValueChanged(val =>
            {
                usableAreaContainer.RotateTo(val.NewValue, 100, Easing.OutQuint);
                tabletContainer.RotateTo(-val.NewValue, 800, Easing.OutQuint);

                checkBounds();
            }, true);

            tablet.BindTo(handler.Tablet);
            tablet.BindValueChanged(_ => Scheduler.AddOnce(updateTabletDetails));

            updateTabletDetails();
            // initial animation should be instant.
            FinishTransforms(true);
        }
Example #2
0
        private void updateTimingGroup()
        {
            beatLength.UnbindBindings();

            var tcp = selectedGroup.Value?.ControlPoints.OfType <TimingControlPoint>().FirstOrDefault();

            if (tcp == null)
            {
                timingPoint = new TimingControlPoint();
                // During movement of a control point's offset, this clause can be hit momentarily,
                // as moving a control point is implemented by removing it and inserting it at the new time.
                // We don't want to reset the `selectedGroupStartTime` here as we rely on having the
                // last value to update the waveform display below.
                selectedGroupEndTime = beatmap.Value.Track.Length;
                return;
            }

            timingPoint = tcp;
            beatLength.BindTo(timingPoint.BeatLengthBindable);

            double?newStartTime = selectedGroup.Value?.Time;
            double?offsetChange = newStartTime - selectedGroupStartTime;

            var nextGroup = editorBeatmap.ControlPointInfo.TimingPoints
                            .SkipWhile(g => g != tcp)
                            .Skip(1)
                            .FirstOrDefault();

            selectedGroupStartTime = newStartTime ?? 0;
            selectedGroupEndTime   = nextGroup?.Time ?? beatmap.Value.Track.Length;

            if (newStartTime.HasValue && offsetChange.HasValue)
            {
                // The offset of the selected point may have changed.
                // This handles the case the user has locked the view and expects the display to update with this change.
                showFromTime(displayedTime + offsetChange.Value, true);
            }
        }
Example #3
0
        protected override void LoadComplete()
        {
            base.LoadComplete();

            enabled.BindTo(tabletHandler.Enabled);
            enabled.BindValueChanged(_ => Scheduler.AddOnce(updateVisibility));

            rotation.BindTo(tabletHandler.Rotation);

            areaOffset.BindTo(tabletHandler.AreaOffset);
            areaOffset.BindValueChanged(val =>
            {
                offsetX.Value = val.NewValue.X;
                offsetY.Value = val.NewValue.Y;
            }, true);

            offsetX.BindValueChanged(val => areaOffset.Value = new Vector2(val.NewValue, areaOffset.Value.Y));
            offsetY.BindValueChanged(val => areaOffset.Value = new Vector2(areaOffset.Value.X, val.NewValue));

            areaSize.BindTo(tabletHandler.AreaSize);
            areaSize.BindValueChanged(val =>
            {
                sizeX.Value = val.NewValue.X;
                sizeY.Value = val.NewValue.Y;
            }, true);

            sizeX.BindValueChanged(val =>
            {
                areaSize.Value = new Vector2(val.NewValue, areaSize.Value.Y);

                aspectRatioApplication?.Cancel();
                aspectRatioApplication = Schedule(() => applyAspectRatio(sizeX));
            });

            sizeY.BindValueChanged(val =>
            {
                areaSize.Value = new Vector2(areaSize.Value.X, val.NewValue);

                aspectRatioApplication?.Cancel();
                aspectRatioApplication = Schedule(() => applyAspectRatio(sizeY));
            });

            updateAspectRatio();
            aspectRatio.BindValueChanged(aspect =>
            {
                aspectRatioApplication?.Cancel();
                aspectRatioApplication = Schedule(() => forceAspectRatio(aspect.NewValue));
            });

            tablet.BindTo(tabletHandler.Tablet);
            tablet.BindValueChanged(val =>
            {
                Scheduler.AddOnce(updateVisibility);

                var tab = val.NewValue;

                bool tabletFound = tab != null;
                if (!tabletFound)
                {
                    return;
                }

                offsetX.MaxValue = tab.Size.X;
                offsetX.Default  = tab.Size.X / 2;
                sizeX.Default    = sizeX.MaxValue = tab.Size.X;

                offsetY.MaxValue = tab.Size.Y;
                offsetY.Default  = tab.Size.Y / 2;
                sizeY.Default    = sizeY.MaxValue = tab.Size.Y;

                areaSize.Default = new Vector2(sizeX.Default, sizeY.Default);
            }, true);
        }