Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added options to follow sequencer cursor. #39

Merged
merged 2 commits into from Aug 30, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
18 changes: 18 additions & 0 deletions FamiStudio/FamiStudio.Linux.csproj
Expand Up @@ -505,6 +505,24 @@
<EmbeddedResource Include="Resources\SpeedSmall.png" />
<EmbeddedResource Include="Resources\LoopSmallFill.png" />
<EmbeddedResource Include="Resources\GhostSmall.png" />
<EmbeddedResource Include="Resources\FollowContinuousBoth.png" />
<EmbeddedResource Include="Resources\FollowContinuousPiano.png" />
<EmbeddedResource Include="Resources\FollowContinuousSeq.png" />
<EmbeddedResource Include="Resources\FollowJumpPiano.png" />
<EmbeddedResource Include="Resources\FollowJumpSeq.png" />
<EmbeddedResource Include="Resources\FollowNoneBoth.png" />
<EmbeddedResource Include="Resources\FollowNonePiano.png" />
<EmbeddedResource Include="Resources\FollowNoneSeq.png" />
<EmbeddedResource Include="Resources\FollowJumpBoth.png" />
<EmbeddedResource Include="Resources\FollowContinuousBoth%402x.png" />
<EmbeddedResource Include="Resources\FollowContinuousPiano%402x.png" />
<EmbeddedResource Include="Resources\FollowContinuousSeq%402x.png" />
<EmbeddedResource Include="Resources\FollowJumpBoth%402x.png" />
<EmbeddedResource Include="Resources\FollowJumpPiano%402x.png" />
<EmbeddedResource Include="Resources\FollowJumpSeq%402x.png" />
<EmbeddedResource Include="Resources\FollowNoneBoth%402x.png" />
<EmbeddedResource Include="Resources\FollowNonePiano%402x.png" />
<EmbeddedResource Include="Resources\FollowNoneSeq%402x.png" />
</ItemGroup>
<ItemGroup>
<BootstrapperPackage Include=".NETFramework,Version=v4.6.1">
Expand Down
18 changes: 18 additions & 0 deletions FamiStudio/FamiStudio.Mac.csproj
Expand Up @@ -483,6 +483,24 @@
<EmbeddedResource Include="Resources\SpeedSmall.png" />
<EmbeddedResource Include="Resources\LoopSmallFill.png" />
<EmbeddedResource Include="Resources\GhostSmall.png" />
<EmbeddedResource Include="Resources\FollowContinuousBoth.png" />
<EmbeddedResource Include="Resources\FollowContinuousPiano.png" />
<EmbeddedResource Include="Resources\FollowContinuousSeq.png" />
<EmbeddedResource Include="Resources\FollowJumpPiano.png" />
<EmbeddedResource Include="Resources\FollowJumpSeq.png" />
<EmbeddedResource Include="Resources\FollowNoneBoth.png" />
<EmbeddedResource Include="Resources\FollowNonePiano.png" />
<EmbeddedResource Include="Resources\FollowNoneSeq.png" />
<EmbeddedResource Include="Resources\FollowJumpBoth.png" />
<EmbeddedResource Include="Resources\FollowContinuousBoth%402x.png" />
<EmbeddedResource Include="Resources\FollowContinuousPiano%402x.png" />
<EmbeddedResource Include="Resources\FollowContinuousSeq%402x.png" />
<EmbeddedResource Include="Resources\FollowJumpBoth%402x.png" />
<EmbeddedResource Include="Resources\FollowJumpPiano%402x.png" />
<EmbeddedResource Include="Resources\FollowJumpSeq%402x.png" />
<EmbeddedResource Include="Resources\FollowNoneBoth%402x.png" />
<EmbeddedResource Include="Resources\FollowNonePiano%402x.png" />
<EmbeddedResource Include="Resources\FollowNoneSeq%402x.png" />
</ItemGroup>
<ItemGroup>
<BootstrapperPackage Include=".NETFramework,Version=v4.6.1">
Expand Down
18 changes: 18 additions & 0 deletions FamiStudio/FamiStudio.csproj
Expand Up @@ -526,6 +526,24 @@
<EmbeddedResource Include="Resources\SpeedSmall.png" />
<EmbeddedResource Include="Resources\LoopSmallFill.png" />
<EmbeddedResource Include="Resources\GhostSmall.png" />
<EmbeddedResource Include="Resources\FollowContinuousBoth.png" />
<EmbeddedResource Include="Resources\FollowContinuousPiano.png" />
<EmbeddedResource Include="Resources\FollowContinuousSeq.png" />
<EmbeddedResource Include="Resources\FollowJumpPiano.png" />
<EmbeddedResource Include="Resources\FollowJumpSeq.png" />
<EmbeddedResource Include="Resources\FollowNoneBoth.png" />
<EmbeddedResource Include="Resources\FollowNonePiano.png" />
<EmbeddedResource Include="Resources\FollowNoneSeq.png" />
<EmbeddedResource Include="Resources\FollowJumpBoth.png" />
<EmbeddedResource Include="Resources\FollowContinuousBoth%402x.png" />
<EmbeddedResource Include="Resources\FollowContinuousPiano%402x.png" />
<EmbeddedResource Include="Resources\FollowContinuousSeq%402x.png" />
<EmbeddedResource Include="Resources\FollowJumpBoth%402x.png" />
<EmbeddedResource Include="Resources\FollowJumpPiano%402x.png" />
<EmbeddedResource Include="Resources\FollowJumpSeq%402x.png" />
<EmbeddedResource Include="Resources\FollowNoneBoth%402x.png" />
<EmbeddedResource Include="Resources\FollowNonePiano%402x.png" />
<EmbeddedResource Include="Resources\FollowNoneSeq%402x.png" />
</ItemGroup>
<ItemGroup>
<BootstrapperPackage Include=".NETFramework,Version=v4.6.1">
Expand Down
Binary file added FamiStudio/Resources/FollowContinuousBoth.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added FamiStudio/Resources/FollowContinuousBoth@2x.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added FamiStudio/Resources/FollowContinuousPiano.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added FamiStudio/Resources/FollowContinuousPiano@2x.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added FamiStudio/Resources/FollowContinuousSeq.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added FamiStudio/Resources/FollowContinuousSeq@2x.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added FamiStudio/Resources/FollowJumpBoth.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added FamiStudio/Resources/FollowJumpBoth@2x.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added FamiStudio/Resources/FollowJumpPiano.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added FamiStudio/Resources/FollowJumpPiano@2x.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added FamiStudio/Resources/FollowJumpSeq.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added FamiStudio/Resources/FollowJumpSeq@2x.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added FamiStudio/Resources/FollowNoneBoth.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added FamiStudio/Resources/FollowNoneBoth@2x.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added FamiStudio/Resources/FollowNonePiano.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added FamiStudio/Resources/FollowNonePiano@2x.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added FamiStudio/Resources/FollowNoneSeq.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added FamiStudio/Resources/FollowNoneSeq@2x.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
42 changes: 32 additions & 10 deletions FamiStudio/Source/UI/Common/ConfigDialog.cs
Expand Up @@ -36,6 +36,20 @@ public enum TimeFormat
"MM:SS:mmm"
};

public string[] FollowModeStrings =
{
"None",
"Jump",
"Continuous"
};

public string[] FollowSyncStrings =
{
"Sequencer",
"Piano Roll",
"Both"
};

private PropertyPage[] pages = new PropertyPage[(int)ConfigSection.Max];
private MultiPropertyDialog dialog;

Expand Down Expand Up @@ -74,23 +88,27 @@ private PropertyPage CreatePropertyPage(PropertyPage page, ConfigSection section
var scalingValues = new[] { "System" };
#endif
var scalingIndex = Settings.DpiScaling == 0 ? 0 : Array.IndexOf(scalingValues, $"{Settings.DpiScaling}%");
var timeFormatIndex = Settings.TimeFormat < (int)TimeFormat.Max ? Settings.TimeFormat : 0;
var timeFormatIndex = Settings.TimeFormat < (int)TimeFormat.Max ? Settings.TimeFormat : 0;
var followModeIndex = Settings.FollowMode <= 0 ? 0 : Settings.FollowMode % FollowModeStrings.Length;
var followSyncIndex = Settings.FollowSync <= 0 ? 0 : Settings.FollowSync % FollowSyncStrings.Length;

page.AddStringList("Scaling (Requires restart):", scalingValues, scalingValues[scalingIndex]); // 0
page.AddStringList("Time Format:", TimeFormatStrings, TimeFormatStrings[timeFormatIndex]); // 1
page.AddBoolean("Check for updates:", Settings.CheckUpdates); // 2
page.AddBoolean("Show Piano Roll View Range:", Settings.ShowPianoRollViewRange); // 3
page.AddBoolean("Trackpad controls:", Settings.TrackPadControls); // 4
page.AddStringList("Follow Mode:", FollowModeStrings, FollowModeStrings[followModeIndex]); // 2
page.AddStringList("Following Views:", FollowSyncStrings, FollowSyncStrings[followSyncIndex]); // 3
page.AddBoolean("Check for updates:", Settings.CheckUpdates); // 4
page.AddBoolean("Show Piano Roll View Range:", Settings.ShowPianoRollViewRange); // 5
page.AddBoolean("Trackpad controls:", Settings.TrackPadControls); // 6
#if FAMISTUDIO_MACOS
page.AddBoolean("Reverse trackpad direction:", Settings.ReverseTrackPad); // 5
page.AddBoolean("Reverse trackpad direction:", Settings.ReverseTrackPad); // 7
page.SetPropertyEnabled(4, Settings.TrackPadControls);
page.PropertyChanged += Page_PropertyChanged;
#endif
#if FAMISTUDIO_LINUX
page.SetPropertyEnabled(0, false);
#endif

break;
break;
}
case ConfigSection.Sound:
{
Expand Down Expand Up @@ -150,14 +168,18 @@ public DialogResult ShowDialog()
var pageSound = pages[(int)ConfigSection.Sound];
var scalingString = pageUI.GetPropertyValue<string>(0);
var timeFormatString = pageUI.GetPropertyValue<string>(1);
var followModeString = pageUI.GetPropertyValue<string>(2);
var followSyncString = pageUI.GetPropertyValue<string>(3);

Settings.DpiScaling = scalingString == "System" ? 0 : int.Parse(scalingString.Substring(0, 3));
Settings.TimeFormat = Array.IndexOf(TimeFormatStrings, timeFormatString);
Settings.CheckUpdates = pageUI.GetPropertyValue<bool>(2);
Settings.ShowPianoRollViewRange = pageUI.GetPropertyValue<bool>(3);
Settings.TrackPadControls = pageUI.GetPropertyValue<bool>(4);
Settings.FollowMode = Array.IndexOf(FollowModeStrings, followModeString);
Settings.FollowSync = Array.IndexOf(FollowSyncStrings, followSyncString);
Settings.CheckUpdates = pageUI.GetPropertyValue<bool>(4);
Settings.ShowPianoRollViewRange = pageUI.GetPropertyValue<bool>(5);
Settings.TrackPadControls = pageUI.GetPropertyValue<bool>(6);
#if FAMISTUDIO_MACOS
Settings.ReverseTrackPad = pageUI.GetPropertyValue<bool>(5);
Settings.ReverseTrackPad = pageUI.GetPropertyValue<bool>(7);
#endif

// Sound
Expand Down
32 changes: 32 additions & 0 deletions FamiStudio/Source/UI/Common/PianoRoll.cs
Expand Up @@ -3607,6 +3607,38 @@ public void Tick()
var pt = this.PointToClient(Cursor.Position);
UpdateSelection(pt.X, false);
}

if (App.IsPlaying && (Settings.FollowSync == 1 || Settings.FollowSync == 2))
{
var seekX = App.CurrentFrame * noteSizeX - scrollX;
var minX = 128;
var maxX = Width - whiteKeySizeX;
bool followed = false;
if (Settings.FollowMode == 1)
{
if (seekX < 0)
{
scrollX = (int)seekX + minX;
followed = true;
}
else if (seekX > maxX)
{
scrollX += maxX;
followed = true;
}
}
else if (Settings.FollowMode == 2)
{
followed = true;
scrollX = (int)seekX + scrollX - Width / 2;
}

if (followed)
{
ClampScroll();
ConditionalInvalidate();
}
}
}

private bool GetEffectNoteForCoord(int x, int y, out int patternIdx, out int noteIdx)
Expand Down
32 changes: 31 additions & 1 deletion FamiStudio/Source/UI/Common/Sequencer.cs
@@ -1,4 +1,4 @@
using System;
using System;
using System.Linq;
using System.Drawing;
using System.Collections.Generic;
Expand Down Expand Up @@ -1648,6 +1648,36 @@ public void Tick()
var pt = PointToClient(Cursor.Position);
UpdateSelection(pt.X, false);
}

if (App.IsPlaying && (Settings.FollowSync == 0 || Settings.FollowSync == 2))
{
var seekX = ScaleForZoom(App.CurrentFrame) * RenderTheme.MainWindowScaling - scrollX;
bool followed = false;
if (Settings.FollowMode == 1)
{
if (seekX < 0)
{
scrollX = (int)seekX + trackNameSizeX;
followed = true;
}
else if (seekX > Width - trackNameSizeX)
{
scrollX += Width - trackNameSizeX;
followed = true;
}
}
else if (Settings.FollowMode == 2)
{
followed = true;
scrollX = (int)seekX + scrollX - Width / 2;
}

if (followed)
{
ClampScroll();
ConditionalInvalidate();
}
}
}

public void SongModified()
Expand Down
48 changes: 44 additions & 4 deletions FamiStudio/Source/UI/Common/Toolbar.cs
Expand Up @@ -38,9 +38,10 @@ public class Toolbar : RenderControl
const int ButtonRec = 12;
const int ButtonRewind = 13;
const int ButtonLoop = 14;
const int ButtonMachine = 15;
const int ButtonHelp = 16;
const int ButtonCount = 17;
const int ButtonFollow = 15;
const int ButtonMachine = 16;
const int ButtonHelp = 17;
const int ButtonCount = 18; //should always be last

const int DefaultTimecodePosX = 404;
const int DefaultTimecodePosY = 4;
Expand Down Expand Up @@ -110,6 +111,9 @@ class TooltipSpecialCharacter
RenderBitmap bmpPalToNtsc;
RenderBitmap bmpRec;
RenderBitmap bmpRecRed;
RenderBitmap[] bmpFollowNone;
RenderBitmap[] bmpFollowJump;
RenderBitmap[] bmpFollowContinuous;
Button[] buttons = new Button[ButtonCount];
Dictionary<string, TooltipSpecialCharacter> specialCharacters = new Dictionary<string, TooltipSpecialCharacter>();

Expand All @@ -132,6 +136,17 @@ protected override void OnRenderInitialized(RenderGraphics g)
bmpRec = g.CreateBitmapFromResource("Rec");
bmpRecRed = g.CreateBitmapFromResource("RecRed");

string[] followModes = { "Seq", "Piano", "Both" };
bmpFollowNone = new RenderBitmap[followModes.Length];
bmpFollowJump = new RenderBitmap[followModes.Length];
bmpFollowContinuous = new RenderBitmap[followModes.Length];
for (int i = 0; i < followModes.Length; i++)
{
bmpFollowNone[i] = g.CreateBitmapFromResource("FollowNone" + followModes[i]);
bmpFollowJump[i] = g.CreateBitmapFromResource("FollowJump" + followModes[i]);
bmpFollowContinuous[i] = g.CreateBitmapFromResource("FollowContinuous" + followModes[i]);
}

buttons[ButtonNew] = new Button { X = 4, Y = 4, Bmp = g.CreateBitmapFromResource("File"), Click = OnNew };
buttons[ButtonOpen] = new Button { X = 40, Y = 4, Bmp = g.CreateBitmapFromResource("Open"), Click = OnOpen };
buttons[ButtonSave] = new Button { X = 76, Y = 4, Bmp = g.CreateBitmapFromResource("Save"), Click = OnSave, RightClick = OnSaveAs };
Expand All @@ -147,7 +162,8 @@ protected override void OnRenderInitialized(RenderGraphics g)
buttons[ButtonRec] = new Button { X = 608, Y = 4, GetBitmap = OnRecordGetBitmap, Click = OnRecord };
buttons[ButtonRewind] = new Button { X = 644, Y = 4, Bmp = g.CreateBitmapFromResource("Rewind"), Click = OnRewind };
buttons[ButtonLoop] = new Button { X = 680, Y = 4, Click = OnLoop, GetBitmap = OnLoopGetBitmap };
buttons[ButtonMachine] = new Button { X = 716, Y = 4, Click = OnMachine, GetBitmap = OnMachineGetBitmap, Enabled = OnMachineEnabled };
buttons[ButtonFollow] = new Button { X = 716, Y = 4, Click = OnFollowMode, RightClick = OnFollowSync, GetBitmap = OnFollowGetBitmap };
buttons[ButtonMachine] = new Button { X = 752, Y = 4, Click = OnMachine, GetBitmap = OnMachineGetBitmap, Enabled = OnMachineEnabled };
buttons[ButtonHelp] = new Button { X = 36, Y = 4, Bmp = g.CreateBitmapFromResource("Help"), RightAligned = true, Click = OnHelp };

buttons[ButtonNew].ToolTip = "{MouseLeft} New Project {Ctrl} {N}";
Expand All @@ -165,6 +181,7 @@ protected override void OnRenderInitialized(RenderGraphics g)
buttons[ButtonRewind].ToolTip = "{MouseLeft} Rewind {Home}\nRewind to beginning of current pattern {Ctrl} {Home}";
buttons[ButtonRec].ToolTip = "{MouseLeft} Toggles recording mode {Enter}\nAbort recording {Esc}";
buttons[ButtonLoop].ToolTip = "{MouseLeft} Toggle Loop Mode";
buttons[ButtonFollow].ToolTip = "{MouseLeft} Toggle Follow Mode - {MouseRight} Toggle Window Following";
buttons[ButtonMachine].ToolTip = "{MouseLeft} Toggle between NTSC/PAL playback mode";
buttons[ButtonHelp].ToolTip = "{MouseLeft} Online documentation";

Expand Down Expand Up @@ -416,6 +433,29 @@ private RenderBitmap OnLoopGetBitmap()
return null;
}

private void OnFollowMode()
{
Settings.FollowMode = (Settings.FollowMode + 1) % 3;
}

private void OnFollowSync()
{
Settings.FollowSync = (Settings.FollowSync + 1) % 3;
}

private RenderBitmap OnFollowGetBitmap()
{
RenderBitmap[] arr;
switch (Settings.FollowMode)
{
case 0: arr = bmpFollowNone; break;
case 1: arr = bmpFollowJump; break;
case 2: arr = bmpFollowContinuous; break;
default: return null;
}
return arr[Settings.FollowSync % arr.Length];
}

private void OnMachine()
{
App.PalPlayback = !App.PalPlayback;
Expand Down
6 changes: 6 additions & 0 deletions FamiStudio/Source/Utils/Settings.cs
Expand Up @@ -22,6 +22,8 @@ static class Settings
public static bool ShowPianoRollViewRange = true;
public static bool TrackPadControls = false;
public static bool ReverseTrackPad = false;
public static int FollowMode = 0;
public static int FollowSync = 0;
public static bool ShowTutorial = true;

// Audio section
Expand All @@ -47,6 +49,8 @@ public static void Load()
ShowTutorial = ini.GetBool("UI", "ShowTutorial", true);
DpiScaling = ini.GetInt("UI", "DpiScaling", 0);
TimeFormat = ini.GetInt("UI", "TimeFormat", 0);
FollowMode = ini.GetInt("UI", "FollowMode", 0);
FollowSync = ini.GetInt("UI", "FollowSync", 0);
CheckUpdates = ini.GetBool("UI", "CheckUpdates", true);
ShowPianoRollViewRange = ini.GetBool("UI", "ShowPianoRollViewRange", true);
TrackPadControls = ini.GetBool("UI", "TrackPadControls", false);
Expand Down Expand Up @@ -88,6 +92,8 @@ public static void Save()
ini.SetBool("UI", "ShowTutorial", ShowTutorial);
ini.SetInt("UI", "DpiScaling", DpiScaling);
ini.SetInt("UI", "TimeFormat", TimeFormat);
ini.SetInt("UI", "FollowMode", FollowMode);
ini.SetInt("UI", "FollowSync", FollowSync);
ini.SetBool("UI", "CheckUpdates", CheckUpdates);
ini.SetBool("UI", "ShowPianoRollViewRange", ShowPianoRollViewRange);
ini.SetBool("UI", "TrackPadControls", TrackPadControls);
Expand Down