GUI: implement instrument bank ins picker
This commit is contained in:
parent
eb71c27ad9
commit
b8c785230e
1
TODO.md
1
TODO.md
|
@ -1,6 +1,5 @@
|
||||||
# to-do for 0.6pre1
|
# to-do for 0.6pre1
|
||||||
|
|
||||||
- instrument loading selector
|
|
||||||
- rewrite the system name detection function anyway
|
- rewrite the system name detection function anyway
|
||||||
- add another FM editor layout
|
- add another FM editor layout
|
||||||
- add ability to move selection by dragging
|
- add ability to move selection by dragging
|
||||||
|
|
|
@ -3823,19 +3823,57 @@ bool FurnaceGUI::loop() {
|
||||||
} else {
|
} else {
|
||||||
ImGui::Text("this is an instrument bank! select which ones to load:");
|
ImGui::Text("this is an instrument bank! select which ones to load:");
|
||||||
}
|
}
|
||||||
for (size_t i=0; i<pendingIns.size(); i++) {
|
bool anySelected=false;
|
||||||
String id=fmt::sprintf("%d: %s",(int)i,pendingIns[i].first->name);
|
float sizeY=ImGui::GetFrameHeightWithSpacing()*pendingIns.size();
|
||||||
if (ImGui::Selectable(id.c_str())) {
|
if (sizeY>(scrH-180.0)*dpiScale) {
|
||||||
pendingIns[i].second=true;
|
sizeY=(scrH-180.0)*dpiScale;
|
||||||
e->addInstrumentPtr(pendingIns[i].first);
|
if (sizeY<60.0*dpiScale) sizeY=60.0*dpiScale;
|
||||||
|
}
|
||||||
|
if (ImGui::BeginTable("PendingInsList",1,ImGuiTableFlags_ScrollY,ImVec2(0.0f,sizeY))) {
|
||||||
|
for (size_t i=0; i<pendingIns.size(); i++) {
|
||||||
|
ImGui::TableNextRow();
|
||||||
|
ImGui::TableNextColumn();
|
||||||
|
String id=fmt::sprintf("%d: %s",(int)i,pendingIns[i].first->name);
|
||||||
|
if (pendingInsSingle) {
|
||||||
|
if (ImGui::Selectable(id.c_str())) {
|
||||||
|
pendingIns[i].second=true;
|
||||||
|
quitPlease=true;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
ImGui::Checkbox(id.c_str(),&pendingIns[i].second);
|
||||||
|
}
|
||||||
|
if (pendingIns[i].second) anySelected=true;
|
||||||
|
}
|
||||||
|
ImGui::EndTable();
|
||||||
|
}
|
||||||
|
if (!pendingInsSingle) {
|
||||||
|
ImGui::BeginDisabled(!anySelected);
|
||||||
|
if (ImGui::Button("OK")) {
|
||||||
quitPlease=true;
|
quitPlease=true;
|
||||||
}
|
}
|
||||||
|
ImGui::EndDisabled();
|
||||||
|
ImGui::SameLine();
|
||||||
|
}
|
||||||
|
if (ImGui::Button("Cancel")) {
|
||||||
|
for (std::pair<DivInstrument*,bool>& i: pendingIns) {
|
||||||
|
i.second=false;
|
||||||
|
}
|
||||||
|
quitPlease=true;
|
||||||
}
|
}
|
||||||
if (quitPlease) {
|
if (quitPlease) {
|
||||||
ImGui::CloseCurrentPopup();
|
ImGui::CloseCurrentPopup();
|
||||||
for (std::pair<DivInstrument*,bool> i: pendingIns) {
|
for (std::pair<DivInstrument*,bool>& i: pendingIns) {
|
||||||
if (!i.second) {
|
if (!i.second || pendingInsSingle) {
|
||||||
|
if (i.second) {
|
||||||
|
if (curIns>=0 && curIns<(int)e->song.ins.size()) {
|
||||||
|
*e->song.ins[curIns]=*i.first;
|
||||||
|
} else {
|
||||||
|
showError("...but you haven't selected an instrument!");
|
||||||
|
}
|
||||||
|
}
|
||||||
delete i.first;
|
delete i.first;
|
||||||
|
} else {
|
||||||
|
e->addInstrumentPtr(i.first);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
pendingIns.clear();
|
pendingIns.clear();
|
||||||
|
|
Loading…
Reference in a new issue