mirror of
https://github.com/gnif/LookingGlass.git
synced 2024-11-21 21:17:19 +00:00
[client] imgui: render twice for alerts
When using jitRender, or on the first frame of an alert the window doesn't get resized immediately causing it to cut off the end of the text. ImGui needs two passes to calulate the bounding box for automatically sized windows, this is per it's design and not a bug, see: https://github.com/ocornut/imgui/issues/2158#issuecomment-434223618
This commit is contained in:
parent
ec0bd6adc8
commit
35334333ac
@ -637,6 +637,8 @@ void app_alert(LG_MsgAlert type, const char * fmt, ...)
|
||||
g_state.alertTimeout = microtime() + ALERT_TIMEOUT;
|
||||
g_state.alertType = type;
|
||||
g_state.alertShow = true;
|
||||
|
||||
g_state.renderImGuiTwice = true;
|
||||
app_invalidateWindow(false);
|
||||
}
|
||||
|
||||
@ -803,6 +805,8 @@ int app_renderOverlay(struct Rect * rects, int maxRects)
|
||||
g_state.io->DeltaTime = (now - g_state.lastImGuiFrame) * 1e-9f;
|
||||
g_state.lastImGuiFrame = now;
|
||||
|
||||
render_again:
|
||||
|
||||
igNewFrame();
|
||||
|
||||
if (g_state.overlayInput)
|
||||
@ -871,6 +875,16 @@ int app_renderOverlay(struct Rect * rects, int maxRects)
|
||||
|
||||
igRender();
|
||||
|
||||
/* imgui requires two passes to calculate the bounding box of auto sized
|
||||
* windows, this is by design
|
||||
* ref: https://github.com/ocornut/imgui/issues/2158#issuecomment-434223618
|
||||
*/
|
||||
if (g_state.renderImGuiTwice)
|
||||
{
|
||||
g_state.renderImGuiTwice = false;
|
||||
goto render_again;
|
||||
}
|
||||
|
||||
return totalDamage ? -1 : totalRects;
|
||||
}
|
||||
|
||||
|
@ -61,6 +61,7 @@ struct AppState
|
||||
bool modAlt;
|
||||
bool modSuper;
|
||||
uint64_t lastImGuiFrame;
|
||||
bool renderImGuiTwice;
|
||||
|
||||
bool alertShow;
|
||||
char * alertMessage;
|
||||
|
Loading…
Reference in New Issue
Block a user