diff --git a/src/single_window/main_window.cpp b/src/single_window/main_window.cpp index 00e5053..e7f0d06 100644 --- a/src/single_window/main_window.cpp +++ b/src/single_window/main_window.cpp @@ -55,6 +55,7 @@ int Render::MainWindow() { ImGui::TextColored( ImVec4(0.0f, 0.0f, 0.0f, 0.5f), "%s", localization::recent_connections[localization_language_index_].c_str()); + ImGui::SetWindowFontScale(1.0f); draw_list->AddLine( ImVec2(25.0f, title_bar_height_ + local_window_height_ + 35.0f), @@ -75,11 +76,35 @@ int Render::MainWindow() { } int Render::ShowRecentConnections() { - for (int i = 0; i < recent_connection_textures_.size(); i++) { - ImGui::Image((ImTextureID)(intptr_t)recent_connection_textures_[i], + for (auto it = recent_connection_textures_.begin(); + it != recent_connection_textures_.end(); ++it) { + std::string recent_connection_sub_window_name = + "RecentConnectionsSubWindow" + it->first; + ImGui::BeginChild(recent_connection_sub_window_name.c_str(), + ImVec2(recent_connection_image_width_ + 16.0f, + recent_connection_image_height_ + 32.0f), + ImGuiChildFlags_Border, + ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoCollapse | + ImGuiWindowFlags_NoMove | + ImGuiWindowFlags_NoTitleBar | + ImGuiWindowFlags_NoBringToFrontOnFocus | + ImGuiWindowFlags_NoScrollbar); + ImGui::Image((ImTextureID)(intptr_t)it->second, ImVec2((float)recent_connection_image_width_, (float)recent_connection_image_height_)); + ImGui::SetWindowFontScale(0.4f); + + ImVec2 window_size = ImGui::GetWindowSize(); + ImVec2 text_size = ImGui::CalcTextSize(it->first.c_str()); + ImVec2 pos = ImGui::GetCursorPos(); + pos.x = (window_size.x - text_size.x) / 2.0f; + ImGui::SetCursorPos(pos); + + ImGui::Text("%s", it->first.c_str()); + ImGui::SetWindowFontScale(1.0f); + ImGui::EndChild(); ImGui::SameLine(); } + return 0; } \ No newline at end of file diff --git a/src/single_window/render.h b/src/single_window/render.h index 89d8a4c..b974ae8 100644 --- a/src/single_window/render.h +++ b/src/single_window/render.h @@ -225,7 +225,7 @@ class Render { bool stream_window_inited_ = false; // recent connections - std::vector recent_connection_textures_; + std::map recent_connection_textures_; int recent_connection_image_width_ = 128; int recent_connection_image_height_ = 72; uint32_t recent_connection_image_save_time_ = 0; diff --git a/src/single_window/thumbnail.cpp b/src/single_window/thumbnail.cpp index df89a54..6f68729 100644 --- a/src/single_window/thumbnail.cpp +++ b/src/single_window/thumbnail.cpp @@ -173,8 +173,8 @@ std::vector Thumbnail::FindThumbnailPath( } int Thumbnail::LoadThumbnail(SDL_Renderer* renderer, - std::vector& textures, int* width, - int* height) { + std::map& textures, + int* width, int* height) { std::vector image_path = FindThumbnailPath(image_path_); @@ -182,10 +182,14 @@ int Thumbnail::LoadThumbnail(SDL_Renderer* renderer, return -1; } else { for (int i = 0; i < image_path.size(); i++) { - textures.push_back(nullptr); + size_t pos1 = image_path[i].string().find('\\') + 1; + size_t pos2 = image_path[i].string().rfind('@'); + std::string host_name = image_path[i].string().substr(pos1, pos2 - pos1); + textures[host_name] = nullptr; LoadTextureFromFile(image_path[i].string().c_str(), renderer, - &(textures[i]), width, height); + &(textures[host_name]), width, height); } return 0; } + return 0; } \ No newline at end of file diff --git a/src/single_window/thumbnail.h b/src/single_window/thumbnail.h index d5c1d52..4f6d3dc 100644 --- a/src/single_window/thumbnail.h +++ b/src/single_window/thumbnail.h @@ -22,8 +22,9 @@ class Thumbnail { const std::string& host_name, const std::string& remote_id); - int LoadThumbnail(SDL_Renderer* renderer, std::vector& textures, - int* width, int* height); + int LoadThumbnail(SDL_Renderer* renderer, + std::map& textures, int* width, + int* height); private: std::vector FindThumbnailPath(