GUI: reduce pattern/orders latency

no more oldOrder/oldRow hacks!
This commit is contained in:
tildearrow 2023-09-16 04:08:12 -05:00
parent 5ca710860b
commit 083f870930
8 changed files with 43 additions and 60 deletions

View file

@ -259,18 +259,18 @@ void FurnaceGUI::drawOrders() {
}
ImGui::PushFont(patFont);
bool tooSmall=((displayChans+1)>((ImGui::GetContentRegionAvail().x)/(ImGui::CalcTextSize("AA").x+2.0*ImGui::GetStyle().ItemInnerSpacing.x)));
ImGui::PopFont();
float yHeight=ImGui::GetContentRegionAvail().y;
float lineHeight=(ImGui::GetTextLineHeight()+4*dpiScale);
if (e->isPlaying()) {
if (followOrders) {
float nextOrdScroll=(playOrder+1)*lineHeight-((yHeight-(tooSmall?ImGui::GetStyle().ScrollbarSize:0.0f))/2.0f);
if (nextOrdScroll<0.0f) nextOrdScroll=0.0f;
ImGui::SetNextWindowScroll(ImVec2(-1.0f,nextOrdScroll));
}
}
if (ImGui::BeginTable("OrdersTable",1+displayChans,(tooSmall?ImGuiTableFlags_SizingFixedFit:ImGuiTableFlags_SizingStretchSame)|ImGuiTableFlags_ScrollX|ImGuiTableFlags_ScrollY)) {
ImGui::PushFont(patFont);
ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing,prevSpacing);
ImGui::TableSetupScrollFreeze(1,1);
float lineHeight=(ImGui::GetTextLineHeight()+4*dpiScale);
if (e->isPlaying()) {
if (followOrders) {
ImGui::SetScrollY((e->getOrder()+1)*lineHeight-((yHeight-(tooSmall?ImGui::GetStyle().ScrollbarSize:0.0f))/2.0f));
}
}
ImGui::TableNextRow(0,lineHeight);
ImVec2 ra=ImGui::GetContentRegionAvail();
ImGui::TableNextColumn();
@ -283,9 +283,9 @@ void FurnaceGUI::drawOrders() {
ImGui::PopStyleColor();
for (int i=0; i<e->curSubSong->ordersLen; i++) {
ImGui::TableNextRow(0,lineHeight);
if (oldOrder1==i) ImGui::TableSetBgColor(ImGuiTableBgTarget_RowBg0,ImGui::GetColorU32(uiColors[GUI_COLOR_ORDER_ACTIVE]));
if (playOrder==i && e->isPlaying()) ImGui::TableSetBgColor(ImGuiTableBgTarget_RowBg0,ImGui::GetColorU32(uiColors[GUI_COLOR_ORDER_ACTIVE]));
ImGui::TableNextColumn();
if ((!followPattern && curOrder==i) || (followPattern && oldOrder1==i)) {
if (curOrder==i) {
// draw a border
ImDrawList* dl=ImGui::GetWindowDrawList();
ImVec2 rBegin=ImGui::GetCursorScreenPos();
@ -322,7 +322,7 @@ void FurnaceGUI::drawOrders() {
//}
ImGui::PushStyleColor(ImGuiCol_Text,(curOrder==i || e->curOrders->ord[j][i]==e->curOrders->ord[j][curOrder])?uiColors[GUI_COLOR_ORDER_SIMILAR]:uiColors[GUI_COLOR_ORDER_INACTIVE]);
if (ImGui::Selectable(selID,settings.ordersCursor?(cursor.xCoarse==j && oldOrder1!=i):false)) {
if (ImGui::Selectable(selID,settings.ordersCursor?(cursor.xCoarse==j && curOrder!=i):false)) {
if (curOrder==i) {
if (orderEditMode==0) {
prepareUndo(GUI_UNDO_CHANGE_ORDER);
@ -394,9 +394,9 @@ void FurnaceGUI::drawOrders() {
}
}
ImGui::PopStyleVar();
ImGui::PopFont();
ImGui::EndTable();
}
ImGui::PopFont();
if (settings.orderButtonPos==2) {
ImGui::TableNextColumn();
@ -411,6 +411,5 @@ void FurnaceGUI::drawOrders() {
}
}
if (ImGui::IsWindowFocused(ImGuiFocusedFlags_ChildWindows)) curWindow=GUI_WINDOW_ORDERS;
oldOrder1=e->getOrder();
ImGui::End();
}