Skip to content

Commit 2df3d4d

Browse files
committed
Gui changes
- More auto-centering for popups - Hide file explorer by default
1 parent 2a17a9b commit 2df3d4d

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

Nanoforge/gui/MainGui.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ void MainGui::Init(ImGuiFontManager* fontManager, PackfileVFS* packfileVFS, DX11
5656
AddMenuItem("", true, CreateHandle<StatusBar>());
5757
AddMenuItem("View/Start page", true, CreateHandle<StartPanel>());
5858
AddMenuItem("View/Log", false, CreateHandle<LogPanel> ());
59-
AddMenuItem("View/File explorer", true, CreateHandle<FileExplorer>());
59+
AddMenuItem("View/File explorer", false, CreateHandle<FileExplorer>());
6060
AddMenuItem("View/Scriptx viewer (WIP)", false, CreateHandle<ScriptxEditor>(&State));
6161

6262
//Not added to the menu. Only available through key shortcut so people don't go messing with the registry unless they know what they're doing
@@ -895,8 +895,8 @@ void MainGui::DrawProjectSaveLoadDialogs()
895895
if (State.CurrentProject->Loaded() && State.CurrentProject->Saving)
896896
{
897897
ImGui::OpenPopup(saveDialogName);
898-
ImVec2 viewportSize = ImGui::GetMainViewport()->Size;
899-
ImGui::SetNextWindowPos({ viewportSize.x / 2.7f, viewportSize.y / 2.7f }, ImGuiCond_Appearing); //Auto center
898+
ImGuiIO& io = ImGui::GetIO();
899+
ImGui::SetNextWindowPos(ImVec2(io.DisplaySize.x * 0.5f, io.DisplaySize.y * 0.5f), ImGuiCond_Always, ImVec2(0.5f, 0.5f)); //Auto center
900900
if (ImGui::BeginPopupModal(saveDialogName, nullptr, ImGuiWindowFlags_AlwaysAutoResize))
901901
{
902902
ImGui::Text(State.CurrentProject->SaveThreadState.c_str());
@@ -910,6 +910,8 @@ void MainGui::DrawProjectSaveLoadDialogs()
910910
if (State.CurrentProject->Loading)
911911
{
912912
ImGui::OpenPopup(loadDialogName);
913+
ImGuiIO& io = ImGui::GetIO();
914+
ImGui::SetNextWindowPos(ImVec2(io.DisplaySize.x * 0.5f, io.DisplaySize.y * 0.5f), ImGuiCond_Always, ImVec2(0.5f, 0.5f)); //Auto center
913915
if (ImGui::BeginPopupModal(loadDialogName, nullptr, ImGuiWindowFlags_AlwaysAutoResize))
914916
{
915917
ImGui::Text(State.CurrentProject->LoadThreadState.c_str());

Nanoforge/gui/util/Popup.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ PopupResult Popup::Update(GuiState* state)
1616

1717
ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, { 8.0f, 8.0f }); //Manually set padding since the parent window might be a document with padding disabled
1818
PopupResult popupResult = PopupResult::None;
19+
ImGuiIO& io = ImGui::GetIO();
20+
ImGui::SetNextWindowPos(ImVec2(io.DisplaySize.x * 0.5f, io.DisplaySize.y * 0.5f), ImGuiCond_Always, ImVec2(0.5f, 0.5f)); //Auto center
1921
bool openResult = modal_ ? ImGui::BeginPopupModal(title_.c_str(), &open_) : ImGui::BeginPopup(title_.c_str());
2022
if (openResult)
2123
{

0 commit comments

Comments
 (0)