mirror of
https://github.com/tildearrow/furnace.git
synced 2024-11-15 17:25:06 +00:00
GUI: Remember window x/y position and maximized state. Warning: This may cause issues when windows are re-ordered. Is there a way to fix windows spawning outside of screen boundaries?
This commit is contained in:
parent
e226d09807
commit
e88e0a4e4e
2 changed files with 52 additions and 17 deletions
|
@ -862,7 +862,7 @@ void FurnaceGUI::stopPreviewNote(SDL_Scancode scancode, bool autoNote) {
|
||||||
|
|
||||||
void FurnaceGUI::noteInput(int num, int key, int vol) {
|
void FurnaceGUI::noteInput(int num, int key, int vol) {
|
||||||
DivPattern* pat=e->curPat[cursor.xCoarse].getPattern(e->curOrders->ord[cursor.xCoarse][curOrder],true);
|
DivPattern* pat=e->curPat[cursor.xCoarse].getPattern(e->curOrders->ord[cursor.xCoarse][curOrder],true);
|
||||||
|
|
||||||
prepareUndo(GUI_UNDO_PATTERN_EDIT);
|
prepareUndo(GUI_UNDO_PATTERN_EDIT);
|
||||||
|
|
||||||
if (key==100) { // note off
|
if (key==100) { // note off
|
||||||
|
@ -2103,7 +2103,7 @@ void FurnaceGUI::editOptions(bool topMenu) {
|
||||||
snprintf(id,63,"%.2x##LatchFX",data);
|
snprintf(id,63,"%.2x##LatchFX",data);
|
||||||
ImGui::PushStyleColor(ImGuiCol_Text,uiColors[fxColors[data]]);
|
ImGui::PushStyleColor(ImGuiCol_Text,uiColors[fxColors[data]]);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ImGui::Selectable(id,latchTarget==3,ImGuiSelectableFlags_DontClosePopups)) {
|
if (ImGui::Selectable(id,latchTarget==3,ImGuiSelectableFlags_DontClosePopups)) {
|
||||||
latchTarget=3;
|
latchTarget=3;
|
||||||
latchNibble=false;
|
latchNibble=false;
|
||||||
|
@ -2176,7 +2176,7 @@ void FurnaceGUI::editOptions(bool topMenu) {
|
||||||
doTranspose(transposeAmount,opMaskTransposeValue);
|
doTranspose(transposeAmount,opMaskTransposeValue);
|
||||||
ImGui::CloseCurrentPopup();
|
ImGui::CloseCurrentPopup();
|
||||||
}
|
}
|
||||||
|
|
||||||
ImGui::Separator();
|
ImGui::Separator();
|
||||||
if (ImGui::MenuItem("interpolate",BIND_FOR(GUI_ACTION_PAT_INTERPOLATE))) doInterpolate();
|
if (ImGui::MenuItem("interpolate",BIND_FOR(GUI_ACTION_PAT_INTERPOLATE))) doInterpolate();
|
||||||
if (ImGui::BeginMenu("change instrument...")) {
|
if (ImGui::BeginMenu("change instrument...")) {
|
||||||
|
@ -2303,7 +2303,7 @@ void FurnaceGUI::toggleMobileUI(bool enable, bool force) {
|
||||||
if (mobileUI!=enable || force) {
|
if (mobileUI!=enable || force) {
|
||||||
if (!mobileUI && enable) {
|
if (!mobileUI && enable) {
|
||||||
ImGui::SaveIniSettingsToDisk(finalLayoutPath);
|
ImGui::SaveIniSettingsToDisk(finalLayoutPath);
|
||||||
}
|
}
|
||||||
mobileUI=enable;
|
mobileUI=enable;
|
||||||
if (mobileUI) {
|
if (mobileUI) {
|
||||||
ImGui::GetIO().IniFilename=NULL;
|
ImGui::GetIO().IniFilename=NULL;
|
||||||
|
@ -2311,7 +2311,7 @@ void FurnaceGUI::toggleMobileUI(bool enable, bool force) {
|
||||||
ImGui::GetIO().IniFilename=finalLayoutPath;
|
ImGui::GetIO().IniFilename=finalLayoutPath;
|
||||||
ImGui::LoadIniSettingsFromDisk(finalLayoutPath);
|
ImGui::LoadIniSettingsFromDisk(finalLayoutPath);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int _processEvent(void* instance, SDL_Event* event) {
|
int _processEvent(void* instance, SDL_Event* event) {
|
||||||
|
@ -2536,6 +2536,7 @@ bool FurnaceGUI::loop() {
|
||||||
if (settings.powerSave) SDL_WaitEventTimeout(NULL,500);
|
if (settings.powerSave) SDL_WaitEventTimeout(NULL,500);
|
||||||
}
|
}
|
||||||
eventTimeBegin=SDL_GetPerformanceCounter();
|
eventTimeBegin=SDL_GetPerformanceCounter();
|
||||||
|
bool updateWindow = false;
|
||||||
while (SDL_PollEvent(&ev)) {
|
while (SDL_PollEvent(&ev)) {
|
||||||
WAKE_UP;
|
WAKE_UP;
|
||||||
ImGui_ImplSDL2_ProcessEvent(&ev);
|
ImGui_ImplSDL2_ProcessEvent(&ev);
|
||||||
|
@ -2642,6 +2643,20 @@ bool FurnaceGUI::loop() {
|
||||||
scrW=ev.window.data1/dpiScale;
|
scrW=ev.window.data1/dpiScale;
|
||||||
scrH=ev.window.data2/dpiScale;
|
scrH=ev.window.data2/dpiScale;
|
||||||
#endif
|
#endif
|
||||||
|
updateWindow=true;
|
||||||
|
break;
|
||||||
|
case SDL_WINDOWEVENT_MOVED:
|
||||||
|
scrX=ev.window.data1;
|
||||||
|
scrY=ev.window.data2;
|
||||||
|
updateWindow=true;
|
||||||
|
break;
|
||||||
|
case SDL_WINDOWEVENT_MAXIMIZED:
|
||||||
|
scrMax=true;
|
||||||
|
updateWindow=true;
|
||||||
|
break;
|
||||||
|
case SDL_WINDOWEVENT_RESTORED:
|
||||||
|
scrMax=false;
|
||||||
|
updateWindow=true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -2697,6 +2712,18 @@ bool FurnaceGUI::loop() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// update config x/y/w/h values based on scrMax state
|
||||||
|
if(updateWindow) {
|
||||||
|
if(scrMax) {
|
||||||
|
scrConfY=scrConfX = SDL_WINDOWPOS_CENTERED_DISPLAY(SDL_GetWindowDisplayIndex(sdlWin));
|
||||||
|
} else {
|
||||||
|
scrConfX=scrX;
|
||||||
|
scrConfY=scrY;
|
||||||
|
scrConfW=scrW;
|
||||||
|
scrConfH=scrH;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
wantCaptureKeyboard=ImGui::GetIO().WantTextInput;
|
wantCaptureKeyboard=ImGui::GetIO().WantTextInput;
|
||||||
|
|
||||||
if (wantCaptureKeyboard!=oldWantCaptureKeyboard) {
|
if (wantCaptureKeyboard!=oldWantCaptureKeyboard) {
|
||||||
|
@ -2714,7 +2741,7 @@ bool FurnaceGUI::loop() {
|
||||||
if (ImGui::GetIO().MouseDown[0] || ImGui::GetIO().MouseDown[1] || ImGui::GetIO().MouseDown[2] || ImGui::GetIO().MouseDown[3] || ImGui::GetIO().MouseDown[4]) {
|
if (ImGui::GetIO().MouseDown[0] || ImGui::GetIO().MouseDown[1] || ImGui::GetIO().MouseDown[2] || ImGui::GetIO().MouseDown[3] || ImGui::GetIO().MouseDown[4]) {
|
||||||
WAKE_UP;
|
WAKE_UP;
|
||||||
}
|
}
|
||||||
|
|
||||||
while (true) {
|
while (true) {
|
||||||
midiLock.lock();
|
midiLock.lock();
|
||||||
if (midiQueue.empty()) {
|
if (midiQueue.empty()) {
|
||||||
|
@ -2870,7 +2897,7 @@ bool FurnaceGUI::loop() {
|
||||||
eventTimeEnd=SDL_GetPerformanceCounter();
|
eventTimeEnd=SDL_GetPerformanceCounter();
|
||||||
|
|
||||||
layoutTimeBegin=SDL_GetPerformanceCounter();
|
layoutTimeBegin=SDL_GetPerformanceCounter();
|
||||||
|
|
||||||
ImGui_ImplSDLRenderer_NewFrame();
|
ImGui_ImplSDLRenderer_NewFrame();
|
||||||
ImGui_ImplSDL2_NewFrame(sdlWin);
|
ImGui_ImplSDL2_NewFrame(sdlWin);
|
||||||
ImGui::NewFrame();
|
ImGui::NewFrame();
|
||||||
|
@ -3125,7 +3152,7 @@ bool FurnaceGUI::loop() {
|
||||||
if (ImGui::MenuItem("log viewer",BIND_FOR(GUI_ACTION_WINDOW_LOG),logOpen)) logOpen=!logOpen;
|
if (ImGui::MenuItem("log viewer",BIND_FOR(GUI_ACTION_WINDOW_LOG),logOpen)) logOpen=!logOpen;
|
||||||
if (ImGui::MenuItem("statistics",BIND_FOR(GUI_ACTION_WINDOW_STATS),statsOpen)) statsOpen=!statsOpen;
|
if (ImGui::MenuItem("statistics",BIND_FOR(GUI_ACTION_WINDOW_STATS),statsOpen)) statsOpen=!statsOpen;
|
||||||
if (spoilerOpen) if (ImGui::MenuItem("spoiler",NULL,spoilerOpen)) spoilerOpen=!spoilerOpen;
|
if (spoilerOpen) if (ImGui::MenuItem("spoiler",NULL,spoilerOpen)) spoilerOpen=!spoilerOpen;
|
||||||
|
|
||||||
ImGui::EndMenu();
|
ImGui::EndMenu();
|
||||||
}
|
}
|
||||||
if (ImGui::BeginMenu("help")) {
|
if (ImGui::BeginMenu("help")) {
|
||||||
|
@ -4263,7 +4290,7 @@ bool FurnaceGUI::loop() {
|
||||||
}
|
}
|
||||||
logD("saving backup...");
|
logD("saving backup...");
|
||||||
SafeWriter* w=e->saveFur(true);
|
SafeWriter* w=e->saveFur(true);
|
||||||
|
|
||||||
if (w!=NULL) {
|
if (w!=NULL) {
|
||||||
FILE* outFile=ps_fopen(backupPath.c_str(),"wb");
|
FILE* outFile=ps_fopen(backupPath.c_str(),"wb");
|
||||||
if (outFile!=NULL) {
|
if (outFile!=NULL) {
|
||||||
|
@ -4436,8 +4463,11 @@ bool FurnaceGUI::init() {
|
||||||
SDL_Surface* icon=SDL_CreateRGBSurfaceFrom(furIcon,256,256,32,256*4,0xff,0xff00,0xff0000,0xff000000);
|
SDL_Surface* icon=SDL_CreateRGBSurfaceFrom(furIcon,256,256,32,256*4,0xff,0xff00,0xff0000,0xff000000);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
scrW=e->getConfInt("lastWindowWidth",1280);
|
scrW=scrConfW=e->getConfInt("lastWindowWidth",1280);
|
||||||
scrH=e->getConfInt("lastWindowHeight",800);
|
scrH=scrConfH=e->getConfInt("lastWindowHeight",800);
|
||||||
|
scrX=scrConfX=e->getConfInt("lastWindowX",SDL_WINDOWPOS_CENTERED);
|
||||||
|
scrY=scrConfY=e->getConfInt("lastWindowY",SDL_WINDOWPOS_CENTERED);
|
||||||
|
scrMax=e->getConfBool("lastWindowMax",false);
|
||||||
|
|
||||||
#ifndef __APPLE__
|
#ifndef __APPLE__
|
||||||
SDL_Rect displaySize;
|
SDL_Rect displaySize;
|
||||||
|
@ -4453,7 +4483,7 @@ bool FurnaceGUI::init() {
|
||||||
|
|
||||||
SDL_Init(SDL_INIT_VIDEO);
|
SDL_Init(SDL_INIT_VIDEO);
|
||||||
|
|
||||||
sdlWin=SDL_CreateWindow("Furnace",SDL_WINDOWPOS_CENTERED,SDL_WINDOWPOS_CENTERED,scrW*dpiScale,scrH*dpiScale,SDL_WINDOW_RESIZABLE|SDL_WINDOW_ALLOW_HIGHDPI|(fullScreen?SDL_WINDOW_FULLSCREEN_DESKTOP:0));
|
sdlWin=SDL_CreateWindow("Furnace",scrX,scrY,scrW*dpiScale,scrH*dpiScale,SDL_WINDOW_RESIZABLE|SDL_WINDOW_ALLOW_HIGHDPI|(scrMax?SDL_WINDOW_MAXIMIZED:0)|(fullScreen?SDL_WINDOW_FULLSCREEN_DESKTOP:0));
|
||||||
if (sdlWin==NULL) {
|
if (sdlWin==NULL) {
|
||||||
logE("could not open window! %s",SDL_GetError());
|
logE("could not open window! %s",SDL_GetError());
|
||||||
return false;
|
return false;
|
||||||
|
@ -4619,8 +4649,11 @@ bool FurnaceGUI::finish() {
|
||||||
e->setConf("spoilerOpen",spoilerOpen);
|
e->setConf("spoilerOpen",spoilerOpen);
|
||||||
|
|
||||||
// commit last window size
|
// commit last window size
|
||||||
e->setConf("lastWindowWidth",scrW);
|
e->setConf("lastWindowWidth",scrConfW);
|
||||||
e->setConf("lastWindowHeight",scrH);
|
e->setConf("lastWindowHeight",scrConfH);
|
||||||
|
e->setConf("lastWindowX",scrConfX);
|
||||||
|
e->setConf("lastWindowY",scrConfY);
|
||||||
|
e->setConf("lastWindowMax",scrMax);
|
||||||
|
|
||||||
e->setConf("tempoView",tempoView);
|
e->setConf("tempoView",tempoView);
|
||||||
e->setConf("waveHex",waveHex);
|
e->setConf("waveHex",waveHex);
|
||||||
|
|
|
@ -996,7 +996,9 @@ class FurnaceGUI {
|
||||||
|
|
||||||
FurnaceGUIFileDialog* fileDialog;
|
FurnaceGUIFileDialog* fileDialog;
|
||||||
|
|
||||||
int scrW, scrH;
|
int scrW, scrH, scrConfW, scrConfH;
|
||||||
|
int scrX, scrY, scrConfX, scrConfY;
|
||||||
|
bool scrMax;
|
||||||
|
|
||||||
double dpiScale;
|
double dpiScale;
|
||||||
|
|
||||||
|
@ -1429,7 +1431,7 @@ class FurnaceGUI {
|
||||||
int chanToMove;
|
int chanToMove;
|
||||||
|
|
||||||
ImVec2 patWindowPos, patWindowSize;
|
ImVec2 patWindowPos, patWindowSize;
|
||||||
|
|
||||||
// pattern view specific
|
// pattern view specific
|
||||||
ImVec2 fourChars, threeChars, twoChars;
|
ImVec2 fourChars, threeChars, twoChars;
|
||||||
ImVec2 noteCellSize, insCellSize, volCellSize, effectCellSize, effectValCellSize;
|
ImVec2 noteCellSize, insCellSize, volCellSize, effectCellSize, effectValCellSize;
|
||||||
|
@ -1505,7 +1507,7 @@ class FurnaceGUI {
|
||||||
// visualizer
|
// visualizer
|
||||||
float keyHit[DIV_MAX_CHANS];
|
float keyHit[DIV_MAX_CHANS];
|
||||||
int lastIns[DIV_MAX_CHANS];
|
int lastIns[DIV_MAX_CHANS];
|
||||||
|
|
||||||
// log window
|
// log window
|
||||||
bool followLog;
|
bool followLog;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue