[feat] add audio capture button in control bar

This commit is contained in:
dijunkun
2024-08-15 11:25:19 +08:00
parent 65927c2091
commit 4704d494ec
4 changed files with 27 additions and 2 deletions

View File

@@ -28,6 +28,8 @@ static std::vector<std::string> exit_fullscreen = {u8" 退出全屏",
" Exit fullscreen"}; " Exit fullscreen"};
static std::vector<std::string> control_mouse = {u8" 控制", " Control"}; static std::vector<std::string> control_mouse = {u8" 控制", " Control"};
static std::vector<std::string> release_mouse = {u8" 释放", " Release"}; static std::vector<std::string> release_mouse = {u8" 释放", " Release"};
static std::vector<std::string> audio_capture = {u8" 声音", " Audio"};
static std::vector<std::string> mute = {u8" 静音", " Mute"};
static std::vector<std::string> settings = {u8"设置", "Settings"}; static std::vector<std::string> settings = {u8"设置", "Settings"};
static std::vector<std::string> language = {u8"语言:", "Language:"}; static std::vector<std::string> language = {u8"语言:", "Language:"};
static std::vector<std::string> language_zh = {u8"中文", "Chinese"}; static std::vector<std::string> language_zh = {u8"中文", "Chinese"};

View File

@@ -11,7 +11,7 @@ int Render::ControlBar() {
if (control_bar_expand_) { if (control_bar_expand_) {
ImGui::SetCursorPosX(is_control_bar_in_left_ ? (control_window_width_ + 5) ImGui::SetCursorPosX(is_control_bar_in_left_ ? (control_window_width_ + 5)
: 87); : 53);
// Mouse control // Mouse control
std::string mouse = ICON_FA_COMPUTER_MOUSE; std::string mouse = ICON_FA_COMPUTER_MOUSE;
if (ImGui::Button(mouse.c_str(), ImVec2(25, 25))) { if (ImGui::Button(mouse.c_str(), ImVec2(25, 25))) {
@@ -30,6 +30,26 @@ int Render::ControlBar() {
mouse_control_button_pressed_ = !mouse_control_button_pressed_; mouse_control_button_pressed_ = !mouse_control_button_pressed_;
} }
ImGui::SameLine();
// Audio capture
std::string audio = audio_capture_button_pressed_ ? ICON_FA_VOLUME_HIGH
: ICON_FA_VOLUME_XMARK;
if (ImGui::Button(audio.c_str(), ImVec2(25, 25))) {
if (mouse_control_button_label_ ==
localization::audio_capture[localization_language_index_] &&
connection_established_) {
audio_capture_button_pressed_ = true;
audio_capture_ = true;
audio_capture_button_label_ =
localization::mute[localization_language_index_];
} else {
control_mouse_ = false;
audio_capture_button_label_ =
localization::audio_capture[localization_language_index_];
}
audio_capture_button_pressed_ = !audio_capture_button_pressed_;
}
ImGui::SameLine(); ImGui::SameLine();
// Fullscreen // Fullscreen
std::string fullscreen = std::string fullscreen =

View File

@@ -117,6 +117,7 @@ class Render {
std::string connect_button_label_ = "Connect"; std::string connect_button_label_ = "Connect";
std::string fullscreen_button_label_ = "Fullscreen"; std::string fullscreen_button_label_ = "Fullscreen";
std::string mouse_control_button_label_ = "Mouse Control"; std::string mouse_control_button_label_ = "Mouse Control";
std::string audio_capture_button_label_ = "Audio Capture";
std::string settings_button_label_ = "Setting"; std::string settings_button_label_ = "Setting";
char input_password_tmp_[7] = ""; char input_password_tmp_[7] = "";
char input_password_[7] = ""; char input_password_[7] = "";
@@ -187,12 +188,14 @@ class Render {
bool control_bar_expand_ = true; bool control_bar_expand_ = true;
bool fullscreen_button_pressed_ = false; bool fullscreen_button_pressed_ = false;
bool mouse_control_button_pressed_ = false; bool mouse_control_button_pressed_ = false;
bool audio_capture_button_pressed_ = true;
bool show_settings_window_ = false; bool show_settings_window_ = false;
bool received_frame_ = false; bool received_frame_ = false;
bool is_create_connection_ = false; bool is_create_connection_ = false;
bool audio_buffer_fresh_ = false; bool audio_buffer_fresh_ = false;
bool rejoin_ = false; bool rejoin_ = false;
bool control_mouse_ = false; bool control_mouse_ = false;
bool audio_capture_ = true;
bool local_id_copied_ = false; bool local_id_copied_ = false;
bool show_password_ = true; bool show_password_ = true;
bool password_inited_ = false; bool password_inited_ = false;

View File

@@ -19,7 +19,7 @@ end
add_requires("spdlog 1.14.1", {system = false}) add_requires("spdlog 1.14.1", {system = false})
add_requires("imgui v1.91.0", {configs = {sdl2 = true, sdl2_renderer = true}}) add_requires("imgui v1.91.0", {configs = {sdl2 = true, sdl2_renderer = true}})
add_requires("libyuv") add_requires("libyuv")
add_requires("miniaudio") add_requires("miniaudio 0.11.21")
if is_os("windows") then if is_os("windows") then
add_links("Shell32", "windowsapp", "dwmapi", "User32", "kernel32", add_links("Shell32", "windowsapp", "dwmapi", "User32", "kernel32",