Skip to content

Commit

Permalink
ImGui fixes for self-hotsed imgui.h
Browse files Browse the repository at this point in the history
  • Loading branch information
gwaldron committed Jul 12, 2024
1 parent e285c3b commit 448e91b
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 15 deletions.
3 changes: 1 addition & 2 deletions src/osgEarthImGui/Common
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@

// note: No Windows declspec's here because we are using CMAKE_EXINDOWS_EXPORT_ALL_SYMBOLS

#include <GL/glew.h>

#ifndef IMGUI_VERSION
#include <GL/glew.h>
#include <osgEarthImGui/imgui.h>
#endif
8 changes: 0 additions & 8 deletions src/osgEarthImGui/ImGuiApp
Original file line number Diff line number Diff line change
Expand Up @@ -242,22 +242,14 @@ namespace osgEarth
ImGui::EndMainMenuBar();
}

bool dirty = false;

for (auto& iter : _menu)
{
for (auto& gui : iter.second)
{
if (gui->isVisible())
gui->draw(ri);

if (gui->visibilityChanged())
dirty = true;
}
}

if (dirty)
ImGuiPanel::dirtySettings();
}

//! Toggle a GUI's visibility by its type
Expand Down
8 changes: 3 additions & 5 deletions src/osgEarthImGui/ImGuiPanel
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
#include <osgEarth/MapNode>
#include <osgEarth/Terrain>
#include <osgEarth/GeoData>
#include <osgEarth/NodeUtils>

#include <osgDB/ReadFile>
#include <osg/observer_ptr>
Expand Down Expand Up @@ -180,12 +181,9 @@ namespace osgEarth
save(conf);
}

//! tells ImGui it needs to write a new .ini file
static void dirtySettings()
void dirtySettings()
{
std::string file = ImGui::GetIO().IniFilename;
if (file.empty()) file = "imgui.ini";
ImGui::SaveIniSettingsToDisk(file.c_str());
// nop - settings save automatically
}

//! whether the visibility changed (and resets the flag)
Expand Down

0 comments on commit 448e91b

Please sign in to comment.