GUI: optimize pattern view
don't render what isn't visible from 3.5ms to 2ms in my phone to-do: check for regressions...
This commit is contained in:
parent
dd9983778b
commit
f674a38d8e
|
@ -2545,7 +2545,7 @@ class FurnaceGUI {
|
||||||
ImVec2 patWindowPos, patWindowSize;
|
ImVec2 patWindowPos, patWindowSize;
|
||||||
|
|
||||||
// pattern view specific
|
// pattern view specific
|
||||||
ImVec2 fourChars, threeChars, twoChars;
|
ImVec2 fourChars, threeChars, twoChars, oneChar;
|
||||||
ImVec2 noteCellSize, insCellSize, volCellSize, effectCellSize, effectValCellSize;
|
ImVec2 noteCellSize, insCellSize, volCellSize, effectCellSize, effectValCellSize;
|
||||||
SelectionPoint sel1, sel2;
|
SelectionPoint sel1, sel2;
|
||||||
int dummyRows;
|
int dummyRows;
|
||||||
|
|
|
@ -167,7 +167,9 @@ inline void FurnaceGUI::patternRow(int i, bool isPlaying, float lineHeight, int
|
||||||
int chanVolMax=e->getMaxVolumeChan(j);
|
int chanVolMax=e->getMaxVolumeChan(j);
|
||||||
if (chanVolMax<1) chanVolMax=1;
|
if (chanVolMax<1) chanVolMax=1;
|
||||||
const DivPattern* pat=patCache[j];
|
const DivPattern* pat=patCache[j];
|
||||||
ImGui::TableNextColumn();
|
if (!ImGui::TableNextColumn()) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
for (int k=mustSetXOf; k<=j; k++) {
|
for (int k=mustSetXOf; k<=j; k++) {
|
||||||
patChanX[k]=ImGui::GetCursorScreenPos().x;
|
patChanX[k]=ImGui::GetCursorScreenPos().x;
|
||||||
}
|
}
|
||||||
|
@ -478,10 +480,30 @@ void FurnaceGUI::drawPattern() {
|
||||||
if (chans<1) {
|
if (chans<1) {
|
||||||
ImGui::Text(_("there aren't any channels to show."));
|
ImGui::Text(_("there aren't any channels to show."));
|
||||||
} else if (ImGui::BeginTable("PatternView",displayChans+2,ImGuiTableFlags_BordersInnerV|ImGuiTableFlags_ScrollX|ImGuiTableFlags_ScrollY|ImGuiTableFlags_NoPadInnerX|ImGuiTableFlags_NoBordersInFrozenArea|((settings.cursorFollowsWheel || wheelCalmDown)?ImGuiTableFlags_NoScrollWithMouse:0))) {
|
} else if (ImGui::BeginTable("PatternView",displayChans+2,ImGuiTableFlags_BordersInnerV|ImGuiTableFlags_ScrollX|ImGuiTableFlags_ScrollY|ImGuiTableFlags_NoPadInnerX|ImGuiTableFlags_NoBordersInFrozenArea|((settings.cursorFollowsWheel || wheelCalmDown)?ImGuiTableFlags_NoScrollWithMouse:0))) {
|
||||||
ImGui::TableSetupColumn("pos",ImGuiTableColumnFlags_WidthFixed);
|
|
||||||
char chanID[2048];
|
char chanID[2048];
|
||||||
float lineHeight=(ImGui::GetTextLineHeight()+2*dpiScale);
|
float lineHeight=(ImGui::GetTextLineHeight()+2*dpiScale);
|
||||||
|
|
||||||
|
// 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;
|
||||||
|
|
||||||
|
// and now set things up
|
||||||
|
ImGui::TableSetupColumn("pos",ImGuiTableColumnFlags_WidthFixed,fourChars.x);
|
||||||
|
|
||||||
if (nextAddScroll!=0.0f) {
|
if (nextAddScroll!=0.0f) {
|
||||||
ImGui::SetScrollY(ImGui::GetScrollY()+nextAddScroll);
|
ImGui::SetScrollY(ImGui::GetScrollY()+nextAddScroll);
|
||||||
nextScroll=-1.0f;
|
nextScroll=-1.0f;
|
||||||
|
@ -495,7 +517,18 @@ void FurnaceGUI::drawPattern() {
|
||||||
ImGui::TableSetupScrollFreeze(1,1);
|
ImGui::TableSetupScrollFreeze(1,1);
|
||||||
for (int i=0; i<chans; i++) {
|
for (int i=0; i<chans; i++) {
|
||||||
if (!e->curSubSong->chanShow[i]) continue;
|
if (!e->curSubSong->chanShow[i]) continue;
|
||||||
ImGui::TableSetupColumn(fmt::sprintf("c%d",i).c_str(),ImGuiTableColumnFlags_WidthFixed);
|
float chanWidth=noteCellSize.x;
|
||||||
|
if (e->curSubSong->chanCollapse[i]<3) {
|
||||||
|
chanWidth+=insCellSize.x;
|
||||||
|
}
|
||||||
|
if (e->curSubSong->chanCollapse[i]<2) {
|
||||||
|
chanWidth+=volCellSize.x;
|
||||||
|
}
|
||||||
|
if (e->curSubSong->chanCollapse[i]<1) {
|
||||||
|
chanWidth+=(effectCellSize.x+effectValCellSize.x)*e->curPat[i].effectCols;
|
||||||
|
}
|
||||||
|
|
||||||
|
ImGui::TableSetupColumn(fmt::sprintf("c%d",i).c_str(),ImGuiTableColumnFlags_WidthFixed,chanWidth);
|
||||||
}
|
}
|
||||||
ImGui::TableNextRow();
|
ImGui::TableNextRow();
|
||||||
ImGui::TableNextColumn();
|
ImGui::TableNextColumn();
|
||||||
|
@ -1116,22 +1149,6 @@ void FurnaceGUI::drawPattern() {
|
||||||
if (e->hasExtValue()) {
|
if (e->hasExtValue()) {
|
||||||
ImGui::TextColored(uiColors[GUI_COLOR_EE_VALUE]," %.2X",e->getExtValue());
|
ImGui::TextColored(uiColors[GUI_COLOR_EE_VALUE]," %.2X",e->getExtValue());
|
||||||
}
|
}
|
||||||
float oneCharSize=ImGui::CalcTextSize("A").x;
|
|
||||||
fourChars=ImVec2(oneCharSize*4.0f,lineHeight);
|
|
||||||
threeChars=ImVec2(oneCharSize*3.0f,lineHeight);
|
|
||||||
twoChars=ImVec2(oneCharSize*2.0f,lineHeight);
|
|
||||||
//ImVec2 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;
|
|
||||||
|
|
||||||
dummyRows=(ImGui::GetWindowSize().y/lineHeight)/2;
|
dummyRows=(ImGui::GetWindowSize().y/lineHeight)/2;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue