From 8422e5dc1b64850587e24fe9bd133a41cbd2df3f Mon Sep 17 00:00:00 2001 From: tildearrow Date: Sun, 8 Oct 2023 15:34:14 -0500 Subject: [PATCH] GUI: channel pair hints, part 3 to-do: - flooring --- src/gui/gui.h | 2 ++ src/gui/guiConst.cpp | 2 ++ src/gui/pattern.cpp | 54 +++++++++++++++++++++++++++----------------- 3 files changed, 37 insertions(+), 21 deletions(-) diff --git a/src/gui/gui.h b/src/gui/gui.h index 1191dfe01..ccb81d400 100644 --- a/src/gui/gui.h +++ b/src/gui/gui.h @@ -310,6 +310,8 @@ enum FurnaceGUIColors { GUI_COLOR_PATTERN_STATUS_REL_ON, GUI_COLOR_PATTERN_STATUS_ON, + GUI_COLOR_PATTERN_PAIR, + GUI_COLOR_SAMPLE_BG, GUI_COLOR_SAMPLE_FG, GUI_COLOR_SAMPLE_LOOP, diff --git a/src/gui/guiConst.cpp b/src/gui/guiConst.cpp index 87a7f3c4a..e2874c31c 100644 --- a/src/gui/guiConst.cpp +++ b/src/gui/guiConst.cpp @@ -993,6 +993,8 @@ const FurnaceGUIColorDef guiColors[GUI_COLOR_MAX]={ D(GUI_COLOR_PATTERN_STATUS_REL_ON,"",ImVec4(1.0f,0.8f,0.1f,1.0f)), D(GUI_COLOR_PATTERN_STATUS_ON,"",ImVec4(0.3f,1.0f,0.1f,1.0f)), + D(GUI_COLOR_PATTERN_PAIR,"",ImVec4(0.6f,0.8f,1.0f,1.0f)), + D(GUI_COLOR_SAMPLE_BG,"",ImVec4(0.04f,0.13f,0.2f,1.0f)), D(GUI_COLOR_SAMPLE_FG,"",ImVec4(0.7f,0.7f,0.7f,1.0f)), D(GUI_COLOR_SAMPLE_LOOP,"",ImVec4(0.1f,0.22f,0.35f,1.0f)), diff --git a/src/gui/pattern.cpp b/src/gui/pattern.cpp index 99a46a8cb..17e4c3968 100644 --- a/src/gui/pattern.cpp +++ b/src/gui/pattern.cpp @@ -448,6 +448,7 @@ void FurnaceGUI::drawPattern() { nextScroll=-1.0f; nextAddScroll=0.0f; } + ImDrawList* tdl=NULL; 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]; @@ -1134,11 +1135,13 @@ void FurnaceGUI::drawPattern() { } } } + // HACK: rendering here would cause the pairs to be drawn behind the pattern for some reason... + tdl=ImGui::GetWindowDrawList(); ImGui::EndTable(); } - if (patChannelPairs && e->isRunning()) { // pair hints - ImDrawList* dl=ImGui::GetWindowDrawList(); + ImGui::PushFont(mainFont); + if (patChannelPairs && e->isRunning() && tdl!=NULL) { // pair hints float pos=0.0f; float posCenter=0.0f; float posMin=FLT_MAX; @@ -1177,11 +1180,11 @@ void FurnaceGUI::drawPattern() { } else { textSize=ImGui::CalcTextSize(pairs.label); } - dl->AddLine( + tdl->AddLine( ImVec2(pos,posY), ImVec2(pos,posY+textSize.y), - 0xffffffff, - dpiScale + ImGui::GetColorU32(uiColors[GUI_COLOR_PATTERN_PAIR]), + 2.0f*dpiScale ); for (int j=0; j<8; j++) { @@ -1196,45 +1199,54 @@ void FurnaceGUI::drawPattern() { numPairs++; if (posposMax) posMax=pos; - dl->AddLine( + tdl->AddLine( ImVec2(pos,posY), ImVec2(pos,posY+textSize.y), - 0xffffffff, - dpiScale + ImGui::GetColorU32(uiColors[GUI_COLOR_PATTERN_PAIR]), + 2.0f*dpiScale ); } posCenter/=numPairs; if (pairs.label==NULL) { - dl->AddLine( + tdl->AddLine( ImVec2(posMin,posY+textSize.y), ImVec2(posMax,posY+textSize.y), - 0xffffffff, - dpiScale + ImGui::GetColorU32(uiColors[GUI_COLOR_PATTERN_PAIR]), + 2.0f*dpiScale ); } else { - dl->AddLine( + tdl->AddLine( ImVec2(posMin,posY+textSize.y), - ImVec2(posCenter-textSize.x*0.5,posY+textSize.y), - 0xffffffff, - dpiScale + ImVec2(posCenter-textSize.x*0.5-6.0f*dpiScale,posY+textSize.y), + ImGui::GetColorU32(uiColors[GUI_COLOR_PATTERN_PAIR]), + 2.0f*dpiScale ); - dl->AddLine( - ImVec2(posCenter+textSize.x*0.5,posY+textSize.y), + tdl->AddLine( + ImVec2(posCenter+textSize.x*0.5+6.0f*dpiScale,posY+textSize.y), ImVec2(posMax,posY+textSize.y), - 0xffffffff, - dpiScale + ImGui::GetColorU32(uiColors[GUI_COLOR_PATTERN_PAIR]), + 2.0f*dpiScale ); - dl->AddText( + ImGui::RenderFrame( + ImVec2(posCenter-textSize.x*0.5-6.0f*dpiScale,posY+textSize.y*0.5-3.0f*dpiScale), + ImVec2(posCenter+textSize.x*0.5+6.0f*dpiScale,posY+textSize.y*1.5+3.0f*dpiScale), + ImGui::GetColorU32(ImGuiCol_FrameBg), + true, + ImGui::GetStyle().FrameRounding + ); + + tdl->AddText( ImVec2(posCenter-textSize.x*0.5,posY+textSize.y*0.5), - 0xffffffff, + ImGui::GetColorU32(ImGuiCol_Text), pairs.label ); } } } + ImGui::PopFont(); if (fancyPattern) { // visualizer e->getCommandStream(cmdStream);