[client] overlay/status: draw a tooltip if the user mouses over the spice icon

This commit is contained in:
Babbaj 2022-11-09 14:03:51 -05:00
parent fa6f1abaac
commit be9d1a061f
No known key found for this signature in database
GPG Key ID: F044309848A07CAC
2 changed files with 36 additions and 11 deletions

View File

@ -89,7 +89,6 @@ void app_updateCursorPos(double x, double y)
g_cursor.pos.y = y;
g_cursor.valid = true;
if (app_isOverlayMode())
g_state.io->MousePos = (ImVec2) { x, y };
}

View File

@ -89,6 +89,7 @@ static int status_render(void * udata, bool interactive, struct Rect * windowRec
};
int xPos = screen->x - marginX;
int rects = 1;
for(int i = 0; i < LG_USER_STATUS_MAX; ++i)
{
OverlayImage * img = &l_image[i];
@ -99,27 +100,52 @@ static int status_render(void * udata, bool interactive, struct Rect * windowRec
if (i == LG_USER_STATUS_RECORDING && !l_recordToggle)
goto next;
const ImVec2 topRight = (ImVec2){
xPos,
marginY
};
const ImVec2 bottomLeft = (ImVec2){
xPos - ICON_SIZE,
img->height / l_scale + marginY
};
ImDrawList_AddImage(
igGetBackgroundDrawList_Nil(),
img->tex,
(ImVec2){
xPos,
marginY
},
(ImVec2){
xPos - ICON_SIZE,
img->height / l_scale + marginY
},
topRight,
bottomLeft,
(ImVec2){ 0, 0 },
(ImVec2){ 1, 1 },
0xFFFFFFFF);
// draw a helpful little tooltip if the user tries to mouse over the spice icon
if (i == LG_USER_STATUS_SPICE && g_cursor.valid) {
const double x = g_state.io->MousePos.x;
const double y = g_state.io->MousePos.y;
if (x >= bottomLeft.x && y <= bottomLeft.y && x <= topRight.x && y >= topRight.y) {
igBeginTooltipEx(ImGuiTooltipFlags_None, ImGuiWindowFlags_None);
igText("Using looking glass through SPICE emulation, there is likely a problem with your setup");
ImVec2 windowPos;
ImVec2 windowSize;
igGetWindowPos(&windowPos);
igGetWindowSize(&windowSize);
igEndTooltip();
*windowRects = (struct Rect) {
.x = floorf(windowPos.x),
.y = floorf(windowPos.y),
.w = ceilf(windowSize.x),
.h = ceilf(windowSize.y)
};
rects++;
windowRects++;
}
}
next:
xPos -= ICON_SIZE + gapX;
}
*windowRects = rect;
return 1;
return rects;
}
static bool status_tick(void * udata, unsigned long long tickCount)