Skip to content

Commit

Permalink
Fullscreen mode used to be a global setting. It is now a per-profile …
Browse files Browse the repository at this point in the history
…setting. By default the kiosk profile has this set to true. Other profiles (main, basic) have this set to false by default.
  • Loading branch information
bluescan committed Aug 15, 2023
1 parent 91cfb5a commit 192bded
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 19 deletions.
2 changes: 1 addition & 1 deletion .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
"type": "cppvsdbg",
"request": "launch",
"program": "${workspaceFolder}/build/ViewerInstall/tacentview.exe",
"args": ["--profile","kiosk"],
"args": [],
"stopAtEntry": false,
"cwd": "${workspaceFolder}/TestImages/FormatVariety",
"environment": [],
Expand Down
8 changes: 4 additions & 4 deletions Src/Config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -236,8 +236,7 @@ void Config::GlobalSettings::Save(tExprWriter& writer)
WriteItem(WindowW);
WriteItem(WindowH);
WriteItem(TransparentWorkArea);
WriteItem(LastOpenPath);
WriteLast(FullscreenMode);
WriteLast(LastOpenPath);

writer.Dedent();
writer.CR();
Expand Down Expand Up @@ -268,7 +267,6 @@ void Config::GlobalSettings::Load(tExpression expr)
ReadItem(WindowH);
ReadItem(TransparentWorkArea);
ReadItem(LastOpenPath);
ReadItem(FullscreenMode);
}
}

Expand Down Expand Up @@ -302,14 +300,14 @@ void Config::GlobalSettings::Reset()
WindowY = (screenH - WindowH) >> 1;
TransparentWorkArea = false;
LastOpenPath .Clear();
FullscreenMode = false;
}


void Config::ProfileSettings::Reset(Viewer::Profile profile, uint32 categories)
{
if (categories & Category_Unspecified)
{
FullscreenMode = (profile == Profile::Kiosk) ? true : false;
ShowMenuBar = (profile == Profile::Basic) || (profile == Profile::Kiosk) ? false : true;
ShowNavBar = (profile == Profile::Basic) || (profile == Profile::Kiosk) ? false : true;
ShowImageDetails = (profile == Profile::Basic) || (profile == Profile::Kiosk) ? false : true;
Expand Down Expand Up @@ -448,6 +446,7 @@ void Config::ProfileSettings::Load(tExpression expr)
{
switch (e.Command().Hash())
{
ReadItem(FullscreenMode);
ReadItem(ShowMenuBar);
ReadItem(ShowNavBar);
ReadItem(ShowImageDetails);
Expand Down Expand Up @@ -614,6 +613,7 @@ bool Config::ProfileSettings::Save(tExprWriter& writer) const
writer.WriteAtom(Name);
writer.CR();

WriteItem(FullscreenMode);
WriteItem(ShowMenuBar);
WriteItem(ShowNavBar);
WriteItem(ShowImageDetails);
Expand Down
2 changes: 1 addition & 1 deletion Src/Config.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ struct ProfileSettings
ProfileSettings(Profile profile) : Name(), InputBindings() { Reset(profile, Category_All); }
tString Name; // The name of the profile.

bool FullscreenMode;
bool ShowMenuBar;
bool ShowNavBar;
bool ShowImageDetails;
Expand Down Expand Up @@ -281,7 +282,6 @@ struct GlobalSettings
int WindowH;
bool TransparentWorkArea;
tString LastOpenPath;
bool FullscreenMode;

private:
static void GetScreenSize(int& width, int& height);
Expand Down
2 changes: 1 addition & 1 deletion Src/Preferences.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -427,7 +427,7 @@ void Viewer::ShowPreferencesWindow(bool* popen)
if (!Config::Global.TransparentWorkArea)
PendingTransparentWorkArea = false;
SlideshowCountdown = Config::Current->SlideshowPeriod;
ChangeScreenMode(Config::Global.FullscreenMode, true);
ChangeScreenMode(Config::Current->FullscreenMode, true);
}
ShowToolTip
(
Expand Down
31 changes: 19 additions & 12 deletions Src/TacentView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -319,6 +319,7 @@ namespace Viewer
int RemoveOldCacheFiles(const tString& cacheDir); // Returns num removed.

CursorMove RequestCursorMove = CursorMove_None;
bool IgnoreNextCursorPosCallback = false;

void Update(GLFWwindow* window, double dt, bool dopoll = true);
void WindowRefreshFun(GLFWwindow* window) { Update(window, 0.0, false); }
Expand Down Expand Up @@ -1938,9 +1939,9 @@ void Viewer::Update(GLFWwindow* window, double dt, bool dopoll)
ImGui::SetNextWindowPos(tVector2((workAreaW>>1)-22.0f+mainButtonDim*3.0f, float(topUIHeight) + float(workAreaH) - buttonHeightOffset));
ImGui::SetNextWindowSize(mainButtonSize, ImGuiCond_Always);
ImGui::Begin("Fullscreen", nullptr, flagsImgButton);
uint64 fsImageID = Config::Global.FullscreenMode ? Image_Windowed.Bind() : Image_Fullscreen.Bind();
uint64 fsImageID = Config::Current->FullscreenMode ? Image_Windowed.Bind() : Image_Fullscreen.Bind();
if (ImGui::ImageButton(ImTextureID(fsImageID), mainButtonImgSize, tVector2(0.0f, 0.0f), tVector2(1.0f, 1.0f), 2, tVector4(0,0,0,0), tVector4(1.0f, 1.0f, 1.0f, 1.0f)))
ChangeScreenMode(!Config::Global.FullscreenMode);
ChangeScreenMode(!Config::Current->FullscreenMode);
ImGui::End();

// Exit basic or kiosk profile.
Expand Down Expand Up @@ -2727,11 +2728,11 @@ bool Viewer::DeleteImageFile(const tString& imgFile, bool tryUseRecycleBin)

bool Viewer::ChangeScreenMode(bool fullscreen, bool force)
{
if (!force && (Config::Global.FullscreenMode == fullscreen))
if (!force && (Config::Current->FullscreenMode == fullscreen))
return false;

// If currently in windowed mode, remember our window geometry.
if (!force && !Config::Global.FullscreenMode)
if (!force && !Config::Current->FullscreenMode)
{
glfwGetWindowPos(Viewer::Window, &Viewer::Config::Global.WindowX, &Viewer::Config::Global.WindowY);
glfwGetWindowSize(Viewer::Window, &Viewer::Config::Global.WindowW, &Viewer::Config::Global.WindowH);
Expand Down Expand Up @@ -2768,8 +2769,8 @@ bool Viewer::ChangeScreenMode(bool fullscreen, bool force)
glfwSetWindowMonitor(Viewer::Window, nullptr, Viewer::Config::Global.WindowX, Viewer::Config::Global.WindowY, Viewer::Config::Global.WindowW, Viewer::Config::Global.WindowH, mode->refreshRate);
}
}

Config::Global.FullscreenMode = fullscreen;
IgnoreNextCursorPosCallback = true;
Config::Current->FullscreenMode = fullscreen;
return true;
}

Expand Down Expand Up @@ -2814,6 +2815,7 @@ void Viewer::ChangeProfile(Profile profile)
// settings, the only difference is the default values are different than the main profile.

AutoPropertyWindow();
ChangeScreenMode(Config::Current->FullscreenMode, true);
}


Expand Down Expand Up @@ -3413,18 +3415,18 @@ void Viewer::KeyCallback(GLFWwindow* window, int key, int scancode, int action,
break;

case Bindings::Operation::Fullscreen:
ChangeScreenMode(!Config::Global.FullscreenMode);
ChangeScreenMode(!Config::Current->FullscreenMode);
break;

case Bindings::Operation::Escape:
if (Config::Global.FullscreenMode)
if (Config::Current->FullscreenMode)
ChangeScreenMode(false);
else if ((Config::GetProfile() == Profile::Basic) || (Config::GetProfile() == Profile::Kiosk))
ChangeProfile(Profile::Main);
break;

case Bindings::Operation::EscapeSupportingQuit:
if (Config::Global.FullscreenMode)
if (Config::Current->FullscreenMode)
ChangeScreenMode(false);
else if ((Config::GetProfile() == Profile::Basic) || (Config::GetProfile() == Profile::Kiosk))
ChangeProfile(Profile::Main);
Expand Down Expand Up @@ -3508,7 +3510,12 @@ void Viewer::CursorPosCallback(GLFWwindow* window, double x, double y)
{
if (ImGui::GetIO().WantCaptureMouse)
return;


if (IgnoreNextCursorPosCallback)
{
IgnoreNextCursorPosCallback = false;
return;
}
DisappearCountdown = DisappearDuration;
}

Expand Down Expand Up @@ -3958,7 +3965,7 @@ int main(int argc, char** argv)
glfwMakeContextCurrent(Viewer::Window);
glfwSwapBuffers(Viewer::Window);

if (Viewer::Config::Global.FullscreenMode)
if (Viewer::Config::Current->FullscreenMode)
Viewer::ChangeScreenMode(true, true);

if (Viewer::Config::Current->SlideshowAutoStart)
Expand Down Expand Up @@ -4003,7 +4010,7 @@ int main(int argc, char** argv)
Viewer::UnloadAppImages();

// Get current window geometry and set in config file if we're not in fullscreen mode and not iconified.
if (!Viewer::Config::Global.FullscreenMode && !Viewer::WindowIconified)
if (!Viewer::Config::Current->FullscreenMode && !Viewer::WindowIconified)
{
glfwGetWindowPos(Viewer::Window, &Viewer::Config::Global.WindowX, &Viewer::Config::Global.WindowY);
glfwGetWindowSize(Viewer::Window, &Viewer::Config::Global.WindowW, &Viewer::Config::Global.WindowH);
Expand Down

0 comments on commit 192bded

Please sign in to comment.