git.s-ol.nu ~forks/DiligentTools / 39e733a
Updated display size handling by imgui on Mac and iOS assiduous 1 year, 1 month ago
4 changed file(s) with 6 addition(s) and 27 deletion(s). Raw diff Collapse all Expand all
3838 ImGuiImplIOS(IRenderDevice* pDevice,
3939 TEXTURE_FORMAT BackBufferFmt,
4040 TEXTURE_FORMAT DepthBufferFmt,
41 Uint32 DisplayWidth,
42 Uint32 DisplayHeight,
4341 Uint32 InitialVertexBufferSize = ImGuiImplDiligent::DefaultInitialVBSize,
4442 Uint32 InitialIndexBufferSize = ImGuiImplDiligent::DefaultInitialIBSize);
4543 ~ImGuiImplIOS();
5553 Uint32 RenderSurfaceHeight,
5654 SURFACE_TRANSFORM SurfacePreTransform) override final;
5755 virtual void Render(IDeviceContext* pCtx) override final;
58 void SetDisplaySize(Uint32 DisplayWidth, Uint32 DisplayHeight);
5956 bool OnTouchEvent(float x, float y, bool IsActive);
6057
6158 private:
4141 ImGuiImplMacOS(IRenderDevice* _Nonnull pDevice,
4242 TEXTURE_FORMAT BackBufferFmt,
4343 TEXTURE_FORMAT DepthBufferFmt,
44 Uint32 DisplayWidth,
45 Uint32 DisplayHeight,
4644 Uint32 InitialVertexBufferSize = ImGuiImplDiligent::DefaultInitialVBSize,
4745 Uint32 InitialIndexBufferSize = ImGuiImplDiligent::DefaultInitialIBSize);
4846 ~ImGuiImplMacOS();
5957 SURFACE_TRANSFORM SurfacePreTransform) override final;
6058 virtual void Render(IDeviceContext* _Nonnull pCtx) override final;
6159 bool HandleOSXEvent(NSEvent* _Nonnull event, NSView* _Nonnull view);
62 void SetDisplaySize(Uint32 DisplayWidth, Uint32 DisplayHeight);
6360
6461 private:
6562 std::mutex m_Mtx;
3030 ImGuiImplIOS::ImGuiImplIOS(IRenderDevice* pDevice,
3131 TEXTURE_FORMAT BackBufferFmt,
3232 TEXTURE_FORMAT DepthBufferFmt,
33 Uint32 DisplayWidth,
34 Uint32 DisplayHeight,
3533 Uint32 InitialVertexBufferSize,
3634 Uint32 InitialIndexBufferSize) :
3735 ImGuiImplDiligent(pDevice, BackBufferFmt, DepthBufferFmt, InitialVertexBufferSize, InitialIndexBufferSize)
3836 {
3937 ImGuiIO& io = ImGui::GetIO();
4038 //io.FontGlobalScale = 2;
41 io.DisplaySize = ImVec2(DisplayWidth, DisplayHeight);
42 io.BackendPlatformName = "ImGuiImplIOS";
39 io.BackendPlatformName = "Diligent-ImGuiImplIOS";
4340 }
4441
4542 ImGuiImplIOS::~ImGuiImplIOS()
5653 io.DeltaTime = current_time - m_Time;
5754 m_Time = current_time;
5855
56 io.DisplaySize = ImVec2(RenderSurfaceWidth, RenderSurfaceHeight);
57
5958 ImGuiImplDiligent::NewFrame(RenderSurfaceWidth, RenderSurfaceHeight, SurfacePreTransform);
60 }
61
62 void ImGuiImplIOS::SetDisplaySize(Uint32 DisplayWidth, Uint32 DisplayHeight)
63 {
64 std::lock_guard<std::mutex> Lock(m_Mtx);
65 ImGuiIO& io = ImGui::GetIO();
66 io.DisplaySize = ImVec2(DisplayWidth, DisplayHeight);
6759 }
6860
6961 bool ImGuiImplIOS::OnTouchEvent(float x, float y, bool IsActive)
3131 ImGuiImplMacOS::ImGuiImplMacOS(IRenderDevice* pDevice,
3232 TEXTURE_FORMAT BackBufferFmt,
3333 TEXTURE_FORMAT DepthBufferFmt,
34 Uint32 DisplayWidth,
35 Uint32 DisplayHeight,
3634 Uint32 InitialVertexBufferSize,
3735 Uint32 InitialIndexBufferSize) :
3836 ImGuiImplDiligent(pDevice, BackBufferFmt, DepthBufferFmt, InitialVertexBufferSize, InitialIndexBufferSize)
4038 ImGui_ImplOSX_Init();
4139 ImGuiIO& io = ImGui::GetIO();
4240 io.FontGlobalScale = 2;
43 io.DisplaySize = ImVec2(DisplayWidth, DisplayHeight);
41 io.BackendPlatformName = "Diligent-ImGuiImplMacOS";
4442 }
4543
4644 ImGuiImplMacOS::~ImGuiImplMacOS()
5351 SURFACE_TRANSFORM SurfacePreTransform)
5452 {
5553 std::lock_guard<std::mutex> Lock(m_Mtx);
54 ImGuiIO& io = ImGui::GetIO();
55 io.DisplaySize = ImVec2(RenderSurfaceWidth, RenderSurfaceHeight);
5656 ImGui_ImplOSX_NewFrame(nil);
5757 ImGuiImplDiligent::NewFrame(RenderSurfaceWidth, RenderSurfaceHeight, SurfacePreTransform);
58 }
59
60 void ImGuiImplMacOS::SetDisplaySize(Uint32 DisplayWidth, Uint32 DisplayHeight)
61 {
62 std::lock_guard<std::mutex> Lock(m_Mtx);
63 ImGuiIO& io = ImGui::GetIO();
64 io.DisplaySize = ImVec2(DisplayWidth, DisplayHeight);
6558 }
6659
6760 bool ImGuiImplMacOS::HandleOSXEvent(NSEvent *_Nonnull event, NSView *_Nonnull view)