Skip to content

Commit

Permalink
GUI: selection/scroll improvements
Browse files Browse the repository at this point in the history
now you can scroll left/right by dragging selection to the side edges
  • Loading branch information
tildearrow committed Feb 22, 2025
1 parent f59cb23 commit dd99837
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/gui/cursor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,7 @@ void FurnaceGUI::finishSelection() {
}
selecting=false;
selectingFull=false;
mobilePatSel=false;

if (dragging) {
if (dragSourceX==dragDestinationX && dragSourceY==dragDestinationY && dragSourceXFine==dragDestinationXFine) {
Expand Down
15 changes: 14 additions & 1 deletion src/gui/gui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -569,6 +569,12 @@ void FurnaceGUI::addScroll(int amount) {
haveHitBounds=false;
}

void FurnaceGUI::addScrollX(int amount) {
float lineHeight=(patFont->FontSize+2*dpiScale);
nextAddScrollX=lineHeight*amount;
haveHitBounds=false;
}

void FurnaceGUI::setFileName(String name) {
#ifdef _WIN32
wchar_t ret[4096];
Expand Down Expand Up @@ -3571,14 +3577,20 @@ void FurnaceGUI::pointUp(int x, int y, int button) {
}

void FurnaceGUI::pointMotion(int x, int y, int xrel, int yrel) {
if (selecting) {
if (selecting && (!mobileUI || mobilePatSel)) {
// detect whether we have to scroll
if (y<patWindowPos.y+2.0f*dpiScale) {
addScroll(-1);
}
if (y>patWindowPos.y+patWindowSize.y-2.0f*dpiScale) {
addScroll(1);
}
if (x<patWindowPos.x+(mobileUI?40.0f:4.0f)*dpiScale) {
addScrollX(-1);
}
if (x>patWindowPos.x+patWindowSize.x-(mobileUI?40.0f:4.0f)*dpiScale) {
addScrollX(1);
}
}
if (macroDragActive || macroLoopDragActive || waveDragActive || sampleDragActive || orderScrollLocked) {
int distance=fabs((double)xrel);
Expand Down Expand Up @@ -8546,6 +8558,7 @@ FurnaceGUI::FurnaceGUI():
dragMobileMenu(false),
dragMobileEditButton(false),
wantGrooveListFocus(false),
mobilePatSel(false),
lastAssetType(0),
curWindow(GUI_WINDOW_NOTHING),
nextWindow(GUI_WINDOW_NOTHING),
Expand Down
4 changes: 3 additions & 1 deletion src/gui/gui.h
Original file line number Diff line number Diff line change
Expand Up @@ -2366,6 +2366,7 @@ class FurnaceGUI {
bool selecting, selectingFull, dragging, curNibble, orderNibble, followOrders, followPattern, changeAllOrders, mobileUI;
bool collapseWindow, demandScrollX, fancyPattern, firstFrame, tempoView, waveHex, waveSigned, waveGenVisible, lockLayout, editOptsVisible, latchNibble, nonLatchNibble;
bool keepLoopAlive, keepGrooveAlive, orderScrollLocked, orderScrollTolerance, dragMobileMenu, dragMobileEditButton, wantGrooveListFocus;
bool mobilePatSel;
unsigned char lastAssetType;
FurnaceGUIWindows curWindow, nextWindow, curWindowLast;
std::atomic<FurnaceGUIWindows> curWindowThreadSafe;
Expand Down Expand Up @@ -2517,7 +2518,7 @@ class FurnaceGUI {
int bindSetTarget, bindSetTargetIdx, bindSetPrevValue;
bool bindSetActive, bindSetPending;

float nextScroll, nextAddScroll, orderScroll, orderScrollSlideOrigin;
float nextScroll, nextAddScroll, nextAddScrollX, orderScroll, orderScrollSlideOrigin;

ImVec2 orderScrollRealOrigin;
ImVec2 dragMobileMenuOrigin;
Expand Down Expand Up @@ -3084,6 +3085,7 @@ class FurnaceGUI {
void enableSafeMode();
void updateScroll(int amount);
void addScroll(int amount);
void addScrollX(int amount);
void setFileName(String name);
void runBackupThread();
void pushPartBlend();
Expand Down
11 changes: 11 additions & 0 deletions src/gui/pattern.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@ inline void FurnaceGUI::patternRow(int i, bool isPlaying, float lineHeight, int
if (ImGui::IsItemActive() && CHECK_LONG_HOLD) {
ImGui::InhibitInertialScroll();
NOTIFY_LONG_HOLD;
mobilePatSel=true;
}
ImGui::PopStyleColor();
// for each column
Expand Down Expand Up @@ -210,6 +211,7 @@ inline void FurnaceGUI::patternRow(int i, bool isPlaying, float lineHeight, int
if (ImGui::IsItemActive() && CHECK_LONG_HOLD) {
ImGui::InhibitInertialScroll();
NOTIFY_LONG_HOLD;
mobilePatSel=true;
}
ImGui::PopStyleColor();

Expand Down Expand Up @@ -253,6 +255,7 @@ inline void FurnaceGUI::patternRow(int i, bool isPlaying, float lineHeight, int
if (ImGui::IsItemActive() && CHECK_LONG_HOLD) {
ImGui::InhibitInertialScroll();
NOTIFY_LONG_HOLD;
mobilePatSel=true;
}
ImGui::PopStyleColor();
}
Expand Down Expand Up @@ -290,6 +293,7 @@ inline void FurnaceGUI::patternRow(int i, bool isPlaying, float lineHeight, int
if (ImGui::IsItemActive() && CHECK_LONG_HOLD) {
ImGui::InhibitInertialScroll();
NOTIFY_LONG_HOLD;
mobilePatSel=true;
}
ImGui::PopStyleColor();
}
Expand Down Expand Up @@ -342,6 +346,7 @@ inline void FurnaceGUI::patternRow(int i, bool isPlaying, float lineHeight, int
if (ImGui::IsItemActive() && CHECK_LONG_HOLD) {
ImGui::InhibitInertialScroll();
NOTIFY_LONG_HOLD;
mobilePatSel=true;
}

// effect value
Expand Down Expand Up @@ -371,6 +376,7 @@ inline void FurnaceGUI::patternRow(int i, bool isPlaying, float lineHeight, int
if (ImGui::IsItemActive() && CHECK_LONG_HOLD) {
ImGui::InhibitInertialScroll();
NOTIFY_LONG_HOLD;
mobilePatSel=true;
}
ImGui::PopStyleColor();
}
Expand Down Expand Up @@ -465,6 +471,7 @@ void FurnaceGUI::drawPattern() {
ImGui::SetNextWindowScroll(ImVec2(-1.0f,nextScroll));
nextScroll=-1.0f;
nextAddScroll=0.0f;
nextAddScrollX=0.0f;
}
ImDrawList* tdl=NULL;

Expand All @@ -480,6 +487,10 @@ void FurnaceGUI::drawPattern() {
nextScroll=-1.0f;
nextAddScroll=0.0f;
}
if (nextAddScrollX!=0.0f) {
ImGui::SetScrollX(ImGui::GetScrollX()+nextAddScrollX);
nextAddScrollX=0.0f;
}

ImGui::TableSetupScrollFreeze(1,1);
for (int i=0; i<chans; i++) {
Expand Down

0 comments on commit dd99837

Please sign in to comment.