mirror of
https://github.com/tildearrow/furnace.git
synced 2024-12-29 19:11:23 +00:00
Merge pull request #644 from NatsumiFox/master
GUI: Remember window x/y position and maximized state.
This commit is contained in:
commit
43100fbbee
3 changed files with 111 additions and 29 deletions
|
@ -883,7 +883,7 @@ void FurnaceGUI::stopPreviewNote(SDL_Scancode scancode, bool autoNote) {
|
|||
|
||||
void FurnaceGUI::noteInput(int num, int key, int vol) {
|
||||
DivPattern* pat=e->curPat[cursor.xCoarse].getPattern(e->curOrders->ord[cursor.xCoarse][curOrder],true);
|
||||
|
||||
|
||||
prepareUndo(GUI_UNDO_PATTERN_EDIT);
|
||||
|
||||
if (key==100) { // note off
|
||||
|
@ -2174,7 +2174,7 @@ void FurnaceGUI::editOptions(bool topMenu) {
|
|||
snprintf(id,63,"%.2x##LatchFX",data);
|
||||
ImGui::PushStyleColor(ImGuiCol_Text,uiColors[fxColors[data]]);
|
||||
}
|
||||
|
||||
|
||||
if (ImGui::Selectable(id,latchTarget==3,ImGuiSelectableFlags_DontClosePopups)) {
|
||||
latchTarget=3;
|
||||
latchNibble=false;
|
||||
|
@ -2247,7 +2247,7 @@ void FurnaceGUI::editOptions(bool topMenu) {
|
|||
doTranspose(transposeAmount,opMaskTransposeValue);
|
||||
ImGui::CloseCurrentPopup();
|
||||
}
|
||||
|
||||
|
||||
ImGui::Separator();
|
||||
if (ImGui::MenuItem("interpolate",BIND_FOR(GUI_ACTION_PAT_INTERPOLATE))) doInterpolate();
|
||||
if (ImGui::BeginMenu("change instrument...")) {
|
||||
|
@ -2374,7 +2374,7 @@ void FurnaceGUI::toggleMobileUI(bool enable, bool force) {
|
|||
if (mobileUI!=enable || force) {
|
||||
if (!mobileUI && enable) {
|
||||
ImGui::SaveIniSettingsToDisk(finalLayoutPath);
|
||||
}
|
||||
}
|
||||
mobileUI=enable;
|
||||
if (mobileUI) {
|
||||
ImGui::GetIO().IniFilename=NULL;
|
||||
|
@ -2382,7 +2382,7 @@ void FurnaceGUI::toggleMobileUI(bool enable, bool force) {
|
|||
ImGui::GetIO().IniFilename=finalLayoutPath;
|
||||
ImGui::LoadIniSettingsFromDisk(finalLayoutPath);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int _processEvent(void* instance, SDL_Event* event) {
|
||||
|
@ -2588,6 +2588,35 @@ void FurnaceGUI::processPoint(SDL_Event& ev) {
|
|||
}
|
||||
}
|
||||
|
||||
// how many pixels should be visible at least at x/y dir
|
||||
#define OOB_PIXELS_SAFETY 25
|
||||
|
||||
bool FurnaceGUI::detectOutOfBoundsWindow() {
|
||||
int count = SDL_GetNumVideoDisplays();
|
||||
if(count < 1) {
|
||||
logW("bounds check: error %s", SDL_GetError());
|
||||
return false;
|
||||
}
|
||||
|
||||
SDL_Rect rect;
|
||||
for(int i = 0;i < count;i ++) {
|
||||
if(SDL_GetDisplayUsableBounds(i, &rect) != 0) {
|
||||
logW("bounds check: error %s", SDL_GetError());
|
||||
return false;
|
||||
}
|
||||
|
||||
bool xbound = (rect.x + OOB_PIXELS_SAFETY) <= (scrX + scrW) && (rect.x + rect.w - OOB_PIXELS_SAFETY) >= scrX;
|
||||
bool ybound = (rect.y + OOB_PIXELS_SAFETY) <= (scrY + scrH) && (rect.y + rect.h - OOB_PIXELS_SAFETY) >= scrY;
|
||||
logD("bounds check: display %d is at %dx%dx%dx%d: %s%s", i, rect.x + OOB_PIXELS_SAFETY, rect.y + OOB_PIXELS_SAFETY, rect.x + rect.w - OOB_PIXELS_SAFETY, rect.y + rect.h - OOB_PIXELS_SAFETY, xbound ? "x" : "", ybound ? "y" : "");
|
||||
|
||||
if(xbound && ybound) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool FurnaceGUI::loop() {
|
||||
bool doThreadedInput=!settings.noThreadedInput;
|
||||
if (doThreadedInput) {
|
||||
|
@ -2607,6 +2636,7 @@ bool FurnaceGUI::loop() {
|
|||
if (settings.powerSave) SDL_WaitEventTimeout(NULL,500);
|
||||
}
|
||||
eventTimeBegin=SDL_GetPerformanceCounter();
|
||||
bool updateWindow = false;
|
||||
while (SDL_PollEvent(&ev)) {
|
||||
WAKE_UP;
|
||||
ImGui_ImplSDL2_ProcessEvent(&ev);
|
||||
|
@ -2713,6 +2743,20 @@ bool FurnaceGUI::loop() {
|
|||
scrW=ev.window.data1/dpiScale;
|
||||
scrH=ev.window.data2/dpiScale;
|
||||
#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;
|
||||
|
@ -2768,6 +2812,16 @@ bool FurnaceGUI::loop() {
|
|||
}
|
||||
}
|
||||
|
||||
// update config x/y/w/h values based on scrMax state
|
||||
if(updateWindow) {
|
||||
if(!scrMax) {
|
||||
scrConfX=scrX;
|
||||
scrConfY=scrY;
|
||||
scrConfW=scrW;
|
||||
scrConfH=scrH;
|
||||
}
|
||||
}
|
||||
|
||||
wantCaptureKeyboard=ImGui::GetIO().WantTextInput;
|
||||
|
||||
if (wantCaptureKeyboard!=oldWantCaptureKeyboard) {
|
||||
|
@ -2785,7 +2839,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]) {
|
||||
WAKE_UP;
|
||||
}
|
||||
|
||||
|
||||
while (true) {
|
||||
midiLock.lock();
|
||||
if (midiQueue.empty()) {
|
||||
|
@ -2941,7 +2995,7 @@ bool FurnaceGUI::loop() {
|
|||
eventTimeEnd=SDL_GetPerformanceCounter();
|
||||
|
||||
layoutTimeBegin=SDL_GetPerformanceCounter();
|
||||
|
||||
|
||||
ImGui_ImplSDLRenderer_NewFrame();
|
||||
ImGui_ImplSDL2_NewFrame(sdlWin);
|
||||
ImGui::NewFrame();
|
||||
|
@ -3205,7 +3259,7 @@ bool FurnaceGUI::loop() {
|
|||
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 (spoilerOpen) if (ImGui::MenuItem("spoiler",NULL,spoilerOpen)) spoilerOpen=!spoilerOpen;
|
||||
|
||||
|
||||
ImGui::EndMenu();
|
||||
}
|
||||
if (ImGui::BeginMenu("help")) {
|
||||
|
@ -4346,7 +4400,7 @@ bool FurnaceGUI::loop() {
|
|||
}
|
||||
logD("saving backup...");
|
||||
SafeWriter* w=e->saveFur(true);
|
||||
|
||||
|
||||
if (w!=NULL) {
|
||||
FILE* outFile=ps_fopen(backupPath.c_str(),"wb");
|
||||
if (outFile!=NULL) {
|
||||
|
@ -4519,8 +4573,11 @@ bool FurnaceGUI::init() {
|
|||
SDL_Surface* icon=SDL_CreateRGBSurfaceFrom(furIcon,256,256,32,256*4,0xff,0xff00,0xff0000,0xff000000);
|
||||
#endif
|
||||
|
||||
scrW=e->getConfInt("lastWindowWidth",1280);
|
||||
scrH=e->getConfInt("lastWindowHeight",800);
|
||||
scrW=scrConfW=e->getConfInt("lastWindowWidth",1280);
|
||||
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__
|
||||
SDL_Rect displaySize;
|
||||
|
@ -4536,7 +4593,14 @@ bool FurnaceGUI::init() {
|
|||
|
||||
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));
|
||||
// if window would spawn out of bounds, force it to be get default position
|
||||
if(!detectOutOfBoundsWindow()) {
|
||||
scrMax = false;
|
||||
scrX=scrConfX=SDL_WINDOWPOS_CENTERED;
|
||||
scrY=scrConfY=SDL_WINDOWPOS_CENTERED;
|
||||
}
|
||||
|
||||
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) {
|
||||
logE("could not open window! %s",SDL_GetError());
|
||||
return false;
|
||||
|
@ -4702,8 +4766,11 @@ bool FurnaceGUI::finish() {
|
|||
e->setConf("spoilerOpen",spoilerOpen);
|
||||
|
||||
// commit last window size
|
||||
e->setConf("lastWindowWidth",scrW);
|
||||
e->setConf("lastWindowHeight",scrH);
|
||||
e->setConf("lastWindowWidth",scrConfW);
|
||||
e->setConf("lastWindowHeight",scrConfH);
|
||||
e->setConf("lastWindowX",settings.saveWindowPos?scrConfX:(int)SDL_WINDOWPOS_CENTERED);
|
||||
e->setConf("lastWindowY",settings.saveWindowPos?scrConfY:(int)SDL_WINDOWPOS_CENTERED);
|
||||
e->setConf("lastWindowMax",scrMax);
|
||||
|
||||
e->setConf("tempoView",tempoView);
|
||||
e->setConf("waveHex",waveHex);
|
||||
|
|
|
@ -1010,7 +1010,9 @@ class FurnaceGUI {
|
|||
|
||||
FurnaceGUIFileDialog* fileDialog;
|
||||
|
||||
int scrW, scrH;
|
||||
int scrW, scrH, scrConfW, scrConfH;
|
||||
int scrX, scrY, scrConfX, scrConfY;
|
||||
bool scrMax;
|
||||
|
||||
double dpiScale;
|
||||
|
||||
|
@ -1144,6 +1146,7 @@ class FurnaceGUI {
|
|||
int dragMovesSelection;
|
||||
int unsignedDetune;
|
||||
int noThreadedInput;
|
||||
int saveWindowPos;
|
||||
int clampSamples;
|
||||
int saveUnusedPatterns;
|
||||
int channelColors;
|
||||
|
@ -1451,7 +1454,7 @@ class FurnaceGUI {
|
|||
int chanToMove, sysToMove, sysToDelete;
|
||||
|
||||
ImVec2 patWindowPos, patWindowSize;
|
||||
|
||||
|
||||
// pattern view specific
|
||||
ImVec2 fourChars, threeChars, twoChars;
|
||||
ImVec2 noteCellSize, insCellSize, volCellSize, effectCellSize, effectValCellSize;
|
||||
|
@ -1527,7 +1530,7 @@ class FurnaceGUI {
|
|||
// visualizer
|
||||
float keyHit[DIV_MAX_CHANS];
|
||||
int lastIns[DIV_MAX_CHANS];
|
||||
|
||||
|
||||
// log window
|
||||
bool followLog;
|
||||
|
||||
|
@ -1731,6 +1734,7 @@ class FurnaceGUI {
|
|||
void runBackupThread();
|
||||
void pushPartBlend();
|
||||
void popPartBlend();
|
||||
bool detectOutOfBoundsWindow();
|
||||
int processEvent(SDL_Event* ev);
|
||||
bool loop();
|
||||
bool finish();
|
||||
|
|
|
@ -264,7 +264,7 @@ void FurnaceGUI::drawSettings() {
|
|||
}
|
||||
|
||||
ImGui::Separator();
|
||||
|
||||
|
||||
ImGui::Text("Initial system:");
|
||||
ImGui::SameLine();
|
||||
if (ImGui::Button("Current system")) {
|
||||
|
@ -374,7 +374,7 @@ void FurnaceGUI::drawSettings() {
|
|||
} rightClickable
|
||||
ImGui::SetNextItemWidth(ImGui::GetContentRegionAvail().x-(50.0f*dpiScale));
|
||||
CWSliderScalar("Panning",ImGuiDataType_S8,&settings.initialSys[i+2],&_MINUS_ONE_HUNDRED_TWENTY_SEVEN,&_ONE_HUNDRED_TWENTY_SEVEN); rightClickable
|
||||
|
||||
|
||||
// oh please MSVC don't cry
|
||||
if (ImGui::TreeNode("Configure")) {
|
||||
drawSysConf(-1,(DivSystem)settings.initialSys[i],(unsigned int&)settings.initialSys[i+3],false);
|
||||
|
@ -457,7 +457,7 @@ void FurnaceGUI::drawSettings() {
|
|||
if (ImGui::Checkbox("Double click selects entire column",&doubleClickColumnB)) {
|
||||
settings.doubleClickColumn=doubleClickColumnB;
|
||||
}
|
||||
|
||||
|
||||
bool allowEditDockingB=settings.allowEditDocking;
|
||||
if (ImGui::Checkbox("Allow docking editors",&allowEditDockingB)) {
|
||||
settings.allowEditDocking=allowEditDockingB;
|
||||
|
@ -514,6 +514,14 @@ void FurnaceGUI::drawSettings() {
|
|||
ImGui::SetTooltip("threaded input processes key presses for note preview on a separate thread (on supported platforms), which reduces latency.\nhowever, crashes have been reported when threaded input is on. enable this option if that is the case.");
|
||||
}
|
||||
|
||||
bool saveWindowPosB=settings.saveWindowPos;
|
||||
if (ImGui::Checkbox("Remember window location",&saveWindowPosB)) {
|
||||
settings.saveWindowPos=saveWindowPosB;
|
||||
}
|
||||
if (ImGui::IsItemHovered()) {
|
||||
ImGui::SetTooltip("remembers where window was last located on start-up. When disabled, window will start in a defaul location.");
|
||||
}
|
||||
|
||||
bool blankInsB=settings.blankIns;
|
||||
if (ImGui::Checkbox("New instruments are blank",&blankInsB)) {
|
||||
settings.blankIns=blankInsB;
|
||||
|
@ -644,7 +652,7 @@ void FurnaceGUI::drawSettings() {
|
|||
BUFFER_SIZE_SELECTABLE(2048);
|
||||
ImGui::EndCombo();
|
||||
}
|
||||
|
||||
|
||||
ImGui::Text("Quality");
|
||||
ImGui::SameLine();
|
||||
ImGui::Combo("##Quality",&settings.audioQuality,audioQualities,2);
|
||||
|
@ -702,7 +710,7 @@ void FurnaceGUI::drawSettings() {
|
|||
}
|
||||
|
||||
if (hasToReloadMidi) {
|
||||
midiMap.read(e->getConfigPath()+DIR_SEPARATOR_STR+"midiIn_"+stripName(settings.midiInDevice)+".cfg");
|
||||
midiMap.read(e->getConfigPath()+DIR_SEPARATOR_STR+"midiIn_"+stripName(settings.midiInDevice)+".cfg");
|
||||
midiMap.compile();
|
||||
}
|
||||
|
||||
|
@ -1379,7 +1387,7 @@ void FurnaceGUI::drawSettings() {
|
|||
if (ImGui::Checkbox("Unsigned FM detune values",&unsignedDetuneB)) {
|
||||
settings.unsignedDetune=unsignedDetuneB;
|
||||
}
|
||||
|
||||
|
||||
// sorry. temporarily disabled until ImGui has a way to add separators in tables arbitrarily.
|
||||
/*bool sysSeparatorsB=settings.sysSeparators;
|
||||
if (ImGui::Checkbox("Add separators between systems in Orders",&sysSeparatorsB)) {
|
||||
|
@ -1588,12 +1596,12 @@ void FurnaceGUI::drawSettings() {
|
|||
UI_COLOR_CONFIG(GUI_COLOR_FM_SECONDARY_MOD,"Mod. accent (secondary)");
|
||||
UI_COLOR_CONFIG(GUI_COLOR_FM_BORDER_MOD,"Mod. border");
|
||||
UI_COLOR_CONFIG(GUI_COLOR_FM_BORDER_SHADOW_MOD,"Mod. border shadow");
|
||||
|
||||
|
||||
UI_COLOR_CONFIG(GUI_COLOR_FM_PRIMARY_CAR,"Car. accent (primary");
|
||||
UI_COLOR_CONFIG(GUI_COLOR_FM_SECONDARY_CAR,"Car. accent (secondary)");
|
||||
UI_COLOR_CONFIG(GUI_COLOR_FM_BORDER_CAR,"Car. border");
|
||||
UI_COLOR_CONFIG(GUI_COLOR_FM_BORDER_SHADOW_CAR,"Car. border shadow");
|
||||
|
||||
|
||||
ImGui::TreePop();
|
||||
}
|
||||
if (ImGui::TreeNode("Macro Editor")) {
|
||||
|
@ -1952,7 +1960,7 @@ void FurnaceGUI::drawSettings() {
|
|||
UI_KEYBIND_CONFIG(GUI_ACTION_PAT_COLLAPSE_ROWS);
|
||||
UI_KEYBIND_CONFIG(GUI_ACTION_PAT_EXPAND_ROWS);
|
||||
UI_KEYBIND_CONFIG(GUI_ACTION_PAT_LATCH);
|
||||
|
||||
|
||||
// TODO: collapse/expand pattern and song
|
||||
|
||||
KEYBIND_CONFIG_END;
|
||||
|
@ -2251,6 +2259,7 @@ void FurnaceGUI::syncSettings() {
|
|||
settings.dragMovesSelection=e->getConfInt("dragMovesSelection",2);
|
||||
settings.unsignedDetune=e->getConfInt("unsignedDetune",0);
|
||||
settings.noThreadedInput=e->getConfInt("noThreadedInput",0);
|
||||
settings.saveWindowPos=e->getConfInt("saveWindowPos",1);
|
||||
settings.initialSysName=e->getConfString("initialSysName","");
|
||||
settings.clampSamples=e->getConfInt("clampSamples",0);
|
||||
settings.noteOffLabel=e->getConfString("noteOffLabel","OFF");
|
||||
|
@ -2354,6 +2363,7 @@ void FurnaceGUI::syncSettings() {
|
|||
clampSetting(settings.dragMovesSelection,0,2);
|
||||
clampSetting(settings.unsignedDetune,0,1);
|
||||
clampSetting(settings.noThreadedInput,0,1);
|
||||
clampSetting(settings.saveWindowPos,0,1);
|
||||
clampSetting(settings.clampSamples,0,1);
|
||||
clampSetting(settings.saveUnusedPatterns,0,1);
|
||||
clampSetting(settings.channelColors,0,2);
|
||||
|
@ -2385,7 +2395,7 @@ void FurnaceGUI::syncSettings() {
|
|||
|
||||
parseKeybinds();
|
||||
|
||||
midiMap.read(e->getConfigPath()+DIR_SEPARATOR_STR+"midiIn_"+stripName(settings.midiInDevice)+".cfg");
|
||||
midiMap.read(e->getConfigPath()+DIR_SEPARATOR_STR+"midiIn_"+stripName(settings.midiInDevice)+".cfg");
|
||||
midiMap.compile();
|
||||
|
||||
e->setMidiDirect(midiMap.directChannel);
|
||||
|
@ -2502,6 +2512,7 @@ void FurnaceGUI::commitSettings() {
|
|||
e->setConf("dragMovesSelection",settings.dragMovesSelection);
|
||||
e->setConf("unsignedDetune",settings.unsignedDetune);
|
||||
e->setConf("noThreadedInput",settings.noThreadedInput);
|
||||
e->setConf("saveWindowPos",settings.saveWindowPos);
|
||||
e->setConf("clampSamples",settings.clampSamples);
|
||||
e->setConf("noteOffLabel",settings.noteOffLabel);
|
||||
e->setConf("noteRelLabel",settings.noteRelLabel);
|
||||
|
@ -3180,7 +3191,7 @@ void FurnaceGUI::applyUISettings(bool updateFonts) {
|
|||
if ((iconFont=ImGui::GetIO().Fonts->AddFontFromMemoryCompressedTTF(iconFont_compressed_data,iconFont_compressed_size,e->getConfInt("iconSize",16)*dpiScale,&fc,fontRangeIcon))==NULL) {
|
||||
logE("could not load icon font!");
|
||||
}
|
||||
|
||||
|
||||
if (settings.mainFontSize==settings.patFontSize && settings.patFont<5 && builtinFontM[settings.patFont]==builtinFont[settings.mainFont]) {
|
||||
logD("using main font for pat font.");
|
||||
patFont=mainFont;
|
||||
|
@ -3214,7 +3225,7 @@ void FurnaceGUI::applyUISettings(bool updateFonts) {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if ((bigFont=ImGui::GetIO().Fonts->AddFontFromMemoryCompressedTTF(font_plexSans_compressed_data,font_plexSans_compressed_size,40*dpiScale))==NULL) {
|
||||
logE("could not load big UI font!");
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue