From e28af73746e93f3068bdd0610d902993178c19af Mon Sep 17 00:00:00 2001 From: tildearrow Date: Thu, 26 Oct 2023 19:03:45 -0500 Subject: [PATCH] GUI: channel status, part 2 --- src/engine/engine.cpp | 5 +++++ src/engine/engine.h | 3 +++ src/gui/pattern.cpp | 29 +++++++++++++++++++++-------- 3 files changed, 29 insertions(+), 8 deletions(-) diff --git a/src/engine/engine.cpp b/src/engine/engine.cpp index e8fe8167b..76a307f5b 100644 --- a/src/engine/engine.cpp +++ b/src/engine/engine.cpp @@ -1424,6 +1424,11 @@ DivChannelPair DivEngine::getChanPaired(int ch) { return disCont[dispatchOfChan[ch]].dispatch->getPaired(dispatchChanOfChan[ch]); } +DivChannelModeHints DivEngine::getChanModeHints(int ch) { + if (ch<0 || ch>=chans) return DivChannelModeHints(); + return disCont[dispatchOfChan[ch]].dispatch->getModeHints(dispatchChanOfChan[ch]); +} + unsigned char* DivEngine::getRegisterPool(int sys, int& size, int& depth) { if (sys<0 || sys>=song.systemLen) return NULL; if (disCont[sys].dispatch==NULL) return NULL; diff --git a/src/engine/engine.h b/src/engine/engine.h index f4c46de32..7f0e4600c 100644 --- a/src/engine/engine.h +++ b/src/engine/engine.h @@ -1017,6 +1017,9 @@ class DivEngine { // get channel pairs DivChannelPair getChanPaired(int chan); + // get channel mode hints + DivChannelModeHints getChanModeHints(int chan); + // get register pool unsigned char* getRegisterPool(int sys, int& size, int& depth); diff --git a/src/gui/pattern.cpp b/src/gui/pattern.cpp index 98ea6c94e..157b5078b 100644 --- a/src/gui/pattern.cpp +++ b/src/gui/pattern.cpp @@ -934,17 +934,18 @@ void FurnaceGUI::drawPattern() { ImGui::Dummy(ImVec2(dpiScale,settings.iconSize*dpiScale)); ImVec2 posMax=ImGui::GetContentRegionMax(); ImDrawList* dl=ImGui::GetWindowDrawList(); - ImVec2 iconPos[6]; - - for (int i=0; i<6; i++) { - iconPos[i]=ImLerp(posMin,posMax,ImVec2((float)i/6.0f,0.0f)); - - //dl->AddText(mainFont,settings.mainFontSize*dpiScale,iconPos[i],0xffffffff,ICON_FUR_SINE); - } - 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; ikeyOn) { @@ -960,6 +961,7 @@ void FurnaceGUI::drawPattern() { onOffColor=uiColors[GUI_COLOR_PATTERN_STATUS_OFF]; } } + iconPos[0].x-=mainFont->CalcTextSizeA(mainFont->FontSize,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 @@ -984,6 +986,7 @@ void FurnaceGUI::drawPattern() { } else { pitchColor=uiColors[GUI_COLOR_TOGGLE_OFF]; } + iconPos[1].x-=mainFont->CalcTextSizeA(mainFont->FontSize,FLT_MAX,0.0f,pitchIcon).x*0.5f; dl->AddText(mainFont,settings.mainFontSize*dpiScale,iconPos[1],ImGui::GetColorU32(pitchColor),pitchIcon); @@ -1003,7 +1006,17 @@ void FurnaceGUI::drawPattern() { } else { volColor=uiColors[GUI_COLOR_TOGGLE_OFF]; } + iconPos[2].x-=mainFont->CalcTextSizeA(mainFont->FontSize,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; iCalcTextSizeA(mainFont->FontSize,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;