From 1e9024fb49039457f69dc2512c4babf5119c502f Mon Sep 17 00:00:00 2001 From: Foivos Date: Tue, 13 Jan 2026 21:57:56 +0200 Subject: [PATCH 1/3] correctly wrap multiline tooltips and show them over controlRec in case the tooltip is too low. --- src/raygui.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/raygui.h b/src/raygui.h index 3842e2c4..148d0c2b 100644 --- a/src/raygui.h +++ b/src/raygui.h @@ -5373,14 +5373,16 @@ static void GuiTooltip(Rectangle controlRec) Vector2 textSize = MeasureTextEx(GuiGetFont(), guiTooltipPtr, (float)GuiGetStyle(DEFAULT, TEXT_SIZE), (float)GuiGetStyle(DEFAULT, TEXT_SPACING)); if ((controlRec.x + textSize.x + 16) > GetScreenWidth()) controlRec.x -= (textSize.x + 16 - controlRec.width); + if ((controlRec.y + controlRec.height + textSize.y + 12) > GetScreenHeight()) + controlRec.y -= (controlRec.height + textSize.y + 12); - GuiPanel(RAYGUI_CLITERAL(Rectangle){ controlRec.x, controlRec.y + controlRec.height + 4, textSize.x + 16, GuiGetStyle(DEFAULT, TEXT_SIZE) + 8.0f }, NULL); + GuiPanel(RAYGUI_CLITERAL(Rectangle){ controlRec.x, controlRec.y + controlRec.height + 4, textSize.x + 16, textSize + 8.0f }, NULL); int textPadding = GuiGetStyle(LABEL, TEXT_PADDING); int textAlignment = GuiGetStyle(LABEL, TEXT_ALIGNMENT); GuiSetStyle(LABEL, TEXT_PADDING, 0); GuiSetStyle(LABEL, TEXT_ALIGNMENT, TEXT_ALIGN_CENTER); - GuiLabel(RAYGUI_CLITERAL(Rectangle){ controlRec.x, controlRec.y + controlRec.height + 4, textSize.x + 16, GuiGetStyle(DEFAULT, TEXT_SIZE) + 8.0f }, guiTooltipPtr); + GuiLabel(RAYGUI_CLITERAL(Rectangle){ controlRec.x, controlRec.y + controlRec.height + 4, textSize.x + 16, textSize + 8.0f }, guiTooltipPtr); GuiSetStyle(LABEL, TEXT_ALIGNMENT, textAlignment); GuiSetStyle(LABEL, TEXT_PADDING, textPadding); } From 6178e046066d9aad70a1ad3f9ae934341acdfbe8 Mon Sep 17 00:00:00 2001 From: Foivos Date: Wed, 14 Jan 2026 14:35:24 +0200 Subject: [PATCH 2/3] include .y that was ommited --- src/raygui.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/raygui.h b/src/raygui.h index 148d0c2b..beb86141 100644 --- a/src/raygui.h +++ b/src/raygui.h @@ -5376,13 +5376,13 @@ static void GuiTooltip(Rectangle controlRec) if ((controlRec.y + controlRec.height + textSize.y + 12) > GetScreenHeight()) controlRec.y -= (controlRec.height + textSize.y + 12); - GuiPanel(RAYGUI_CLITERAL(Rectangle){ controlRec.x, controlRec.y + controlRec.height + 4, textSize.x + 16, textSize + 8.0f }, NULL); + GuiPanel(RAYGUI_CLITERAL(Rectangle){ controlRec.x, controlRec.y + controlRec.height + 4, textSize.x + 16, textSize.y + 8.0f }, NULL); int textPadding = GuiGetStyle(LABEL, TEXT_PADDING); int textAlignment = GuiGetStyle(LABEL, TEXT_ALIGNMENT); GuiSetStyle(LABEL, TEXT_PADDING, 0); GuiSetStyle(LABEL, TEXT_ALIGNMENT, TEXT_ALIGN_CENTER); - GuiLabel(RAYGUI_CLITERAL(Rectangle){ controlRec.x, controlRec.y + controlRec.height + 4, textSize.x + 16, textSize + 8.0f }, guiTooltipPtr); + GuiLabel(RAYGUI_CLITERAL(Rectangle){ controlRec.x, controlRec.y + controlRec.height + 4, textSize.x + 16, textSize.y + 8.0f }, guiTooltipPtr); GuiSetStyle(LABEL, TEXT_ALIGNMENT, textAlignment); GuiSetStyle(LABEL, TEXT_PADDING, textPadding); } From 2fb869b9a43f0bd41c3c93fa54ef6f957bcf8bb1 Mon Sep 17 00:00:00 2001 From: Foivos Date: Wed, 14 Jan 2026 15:31:21 +0200 Subject: [PATCH 3/3] fix size of padding to account for multiple lines --- src/raygui.h | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/raygui.h b/src/raygui.h index beb86141..68e54d9c 100644 --- a/src/raygui.h +++ b/src/raygui.h @@ -5373,16 +5373,19 @@ static void GuiTooltip(Rectangle controlRec) Vector2 textSize = MeasureTextEx(GuiGetFont(), guiTooltipPtr, (float)GuiGetStyle(DEFAULT, TEXT_SIZE), (float)GuiGetStyle(DEFAULT, TEXT_SPACING)); if ((controlRec.x + textSize.x + 16) > GetScreenWidth()) controlRec.x -= (textSize.x + 16 - controlRec.width); - if ((controlRec.y + controlRec.height + textSize.y + 12) > GetScreenHeight()) - controlRec.y -= (controlRec.height + textSize.y + 12); - GuiPanel(RAYGUI_CLITERAL(Rectangle){ controlRec.x, controlRec.y + controlRec.height + 4, textSize.x + 16, textSize.y + 8.0f }, NULL); + int numberOfLines; + GetTextLines(guiTooltipPtr, &numberOfLines); + if ((controlRec.y + controlRec.height + textSize.y + 4 + 8 * numberOfLines) > GetScreenHeight()) + controlRec.y -= (controlRec.height + textSize.y + 4 + 8 * numberOfLines); + + GuiPanel(RAYGUI_CLITERAL(Rectangle){ controlRec.x, controlRec.y + controlRec.height + 4, textSize.x + 16, textSize.y + 8.0f * numberOfLines }, NULL); int textPadding = GuiGetStyle(LABEL, TEXT_PADDING); int textAlignment = GuiGetStyle(LABEL, TEXT_ALIGNMENT); GuiSetStyle(LABEL, TEXT_PADDING, 0); GuiSetStyle(LABEL, TEXT_ALIGNMENT, TEXT_ALIGN_CENTER); - GuiLabel(RAYGUI_CLITERAL(Rectangle){ controlRec.x, controlRec.y + controlRec.height + 4, textSize.x + 16, textSize.y + 8.0f }, guiTooltipPtr); + GuiLabel(RAYGUI_CLITERAL(Rectangle){ controlRec.x, controlRec.y + controlRec.height + 4, textSize.x + 16, textSize.y + 8.0f * numberOfLines }, guiTooltipPtr); GuiSetStyle(LABEL, TEXT_ALIGNMENT, textAlignment); GuiSetStyle(LABEL, TEXT_PADDING, textPadding); }