diff --git a/src/gui/gui.cpp b/src/gui/gui.cpp index ebd7dafa0..b42345b83 100644 --- a/src/gui/gui.cpp +++ b/src/gui/gui.cpp @@ -2197,6 +2197,11 @@ void FurnaceGUI::processDrags(int dragX, int dragY) { sampleSelEnd=x; } } + if (orderScrollLocked) { + orderScroll=(orderScrollSlideOrigin-dragX)/(40.0*dpiScale); + if (orderScroll<0.0f) orderScroll=0.0f; + if (orderScroll>(float)e->curSubSong->ordersLen-1) orderScroll=e->curSubSong->ordersLen-1; + } } #define checkExtension(x) \ @@ -2906,6 +2911,13 @@ void FurnaceGUI::pointUp(int x, int y, int button) { } } sampleDragActive=false; + if (orderScrollLocked) { + int targetOrder=round(orderScroll); + if (targetOrder<0) targetOrder=0; + if (targetOrder>e->curSubSong->ordersLen-1) targetOrder=e->curSubSong->ordersLen-1; + if (curOrder!=targetOrder) setOrder(targetOrder); + } + orderScrollLocked=false; if (selecting) { if (!selectingFull) cursor=selEnd; finishSelection(); @@ -2929,7 +2941,7 @@ void FurnaceGUI::pointMotion(int x, int y, int xrel, int yrel) { addScroll(1); } } - if (macroDragActive || macroLoopDragActive || waveDragActive || sampleDragActive) { + if (macroDragActive || macroLoopDragActive || waveDragActive || sampleDragActive || orderScrollLocked) { int distance=fabs((double)xrel); if (distance<1) distance=1; float start=x-xrel; @@ -5728,6 +5740,7 @@ FurnaceGUI::FurnaceGUI(): latchNibble(false), nonLatchNibble(false), keepLoopAlive(false), + orderScrollLocked(false), curWindow(GUI_WINDOW_NOTHING), nextWindow(GUI_WINDOW_NOTHING), curWindowLast(GUI_WINDOW_NOTHING), @@ -5816,6 +5829,8 @@ FurnaceGUI::FurnaceGUI(): bindSetPending(false), nextScroll(-1.0f), nextAddScroll(0.0f), + orderScroll(0.0f), + orderScrollSlideOrigin(0.0f), layoutTimeBegin(0), layoutTimeEnd(0), layoutTimeDelta(0), diff --git a/src/gui/gui.h b/src/gui/gui.h index 23da50710..04811e081 100644 --- a/src/gui/gui.h +++ b/src/gui/gui.h @@ -1419,7 +1419,7 @@ class FurnaceGUI { SelectionPoint selStart, selEnd, cursor, cursorDrag, dragStart, dragEnd; bool selecting, selectingFull, dragging, curNibble, orderNibble, followOrders, followPattern, changeAllOrders, mobileUI; bool collapseWindow, demandScrollX, fancyPattern, wantPatName, firstFrame, tempoView, waveHex, waveSigned, waveGenVisible, lockLayout, editOptsVisible, latchNibble, nonLatchNibble; - bool keepLoopAlive; + bool keepLoopAlive, orderScrollLocked; FurnaceGUIWindows curWindow, nextWindow, curWindowLast; std::atomic curWindowThreadSafe; float peak[2]; @@ -1562,7 +1562,7 @@ class FurnaceGUI { int bindSetTarget, bindSetPrevValue; bool bindSetActive, bindSetPending; - float nextScroll, nextAddScroll; + float nextScroll, nextAddScroll, orderScroll, orderScrollSlideOrigin; int layoutTimeBegin, layoutTimeEnd, layoutTimeDelta; int renderTimeBegin, renderTimeEnd, renderTimeDelta; diff --git a/src/gui/orders.cpp b/src/gui/orders.cpp index 73fcb9147..789921167 100644 --- a/src/gui/orders.cpp +++ b/src/gui/orders.cpp @@ -25,6 +25,20 @@ void FurnaceGUI::drawMobileOrderSel() { if (!portrait) return; + if (!orderScrollLocked) { + if (orderScroll>(float)curOrder-0.005f && orderScroll<(float)curOrder+0.005f) { + orderScroll=curOrder; + } else if (orderScrollcurOrder) orderScroll=curOrder; + WAKE_UP; + } else { + orderScroll-=MAX(0.05f,(orderScroll-curOrder)*0.2f); + if (orderScrollcurSubSong->ordersLen; i++) { + ImVec2 pos=centerPos; + ImVec4 color=uiColors[GUI_COLOR_TEXT]; + pos.x+=(i-orderScroll)*40.0*dpiScale; + if (pos.x<-200.0*dpiScale) continue; + if (pos.x>canvasW+200.0*dpiScale) break; + String text=fmt::sprintf("%.2X",i); + float targetSize=size.y-fabs(i-orderScroll)*2.0*dpiScale; + if (targetSize<8.0*dpiScale) targetSize=8.0*dpiScale; + color.w*=MIN(1.0f,targetSize/size.y); - ImVec2 pos=ImLerp(minArea,maxArea,ImVec2(0.5,0.0)); - ImGui::PushFont(bigFont); - ImVec2 textSize=ImGui::CalcTextSize(text.c_str()); - ImGui::PopFont(); + ImGui::PushFont(bigFont); + ImVec2 textSize=ImGui::CalcTextSize(text.c_str()); + ImGui::PopFont(); - pos.x-=textSize.x*0.5*(size.y/textSize.y); + pos.x-=textSize.x*0.5*(targetSize/textSize.y); + pos.y-=targetSize*0.5; - dl->AddText(bigFont,size.y,pos,col,text.c_str()); + dl->AddText(bigFont,targetSize,pos,ImGui::GetColorU32(color),text.c_str()); + } + } + if (ImGui::IsItemClicked()) { + orderScrollSlideOrigin=ImGui::GetMousePos().x+orderScroll*40.0f*dpiScale; + orderScrollLocked=true; } } ImGui::End();