Files
vr-poser/include/ImGuiLayer.h
2026-03-15 22:03:30 -04:00

51 lines
1.6 KiB
C++

#pragma once
#include <string>
#include <functional>
#include <osg/Camera>
#include <osgViewer/Viewer>
#include <osgGA/GUIEventAdapter>
class MorphManager;
class AppConfig;
class ImGuiLayer {
public:
explicit ImGuiLayer(MorphManager* morphMgr, const AppConfig* cfg);
~ImGuiLayer();
void init(osgViewer::Viewer* viewer);
bool handleEvent(const osgGA::GUIEventAdapter& ea);
void renderPanel(); // called by ImGuiDrawCallback each frame
void markGLInitialized();
// Callbacks set by Application so ImGui can drive app state
std::function<void(const std::string&)> onShaderChange;
std::function<void()> onShaderReload;
std::function<void(float)> onScaleChange;
// Called by Application each frame so the shader tab shows current state
void setCurrentShader(const std::string& s) { m_currentShader = s; }
void setInitialScale(float s) { m_scale = s; m_scaleBuf[0] = 0; }
private:
void renderMorphTab();
void renderShaderTab();
void renderTransformTab();
MorphManager* m_morphMgr = nullptr;
const AppConfig* m_cfg = nullptr;
osgViewer::Viewer* m_viewer = nullptr;
osg::ref_ptr<osg::Camera> m_camera;
bool m_contextCreated = false;
bool m_glInitialized = false;
float m_panelWidth = 380.f; // wider default so names are visible
char m_searchBuf[256] = {};
bool m_showOnlyActive = false;
std::string m_currentShader = "toon";
float m_scale = 1.0f;
char m_scaleBuf[32] = {};
};