mirror of
https://github.com/kunkundi/crossdesk.git
synced 2025-10-26 20:25:34 +08:00
[feat] remote host names will be shown below thumbnails
This commit is contained in:
@@ -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;
|
||||
}
|
||||
@@ -225,7 +225,7 @@ class Render {
|
||||
bool stream_window_inited_ = false;
|
||||
|
||||
// recent connections
|
||||
std::vector<SDL_Texture *> recent_connection_textures_;
|
||||
std::map<std::string, SDL_Texture *> recent_connection_textures_;
|
||||
int recent_connection_image_width_ = 128;
|
||||
int recent_connection_image_height_ = 72;
|
||||
uint32_t recent_connection_image_save_time_ = 0;
|
||||
|
||||
@@ -173,8 +173,8 @@ std::vector<std::filesystem::path> Thumbnail::FindThumbnailPath(
|
||||
}
|
||||
|
||||
int Thumbnail::LoadThumbnail(SDL_Renderer* renderer,
|
||||
std::vector<SDL_Texture*>& textures, int* width,
|
||||
int* height) {
|
||||
std::map<std::string, SDL_Texture*>& textures,
|
||||
int* width, int* height) {
|
||||
std::vector<std::filesystem::path> 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;
|
||||
}
|
||||
@@ -22,8 +22,9 @@ class Thumbnail {
|
||||
const std::string& host_name,
|
||||
const std::string& remote_id);
|
||||
|
||||
int LoadThumbnail(SDL_Renderer* renderer, std::vector<SDL_Texture*>& textures,
|
||||
int* width, int* height);
|
||||
int LoadThumbnail(SDL_Renderer* renderer,
|
||||
std::map<std::string, SDL_Texture*>& textures, int* width,
|
||||
int* height);
|
||||
|
||||
private:
|
||||
std::vector<std::filesystem::path> FindThumbnailPath(
|
||||
|
||||
Reference in New Issue
Block a user