[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,8 +89,7 @@ void app_updateCursorPos(double x, double y)
g_cursor.pos.y = y; g_cursor.pos.y = y;
g_cursor.valid = true; g_cursor.valid = true;
if (app_isOverlayMode()) g_state.io->MousePos = (ImVec2) { x, y };
g_state.io->MousePos = (ImVec2) { x, y };
} }
void app_handleFocusEvent(bool focused) void app_handleFocusEvent(bool focused)

View File

@ -89,6 +89,7 @@ static int status_render(void * udata, bool interactive, struct Rect * windowRec
}; };
int xPos = screen->x - marginX; int xPos = screen->x - marginX;
int rects = 1;
for(int i = 0; i < LG_USER_STATUS_MAX; ++i) for(int i = 0; i < LG_USER_STATUS_MAX; ++i)
{ {
OverlayImage * img = &l_image[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) if (i == LG_USER_STATUS_RECORDING && !l_recordToggle)
goto next; goto next;
const ImVec2 topRight = (ImVec2){
xPos,
marginY
};
const ImVec2 bottomLeft = (ImVec2){
xPos - ICON_SIZE,
img->height / l_scale + marginY
};
ImDrawList_AddImage( ImDrawList_AddImage(
igGetBackgroundDrawList_Nil(), igGetBackgroundDrawList_Nil(),
img->tex, img->tex,
(ImVec2){ topRight,
xPos, bottomLeft,
marginY
},
(ImVec2){
xPos - ICON_SIZE,
img->height / l_scale + marginY
},
(ImVec2){ 0, 0 }, (ImVec2){ 0, 0 },
(ImVec2){ 1, 1 }, (ImVec2){ 1, 1 },
0xFFFFFFFF); 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: next:
xPos -= ICON_SIZE + gapX; xPos -= ICON_SIZE + gapX;
} }
*windowRects = rect; *windowRects = rect;
return 1; return rects;
} }
static bool status_tick(void * udata, unsigned long long tickCount) static bool status_tick(void * udata, unsigned long long tickCount)