GUI: add setting to customize the title bar

closes #339
This commit is contained in:
tildearrow 2022-04-04 13:25:38 -05:00
parent 81150d96fa
commit f89360392f
3 changed files with 77 additions and 4 deletions

View file

@ -544,14 +544,50 @@ void FurnaceGUI::setFileName(String name) {
curFileName=ret;
}
#endif
updateWindowTitle();
}
void FurnaceGUI::updateWindowTitle() {
String title;
switch (settings.titleBarInfo) {
case 0:
title="Furnace";
break;
case 1:
if (e->song.name.empty()) {
SDL_SetWindowTitle(sdlWin,fmt::sprintf("Furnace (%s)",e->getSongSystemName()).c_str());
title="Furnace";
} else {
SDL_SetWindowTitle(sdlWin,fmt::sprintf("%s - Furnace (%s)",e->song.name,e->getSongSystemName()).c_str());
title=fmt::sprintf("%s - Furnace",e->song.name);
}
break;
case 2:
if (curFileName.empty()) {
title="Furnace";
} else {
String shortName;
size_t pos=curFileName.rfind(DIR_SEPARATOR);
if (pos==String::npos) {
shortName=curFileName;
} else {
shortName=curFileName.substr(pos+1);
}
title=fmt::sprintf("%s - Furnace",shortName);
}
break;
case 3:
if (curFileName.empty()) {
title="Furnace";
} else {
title=fmt::sprintf("%s - Furnace",curFileName);
}
break;
}
if (settings.titleBarSys) {
title+=fmt::sprintf(" (%s)",e->getSongSystemName());
}
if (sdlWin!=NULL) SDL_SetWindowTitle(sdlWin,title.c_str());
}
const char* defaultLayout="[Window][DockSpaceViewport_11111111]\n\
@ -1502,6 +1538,7 @@ int FurnaceGUI::save(String path, int dmfVersion) {
w->finish();
curFileName=path;
modified=false;
updateWindowTitle();
if (!e->getWarnings().empty()) {
showWarning(e->getWarnings(),GUI_WARN_GENERIC);
}
@ -3064,6 +3101,8 @@ bool FurnaceGUI::finish() {
FurnaceGUI::FurnaceGUI():
e(NULL),
sdlWin(NULL),
sdlRend(NULL),
sampleTex(NULL),
sampleTexW(0),
sampleTexH(0),

View file

@ -733,6 +733,8 @@ class FurnaceGUI {
int susPosition;
int effectCursorDir;
int cursorPastePos;
int titleBarInfo;
int titleBarSys;
unsigned int maxUndoSteps;
String mainFontPath;
String patFontPath;
@ -789,6 +791,8 @@ class FurnaceGUI {
susPosition(0),
effectCursorDir(1),
cursorPastePos(1),
titleBarInfo(1),
titleBarSys(1),
maxUndoSteps(100),
mainFontPath(""),
patFontPath(""),

View file

@ -733,6 +733,30 @@ void FurnaceGUI::drawSettings() {
ImGui::Separator();
ImGui::Text("Title bar:");
if (ImGui::RadioButton("Furnace##tbar0",settings.titleBarInfo==0)) {
settings.titleBarInfo=0;
updateWindowTitle();
}
if (ImGui::RadioButton("Song Name - Furnace##tbar1",settings.titleBarInfo==1)) {
settings.titleBarInfo=1;
updateWindowTitle();
}
if (ImGui::RadioButton("file_name.fur - Furnace##tbar2",settings.titleBarInfo==2)) {
settings.titleBarInfo=2;
updateWindowTitle();
}
if (ImGui::RadioButton("/path/to/file.fur - Furnace##tbar3",settings.titleBarInfo==3)) {
settings.titleBarInfo=3;
updateWindowTitle();
}
bool titleBarSysB=settings.titleBarSys;
if (ImGui::Checkbox("Display system name on title bar",&titleBarSysB)) {
settings.titleBarSys=titleBarSysB;
updateWindowTitle();
}
ImGui::Text("Status bar:");
if (ImGui::RadioButton("Cursor details##sbar0",settings.statusDisplay==0)) {
settings.statusDisplay=0;
@ -1369,6 +1393,8 @@ void FurnaceGUI::syncSettings() {
settings.susPosition=e->getConfInt("susPosition",0);
settings.effectCursorDir=e->getConfInt("effectCursorDir",1);
settings.cursorPastePos=e->getConfInt("cursorPastePos",1);
settings.titleBarInfo=e->getConfInt("titleBarInfo",1);
settings.titleBarSys=e->getConfInt("titleBarSys",1);
clampSetting(settings.mainFontSize,2,96);
clampSetting(settings.patFontSize,2,96);
@ -1417,6 +1443,8 @@ void FurnaceGUI::syncSettings() {
clampSetting(settings.susPosition,0,1);
clampSetting(settings.effectCursorDir,0,1);
clampSetting(settings.cursorPastePos,0,1);
clampSetting(settings.titleBarInfo,0,3);
clampSetting(settings.titleBarSys,0,1);
// keybinds
LOAD_KEYBIND(GUI_ACTION_OPEN,FURKMOD_CMD|SDLK_o);
@ -1662,6 +1690,8 @@ void FurnaceGUI::commitSettings() {
e->setConf("susPosition",settings.susPosition);
e->setConf("effectCursorDir",settings.effectCursorDir);
e->setConf("cursorPastePos",settings.cursorPastePos);
e->setConf("titleBarInfo",settings.titleBarInfo);
e->setConf("titleBarSys",settings.titleBarSys);
PUT_UI_COLOR(GUI_COLOR_BACKGROUND);
PUT_UI_COLOR(GUI_COLOR_FRAME_BACKGROUND);