2025-12-27 18:16:33 -05:00
|
|
|
/**
|
|
|
|
|
* Furnace Tracker - multi-system chiptune tracker
|
|
|
|
|
* Copyright (C) 2021-2025 tildearrow and contributors
|
|
|
|
|
*
|
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
|
* (at your option) any later version.
|
|
|
|
|
*
|
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
|
*
|
|
|
|
|
* You should have received a copy of the GNU General Public License along
|
|
|
|
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
// for suck's fake Clang extension!
|
|
|
|
|
#define _USE_MATH_DEFINES
|
|
|
|
|
#include "gui.h"
|
|
|
|
|
#include "../ta-log.h"
|
|
|
|
|
#include "imgui_internal.h"
|
|
|
|
|
#include "IconsFontAwesome4.h"
|
|
|
|
|
#include "furIcons.h"
|
|
|
|
|
#include "misc/cpp/imgui_stdlib.h"
|
|
|
|
|
#include "guiConst.h"
|
|
|
|
|
#include "../utfutils.h"
|
|
|
|
|
#include <fmt/printf.h>
|
|
|
|
|
|
2025-12-30 15:54:35 -05:00
|
|
|
#define SETUP_ORDER_ALPHA \
|
|
|
|
|
if (ord==curOrder) { \
|
|
|
|
|
ImGui::GetStyle().Alpha=origAlpha; \
|
|
|
|
|
} else { \
|
|
|
|
|
ImGui::GetStyle().Alpha=disabledAlpha; \
|
|
|
|
|
} \
|
|
|
|
|
activeColor=ImGui::GetColorU32(uiColors[GUI_COLOR_PATTERN_ACTIVE]); \
|
|
|
|
|
inactiveColor=ImGui::GetColorU32(uiColors[GUI_COLOR_PATTERN_INACTIVE]); \
|
2026-01-01 22:47:00 -05:00
|
|
|
rowIndexColor=ImGui::GetColorU32(uiColors[GUI_COLOR_PATTERN_ROW_INDEX]);
|
2025-12-30 15:54:35 -05:00
|
|
|
|
2025-12-30 17:26:38 -05:00
|
|
|
// this is ImGui's TABLE_BORDER_SIZE.
|
|
|
|
|
#define PAT_BORDER_SIZE 1.0f
|
|
|
|
|
|
2025-12-30 20:09:30 -05:00
|
|
|
ImVec2 FurnaceGUI::mapSelPoint(const SelectionPoint& s, float lineHeight) {
|
|
|
|
|
return ImVec2(0,0);
|
|
|
|
|
}
|
|
|
|
|
|
2025-12-27 18:16:33 -05:00
|
|
|
void FurnaceGUI::drawPatternNew() {
|
|
|
|
|
if (nextWindow==GUI_WINDOW_PATTERN) {
|
|
|
|
|
patternOpen=true;
|
|
|
|
|
ImGui::SetNextWindowFocus();
|
|
|
|
|
nextWindow=GUI_WINDOW_NOTHING;
|
|
|
|
|
}
|
|
|
|
|
if (!patternOpen) return;
|
|
|
|
|
|
2026-01-02 20:14:49 -05:00
|
|
|
bool inhibitMenu=false;
|
|
|
|
|
|
2025-12-27 18:16:33 -05:00
|
|
|
if (e->isPlaying() && followPattern) {
|
|
|
|
|
if (oldRowChanged || !e->isStepping()) {
|
|
|
|
|
if (e->isStepping()) pendingStepUpdate=1;
|
|
|
|
|
cursor.y=oldRow;
|
|
|
|
|
cursor.order=curOrder;
|
|
|
|
|
if (selStart.xCoarse==selEnd.xCoarse && selStart.xFine==selEnd.xFine && selStart.y==selEnd.y && selStart.order==selEnd.order && !selecting) {
|
|
|
|
|
selStart=cursor;
|
|
|
|
|
selEnd=cursor;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
sel1=selStart;
|
|
|
|
|
sel2=selEnd;
|
|
|
|
|
if (sel2.order<sel1.order) {
|
|
|
|
|
sel2.order^=sel1.order;
|
|
|
|
|
sel1.order^=sel2.order;
|
|
|
|
|
sel2.order^=sel1.order;
|
|
|
|
|
sel2.y^=sel1.y;
|
|
|
|
|
sel1.y^=sel2.y;
|
|
|
|
|
sel2.y^=sel1.y;
|
|
|
|
|
} else if (sel2.order==sel1.order && sel2.y<sel1.y) {
|
|
|
|
|
sel2.y^=sel1.y;
|
|
|
|
|
sel1.y^=sel2.y;
|
|
|
|
|
sel2.y^=sel1.y;
|
|
|
|
|
}
|
|
|
|
|
if (sel2.xCoarse<sel1.xCoarse) {
|
|
|
|
|
sel2.xCoarse^=sel1.xCoarse;
|
|
|
|
|
sel1.xCoarse^=sel2.xCoarse;
|
|
|
|
|
sel2.xCoarse^=sel1.xCoarse;
|
|
|
|
|
|
|
|
|
|
sel2.xFine^=sel1.xFine;
|
|
|
|
|
sel1.xFine^=sel2.xFine;
|
|
|
|
|
sel2.xFine^=sel1.xFine;
|
|
|
|
|
} else if (sel2.xCoarse==sel1.xCoarse && sel2.xFine<sel1.xFine) {
|
|
|
|
|
sel2.xFine^=sel1.xFine;
|
|
|
|
|
sel1.xFine^=sel2.xFine;
|
|
|
|
|
sel2.xFine^=sel1.xFine;
|
|
|
|
|
}
|
|
|
|
|
|
2026-01-02 20:14:49 -05:00
|
|
|
ImVec2 origWinPadding=ImGui::GetStyle().WindowPadding;
|
2025-12-27 18:16:33 -05:00
|
|
|
ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding,ImVec2(0.0f,0.0f));
|
|
|
|
|
if (mobileUI) {
|
|
|
|
|
patWindowPos=(portrait?ImVec2(0.0f,(mobileMenuPos*-0.65*canvasH)+(0.12*canvasW)):ImVec2((0.16*canvasH)+0.5*canvasW*mobileMenuPos,0.0f));
|
|
|
|
|
patWindowSize=(portrait?ImVec2(canvasW,canvasH-(0.16*canvasW)-(0.12*canvasW)-(pianoOpen?(0.4*canvasW):0.0f)):ImVec2(canvasW-(0.16*canvasH),canvasH-(pianoOpen?(0.3*canvasH):0.0f)));
|
|
|
|
|
ImGui::SetNextWindowPos(patWindowPos);
|
|
|
|
|
ImGui::SetNextWindowSize(patWindowSize);
|
|
|
|
|
}
|
2025-12-30 19:02:02 -05:00
|
|
|
|
|
|
|
|
if (e->isPlaying() && followPattern && (!e->isStepping() || pendingStepUpdate)) updateScroll(oldRow);
|
|
|
|
|
if (--pendingStepUpdate<0) pendingStepUpdate=0;
|
|
|
|
|
if (nextScroll>-0.5f) {
|
|
|
|
|
ImGui::SetNextWindowScroll(ImVec2(-1.0f,nextScroll));
|
|
|
|
|
nextScroll=-1.0f;
|
|
|
|
|
nextAddScroll=0.0f;
|
|
|
|
|
nextAddScrollX=0.0f;
|
|
|
|
|
}
|
|
|
|
|
|
2025-12-30 01:45:57 -05:00
|
|
|
if (ImGui::Begin("PatternNew",&patternOpen,globalWinFlags|ImGuiWindowFlags_HorizontalScrollbar|(settings.avoidRaisingPattern?ImGuiWindowFlags_NoBringToFrontOnFocus:0)|((settings.cursorFollowsWheel && !selecting)?ImGuiWindowFlags_NoScrollWithMouse:0),_("Pattern"))) {
|
2025-12-27 18:16:33 -05:00
|
|
|
if (!mobileUI) {
|
|
|
|
|
patWindowPos=ImGui::GetWindowPos();
|
|
|
|
|
patWindowSize=ImGui::GetWindowSize();
|
|
|
|
|
}
|
|
|
|
|
|
2025-12-27 19:47:31 -05:00
|
|
|
ImDrawList* dl=ImGui::GetWindowDrawList();
|
2025-12-31 20:09:47 -05:00
|
|
|
float patFineOffsets[DIV_MAX_COLS];
|
2025-12-27 19:47:31 -05:00
|
|
|
char id[64];
|
2025-12-30 15:54:35 -05:00
|
|
|
int firstOrd=curOrder;
|
2025-12-27 19:47:31 -05:00
|
|
|
int chans=e->getTotalChannelCount();
|
2025-12-30 15:54:35 -05:00
|
|
|
/*
|
2025-12-27 19:47:31 -05:00
|
|
|
int displayChans=0;
|
|
|
|
|
for (int i=0; i<chans; i++) {
|
|
|
|
|
if (e->curSubSong->chanShow[i]) displayChans++;
|
2025-12-30 15:54:35 -05:00
|
|
|
}*/
|
2025-12-27 18:16:33 -05:00
|
|
|
|
|
|
|
|
ImGui::PushFont(patFont);
|
2025-12-27 19:47:31 -05:00
|
|
|
float lineHeight=(ImGui::GetTextLineHeight()+2*dpiScale);
|
2025-12-30 01:45:57 -05:00
|
|
|
dummyRows=(ImGui::GetWindowSize().y/lineHeight)/2;
|
2025-12-30 15:54:35 -05:00
|
|
|
int totalRows=e->curSubSong->patLen+dummyRows*2;
|
2025-12-30 19:02:02 -05:00
|
|
|
int firstRow=-dummyRows+1;
|
2025-12-30 15:54:35 -05:00
|
|
|
while (firstRow<0) {
|
|
|
|
|
firstRow+=e->curSubSong->patLen;
|
|
|
|
|
firstOrd--;
|
|
|
|
|
}
|
2025-12-27 19:47:31 -05:00
|
|
|
|
2026-01-01 17:56:54 -05:00
|
|
|
// calculate sizes
|
2025-12-27 19:47:31 -05:00
|
|
|
// this could be moved somewhere else for performance...
|
|
|
|
|
float oneCharSize=ImGui::CalcTextSize("A").x;
|
|
|
|
|
fourChars=ImVec2(oneCharSize*4.0f,lineHeight);
|
|
|
|
|
threeChars=ImVec2(oneCharSize*3.0f,lineHeight);
|
|
|
|
|
twoChars=ImVec2(oneCharSize*2.0f,lineHeight);
|
|
|
|
|
oneChar=ImVec2(oneCharSize,lineHeight);
|
|
|
|
|
|
|
|
|
|
noteCellSize=threeChars;
|
|
|
|
|
noteCellSize.x+=(float)settings.noteCellSpacing*dpiScale;
|
|
|
|
|
insCellSize=twoChars;
|
|
|
|
|
insCellSize.x+=(float)settings.insCellSpacing*dpiScale;
|
|
|
|
|
volCellSize=twoChars;
|
|
|
|
|
volCellSize.x+=(float)settings.volCellSpacing*dpiScale;
|
|
|
|
|
effectCellSize=twoChars;
|
|
|
|
|
effectCellSize.x+=(float)settings.effectCellSpacing*dpiScale;
|
|
|
|
|
effectValCellSize=twoChars;
|
|
|
|
|
effectValCellSize.x+=(float)settings.effectValCellSpacing*dpiScale;
|
|
|
|
|
|
2025-12-31 20:09:47 -05:00
|
|
|
float cellSizeAccum=0.0f;
|
|
|
|
|
patFineOffsets[DIV_PAT_NOTE]=cellSizeAccum;
|
|
|
|
|
cellSizeAccum+=noteCellSize.x;
|
|
|
|
|
patFineOffsets[DIV_PAT_INS]=cellSizeAccum;
|
|
|
|
|
cellSizeAccum+=insCellSize.x;
|
|
|
|
|
patFineOffsets[DIV_PAT_VOL]=cellSizeAccum;
|
|
|
|
|
cellSizeAccum+=volCellSize.x;
|
|
|
|
|
for (int i=0; i<DIV_MAX_EFFECTS; i++) {
|
|
|
|
|
patFineOffsets[DIV_PAT_FX(i)]=cellSizeAccum;
|
|
|
|
|
cellSizeAccum+=effectCellSize.x;
|
|
|
|
|
patFineOffsets[DIV_PAT_FXVAL(i)]=cellSizeAccum;
|
|
|
|
|
cellSizeAccum+=effectValCellSize.x;
|
|
|
|
|
}
|
|
|
|
|
patFineOffsets[DIV_PAT_FX(DIV_MAX_EFFECTS)]=cellSizeAccum;
|
|
|
|
|
|
2025-12-27 19:47:31 -05:00
|
|
|
ImVec2 top=ImGui::GetCursorScreenPos();
|
2026-01-01 21:04:02 -05:00
|
|
|
ImVec2 topRows=top+ImVec2(ImGui::GetScrollX(),0);
|
2026-01-02 20:14:49 -05:00
|
|
|
ImVec2 topHeaders=top+ImVec2(0,ImGui::GetScrollY());
|
2025-12-27 19:47:31 -05:00
|
|
|
ImVec2 pos=top;
|
|
|
|
|
|
2025-12-30 15:54:35 -05:00
|
|
|
ImVec2 size=ImVec2(0.0f,lineHeight*totalRows);
|
2025-12-27 19:47:31 -05:00
|
|
|
|
|
|
|
|
for (int i=0; i<chans; i++) {
|
2025-12-30 17:26:38 -05:00
|
|
|
patChanX[i]=size.x;
|
|
|
|
|
if (!e->curSubSong->chanShow[i]) {
|
|
|
|
|
continue;
|
|
|
|
|
}
|
2025-12-27 19:47:31 -05:00
|
|
|
int chanVolMax=e->getMaxVolumeChan(i);
|
|
|
|
|
if (chanVolMax<1) chanVolMax=1;
|
|
|
|
|
|
|
|
|
|
float thisChannelSize=noteCellSize.x;
|
|
|
|
|
if (e->curSubSong->chanCollapse[i]<3) thisChannelSize+=insCellSize.x;
|
|
|
|
|
if (e->curSubSong->chanCollapse[i]<2) thisChannelSize+=volCellSize.x;
|
|
|
|
|
if (e->curSubSong->chanCollapse[i]<1) thisChannelSize+=(effectCellSize.x+effectValCellSize.x)*e->curSubSong->pat[i].effectCols;
|
|
|
|
|
|
2025-12-30 01:45:57 -05:00
|
|
|
size.x+=thisChannelSize;
|
2025-12-30 17:26:38 -05:00
|
|
|
size.x+=PAT_BORDER_SIZE;
|
2025-12-30 01:45:57 -05:00
|
|
|
}
|
2025-12-30 17:26:38 -05:00
|
|
|
patChanX[chans]=size.x;
|
|
|
|
|
|
|
|
|
|
size.x+=oneChar.x;
|
2025-12-30 01:45:57 -05:00
|
|
|
|
2026-01-01 17:56:54 -05:00
|
|
|
// add scroll if required
|
|
|
|
|
if (nextAddScroll!=0.0f) {
|
|
|
|
|
float newScroll=ImGui::GetScrollY()+nextAddScroll;
|
|
|
|
|
// wrap around and go to previous/next pattern if we're about to go beyond the view
|
|
|
|
|
if (newScroll<0.0f && curOrder>0) {
|
|
|
|
|
ImGui::SetScrollY(ImGui::GetScrollMaxY()+newScroll);
|
|
|
|
|
if (!e->isPlaying() || !followPattern) setOrder(curOrder-1);
|
|
|
|
|
} else if (newScroll>ImGui::GetScrollMaxY() && curOrder<(e->curSubSong->ordersLen-1)) {
|
|
|
|
|
ImGui::SetScrollY(newScroll-ImGui::GetScrollMaxY());
|
|
|
|
|
if (!e->isPlaying() || !followPattern) setOrder(curOrder+1);
|
|
|
|
|
} else {
|
|
|
|
|
ImGui::SetScrollY(newScroll);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// select in empty space
|
|
|
|
|
if (nextAddScroll>0.0f) {
|
|
|
|
|
updateSelection(selEnd.xCoarse,selEnd.xFine,bottomMostRow,bottomMostOrder);
|
|
|
|
|
} else {
|
|
|
|
|
updateSelection(selEnd.xCoarse,selEnd.xFine,topMostRow,topMostOrder);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
nextScroll=-1.0f;
|
|
|
|
|
nextAddScroll=0.0f;
|
|
|
|
|
}
|
|
|
|
|
if (nextAddScrollX!=0.0f) {
|
|
|
|
|
ImGui::SetScrollX(ImGui::GetScrollX()+nextAddScrollX);
|
|
|
|
|
nextAddScrollX=0.0f;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
topMostOrder=-1;
|
|
|
|
|
topMostRow=-1;
|
|
|
|
|
|
|
|
|
|
// prepare the view
|
2026-01-01 21:04:02 -05:00
|
|
|
ImVec2 sizeRows=ImVec2(threeChars.x+oneChar.x+PAT_BORDER_SIZE,lineHeight*totalRows);
|
|
|
|
|
ImVec2 minAreaRows=topRows;
|
|
|
|
|
ImVec2 maxAreaRows=ImVec2(
|
|
|
|
|
minAreaRows.x+sizeRows.x,
|
|
|
|
|
minAreaRows.y+sizeRows.y
|
|
|
|
|
);
|
|
|
|
|
ImRect rectRows=ImRect(minAreaRows,maxAreaRows);
|
|
|
|
|
|
2026-01-02 20:14:49 -05:00
|
|
|
ImVec2 sizeHeaders=ImVec2(size.x+sizeRows.x,ImGui::GetFrameHeight());
|
|
|
|
|
ImVec2 minAreaHeaders=topHeaders;
|
|
|
|
|
ImVec2 maxAreaHeaders=ImVec2(
|
|
|
|
|
minAreaHeaders.x+sizeHeaders.x,
|
|
|
|
|
minAreaHeaders.y+sizeHeaders.y
|
|
|
|
|
);
|
|
|
|
|
ImRect rectHeaders=ImRect(minAreaHeaders,maxAreaHeaders);
|
|
|
|
|
|
2026-01-01 21:04:02 -05:00
|
|
|
top.x+=sizeRows.x;
|
2026-01-02 20:14:49 -05:00
|
|
|
top.y+=sizeHeaders.y;
|
|
|
|
|
topRows.y+=sizeHeaders.y;
|
2026-01-01 21:04:02 -05:00
|
|
|
|
2025-12-30 01:45:57 -05:00
|
|
|
ImVec2 minArea=top;
|
|
|
|
|
ImVec2 maxArea=ImVec2(
|
|
|
|
|
minArea.x+size.x,
|
|
|
|
|
minArea.y+size.y
|
|
|
|
|
);
|
|
|
|
|
ImRect rect=ImRect(minArea,maxArea);
|
2025-12-30 19:02:02 -05:00
|
|
|
ImRect winRect=ImRect(ImGui::GetWindowPos(),ImGui::GetWindowPos()+ImGui::GetWindowSize());
|
2025-12-30 01:45:57 -05:00
|
|
|
|
2026-01-01 22:47:00 -05:00
|
|
|
ImU32 activeColor=ImGui::GetColorU32(uiColors[GUI_COLOR_PATTERN_ACTIVE]);
|
|
|
|
|
ImU32 inactiveColor=ImGui::GetColorU32(uiColors[GUI_COLOR_PATTERN_INACTIVE]);
|
|
|
|
|
ImU32 rowIndexColor=ImGui::GetColorU32(uiColors[GUI_COLOR_PATTERN_ROW_INDEX]);
|
|
|
|
|
float origAlpha=ImGui::GetStyle().Alpha;
|
|
|
|
|
float disabledAlpha=ImGui::GetStyle().Alpha*ImGui::GetStyle().DisabledAlpha;
|
|
|
|
|
|
2025-12-30 01:45:57 -05:00
|
|
|
// create the view
|
2026-01-02 20:14:49 -05:00
|
|
|
dl->PushClipRect(ImVec2(topRows.x+sizeRows.x,topHeaders.y+sizeHeaders.y),winRect.Max,true);
|
2026-01-01 22:47:00 -05:00
|
|
|
ImGui::SetCursorScreenPos(top);
|
2025-12-30 01:45:57 -05:00
|
|
|
ImGui::ItemSize(size,ImGui::GetStyle().FramePadding.y);
|
2025-12-31 20:09:47 -05:00
|
|
|
if (ImGui::ItemAdd(rect,ImGui::GetID("PatternView1"),NULL,ImGuiItemFlags_AllowOverlap)) {
|
|
|
|
|
// calculate X and Y position of mouse cursor
|
|
|
|
|
SelectionPoint pointer=SelectionPoint(-1,0,-1,-1);
|
2026-01-01 21:04:02 -05:00
|
|
|
ImVec2 pointerPos=ImGui::GetMousePos()-ImVec2(top.x,0);
|
2025-12-31 20:09:47 -05:00
|
|
|
|
|
|
|
|
// special value for row index
|
2026-01-01 21:04:02 -05:00
|
|
|
// TODO: just no. not ever.
|
|
|
|
|
/*
|
2025-12-31 20:09:47 -05:00
|
|
|
if (pointerPos.x>=top.x && pointerPos.x<patChanX[0]) {
|
|
|
|
|
pointer.xCoarse=-2;
|
2026-01-01 21:04:02 -05:00
|
|
|
}*/
|
2025-12-31 20:09:47 -05:00
|
|
|
|
|
|
|
|
for (int i=0; i<chans; i++) {
|
|
|
|
|
if (!e->curSubSong->chanShow[i]) continue;
|
|
|
|
|
if (pointerPos.x>=patChanX[i] && pointerPos.x<patChanX[i+1]) {
|
|
|
|
|
pointer.xCoarse=i;
|
|
|
|
|
|
|
|
|
|
// calculate xFine
|
|
|
|
|
float fineOffset=pointerPos.x-patChanX[i];
|
|
|
|
|
pointer.xFine=0;
|
|
|
|
|
if (fineOffset>=noteCellSize.x && e->curSubSong->chanCollapse[i]<3) {
|
|
|
|
|
pointer.xFine=1;
|
|
|
|
|
fineOffset-=noteCellSize.x;
|
|
|
|
|
|
|
|
|
|
if (fineOffset>=insCellSize.x && e->curSubSong->chanCollapse[i]<2) {
|
|
|
|
|
pointer.xFine=2;
|
|
|
|
|
fineOffset-=insCellSize.x;
|
|
|
|
|
|
|
|
|
|
if (fineOffset>=volCellSize.x && e->curSubSong->chanCollapse[i]<1) {
|
|
|
|
|
pointer.xFine=3;
|
|
|
|
|
fineOffset-=volCellSize.x;
|
|
|
|
|
|
|
|
|
|
for (int k=0; k<e->curPat[i].effectCols; k++) {
|
|
|
|
|
if (fineOffset>=effectCellSize.x) {
|
|
|
|
|
pointer.xFine++;
|
|
|
|
|
fineOffset-=effectCellSize.x;
|
|
|
|
|
if (fineOffset>=effectValCellSize.x) {
|
|
|
|
|
pointer.xFine++;
|
|
|
|
|
fineOffset-=effectValCellSize.x;
|
|
|
|
|
} else {
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (pointer.xFine>2+2*e->curPat[i].effectCols) pointer.xFine=2+2*e->curPat[i].effectCols;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
{
|
|
|
|
|
int ord=firstOrd;
|
|
|
|
|
int row=firstRow;
|
|
|
|
|
pos=top;
|
|
|
|
|
for (int j=0; j<totalRows; j++) {
|
|
|
|
|
if (ord>=0 && ord<e->curSubSong->ordersLen) {
|
|
|
|
|
if (pointerPos.y>=pos.y && pointerPos.y<(pos.y+lineHeight)) {
|
|
|
|
|
pointer.order=ord;
|
|
|
|
|
pointer.y=row;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (++row>=e->curSubSong->patLen) {
|
|
|
|
|
row=0;
|
|
|
|
|
ord++;
|
|
|
|
|
}
|
|
|
|
|
pos.y+=lineHeight;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
String debugText=fmt::sprintf("CURSOR: %d:%d, %d/%d",pointer.xCoarse,pointer.xFine,pointer.order,pointer.y);
|
|
|
|
|
dl->AddText(top+ImGui::GetCurrentWindow()->Scroll,0xffffffff,debugText.c_str());
|
|
|
|
|
|
2026-01-01 21:04:02 -05:00
|
|
|
// row highlights
|
2025-12-30 15:54:35 -05:00
|
|
|
{
|
|
|
|
|
int ord=firstOrd;
|
|
|
|
|
int row=firstRow;
|
2025-12-30 17:26:38 -05:00
|
|
|
bool isPlaying=e->isPlaying();
|
2025-12-31 20:09:47 -05:00
|
|
|
pos=top;
|
2025-12-30 15:54:35 -05:00
|
|
|
SETUP_ORDER_ALPHA;
|
|
|
|
|
for (int j=0; j<totalRows; j++) {
|
|
|
|
|
if (ord>=0 && ord<e->curSubSong->ordersLen) {
|
2026-01-01 21:04:02 -05:00
|
|
|
/*snprintf(id,63,"%3d",row);
|
|
|
|
|
dl->AddText(pos,rowIndexColor,id);*/
|
2025-12-30 17:26:38 -05:00
|
|
|
ImU32 thisRowBg=0;
|
|
|
|
|
if (edit && cursor.y==row && cursor.order==ord && curWindowLast==GUI_WINDOW_PATTERN) {
|
|
|
|
|
if (editClone && !isPatUnique && secondTimer<0.5) {
|
|
|
|
|
thisRowBg=ImGui::GetColorU32(uiColors[GUI_COLOR_EDITING_CLONE]);
|
|
|
|
|
} else {
|
|
|
|
|
thisRowBg=ImGui::GetColorU32(uiColors[GUI_COLOR_EDITING]);
|
|
|
|
|
}
|
|
|
|
|
} else if (isPlaying && oldRow==row && ord==playOrder) {
|
|
|
|
|
thisRowBg=ImGui::GetColorU32(uiColors[GUI_COLOR_PATTERN_PLAY_HEAD]);
|
|
|
|
|
} else if (e->curSubSong->hilightB>0 && !(row%e->curSubSong->hilightB)) {
|
|
|
|
|
thisRowBg=ImGui::GetColorU32(uiColors[GUI_COLOR_PATTERN_HI_2]);
|
|
|
|
|
} else if (e->curSubSong->hilightA>0 && !(row%e->curSubSong->hilightA)) {
|
|
|
|
|
thisRowBg=ImGui::GetColorU32(uiColors[GUI_COLOR_PATTERN_HI_1]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (thisRowBg) {
|
|
|
|
|
dl->AddRectFilled(
|
|
|
|
|
ImVec2(top.x+patChanX[0],pos.y),
|
|
|
|
|
ImVec2(top.x+patChanX[chans],pos.y+lineHeight),
|
|
|
|
|
thisRowBg
|
|
|
|
|
);
|
|
|
|
|
}
|
2025-12-30 15:54:35 -05:00
|
|
|
}
|
|
|
|
|
if (++row>=e->curSubSong->patLen) {
|
|
|
|
|
row=0;
|
|
|
|
|
ord++;
|
|
|
|
|
SETUP_ORDER_ALPHA;
|
|
|
|
|
}
|
|
|
|
|
pos.y+=lineHeight;
|
|
|
|
|
}
|
2025-12-30 01:45:57 -05:00
|
|
|
}
|
|
|
|
|
|
2025-12-30 20:09:30 -05:00
|
|
|
// selection background
|
2025-12-31 20:09:47 -05:00
|
|
|
if (sel1.xCoarse>=0 && sel1.xCoarse<chans &&
|
|
|
|
|
sel2.xCoarse>=0 && sel2.xCoarse<chans) {
|
2025-12-30 20:09:30 -05:00
|
|
|
int ord=firstOrd;
|
|
|
|
|
int row=firstRow;
|
|
|
|
|
int curSelFindStage=0;
|
|
|
|
|
ImRect selRect;
|
2025-12-31 20:09:47 -05:00
|
|
|
pos=top;
|
2025-12-30 20:09:30 -05:00
|
|
|
SETUP_ORDER_ALPHA;
|
|
|
|
|
// we find the selection's Y position.
|
|
|
|
|
for (int j=0; j<totalRows; j++) {
|
|
|
|
|
// stage 1: find selection start
|
|
|
|
|
if (curSelFindStage==0) {
|
|
|
|
|
if (sel1.order==ord && sel1.y==row) {
|
|
|
|
|
selRect.Min.y=pos.y;
|
|
|
|
|
curSelFindStage=1;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
// stage 2: find selection end
|
|
|
|
|
if (curSelFindStage==1) {
|
|
|
|
|
if (sel2.order==ord && sel2.y==row) {
|
|
|
|
|
selRect.Max.y=pos.y+lineHeight;
|
|
|
|
|
curSelFindStage=2;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
// stage 3: draw selection rectangle
|
|
|
|
|
if (curSelFindStage==2) {
|
2025-12-31 20:09:47 -05:00
|
|
|
selRect.Min.x=top.x+patChanX[sel1.xCoarse]+patFineOffsets[sel1.xFine&31];
|
|
|
|
|
selRect.Max.x=top.x+patChanX[sel2.xCoarse]+patFineOffsets[(1+sel2.xFine)&31];
|
2025-12-30 20:09:30 -05:00
|
|
|
dl->AddRectFilled(
|
|
|
|
|
selRect.Min,
|
|
|
|
|
selRect.Max,
|
2025-12-31 20:09:47 -05:00
|
|
|
ImGui::ColorConvertFloat4ToU32(uiColors[GUI_COLOR_PATTERN_SELECTION])
|
2025-12-31 06:38:10 -05:00
|
|
|
);
|
2025-12-30 20:09:30 -05:00
|
|
|
curSelFindStage=3;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (++row>=e->curSubSong->patLen) {
|
|
|
|
|
row=0;
|
|
|
|
|
ord++;
|
|
|
|
|
SETUP_ORDER_ALPHA;
|
|
|
|
|
}
|
|
|
|
|
pos.y+=lineHeight;
|
|
|
|
|
}
|
|
|
|
|
}
|
2025-12-30 19:02:02 -05:00
|
|
|
|
2025-12-31 20:09:47 -05:00
|
|
|
// cursor background
|
|
|
|
|
if (cursor.xCoarse>=0 && cursor.xCoarse<chans) {
|
|
|
|
|
int ord=firstOrd;
|
|
|
|
|
int row=firstRow;
|
|
|
|
|
pos=top;
|
|
|
|
|
SETUP_ORDER_ALPHA;
|
|
|
|
|
for (int j=0; j<totalRows; j++) {
|
|
|
|
|
if (cursor.order==ord && cursor.y==row) {
|
|
|
|
|
dl->AddRectFilled(
|
|
|
|
|
ImVec2(top.x+patChanX[cursor.xCoarse]+patFineOffsets[cursor.xFine&31],pos.y),
|
|
|
|
|
ImVec2(top.x+patChanX[cursor.xCoarse]+patFineOffsets[(1+cursor.xFine)&31],pos.y+lineHeight),
|
|
|
|
|
ImGui::ColorConvertFloat4ToU32(uiColors[GUI_COLOR_PATTERN_CURSOR])
|
|
|
|
|
);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (++row>=e->curSubSong->patLen) {
|
|
|
|
|
row=0;
|
|
|
|
|
ord++;
|
|
|
|
|
SETUP_ORDER_ALPHA;
|
|
|
|
|
}
|
|
|
|
|
pos.y+=lineHeight;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2025-12-30 19:02:02 -05:00
|
|
|
// channels and borders
|
2026-01-01 17:56:54 -05:00
|
|
|
bool isFirstChan=true;
|
2025-12-30 01:45:57 -05:00
|
|
|
for (int i=0; i<chans; i++) {
|
|
|
|
|
if (!e->curSubSong->chanShow[i]) continue;
|
2025-12-30 17:26:38 -05:00
|
|
|
|
|
|
|
|
ImVec2 thisTop=ImVec2(top.x+patChanX[i],top.y);
|
|
|
|
|
pos=thisTop;
|
|
|
|
|
|
2025-12-30 19:02:02 -05:00
|
|
|
// check bounds
|
|
|
|
|
if (thisTop.x>=winRect.Max.x) break;
|
|
|
|
|
if (top.x+patChanX[i+1]<winRect.Min.x) continue;
|
|
|
|
|
|
2025-12-30 17:26:38 -05:00
|
|
|
dl->AddLine(
|
|
|
|
|
ImVec2(thisTop.x-PAT_BORDER_SIZE*0.5,thisTop.y),
|
|
|
|
|
ImVec2(thisTop.x-PAT_BORDER_SIZE*0.5,maxArea.y),
|
|
|
|
|
ImGui::ColorConvertFloat4ToU32(ImGui::GetStyle().Colors[ImGuiCol_TableBorderLight]),
|
|
|
|
|
PAT_BORDER_SIZE
|
|
|
|
|
);
|
|
|
|
|
|
2025-12-30 15:54:35 -05:00
|
|
|
int ord=firstOrd;
|
|
|
|
|
int row=firstRow;
|
2025-12-30 01:45:57 -05:00
|
|
|
int chanVolMax=e->getMaxVolumeChan(i);
|
|
|
|
|
if (chanVolMax<1) chanVolMax=1;
|
|
|
|
|
|
2025-12-30 15:54:35 -05:00
|
|
|
const DivPattern* pat=NULL;
|
|
|
|
|
if (ord>=0 && ord<e->curSubSong->ordersLen) {
|
|
|
|
|
pat=e->curSubSong->pat[i].getPattern(e->curOrders->ord[i][ord],true);
|
|
|
|
|
}
|
2025-12-30 01:45:57 -05:00
|
|
|
|
2025-12-30 15:54:35 -05:00
|
|
|
SETUP_ORDER_ALPHA;
|
|
|
|
|
|
|
|
|
|
// rows
|
|
|
|
|
for (int j=0; j<totalRows; j++) {
|
2025-12-30 19:02:02 -05:00
|
|
|
if (pos.y>=winRect.Max.y) break;
|
2026-01-01 17:56:54 -05:00
|
|
|
if (pat && pos.y+lineHeight>=winRect.Min.y) {
|
|
|
|
|
if (isFirstChan) {
|
|
|
|
|
// set the top-most and bottom-most Y positions
|
|
|
|
|
if (topMostOrder==-1) {
|
|
|
|
|
topMostOrder=ord;
|
|
|
|
|
}
|
|
|
|
|
if (topMostRow==-1) {
|
|
|
|
|
topMostRow=row;
|
|
|
|
|
}
|
|
|
|
|
bottomMostOrder=ord;
|
|
|
|
|
bottomMostRow=row;
|
|
|
|
|
}
|
|
|
|
|
|
2025-12-30 15:54:35 -05:00
|
|
|
// note
|
|
|
|
|
snprintf(id,63,"%.31s",noteName(pat->newData[row][DIV_PAT_NOTE]));
|
|
|
|
|
if (pat->newData[row][DIV_PAT_NOTE]==-1) {
|
|
|
|
|
dl->AddText(pos,inactiveColor,id);
|
2025-12-27 19:47:31 -05:00
|
|
|
} else {
|
2025-12-30 15:54:35 -05:00
|
|
|
dl->AddText(pos,activeColor,id);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// instrument
|
|
|
|
|
if (e->curSubSong->chanCollapse[i]<3) {
|
|
|
|
|
pos.x+=threeChars.x;
|
|
|
|
|
if (pat->newData[row][DIV_PAT_INS]==-1) {
|
|
|
|
|
dl->AddText(pos,inactiveColor,emptyLabel2);
|
2025-12-27 19:47:31 -05:00
|
|
|
} else {
|
2025-12-30 15:54:35 -05:00
|
|
|
snprintf(id,63,"%.2X",pat->newData[row][DIV_PAT_INS]);
|
|
|
|
|
if (pat->newData[row][DIV_PAT_INS]<0 || pat->newData[row][DIV_PAT_INS]>=e->song.insLen) {
|
|
|
|
|
dl->AddText(pos,ImGui::GetColorU32(uiColors[GUI_COLOR_PATTERN_INS_ERROR]),id);
|
2025-12-30 01:45:57 -05:00
|
|
|
} else {
|
2025-12-30 15:54:35 -05:00
|
|
|
DivInstrumentType t=e->song.ins[pat->newData[row][DIV_PAT_INS]]->type;
|
|
|
|
|
if (t!=DIV_INS_AMIGA && t!=e->getPreferInsType(i)) {
|
|
|
|
|
dl->AddText(pos,ImGui::GetColorU32(uiColors[GUI_COLOR_PATTERN_INS_WARN]),id);
|
|
|
|
|
} else {
|
|
|
|
|
dl->AddText(pos,ImGui::GetColorU32(uiColors[GUI_COLOR_PATTERN_INS]),id);
|
|
|
|
|
}
|
2025-12-30 01:45:57 -05:00
|
|
|
}
|
2025-12-27 19:47:31 -05:00
|
|
|
}
|
|
|
|
|
}
|
2025-12-30 01:45:57 -05:00
|
|
|
|
2025-12-30 15:54:35 -05:00
|
|
|
// volume
|
|
|
|
|
if (e->curSubSong->chanCollapse[i]<2) {
|
2025-12-30 01:45:57 -05:00
|
|
|
pos.x+=twoChars.x;
|
2025-12-30 15:54:35 -05:00
|
|
|
if (pat->newData[row][DIV_PAT_VOL]==-1) {
|
2025-12-30 01:45:57 -05:00
|
|
|
dl->AddText(pos,inactiveColor,emptyLabel2);
|
2025-12-27 19:47:31 -05:00
|
|
|
} else {
|
2025-12-30 15:54:35 -05:00
|
|
|
int volColor=(pat->newData[row][DIV_PAT_VOL]*127)/chanVolMax;
|
|
|
|
|
if (volColor>127) volColor=127;
|
|
|
|
|
if (volColor<0) volColor=0;
|
|
|
|
|
snprintf(id,63,"%.2X",pat->newData[row][DIV_PAT_VOL]);
|
|
|
|
|
dl->AddText(pos,ImGui::GetColorU32(volColors[volColor]),id);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// effects
|
|
|
|
|
if (e->curSubSong->chanCollapse[i]<1) {
|
|
|
|
|
for (int k=0; k<e->curPat[i].effectCols; k++) {
|
|
|
|
|
int index=DIV_PAT_FX(k);
|
|
|
|
|
int indexVal=DIV_PAT_FXVAL(k);
|
|
|
|
|
ImU32 effectColor=inactiveColor;
|
|
|
|
|
|
|
|
|
|
// effect
|
|
|
|
|
pos.x+=twoChars.x;
|
|
|
|
|
if (pat->newData[row][index]==-1) {
|
|
|
|
|
dl->AddText(pos,inactiveColor,emptyLabel2);
|
2025-12-27 19:47:31 -05:00
|
|
|
} else {
|
2025-12-30 15:54:35 -05:00
|
|
|
if (pat->newData[row][index]>0xff) {
|
|
|
|
|
snprintf(id,63,"??");
|
|
|
|
|
effectColor=ImGui::GetColorU32(uiColors[GUI_COLOR_PATTERN_EFFECT_INVALID]);
|
2025-12-30 01:45:57 -05:00
|
|
|
} else {
|
2025-12-30 15:54:35 -05:00
|
|
|
const unsigned char data=pat->newData[row][index];
|
|
|
|
|
effectColor=ImGui::GetColorU32(uiColors[fxColors[data]]);
|
|
|
|
|
if (pat->newData[row][index]>=0x10 || settings.oneDigitEffects==0) {
|
|
|
|
|
snprintf(id,63,"%.2X",data);
|
|
|
|
|
} else {
|
|
|
|
|
snprintf(id,63," %.1X",data);
|
|
|
|
|
}
|
2025-12-30 01:45:57 -05:00
|
|
|
}
|
2025-12-30 15:54:35 -05:00
|
|
|
dl->AddText(pos,effectColor,id);
|
2025-12-27 19:47:31 -05:00
|
|
|
}
|
|
|
|
|
|
2025-12-30 15:54:35 -05:00
|
|
|
// effect value
|
|
|
|
|
pos.x+=twoChars.x;
|
|
|
|
|
if (pat->newData[row][indexVal]==-1) {
|
|
|
|
|
dl->AddText(pos,effectColor,emptyLabel2);
|
|
|
|
|
} else {
|
|
|
|
|
snprintf(id,63,"%.2X",pat->newData[row][indexVal]);
|
|
|
|
|
dl->AddText(pos,effectColor,id);
|
|
|
|
|
}
|
2025-12-30 01:45:57 -05:00
|
|
|
}
|
2025-12-27 19:47:31 -05:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2025-12-30 01:45:57 -05:00
|
|
|
// go to next row
|
2025-12-30 15:54:35 -05:00
|
|
|
if (++row>=e->curSubSong->patLen) {
|
|
|
|
|
row=0;
|
|
|
|
|
ord++;
|
|
|
|
|
if (ord>=0 && ord<e->curSubSong->ordersLen) {
|
|
|
|
|
pat=e->curSubSong->pat[i].getPattern(e->curOrders->ord[i][ord],true);
|
|
|
|
|
} else {
|
|
|
|
|
pat=NULL;
|
|
|
|
|
}
|
|
|
|
|
SETUP_ORDER_ALPHA;
|
|
|
|
|
}
|
2025-12-30 17:26:38 -05:00
|
|
|
pos.x=thisTop.x;
|
2025-12-30 01:45:57 -05:00
|
|
|
pos.y+=lineHeight;
|
|
|
|
|
}
|
2026-01-01 17:56:54 -05:00
|
|
|
|
|
|
|
|
isFirstChan=false;
|
2025-12-27 19:47:31 -05:00
|
|
|
}
|
2025-12-30 15:54:35 -05:00
|
|
|
|
2025-12-30 17:26:38 -05:00
|
|
|
dl->AddLine(
|
|
|
|
|
ImVec2(top.x+patChanX[chans]-PAT_BORDER_SIZE*0.5,top.y),
|
|
|
|
|
ImVec2(top.x+patChanX[chans]-PAT_BORDER_SIZE*0.5,maxArea.y),
|
|
|
|
|
ImGui::ColorConvertFloat4ToU32(ImGui::GetStyle().Colors[ImGuiCol_TableBorderLight]),
|
|
|
|
|
PAT_BORDER_SIZE
|
|
|
|
|
);
|
|
|
|
|
|
2025-12-30 15:54:35 -05:00
|
|
|
ImGui::GetStyle().Alpha=origAlpha;
|
2025-12-31 20:09:47 -05:00
|
|
|
|
|
|
|
|
// test for selection
|
2026-01-01 17:56:54 -05:00
|
|
|
if (pointer.xCoarse>=0 && pointer.y>=0 && pointer.order>=0) {
|
|
|
|
|
if (ImGui::IsWindowHovered()) {
|
|
|
|
|
if (ImRect(dl->GetClipRectMin(),dl->GetClipRectMax()).Contains(ImGui::GetMousePos())) {
|
|
|
|
|
dl->AddText(top+ImVec2(0,lineHeight)+ImGui::GetCurrentWindow()->Scroll,0xffffffff,"Hovered!!!!!!!");
|
|
|
|
|
if (ImGui::IsMouseClicked(ImGuiMouseButton_Left)) {
|
|
|
|
|
startSelection(pointer.xCoarse,pointer.xFine,pointer.y,pointer.order);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
updateSelection(pointer.xCoarse,pointer.xFine,pointer.y,pointer.order);
|
|
|
|
|
|
|
|
|
|
if (ImGui::IsMouseDown(ImGuiMouseButton_Left) && CHECK_LONG_HOLD) {
|
|
|
|
|
ImGui::InhibitInertialScroll();
|
|
|
|
|
NOTIFY_LONG_HOLD;
|
|
|
|
|
mobilePatSel=true;
|
|
|
|
|
}
|
|
|
|
|
}
|
2025-12-31 20:09:47 -05:00
|
|
|
}
|
|
|
|
|
}
|
2025-12-27 19:47:31 -05:00
|
|
|
}
|
2026-01-01 22:47:00 -05:00
|
|
|
dl->PopClipRect();
|
2026-01-01 21:04:02 -05:00
|
|
|
|
|
|
|
|
// pattern rows (frozen in place)
|
|
|
|
|
ImGui::SetCursorScreenPos(topRows);
|
2026-01-02 20:14:49 -05:00
|
|
|
dl->PushClipRect(ImVec2(topRows.x+sizeRows.x,topHeaders.y+sizeHeaders.y),winRect.Max,true);
|
2026-01-01 21:04:02 -05:00
|
|
|
ImGui::ItemSize(sizeRows,ImGui::GetStyle().FramePadding.y);
|
|
|
|
|
if (ImGui::ItemAdd(rectRows,ImGui::GetID("PatternRows"),NULL,ImGuiItemFlags_AllowOverlap)) {
|
2026-01-01 22:47:00 -05:00
|
|
|
// pattern rows
|
|
|
|
|
int ord=firstOrd;
|
|
|
|
|
int row=firstRow;
|
|
|
|
|
pos=topRows;
|
|
|
|
|
SETUP_ORDER_ALPHA;
|
|
|
|
|
for (int j=0; j<totalRows; j++) {
|
|
|
|
|
if (ord>=0 && ord<e->curSubSong->ordersLen) {
|
|
|
|
|
snprintf(id,63,"%3d",row);
|
|
|
|
|
dl->AddText(pos,rowIndexColor,id);
|
|
|
|
|
}
|
|
|
|
|
if (++row>=e->curSubSong->patLen) {
|
|
|
|
|
row=0;
|
|
|
|
|
ord++;
|
|
|
|
|
SETUP_ORDER_ALPHA;
|
|
|
|
|
}
|
|
|
|
|
pos.y+=lineHeight;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ImGui::GetStyle().Alpha=origAlpha;
|
|
|
|
|
|
|
|
|
|
dl->AddLine(
|
|
|
|
|
ImVec2(maxAreaRows.x-PAT_BORDER_SIZE*0.5,topRows.y),
|
|
|
|
|
ImVec2(maxAreaRows.x-PAT_BORDER_SIZE*0.5,maxArea.y),
|
|
|
|
|
ImGui::ColorConvertFloat4ToU32(ImGui::GetStyle().Colors[ImGuiCol_TableBorderLight]),
|
|
|
|
|
PAT_BORDER_SIZE
|
|
|
|
|
);
|
2026-01-01 21:04:02 -05:00
|
|
|
}
|
2026-01-02 20:14:49 -05:00
|
|
|
dl->PopClipRect();
|
2026-01-01 21:04:02 -05:00
|
|
|
|
|
|
|
|
// channel headers (frozen in place)
|
2026-01-02 20:14:49 -05:00
|
|
|
ImGui::SetCursorScreenPos(topHeaders);
|
|
|
|
|
ImGui::ItemSize(sizeHeaders,ImGui::GetStyle().FramePadding.y);
|
|
|
|
|
if (ImGui::ItemAdd(rectHeaders,ImGui::GetID("PatternHeaders"),NULL,ImGuiItemFlags_AllowOverlap)) {
|
|
|
|
|
//// THE PREVIOUS MESS.
|
|
|
|
|
char chanID[2048];
|
|
|
|
|
// draw channel headers
|
|
|
|
|
for (int i=0; i<chans; i++) {
|
|
|
|
|
// skip hidden channels
|
|
|
|
|
if (!e->curSubSong->chanShow[i]) continue;
|
|
|
|
|
ImGui::SetCursorScreenPos(ImVec2(topHeaders.x+patChanX[i]+sizeRows.x,topHeaders.y));
|
|
|
|
|
bool displayTooltip=false;
|
|
|
|
|
|
|
|
|
|
// initialize some constants
|
|
|
|
|
bool muted=e->isChannelMuted(i);
|
|
|
|
|
ImVec4 chanHead=muted?uiColors[GUI_COLOR_CHANNEL_MUTED]:channelColor(i);
|
|
|
|
|
ImVec4 chanHeadActive=chanHead;
|
|
|
|
|
ImVec4 chanHeadHover=chanHead;
|
|
|
|
|
ImVec4 chanHeadBase=chanHead;
|
|
|
|
|
|
|
|
|
|
// update key hit
|
|
|
|
|
if (e->keyHit[i]) {
|
|
|
|
|
keyHit1[i]=1.0f;
|
|
|
|
|
|
|
|
|
|
if (chanOscRandomPhase) {
|
|
|
|
|
chanOscChan[i].phaseOff=(float)rand()/(float)RAND_MAX;
|
|
|
|
|
} else {
|
|
|
|
|
chanOscChan[i].phaseOff=0.0f;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (settings.channelFeedbackStyle==1) {
|
|
|
|
|
keyHit[i]=0.2;
|
|
|
|
|
if (!muted) {
|
|
|
|
|
int note=e->getChanState(i)->note+60;
|
|
|
|
|
if (note>=0 && note<180) {
|
|
|
|
|
pianoKeyHit[note].value=1.0;
|
|
|
|
|
pianoKeyHit[note].chan=i;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
e->keyHit[i]=false;
|
|
|
|
|
}
|
|
|
|
|
if (settings.channelFeedbackStyle==2 && e->isRunning()) {
|
|
|
|
|
float amount=((float)(e->getChanState(i)->volume>>8)/(float)e->getMaxVolumeChan(i));
|
|
|
|
|
if (e->getChanState(i)->keyOff) amount=0.0f;
|
|
|
|
|
keyHit[i]=amount*0.2f;
|
|
|
|
|
if (!muted && e->getChanState(i)->keyOn) {
|
|
|
|
|
int note=e->getChanState(i)->note+60;
|
|
|
|
|
if (note>=0 && note<180) {
|
|
|
|
|
pianoKeyHit[note].value=amount;
|
|
|
|
|
pianoKeyHit[note].chan=i;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
} else if (settings.channelFeedbackStyle==3 && e->isRunning()) {
|
|
|
|
|
bool active=e->getChanState(i)->keyOn;
|
|
|
|
|
keyHit[i]=active?0.2f:0.0f;
|
|
|
|
|
if (!muted) {
|
|
|
|
|
int note=e->getChanState(i)->note+60;
|
|
|
|
|
if (note>=0 && note<180) {
|
|
|
|
|
pianoKeyHit[note].value=active?1.0f:0.0f;
|
|
|
|
|
pianoKeyHit[note].chan=i;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
} else if (settings.channelFeedbackStyle==4 && e->isRunning()) {
|
|
|
|
|
float amount=powf(chanOscVol[i],settings.channelFeedbackGamma);
|
|
|
|
|
if (isnan(amount)) amount=0; // how is it nan tho??
|
|
|
|
|
if (e->getChanState(i)->keyOff) amount=0.0f;
|
|
|
|
|
keyHit[i]=amount*0.2f;
|
|
|
|
|
if (!muted && e->getChanState(i)->keyOn) {
|
|
|
|
|
int note=e->getChanState(i)->note+60;
|
|
|
|
|
if (note>=0 && note<180) {
|
|
|
|
|
pianoKeyHit[note].value=amount;
|
|
|
|
|
pianoKeyHit[note].chan=i;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
// set key hit colors
|
|
|
|
|
if (settings.guiColorsBase) {
|
|
|
|
|
chanHead.x*=1.0-keyHit[i]; chanHead.y*=1.0-keyHit[i]; chanHead.z*=1.0-keyHit[i];
|
|
|
|
|
chanHeadActive.x*=0.5; chanHeadActive.y*=0.5; chanHeadActive.z*=0.5;
|
|
|
|
|
chanHeadHover.x*=0.9-keyHit[i]; chanHeadHover.y*=0.9-keyHit[i]; chanHeadHover.z*=0.9-keyHit[i];
|
|
|
|
|
} else {
|
|
|
|
|
chanHead.x*=0.25+keyHit[i]; chanHead.y*=0.25+keyHit[i]; chanHead.z*=0.25+keyHit[i];
|
|
|
|
|
chanHeadActive.x*=0.8; chanHeadActive.y*=0.8; chanHeadActive.z*=0.8;
|
|
|
|
|
chanHeadHover.x*=0.4+keyHit[i]; chanHeadHover.y*=0.4+keyHit[i]; chanHeadHover.z*=0.4+keyHit[i];
|
|
|
|
|
}
|
|
|
|
|
keyHit[i]-=((settings.channelStyle==0)?0.02:0.01)*60.0*ImGui::GetIO().DeltaTime;
|
|
|
|
|
if (keyHit[i]<0) keyHit[i]=0;
|
|
|
|
|
// push colors
|
|
|
|
|
ImGui::PushStyleColor(ImGuiCol_Header,chanHead);
|
|
|
|
|
ImGui::PushStyleColor(ImGuiCol_HeaderActive,chanHeadActive);
|
|
|
|
|
ImGui::PushStyleColor(ImGuiCol_HeaderHovered,chanHeadHover);
|
|
|
|
|
ImGui::PushStyleColor(ImGuiCol_Text,ImGui::GetColorU32(channelTextColor(i)));
|
|
|
|
|
if (settings.channelStyle==0) ImGui::TableSetBgColor(ImGuiTableBgTarget_CellBg,ImGui::GetColorU32(chanHead));
|
|
|
|
|
if (muted) ImGui::PushStyleColor(ImGuiCol_Text,uiColors[GUI_COLOR_CHANNEL_MUTED]);
|
|
|
|
|
if (settings.channelFont==0) ImGui::PushFont(mainFont);
|
|
|
|
|
|
|
|
|
|
// what the hell???
|
|
|
|
|
// we don't need this
|
|
|
|
|
ImGuiWindow* window=ImGui::GetCurrentWindow();
|
|
|
|
|
ImVec2 sizeHeader=ImVec2(
|
|
|
|
|
patChanX[i+1]-patChanX[i],
|
|
|
|
|
lineHeight+1.0f*dpiScale
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
if (settings.channelStyle!=0) {
|
|
|
|
|
sizeHeader.y+=6.0f*dpiScale;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (settings.channelStyle==2) {
|
|
|
|
|
sizeHeader.y+=6.0f*dpiScale;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ImVec2 minAreaHeader=window->DC.CursorPos;
|
|
|
|
|
ImVec2 maxAreaHeader=ImVec2(
|
|
|
|
|
minAreaHeader.x+sizeHeader.x,
|
|
|
|
|
minAreaHeader.y+sizeHeader.y
|
|
|
|
|
);
|
|
|
|
|
ImRect rectHeader=ImRect(minAreaHeader,maxAreaHeader);
|
|
|
|
|
float padding=ImGui::CalcTextSize("A").x;
|
|
|
|
|
|
|
|
|
|
ImVec2 minLabelArea=minAreaHeader;
|
|
|
|
|
ImVec2 maxLabelArea=maxAreaHeader;
|
|
|
|
|
|
|
|
|
|
if (e->curSubSong->chanCollapse[i]) {
|
|
|
|
|
const char* chName=e->getChannelShortName(i);
|
|
|
|
|
if (strlen(chName)>3) {
|
|
|
|
|
snprintf(chanID,2048,"...");
|
|
|
|
|
} else {
|
|
|
|
|
snprintf(chanID,2048,"%s",chName);
|
|
|
|
|
}
|
|
|
|
|
displayTooltip=true;
|
|
|
|
|
} else {
|
|
|
|
|
minLabelArea.x+=padding;
|
|
|
|
|
maxLabelArea.x-=padding;
|
|
|
|
|
if (settings.channelStyle==3) { // split button
|
|
|
|
|
maxLabelArea.x-=ImGui::GetFrameHeightWithSpacing();
|
|
|
|
|
}
|
|
|
|
|
const char* chName=e->getChannelName(i);
|
|
|
|
|
float chNameLimit=maxLabelArea.x-minLabelArea.x;
|
|
|
|
|
if (ImGui::CalcTextSize(chName).x>chNameLimit) {
|
|
|
|
|
String shortChName;
|
|
|
|
|
float totalAdvanced=0.0f;
|
|
|
|
|
float ellipsisSize=ImGui::CalcTextSize("...").x;
|
|
|
|
|
for (const char* j=chName; *j;) {
|
|
|
|
|
signed char l;
|
|
|
|
|
int ch=decodeUTF8((const unsigned char*)j,l);
|
|
|
|
|
|
|
|
|
|
// TODO: eliminate use of GetFontBaked()?
|
|
|
|
|
totalAdvanced+=ImGui::GetFontBaked()->GetCharAdvance(ch);
|
|
|
|
|
if (totalAdvanced>(chNameLimit-ellipsisSize)) break;
|
|
|
|
|
|
|
|
|
|
for (int k=0; k<l; k++) {
|
|
|
|
|
shortChName+=j[k];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
j+=l;
|
|
|
|
|
}
|
|
|
|
|
shortChName+="...";
|
|
|
|
|
snprintf(chanID,2048,"%s",shortChName.c_str());
|
|
|
|
|
displayTooltip=true;
|
|
|
|
|
} else {
|
|
|
|
|
snprintf(chanID,2048,"%s",chName);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (settings.channelTextCenter) {
|
|
|
|
|
minLabelArea.x+=0.5f*(maxLabelArea.x-minLabelArea.x-ImGui::CalcTextSize(chanID).x);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ((!patExtraButtons && !patChannelNames && !patChannelHints) || settings.channelVolStyle!=0) ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing,ImVec2(0.0f,0.0f));
|
|
|
|
|
|
|
|
|
|
ImGui::PushID(2048+i);
|
|
|
|
|
switch (settings.channelStyle) {
|
|
|
|
|
case 0: // classic
|
|
|
|
|
ImGui::ItemSize(sizeHeader,ImGui::GetStyle().FramePadding.y);
|
|
|
|
|
if (ImGui::ItemAdd(rectHeader,ImGui::GetID(chanID))) {
|
|
|
|
|
bool hovered=ImGui::ItemHoverable(rectHeader,ImGui::GetID(chanID),0);
|
|
|
|
|
ImU32 col=(hovered || (mobileUI && ImGui::IsMouseDown(ImGuiMouseButton_Left)))?ImGui::GetColorU32(ImGuiCol_HeaderHovered):ImGui::GetColorU32(ImGuiCol_Header);
|
|
|
|
|
dl->AddRectFilled(rectHeader.Min,rectHeader.Max,col);
|
|
|
|
|
dl->AddTextNoHashHide(ImVec2(minLabelArea.x,rectHeader.Min.y),ImGui::GetColorU32(channelTextColor(i)),chanID);
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case 1: { // line
|
|
|
|
|
ImGui::ItemSize(sizeHeader,ImGui::GetStyle().FramePadding.y);
|
|
|
|
|
if (ImGui::ItemAdd(rectHeader,ImGui::GetID(chanID))) {
|
|
|
|
|
bool hovered=ImGui::ItemHoverable(rectHeader,ImGui::GetID(chanID),0);
|
|
|
|
|
ImU32 fadeCol0=ImGui::GetColorU32(ImVec4(
|
|
|
|
|
chanHeadBase.x,
|
|
|
|
|
chanHeadBase.y,
|
|
|
|
|
chanHeadBase.z,
|
|
|
|
|
(hovered && (!mobileUI || ImGui::IsMouseDown(ImGuiMouseButton_Left)))?0.25f:0.0f
|
|
|
|
|
));
|
|
|
|
|
ImU32 fadeCol=ImGui::GetColorU32(ImVec4(
|
|
|
|
|
chanHeadBase.x,
|
|
|
|
|
chanHeadBase.y,
|
|
|
|
|
chanHeadBase.z,
|
|
|
|
|
(hovered && (!mobileUI || ImGui::IsMouseDown(ImGuiMouseButton_Left)))?0.5f:MIN(1.0f,chanHeadBase.w*keyHit[i]*4.0f)
|
|
|
|
|
));
|
|
|
|
|
dl->AddRectFilledMultiColor(rectHeader.Min,rectHeader.Max,fadeCol0,fadeCol0,fadeCol,fadeCol);
|
|
|
|
|
dl->AddLine(ImVec2(rectHeader.Min.x,rectHeader.Max.y),ImVec2(rectHeader.Max.x,rectHeader.Max.y),ImGui::GetColorU32(chanHeadBase),2.0f*dpiScale);
|
|
|
|
|
dl->AddTextNoHashHide(ImVec2(minLabelArea.x,rectHeader.Min.y+3.0*dpiScale),ImGui::GetColorU32(channelTextColor(i)),chanID);
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
case 2: { // round
|
|
|
|
|
ImGui::ItemSize(sizeHeader,ImGui::GetStyle().FramePadding.y);
|
|
|
|
|
if (ImGui::ItemAdd(rectHeader,ImGui::GetID(chanID))) {
|
|
|
|
|
bool hovered=ImGui::ItemHoverable(rectHeader,ImGui::GetID(chanID),0);
|
|
|
|
|
ImU32 fadeCol0=ImGui::GetColorU32(ImVec4(
|
|
|
|
|
chanHeadBase.x,
|
|
|
|
|
chanHeadBase.y,
|
|
|
|
|
chanHeadBase.z,
|
|
|
|
|
(hovered && (!mobileUI || ImGui::IsMouseDown(ImGuiMouseButton_Left)))?0.5f:MIN(1.0f,0.3f+chanHeadBase.w*keyHit[i]*1.5f)
|
|
|
|
|
));
|
|
|
|
|
ImU32 fadeCol=ImGui::GetColorU32(ImVec4(
|
|
|
|
|
chanHeadBase.x,
|
|
|
|
|
chanHeadBase.y,
|
|
|
|
|
chanHeadBase.z,
|
|
|
|
|
(hovered && (!mobileUI || ImGui::IsMouseDown(ImGuiMouseButton_Left)))?0.3f:MIN(1.0f,0.2f+chanHeadBase.w*keyHit[i]*1.2f)
|
|
|
|
|
));
|
|
|
|
|
ImVec2 rMin=rectHeader.Min;
|
|
|
|
|
ImVec2 rMax=rectHeader.Max;
|
|
|
|
|
rMin.x+=3.0f*dpiScale;
|
|
|
|
|
rMin.y+=6.0f*dpiScale;
|
|
|
|
|
rMax.x-=3.0f*dpiScale;
|
|
|
|
|
rMax.y-=6.0f*dpiScale;
|
|
|
|
|
dl->AddRectFilledMultiColor(rMin,rMax,fadeCol0,fadeCol0,fadeCol,fadeCol,4.0f*dpiScale);
|
|
|
|
|
dl->AddTextNoHashHide(ImVec2(minLabelArea.x,rectHeader.Min.y+6.0*dpiScale),ImGui::GetColorU32(channelTextColor(i)),chanID);
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
case 3: // split button
|
|
|
|
|
ImGui::Dummy(ImVec2(1.0f,2.0f*dpiScale));
|
|
|
|
|
//ImGui::SetCursorPosX(minLabelArea.x);
|
|
|
|
|
ImGui::TextNoHashHide("%s",chanID);
|
|
|
|
|
ImGui::SameLine();
|
|
|
|
|
ImGui::PushFont(mainFont);
|
|
|
|
|
ImGui::SmallButton(muted?ICON_FA_VOLUME_OFF:ICON_FA_VOLUME_UP);
|
|
|
|
|
ImGui::PopFont();
|
|
|
|
|
break;
|
|
|
|
|
case 4: { // square border
|
|
|
|
|
ImGui::ItemSize(sizeHeader,ImGui::GetStyle().FramePadding.y);
|
|
|
|
|
if (ImGui::ItemAdd(rectHeader,ImGui::GetID(chanID))) {
|
|
|
|
|
bool hovered=ImGui::ItemHoverable(rectHeader,ImGui::GetID(chanID),0);
|
|
|
|
|
ImU32 fadeCol=ImGui::GetColorU32(ImVec4(
|
|
|
|
|
chanHeadBase.x,
|
|
|
|
|
chanHeadBase.y,
|
|
|
|
|
chanHeadBase.z,
|
|
|
|
|
(hovered && (!mobileUI || ImGui::IsMouseDown(ImGuiMouseButton_Left)))?1.0f:MIN(1.0f,0.2f+chanHeadBase.w*keyHit[i]*4.0f)
|
|
|
|
|
));
|
|
|
|
|
ImVec2 rMin=rectHeader.Min;
|
|
|
|
|
ImVec2 rMax=rectHeader.Max;
|
|
|
|
|
rMin.x+=2.0f*dpiScale;
|
|
|
|
|
rMin.y+=3.0f*dpiScale;
|
|
|
|
|
rMax.x-=3.0f*dpiScale;
|
|
|
|
|
rMax.y-=3.0f*dpiScale;
|
|
|
|
|
dl->AddRect(rMin,rMax,fadeCol,0.0f,2.0*dpiScale);
|
|
|
|
|
dl->AddTextNoHashHide(ImVec2(minLabelArea.x,rectHeader.Min.y+3.0*dpiScale),ImGui::GetColorU32(channelTextColor(i)),chanID);
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
case 5: { // round border
|
|
|
|
|
ImGui::ItemSize(sizeHeader,ImGui::GetStyle().FramePadding.y);
|
|
|
|
|
if (ImGui::ItemAdd(rectHeader,ImGui::GetID(chanID))) {
|
|
|
|
|
bool hovered=ImGui::ItemHoverable(rectHeader,ImGui::GetID(chanID),0);
|
|
|
|
|
ImU32 fadeCol=ImGui::GetColorU32(ImVec4(
|
|
|
|
|
chanHeadBase.x,
|
|
|
|
|
chanHeadBase.y,
|
|
|
|
|
chanHeadBase.z,
|
|
|
|
|
(hovered && (!mobileUI || ImGui::IsMouseDown(ImGuiMouseButton_Left)))?1.0f:MIN(1.0f,0.2f+chanHeadBase.w*keyHit[i]*4.0f)
|
|
|
|
|
));
|
|
|
|
|
ImVec2 rMin=rectHeader.Min;
|
|
|
|
|
ImVec2 rMax=rectHeader.Max;
|
|
|
|
|
rMin.x+=2.0f*dpiScale;
|
|
|
|
|
rMin.y+=3.0f*dpiScale;
|
|
|
|
|
rMax.x-=3.0f*dpiScale;
|
|
|
|
|
rMax.y-=3.0f*dpiScale;
|
|
|
|
|
dl->AddRect(rMin,rMax,fadeCol,4.0f*dpiScale,ImDrawFlags_RoundCornersAll,2.0*dpiScale);
|
|
|
|
|
dl->AddTextNoHashHide(ImVec2(minLabelArea.x,rectHeader.Min.y+3.0*dpiScale),ImGui::GetColorU32(channelTextColor(i)),chanID);
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
ImGui::PopID();
|
|
|
|
|
|
|
|
|
|
if ((!patExtraButtons && !patChannelNames && !patChannelHints) || settings.channelVolStyle!=0) ImGui::PopStyleVar();
|
|
|
|
|
|
|
|
|
|
if (displayTooltip && ImGui::IsItemHovered() && !mobileUI) {
|
|
|
|
|
ImGui::SetTooltip("%s",e->getChannelName(i));
|
|
|
|
|
}
|
|
|
|
|
if (settings.channelFont==0) ImGui::PopFont();
|
|
|
|
|
if (mobileUI) {
|
|
|
|
|
if (ImGui::IsItemHovered()) {
|
|
|
|
|
if (CHECK_LONG_HOLD) {
|
|
|
|
|
NOTIFY_LONG_HOLD;
|
|
|
|
|
e->toggleSolo(i);
|
|
|
|
|
soloChan=i;
|
|
|
|
|
}
|
|
|
|
|
if (ImGui::IsMouseReleased(ImGuiMouseButton_Left) && !ImGui::WasInertialScroll()) {
|
|
|
|
|
if (soloChan!=i) {
|
|
|
|
|
e->toggleMute(i);
|
|
|
|
|
} else {
|
|
|
|
|
soloChan=-1;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
if (ImGui::IsItemClicked(ImGuiMouseButton_Left)) {
|
|
|
|
|
if (settings.soloAction!=1 && soloTimeout>0 && soloChan==i) {
|
|
|
|
|
e->toggleSolo(i);
|
|
|
|
|
soloTimeout=0;
|
|
|
|
|
} else {
|
|
|
|
|
e->toggleMute(i);
|
|
|
|
|
soloTimeout=settings.doubleClickTime;
|
|
|
|
|
soloChan=i;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (muted) ImGui::PopStyleColor();
|
|
|
|
|
ImGui::PopStyleColor(4);
|
|
|
|
|
if (settings.soloAction!=2 && !mobileUI) if (ImGui::IsItemClicked(ImGuiMouseButton_Right)) {
|
|
|
|
|
inhibitMenu=true;
|
|
|
|
|
e->toggleSolo(i);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (settings.channelStyle==3) {
|
|
|
|
|
ImGui::Dummy(ImVec2(1.0f,2.0f*dpiScale));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// volume bar
|
|
|
|
|
if (settings.channelVolStyle!=0) {
|
|
|
|
|
ImVec2 sizeV=ImVec2(
|
|
|
|
|
patChanX[i+1]-patChanX[i],
|
|
|
|
|
6.0*dpiScale
|
|
|
|
|
);
|
|
|
|
|
ImVec2 minAreaV=window->DC.CursorPos;
|
|
|
|
|
ImVec2 maxAreaV=ImVec2(
|
|
|
|
|
minAreaV.x+sizeV.x,
|
|
|
|
|
minAreaV.y+sizeV.y
|
|
|
|
|
);
|
|
|
|
|
ImRect rectV=ImRect(minAreaV,maxAreaV);
|
|
|
|
|
ImGui::ItemSize(sizeV,ImGui::GetStyle().FramePadding.y);
|
|
|
|
|
if (ImGui::ItemAdd(rectV,ImGui::GetID(chanID))) {
|
|
|
|
|
float xLeft=0.0f;
|
|
|
|
|
float xRight=1.0f;
|
|
|
|
|
|
|
|
|
|
if (e->keyHit[i]) {
|
|
|
|
|
keyHit1[i]=1.0f;
|
|
|
|
|
e->keyHit[i]=false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (e->isRunning()) {
|
|
|
|
|
DivChannelState* cs=e->getChanState(i);
|
|
|
|
|
unsigned short chanPan=e->getChanPan(i);
|
|
|
|
|
float stereoPan=(float)(e->convertPanSplitToLinear(chanPan,8,256)-128)/128.0;
|
|
|
|
|
switch (settings.channelVolStyle) {
|
|
|
|
|
case 1: // simple
|
|
|
|
|
xRight=((float)(cs->volume>>8)/(float)e->getMaxVolumeChan(i))*0.9+(keyHit1[i]*0.1f);
|
|
|
|
|
break;
|
|
|
|
|
case 2: { // stereo
|
|
|
|
|
float amount=((float)(cs->volume>>8)/(float)e->getMaxVolumeChan(i))*0.4+(keyHit1[i]*0.1f);
|
|
|
|
|
xRight=0.5+amount*(1.0+MIN(0.0,stereoPan));
|
|
|
|
|
xLeft=0.5-amount*(1.0-MAX(0.0,stereoPan));
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
case 3: // real
|
|
|
|
|
xRight=chanOscVol[i];
|
|
|
|
|
break;
|
|
|
|
|
case 4: // real (stereo)
|
|
|
|
|
xRight=0.5+chanOscVol[i]*0.5*(1.0+MIN(0.0,stereoPan));
|
|
|
|
|
xLeft=0.5-chanOscVol[i]*0.5*(1.0-MAX(0.0,stereoPan));
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (xLeft<0.0f) xLeft=0.0f;
|
|
|
|
|
if (xLeft>1.0f) xLeft=1.0f;
|
|
|
|
|
if (xRight<0.0f) xRight=0.0f;
|
|
|
|
|
if (xRight>1.0f) xRight=1.0f;
|
|
|
|
|
|
|
|
|
|
dl->AddRectFilled(
|
|
|
|
|
ImLerp(rectV.Min,rectV.Max,ImVec2(xLeft,0.0f)),
|
|
|
|
|
ImLerp(rectV.Min,rectV.Max,ImVec2(xRight,1.0f)),
|
|
|
|
|
ImGui::GetColorU32(chanHeadBase)
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// extra buttons
|
|
|
|
|
if (patExtraButtons) {
|
|
|
|
|
snprintf(chanID,2048,"%c###_HCH%d",e->curSubSong->chanCollapse[i]?'+':'-',i);
|
|
|
|
|
ImGui::SetCursorPosX(ImGui::GetCursorPosX()+4.0f*dpiScale);
|
|
|
|
|
if (ImGui::SmallButton(chanID)) {
|
|
|
|
|
if (e->curSubSong->chanCollapse[i]==0) {
|
|
|
|
|
e->curSubSong->chanCollapse[i]=3;
|
|
|
|
|
} else if (e->curSubSong->chanCollapse[i]>0) {
|
|
|
|
|
e->curSubSong->chanCollapse[i]--;
|
|
|
|
|
}
|
|
|
|
|
finishSelection();
|
|
|
|
|
}
|
|
|
|
|
if (!e->curSubSong->chanCollapse[i]) {
|
|
|
|
|
ImGui::SameLine();
|
|
|
|
|
snprintf(chanID,2048,"<###_LCH%d",i);
|
|
|
|
|
ImGui::BeginDisabled(e->curPat[i].effectCols<=1);
|
|
|
|
|
if (ImGui::SmallButton(chanID)) {
|
|
|
|
|
e->curPat[i].effectCols--;
|
|
|
|
|
if (e->curPat[i].effectCols<1) e->curPat[i].effectCols=1;
|
|
|
|
|
finishSelection();
|
|
|
|
|
}
|
|
|
|
|
ImGui::EndDisabled();
|
|
|
|
|
ImGui::SameLine();
|
|
|
|
|
ImGui::BeginDisabled(e->curPat[i].effectCols>=DIV_MAX_EFFECTS);
|
|
|
|
|
snprintf(chanID,2048,">###_RCH%d",i);
|
|
|
|
|
if (ImGui::SmallButton(chanID)) {
|
|
|
|
|
e->curPat[i].effectCols++;
|
|
|
|
|
if (e->curPat[i].effectCols>DIV_MAX_EFFECTS) e->curPat[i].effectCols=DIV_MAX_EFFECTS;
|
|
|
|
|
finishSelection();
|
|
|
|
|
}
|
|
|
|
|
ImGui::EndDisabled();
|
|
|
|
|
}
|
|
|
|
|
ImGui::Spacing();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (patChannelNames) {
|
|
|
|
|
DivPattern* pat=e->curPat[i].getPattern(e->curOrders->ord[i][curOrder],true);
|
|
|
|
|
ImGui::PushFont(mainFont);
|
|
|
|
|
snprintf(chanID,2048," %s###PatName%d",pat->name.c_str(),i);
|
|
|
|
|
if (ImGui::Selectable(chanID,true,ImGuiSelectableFlags_NoPadWithHalfSpacing,ImVec2(0.0f,lineHeight+1.0f*dpiScale))) {
|
|
|
|
|
editStr(&pat->name);
|
|
|
|
|
}
|
|
|
|
|
ImGui::PopFont();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (patChannelHints) {
|
|
|
|
|
ImGuiWindow* win=ImGui::GetCurrentWindow();
|
|
|
|
|
ImVec2 posMin=win->DC.CursorPos;
|
|
|
|
|
ImGui::Dummy(ImVec2(dpiScale,settings.iconSize*dpiScale));
|
|
|
|
|
ImVec2 posMax=ImVec2(win->WorkRect.Max.x,win->WorkRect.Max.y);
|
|
|
|
|
posMin.y-=ImGui::GetStyle().ItemSpacing.y*0.5;
|
|
|
|
|
ImDrawList* dl=ImGui::GetWindowDrawList();
|
|
|
|
|
ImVec2 iconPos[6];
|
|
|
|
|
DivChannelState* cs=e->getChanState(i);
|
|
|
|
|
if (cs!=NULL) {
|
|
|
|
|
DivChannelModeHints hints=e->getChanModeHints(i);
|
|
|
|
|
if (hints.count>4) hints.count=4;
|
|
|
|
|
int hintCount=3+hints.count;
|
|
|
|
|
|
|
|
|
|
// calculate icon size
|
|
|
|
|
for (int i=0; i<hintCount; i++) {
|
|
|
|
|
iconPos[i]=ImLerp(posMin,posMax,ImVec2((float)(2*i+1)/(float)(hintCount*2),0.0f));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 1. ON/OFF
|
|
|
|
|
ImVec4 onOffColor;
|
|
|
|
|
if (cs->keyOn) {
|
|
|
|
|
if (cs->releasing) {
|
|
|
|
|
onOffColor=uiColors[GUI_COLOR_PATTERN_STATUS_REL_ON];
|
|
|
|
|
} else {
|
|
|
|
|
onOffColor=uiColors[GUI_COLOR_PATTERN_STATUS_ON];
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
if (cs->releasing) {
|
|
|
|
|
onOffColor=uiColors[GUI_COLOR_PATTERN_STATUS_REL];
|
|
|
|
|
} else {
|
|
|
|
|
onOffColor=uiColors[GUI_COLOR_PATTERN_STATUS_OFF];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
iconPos[0].x-=mainFont->CalcTextSizeA(MAIN_FONT_SIZE,FLT_MAX,0.0f,ICON_FA_SQUARE).x*0.5f;
|
|
|
|
|
dl->AddText(mainFont,settings.mainFontSize*dpiScale,iconPos[0],ImGui::GetColorU32(onOffColor),ICON_FA_SQUARE);
|
|
|
|
|
|
|
|
|
|
// 2. PITCH SLIDE/VIBRATO
|
|
|
|
|
ImVec4 pitchColor;
|
|
|
|
|
const char* pitchIcon=ICON_FUR_SINE;
|
|
|
|
|
if (cs->inPorta) {
|
|
|
|
|
pitchIcon=ICON_FA_SHARE;
|
|
|
|
|
pitchColor=uiColors[GUI_COLOR_PATTERN_STATUS_PITCH];
|
|
|
|
|
} else if (cs->portaSpeed>0) {
|
|
|
|
|
if (cs->portaNote>=60) {
|
|
|
|
|
pitchIcon=ICON_FA_CHEVRON_UP;
|
|
|
|
|
} else {
|
|
|
|
|
pitchIcon=ICON_FA_CHEVRON_DOWN;
|
|
|
|
|
}
|
|
|
|
|
pitchColor=uiColors[GUI_COLOR_PATTERN_STATUS_PITCH];
|
|
|
|
|
} else if (cs->vibratoDepth>0) {
|
|
|
|
|
pitchIcon=ICON_FUR_SINE;
|
|
|
|
|
pitchColor=uiColors[GUI_COLOR_PATTERN_STATUS_PITCH];
|
|
|
|
|
} else if (cs->arp) {
|
|
|
|
|
pitchIcon=ICON_FA_BARS;
|
|
|
|
|
pitchColor=uiColors[GUI_COLOR_PATTERN_STATUS_NOTE];
|
|
|
|
|
} else {
|
|
|
|
|
pitchColor=uiColors[GUI_COLOR_PATTERN_STATUS_OFF];
|
|
|
|
|
}
|
|
|
|
|
iconPos[1].x-=mainFont->CalcTextSizeA(MAIN_FONT_SIZE,FLT_MAX,0.0f,pitchIcon).x*0.5f;
|
|
|
|
|
dl->AddText(mainFont,settings.mainFontSize*dpiScale,iconPos[1],ImGui::GetColorU32(pitchColor),pitchIcon);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 3. VOLUME
|
|
|
|
|
ImVec4 volColor;
|
|
|
|
|
const char* volIcon=ICON_FA_MINUS;
|
|
|
|
|
if (cs->tremoloDepth>0) {
|
|
|
|
|
volIcon=ICON_FUR_SINE;
|
|
|
|
|
volColor=uiColors[GUI_COLOR_PATTERN_STATUS_VOLUME];
|
|
|
|
|
} else if (cs->volSpeed) {
|
|
|
|
|
if (cs->volSpeed>0) {
|
|
|
|
|
volIcon=ICON_FA_CHEVRON_UP;
|
|
|
|
|
} else {
|
|
|
|
|
volIcon=ICON_FA_CHEVRON_DOWN;
|
|
|
|
|
}
|
|
|
|
|
volColor=uiColors[GUI_COLOR_PATTERN_STATUS_VOLUME];
|
|
|
|
|
} else {
|
|
|
|
|
volColor=uiColors[GUI_COLOR_PATTERN_STATUS_OFF];
|
|
|
|
|
}
|
|
|
|
|
iconPos[2].x-=mainFont->CalcTextSizeA(MAIN_FONT_SIZE,FLT_MAX,0.0f,volIcon).x*0.5f;
|
|
|
|
|
dl->AddText(mainFont,settings.mainFontSize*dpiScale,iconPos[2],ImGui::GetColorU32(volColor),volIcon);
|
|
|
|
|
|
|
|
|
|
// 4. OTHER
|
|
|
|
|
for (int i=0; i<hints.count; i++) {
|
|
|
|
|
if (hints.hint[i]==NULL) continue;
|
|
|
|
|
ImVec4 hintColor=uiColors[GUI_COLOR_PATTERN_STATUS_OFF];
|
|
|
|
|
switch (hints.type[i]) {
|
|
|
|
|
case 0:
|
|
|
|
|
hintColor=uiColors[GUI_COLOR_PATTERN_STATUS_OFF];
|
|
|
|
|
break;
|
|
|
|
|
case 1:
|
|
|
|
|
hintColor=uiColors[GUI_COLOR_PATTERN_STATUS_VOLUME];
|
|
|
|
|
break;
|
|
|
|
|
case 2:
|
|
|
|
|
hintColor=uiColors[GUI_COLOR_PATTERN_STATUS_PITCH];
|
|
|
|
|
break;
|
|
|
|
|
case 3:
|
|
|
|
|
hintColor=uiColors[GUI_COLOR_PATTERN_STATUS_PANNING];
|
|
|
|
|
break;
|
|
|
|
|
case 4:
|
|
|
|
|
hintColor=uiColors[GUI_COLOR_PATTERN_STATUS_SYS1];
|
|
|
|
|
break;
|
|
|
|
|
case 5:
|
|
|
|
|
hintColor=uiColors[GUI_COLOR_PATTERN_STATUS_SYS2];
|
|
|
|
|
break;
|
|
|
|
|
case 6:
|
|
|
|
|
hintColor=uiColors[GUI_COLOR_PATTERN_STATUS_MIXING];
|
|
|
|
|
break;
|
|
|
|
|
case 7:
|
|
|
|
|
hintColor=uiColors[GUI_COLOR_PATTERN_STATUS_DSP];
|
|
|
|
|
break;
|
|
|
|
|
case 8:
|
|
|
|
|
hintColor=uiColors[GUI_COLOR_PATTERN_STATUS_NOTE];
|
|
|
|
|
break;
|
|
|
|
|
case 9:
|
|
|
|
|
hintColor=uiColors[GUI_COLOR_PATTERN_STATUS_MISC1];
|
|
|
|
|
break;
|
|
|
|
|
case 10:
|
|
|
|
|
hintColor=uiColors[GUI_COLOR_PATTERN_STATUS_MISC2];
|
|
|
|
|
break;
|
|
|
|
|
case 11:
|
|
|
|
|
hintColor=uiColors[GUI_COLOR_PATTERN_STATUS_MISC3];
|
|
|
|
|
break;
|
|
|
|
|
case 12:
|
|
|
|
|
hintColor=uiColors[GUI_COLOR_PATTERN_STATUS_ATTACK];
|
|
|
|
|
break;
|
|
|
|
|
case 13:
|
|
|
|
|
hintColor=uiColors[GUI_COLOR_PATTERN_STATUS_DECAY];
|
|
|
|
|
break;
|
|
|
|
|
case 14:
|
|
|
|
|
hintColor=uiColors[GUI_COLOR_PATTERN_STATUS_SUSTAIN];
|
|
|
|
|
break;
|
|
|
|
|
case 15:
|
|
|
|
|
hintColor=uiColors[GUI_COLOR_PATTERN_STATUS_RELEASE];
|
|
|
|
|
break;
|
|
|
|
|
case 16:
|
|
|
|
|
hintColor=uiColors[GUI_COLOR_PATTERN_STATUS_DEC_LINEAR];
|
|
|
|
|
break;
|
|
|
|
|
case 17:
|
|
|
|
|
hintColor=uiColors[GUI_COLOR_PATTERN_STATUS_DEC_EXP];
|
|
|
|
|
break;
|
|
|
|
|
case 18:
|
|
|
|
|
hintColor=uiColors[GUI_COLOR_PATTERN_STATUS_INC];
|
|
|
|
|
break;
|
|
|
|
|
case 19:
|
|
|
|
|
hintColor=uiColors[GUI_COLOR_PATTERN_STATUS_BENT];
|
|
|
|
|
break;
|
|
|
|
|
case 20:
|
|
|
|
|
hintColor=uiColors[GUI_COLOR_PATTERN_STATUS_DIRECT];
|
|
|
|
|
break;
|
|
|
|
|
case 21:
|
|
|
|
|
hintColor=uiColors[GUI_COLOR_PATTERN_STATUS_WARNING];
|
|
|
|
|
break;
|
|
|
|
|
case 22:
|
|
|
|
|
hintColor=uiColors[GUI_COLOR_PATTERN_STATUS_ERROR];
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
hintColor=uiColors[GUI_COLOR_TEXT];
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
iconPos[i+3].x-=mainFont->CalcTextSizeA(MAIN_FONT_SIZE,FLT_MAX,0.0f,hints.hint[i]).x*0.5f;
|
|
|
|
|
dl->AddText(mainFont,settings.mainFontSize*dpiScale,iconPos[i+3],ImGui::GetColorU32(hintColor),hints.hint[i]);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
//chanHeadBottom=ImGui::GetCursorScreenPos().y-ImGui::GetStyle().ItemSpacing.y;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//lastPatternWidth=ImGui::GetCursorPosX()-lpwStart+ImGui::GetStyle().ScrollbarSize;
|
|
|
|
|
/*if (e->hasExtValue()) {
|
|
|
|
|
ImGui::TextColored(uiColors[GUI_COLOR_EE_VALUE]," %.2X",e->getExtValue());
|
|
|
|
|
}*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//// NEW CODE.
|
|
|
|
|
for (int i=0; i<chans; i++) {
|
|
|
|
|
if (!e->curSubSong->chanShow[i]) continue;
|
|
|
|
|
|
|
|
|
|
pos=topHeaders+ImVec2(patChanX[i]+sizeRows.x,0);
|
|
|
|
|
|
|
|
|
|
dl->AddLine(
|
|
|
|
|
ImVec2(pos.x-PAT_BORDER_SIZE*0.5,pos.y),
|
|
|
|
|
ImVec2(pos.x-PAT_BORDER_SIZE*0.5,maxAreaHeaders.y),
|
|
|
|
|
ImGui::ColorConvertFloat4ToU32(ImGui::GetStyle().Colors[ImGuiCol_TableBorderLight]),
|
|
|
|
|
PAT_BORDER_SIZE
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
dl->AddLine(
|
|
|
|
|
ImVec2(minAreaHeaders.x,maxAreaHeaders.y-PAT_BORDER_SIZE*0.5),
|
|
|
|
|
ImVec2(maxAreaHeaders.x,maxAreaHeaders.y-PAT_BORDER_SIZE*0.5),
|
|
|
|
|
ImGui::ColorConvertFloat4ToU32(ImGui::GetStyle().Colors[ImGuiCol_TableBorderLight]),
|
|
|
|
|
PAT_BORDER_SIZE
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// the final button
|
|
|
|
|
ImGui::SetCursorScreenPos(ImVec2(topRows.x,topHeaders.y));
|
|
|
|
|
if (ImGui::Selectable(" ++###ExtraChannelButtons",false,ImGuiSelectableFlags_NoPadWithHalfSpacing,ImVec2(sizeRows.x,lineHeight+1.0f*dpiScale))) {
|
|
|
|
|
ImGui::OpenPopup("PatternOpt");
|
|
|
|
|
}
|
|
|
|
|
if (ImGui::IsItemHovered() && !mobileUI) {
|
|
|
|
|
ImGui::SetTooltip(_("click for pattern options (effect columns/pattern names/visualizer)"));
|
|
|
|
|
}
|
|
|
|
|
if (ImGui::IsItemClicked(ImGuiMouseButton_Right)) {
|
|
|
|
|
fancyPattern=!fancyPattern;
|
|
|
|
|
inhibitMenu=true;
|
|
|
|
|
e->enableCommandStream(fancyPattern);
|
|
|
|
|
e->getCommandStream(cmdStream);
|
|
|
|
|
cmdStream.clear();
|
|
|
|
|
}
|
|
|
|
|
ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding,origWinPadding);
|
|
|
|
|
ImGui::PushFont(mainFont);
|
|
|
|
|
if (ImGui::BeginPopup("PatternOpt",ImGuiWindowFlags_NoMove|ImGuiWindowFlags_AlwaysAutoResize|ImGuiWindowFlags_NoTitleBar|ImGuiWindowFlags_NoSavedSettings)) {
|
|
|
|
|
ImGui::Text(_("Options:"));
|
|
|
|
|
ImGui::Indent();
|
|
|
|
|
ImGui::Checkbox(_("Effect columns/collapse"),&patExtraButtons);
|
|
|
|
|
ImGui::Checkbox(_("Pattern names"),&patChannelNames);
|
|
|
|
|
ImGui::Checkbox(_("Channel group hints"),&patChannelPairs);
|
|
|
|
|
if (ImGui::Checkbox(_("Visualizer"),&fancyPattern)) {
|
|
|
|
|
inhibitMenu=true;
|
|
|
|
|
e->enableCommandStream(fancyPattern);
|
|
|
|
|
e->getCommandStream(cmdStream);
|
|
|
|
|
cmdStream.clear();
|
|
|
|
|
}
|
|
|
|
|
ImGui::Unindent();
|
|
|
|
|
|
|
|
|
|
ImGui::Text(_("Channel status:"));
|
|
|
|
|
ImGui::Indent();
|
|
|
|
|
if (ImGui::RadioButton(_("No###_PCS0"),patChannelHints==0)) {
|
|
|
|
|
patChannelHints=0;
|
|
|
|
|
}
|
|
|
|
|
if (ImGui::RadioButton(_("Yes###_PCS1"),patChannelHints==1)) {
|
|
|
|
|
patChannelHints=1;
|
|
|
|
|
}
|
|
|
|
|
ImGui::Unindent();
|
|
|
|
|
ImGui::EndPopup();
|
|
|
|
|
}
|
|
|
|
|
ImGui::PopFont();
|
|
|
|
|
ImGui::PopStyleVar();
|
2026-01-01 21:04:02 -05:00
|
|
|
|
2025-12-27 18:16:33 -05:00
|
|
|
ImGui::PopFont();
|
|
|
|
|
}
|
|
|
|
|
ImGui::PopStyleVar();
|
2026-01-02 20:14:49 -05:00
|
|
|
|
|
|
|
|
if (patternOpen) {
|
|
|
|
|
if (!inhibitMenu && ImGui::IsWindowHovered(ImGuiHoveredFlags_ChildWindows) && ImGui::IsMouseClicked(ImGuiMouseButton_Right)) ImGui::OpenPopup("patternActionMenu");
|
|
|
|
|
if (openEditMenu) ImGui::OpenPopup("patternActionMenu");
|
|
|
|
|
if (ImGui::BeginPopup("patternActionMenu",ImGuiWindowFlags_NoMove|ImGuiWindowFlags_AlwaysAutoResize|ImGuiWindowFlags_NoTitleBar|ImGuiWindowFlags_NoSavedSettings)) {
|
|
|
|
|
editOptions(false);
|
|
|
|
|
ImGui::EndPopup();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2025-12-27 18:16:33 -05:00
|
|
|
if (ImGui::IsWindowFocused(ImGuiFocusedFlags_ChildWindows)) curWindow=GUI_WINDOW_PATTERN;
|
|
|
|
|
ImGui::End();
|
|
|
|
|
}
|
|
|
|
|
|