mirror of
https://github.com/ocornut/imgui.git
synced 2026-06-03 18:44:53 +00:00
DrawList: added ImDrawListFlags_NoTextPixelSnap to disable snapping of AddText() coordinates for a given scope. (#3437, #9417, #2291)
This may evolve into a per-call ImDrawFlags option as well. + clip_rect.Max.y early out may be applied before truncation.
This commit is contained in:
@@ -50,15 +50,17 @@ Other Changes:
|
|||||||
- Clicking on a window's empty-space to move/focus a window checks
|
- Clicking on a window's empty-space to move/focus a window checks
|
||||||
for lack of queued focus request. (#9382)
|
for lack of queued focus request. (#9382)
|
||||||
- InputText:
|
- InputText:
|
||||||
- Added style.InputTextCursorSize to configure cursor/caret thickness. (#7031, #9409)
|
- Added `style.InputTextCursorSize` to configure cursor/caret thickness. (#7031, #9409)
|
||||||
This is automatically scaled by style.ScaleAllSizes().
|
This is automatically scaled by `style.ScaleAllSizes()`.
|
||||||
- Fonts:
|
- Fonts:
|
||||||
- Added `IMGUI_DISABLE_DEFAULT_FONT_BITMAP`/`IMGUI_DISABLE_DEFAULT_FONT_VECTOR` to
|
- Added `IMGUI_DISABLE_DEFAULT_FONT_BITMAP`/`IMGUI_DISABLE_DEFAULT_FONT_VECTOR` to
|
||||||
disable embedding either fonts separately. (#9407)
|
disable embedding either fonts separately. (#9407)
|
||||||
- Tweak CalcTextSize() awkward width rounding/ceiling code to reduce floating-point
|
- Tweak `CalcTextSize()` awkward width rounding/ceiling code to reduce floating-point
|
||||||
imprecisions altering the result by 1 even at relatively small width. (#791)
|
imprecisions altering the result by 1 even at relatively small width. (#791)
|
||||||
- DrawList:
|
- DrawList:
|
||||||
- Minor optimization to AddLine(), AddLineH(), AddLineV() functions. (#4091)
|
- Minor optimization to `AddLine()`, `AddLineH()`, `AddLineV()` functions. (#4091)
|
||||||
|
- Added `ImDrawListFlags_NoTextPixelSnap` to disable snapping of AddText()
|
||||||
|
coordinates for a given scope. (#3437, #9417, #2291)
|
||||||
- Demo:
|
- Demo:
|
||||||
- Extract 'Widgets->Tree Nodes->Selectable Nodes' out of the 'Advanced'
|
- Extract 'Widgets->Tree Nodes->Selectable Nodes' out of the 'Advanced'
|
||||||
demo for clarity (manual reimplementation of basic selection).
|
demo for clarity (manual reimplementation of basic selection).
|
||||||
|
|||||||
1
imgui.h
1
imgui.h
@@ -3279,6 +3279,7 @@ enum ImDrawListFlags_
|
|||||||
ImDrawListFlags_AntiAliasedLinesUseTex = 1 << 1, // Enable anti-aliased lines/borders using textures when possible. Require backend to render with bilinear filtering (NOT point/nearest filtering).
|
ImDrawListFlags_AntiAliasedLinesUseTex = 1 << 1, // Enable anti-aliased lines/borders using textures when possible. Require backend to render with bilinear filtering (NOT point/nearest filtering).
|
||||||
ImDrawListFlags_AntiAliasedFill = 1 << 2, // Enable anti-aliased edge around filled shapes (rounded rectangles, circles).
|
ImDrawListFlags_AntiAliasedFill = 1 << 2, // Enable anti-aliased edge around filled shapes (rounded rectangles, circles).
|
||||||
ImDrawListFlags_AllowVtxOffset = 1 << 3, // Can emit 'VtxOffset > 0' to allow large meshes. Set when 'ImGuiBackendFlags_RendererHasVtxOffset' is enabled.
|
ImDrawListFlags_AllowVtxOffset = 1 << 3, // Can emit 'VtxOffset > 0' to allow large meshes. Set when 'ImGuiBackendFlags_RendererHasVtxOffset' is enabled.
|
||||||
|
ImDrawListFlags_NoTextPixelSnap = 1 << 4, // [Internal] Disable automatically snapping AddText() calls to pixel boundaries.
|
||||||
};
|
};
|
||||||
|
|
||||||
// Draw command list
|
// Draw command list
|
||||||
|
|||||||
@@ -5764,8 +5764,13 @@ void ImFont::RenderChar(ImDrawList* draw_list, float size, const ImVec2& pos, Im
|
|||||||
if (glyph->Colored)
|
if (glyph->Colored)
|
||||||
col |= ~IM_COL32_A_MASK;
|
col |= ~IM_COL32_A_MASK;
|
||||||
float scale = (size >= 0.0f) ? (size / baked->Size) : 1.0f;
|
float scale = (size >= 0.0f) ? (size / baked->Size) : 1.0f;
|
||||||
float x = IM_TRUNC(pos.x);
|
float x = pos.x;
|
||||||
float y = IM_TRUNC(pos.y);
|
float y = pos.y;
|
||||||
|
if ((draw_list->Flags & ImDrawListFlags_NoTextPixelSnap) == 0)
|
||||||
|
{
|
||||||
|
x = IM_TRUNC(x);
|
||||||
|
y = IM_TRUNC(y);
|
||||||
|
}
|
||||||
|
|
||||||
float x1 = x + glyph->X0 * scale;
|
float x1 = x + glyph->X0 * scale;
|
||||||
float x2 = x + glyph->X1 * scale;
|
float x2 = x + glyph->X1 * scale;
|
||||||
@@ -5797,12 +5802,17 @@ void ImFont::RenderChar(ImDrawList* draw_list, float size, const ImVec2& pos, Im
|
|||||||
// DO NOT CALL DIRECTLY THIS WILL CHANGE WILDLY IN 2026. Use ImDrawList::AddText().
|
// DO NOT CALL DIRECTLY THIS WILL CHANGE WILDLY IN 2026. Use ImDrawList::AddText().
|
||||||
void ImFont::RenderText(ImDrawList* draw_list, float size, const ImVec2& pos, ImU32 col, const ImVec4& clip_rect, const char* text_begin, const char* text_end, float wrap_width, ImDrawTextFlags flags)
|
void ImFont::RenderText(ImDrawList* draw_list, float size, const ImVec2& pos, ImU32 col, const ImVec4& clip_rect, const char* text_begin, const char* text_end, float wrap_width, ImDrawTextFlags flags)
|
||||||
{
|
{
|
||||||
// Align to be pixel perfect
|
|
||||||
begin:
|
begin:
|
||||||
float x = IM_TRUNC(pos.x);
|
// Align to be pixel perfect
|
||||||
float y = IM_TRUNC(pos.y);
|
float x = pos.x;
|
||||||
|
float y = pos.y;
|
||||||
if (y > clip_rect.w)
|
if (y > clip_rect.w)
|
||||||
return;
|
return;
|
||||||
|
if ((draw_list->Flags & ImDrawListFlags_NoTextPixelSnap) == 0)
|
||||||
|
{
|
||||||
|
x = IM_TRUNC(x);
|
||||||
|
y = IM_TRUNC(y);
|
||||||
|
}
|
||||||
|
|
||||||
if (!text_end)
|
if (!text_end)
|
||||||
text_end = text_begin + ImStrlen(text_begin); // ImGui:: functions generally already provides a valid text_end, so this is merely to handle direct calls.
|
text_end = text_begin + ImStrlen(text_begin); // ImGui:: functions generally already provides a valid text_end, so this is merely to handle direct calls.
|
||||||
|
|||||||
Reference in New Issue
Block a user