mirror of
				https://github.com/kunkundi/crossdesk.git
				synced 2025-10-26 20:25:34 +08:00 
			
		
		
		
	[feat] use horizontal scroll bar to show all recent connections
This commit is contained in:
		| @@ -24,31 +24,31 @@ int Render::MainWindow() { | |||||||
|  |  | ||||||
|   ImDrawList* draw_list = ImGui::GetWindowDrawList(); |   ImDrawList* draw_list = ImGui::GetWindowDrawList(); | ||||||
|   draw_list->AddLine( |   draw_list->AddLine( | ||||||
|       ImVec2(main_window_width_default_ / 2, title_bar_height_ + 25.0f), |       ImVec2(main_window_width_default_ / 2, title_bar_height_ + 15.0f), | ||||||
|       ImVec2(main_window_width_default_ / 2, title_bar_height_ + 240.0f), |       ImVec2(main_window_width_default_ / 2, title_bar_height_ + 225.0f), | ||||||
|       IM_COL32(0, 0, 0, 122), 1.0f); |       IM_COL32(0, 0, 0, 122), 1.0f); | ||||||
|  |  | ||||||
|   RemoteWindow(); |   RemoteWindow(); | ||||||
|   ImGui::EndChild(); |   ImGui::EndChild(); | ||||||
|  |  | ||||||
|   ImGui::SetNextWindowPos( |   ImGui::SetNextWindowPos( | ||||||
|       ImVec2(0, title_bar_height_ + local_window_height_ - 1), |       ImVec2(0, title_bar_height_ + local_window_height_ - 1.0f), | ||||||
|       ImGuiCond_Always); |       ImGuiCond_Always); | ||||||
|   ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2(0.0f, 0.0f)); |   ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2(0.0f, 0.0f)); | ||||||
|   ImGui::PushStyleColor(ImGuiCol_ChildBg, ImVec4(1.0f, 1.0f, 1.0f, 0.0f)); |   ImGui::PushStyleColor(ImGuiCol_ChildBg, ImVec4(1.0f, 1.0f, 1.0f, 1.0f)); | ||||||
|   ImGui::BeginChild("RecentConnectionsWindow", |   ImGui::BeginChild( | ||||||
|                     ImVec2(main_window_width_default_, |       "RecentConnectionsWindow", | ||||||
|                            main_window_height_default_ - title_bar_height_ - |       ImVec2(main_window_width_default_, | ||||||
|                                local_window_height_ - status_bar_height_), |              main_window_height_default_ - title_bar_height_ - | ||||||
|                     ImGuiChildFlags_Border, |                  local_window_height_ - status_bar_height_ + 1.0f), | ||||||
|                     ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoCollapse | |       ImGuiChildFlags_Border, | ||||||
|                         ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoTitleBar | |       ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoCollapse | | ||||||
|                         ImGuiWindowFlags_NoBringToFrontOnFocus); |           ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoTitleBar | | ||||||
|  |           ImGuiWindowFlags_NoBringToFrontOnFocus); | ||||||
|   ImGui::PopStyleVar(); |   ImGui::PopStyleVar(); | ||||||
|   ImGui::PopStyleColor(); |   ImGui::PopStyleColor(); | ||||||
|  |  | ||||||
|   ImGui::SetCursorPosY(ImGui::GetCursorPosY() + |   ImGui::SetCursorPosY(ImGui::GetCursorPosY() + main_window_text_y_padding_); | ||||||
|                        main_window_text_y_padding_ / 2); |  | ||||||
|   ImGui::Indent(main_child_window_x_padding_); |   ImGui::Indent(main_child_window_x_padding_); | ||||||
|   ImGui::SetWindowFontScale(0.8f); |   ImGui::SetWindowFontScale(0.8f); | ||||||
|  |  | ||||||
| @@ -57,14 +57,6 @@ int Render::MainWindow() { | |||||||
|       localization::recent_connections[localization_language_index_].c_str()); |       localization::recent_connections[localization_language_index_].c_str()); | ||||||
|   ImGui::SetWindowFontScale(1.0f); |   ImGui::SetWindowFontScale(1.0f); | ||||||
|  |  | ||||||
|   draw_list->AddLine( |  | ||||||
|       ImVec2(25.0f, title_bar_height_ + local_window_height_ + 35.0f), |  | ||||||
|       ImVec2(main_window_width_default_ - 25.0f, |  | ||||||
|              title_bar_height_ + local_window_height_ + 35.0f), |  | ||||||
|       IM_COL32(0, 0, 0, 122), 1.0f); |  | ||||||
|  |  | ||||||
|   ImGui::SetCursorPosY(ImGui::GetCursorPosY() + |  | ||||||
|                        main_window_text_y_padding_ / 2); |  | ||||||
|   ShowRecentConnections(); |   ShowRecentConnections(); | ||||||
|  |  | ||||||
|   ImGui::EndChild(); |   ImGui::EndChild(); | ||||||
| @@ -76,6 +68,17 @@ int Render::MainWindow() { | |||||||
| } | } | ||||||
|  |  | ||||||
| int Render::ShowRecentConnections() { | int Render::ShowRecentConnections() { | ||||||
|  |   ImGui::SetCursorPosX(25.0f); | ||||||
|  |   ImGui::BeginChild("RecentConnectionsContainer", | ||||||
|  |                     ImVec2(main_window_width_default_ - 50.0f, 152.0f), | ||||||
|  |                     ImGuiChildFlags_Border, | ||||||
|  |                     ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoCollapse | | ||||||
|  |                         ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoTitleBar | | ||||||
|  |                         ImGuiWindowFlags_NoBringToFrontOnFocus | | ||||||
|  |                         ImGuiWindowFlags_AlwaysHorizontalScrollbar); | ||||||
|  |  | ||||||
|  |   int recent_connections_count = recent_connection_textures_.size(); | ||||||
|  |   int count = 0; | ||||||
|   for (auto it = recent_connection_textures_.begin(); |   for (auto it = recent_connection_textures_.begin(); | ||||||
|        it != recent_connection_textures_.end(); ++it) { |        it != recent_connection_textures_.end(); ++it) { | ||||||
|     std::string recent_connection_sub_window_name = |     std::string recent_connection_sub_window_name = | ||||||
| @@ -103,8 +106,10 @@ int Render::ShowRecentConnections() { | |||||||
|     ImGui::Text("%s", it->first.c_str()); |     ImGui::Text("%s", it->first.c_str()); | ||||||
|     ImGui::SetWindowFontScale(1.0f); |     ImGui::SetWindowFontScale(1.0f); | ||||||
|     ImGui::EndChild(); |     ImGui::EndChild(); | ||||||
|     ImGui::SameLine(); |     count++; | ||||||
|  |     ImGui::SameLine(0, count != recent_connections_count ? 23.0f : 0.0f); | ||||||
|   } |   } | ||||||
|  |   ImGui::EndChild(); | ||||||
|  |  | ||||||
|   return 0; |   return 0; | ||||||
| } | } | ||||||
| @@ -914,6 +914,7 @@ int Render::Run() { | |||||||
|         int ret = thumbnail_.LoadThumbnail( |         int ret = thumbnail_.LoadThumbnail( | ||||||
|             main_renderer_, recent_connection_textures_, |             main_renderer_, recent_connection_textures_, | ||||||
|             &recent_connection_image_width_, &recent_connection_image_height_); |             &recent_connection_image_width_, &recent_connection_image_height_); | ||||||
|  |         LOG_ERROR("load [{} {}]", ret, recent_connection_textures_.size()); | ||||||
|         if (!ret) { |         if (!ret) { | ||||||
|           LOG_INFO("Load recent connection thumbnails"); |           LOG_INFO("Load recent connection thumbnails"); | ||||||
|         } |         } | ||||||
|   | |||||||
| @@ -176,16 +176,16 @@ class Render { | |||||||
|   int control_window_width_ = 170; |   int control_window_width_ = 170; | ||||||
|   int control_window_height_ = 40; |   int control_window_height_ = 40; | ||||||
|   int local_window_width_ = 320; |   int local_window_width_ = 320; | ||||||
|   int local_window_height_ = 260; |   int local_window_height_ = 235; | ||||||
|   int remote_window_width_ = 320; |   int remote_window_width_ = 320; | ||||||
|   int remote_window_height_ = 260; |   int remote_window_height_ = 235; | ||||||
|   int local_child_window_width_ = 266; |   int local_child_window_width_ = 266; | ||||||
|   int local_child_window_height_ = 180; |   int local_child_window_height_ = 180; | ||||||
|   int remote_child_window_width_ = 266; |   int remote_child_window_width_ = 266; | ||||||
|   int remote_child_window_height_ = 180; |   int remote_child_window_height_ = 180; | ||||||
|   int main_window_text_y_padding_ = 20; |   int main_window_text_y_padding_ = 10; | ||||||
|   int main_child_window_x_padding_ = 27; |   int main_child_window_x_padding_ = 27; | ||||||
|   int main_child_window_y_padding_ = 60; |   int main_child_window_y_padding_ = 45; | ||||||
|   int status_bar_height_ = 20; |   int status_bar_height_ = 20; | ||||||
|   int connection_status_window_width_ = 200; |   int connection_status_window_width_ = 200; | ||||||
|   int connection_status_window_height_ = 150; |   int connection_status_window_height_ = 150; | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user