GUI: begin working on unified ins/wave/sample list

This commit is contained in:
tildearrow 2022-03-14 00:26:27 -05:00
parent 5b2ec3ee87
commit a96fd5727e
5 changed files with 104 additions and 67 deletions

View file

@ -32,6 +32,7 @@
#include "ImGuiFileDialog.h" #include "ImGuiFileDialog.h"
#include "IconsFontAwesome4.h" #include "IconsFontAwesome4.h"
#include "misc/cpp/imgui_stdlib.h" #include "misc/cpp/imgui_stdlib.h"
#include "plot_nolerp.h"
#include "guiConst.h" #include "guiConst.h"
#include "intConst.h" #include "intConst.h"
#include <stdint.h> #include <stdint.h>
@ -1090,6 +1091,13 @@ void FurnaceGUI::drawInsList() {
} }
ImGui::Separator(); ImGui::Separator();
if (ImGui::BeginTable("InsListScroll",1,ImGuiTableFlags_ScrollY)) { if (ImGui::BeginTable("InsListScroll",1,ImGuiTableFlags_ScrollY)) {
if (settings.unifiedDataView) {
ImGui::TableNextRow();
ImGui::TableNextColumn();
ImGui::Text(ICON_FA_TASKS " Instruments");
ImGui::Indent();
}
for (int i=0; i<(int)e->song.ins.size(); i++) { for (int i=0; i<(int)e->song.ins.size(); i++) {
DivInstrument* ins=e->song.ins[i]; DivInstrument* ins=e->song.ins[i];
String name; String name;
@ -1214,12 +1222,32 @@ void FurnaceGUI::drawInsList() {
} }
ImGui::PopStyleColor(); ImGui::PopStyleColor();
if (ImGui::IsItemHovered()) { if (ImGui::IsItemHovered()) {
ImGui::SetTooltip("%s",(ins->type>DIV_INS_MAX)?"Unknown":insTypes[ins->type]);
if (ImGui::IsMouseDoubleClicked(ImGuiMouseButton_Left)) { if (ImGui::IsMouseDoubleClicked(ImGuiMouseButton_Left)) {
insEditOpen=true; insEditOpen=true;
nextWindow=GUI_WINDOW_INS_EDIT; nextWindow=GUI_WINDOW_INS_EDIT;
} }
} }
} }
if (settings.unifiedDataView) {
ImGui::Unindent();
ImGui::TableNextRow();
ImGui::TableNextColumn();
ImGui::Text(ICON_FA_AREA_CHART " Wavetables");
ImGui::Indent();
actualWaveList();
ImGui::Unindent();
ImGui::TableNextRow();
ImGui::TableNextColumn();
ImGui::Text(ICON_FA_VOLUME_UP " Samples");
ImGui::Indent();
actualSampleList();
ImGui::Unindent();
}
ImGui::EndTable(); ImGui::EndTable();
} }
} }
@ -1231,6 +1259,47 @@ const char* sampleNote[12]={
"C", "C#", "D", "D#", "E", "F", "F#", "G", "G#", "A", "A#", "B" "C", "C#", "D", "D#", "E", "F", "F#", "G", "G#", "A", "A#", "B"
}; };
void FurnaceGUI::actualWaveList() {
float wavePreview[256];
for (int i=0; i<(int)e->song.wave.size(); i++) {
DivWavetable* wave=e->song.wave[i];
for (int i=0; i<wave->len; i++) {
wavePreview[i]=wave->data[i];
}
if (wave->len>0) wavePreview[wave->len]=wave->data[wave->len-1];
ImGui::TableNextRow();
ImGui::TableNextColumn();
if (ImGui::Selectable(fmt::sprintf("%d##_WAVE%d\n",i,i).c_str(),curWave==i)) {
curWave=i;
}
if (ImGui::IsItemHovered()) {
if (ImGui::IsMouseDoubleClicked(ImGuiMouseButton_Left)) {
waveEditOpen=true;
}
}
ImGui::SameLine();
PlotNoLerp(fmt::sprintf("##_WAVEP%d",i).c_str(),wavePreview,wave->len+1,0,NULL,0,wave->max);
}
}
void FurnaceGUI::actualSampleList() {
for (int i=0; i<(int)e->song.sample.size(); i++) {
DivSample* sample=e->song.sample[i];
ImGui::TableNextRow();
ImGui::TableNextColumn();
if (ImGui::Selectable(fmt::sprintf("%d: %s##_SAM%d",i,sample->name,i).c_str(),curSample==i)) {
curSample=i;
}
if (ImGui::IsItemHovered()) {
ImGui::SetTooltip("Bank %d: %s",i/12,sampleNote[i%12]);
if (ImGui::IsMouseDoubleClicked(ImGuiMouseButton_Left)) {
sampleEditOpen=true;
}
}
}
}
void FurnaceGUI::drawSampleList() { void FurnaceGUI::drawSampleList() {
if (nextWindow==GUI_WINDOW_SAMPLE_LIST) { if (nextWindow==GUI_WINDOW_SAMPLE_LIST) {
sampleListOpen=true; sampleListOpen=true;
@ -1272,24 +1341,7 @@ void FurnaceGUI::drawSampleList() {
} }
ImGui::Separator(); ImGui::Separator();
if (ImGui::BeginTable("SampleListScroll",1,ImGuiTableFlags_ScrollY)) { if (ImGui::BeginTable("SampleListScroll",1,ImGuiTableFlags_ScrollY)) {
for (int i=0; i<(int)e->song.sample.size(); i++) { actualSampleList();
DivSample* sample=e->song.sample[i];
ImGui::TableNextRow();
ImGui::TableNextColumn();
if ((i%12)==0) {
if (i>0) ImGui::Unindent();
ImGui::Text("Bank %d",i/12);
ImGui::Indent();
}
if (ImGui::Selectable(fmt::sprintf("%s: %s##_SAM%d",sampleNote[i%12],sample->name,i).c_str(),curSample==i)) {
curSample=i;
}
if (ImGui::IsItemHovered()) {
if (ImGui::IsMouseDoubleClicked(ImGuiMouseButton_Left)) {
sampleEditOpen=true;
}
}
}
ImGui::EndTable(); ImGui::EndTable();
} }
ImGui::Unindent(); ImGui::Unindent();

View file

@ -721,6 +721,9 @@ class FurnaceGUI {
void patternRow(int i, bool isPlaying, float lineHeight, int chans, int ord); void patternRow(int i, bool isPlaying, float lineHeight, int chans, int ord);
void actualWaveList();
void actualSampleList();
void drawEditControls(); void drawEditControls();
void drawSongInfo(); void drawSongInfo();
void drawOrders(); void drawOrders();

View file

@ -19,6 +19,7 @@
// guiConst: constants used in the GUI like arrays, strings and other stuff // guiConst: constants used in the GUI like arrays, strings and other stuff
#include "guiConst.h" #include "guiConst.h"
#include "../engine/instrument.h"
const int opOrder[4]={ const int opOrder[4]={
0, 2, 1, 3 0, 2, 1, 3
@ -64,3 +65,31 @@ const char* pitchLabel[11]={
"1/6", "1/5", "1/4", "1/3", "1/2", "1x", "2x", "3x", "4x", "5x", "6x" "1/6", "1/5", "1/4", "1/3", "1/2", "1x", "2x", "3x", "4x", "5x", "6x"
}; };
const char* insTypes[DIV_INS_MAX]={
"Standard",
"FM (4-operator)",
"Game Boy",
"C64",
"Amiga/Sample",
"PC Engine",
"AY-3-8910/SSG",
"AY8930",
"TIA",
"SAA1099",
"VIC",
"PET",
"VRC6",
"FM (OPLL)",
"FM (OPL)",
"FDS",
"Virtual Boy",
"Namco 163",
"Konami SCC",
"FM (OPZ)",
"POKEY",
"PC Beeper",
"WonderSwan",
"Atari Lynx",
"VERA",
"X1-010"
};

View file

@ -23,3 +23,4 @@ extern const int opOrder[4];
extern const char* noteNames[180]; extern const char* noteNames[180];
extern const char* noteNamesG[180]; extern const char* noteNamesG[180];
extern const char* pitchLabel[11]; extern const char* pitchLabel[11];
extern const char* insTypes[];

View file

@ -27,35 +27,6 @@
#include <imgui.h> #include <imgui.h>
#include "plot_nolerp.h" #include "plot_nolerp.h"
const char* insTypes[DIV_INS_MAX]={
"Standard",
"FM (4-operator)",
"Game Boy",
"C64",
"Amiga/Sample",
"PC Engine",
"AY-3-8910/SSG",
"AY8930",
"TIA",
"SAA1099",
"VIC",
"PET",
"VRC6",
"FM (OPLL)",
"FM (OPL)",
"FDS",
"Virtual Boy",
"Namco 163",
"Konami SCC",
"FM (OPZ)",
"POKEY",
"PC Beeper",
"WonderSwan",
"Atari Lynx",
"VERA",
"X1-010"
};
const char* ssgEnvTypes[8]={ const char* ssgEnvTypes[8]={
"Down Down Down", "Down.", "Down Up Down Up", "Down UP", "Up Up Up", "Up.", "Up Down Up Down", "Up DOWN" "Down Down Down", "Down.", "Down Up Down Up", "Down UP", "Up Up Up", "Up.", "Up Down Up Down", "Up DOWN"
}; };
@ -1787,7 +1758,6 @@ void FurnaceGUI::drawWaveList() {
nextWindow=GUI_WINDOW_NOTHING; nextWindow=GUI_WINDOW_NOTHING;
} }
if (!waveListOpen) return; if (!waveListOpen) return;
float wavePreview[256];
if (ImGui::Begin("Wavetables",&waveListOpen)) { if (ImGui::Begin("Wavetables",&waveListOpen)) {
if (ImGui::Button(ICON_FA_PLUS "##WaveAdd")) { if (ImGui::Button(ICON_FA_PLUS "##WaveAdd")) {
doAction(GUI_ACTION_WAVE_LIST_ADD); doAction(GUI_ACTION_WAVE_LIST_ADD);
@ -1818,25 +1788,7 @@ void FurnaceGUI::drawWaveList() {
} }
ImGui::Separator(); ImGui::Separator();
if (ImGui::BeginTable("WaveListScroll",1,ImGuiTableFlags_ScrollY)) { if (ImGui::BeginTable("WaveListScroll",1,ImGuiTableFlags_ScrollY)) {
for (int i=0; i<(int)e->song.wave.size(); i++) { actualWaveList();
DivWavetable* wave=e->song.wave[i];
for (int i=0; i<wave->len; i++) {
wavePreview[i]=wave->data[i];
}
if (wave->len>0) wavePreview[wave->len]=wave->data[wave->len-1];
ImGui::TableNextRow();
ImGui::TableNextColumn();
if (ImGui::Selectable(fmt::sprintf("%d##_WAVE%d\n",i,i).c_str(),curWave==i)) {
curWave=i;
}
if (ImGui::IsItemHovered()) {
if (ImGui::IsMouseDoubleClicked(ImGuiMouseButton_Left)) {
waveEditOpen=true;
}
}
ImGui::SameLine();
PlotNoLerp(fmt::sprintf("##_WAVEP%d",i).c_str(),wavePreview,wave->len+1,0,NULL,0,wave->max);
}
ImGui::EndTable(); ImGui::EndTable();
} }
} }