mirror of
https://github.com/ocornut/imgui.git
synced 2026-09-27 00:13:29 +03:00
expose a getter for css to imgui scale ratio
This commit is contained in:
parent
ec5643bda6
commit
da9e7b6e5e
2 changed files with 11 additions and 0 deletions
|
|
@ -4,6 +4,7 @@
|
|||
//
|
||||
// CHANGELOG
|
||||
// (minor and older changes stripped away, please see git history for details)
|
||||
// 2026-09-06: Emscripten: Added ImGui_ImplEmscripten_GetCssToImGuiScale() helper.
|
||||
// 2026-09-05: Emscripten: Use the canvas framebuffer dimensions for display sizing and exact per-axis mouse coordinate scaling.
|
||||
// 2026-09-04: Emscripten: Replaced TargetDevicePixelRatio global with an Init() parameter and runtime setter.
|
||||
// 2026-09-03: Updated coding style and simplified key translation table setup.
|
||||
|
|
@ -402,6 +403,13 @@ void ImGui_ImplEmscripten_SetTargetDevicePixelRatio(float target_device_pixel_ra
|
|||
ImGui_ImplEmscripten_UpdateDisplayProperties(ImGui::GetIO(), bd);
|
||||
}
|
||||
|
||||
ImVec2 ImGui_ImplEmscripten_GetCssToImGuiScale()
|
||||
{
|
||||
ImGui_ImplEmscripten_Data* bd = ImGui_ImplEmscripten_GetBackendData();
|
||||
IM_ASSERT(bd != nullptr && "Context or backend not initialized? Did you call ImGui_ImplEmscripten_Init()?");
|
||||
return bd != nullptr ? bd->CssToImGuiScale : ImVec2(1.0f, 1.0f);
|
||||
}
|
||||
|
||||
void ImGui_ImplEmscripten_Shutdown()
|
||||
{
|
||||
ImGui_ImplEmscripten_Data* bd = ImGui_ImplEmscripten_GetBackendData();
|
||||
|
|
|
|||
|
|
@ -47,6 +47,9 @@ IMGUI_IMPL_API bool ImGui_ImplEmscripten_Init(float target_device_pixel_ratio =
|
|||
// Change the target device pixel ratio at runtime and update display properties immediately.
|
||||
IMGUI_IMPL_API void ImGui_ImplEmscripten_SetTargetDevicePixelRatio(float target_device_pixel_ratio);
|
||||
|
||||
// Return the scale used to convert browser CSS pixel coordinates to Dear ImGui coordinates. Valid after Init().
|
||||
IMGUI_IMPL_API ImVec2 ImGui_ImplEmscripten_GetCssToImGuiScale();
|
||||
|
||||
// Shut down the Emscripten backend. This unsets all Emscripten input callbacks set by Init.
|
||||
// Note it'll also unset any Emscripten input callbacks set elsewhere in the program!
|
||||
// Note also there is no obligation to ever call this, unless you intend to reset the backend (i.e. with ImGui::DestroyContext()).
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue