50#ifdef VCLIB_RENDER_BACKEND_BGFX
61 DRA::WINDOW_MANAGER_ID == WindowManagerId::GLFW_WINDOW ||
62 DRA::WINDOW_MANAGER_ID == WindowManagerId::QT_WIDGET,
63 "ImGuiDrawer supports only GLFW or Qt window managers.");
65#ifdef VCLIB_RENDER_BACKEND_BGFX
76#ifdef VCLIB_RENDER_BACKEND_OPENGL2
78#elif defined(VCLIB_RENDER_BACKEND_BGFX)
79 ImGui_ImplBgfx_Shutdown();
84 if constexpr (DRA::WINDOW_MANAGER_ID == WindowManagerId::GLFW_WINDOW) {
89 if constexpr (DRA::WINDOW_MANAGER_ID == WindowManagerId::QT_WIDGET) {
90 ImGui_ImplQt_Shutdown();
93 ImGui::DestroyContext();
96 virtual void onInit(uint)
100 ImGui::CreateContext();
107 ImGui::StyleColorsDark();
109#ifdef VCLIB_WITH_GLFW
110 if constexpr (DRA::WINDOW_MANAGER_ID == WindowManagerId::GLFW_WINDOW) {
112 reinterpret_cast<GLFWwindow*
>(DRA::DRW::windowPtr(derived()));
114#ifdef VCLIB_RENDER_BACKEND_OPENGL2
117#elif defined(VCLIB_RENDER_BACKEND_BGFX)
119 ImGui_ImplBgfx_Init();
124 if constexpr (DRA::WINDOW_MANAGER_ID == WindowManagerId::QT_WIDGET) {
126 reinterpret_cast<QWidget*
>(DRA::DRW::windowPtr(derived()));
128 ImGui_ImplQt_Init(mWindow);
129#ifdef VCLIB_RENDER_BACKEND_OPENGL2
131#elif defined(VCLIB_RENDER_BACKEND_BGFX)
132 ImGui_ImplBgfx_Init();
138 virtual void onDraw(uint viewId)
141#ifdef VCLIB_RENDER_BACKEND_OPENGL2
143#elif defined(VCLIB_RENDER_BACKEND_BGFX)
147#ifdef VCLIB_WITH_GLFW
148 if constexpr (DRA::WINDOW_MANAGER_ID == WindowManagerId::GLFW_WINDOW) {
153 if constexpr (DRA::WINDOW_MANAGER_ID == WindowManagerId::QT_WIDGET) {
154 ImGui_ImplQt_NewFrame();
159#ifdef VCLIB_RENDER_BACKEND_OPENGL2
160 this->onDrawContent(viewId);
161#elif defined(VCLIB_RENDER_BACKEND_BGFX)
166 virtual void onPostDraw()
170#ifdef VCLIB_RENDER_BACKEND_OPENGL2
172#elif defined(VCLIB_RENDER_BACKEND_BGFX)
173 ImGui_ImplBgfx_RenderDrawData(ImGui::GetDrawData());
185 return wantCapture(
false);
190 return wantCapture(
false);
195 return wantCapture();
198 virtual bool onMousePress(
204 return wantCapture();
207 virtual bool onMouseRelease(
213 return wantCapture();
216 virtual bool onMouseDoubleClick(
222 return wantCapture();
225 virtual bool onMouseScroll(
230 return wantCapture();
234 bool isWindowMinimized()
const {
return derived()->isMinimized(); }
237 auto* derived() {
return static_cast<DRA*
>(
this); }
239 const auto* derived()
const {
return static_cast<const DRA*
>(
this); }
241 bool wantCapture(
bool mouse =
true)
243 const auto& io = ImGui::GetIO();
244 return mouse ? io.WantCaptureMouse : io.WantCaptureKeyboard;
static Context & instance(void *windowHandle=nullptr, void *displayHandle=nullptr)
Return the context instance.
Definition context.cpp:371