From fa0e5494adcc1662f601035559a50854ac359e19 Mon Sep 17 00:00:00 2001 From: Eknous-P Date: Wed, 12 Nov 2025 19:03:48 +0400 Subject: [PATCH] per-channel colors cherry-picked from ffcfc51a086de91ed67a5b144fec82b010b5acb8, but without the tri-state checkbox sorry for being impatient again, im bored and have nothing to do --- src/engine/song.cpp | 1 + src/engine/song.h | 2 ++ src/gui/channels.cpp | 25 ++++++++++++++++++++++++- src/gui/gui.cpp | 2 +- 4 files changed, 28 insertions(+), 2 deletions(-) diff --git a/src/engine/song.cpp b/src/engine/song.cpp index 798c5f1c4..ff6e0e10e 100644 --- a/src/engine/song.cpp +++ b/src/engine/song.cpp @@ -642,6 +642,7 @@ void DivSong::findSubSongs(int chans) { memcpy(theCopy->chanShow,i->chanShow,DIV_MAX_CHANS*sizeof(bool)); memcpy(theCopy->chanShowChanOsc,i->chanShowChanOsc,DIV_MAX_CHANS*sizeof(bool)); memcpy(theCopy->chanCollapse,i->chanCollapse,DIV_MAX_CHANS); + memcpy(theCopy->chanColor,i->chanColor,DIV_MAX_CHANS*sizeof(unsigned int)); for (int k=0; kchanName[k]=i->chanName[k]; diff --git a/src/engine/song.h b/src/engine/song.h index 4b6e1b7fc..38da9b7d1 100644 --- a/src/engine/song.h +++ b/src/engine/song.h @@ -219,6 +219,7 @@ struct DivSubSong { unsigned char chanCollapse[DIV_MAX_CHANS]; String chanName[DIV_MAX_CHANS]; String chanShortName[DIV_MAX_CHANS]; + unsigned int chanColor[DIV_MAX_CHANS]; // song timestamps DivSongTimestamps ts; @@ -249,6 +250,7 @@ struct DivSubSong { chanShow[i]=true; chanShowChanOsc[i]=true; chanCollapse[i]=0; + chanColor[i]=0; } } }; diff --git a/src/gui/channels.cpp b/src/gui/channels.cpp index 091a4103a..a1cc0eb4a 100644 --- a/src/gui/channels.cpp +++ b/src/gui/channels.cpp @@ -38,12 +38,13 @@ void FurnaceGUI::drawChannels() { //ImGui::SetNextWindowSizeConstraints(ImVec2(440.0f*dpiScale,400.0f*dpiScale),ImVec2(canvasW,canvasH)); } if (ImGui::Begin("Channels",&channelsOpen,globalWinFlags,_("Channels"))) { - if (ImGui::BeginTable("ChannelList",5)) { + if (ImGui::BeginTable("ChannelList",6)) { ImGui::TableSetupColumn("c0",ImGuiTableColumnFlags_WidthFixed,0.0); ImGui::TableSetupColumn("c1",ImGuiTableColumnFlags_WidthFixed,0.0); ImGui::TableSetupColumn("c2",ImGuiTableColumnFlags_WidthFixed,0.0); ImGui::TableSetupColumn("c3",ImGuiTableColumnFlags_WidthStretch,0.0); ImGui::TableSetupColumn("c4",ImGuiTableColumnFlags_WidthFixed,48.0f*dpiScale); + ImGui::TableSetupColumn("c5",ImGuiTableColumnFlags_WidthFixed,0.0f); ImGui::TableNextRow(ImGuiTableRowFlags_Headers); ImGui::TableNextColumn(); ImGui::Text(_("Pat")); @@ -52,6 +53,9 @@ void FurnaceGUI::drawChannels() { ImGui::TableNextColumn(); ImGui::TableNextColumn(); ImGui::Text(_("Name")); + ImGui::TableNextColumn(); + ImGui::TableNextColumn(); + ImGui::Text(_("Color")); for (int i=0; igetTotalChannelCount(); i++) { ImGui::PushID(i); ImGui::TableNextRow(); @@ -106,6 +110,25 @@ void FurnaceGUI::drawChannels() { if (ImGui::InputTextWithHint("##ChanShortName",e->getChannelShortName(i),&e->curSubSong->chanShortName[i])) { MARK_MODIFIED; } + ImGui::TableNextColumn(); + ImVec4 curColor=e->curSubSong->chanColor[i]?ImGui::ColorConvertU32ToFloat4(e->curSubSong->chanColor[i]):uiColors[GUI_COLOR_CHANNEL_FM+e->getChannelType(i)]; + ImGui::ColorButton("##ChanColor",curColor); + if (ImGui::BeginPopupContextItem("##ChanColorEditPopup", ImGuiPopupFlags_MouseButtonLeft)) { + ImGui::ColorPicker4("##ChanColorEdit", (float*)&curColor); + e->curSubSong->chanColor[i]=ImGui::ColorConvertFloat4ToU32(curColor); + MARK_MODIFIED; + ImGui::EndPopup(); + } + ImGui::SameLine(); + ImGui::BeginDisabled(e->curSubSong->chanColor[i]==0); + if (ImGui::Button(ICON_FA_REFRESH "##ChanColorReset")) { + e->curSubSong->chanColor[i]=0; + MARK_MODIFIED; + } + if (ImGui::IsItemHovered()) { + ImGui::SetTooltip(_("Reset color")); + } + ImGui::EndDisabled(); ImGui::PopID(); } ImGui::EndTable(); diff --git a/src/gui/gui.cpp b/src/gui/gui.cpp index e80930911..16376718a 100644 --- a/src/gui/gui.cpp +++ b/src/gui/gui.cpp @@ -942,7 +942,7 @@ ImVec4 FurnaceGUI::channelColor(int ch) { return uiColors[GUI_COLOR_CHANNEL_BG]; break; case 1: - return uiColors[GUI_COLOR_CHANNEL_FM+e->getChannelType(ch)]; + return e->curSubSong->chanColor[ch]?ImGui::ColorConvertU32ToFloat4(e->curSubSong->chanColor[ch]):uiColors[GUI_COLOR_CHANNEL_FM+e->getChannelType(ch)]; break; case 2: return uiColors[GUI_COLOR_INSTR_STD+e->getPreferInsType(ch)];