56 DRA::WINDOW_MANAGER_ID == WindowManagerId::GLFW_WINDOW ||
57 DRA::WINDOW_MANAGER_ID == WindowManagerId::QT_WIDGET,
58 "ImGuiDrawer supports only GLFW or Qt window managers.");
66#ifdef VCLIB_RENDER_BACKEND_OPENGL2
68#elif defined(VCLIB_RENDER_BACKEND_BGFX)
69 ImGui_ImplBgfx_Shutdown();
72 if constexpr (DRA::WINDOW_MANAGER_ID == WindowManagerId::GLFW_WINDOW) {
77 if constexpr (DRA::WINDOW_MANAGER_ID == WindowManagerId::QT_WIDGET) {
78 ImGui_ImplQt_Shutdown();
81 ImGui::DestroyContext();
84 virtual void onInit(uint viewId)
88 ImGui::CreateContext();
95 ImGui::StyleColorsDark();
98 if constexpr (DRA::WINDOW_MANAGER_ID == WindowManagerId::GLFW_WINDOW) {
100 reinterpret_cast<GLFWwindow*
>(DRA::DRW::windowPtr(derived()));
102#ifdef VCLIB_RENDER_BACKEND_OPENGL2
105#elif defined(VCLIB_RENDER_BACKEND_BGFX)
107 ImGui_ImplBgfx_Init();
112 if constexpr (DRA::WINDOW_MANAGER_ID == WindowManagerId::QT_WIDGET) {
114 reinterpret_cast<QWidget*
>(DRA::DRW::windowPtr(derived()));
116 ImGui_ImplQt_Init(mWindow);
117#ifdef VCLIB_RENDER_BACKEND_OPENGL2
119#elif defined(VCLIB_RENDER_BACKEND_BGFX)
120 ImGui_ImplBgfx_Init();
126 virtual void onDraw(uint viewId)
129#ifdef VCLIB_RENDER_BACKEND_OPENGL2
131#elif defined(VCLIB_RENDER_BACKEND_BGFX)
132 ImGui_ImplBgfx_NewFrame();
134#ifdef VCLIB_WITH_GLFW
135 if constexpr (DRA::WINDOW_MANAGER_ID == WindowManagerId::GLFW_WINDOW) {
140 if constexpr (DRA::WINDOW_MANAGER_ID == WindowManagerId::QT_WIDGET) {
141 ImGui_ImplQt_NewFrame();
146 this->onDrawContent(viewId);
149 virtual void onPostDraw()
153#ifdef VCLIB_RENDER_BACKEND_OPENGL2
155#elif defined(VCLIB_RENDER_BACKEND_BGFX)
156 ImGui_ImplBgfx_RenderDrawData(ImGui::GetDrawData());
168 return wantCapture(
false);
173 return wantCapture(
false);
178 return wantCapture();
181 virtual bool onMousePress(
187 return wantCapture();
190 virtual bool onMouseRelease(
196 return wantCapture();
199 virtual bool onMouseDoubleClick(
205 return wantCapture();
208 virtual bool onMouseScroll(
213 return wantCapture();
217 bool isWindowMinimized()
const {
return derived()->isMinimized(); }
220 auto* derived() {
return static_cast<DRA*
>(
this); }
222 const auto* derived()
const {
return static_cast<const DRA*
>(
this); }
224 bool wantCapture(
bool mouse =
true)
226 const auto& io = ImGui::GetIO();
227 return mouse ? io.WantCaptureMouse : io.WantCaptureKeyboard;