mirror of
https://github.com/kunkundi/crossdesk.git
synced 2026-03-27 20:13:14 +08:00
[feat] add online status indicators for recent connections
This commit is contained in:
@@ -122,6 +122,8 @@ int Render::ShowRecentConnections() {
|
||||
it.second.remote_host_name = "unknown";
|
||||
}
|
||||
|
||||
bool online = device_presence_.IsOnline(it.second.remote_id);
|
||||
|
||||
ImVec2 image_screen_pos = ImVec2(
|
||||
ImGui::GetCursorScreenPos().x + recent_connection_image_width * 0.04f,
|
||||
ImGui::GetCursorScreenPos().y + recent_connection_image_height * 0.08f);
|
||||
@@ -133,6 +135,26 @@ int Render::ShowRecentConnections() {
|
||||
(ImTextureID)(intptr_t)it.second.texture,
|
||||
ImVec2(recent_connection_image_width, recent_connection_image_height));
|
||||
|
||||
ImDrawList* draw_list = ImGui::GetWindowDrawList();
|
||||
ImVec2 circle_pos =
|
||||
ImVec2(image_screen_pos.x + recent_connection_image_width * 0.07f,
|
||||
image_screen_pos.y + recent_connection_image_height * 0.13f);
|
||||
ImU32 fill_color =
|
||||
online ? IM_COL32(0, 255, 0, 255) : IM_COL32(140, 140, 140, 255);
|
||||
ImU32 border_color = IM_COL32(255, 255, 255, 230);
|
||||
draw_list->AddCircleFilled(circle_pos, 6.0f, fill_color);
|
||||
draw_list->AddCircle(circle_pos, 6.0f, border_color, 100, 2.0f);
|
||||
if (ImGui::IsMouseHoveringRect(
|
||||
ImVec2(circle_pos.x - 6.0f, circle_pos.y - 6.0f),
|
||||
ImVec2(circle_pos.x + 6.0f, circle_pos.y + 6.0f))) {
|
||||
ImGui::BeginTooltip();
|
||||
ImGui::SetWindowFontScale(0.5f);
|
||||
ImGui::Text("%s", online ? localization::online[0].c_str()
|
||||
: localization::offline[0].c_str());
|
||||
ImGui::SetWindowFontScale(1.0f);
|
||||
ImGui::EndTooltip();
|
||||
}
|
||||
|
||||
// remote id display button
|
||||
{
|
||||
ImGui::PushStyleColor(ImGuiCol_Button, ImVec4(0, 0, 0, 0.2f));
|
||||
|
||||
Reference in New Issue
Block a user