mirror of
https://github.com/tildearrow/furnace.git
synced 2024-12-02 17:27:25 +00:00
GUI: improve wavetable editor, part 1
This commit is contained in:
parent
598ca75402
commit
962dab012c
3 changed files with 62 additions and 71 deletions
|
@ -4116,6 +4116,7 @@ bool FurnaceGUI::init() {
|
||||||
|
|
||||||
tempoView=e->getConfBool("tempoView",true);
|
tempoView=e->getConfBool("tempoView",true);
|
||||||
waveHex=e->getConfBool("waveHex",false);
|
waveHex=e->getConfBool("waveHex",false);
|
||||||
|
waveEditStyle=e->getConfInt("waveEditStyle",0);
|
||||||
lockLayout=e->getConfBool("lockLayout",false);
|
lockLayout=e->getConfBool("lockLayout",false);
|
||||||
#ifdef IS_MOBILE
|
#ifdef IS_MOBILE
|
||||||
fullScreen=true;
|
fullScreen=true;
|
||||||
|
@ -4359,6 +4360,7 @@ bool FurnaceGUI::finish() {
|
||||||
|
|
||||||
e->setConf("tempoView",tempoView);
|
e->setConf("tempoView",tempoView);
|
||||||
e->setConf("waveHex",waveHex);
|
e->setConf("waveHex",waveHex);
|
||||||
|
e->setConf("waveEditStyle",waveEditStyle);
|
||||||
e->setConf("lockLayout",lockLayout);
|
e->setConf("lockLayout",lockLayout);
|
||||||
e->setConf("fullScreen",fullScreen);
|
e->setConf("fullScreen",fullScreen);
|
||||||
e->setConf("mobileUI",mobileUI);
|
e->setConf("mobileUI",mobileUI);
|
||||||
|
@ -4438,6 +4440,7 @@ FurnaceGUI::FurnaceGUI():
|
||||||
vgmExportVersion(0x171),
|
vgmExportVersion(0x171),
|
||||||
drawHalt(10),
|
drawHalt(10),
|
||||||
macroPointSize(16),
|
macroPointSize(16),
|
||||||
|
waveEditStyle(0),
|
||||||
globalWinFlags(0),
|
globalWinFlags(0),
|
||||||
curFileDialog(GUI_FILE_OPEN),
|
curFileDialog(GUI_FILE_OPEN),
|
||||||
warnAction(GUI_WARN_OPEN),
|
warnAction(GUI_WARN_OPEN),
|
||||||
|
|
|
@ -958,6 +958,7 @@ class FurnaceGUI {
|
||||||
int vgmExportVersion;
|
int vgmExportVersion;
|
||||||
int drawHalt;
|
int drawHalt;
|
||||||
int macroPointSize;
|
int macroPointSize;
|
||||||
|
int waveEditStyle;
|
||||||
|
|
||||||
ImGuiWindowFlags globalWinFlags;
|
ImGuiWindowFlags globalWinFlags;
|
||||||
|
|
||||||
|
|
|
@ -36,6 +36,14 @@ void FurnaceGUI::drawWaveEdit() {
|
||||||
if (curWave<0 || curWave>=(int)e->song.wave.size()) {
|
if (curWave<0 || curWave>=(int)e->song.wave.size()) {
|
||||||
ImGui::Text("no wavetable selected");
|
ImGui::Text("no wavetable selected");
|
||||||
} else {
|
} else {
|
||||||
|
DivWavetable* wave=e->song.wave[curWave];
|
||||||
|
|
||||||
|
if (ImGui::BeginTable("WEProps",2)) {
|
||||||
|
ImGui::TableSetupColumn("c0",ImGuiTableColumnFlags_WidthStretch);
|
||||||
|
ImGui::TableSetupColumn("c1",ImGuiTableColumnFlags_WidthFixed);
|
||||||
|
ImGui::TableNextRow();
|
||||||
|
|
||||||
|
ImGui::TableNextColumn();
|
||||||
ImGui::SetNextItemWidth(80.0f*dpiScale);
|
ImGui::SetNextItemWidth(80.0f*dpiScale);
|
||||||
if (ImGui::InputInt("##CurWave",&curWave,1,1)) {
|
if (ImGui::InputInt("##CurWave",&curWave,1,1)) {
|
||||||
if (curWave<0) curWave=0;
|
if (curWave<0) curWave=0;
|
||||||
|
@ -52,15 +60,21 @@ void FurnaceGUI::drawWaveEdit() {
|
||||||
}
|
}
|
||||||
ImGui::SameLine();
|
ImGui::SameLine();
|
||||||
|
|
||||||
DivWavetable* wave=e->song.wave[curWave];
|
if (ImGui::RadioButton("Steps",waveEditStyle==0)) {
|
||||||
|
waveEditStyle=0;
|
||||||
|
}
|
||||||
|
ImGui::SameLine();
|
||||||
|
if (ImGui::RadioButton("Lines",waveEditStyle==1)) {
|
||||||
|
waveEditStyle=1;
|
||||||
|
}
|
||||||
|
|
||||||
if (!settings.waveLayout){
|
ImGui::TableNextColumn();
|
||||||
ImGui::Text("Width");
|
ImGui::Text("Width");
|
||||||
if (ImGui::IsItemHovered()) {
|
if (ImGui::IsItemHovered()) {
|
||||||
ImGui::SetTooltip("use a width of:\n- any on Amiga/N163\n- 32 on Game Boy, PC Engine and WonderSwan\n- 64 on FDS\n- 128 on X1-010\nany other widths will be scaled during playback.");
|
ImGui::SetTooltip("use a width of:\n- any on Amiga/N163\n- 32 on Game Boy, PC Engine and WonderSwan\n- 64 on FDS\n- 128 on X1-010\nany other widths will be scaled during playback.");
|
||||||
}
|
}
|
||||||
ImGui::SameLine();
|
ImGui::SameLine();
|
||||||
ImGui::SetNextItemWidth(128.0f*dpiScale);
|
ImGui::SetNextItemWidth(96.0f*dpiScale);
|
||||||
if (ImGui::InputInt("##_WTW",&wave->len,1,2)) {
|
if (ImGui::InputInt("##_WTW",&wave->len,1,2)) {
|
||||||
if (wave->len>256) wave->len=256;
|
if (wave->len>256) wave->len=256;
|
||||||
if (wave->len<1) wave->len=1;
|
if (wave->len<1) wave->len=1;
|
||||||
|
@ -74,78 +88,35 @@ void FurnaceGUI::drawWaveEdit() {
|
||||||
ImGui::SetTooltip("use a height of:\n- 15 for Game Boy, WonderSwan, X1-010 Envelope shape and N163\n- 31 for PC Engine\n- 63 for FDS\n- 255 for X1-010\nany other heights will be scaled during playback.");
|
ImGui::SetTooltip("use a height of:\n- 15 for Game Boy, WonderSwan, X1-010 Envelope shape and N163\n- 31 for PC Engine\n- 63 for FDS\n- 255 for X1-010\nany other heights will be scaled during playback.");
|
||||||
}
|
}
|
||||||
ImGui::SameLine();
|
ImGui::SameLine();
|
||||||
ImGui::SetNextItemWidth(128.0f*dpiScale);
|
ImGui::SetNextItemWidth(96.0f*dpiScale);
|
||||||
if (ImGui::InputInt("##_WTH",&wave->max,1,2)) {
|
if (ImGui::InputInt("##_WTH",&wave->max,1,2)) {
|
||||||
if (wave->max>255) wave->max=255;
|
if (wave->max>255) wave->max=255;
|
||||||
if (wave->max<1) wave->max=1;
|
if (wave->max<1) wave->max=1;
|
||||||
e->notifyWaveChange(curWave);
|
e->notifyWaveChange(curWave);
|
||||||
MARK_MODIFIED;
|
MARK_MODIFIED;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
ImGui::SameLine();
|
|
||||||
if (ImGui::RadioButton("Dec",!waveHex)) {
|
|
||||||
waveHex=false;
|
|
||||||
}
|
|
||||||
ImGui::SameLine();
|
|
||||||
if (ImGui::RadioButton("Hex",waveHex)) {
|
|
||||||
waveHex=true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (settings.waveLayout){
|
|
||||||
if (ImGui::BeginTable("WaveProps",2,ImGuiTableFlags_SizingStretchSame)) {
|
|
||||||
ImGui::TableNextRow();
|
|
||||||
ImGui::TableNextColumn();
|
|
||||||
ImGui::Text("Width");
|
|
||||||
if (ImGui::IsItemHovered()) {
|
|
||||||
ImGui::SetTooltip("use a width of:\n- any on Amiga/N163\n- 32 on Game Boy, PC Engine and WonderSwan\n- 64 on FDS\n- 128 on X1-010\nany other widths will be scaled during playback.");
|
|
||||||
}
|
|
||||||
ImGui::SameLine();
|
|
||||||
ImGui::SetNextItemWidth(ImGui::GetContentRegionAvail().x);
|
|
||||||
if (ImGui::InputInt("##_WTW",&wave->len,1,2)) {
|
|
||||||
if (wave->len>256) wave->len=256;
|
|
||||||
if (wave->len<1) wave->len=1;
|
|
||||||
e->notifyWaveChange(curWave);
|
|
||||||
if (wavePreviewOn) e->previewWave(curWave,wavePreviewNote);
|
|
||||||
MARK_MODIFIED;
|
|
||||||
}
|
|
||||||
ImGui::TableNextColumn();
|
|
||||||
ImGui::SameLine();
|
|
||||||
ImGui::Text("Height");
|
|
||||||
if (ImGui::IsItemHovered()) {
|
|
||||||
ImGui::SetTooltip("use a height of:\n- 15 for Game Boy, WonderSwan, X1-010 Envelope shape and N163\n- 31 for PC Engine\n- 63 for FDS\n- 255 for X1-010\nany other heights will be scaled during playback.");
|
|
||||||
}
|
|
||||||
ImGui::SameLine();
|
|
||||||
ImGui::SetNextItemWidth(ImGui::GetContentRegionAvail().x);
|
|
||||||
if (ImGui::InputInt("##_WTH",&wave->max,1,2)) {
|
|
||||||
if (wave->max>255) wave->max=255;
|
|
||||||
if (wave->max<1) wave->max=1;
|
|
||||||
e->notifyWaveChange(curWave);
|
|
||||||
MARK_MODIFIED;
|
|
||||||
}
|
|
||||||
ImGui::EndTable();
|
ImGui::EndTable();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
for (int i=0; i<wave->len; i++) {
|
for (int i=0; i<wave->len; i++) {
|
||||||
if (wave->data[i]>wave->max) wave->data[i]=wave->max;
|
if (wave->data[i]>wave->max) wave->data[i]=wave->max;
|
||||||
wavePreview[i]=wave->data[i];
|
wavePreview[i]=wave->data[i];
|
||||||
}
|
}
|
||||||
if (wave->len>0) wavePreview[wave->len]=wave->data[wave->len-1];
|
if (wave->len>0) wavePreview[wave->len]=wave->data[wave->len-1];
|
||||||
ImGui::SetNextItemWidth(ImGui::GetContentRegionAvail().x); // wavetable text input size found here
|
|
||||||
if (ImGui::InputText("##MMLWave",&mmlStringW)) {
|
|
||||||
decodeMMLStrW(mmlStringW,wave->data,wave->len,wave->max,waveHex);
|
|
||||||
}
|
|
||||||
if (!ImGui::IsItemActive()) {
|
|
||||||
encodeMMLStr(mmlStringW,wave->data,wave->len,-1,-1,waveHex);
|
|
||||||
}
|
|
||||||
|
|
||||||
ImGui::PushStyleVar(ImGuiStyleVar_FramePadding,ImVec2(0.0f,0.0f));
|
ImGui::PushStyleVar(ImGuiStyleVar_FramePadding,ImVec2(0.0f,0.0f));
|
||||||
|
|
||||||
ImVec2 contentRegion=ImGui::GetContentRegionAvail(); // wavetable graph size determined here
|
ImVec2 contentRegion=ImGui::GetContentRegionAvail(); // wavetable graph size determined here
|
||||||
if (ImGui::GetContentRegionAvail().y > (ImGui::GetContentRegionAvail().x / 2.0f)) {
|
contentRegion.y-=ImGui::GetFrameHeightWithSpacing()+ImGui::GetStyle().WindowPadding.y;
|
||||||
|
/*if (ImGui::GetContentRegionAvail().y > (ImGui::GetContentRegionAvail().x / 2.0f)) {
|
||||||
contentRegion=ImVec2(ImGui::GetContentRegionAvail().x,ImGui::GetContentRegionAvail().x / 2.0f);
|
contentRegion=ImVec2(ImGui::GetContentRegionAvail().x,ImGui::GetContentRegionAvail().x / 2.0f);
|
||||||
}
|
}*/
|
||||||
|
if (waveEditStyle) {
|
||||||
PlotNoLerp("##Waveform",wavePreview,wave->len+1,0,NULL,0,wave->max,contentRegion);
|
PlotNoLerp("##Waveform",wavePreview,wave->len+1,0,NULL,0,wave->max,contentRegion);
|
||||||
|
} else {
|
||||||
|
PlotCustom("##Waveform",wavePreview,wave->len+1,0,NULL,0,wave->max,contentRegion,sizeof(float),ImVec4(1.0f,1.0f,1.0f,1.0f),0,NULL,true);
|
||||||
|
}
|
||||||
if (ImGui::IsItemClicked(ImGuiMouseButton_Left)) {
|
if (ImGui::IsItemClicked(ImGuiMouseButton_Left)) {
|
||||||
waveDragStart=ImGui::GetItemRectMin();
|
waveDragStart=ImGui::GetItemRectMin();
|
||||||
waveDragAreaSize=contentRegion;
|
waveDragAreaSize=contentRegion;
|
||||||
|
@ -159,6 +130,22 @@ void FurnaceGUI::drawWaveEdit() {
|
||||||
modified=true;
|
modified=true;
|
||||||
}
|
}
|
||||||
ImGui::PopStyleVar();
|
ImGui::PopStyleVar();
|
||||||
|
|
||||||
|
if (ImGui::RadioButton("Dec",!waveHex)) {
|
||||||
|
waveHex=false;
|
||||||
|
}
|
||||||
|
ImGui::SameLine();
|
||||||
|
if (ImGui::RadioButton("Hex",waveHex)) {
|
||||||
|
waveHex=true;
|
||||||
|
}
|
||||||
|
ImGui::SameLine();
|
||||||
|
ImGui::SetNextItemWidth(ImGui::GetContentRegionAvail().x); // wavetable text input size found here
|
||||||
|
if (ImGui::InputText("##MMLWave",&mmlStringW)) {
|
||||||
|
decodeMMLStrW(mmlStringW,wave->data,wave->len,wave->max,waveHex);
|
||||||
|
}
|
||||||
|
if (!ImGui::IsItemActive()) {
|
||||||
|
encodeMMLStr(mmlStringW,wave->data,wave->len,-1,-1,waveHex);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (ImGui::IsWindowFocused(ImGuiFocusedFlags_ChildWindows)) curWindow=GUI_WINDOW_WAVE_EDIT;
|
if (ImGui::IsWindowFocused(ImGuiFocusedFlags_ChildWindows)) curWindow=GUI_WINDOW_WAVE_EDIT;
|
||||||
|
|
Loading…
Reference in a new issue