Skip to content

Commit 193b9d8

Browse files
authored
Fixes for internal API changes in 1.92.x: ImFontBaked, ImGuiWindow::CalcFontSize(). (#614)
1 parent 47522f4 commit 193b9d8

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

implot.cpp

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -342,11 +342,16 @@ void AddTextVertical(ImDrawList *DrawList, ImVec2 pos, ImU32 col, const char *te
342342
if (!text_end)
343343
text_end = text_begin + strlen(text_begin);
344344
ImGuiContext& g = *GImGui;
345+
#ifdef IMGUI_HAS_TEXTURES
346+
ImFontBaked* font = g.Font->GetFontBaked(g.FontSize);
347+
const float scale = g.FontSize / font->Size;
348+
#else
345349
ImFont* font = g.Font;
350+
const float scale = g.FontSize / font->FontSize;
351+
#endif
346352
// Align to be pixel perfect
347353
pos.x = ImFloor(pos.x);
348354
pos.y = ImFloor(pos.y);
349-
const float scale = g.FontSize / font->FontSize;
350355
const char* s = text_begin;
351356
int chars_exp = (int)(text_end - s);
352357
int chars_rnd = 0;
@@ -3059,7 +3064,11 @@ void EndPlot() {
30593064
ImGui::SetKeyOwner(ImGuiKey_MouseWheelY, plot.Items.ID);
30603065
if (IO.MouseWheel != 0.0f) {
30613066
ImVec2 max_step = legend.Rect.GetSize() * 0.67f;
3067+
#if IMGUI_VERSION_NUM < 19172
30623068
float font_size = ImGui::GetCurrentWindow()->CalcFontSize();
3069+
#else
3070+
float font_size = ImGui::GetCurrentWindow()->FontRefSize;
3071+
#endif
30633072
float scroll_step = ImFloor(ImMin(2 * font_size, max_step.x));
30643073
legend.Scroll.x += scroll_step * IO.MouseWheel;
30653074
legend.Scroll.y += scroll_step * IO.MouseWheel;
@@ -3578,7 +3587,11 @@ void EndSubplots() {
35783587
ImGui::SetKeyOwner(ImGuiKey_MouseWheelY, subplot.Items.ID);
35793588
if (IO.MouseWheel != 0.0f) {
35803589
ImVec2 max_step = legend.Rect.GetSize() * 0.67f;
3590+
#if IMGUI_VERSION_NUM < 19172
35813591
float font_size = ImGui::GetCurrentWindow()->CalcFontSize();
3592+
#else
3593+
float font_size = ImGui::GetCurrentWindow()->FontRefSize;
3594+
#endif
35823595
float scroll_step = ImFloor(ImMin(2 * font_size, max_step.x));
35833596
legend.Scroll.x += scroll_step * IO.MouseWheel;
35843597
legend.Scroll.y += scroll_step * IO.MouseWheel;

0 commit comments

Comments
 (0)