diff --git a/src/single_window/about_window.cpp b/src/single_window/about_window.cpp index 65067b6..4cc6d1d 100644 --- a/src/single_window/about_window.cpp +++ b/src/single_window/about_window.cpp @@ -1,4 +1,3 @@ -#include "IconsFontAwesome6.h" #include "layout_style.h" #include "localization.h" #include "rd_log.h" diff --git a/src/single_window/control_bar.cpp b/src/single_window/control_bar.cpp index 70affdf..5821e5e 100644 --- a/src/single_window/control_bar.cpp +++ b/src/single_window/control_bar.cpp @@ -1,4 +1,3 @@ -#include "IconsFontAwesome6.h" #include "layout_style.h" #include "localization.h" #include "rd_log.h" diff --git a/src/single_window/local_peer_window.cpp b/src/single_window/local_peer_window.cpp index 678d7e4..80cd301 100644 --- a/src/single_window/local_peer_window.cpp +++ b/src/single_window/local_peer_window.cpp @@ -1,6 +1,5 @@ #include -#include "IconsFontAwesome6.h" #include "layout_style.h" #include "localization.h" #include "rd_log.h" diff --git a/src/single_window/main_window.cpp b/src/single_window/main_window.cpp index fc5e884..ee5ba5b 100644 --- a/src/single_window/main_window.cpp +++ b/src/single_window/main_window.cpp @@ -1,4 +1,3 @@ -#include "IconsFontAwesome6.h" #include "localization.h" #include "rd_log.h" #include "render.h" @@ -87,6 +86,8 @@ int Render::ShowRecentConnections() { ImGui::PopStyleColor(); int recent_connections_count = recent_connection_textures_.size(); int count = 0; + int button_width = 20; + int button_height = 20; for (auto it = recent_connection_textures_.begin(); it != recent_connection_textures_.end(); ++it) { sub_containers_pos[it->first] = ImGui::GetCursorPos(); @@ -112,42 +113,105 @@ int Render::ShowRecentConnections() { ImGui::SetCursorPos(pos); ImGui::Text(host_name.c_str()); ImGui::SetWindowFontScale(1.0f); + ImVec2 image_pos = ImGui::GetCursorPos(); ImGui::Image((ImTextureID)(intptr_t)it->second, ImVec2((float)recent_connection_image_width_, (float)recent_connection_image_height_)); + ImGui::PushStyleColor(ImGuiCol_Button, ImVec4(1.0f, 1.0f, 1.0f, 0.8f)); + ImGui::PushStyleColor(ImGuiCol_ButtonHovered, + ImVec4(0.1f, 0.4f, 0.8f, 1.0f)); + ImGui::PushStyleColor(ImGuiCol_ButtonActive, + ImVec4(1.0f, 1.0f, 1.0f, 0.7f)); + ImVec2 trash_can_button_pos = + ImVec2(image_pos.x, + image_pos.y + recent_connection_image_height_ - button_height); + ImGui::SetCursorPos(trash_can_button_pos); + ImGui::SetWindowFontScale(0.5f); + std::string trash_can = ICON_FA_TRASH_CAN; + std::string recent_connection_delete_button_name = + trash_can + "##RecentConnectionDelete" + + std::to_string(trash_can_button_pos.x); + if (ImGui::Button(recent_connection_delete_button_name.c_str())) { + show_confirm_delete_connection_ = true; + } + + if (delete_connection_) { + if (!thumbnail_.DeleteThumbnail(it->first)) { + reload_recent_connections_ = true; + delete_connection_ = false; + } + } + + ImVec2 connect_button_pos = + ImVec2(image_pos.x + recent_connection_image_width_ - button_width, + image_pos.y + recent_connection_image_height_ - button_height); + ImGui::SetCursorPos(connect_button_pos); + std::string connect = ICON_FA_ARROW_RIGHT_LONG; + std::string connect_to_this_connection_button_name = + connect + "##ConnectionTo" + it->first; + if (ImGui::Button(connect_to_this_connection_button_name.c_str(), + ImVec2(button_width, button_height))) { + LOG_ERROR("Connect to [{}]", + connect_to_this_connection_button_name.c_str()); + } + ImGui::SetWindowFontScale(1.0f); + ImGui::PopStyleColor(3); + ImGui::EndChild(); count++; ImGui::SameLine(0, count != recent_connections_count ? 23.0f : 0.0f); } - ImGui::PushStyleColor(ImGuiCol_Button, ImVec4(0, 0, 0, 0)); - ImGui::PushStyleColor(ImGuiCol_ButtonHovered, ImVec4(0, 0, 0, 0)); - ImGui::PushStyleColor(ImGuiCol_ButtonActive, ImVec4(0, 0, 0, 0)); - for (const auto& pos : sub_containers_pos) { - ImVec2 delete_button_pos = - ImVec2(pos.second.x + recent_connection_sub_container_width - 11.0f, - pos.second.y - 7.0f); - ImGui::SetCursorPos(delete_button_pos); - ImGui::SetWindowFontScale(0.5f); - std::string xmake = ICON_FA_CIRCLE_XMARK; - std::string recent_connection_delete_button_name = - xmake + "##RecentConnectionDelete" + - std::to_string(delete_button_pos.x); - if (ImGui::SmallButton(recent_connection_delete_button_name.c_str())) { - show_confirm_delete_connection_ = true; - } + // ImGui::PushStyleColor(ImGuiCol_Button, ImVec4(0, 0, 0, 0)); + // ImGui::PushStyleColor(ImGuiCol_ButtonHovered, ImVec4(0, 0, 0, 0)); + // ImGui::PushStyleColor(ImGuiCol_ButtonActive, ImVec4(0, 0, 0, 0)); + // for (const auto& pos : sub_containers_pos) { + // ImVec2 delete_button_pos = + // ImVec2(pos.second.x + recent_connection_sub_container_width - 11.0f, + // pos.second.y - 7.0f); + // ImGui::SetCursorPos(delete_button_pos); + // ImGui::SetWindowFontScale(0.5f); + // std::string xmake = ICON_FA_CIRCLE_XMARK; + // std::string recent_connection_delete_button_name = + // xmake + "##RecentConnectionDelete" + + // std::to_string(delete_button_pos.x); + // if (ImGui::SmallButton(recent_connection_delete_button_name.c_str())) { + // show_confirm_delete_connection_ = true; + // } - if (delete_connection_) { - if (!thumbnail_.DeleteThumbnail(pos.first)) { - reload_recent_connections_ = true; - delete_connection_ = false; - } - } - ImGui::SetWindowFontScale(1.0f); - } - ImGui::PopStyleColor(3); + // if (delete_connection_) { + // if (!thumbnail_.DeleteThumbnail(pos.first)) { + // reload_recent_connections_ = true; + // delete_connection_ = false; + // } + // } + // ImGui::SetWindowFontScale(1.0f); + + // { + // int delete_button_width = 20; + // int delete_button_height = 20; + // int pos_x = pos.second.x; + // int pos_y = pos.second.y + recent_connection_sub_container_height - + // delete_button_height; + // ImVec2 connect_button_pos = ImVec2(pos_x, pos_y); + // ImGui::SetCursorPos(connect_button_pos); + // ImGui::PushStyleColor(ImGuiCol_Button, ImVec4(1, 0, 0, 1)); + // ImGui::PushStyleColor(ImGuiCol_ButtonHovered, ImVec4(0, 1, 0, 1)); + // ImGui::PushStyleColor(ImGuiCol_ButtonActive, ImVec4(0, 0, 1, 1)); + // std::string connect_to_this_connection_button_name = + // "##ConnectionTo" + pos.first; + // if (ImGui::Button(connect_to_this_connection_button_name.c_str(), + // ImVec2(delete_button_width, delete_button_height))) { + // LOG_ERROR("Connect to [{}]", + // connect_to_this_connection_button_name.c_str()); + // } + + // ImGui::PopStyleColor(3); + // } + // } + // ImGui::PopStyleColor(3); ImGui::EndChild(); diff --git a/src/single_window/remote_peer_window.cpp b/src/single_window/remote_peer_window.cpp index fb52496..ed0ea98 100644 --- a/src/single_window/remote_peer_window.cpp +++ b/src/single_window/remote_peer_window.cpp @@ -1,4 +1,3 @@ -#include "IconsFontAwesome6.h" #include "layout_style.h" #include "localization.h" #include "rd_log.h" diff --git a/src/single_window/render.cpp b/src/single_window/render.cpp index 71a8ebc..6ac408d 100644 --- a/src/single_window/render.cpp +++ b/src/single_window/render.cpp @@ -5,7 +5,6 @@ #include #include -#include "IconsFontAwesome6.h" #include "OPPOSans_Regular.h" #include "device_controller_factory.h" #include "fa_regular_400.h" diff --git a/src/single_window/render.h b/src/single_window/render.h index 74ee089..a25d22b 100644 --- a/src/single_window/render.h +++ b/src/single_window/render.h @@ -14,6 +14,7 @@ #include #include "../../thirdparty/projectx/src/interface/x.h" +#include "IconsFontAwesome6.h" #include "config_center.h" #include "device_controller_factory.h" #include "imgui.h" diff --git a/src/single_window/setting_window.cpp b/src/single_window/setting_window.cpp index 31b9332..6bac551 100644 --- a/src/single_window/setting_window.cpp +++ b/src/single_window/setting_window.cpp @@ -1,4 +1,3 @@ -#include "IconsFontAwesome6.h" #include "layout_style.h" #include "localization.h" #include "rd_log.h" diff --git a/src/single_window/title_bar.cpp b/src/single_window/title_bar.cpp index 220a869..ba3150b 100644 --- a/src/single_window/title_bar.cpp +++ b/src/single_window/title_bar.cpp @@ -1,4 +1,3 @@ -#include "IconsFontAwesome6.h" #include "localization.h" #include "render.h"