GUI: and here is the mobile orders bar

This commit is contained in:
tildearrow 2022-11-30 17:20:04 -05:00
parent 992fefd9d2
commit fa564dbe78
3 changed files with 55 additions and 11 deletions

View file

@ -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),

View file

@ -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<FurnaceGUIWindows> 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;

View file

@ -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 (orderScroll<curOrder) {
orderScroll+=MAX(0.05f,(curOrder-orderScroll)*0.2f);
if (orderScroll>curOrder) orderScroll=curOrder;
WAKE_UP;
} else {
orderScroll-=MAX(0.05f,(orderScroll-curOrder)*0.2f);
if (orderScroll<curOrder) orderScroll=curOrder;
WAKE_UP;
}
}
ImGui::SetNextWindowPos(ImVec2(0.0f,mobileMenuPos*-0.65*canvasH));
ImGui::SetNextWindowSize(ImVec2(canvasW,0.12*canvasW));
if (ImGui::Begin("OrderSel",NULL,globalWinFlags)) {
@ -41,18 +55,33 @@ void FurnaceGUI::drawMobileOrderSel() {
);
ImRect rect=ImRect(minArea,maxArea);
ImGui::ItemSize(size,style.FramePadding.y);
ImU32 col=ImGui::GetColorU32(ImGuiCol_Text);
if (ImGui::ItemAdd(rect,ImGui::GetID("OrderSelW"))) {
String text=fmt::sprintf("%.2X",curOrder);
ImVec2 centerPos=ImLerp(minArea,maxArea,ImVec2(0.5,0.5));
for (int i=0; i<e->curSubSong->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();