mirror of
https://github.com/tildearrow/furnace.git
synced 2024-11-23 21:15:11 +00:00
GUI: add default layout
This commit is contained in:
parent
39dee5a343
commit
f6144a3343
3 changed files with 110 additions and 7 deletions
110
src/gui/gui.cpp
110
src/gui/gui.cpp
|
@ -7,6 +7,8 @@
|
||||||
#include "fonts.h"
|
#include "fonts.h"
|
||||||
#include "../ta-log.h"
|
#include "../ta-log.h"
|
||||||
#include "imgui.h"
|
#include "imgui.h"
|
||||||
|
#include "imgui_impl_sdl.h"
|
||||||
|
#include "imgui_impl_sdlrenderer.h"
|
||||||
#include "imgui_internal.h"
|
#include "imgui_internal.h"
|
||||||
#include "ImGuiFileDialog.h"
|
#include "ImGuiFileDialog.h"
|
||||||
#include "plot_nolerp.h"
|
#include "plot_nolerp.h"
|
||||||
|
@ -157,6 +159,91 @@ void FurnaceGUI::updateWindowTitle() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const char* defaultLayout="[Window][DockSpaceViewport_11111111]\n\
|
||||||
|
Pos=0,24\n\
|
||||||
|
Size=1280,800\n\
|
||||||
|
Collapsed=0\n\
|
||||||
|
\n\
|
||||||
|
[Window][Debug##Default]\n\
|
||||||
|
Pos=60,60\n\
|
||||||
|
Size=400,400\n\
|
||||||
|
Collapsed=0\n\
|
||||||
|
\n\
|
||||||
|
[Window][Play/Edit Controls]\n\
|
||||||
|
Pos=351,24\n\
|
||||||
|
Size=220,231\n\
|
||||||
|
Collapsed=0\n\
|
||||||
|
DockId=0x00000007,0\n\
|
||||||
|
\n\
|
||||||
|
[Window][Song Information]\n\
|
||||||
|
Pos=904,24\n\
|
||||||
|
Size=376,231\n\
|
||||||
|
Collapsed=0\n\
|
||||||
|
DockId=0x00000004,0\n\
|
||||||
|
\n\
|
||||||
|
[Window][Orders]\n\
|
||||||
|
Pos=0,24\n\
|
||||||
|
Size=349,231\n\
|
||||||
|
Collapsed=0\n\
|
||||||
|
DockId=0x00000005,0\n\
|
||||||
|
\n\
|
||||||
|
[Window][Instruments]\n\
|
||||||
|
Pos=573,24\n\
|
||||||
|
Size=329,231\n\
|
||||||
|
Collapsed=0\n\
|
||||||
|
DockId=0x00000008,1\n\
|
||||||
|
\n\
|
||||||
|
[Window][Wavetables]\n\
|
||||||
|
Pos=573,24\n\
|
||||||
|
Size=329,231\n\
|
||||||
|
Collapsed=0\n\
|
||||||
|
DockId=0x00000008,2\n\
|
||||||
|
\n\
|
||||||
|
[Window][Samples]\n\
|
||||||
|
Pos=573,24\n\
|
||||||
|
Size=329,231\n\
|
||||||
|
Collapsed=0\n\
|
||||||
|
DockId=0x00000008,0\n\
|
||||||
|
\n\
|
||||||
|
[Window][Pattern]\n\
|
||||||
|
Pos=0,257\n\
|
||||||
|
Size=1280,800\n\
|
||||||
|
Collapsed=0\n\
|
||||||
|
DockId=0x00000002,0\n\
|
||||||
|
\n\
|
||||||
|
[Docking][Data]\n\
|
||||||
|
DockSpace ID=0x8B93E3BD Window=0xA787BDB4 Pos=0,24 Size=1280,800 Split=Y Selected=0x6C01C512\n\
|
||||||
|
DockNode ID=0x00000001 Parent=0x8B93E3BD SizeRef=1280,231 Split=X Selected=0xF3094A52\n\
|
||||||
|
DockNode ID=0x00000003 Parent=0x00000001 SizeRef=902,231 Split=X Selected=0x65CC51DC\n\
|
||||||
|
DockNode ID=0x00000005 Parent=0x00000003 SizeRef=349,231 Selected=0xE283F8D8\n\
|
||||||
|
DockNode ID=0x00000006 Parent=0x00000003 SizeRef=551,231 Split=X Selected=0x756E3877\n\
|
||||||
|
DockNode ID=0x00000007 Parent=0x00000006 SizeRef=220,231 Selected=0xD2BA8AA2\n\
|
||||||
|
DockNode ID=0x00000008 Parent=0x00000006 SizeRef=329,231 Selected=0x756E3877\n\
|
||||||
|
DockNode ID=0x00000004 Parent=0x00000001 SizeRef=376,231 Selected=0xF3094A52\n\
|
||||||
|
DockNode ID=0x00000002 Parent=0x8B93E3BD SizeRef=1280,498 CentralNode=1 Selected=0x6C01C512\n\
|
||||||
|
\n\
|
||||||
|
";
|
||||||
|
|
||||||
|
void FurnaceGUI::prepareLayout() {
|
||||||
|
FILE* check;
|
||||||
|
check=fopen(finalLayoutPath,"r");
|
||||||
|
if (check!=NULL) {
|
||||||
|
fclose(check);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// copy initial layout
|
||||||
|
logI("loading default layout.\n");
|
||||||
|
check=fopen(finalLayoutPath,"w");
|
||||||
|
if (check==NULL) {
|
||||||
|
logW("could not write default layout!\n");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
fwrite(defaultLayout,1,strlen(defaultLayout),check);
|
||||||
|
fclose(check);
|
||||||
|
}
|
||||||
|
|
||||||
void FurnaceGUI::drawEditControls() {
|
void FurnaceGUI::drawEditControls() {
|
||||||
if (!editControlsOpen) return;
|
if (!editControlsOpen) return;
|
||||||
if (ImGui::Begin("Play/Edit Controls",&editControlsOpen)) {
|
if (ImGui::Begin("Play/Edit Controls",&editControlsOpen)) {
|
||||||
|
@ -1545,16 +1632,16 @@ void FurnaceGUI::keyUp(SDL_Event& ev) {
|
||||||
void FurnaceGUI::openFileDialog(FurnaceGUIFileDialogs type) {
|
void FurnaceGUI::openFileDialog(FurnaceGUIFileDialogs type) {
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case GUI_FILE_OPEN:
|
case GUI_FILE_OPEN:
|
||||||
ImGuiFileDialog::Instance()->OpenDialog("FileDialog","Open File","DefleMask module{.dmf},.*",workingDir);
|
ImGuiFileDialog::Instance()->OpenModal("FileDialog","Open File","DefleMask module{.dmf},.*",workingDir);
|
||||||
break;
|
break;
|
||||||
case GUI_FILE_SAVE:
|
case GUI_FILE_SAVE:
|
||||||
ImGuiFileDialog::Instance()->OpenDialog("FileDialog","Save File","DefleMask module{.dmf}",workingDir);
|
ImGuiFileDialog::Instance()->OpenModal("FileDialog","Save File","DefleMask module{.dmf}",workingDir);
|
||||||
break;
|
break;
|
||||||
case GUI_FILE_SAMPLE_OPEN:
|
case GUI_FILE_SAMPLE_OPEN:
|
||||||
ImGuiFileDialog::Instance()->OpenDialog("FileDialog","Load Sample","Wave file{.wav},.*",workingDir);
|
ImGuiFileDialog::Instance()->OpenModal("FileDialog","Load Sample","Wave file{.wav},.*",workingDir);
|
||||||
break;
|
break;
|
||||||
case GUI_FILE_SAMPLE_SAVE:
|
case GUI_FILE_SAMPLE_SAVE:
|
||||||
ImGuiFileDialog::Instance()->OpenDialog("FileDialog","Save Sample","Wave file{.wav}",workingDir);
|
ImGuiFileDialog::Instance()->OpenModal("FileDialog","Save Sample","Wave file{.wav}",workingDir);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
curFileDialog=type;
|
curFileDialog=type;
|
||||||
|
@ -1965,10 +2052,11 @@ bool FurnaceGUI::init() {
|
||||||
|
|
||||||
sty.ScaleAllSizes(dpiScale);
|
sty.ScaleAllSizes(dpiScale);
|
||||||
|
|
||||||
strncpy(finalConfigPath,(e->getConfigPath()+String(LAYOUT_INI)).c_str(),4095);
|
strncpy(finalLayoutPath,(e->getConfigPath()+String(LAYOUT_INI)).c_str(),4095);
|
||||||
|
prepareLayout();
|
||||||
|
|
||||||
ImGui::GetIO().ConfigFlags|=ImGuiConfigFlags_DockingEnable;
|
ImGui::GetIO().ConfigFlags|=ImGuiConfigFlags_DockingEnable;
|
||||||
ImGui::GetIO().IniFilename=finalConfigPath;
|
ImGui::GetIO().IniFilename=finalLayoutPath;
|
||||||
|
|
||||||
if ((mainFont=ImGui::GetIO().Fonts->AddFontFromMemoryCompressedTTF(defFont_main_compressed_data,defFont_main_compressed_size,18*dpiScale))==NULL) {
|
if ((mainFont=ImGui::GetIO().Fonts->AddFontFromMemoryCompressedTTF(defFont_main_compressed_data,defFont_main_compressed_size,18*dpiScale))==NULL) {
|
||||||
logE("could not load UI font!\n");
|
logE("could not load UI font!\n");
|
||||||
|
@ -1992,6 +2080,16 @@ bool FurnaceGUI::init() {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool FurnaceGUI::finish() {
|
||||||
|
ImGui::SaveIniSettingsToDisk(finalLayoutPath);
|
||||||
|
ImGui_ImplSDLRenderer_Shutdown();
|
||||||
|
ImGui_ImplSDL2_Shutdown();
|
||||||
|
ImGui::DestroyContext();
|
||||||
|
SDL_DestroyRenderer(sdlRend);
|
||||||
|
SDL_DestroyWindow(sdlWin);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
FurnaceGUI::FurnaceGUI():
|
FurnaceGUI::FurnaceGUI():
|
||||||
e(NULL),
|
e(NULL),
|
||||||
quit(false),
|
quit(false),
|
||||||
|
|
|
@ -86,7 +86,7 @@ class FurnaceGUI {
|
||||||
ImVec4 uiColors[GUI_COLOR_MAX];
|
ImVec4 uiColors[GUI_COLOR_MAX];
|
||||||
ImVec4 volColors[128];
|
ImVec4 volColors[128];
|
||||||
|
|
||||||
char finalConfigPath[4096];
|
char finalLayoutPath[4096];
|
||||||
|
|
||||||
int curIns, curWave, curSample, curOctave, oldRow, editStep;
|
int curIns, curWave, curSample, curOctave, oldRow, editStep;
|
||||||
bool editControlsOpen, ordersOpen, insListOpen, songInfoOpen, patternOpen, insEditOpen;
|
bool editControlsOpen, ordersOpen, insListOpen, songInfoOpen, patternOpen, insEditOpen;
|
||||||
|
@ -123,6 +123,7 @@ class FurnaceGUI {
|
||||||
float nextScroll;
|
float nextScroll;
|
||||||
|
|
||||||
void updateWindowTitle();
|
void updateWindowTitle();
|
||||||
|
void prepareLayout();
|
||||||
|
|
||||||
void drawEditControls();
|
void drawEditControls();
|
||||||
void drawSongInfo();
|
void drawSongInfo();
|
||||||
|
@ -161,6 +162,7 @@ class FurnaceGUI {
|
||||||
void bindEngine(DivEngine* eng);
|
void bindEngine(DivEngine* eng);
|
||||||
void updateScroll(int amount);
|
void updateScroll(int amount);
|
||||||
bool loop();
|
bool loop();
|
||||||
|
bool finish();
|
||||||
bool init();
|
bool init();
|
||||||
FurnaceGUI();
|
FurnaceGUI();
|
||||||
};
|
};
|
||||||
|
|
|
@ -313,10 +313,13 @@ int main(int argc, char** argv) {
|
||||||
g.init();
|
g.init();
|
||||||
|
|
||||||
g.loop();
|
g.loop();
|
||||||
|
logI("closing GUI.\n");
|
||||||
|
g.finish();
|
||||||
#else
|
#else
|
||||||
logE("GUI requested but GUI not compiled!\n");
|
logE("GUI requested but GUI not compiled!\n");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
logI("stopping engine.\n");
|
||||||
e.quit();
|
e.quit();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue