GUI: channel customization, part 1

This commit is contained in:
tildearrow 2022-09-18 03:51:10 -05:00
parent ca224632a1
commit 75bcad558a
6 changed files with 80 additions and 15 deletions

View File

@ -2,6 +2,6 @@
- stereo separation control for AY
- "paste with instrument"
- FM operator muting
- FM operator swap
- channel appearance settings
- auto-detect system
- bug fixes

View File

@ -584,6 +584,38 @@ void FurnaceGUI::updateWindowTitle() {
if (sdlWin!=NULL) SDL_SetWindowTitle(sdlWin,title.c_str());
}
ImVec4 FurnaceGUI::channelColor(int ch) {
switch (settings.channelColors) {
case 0:
return uiColors[GUI_COLOR_CHANNEL_BG];
break;
case 1:
return uiColors[GUI_COLOR_CHANNEL_FM+e->getChannelType(ch)];
break;
case 2:
return uiColors[GUI_COLOR_INSTR_STD+e->getPreferInsType(ch)];
break;
}
// invalid
return uiColors[GUI_COLOR_TEXT];
}
ImVec4 FurnaceGUI::channelTextColor(int ch) {
switch (settings.channelTextColors) {
case 0:
return uiColors[GUI_COLOR_CHANNEL_FG];
break;
case 1:
return uiColors[GUI_COLOR_CHANNEL_FM+e->getChannelType(ch)];
break;
case 2:
return uiColors[GUI_COLOR_INSTR_STD+e->getPreferInsType(ch)];
break;
}
// invalid
return uiColors[GUI_COLOR_TEXT];
}
const char* defaultLayout="[Window][DockSpaceViewport_11111111]\n\
Pos=0,24\n\
Size=1280,731\n\

View File

@ -161,6 +161,8 @@ enum FurnaceGUIColors {
GUI_COLOR_INSTR_OPL_DRUMS,
GUI_COLOR_INSTR_UNKNOWN,
GUI_COLOR_CHANNEL_BG,
GUI_COLOR_CHANNEL_FG,
GUI_COLOR_CHANNEL_FM,
GUI_COLOR_CHANNEL_PULSE,
GUI_COLOR_CHANNEL_NOISE,
@ -1604,6 +1606,8 @@ class FurnaceGUI {
void updateWindowTitle();
void prepareLayout();
ImVec4 channelColor(int ch);
ImVec4 channelTextColor(int ch);
void readOsc();

View File

@ -774,6 +774,8 @@ const FurnaceGUIColorDef guiColors[GUI_COLOR_MAX]={
D(GUI_COLOR_INSTR_OPL_DRUMS,"",ImVec4(0.3f,1.0f,0.9f,1.0f)),
D(GUI_COLOR_INSTR_UNKNOWN,"",ImVec4(0.3f,0.3f,0.3f,1.0f)),
D(GUI_COLOR_CHANNEL_BG,"",ImVec4(0.4f,0.6f,0.8f,1.0f)),
D(GUI_COLOR_CHANNEL_FG,"",ImVec4(1.0f,1.0f,1.0f,1.0f)),
D(GUI_COLOR_CHANNEL_FM,"",ImVec4(0.2f,0.8f,1.0f,1.0f)),
D(GUI_COLOR_CHANNEL_PULSE,"",ImVec4(0.4f,1.0f,0.2f,1.0f)),
D(GUI_COLOR_CHANNEL_NOISE,"",ImVec4(0.8f,0.8f,0.8f,1.0f)),

View File

@ -468,20 +468,44 @@ void FurnaceGUI::drawPattern() {
snprintf(chanID,2048," %s##_CH%d",chName,i);
}
}
bool muted=e->isChannelMuted(i);
ImVec4 chanHead=muted?uiColors[GUI_COLOR_CHANNEL_MUTED]:uiColors[GUI_COLOR_CHANNEL_FM+e->getChannelType(i)];
ImVec4 chanHead=muted?uiColors[GUI_COLOR_CHANNEL_MUTED]:channelColor(i);
ImVec4 chanHeadActive=chanHead;
ImVec4 chanHeadHover=chanHead;
if (e->keyHit[i]) {
keyHit[i]=0.2;
if (!muted) {
int note=e->getChanState(i)->note+60;
if (note>=0 && note<180) {
pianoKeyHit[note]=1.0;
if (settings.channelFeedbackStyle==1) {
keyHit[i]=0.2;
if (!muted) {
int note=e->getChanState(i)->note+60;
if (note>=0 && note<180) {
pianoKeyHit[note]=1.0;
}
}
}
e->keyHit[i]=false;
}
if (settings.channelFeedbackStyle==2 && e->isRunning()) {
float amount=((float)(e->getChanState(i)->volume>>8)/(float)e->getMaxVolumeChan(i));
if (!e->getChanState(i)->keyOn) amount=0.0f;
keyHit[i]=amount*0.2f;
if (!muted) {
int note=e->getChanState(i)->note+60;
if (note>=0 && note<180) {
pianoKeyHit[note]=amount;
}
}
} else if (settings.channelFeedbackStyle==3 && e->isRunning()) {
bool active=e->getChanState(i)->keyOn;
keyHit[i]=active?0.2f:0.0f;
if (!muted) {
int note=e->getChanState(i)->note+60;
if (note>=0 && note<180) {
pianoKeyHit[note]=active?1.0f:0.0f;
}
}
}
if (settings.guiColorsBase) {
chanHead.x*=1.0-keyHit[i]; chanHead.y*=1.0-keyHit[i]; chanHead.z*=1.0-keyHit[i];
chanHeadActive.x*=0.5; chanHeadActive.y*=0.5; chanHeadActive.z*=0.5;
@ -496,6 +520,7 @@ void FurnaceGUI::drawPattern() {
ImGui::PushStyleColor(ImGuiCol_Header,chanHead);
ImGui::PushStyleColor(ImGuiCol_HeaderActive,chanHeadActive);
ImGui::PushStyleColor(ImGuiCol_HeaderHovered,chanHeadHover);
ImGui::PushStyleColor(ImGuiCol_Text,ImGui::GetColorU32(channelTextColor(i)));
ImGui::TableSetBgColor(ImGuiTableBgTarget_CellBg,ImGui::GetColorU32(chanHead));
if (muted) ImGui::PushStyleColor(ImGuiCol_Text,uiColors[GUI_COLOR_CHANNEL_MUTED]);
ImGui::Selectable(chanID,true,ImGuiSelectableFlags_NoPadWithHalfSpacing,ImVec2(0.0f,lineHeight+1.0f*dpiScale));
@ -513,7 +538,7 @@ void FurnaceGUI::drawPattern() {
}
}
if (muted) ImGui::PopStyleColor();
ImGui::PopStyleColor(3);
ImGui::PopStyleColor(4);
if (settings.soloAction!=2) if (ImGui::IsItemClicked(ImGuiMouseButton_Right)) {
inhibitMenu=true;
e->toggleSolo(i);

View File

@ -1284,14 +1284,14 @@ void FurnaceGUI::drawSettings() {
}
ImGui::Text("Channel name colors:");
if (ImGui::RadioButton("Single##CTC0",settings.channelColors==0)) {
settings.channelColors=0;
if (ImGui::RadioButton("Single##CTC0",settings.channelTextColors==0)) {
settings.channelTextColors=0;
}
if (ImGui::RadioButton("Channel type##CTC1",settings.channelColors==1)) {
settings.channelColors=1;
if (ImGui::RadioButton("Channel type##CTC1",settings.channelTextColors==1)) {
settings.channelTextColors=1;
}
if (ImGui::RadioButton("Instrument type##CTC2",settings.channelColors==2)) {
settings.channelColors=2;
if (ImGui::RadioButton("Instrument type##CTC2",settings.channelTextColors==2)) {
settings.channelTextColors=2;
}
ImGui::Text("Channel style:");
@ -1659,6 +1659,8 @@ void FurnaceGUI::drawSettings() {
ImGui::TreePop();
}
if (ImGui::TreeNode("Channel")) {
UI_COLOR_CONFIG(GUI_COLOR_CHANNEL_BG,"Single color (background)");
UI_COLOR_CONFIG(GUI_COLOR_CHANNEL_FG,"Single color (text)");
UI_COLOR_CONFIG(GUI_COLOR_CHANNEL_FM,"FM");
UI_COLOR_CONFIG(GUI_COLOR_CHANNEL_PULSE,"Pulse");
UI_COLOR_CONFIG(GUI_COLOR_CHANNEL_NOISE,"Noise");