#include "layout_style.h" #include "localization.h" #include "rd_log.h" #include "render.h" int Render::ControlBar() { ImGui::PushStyleVar(ImGuiStyleVar_FrameRounding, 3.0f); if (control_bar_expand_) { ImGui::SetCursorPosX( is_control_bar_in_left_ ? (control_window_width_ + 5.0f) : 41.0f); // mouse control button ImDrawList* draw_list = ImGui::GetWindowDrawList(); if (is_control_bar_in_left_) { draw_list->AddLine( ImVec2(ImGui::GetCursorScreenPos().x - 5.0f, ImGui::GetCursorScreenPos().y - 7.0f), ImVec2(ImGui::GetCursorScreenPos().x - 5.0f, ImGui::GetCursorScreenPos().y - 7.0f + control_window_height_), IM_COL32(178, 178, 178, 255), 1.0f); } float disable_mouse_x = ImGui::GetCursorScreenPos().x + 4.0f; float disable_mouse_y = ImGui::GetCursorScreenPos().y + 4.0f; std::string mouse = mouse_control_button_pressed_ ? ICON_FA_COMPUTER_MOUSE : ICON_FA_COMPUTER_MOUSE; if (ImGui::Button(mouse.c_str(), ImVec2(25, 25))) { if (connection_established_) { control_mouse_ = !control_mouse_; mouse_control_button_pressed_ = !mouse_control_button_pressed_; mouse_control_button_label_ = mouse_control_button_pressed_ ? localization::release_mouse[localization_language_index_] : localization::control_mouse[localization_language_index_]; } } if (!mouse_control_button_pressed_) { draw_list->AddLine( ImVec2(disable_mouse_x, disable_mouse_y), ImVec2(disable_mouse_x + 16.0f, disable_mouse_y + 14.2f), IM_COL32(0, 0, 0, 255), 2.0f); draw_list->AddLine( ImVec2(disable_mouse_x - 1.2f, disable_mouse_y + 1.2f), ImVec2(disable_mouse_x + 15.3f, disable_mouse_y + 15.4f), ImGui::IsItemHovered() ? IM_COL32(66, 150, 250, 255) : IM_COL32(179, 213, 253, 255), 2.0f); } ImGui::SameLine(); // audio capture button float disable_audio_x = ImGui::GetCursorScreenPos().x + 4; float disable_audio_y = ImGui::GetCursorScreenPos().y + 4.0f; // std::string audio = audio_capture_button_pressed_ ? ICON_FA_VOLUME_HIGH // : ICON_FA_VOLUME_XMARK; std::string audio = audio_capture_button_pressed_ ? ICON_FA_VOLUME_HIGH : ICON_FA_VOLUME_HIGH; if (ImGui::Button(audio.c_str(), ImVec2(25, 25))) { if (connection_established_) { audio_capture_ = !audio_capture_; audio_capture_button_pressed_ = !audio_capture_button_pressed_; audio_capture_button_label_ = audio_capture_button_pressed_ ? localization::audio_capture[localization_language_index_] : localization::mute[localization_language_index_]; RemoteAction remote_action; remote_action.type = ControlType::audio_capture; remote_action.a = audio_capture_button_pressed_; SendData(peer_, DATA_TYPE::DATA, (const char*)&remote_action, sizeof(remote_action)); } } if (!audio_capture_button_pressed_) { draw_list->AddLine( ImVec2(disable_audio_x, disable_audio_y), ImVec2(disable_audio_x + 16.0f, disable_audio_y + 14.2f), IM_COL32(0, 0, 0, 255), 2.0f); draw_list->AddLine( ImVec2(disable_audio_x - 1.2f, disable_audio_y + 1.2f), ImVec2(disable_audio_x + 15.3f, disable_audio_y + 15.4f), ImGui::IsItemHovered() ? IM_COL32(66, 150, 250, 255) : IM_COL32(179, 213, 253, 255), 2.0f); } ImGui::SameLine(); // fullscreen button std::string fullscreen = fullscreen_button_pressed_ ? ICON_FA_COMPRESS : ICON_FA_EXPAND; if (ImGui::Button(fullscreen.c_str(), ImVec2(25, 25))) { fullscreen_button_pressed_ = !fullscreen_button_pressed_; fullscreen_button_label_ = fullscreen_button_pressed_ ? localization::exit_fullscreen[localization_language_index_] : localization::fullscreen[localization_language_index_]; if (fullscreen_button_pressed_) { SDL_SetWindowFullscreen(main_window_, SDL_WINDOW_FULLSCREEN_DESKTOP); } else { SDL_SetWindowFullscreen(main_window_, SDL_FALSE); } } ImGui::SameLine(); // close button std::string close_button = ICON_FA_XMARK; if (ImGui::Button(close_button.c_str(), ImVec2(25, 25))) { SDL_Event event; event.type = SDL_QUIT; SDL_PushEvent(&event); } ImGui::SameLine(); if (!is_control_bar_in_left_) { draw_list->AddLine( ImVec2(ImGui::GetCursorScreenPos().x - 3.0f, ImGui::GetCursorScreenPos().y - 7.0f), ImVec2(ImGui::GetCursorScreenPos().x - 3.0f, ImGui::GetCursorScreenPos().y - 7.0f + control_window_height_), IM_COL32(178, 178, 178, 255), 1.0f); } } ImGui::SetCursorPosX( is_control_bar_in_left_ ? (control_window_width_ * 2 - 18.0f) : 3.0f); std::string control_bar = control_bar_expand_ ? (is_control_bar_in_left_ ? ICON_FA_ANGLE_LEFT : ICON_FA_ANGLE_RIGHT) : (is_control_bar_in_left_ ? ICON_FA_ANGLE_RIGHT : ICON_FA_ANGLE_LEFT); if (ImGui::Button(control_bar.c_str(), ImVec2(15, 25))) { control_bar_expand_ = !control_bar_expand_; control_bar_button_pressed_time_ = ImGui::GetTime(); control_window_width_is_changing_ = true; } ImGui::PopStyleVar(); return 0; }