GUI: add new settings and proper inslist scroll

- step on delete
- scroll step
This commit is contained in:
tildearrow 2022-02-04 00:03:30 -05:00
parent 764196c1ad
commit f03b410281
2 changed files with 97 additions and 58 deletions

View file

@ -966,64 +966,69 @@ void FurnaceGUI::drawInsList() {
} }
} }
ImGui::Separator(); ImGui::Separator();
for (int i=0; i<(int)e->song.ins.size(); i++) { if (ImGui::BeginTable("InsListScroll",1,ImGuiTableFlags_ScrollY)) {
DivInstrument* ins=e->song.ins[i]; for (int i=0; i<(int)e->song.ins.size(); i++) {
String name; DivInstrument* ins=e->song.ins[i];
switch (ins->type) { String name;
case DIV_INS_FM: switch (ins->type) {
ImGui::PushStyleColor(ImGuiCol_Text,uiColors[GUI_COLOR_INSTR_FM]); case DIV_INS_FM:
name=fmt::sprintf(ICON_FA_AREA_CHART " %.2X: %s##_INS%d\n",i,ins->name,i); ImGui::PushStyleColor(ImGuiCol_Text,uiColors[GUI_COLOR_INSTR_FM]);
break; name=fmt::sprintf(ICON_FA_AREA_CHART " %.2X: %s##_INS%d\n",i,ins->name,i);
case DIV_INS_STD: break;
ImGui::PushStyleColor(ImGuiCol_Text,uiColors[GUI_COLOR_INSTR_STD]); case DIV_INS_STD:
name=fmt::sprintf(ICON_FA_BAR_CHART " %.2X: %s##_INS%d\n",i,ins->name,i); ImGui::PushStyleColor(ImGuiCol_Text,uiColors[GUI_COLOR_INSTR_STD]);
break; name=fmt::sprintf(ICON_FA_BAR_CHART " %.2X: %s##_INS%d\n",i,ins->name,i);
case DIV_INS_GB: break;
ImGui::PushStyleColor(ImGuiCol_Text,uiColors[GUI_COLOR_INSTR_GB]); case DIV_INS_GB:
name=fmt::sprintf(ICON_FA_GAMEPAD " %.2X: %s##_INS%d\n",i,ins->name,i); ImGui::PushStyleColor(ImGuiCol_Text,uiColors[GUI_COLOR_INSTR_GB]);
break; name=fmt::sprintf(ICON_FA_GAMEPAD " %.2X: %s##_INS%d\n",i,ins->name,i);
case DIV_INS_C64: break;
ImGui::PushStyleColor(ImGuiCol_Text,uiColors[GUI_COLOR_INSTR_C64]); case DIV_INS_C64:
name=fmt::sprintf(ICON_FA_KEYBOARD_O " %.2X: %s##_INS%d\n",i,ins->name,i); ImGui::PushStyleColor(ImGuiCol_Text,uiColors[GUI_COLOR_INSTR_C64]);
break; name=fmt::sprintf(ICON_FA_KEYBOARD_O " %.2X: %s##_INS%d\n",i,ins->name,i);
case DIV_INS_AMIGA: break;
ImGui::PushStyleColor(ImGuiCol_Text,uiColors[GUI_COLOR_INSTR_AMIGA]); case DIV_INS_AMIGA:
name=fmt::sprintf(ICON_FA_VOLUME_UP " %.2X: %s##_INS%d\n",i,ins->name,i); ImGui::PushStyleColor(ImGuiCol_Text,uiColors[GUI_COLOR_INSTR_AMIGA]);
break; name=fmt::sprintf(ICON_FA_VOLUME_UP " %.2X: %s##_INS%d\n",i,ins->name,i);
case DIV_INS_PCE: break;
ImGui::PushStyleColor(ImGuiCol_Text,uiColors[GUI_COLOR_INSTR_PCE]); case DIV_INS_PCE:
name=fmt::sprintf(ICON_FA_ID_BADGE " %.2X: %s##_INS%d\n",i,ins->name,i); ImGui::PushStyleColor(ImGuiCol_Text,uiColors[GUI_COLOR_INSTR_PCE]);
break; name=fmt::sprintf(ICON_FA_ID_BADGE " %.2X: %s##_INS%d\n",i,ins->name,i);
case DIV_INS_AY: break;
ImGui::PushStyleColor(ImGuiCol_Text,uiColors[GUI_COLOR_INSTR_AY]); case DIV_INS_AY:
name=fmt::sprintf(ICON_FA_BAR_CHART " %.2X: %s##_INS%d\n",i,ins->name,i); ImGui::PushStyleColor(ImGuiCol_Text,uiColors[GUI_COLOR_INSTR_AY]);
break; name=fmt::sprintf(ICON_FA_BAR_CHART " %.2X: %s##_INS%d\n",i,ins->name,i);
case DIV_INS_AY8930: break;
ImGui::PushStyleColor(ImGuiCol_Text,uiColors[GUI_COLOR_INSTR_AY8930]); case DIV_INS_AY8930:
name=fmt::sprintf(ICON_FA_BAR_CHART " %.2X: %s##_INS%d\n",i,ins->name,i); ImGui::PushStyleColor(ImGuiCol_Text,uiColors[GUI_COLOR_INSTR_AY8930]);
break; name=fmt::sprintf(ICON_FA_BAR_CHART " %.2X: %s##_INS%d\n",i,ins->name,i);
case DIV_INS_TIA: break;
ImGui::PushStyleColor(ImGuiCol_Text,uiColors[GUI_COLOR_INSTR_TIA]); case DIV_INS_TIA:
name=fmt::sprintf(ICON_FA_BAR_CHART " %.2X: %s##_INS%d\n",i,ins->name,i); ImGui::PushStyleColor(ImGuiCol_Text,uiColors[GUI_COLOR_INSTR_TIA]);
break; name=fmt::sprintf(ICON_FA_BAR_CHART " %.2X: %s##_INS%d\n",i,ins->name,i);
case DIV_INS_SAA1099: break;
ImGui::PushStyleColor(ImGuiCol_Text,uiColors[GUI_COLOR_INSTR_SAA1099]); case DIV_INS_SAA1099:
name=fmt::sprintf(ICON_FA_BAR_CHART " %.2X: %s##_INS%d\n",i,ins->name,i); ImGui::PushStyleColor(ImGuiCol_Text,uiColors[GUI_COLOR_INSTR_SAA1099]);
break; name=fmt::sprintf(ICON_FA_BAR_CHART " %.2X: %s##_INS%d\n",i,ins->name,i);
default: break;
ImGui::PushStyleColor(ImGuiCol_Text,uiColors[GUI_COLOR_INSTR_UNKNOWN]); default:
name=fmt::sprintf(ICON_FA_QUESTION " %.2X: %s##_INS%d\n",i,ins->name,i); ImGui::PushStyleColor(ImGuiCol_Text,uiColors[GUI_COLOR_INSTR_UNKNOWN]);
break; name=fmt::sprintf(ICON_FA_QUESTION " %.2X: %s##_INS%d\n",i,ins->name,i);
} break;
if (ImGui::Selectable(name.c_str(),curIns==i)) { }
curIns=i; ImGui::TableNextRow();
} ImGui::TableNextColumn();
ImGui::PopStyleColor(); if (ImGui::Selectable(name.c_str(),curIns==i)) {
if (ImGui::IsItemHovered()) { curIns=i;
if (ImGui::IsMouseDoubleClicked(ImGuiMouseButton_Left)) { }
insEditOpen=true; ImGui::PopStyleColor();
if (ImGui::IsItemHovered()) {
if (ImGui::IsMouseDoubleClicked(ImGuiMouseButton_Left)) {
insEditOpen=true;
}
} }
} }
ImGui::EndTable();
} }
} }
if (ImGui::IsWindowFocused()) curWindow=GUI_WINDOW_INS_LIST; if (ImGui::IsWindowFocused()) curWindow=GUI_WINDOW_INS_LIST;
@ -2832,6 +2837,11 @@ void FurnaceGUI::drawSettings() {
settings.pullDeleteBehavior=pullDeleteBehaviorB; settings.pullDeleteBehavior=pullDeleteBehaviorB;
} }
bool stepOnDeleteB=settings.stepOnDelete;
if (ImGui::Checkbox("Move cursor by edit step on delete",&stepOnDeleteB)) {
settings.stepOnDelete=stepOnDeleteB;
}
bool allowEditDockingB=settings.allowEditDocking; bool allowEditDockingB=settings.allowEditDocking;
if (ImGui::Checkbox("Allow docking editors",&allowEditDockingB)) { if (ImGui::Checkbox("Allow docking editors",&allowEditDockingB)) {
settings.allowEditDocking=allowEditDockingB; settings.allowEditDocking=allowEditDockingB;
@ -2858,6 +2868,14 @@ void FurnaceGUI::drawSettings() {
if (ImGui::RadioButton("Yes, and move to next/prev pattern##wrapV2",settings.wrapVertical==2)) { if (ImGui::RadioButton("Yes, and move to next/prev pattern##wrapV2",settings.wrapVertical==2)) {
settings.wrapVertical=2; settings.wrapVertical=2;
} }
ImGui::Text("Cursor movement keys behavior:");
if (ImGui::RadioButton("Move by one##cmk0",settings.scrollStep==0)) {
settings.scrollStep=0;
}
if (ImGui::RadioButton("Move by Edit Step##cmk1",settings.scrollStep==1)) {
settings.scrollStep=1;
}
ImGui::EndTabItem(); ImGui::EndTabItem();
} }
if (ImGui::BeginTabItem("Audio")) { if (ImGui::BeginTabItem("Audio")) {
@ -2977,6 +2995,12 @@ void FurnaceGUI::drawSettings() {
if (ImGui::Checkbox("Use German notation",&germanNotationB)) { if (ImGui::Checkbox("Use German notation",&germanNotationB)) {
settings.germanNotation=germanNotationB; settings.germanNotation=germanNotationB;
} }
// sorry. temporarily disabled until ImGui has a way to add separators in tables arbitrarily.
/*bool sysSeparatorsB=settings.sysSeparators;
if (ImGui::Checkbox("Add separators between systems in Orders",&sysSeparatorsB)) {
settings.sysSeparators=sysSeparatorsB;
}*/
bool partyTimeB=settings.partyTime; bool partyTimeB=settings.partyTime;
if (ImGui::Checkbox("About screen party time",&partyTimeB)) { if (ImGui::Checkbox("About screen party time",&partyTimeB)) {
@ -3114,6 +3138,9 @@ void FurnaceGUI::syncSettings() {
if (settings.fmNames<0 || settings.fmNames>2) settings.fmNames=0; if (settings.fmNames<0 || settings.fmNames>2) settings.fmNames=0;
settings.partyTime=e->getConfInt("partyTime",0); settings.partyTime=e->getConfInt("partyTime",0);
settings.germanNotation=e->getConfInt("germanNotation",0); settings.germanNotation=e->getConfInt("germanNotation",0);
settings.stepOnDelete=e->getConfInt("stepOnDelete",0);
settings.scrollStep=e->getConfInt("scrollStep",0);
settings.sysSeparators=e->getConfInt("sysSeparators",1);
} }
#define PUT_UI_COLOR(source) e->setConf(#source,(int)ImGui::GetColorU32(uiColors[source])); #define PUT_UI_COLOR(source) e->setConf(#source,(int)ImGui::GetColorU32(uiColors[source]));
@ -3145,6 +3172,9 @@ void FurnaceGUI::commitSettings() {
e->setConf("overflowHighlight",settings.overflowHighlight); e->setConf("overflowHighlight",settings.overflowHighlight);
e->setConf("partyTime",settings.partyTime); e->setConf("partyTime",settings.partyTime);
e->setConf("germanNotation",settings.germanNotation); e->setConf("germanNotation",settings.germanNotation);
e->setConf("stepOnDelete",settings.stepOnDelete);
e->setConf("scrollStep",settings.scrollStep);
e->setConf("sysSeparators",settings.sysSeparators);
PUT_UI_COLOR(GUI_COLOR_BACKGROUND); PUT_UI_COLOR(GUI_COLOR_BACKGROUND);
PUT_UI_COLOR(GUI_COLOR_FRAME_BACKGROUND); PUT_UI_COLOR(GUI_COLOR_FRAME_BACKGROUND);
@ -4330,10 +4360,10 @@ void FurnaceGUI::keyDown(SDL_Event& ev) {
edit=!edit; edit=!edit;
break; break;
case SDLK_UP: case SDLK_UP:
moveCursor(0,-1,ev.key.keysym.mod&KMOD_SHIFT); moveCursor(0,-MAX(1,settings.scrollStep?editStep:1),ev.key.keysym.mod&KMOD_SHIFT);
break; break;
case SDLK_DOWN: case SDLK_DOWN:
moveCursor(0,1,ev.key.keysym.mod&KMOD_SHIFT); moveCursor(0,MAX(1,settings.scrollStep?editStep:1),ev.key.keysym.mod&KMOD_SHIFT);
break; break;
case SDLK_LEFT: case SDLK_LEFT:
moveCursor(-1,0,ev.key.keysym.mod&KMOD_SHIFT); moveCursor(-1,0,ev.key.keysym.mod&KMOD_SHIFT);
@ -4355,6 +4385,9 @@ void FurnaceGUI::keyDown(SDL_Event& ev) {
break; break;
case SDLK_DELETE: case SDLK_DELETE:
doDelete(); doDelete();
if (settings.stepOnDelete) {
moveCursor(0,editStep,false);
}
break; break;
case SDLK_BACKSPACE: case SDLK_BACKSPACE:
doPullDelete(); doPullDelete();

View file

@ -214,6 +214,9 @@ class FurnaceGUI {
int overflowHighlight; int overflowHighlight;
int partyTime; int partyTime;
int germanNotation; int germanNotation;
int stepOnDelete;
int scrollStep;
int sysSeparators;
unsigned int maxUndoSteps; unsigned int maxUndoSteps;
String mainFontPath; String mainFontPath;
String patFontPath; String patFontPath;
@ -243,6 +246,9 @@ class FurnaceGUI {
overflowHighlight(0), overflowHighlight(0),
partyTime(0), partyTime(0),
germanNotation(0), germanNotation(0),
stepOnDelete(0),
scrollStep(0),
sysSeparators(1),
maxUndoSteps(100), maxUndoSteps(100),
mainFontPath(""), mainFontPath(""),
patFontPath("") {} patFontPath("") {}