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
This commit is contained in:
Eknous-P 2025-11-12 19:03:48 +04:00
parent 7f9baedc89
commit fa0e5494ad
4 changed files with 28 additions and 2 deletions

View file

@ -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; k<DIV_MAX_CHANS; k++) {
theCopy->chanName[k]=i->chanName[k];

View file

@ -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;
}
}
};

View file

@ -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; i<e->getTotalChannelCount(); 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();

View file

@ -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)];