GUI: add "cursor follows wheel" option

needs testing
This commit is contained in:
tildearrow 2023-07-21 17:25:49 -05:00
parent 2f0f30f2f4
commit d411c9caba
3 changed files with 19 additions and 2 deletions

View file

@ -1521,6 +1521,7 @@ class FurnaceGUI {
int pullDeleteRow; int pullDeleteRow;
int newSongBehavior; int newSongBehavior;
int memUsageUnit; int memUsageUnit;
int cursorFollowsWheel;
unsigned int maxUndoSteps; unsigned int maxUndoSteps;
String mainFontPath; String mainFontPath;
String patFontPath; String patFontPath;
@ -1674,6 +1675,7 @@ class FurnaceGUI {
pullDeleteRow(1), pullDeleteRow(1),
newSongBehavior(0), newSongBehavior(0),
memUsageUnit(1), memUsageUnit(1),
cursorFollowsWheel(0),
maxUndoSteps(100), maxUndoSteps(100),
mainFontPath(""), mainFontPath(""),
patFontPath(""), patFontPath(""),

View file

@ -412,7 +412,7 @@ void FurnaceGUI::drawPattern() {
ImGui::SetNextWindowPos(patWindowPos); ImGui::SetNextWindowPos(patWindowPos);
ImGui::SetNextWindowSize(patWindowSize); ImGui::SetNextWindowSize(patWindowSize);
} }
if (ImGui::Begin("Pattern",&patternOpen,globalWinFlags|(settings.avoidRaisingPattern?ImGuiWindowFlags_NoBringToFrontOnFocus:0))) { if (ImGui::Begin("Pattern",&patternOpen,globalWinFlags|(settings.avoidRaisingPattern?ImGuiWindowFlags_NoBringToFrontOnFocus:0)|(settings.cursorFollowsWheel?ImGuiWindowFlags_NoScrollWithMouse:0))) {
if (!mobileUI) { if (!mobileUI) {
patWindowPos=ImGui::GetWindowPos(); patWindowPos=ImGui::GetWindowPos();
patWindowSize=ImGui::GetWindowSize(); patWindowSize=ImGui::GetWindowSize();
@ -951,9 +951,16 @@ void FurnaceGUI::drawPattern() {
demandScrollX=false; demandScrollX=false;
} }
// cursor follows wheel
if (settings.cursorFollowsWheel && (!e->isPlaying() || !followPattern) && ImGui::IsWindowHovered(ImGuiHoveredFlags_ChildWindows)) {
if (wheelX!=0 || wheelY!=0) {
moveCursor(wheelX,wheelY,false);
}
}
// overflow changes order // overflow changes order
// TODO: this is very unreliable and sometimes it can warp you out of the song // TODO: this is very unreliable and sometimes it can warp you out of the song
if (settings.scrollChangesOrder && (!e->isPlaying() || !followPattern) && ImGui::IsWindowHovered(ImGuiHoveredFlags_ChildWindows)) { if (settings.scrollChangesOrder && (!e->isPlaying() || !followPattern) && ImGui::IsWindowHovered(ImGuiHoveredFlags_ChildWindows) && !settings.cursorFollowsWheel) {
if (wheelY!=0) { if (wheelY!=0) {
if (wheelY>0) { if (wheelY>0) {
if (ImGui::GetScrollY()<=0) { if (ImGui::GetScrollY()<=0) {

View file

@ -587,6 +587,11 @@ void FurnaceGUI::drawSettings() {
settings.cursorMoveNoScroll=cursorMoveNoScrollB; settings.cursorMoveNoScroll=cursorMoveNoScrollB;
} }
bool cursorFollowsWheelB=settings.cursorFollowsWheel;
if (ImGui::Checkbox("Move cursor with scroll wheel",&cursorFollowsWheelB)) {
settings.cursorFollowsWheel=cursorFollowsWheelB;
}
bool doubleClickColumnB=settings.doubleClickColumn; bool doubleClickColumnB=settings.doubleClickColumn;
if (ImGui::Checkbox("Double click selects entire column",&doubleClickColumnB)) { if (ImGui::Checkbox("Double click selects entire column",&doubleClickColumnB)) {
settings.doubleClickColumn=doubleClickColumnB; settings.doubleClickColumn=doubleClickColumnB;
@ -2804,6 +2809,7 @@ void FurnaceGUI::syncSettings() {
settings.pullDeleteRow=e->getConfInt("pullDeleteRow",1); settings.pullDeleteRow=e->getConfInt("pullDeleteRow",1);
settings.newSongBehavior=e->getConfInt("newSongBehavior",0); settings.newSongBehavior=e->getConfInt("newSongBehavior",0);
settings.memUsageUnit=e->getConfInt("memUsageUnit",1); settings.memUsageUnit=e->getConfInt("memUsageUnit",1);
settings.cursorFollowsWheel=e->getConfInt("cursorFollowsWheel",0);
clampSetting(settings.mainFontSize,2,96); clampSetting(settings.mainFontSize,2,96);
clampSetting(settings.patFontSize,2,96); clampSetting(settings.patFontSize,2,96);
@ -2931,6 +2937,7 @@ void FurnaceGUI::syncSettings() {
clampSetting(settings.pullDeleteRow,0,1); clampSetting(settings.pullDeleteRow,0,1);
clampSetting(settings.newSongBehavior,0,1); clampSetting(settings.newSongBehavior,0,1);
clampSetting(settings.memUsageUnit,0,1); clampSetting(settings.memUsageUnit,0,1);
clampSetting(settings.cursorFollowsWheel,0,1);
if (settings.exportLoops<0.0) settings.exportLoops=0.0; if (settings.exportLoops<0.0) settings.exportLoops=0.0;
if (settings.exportFadeOut<0.0) settings.exportFadeOut=0.0; if (settings.exportFadeOut<0.0) settings.exportFadeOut=0.0;
@ -3154,6 +3161,7 @@ void FurnaceGUI::commitSettings() {
e->setConf("pullDeleteRow",settings.pullDeleteRow); e->setConf("pullDeleteRow",settings.pullDeleteRow);
e->setConf("newSongBehavior",settings.newSongBehavior); e->setConf("newSongBehavior",settings.newSongBehavior);
e->setConf("memUsageUnit",settings.memUsageUnit); e->setConf("memUsageUnit",settings.memUsageUnit);
e->setConf("cursorFollowsWheel",settings.cursorFollowsWheel);
// colors // colors
for (int i=0; i<GUI_COLOR_MAX; i++) { for (int i=0; i<GUI_COLOR_MAX; i++) {