@ -506,6 +506,14 @@ This approach is relatively easy and functional but comes with two issues:
- Style override may be lost during the `Begin()` call crossing monitor boundaries. You may need to do some custom scaling mumbo-jumbo if you want your `OnChangedViewport()` handler to preserve style overrides.
Please note that if you are not using multi-viewports with multi-monitors using different DPI scales, you can ignore that and use the simpler technique recommended at the top.
On Windows, in addition to scaling the font size (make sure to round to an integer) and using `style.ScaleAllSizes()`, you will need to inform Windows that your application is DPI aware. If this is not done, Windows will scale the application window and the UI text will be blurry. Potential solutions to indicate DPI awareness on Windows are:
- For SDL: the flag `SDL_WINDOW_ALLOW_HIGHDPI` needs to be passed to `SDL_CreateWindow()``.
- For GLFW: this is done automatically.
- For other Windows projects with other backends, or wrapper projects:
- We provide a `ImGui_ImplWin32_EnableDpiAwareness()` helper method in the Win32 backend.
- Use an [application manifest file](https://learn.microsoft.com/en-us/windows/win32/hidpi/setting-the-default-dpi-awareness-for-a-process) to set the `<dpiAware>` property.
### Q: How can I load a different font than the default?
Use the font atlas to load the TTF/OTF file you want:
// - If no fonts are loaded, dear imgui will use the default font. You can also load multiple fonts and use ImGui::PushFont()/PopFont() to select them.
// Window resizing from edges (when io.ConfigWindowsResizeFromEdges = true and ImGuiBackendFlags_HasMouseCursors is set in io.BackendFlags by backend)
staticconstfloatWINDOWS_HOVER_PADDING=4.0f;// Extend outside window for hovering/resizing (maxxed with TouchPadding) and inside windows for borders. Affect FindHoveredWindow().
staticconstfloatWINDOWS_RESIZE_FROM_EDGES_FEEDBACK_TIMER=0.04f;// Reduce visual noise by only highlighting the border after a certain time.
staticconstfloatWINDOWS_MOUSE_WHEEL_SCROLL_LOCK_TIMER=0.80f;// Lock scrolled window (so it doesn't pick child windows that are scrolling through) for a certain time, unless mouse moved.
staticconstfloatWINDOWS_MOUSE_WHEEL_SCROLL_LOCK_TIMER=0.70f;// Lock scrolled window (so it doesn't pick child windows that are scrolling through) for a certain time, unless mouse moved.
// Docking
staticconstfloatDOCKING_TRANSPARENT_PAYLOAD_ALPHA=0.50f;// For use with io.ConfigDockingTransparentPayload. Apply to Viewport _or_ WindowBg in host viewport.
typedefintImGuiMouseCursor;// -> enum ImGuiMouseCursor_ // Enum: A mouse cursor identifier
typedefintImGuiMouseCursor;// -> enum ImGuiMouseCursor_ // Enum: A mouse cursor shape
typedefintImGuiSortDirection;// -> enum ImGuiSortDirection_ // Enum: A sorting direction (ascending or descending)
typedefintImGuiStyleVar;// -> enum ImGuiStyleVar_ // Enum: A variable identifier for styling
typedefintImGuiTableBgTarget;// -> enum ImGuiTableBgTarget_ // Enum: A color target for TableSetBgColor()
@ -370,6 +370,7 @@ namespace ImGui
IMGUI_APIvoidSetNextWindowContentSize(constImVec2&size);// set next window content size (~ scrollable client area, which enforce the range of scrollbars). Not including window decorations (title bar, menu bar, etc.) nor WindowPadding. set an axis to 0.0f to leave it automatic. call before Begin()
IMGUI_APIvoidSetNextWindowCollapsed(boolcollapsed,ImGuiCondcond=0);// set next window collapsed state. call before Begin()
IMGUI_APIvoidSetNextWindowFocus();// set next window to be focused / top-most. call before Begin()
IMGUI_APIvoidSetNextWindowScroll(constImVec2&scroll);// set next window scrolling value (use < 0.0f to not affect a given axis).
IMGUI_APIvoidSetNextWindowBgAlpha(floatalpha);// set next window background color alpha. helper to easily override the Alpha component of ImGuiCol_WindowBg/ChildBg/PopupBg. you may also use ImGuiWindowFlags_NoBackground.
IMGUI_APIvoidSetNextWindowViewport(ImGuiIDviewport_id);// set next window viewport
IMGUI_APIvoidSetWindowPos(constImVec2&pos,ImGuiCondcond=0);// (not recommended) set current window position - call within Begin()/End(). prefer using SetNextWindowPos(), as this may incur tearing and side-effects.
@ -391,6 +392,8 @@ namespace ImGui
IMGUI_APIImVec2GetWindowContentRegionMax();// content boundaries max for the full window (roughly (0,0)+Size-Scroll) where Size can be overridden with SetNextWindowContentSize(), in window coordinates
// Windows Scrolling
// - Any change of Scroll will be applied at the beginning of next frame in the first call to Begin().
// - You may instead use SetNextWindowScroll() prior to calling Begin() to avoid this delay, as an alternative to using SetScrollX()/SetScrollY().
IMGUI_APIfloatGetScrollX();// get scrolling amount [0 .. GetScrollMaxX()]
IMGUI_APIfloatGetScrollY();// get scrolling amount [0 .. GetScrollMaxY()]
IMGUI_APIvoidSetScrollX(floatscroll_x);// set scrolling amount [0 .. GetScrollMaxX()]
@ -940,8 +943,8 @@ namespace ImGui
IMGUI_APIboolIsMouseDragging(ImGuiMouseButtonbutton,floatlock_threshold=-1.0f);// is mouse dragging? (if lock_threshold < -1.0f, uses io.MouseDraggingThreshold)
IMGUI_APIImVec2GetMouseDragDelta(ImGuiMouseButtonbutton=0,floatlock_threshold=-1.0f);// return the delta from the initial clicking position while the mouse button is pressed or was just released. This is locked and return 0.0f until the mouse moves past a distance threshold at least once (if lock_threshold < -1.0f, uses io.MouseDraggingThreshold)
IMGUI_APIImGuiMouseCursorGetMouseCursor();// get desired cursor type, reset in ImGui::NewFrame(), this is updated during the frame. valid before Render(). If you use software rendering by setting io.MouseDrawCursor ImGui will render those for you
IMGUI_APIvoidSetMouseCursor(ImGuiMouseCursorcursor_type);// set desired cursor type
IMGUI_APIImGuiMouseCursorGetMouseCursor();// get desired mouse cursor shape. Important: reset in ImGui::NewFrame(), this is updated during the frame. valid before Render(). If you use software rendering by setting io.MouseDrawCursor ImGui will render those for you
IMGUI_APIvoidSetMouseCursor(ImGuiMouseCursorcursor_type);// set desired mouse cursor shape
IMGUI_APIvoidSetNextFrameWantCaptureMouse(boolwant_capture_mouse);// Override io.WantCaptureMouse flag next frame (said flag is left for your application to handle, typical when true it instucts your app to ignore inputs). This is equivalent to setting "io.WantCaptureMouse = want_capture_mouse;" after the next NewFrame() call.