Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Core/Animation/TimeFormat.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ private static int GetBeatTimeTick(double timeInBars, int startCountFrom)

public static string FormatTimeInBars(double timeInBars, int startCountFrom)
{
return $"{GetBeatTimeBar(timeInBars, startCountFrom):0}.{GetBeatTimeBeat(timeInBars, startCountFrom):0}.{GetBeatTimeTick(timeInBars,startCountFrom):0}.";
return $"{GetBeatTimeBar(timeInBars, startCountFrom):0}.{GetBeatTimeBeat(timeInBars, startCountFrom):0}.{GetBeatTimeTick(timeInBars,startCountFrom):0}";
}

public static double ToSeconds(double timeInBars, double bpm)
Expand Down
2 changes: 1 addition & 1 deletion Editor/Gui/Windows/TimeLine/TimeClips/ClipTimingEditor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ private static void DrawContent(LayersArea.LayerContext context)
var labelWidth = 70 * T3Ui.UiScaleFactor;
var width = 70 * T3Ui.UiScaleFactor;

FormInputs.AddSectionSubHeader("Edit clip timing");
FormInputs.AddSectionSubHeader("Edit clip timing (in bars)");

ImGui.NewLine();
ImGui.SameLine(labelWidth);
Expand Down
20 changes: 16 additions & 4 deletions Editor/Gui/Windows/TimeLine/TimeClips/TimeClipItem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -147,10 +147,17 @@ internal static void DrawClip(TimeClip timeClip, ref ClipDrawingAttributes attr)
}

ImGui.PushStyleColor(ImGuiCol.Text, UiColors.TextMuted.Rgba);
ImGui.TextUnformatted($"Visible: {timeClip.TimeRange.Start:0.00} ... {timeClip.TimeRange.End:0.00}");

_timeRangeStart.TimeInBars = timeClip.TimeRange.Start;
_timeRangeEnd.TimeInBars = timeClip.TimeRange.End;
ImGui.TextUnformatted($"Visible: {TimeControls.FormattedTime(_timeRangeStart)} "+
$"... {TimeControls.FormattedTime(_timeRangeEnd)}");
if (timeRemapped)
{
ImGui.TextUnformatted($"Source {timeClip.SourceRange.Start:0.00} ... {timeClip.SourceRange.End:0.00}");
_sourceRangeStart.TimeInBars = timeClip.SourceRange.Start;
_sourceRangeEnd.TimeInBars = timeClip.SourceRange.End;
ImGui.TextUnformatted($"Source: {TimeControls.FormattedTime(_sourceRangeStart)} "+
$"... {TimeControls.FormattedTime(_sourceRangeEnd)}");
}

if (timeStretched)
Expand Down Expand Up @@ -329,8 +336,8 @@ private static void HandleDragging(ClipDrawingAttributes attr, TimeClip timeClip


if (allowSnapping && attr.LayerContext.SnapHandler.TryCheckForSnapping(currentDragTime - _timeWithinDraggedClip,
out var snappedClipStartTime,
attr.LayerContext.TimeCanvas.Scale.X))
out var snappedClipStartTime,
attr.LayerContext.TimeCanvas.Scale.X))
{
currentDragTime = (float)snappedClipStartTime + _timeWithinDraggedClip;
}
Expand Down Expand Up @@ -383,4 +390,9 @@ private static double GetIncrement(double snappedTotalDelta)
private static readonly Vector2 _handleOffset = new(HandleWidth, 0);
private static readonly Color _timeRemappingColor = UiColors.StatusAnimated.Fade(0.5f);
private static float _posPosYOnDragStart;

private static Playback _timeRangeStart = new();
private static Playback _timeRangeEnd = new();
private static Playback _sourceRangeStart = new();
private static Playback _sourceRangeEnd = new();
}
51 changes: 26 additions & 25 deletions Editor/Gui/Windows/TimeLine/TimeControls.cs
Original file line number Diff line number Diff line change
Expand Up @@ -204,31 +204,7 @@ internal static void DrawTimeControls(TimeLineCanvas timeLineCanvas, Instance co

// Current Time
var delta = 0.0;
string formattedTime = "";
switch (UserSettings.Config.TimeDisplayMode)
{
case TimeFormat.TimeDisplayModes.Bars:
formattedTime = TimeFormat.FormatTimeInBars(playback.TimeInBars, 0);
break;

case TimeFormat.TimeDisplayModes.Secs:
var ts = TimeSpan.FromSeconds(playback.TimeInSecs);

formattedTime = ts.Hours > 0
? ts.ToString(@"hh\:mm\:ss\:ff")
: ts.ToString(@"mm\:ss\:ff");
break;

case TimeFormat.TimeDisplayModes.F30:
var frames = playback.TimeInSecs * 30;
formattedTime = $"{frames:0}f ";
break;

case TimeFormat.TimeDisplayModes.F60:
var frames60 = playback.TimeInSecs * 60;
formattedTime = $"{frames60:0}f ";
break;
}
var formattedTime = FormattedTime(playback);

ImGui.PushStyleColor(ImGuiCol.Text, UiColors.TextMuted.Rgba);
if (JogDial(formattedTime, ref delta, new Vector2(StandardWidth, ControlSize.Y)))
Expand Down Expand Up @@ -646,6 +622,31 @@ internal static void DrawTimeControls(TimeLineCanvas timeLineCanvas, Instance co
ImGui.SameLine();
}

public static string FormattedTime(Playback playback)
{
switch (UserSettings.Config.TimeDisplayMode)
{
case TimeFormat.TimeDisplayModes.Bars:
return TimeFormat.FormatTimeInBars(playback.TimeInBars, 0);

case TimeFormat.TimeDisplayModes.Secs:
var ts = TimeSpan.FromSeconds(playback.TimeInSecs);

return ts.Hours > 0
? ts.ToString(@"hh\:mm\:ss\:ff")
: ts.ToString(@"mm\:ss\:ff");

case TimeFormat.TimeDisplayModes.F30:
return $"{playback.TimeInSecs * 30:0}f ";

case TimeFormat.TimeDisplayModes.F60:
return $"{playback.TimeInSecs * 60:0}f ";

default:
return "";
}
}

private static double _lastPlaybackStartTime;
// beat grid optimizations
private static float _lastUiScaleFactor = -1f;
Expand Down
2 changes: 1 addition & 1 deletion Editor/Gui/Windows/TimeLine/TimeLineCanvas.cs
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ private void ScrollToTimeAfterStopped()
var oldScroll = Scroll;
Scroll = new Vector2(0, Scroll.Y);
var posScreen = TransformX((float)Playback.TimeInBars);
// position that playhead in the center of the window
// position that play head in the center of the window
ScrollTarget.X = InverseTransformX(posScreen - WindowSize.X * 0.5f);
// restore old state of scrolling
Scroll = oldScroll;
Expand Down