mirror of
https://github.com/kunkundi/crossdesk.git
synced 2026-07-26 09:18:41 +08:00
[fix] refine recent connections overflow layout, refs #85
This commit is contained in:
@@ -82,6 +82,16 @@ int Render::ShowRecentConnections() {
|
|||||||
float recent_connection_footer_height =
|
float recent_connection_footer_height =
|
||||||
recent_connection_button_height * 1.18f;
|
recent_connection_button_height * 1.18f;
|
||||||
float recent_connection_name_width = recent_connection_image_width;
|
float recent_connection_name_width = recent_connection_image_width;
|
||||||
|
const float recent_connection_spacing = recent_connection_image_width * 0.16f;
|
||||||
|
const float recent_connections_content_width =
|
||||||
|
recent_connections_.empty()
|
||||||
|
? 0.0f
|
||||||
|
: recent_connections_.size() * recent_connection_sub_container_width +
|
||||||
|
(recent_connections_.size() - 1) * recent_connection_spacing;
|
||||||
|
const float recent_connections_available_width =
|
||||||
|
recent_connection_panel_width - 2.0f * ImGui::GetStyle().WindowPadding.x;
|
||||||
|
const bool has_horizontal_overflow =
|
||||||
|
recent_connections_content_width > recent_connections_available_width;
|
||||||
|
|
||||||
ImGui::SetCursorPos(
|
ImGui::SetCursorPos(
|
||||||
ImVec2(io.DisplaySize.x * 0.045f, io.DisplaySize.y * 0.1f));
|
ImVec2(io.DisplaySize.x * 0.045f, io.DisplaySize.y * 0.1f));
|
||||||
@@ -92,10 +102,10 @@ int Render::ShowRecentConnections() {
|
|||||||
ImGui::PushStyleVar(ImGuiStyleVar_ChildRounding, 10.0f);
|
ImGui::PushStyleVar(ImGuiStyleVar_ChildRounding, 10.0f);
|
||||||
const ImGuiWindowFlags container_flags =
|
const ImGuiWindowFlags container_flags =
|
||||||
ImGuiWindowFlags_NoDecoration | ImGuiWindowFlags_NoMove |
|
ImGuiWindowFlags_NoDecoration | ImGuiWindowFlags_NoMove |
|
||||||
ImGuiWindowFlags_NoBringToFrontOnFocus | ImGuiWindowFlags_NoScrollWithMouse |
|
ImGuiWindowFlags_NoBringToFrontOnFocus |
|
||||||
(recent_connections_.empty()
|
ImGuiWindowFlags_NoScrollWithMouse |
|
||||||
? ImGuiWindowFlags_None
|
(has_horizontal_overflow ? ImGuiWindowFlags_AlwaysHorizontalScrollbar
|
||||||
: ImGuiWindowFlags_AlwaysHorizontalScrollbar);
|
: ImGuiWindowFlags_None);
|
||||||
ImGui::BeginChild(
|
ImGui::BeginChild(
|
||||||
"RecentConnectionsContainer",
|
"RecentConnectionsContainer",
|
||||||
ImVec2(recent_connection_panel_width, recent_connection_panel_height),
|
ImVec2(recent_connection_panel_width, recent_connection_panel_height),
|
||||||
@@ -221,21 +231,19 @@ int Render::ShowRecentConnections() {
|
|||||||
|
|
||||||
if (show_image_tooltip) {
|
if (show_image_tooltip) {
|
||||||
const ImVec2 mouse_pos = ImGui::GetMousePos();
|
const ImVec2 mouse_pos = ImGui::GetMousePos();
|
||||||
const bool place_tooltip_on_left =
|
const bool place_tooltip_on_left = mouse_pos.x > io.DisplaySize.x * 0.7f;
|
||||||
mouse_pos.x > io.DisplaySize.x * 0.7f;
|
|
||||||
ImGui::SetNextWindowPos(
|
ImGui::SetNextWindowPos(
|
||||||
ImVec2(mouse_pos.x + (place_tooltip_on_left ? -12.0f : 12.0f),
|
ImVec2(mouse_pos.x + (place_tooltip_on_left ? -12.0f : 12.0f),
|
||||||
mouse_pos.y - 8.0f),
|
mouse_pos.y - 8.0f),
|
||||||
ImGuiCond_Always,
|
ImGuiCond_Always, ImVec2(place_tooltip_on_left ? 1.0f : 0.0f, 1.0f));
|
||||||
ImVec2(place_tooltip_on_left ? 1.0f : 0.0f, 1.0f));
|
|
||||||
ImGui::BeginTooltip();
|
ImGui::BeginTooltip();
|
||||||
|
|
||||||
ImGui::SetWindowFontScale(0.4f);
|
ImGui::SetWindowFontScale(0.4f);
|
||||||
|
|
||||||
ImGui::Text("%s: %s",
|
ImGui::Text(
|
||||||
localization::device_name[localization_language_index_]
|
"%s: %s",
|
||||||
.c_str(),
|
localization::device_name[localization_language_index_].c_str(),
|
||||||
display_name.c_str());
|
display_name.c_str());
|
||||||
|
|
||||||
if (!it.second.remote_host_name.empty() &&
|
if (!it.second.remote_host_name.empty() &&
|
||||||
it.second.remote_host_name != display_name) {
|
it.second.remote_host_name != display_name) {
|
||||||
@@ -295,8 +303,8 @@ int Render::ShowRecentConnections() {
|
|||||||
const float t = static_cast<float>(i) / halo_layers;
|
const float t = static_cast<float>(i) / halo_layers;
|
||||||
const float r = dot_radius + (halo_radius - dot_radius) * t;
|
const float r = dot_radius + (halo_radius - dot_radius) * t;
|
||||||
const int alpha = static_cast<int>(14.0f * (1.0f - t) + 4.0f);
|
const int alpha = static_cast<int>(14.0f * (1.0f - t) + 4.0f);
|
||||||
draw_list->AddCircleFilled(
|
draw_list->AddCircleFilled(dot_center, r,
|
||||||
dot_center, r, IM_COL32(74, 222, 128, alpha));
|
IM_COL32(74, 222, 128, alpha));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
draw_list->AddCircleFilled(dot_center, dot_radius, dot_color);
|
draw_list->AddCircleFilled(dot_center, dot_radius, dot_color);
|
||||||
@@ -306,12 +314,11 @@ int Render::ShowRecentConnections() {
|
|||||||
ImVec2 text_min =
|
ImVec2 text_min =
|
||||||
ImVec2(status_block_end_x + status_gap, footer_screen_pos.y);
|
ImVec2(status_block_end_x + status_gap, footer_screen_pos.y);
|
||||||
|
|
||||||
ImVec2 text_max =
|
ImVec2 text_max = ImVec2(
|
||||||
ImVec2(card_hovered
|
card_hovered
|
||||||
? toolbar_screen_pos.x - status_gap
|
? toolbar_screen_pos.x - status_gap
|
||||||
: footer_screen_end.x -
|
: footer_screen_end.x - recent_connection_name_width * 0.05f,
|
||||||
recent_connection_name_width * 0.05f,
|
footer_screen_end.y);
|
||||||
footer_screen_end.y);
|
|
||||||
|
|
||||||
ImGui::SetWindowFontScale(0.52f);
|
ImGui::SetWindowFontScale(0.52f);
|
||||||
|
|
||||||
@@ -424,20 +431,6 @@ int Render::ShowRecentConnections() {
|
|||||||
ImGui::PopStyleVar(3);
|
ImGui::PopStyleVar(3);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (count != recent_connections_count - 1) {
|
|
||||||
ImVec2 line_start =
|
|
||||||
ImVec2(image_screen_pos.x + recent_connection_image_width * 1.19f,
|
|
||||||
image_screen_pos.y);
|
|
||||||
|
|
||||||
ImVec2 line_end =
|
|
||||||
ImVec2(image_screen_pos.x + recent_connection_image_width * 1.19f,
|
|
||||||
image_screen_pos.y + recent_connection_image_height +
|
|
||||||
recent_connection_footer_height);
|
|
||||||
|
|
||||||
ImGui::GetWindowDrawList()->AddLine(line_start, line_end,
|
|
||||||
IM_COL32(0, 0, 0, 122), 1.0f);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (delete_connection_ && delete_connection_name_ == it.first) {
|
if (delete_connection_ && delete_connection_name_ == it.first) {
|
||||||
if (!thumbnail_->DeleteThumbnail(it.first)) {
|
if (!thumbnail_->DeleteThumbnail(it.first)) {
|
||||||
recent_connection_aliases_.erase(it.second.remote_id);
|
recent_connection_aliases_.erase(it.second.remote_id);
|
||||||
@@ -451,10 +444,10 @@ int Render::ShowRecentConnections() {
|
|||||||
|
|
||||||
if (count != recent_connections_count - 1) {
|
if (count != recent_connections_count - 1) {
|
||||||
ImVec2 line_start =
|
ImVec2 line_start =
|
||||||
ImVec2(image_screen_pos.x + recent_connection_image_width * 1.19f,
|
ImVec2(image_screen_pos.x + recent_connection_image_width * 1.18f,
|
||||||
image_screen_pos.y);
|
image_screen_pos.y);
|
||||||
ImVec2 line_end =
|
ImVec2 line_end =
|
||||||
ImVec2(image_screen_pos.x + recent_connection_image_width * 1.19f,
|
ImVec2(image_screen_pos.x + recent_connection_image_width * 1.18f,
|
||||||
image_screen_pos.y + recent_connection_image_height +
|
image_screen_pos.y + recent_connection_image_height +
|
||||||
recent_connection_footer_height);
|
recent_connection_footer_height);
|
||||||
ImGui::GetWindowDrawList()->AddLine(line_start, line_end,
|
ImGui::GetWindowDrawList()->AddLine(line_start, line_end,
|
||||||
@@ -463,7 +456,7 @@ int Render::ShowRecentConnections() {
|
|||||||
|
|
||||||
count++;
|
count++;
|
||||||
ImGui::SameLine(0, count != recent_connections_count
|
ImGui::SameLine(0, count != recent_connections_count
|
||||||
? (recent_connection_image_width * 0.165f)
|
? recent_connection_spacing
|
||||||
: 0.0f);
|
: 0.0f);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+18
-22
@@ -742,10 +742,9 @@ void Render::BeginEditRecentConnectionAlias(
|
|||||||
memset(edit_connection_alias_, 0, sizeof(edit_connection_alias_));
|
memset(edit_connection_alias_, 0, sizeof(edit_connection_alias_));
|
||||||
|
|
||||||
const auto alias_it = recent_connection_aliases_.find(connection.remote_id);
|
const auto alias_it = recent_connection_aliases_.find(connection.remote_id);
|
||||||
std::string alias =
|
std::string alias = alias_it != recent_connection_aliases_.end()
|
||||||
alias_it != recent_connection_aliases_.end()
|
? alias_it->second
|
||||||
? alias_it->second
|
: GetRecentConnectionDisplayName(connection);
|
||||||
: GetRecentConnectionDisplayName(connection);
|
|
||||||
|
|
||||||
if (!alias.empty()) {
|
if (!alias.empty()) {
|
||||||
strncpy(edit_connection_alias_, alias.c_str(),
|
strncpy(edit_connection_alias_, alias.c_str(),
|
||||||
@@ -781,21 +780,17 @@ int Render::ScreenCapturerInit() {
|
|||||||
fps,
|
fps,
|
||||||
[this, fps](unsigned char* data, int size, int width, int height,
|
[this, fps](unsigned char* data, int size, int width, int height,
|
||||||
const char* display_name) -> void {
|
const char* display_name) -> void {
|
||||||
const auto now_time =
|
const auto now_time = static_cast<uint64_t>(
|
||||||
static_cast<uint64_t>(std::chrono::duration_cast<
|
std::chrono::duration_cast<std::chrono::milliseconds>(
|
||||||
std::chrono::milliseconds>(
|
std::chrono::steady_clock::now().time_since_epoch())
|
||||||
std::chrono::steady_clock::now()
|
.count());
|
||||||
.time_since_epoch())
|
|
||||||
.count());
|
|
||||||
auto duration = now_time - last_frame_time_;
|
auto duration = now_time - last_frame_time_;
|
||||||
if (duration * fps >= 1000) { // ~60 FPS
|
if (duration * fps >= 1000) { // ~60 FPS
|
||||||
const std::string stream_id = display_name ? display_name : "";
|
const std::string stream_id = display_name ? display_name : "";
|
||||||
const bool resumed_after_gap =
|
const bool resumed_after_gap =
|
||||||
last_frame_time_ != 0 &&
|
last_frame_time_ != 0 && duration >= kCaptureResumeKeyFrameGapMs;
|
||||||
duration >= kCaptureResumeKeyFrameGapMs;
|
const bool stream_changed = !last_video_frame_stream_id_.empty() &&
|
||||||
const bool stream_changed =
|
last_video_frame_stream_id_ != stream_id;
|
||||||
!last_video_frame_stream_id_.empty() &&
|
|
||||||
last_video_frame_stream_id_ != stream_id;
|
|
||||||
if (resumed_after_gap || stream_changed) {
|
if (resumed_after_gap || stream_changed) {
|
||||||
if (RequestVideoKeyFrame(peer_, stream_id.c_str()) == 0) {
|
if (RequestVideoKeyFrame(peer_, stream_id.c_str()) == 0) {
|
||||||
LOG_INFO(
|
LOG_INFO(
|
||||||
@@ -1151,8 +1146,7 @@ int Render::CreateConnectionPeer() {
|
|||||||
ConfigCenter::VIDEO_ENCODE_FORMAT::AV1
|
ConfigCenter::VIDEO_ENCODE_FORMAT::AV1
|
||||||
? true
|
? true
|
||||||
: false;
|
: false;
|
||||||
params_.turn_mode =
|
params_.turn_mode = static_cast<TurnMode>(config_center_->GetTurnMode());
|
||||||
static_cast<TurnMode>(config_center_->GetTurnMode());
|
|
||||||
params_.enable_srtp = config_center_->IsEnableSrtp();
|
params_.enable_srtp = config_center_->IsEnableSrtp();
|
||||||
params_.video_quality =
|
params_.video_quality =
|
||||||
static_cast<VideoQuality>(config_center_->GetVideoQuality());
|
static_cast<VideoQuality>(config_center_->GetVideoQuality());
|
||||||
@@ -1386,9 +1380,8 @@ int Render::CreateMainWindow() {
|
|||||||
tray_ = std::make_unique<MacTray>(main_window_, "CrossDesk",
|
tray_ = std::make_unique<MacTray>(main_window_, "CrossDesk",
|
||||||
localization_language_index_);
|
localization_language_index_);
|
||||||
#elif defined(__linux__) && !defined(__APPLE__)
|
#elif defined(__linux__) && !defined(__APPLE__)
|
||||||
tray_ = std::make_unique<LinuxTray>(main_window_, "CrossDesk",
|
tray_ = std::make_unique<LinuxTray>(
|
||||||
localization_language_index_,
|
main_window_, "CrossDesk", localization_language_index_, APP_EXIT_EVENT);
|
||||||
APP_EXIT_EVENT);
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
ImGui_ImplSDL3_InitForSDLRenderer(main_window_, main_renderer_);
|
ImGui_ImplSDL3_InitForSDLRenderer(main_window_, main_renderer_);
|
||||||
@@ -1937,7 +1930,9 @@ int Render::Run() {
|
|||||||
} else {
|
} else {
|
||||||
latest_version_ = "";
|
latest_version_ = "";
|
||||||
update_available_ = false;
|
update_available_ = false;
|
||||||
LOG_WARN("Update check skipped: version.json is empty or missing latest_version");
|
LOG_WARN(
|
||||||
|
"Update check skipped: version.json is empty or missing "
|
||||||
|
"latest_version");
|
||||||
}
|
}
|
||||||
|
|
||||||
InitializeSettings();
|
InitializeSettings();
|
||||||
@@ -2292,7 +2287,8 @@ void Render::HandleWindowsServiceIntegration() {
|
|||||||
last_logged_service_error_code = 0;
|
last_logged_service_error_code = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
RemoteAction remote_action = BuildWindowsServiceStatusAction(broadcast_status);
|
RemoteAction remote_action =
|
||||||
|
BuildWindowsServiceStatusAction(broadcast_status);
|
||||||
std::string msg = remote_action.to_json();
|
std::string msg = remote_action.to_json();
|
||||||
int ret = SendReliableDataFrame(peer_, msg.data(), msg.size(),
|
int ret = SendReliableDataFrame(peer_, msg.data(), msg.size(),
|
||||||
control_data_label_.c_str());
|
control_data_label_.c_str());
|
||||||
|
|||||||
Reference in New Issue
Block a user