mirror of
https://github.com/kunkundi/crossdesk.git
synced 2025-10-27 04:35:34 +08:00
Add signal and p2p connection status windows
This commit is contained in:
@@ -45,6 +45,18 @@ static std::vector<std::string> enable_hardware_video_codec = {
|
||||
static std::vector<std::string> ok = {u8"确认", "OK"};
|
||||
static std::vector<std::string> cancel = {u8"取消", "Cancel"};
|
||||
|
||||
static std::vector<std::string> signal_connected = {u8"已连接服务器",
|
||||
"Connected"};
|
||||
static std::vector<std::string> signal_disconnected = {u8"未连接服务器",
|
||||
"Disconnected"};
|
||||
|
||||
static std::vector<std::string> p2p_connected = {u8"对等连接已建立",
|
||||
"P2P Connected"};
|
||||
static std::vector<std::string> p2p_disconnected = {u8"对等连接已断开",
|
||||
"P2P Disconnected"};
|
||||
static std::vector<std::string> p2p_connecting = {u8"正在建立对等连接",
|
||||
"P2P Connecting"};
|
||||
|
||||
} // namespace localization
|
||||
|
||||
#endif
|
||||
@@ -190,7 +190,7 @@ void Render::OnConnectionStatusCb(ConnectionStatus status, void *user_data) {
|
||||
} else if (ConnectionStatus::IncorrectPassword == status) {
|
||||
main_window->connection_status_str_ = "Incorrect password";
|
||||
if (main_window->connect_button_pressed_) {
|
||||
main_window->connect_button_pressed_ = false;
|
||||
// main_window->connect_button_pressed_ = false;
|
||||
main_window->connection_established_ = false;
|
||||
main_window->connect_button_label_ =
|
||||
main_window->connect_button_pressed_
|
||||
@@ -202,7 +202,7 @@ void Render::OnConnectionStatusCb(ConnectionStatus status, void *user_data) {
|
||||
} else if (ConnectionStatus::NoSuchTransmissionId == status) {
|
||||
main_window->connection_status_str_ = "No such transmission id";
|
||||
if (main_window->connect_button_pressed_) {
|
||||
main_window->connect_button_pressed_ = false;
|
||||
// main_window->connect_button_pressed_ = false;
|
||||
main_window->connection_established_ = false;
|
||||
main_window->connect_button_label_ =
|
||||
main_window->connect_button_pressed_
|
||||
|
||||
65
src/single_window/connection_status_window.cpp
Normal file
65
src/single_window/connection_status_window.cpp
Normal file
@@ -0,0 +1,65 @@
|
||||
#include "layout_style.h"
|
||||
#include "localization.h"
|
||||
#include "log.h"
|
||||
#include "render.h"
|
||||
|
||||
int Render::ConnectionStatusWindow() {
|
||||
if (connect_button_pressed_) {
|
||||
const ImGuiViewport *viewport = ImGui::GetMainViewport();
|
||||
|
||||
ImGui::SetNextWindowPos(ImVec2((viewport->WorkSize.x - viewport->WorkPos.x -
|
||||
connection_status_window_width_) /
|
||||
2,
|
||||
(viewport->WorkSize.y - viewport->WorkPos.y -
|
||||
connection_status_window_height_) /
|
||||
2));
|
||||
|
||||
ImGui::SetNextWindowSize(ImVec2(connection_status_window_width_,
|
||||
connection_status_window_height_));
|
||||
|
||||
ImGui::SetWindowFontScale(0.5f);
|
||||
ImGui::Begin("ConnectionStatusWindow", nullptr,
|
||||
ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoCollapse |
|
||||
ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoTitleBar |
|
||||
ImGuiWindowFlags_NoSavedSettings);
|
||||
ImGui::SetWindowFontScale(1.0f);
|
||||
|
||||
ImGui::SetCursorPosX(connection_status_window_width_ * 1 / 3);
|
||||
ImGui::SetCursorPosY(connection_status_window_height_ * 1 / 3);
|
||||
ImGui::SetWindowFontScale(0.5f);
|
||||
|
||||
if (ConnectionStatus::Connecting == connection_status_) {
|
||||
ImGui::Text("Connecting...");
|
||||
} else if (ConnectionStatus::Connected == connection_status_) {
|
||||
ImGui::Text("Connected");
|
||||
} else if (ConnectionStatus::Disconnected == connection_status_) {
|
||||
ImGui::Text("Disonnected");
|
||||
} else if (ConnectionStatus::Failed == connection_status_) {
|
||||
ImGui::Text("Failed");
|
||||
} else if (ConnectionStatus::Closed == connection_status_) {
|
||||
ImGui::Text("Closed");
|
||||
} else if (ConnectionStatus::IncorrectPassword == connection_status_) {
|
||||
ImGui::Text("Incorrect password");
|
||||
} else if (ConnectionStatus::NoSuchTransmissionId == connection_status_) {
|
||||
ImGui::Text("No such transmissionId");
|
||||
}
|
||||
|
||||
ImGui::SetWindowFontScale(1.0f);
|
||||
|
||||
ImGui::SetCursorPosX(connection_status_window_width_ * 3 / 7);
|
||||
ImGui::SetCursorPosY(connection_status_window_height_ * 2 / 3);
|
||||
|
||||
ImGui::SetWindowFontScale(0.5f);
|
||||
// Cancel
|
||||
if (ImGui::Button(
|
||||
localization::cancel[localization_language_index_].c_str())) {
|
||||
connect_button_pressed_ = false;
|
||||
}
|
||||
ImGui::SetWindowFontScale(1.0f);
|
||||
|
||||
ImGui::SetWindowFontScale(0.5f);
|
||||
ImGui::End();
|
||||
ImGui::SetWindowFontScale(1.0f);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@@ -28,7 +28,7 @@
|
||||
#define VIDEO_QUALITY_SELECT_WINDOW_PADDING_EN 147
|
||||
#define VIDEO_ENCODE_FORMAT_SELECT_WINDOW_PADDING_CN 100
|
||||
#define VIDEO_ENCODE_FORMAT_SELECT_WINDOW_PADDING_EN 147
|
||||
#define ENABLE_HARDWARE_VIDEO_CODEC_CHECKBOX_PADDING_CN 154
|
||||
#define ENABLE_HARDWARE_VIDEO_CODEC_CHECKBOX_PADDING_CN 151
|
||||
#define ENABLE_HARDWARE_VIDEO_CODEC_CHECKBOX_PADDING_EN 201
|
||||
#define SETTINGS_SELECT_WINDOW_WIDTH 73
|
||||
#define SETTINGS_OK_BUTTON_PADDING_CN 55
|
||||
|
||||
@@ -8,10 +8,12 @@ int Render::LocalWindow() {
|
||||
ImGui::PushStyleColor(ImGuiCol_ChildBg, ImVec4(255, 255, 255, 1));
|
||||
ImGui::BeginChild(
|
||||
"LocalDesktopWindow",
|
||||
ImVec2(local_window_width_, main_window_height_ - menu_window_height_),
|
||||
ImVec2(local_window_width_,
|
||||
main_window_height_ - menu_window_height_ - status_bar_height_),
|
||||
ImGuiChildFlags_Border,
|
||||
ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoCollapse |
|
||||
ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoTitleBar);
|
||||
ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoTitleBar |
|
||||
ImGuiWindowFlags_NoBringToFrontOnFocus);
|
||||
|
||||
ImGui::SetWindowFontScale(1.0f);
|
||||
ImGui::Text(
|
||||
@@ -21,8 +23,11 @@ int Render::LocalWindow() {
|
||||
{
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_ChildRounding, 10.0f);
|
||||
ImGui::PushStyleColor(ImGuiCol_ChildBg, ImVec4(0, 0, 0, 0.05));
|
||||
ImGui::BeginChild("LocalDesktopWindow_1", ImVec2(330, 180),
|
||||
ImGuiChildFlags_Border);
|
||||
ImGui::BeginChild(
|
||||
"LocalDesktopWindow_1", ImVec2(330, 180), ImGuiChildFlags_Border,
|
||||
ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoCollapse |
|
||||
ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoTitleBar |
|
||||
ImGuiWindowFlags_NoBringToFrontOnFocus);
|
||||
{
|
||||
ImGui::SetWindowFontScale(0.5f);
|
||||
ImGui::Text("%s",
|
||||
@@ -64,7 +69,7 @@ int Render::LocalWindow() {
|
||||
|
||||
ImGui::SetWindowFontScale(0.5f);
|
||||
if (ImGui::Button(show_password_ ? ICON_FA_EYE : ICON_FA_EYE_SLASH,
|
||||
ImVec2(35, 35))) {
|
||||
ImVec2(35, 38))) {
|
||||
show_password_ = !show_password_;
|
||||
}
|
||||
ImGui::PopStyleColor(3);
|
||||
@@ -74,12 +79,12 @@ int Render::LocalWindow() {
|
||||
ImGui::PushStyleColor(ImGuiCol_ButtonHovered, ImVec4(0, 0, 0, 0));
|
||||
ImGui::PushStyleColor(ImGuiCol_ButtonActive, ImVec4(0, 0, 0, 0));
|
||||
if (!regenerate_password_) {
|
||||
if (ImGui::Button(ICON_FA_ARROWS_ROTATE, ImVec2(35, 35))) {
|
||||
if (ImGui::Button(ICON_FA_ARROWS_ROTATE, ImVec2(35, 38))) {
|
||||
regenerate_password_ = true;
|
||||
}
|
||||
} else {
|
||||
regenerate_password_frame_count_++;
|
||||
if (ImGui::Button(ICON_FA_SPINNER, ImVec2(35, 35))) {
|
||||
if (ImGui::Button(ICON_FA_SPINNER, ImVec2(35, 38))) {
|
||||
}
|
||||
if (regenerate_password_frame_count_ == 15) {
|
||||
regenerate_password_frame_count_ = 0;
|
||||
|
||||
@@ -8,6 +8,8 @@ int Render::MainWindow() {
|
||||
MenuWindow();
|
||||
LocalWindow();
|
||||
RemoteWindow();
|
||||
StatusBar();
|
||||
ConnectionStatusWindow();
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -1,17 +1,20 @@
|
||||
#include "IconsFontAwesome6.h"
|
||||
#include "log.h"
|
||||
#include "render.h"
|
||||
|
||||
int Render::MenuWindow() {
|
||||
ImGui::PushStyleColor(ImGuiCol_MenuBarBg, ImVec4(255, 255, 255, 1));
|
||||
static bool a, b, c, d, e;
|
||||
ImGui::SetNextWindowPos(ImVec2(0, 0), ImGuiCond_Always);
|
||||
ImGui::BeginChild("MenuWindow",
|
||||
ImVec2(main_window_width_, menu_window_height_),
|
||||
ImGuiChildFlags_Border, ImGuiWindowFlags_MenuBar);
|
||||
ImGui::SetWindowFontScale(0.8f);
|
||||
ImGui::BeginChild(
|
||||
"MenuWindow", ImVec2(main_window_width_, menu_window_height_),
|
||||
ImGuiChildFlags_Border,
|
||||
ImGuiWindowFlags_MenuBar | ImGuiWindowFlags_NoBringToFrontOnFocus);
|
||||
ImGui::SetWindowFontScale(1.0f);
|
||||
if (ImGui::BeginMenuBar()) {
|
||||
ImGui::SetWindowFontScale(0.8f);
|
||||
if (ImGui::BeginMenu(ICON_FA_BARS, true)) {
|
||||
ImGui::SetWindowFontScale(0.7f);
|
||||
ImGui::SetWindowFontScale(0.5f);
|
||||
ImGui::MenuItem("Auto-resizing window", NULL, &a);
|
||||
ImGui::MenuItem("Constrained-resizing window", NULL, &b);
|
||||
ImGui::MenuItem("Fullscreen window", NULL, &c);
|
||||
|
||||
@@ -8,12 +8,14 @@ int Render::RemoteWindow() {
|
||||
ImGui::SetNextWindowPos(ImVec2(local_window_width_ - 1, menu_window_height_),
|
||||
ImGuiCond_Always);
|
||||
ImGui::PushStyleColor(ImGuiCol_ChildBg, ImVec4(255, 255, 255, 1));
|
||||
ImGui::BeginChild("RemoteDesktopWindow",
|
||||
ImVec2(main_window_width_ - local_window_width_,
|
||||
main_window_height_ - menu_window_height_),
|
||||
ImGuiChildFlags_Border,
|
||||
ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoCollapse |
|
||||
ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoTitleBar);
|
||||
ImGui::BeginChild(
|
||||
"RemoteDesktopWindow",
|
||||
ImVec2(main_window_width_ - local_window_width_ + 1,
|
||||
main_window_height_ - menu_window_height_ - status_bar_height_),
|
||||
ImGuiChildFlags_Border,
|
||||
ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoCollapse |
|
||||
ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoTitleBar |
|
||||
ImGuiWindowFlags_NoBringToFrontOnFocus);
|
||||
|
||||
ImGui::SetWindowFontScale(1.0f);
|
||||
ImGui::Text(
|
||||
@@ -24,7 +26,10 @@ int Render::RemoteWindow() {
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_ChildRounding, 10.0f);
|
||||
ImGui::PushStyleColor(ImGuiCol_ChildBg, ImVec4(0, 0, 0, 0.09));
|
||||
ImGui::BeginChild("RemoteDesktopWindow_1", ImVec2(330, 180),
|
||||
ImGuiChildFlags_Border);
|
||||
ImGuiChildFlags_Border,
|
||||
ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoCollapse |
|
||||
ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoTitleBar |
|
||||
ImGuiWindowFlags_NoBringToFrontOnFocus);
|
||||
{
|
||||
ImGui::SetWindowFontScale(0.5f);
|
||||
ImGui::Text("%s",
|
||||
@@ -38,10 +43,11 @@ int Render::RemoteWindow() {
|
||||
ImGuiInputTextFlags_CharsUppercase | ImGuiInputTextFlags_CharsNoBlank);
|
||||
|
||||
ImGui::SameLine();
|
||||
if (ImGui::Button(ICON_FA_ARROW_RIGHT_LONG, ImVec2(55, 35)) || rejoin_) {
|
||||
if (ImGui::Button(ICON_FA_ARROW_RIGHT_LONG, ImVec2(55, 38)) || rejoin_) {
|
||||
connect_button_pressed_ = true;
|
||||
int ret = -1;
|
||||
if ("SignalConnected" == signal_status_str_) {
|
||||
if (!connection_established_ && strlen(remote_id_)) {
|
||||
if (signal_connected_) {
|
||||
if (!connection_established_) {
|
||||
if (remote_id_ == local_id_ && !peer_reserved_) {
|
||||
peer_reserved_ = CreatePeer(¶ms_);
|
||||
if (peer_reserved_) {
|
||||
|
||||
@@ -38,6 +38,8 @@ class Render {
|
||||
int ControlWindow();
|
||||
int ControlBar();
|
||||
int MenuWindow();
|
||||
int StatusBar();
|
||||
int ConnectionStatusWindow();
|
||||
|
||||
public:
|
||||
static void OnReceiveVideoBufferCb(const char *data, size_t size,
|
||||
@@ -123,6 +125,9 @@ class Render {
|
||||
int main_window_height_before_fullscreen_ = 720;
|
||||
int menu_window_height_ = 30;
|
||||
int local_window_width_ = 350;
|
||||
int status_bar_height_ = 20;
|
||||
int connection_status_window_width_ = 200;
|
||||
int connection_status_window_height_ = 150;
|
||||
|
||||
int main_window_width_real_ = 960;
|
||||
int main_window_height_real_ = 540;
|
||||
@@ -171,6 +176,7 @@ class Render {
|
||||
SignalStatus signal_status_ = SignalStatus::SignalClosed;
|
||||
std::string signal_status_str_ = "";
|
||||
std::string connection_status_str_ = "";
|
||||
bool signal_connected_ = false;
|
||||
|
||||
private:
|
||||
PeerPtr *peer_ = nullptr;
|
||||
|
||||
@@ -149,14 +149,19 @@ void Render::OnSignalStatusCb(SignalStatus status, void *user_data) {
|
||||
render->signal_status_ = status;
|
||||
if (SignalStatus::SignalConnecting == status) {
|
||||
render->signal_status_str_ = "SignalConnecting";
|
||||
render->signal_connected_ = false;
|
||||
} else if (SignalStatus::SignalConnected == status) {
|
||||
render->signal_status_str_ = "SignalConnected";
|
||||
render->signal_connected_ = true;
|
||||
} else if (SignalStatus::SignalFailed == status) {
|
||||
render->signal_status_str_ = "SignalFailed";
|
||||
render->signal_connected_ = false;
|
||||
} else if (SignalStatus::SignalClosed == status) {
|
||||
render->signal_status_str_ = "SignalClosed";
|
||||
render->signal_connected_ = false;
|
||||
} else if (SignalStatus::SignalReconnecting == status) {
|
||||
render->signal_status_str_ = "SignalReconnecting";
|
||||
render->signal_connected_ = false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -169,6 +174,7 @@ void Render::OnConnectionStatusCb(ConnectionStatus status, void *user_data) {
|
||||
render->connection_status_str_ = "Connected";
|
||||
render->connection_established_ = true;
|
||||
render->streaming_ = true;
|
||||
// render->connect_button_pressed_ = false;
|
||||
SDL_SetWindowSize(render->main_window_, render->stream_window_width_,
|
||||
render->stream_window_height_);
|
||||
SDL_SetWindowPosition(render->main_window_, SDL_WINDOWPOS_CENTERED,
|
||||
@@ -196,7 +202,7 @@ void Render::OnConnectionStatusCb(ConnectionStatus status, void *user_data) {
|
||||
} else if (ConnectionStatus::IncorrectPassword == status) {
|
||||
render->connection_status_str_ = "Incorrect password";
|
||||
if (render->connect_button_pressed_) {
|
||||
render->connect_button_pressed_ = false;
|
||||
// render->connect_button_pressed_ = false;
|
||||
render->connection_established_ = false;
|
||||
render->connect_button_label_ =
|
||||
render->connect_button_pressed_
|
||||
@@ -206,7 +212,7 @@ void Render::OnConnectionStatusCb(ConnectionStatus status, void *user_data) {
|
||||
} else if (ConnectionStatus::NoSuchTransmissionId == status) {
|
||||
render->connection_status_str_ = "No such transmission id";
|
||||
if (render->connect_button_pressed_) {
|
||||
render->connect_button_pressed_ = false;
|
||||
// render->connect_button_pressed_ = false;
|
||||
render->connection_established_ = false;
|
||||
render->connect_button_label_ =
|
||||
render->connect_button_pressed_
|
||||
|
||||
@@ -9,15 +9,14 @@ int Render::SettingButton() {
|
||||
ImGui::PushStyleColor(ImGuiCol_Button, ImVec4(0, 0, 0, 0));
|
||||
ImGui::PushStyleColor(ImGuiCol_ButtonHovered, ImVec4(0, 0, 1, 0.4));
|
||||
ImGui::PushStyleColor(ImGuiCol_ButtonActive, ImVec4(0, 0, 0, 0));
|
||||
ImGui::SetWindowFontScale(0.8f);
|
||||
// ImGui::PushStyleVar(ImGuiStyleVar_FrameRounding, 3.0f);
|
||||
|
||||
std::string gear = ICON_FA_GEAR;
|
||||
if (ImGui::Button(gear.c_str(), ImVec2(40, 35))) {
|
||||
settings_button_pressed_ = !settings_button_pressed_;
|
||||
settings_window_pos_reset_ = true;
|
||||
}
|
||||
ImGui::PopStyleColor(3);
|
||||
|
||||
ImGui::PopStyleColor(4);
|
||||
|
||||
if (settings_button_pressed_) {
|
||||
if (settings_window_pos_reset_) {
|
||||
@@ -49,199 +48,204 @@ int Render::SettingButton() {
|
||||
settings_window_pos_reset_ = false;
|
||||
}
|
||||
|
||||
// ImGui::SetWindowFontScale(0.5f);
|
||||
// Settings
|
||||
ImGui::Begin(localization::settings[localization_language_index_].c_str(),
|
||||
nullptr,
|
||||
ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoCollapse |
|
||||
ImGuiWindowFlags_NoSavedSettings);
|
||||
ImGui::SetWindowFontScale(0.5f);
|
||||
{
|
||||
const char *language_items[] = {
|
||||
localization::language_zh[localization_language_index_].c_str(),
|
||||
localization::language_en[localization_language_index_].c_str()};
|
||||
|
||||
ImGui::SetCursorPosY(32);
|
||||
ImGui::Text("%s",
|
||||
localization::language[localization_language_index_].c_str());
|
||||
if (ConfigCenter::LANGUAGE::CHINESE == localization_language_) {
|
||||
ImGui::SetCursorPosX(LANGUAGE_SELECT_WINDOW_PADDING_CN);
|
||||
} else {
|
||||
ImGui::SetCursorPosX(LANGUAGE_SELECT_WINDOW_PADDING_EN);
|
||||
}
|
||||
ImGui::SetCursorPosY(30);
|
||||
ImGui::SetNextItemWidth(SETTINGS_SELECT_WINDOW_WIDTH);
|
||||
|
||||
ImGui::Combo("##language", &language_button_value_, language_items,
|
||||
IM_ARRAYSIZE(language_items));
|
||||
}
|
||||
|
||||
ImGui::Separator();
|
||||
|
||||
{
|
||||
const char *video_quality_items[] = {
|
||||
localization::video_quality_high[localization_language_index_]
|
||||
.c_str(),
|
||||
localization::video_quality_medium[localization_language_index_]
|
||||
.c_str(),
|
||||
localization::video_quality_low[localization_language_index_]
|
||||
.c_str()};
|
||||
|
||||
ImGui::SetCursorPosY(62);
|
||||
ImGui::Text(
|
||||
"%s",
|
||||
localization::video_quality[localization_language_index_].c_str());
|
||||
|
||||
if (ConfigCenter::LANGUAGE::CHINESE == localization_language_) {
|
||||
ImGui::SetCursorPosX(VIDEO_QUALITY_SELECT_WINDOW_PADDING_CN);
|
||||
} else {
|
||||
ImGui::SetCursorPosX(VIDEO_QUALITY_SELECT_WINDOW_PADDING_EN);
|
||||
}
|
||||
ImGui::SetCursorPosY(60);
|
||||
ImGui::SetNextItemWidth(SETTINGS_SELECT_WINDOW_WIDTH);
|
||||
|
||||
ImGui::Combo("##video_quality", &video_quality_button_value_,
|
||||
video_quality_items, IM_ARRAYSIZE(video_quality_items));
|
||||
}
|
||||
|
||||
ImGui::Separator();
|
||||
|
||||
{
|
||||
const char *video_encode_format_items[] = {
|
||||
localization::av1[localization_language_index_].c_str(),
|
||||
localization::h264[localization_language_index_].c_str()};
|
||||
|
||||
ImGui::SetCursorPosY(92);
|
||||
ImGui::Text(
|
||||
"%s", localization::video_encode_format[localization_language_index_]
|
||||
.c_str());
|
||||
|
||||
if (ConfigCenter::LANGUAGE::CHINESE == localization_language_) {
|
||||
ImGui::SetCursorPosX(VIDEO_ENCODE_FORMAT_SELECT_WINDOW_PADDING_CN);
|
||||
} else {
|
||||
ImGui::SetCursorPosX(VIDEO_ENCODE_FORMAT_SELECT_WINDOW_PADDING_EN);
|
||||
}
|
||||
ImGui::SetCursorPosY(90);
|
||||
ImGui::SetNextItemWidth(SETTINGS_SELECT_WINDOW_WIDTH);
|
||||
|
||||
ImGui::Combo("##video_encode_format", &video_encode_format_button_value_,
|
||||
video_encode_format_items,
|
||||
IM_ARRAYSIZE(video_encode_format_items));
|
||||
}
|
||||
|
||||
ImGui::Separator();
|
||||
|
||||
{
|
||||
ImGui::SetCursorPosY(122);
|
||||
ImGui::Text("%s", localization::enable_hardware_video_codec
|
||||
[localization_language_index_]
|
||||
.c_str());
|
||||
|
||||
if (ConfigCenter::LANGUAGE::CHINESE == localization_language_) {
|
||||
ImGui::SetCursorPosX(ENABLE_HARDWARE_VIDEO_CODEC_CHECKBOX_PADDING_CN);
|
||||
} else {
|
||||
ImGui::SetCursorPosX(ENABLE_HARDWARE_VIDEO_CODEC_CHECKBOX_PADDING_EN);
|
||||
}
|
||||
ImGui::SetCursorPosY(120);
|
||||
ImGui::Checkbox("##enable_hardware_video_codec",
|
||||
&enable_hardware_video_codec_);
|
||||
}
|
||||
|
||||
if (ConfigCenter::LANGUAGE::CHINESE == localization_language_) {
|
||||
ImGui::SetCursorPosX(SETTINGS_OK_BUTTON_PADDING_CN);
|
||||
} else {
|
||||
ImGui::SetCursorPosX(SETTINGS_OK_BUTTON_PADDING_EN);
|
||||
}
|
||||
ImGui::SetCursorPosY(160.0f);
|
||||
|
||||
// OK
|
||||
if (ImGui::Button(localization::ok[localization_language_index_].c_str())) {
|
||||
settings_button_pressed_ = false;
|
||||
|
||||
// Language
|
||||
if (language_button_value_ == 0) {
|
||||
config_center_.SetLanguage(ConfigCenter::LANGUAGE::CHINESE);
|
||||
} else {
|
||||
config_center_.SetLanguage(ConfigCenter::LANGUAGE::ENGLISH);
|
||||
}
|
||||
language_button_value_last_ = language_button_value_;
|
||||
localization_language_ = (ConfigCenter::LANGUAGE)language_button_value_;
|
||||
localization_language_index_ = language_button_value_;
|
||||
LOG_INFO("Set localization language: {}",
|
||||
localization_language_index_ == 0 ? "zh" : "en");
|
||||
|
||||
// Video quality
|
||||
if (video_quality_button_value_ == 0) {
|
||||
config_center_.SetVideoQuality(ConfigCenter::VIDEO_QUALITY::HIGH);
|
||||
} else if (video_quality_button_value_ == 1) {
|
||||
config_center_.SetVideoQuality(ConfigCenter::VIDEO_QUALITY::MEDIUM);
|
||||
} else {
|
||||
config_center_.SetVideoQuality(ConfigCenter::VIDEO_QUALITY::LOW);
|
||||
}
|
||||
video_quality_button_value_last_ = video_quality_button_value_;
|
||||
|
||||
// Video encode format
|
||||
if (video_encode_format_button_value_ == 0) {
|
||||
config_center_.SetVideoEncodeFormat(
|
||||
ConfigCenter::VIDEO_ENCODE_FORMAT::AV1);
|
||||
} else if (video_encode_format_button_value_ == 1) {
|
||||
config_center_.SetVideoEncodeFormat(
|
||||
ConfigCenter::VIDEO_ENCODE_FORMAT::H264);
|
||||
}
|
||||
video_encode_format_button_value_last_ =
|
||||
video_encode_format_button_value_;
|
||||
|
||||
// Hardware video codec
|
||||
if (enable_hardware_video_codec_) {
|
||||
config_center_.SetHardwareVideoCodec(true);
|
||||
} else {
|
||||
config_center_.SetHardwareVideoCodec(false);
|
||||
}
|
||||
enable_hardware_video_codec_last_ = enable_hardware_video_codec_;
|
||||
|
||||
SaveSettingsIntoCacheFile();
|
||||
settings_window_pos_reset_ = true;
|
||||
|
||||
// Recreate peer instance
|
||||
LoadSettingsIntoCacheFile();
|
||||
|
||||
// Recreate peer instance
|
||||
ImGui::SetWindowFontScale(0.5f);
|
||||
ImGui::Begin(localization::settings[localization_language_index_].c_str(),
|
||||
nullptr,
|
||||
ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoCollapse |
|
||||
ImGuiWindowFlags_NoSavedSettings);
|
||||
ImGui::SetWindowFontScale(1.0f);
|
||||
ImGui::SetWindowFontScale(0.5f);
|
||||
{
|
||||
DestroyPeer(peer_);
|
||||
CreateConnectionPeer();
|
||||
LOG_INFO("Recreate peer instance successful");
|
||||
const char *language_items[] = {
|
||||
localization::language_zh[localization_language_index_].c_str(),
|
||||
localization::language_en[localization_language_index_].c_str()};
|
||||
|
||||
ImGui::SetCursorPosY(32);
|
||||
ImGui::Text(
|
||||
"%s", localization::language[localization_language_index_].c_str());
|
||||
if (ConfigCenter::LANGUAGE::CHINESE == localization_language_) {
|
||||
ImGui::SetCursorPosX(LANGUAGE_SELECT_WINDOW_PADDING_CN);
|
||||
} else {
|
||||
ImGui::SetCursorPosX(LANGUAGE_SELECT_WINDOW_PADDING_EN);
|
||||
}
|
||||
ImGui::SetCursorPosY(30);
|
||||
ImGui::SetNextItemWidth(SETTINGS_SELECT_WINDOW_WIDTH);
|
||||
|
||||
ImGui::Combo("##language", &language_button_value_, language_items,
|
||||
IM_ARRAYSIZE(language_items));
|
||||
}
|
||||
|
||||
ImGui::Separator();
|
||||
|
||||
{
|
||||
const char *video_quality_items[] = {
|
||||
localization::video_quality_high[localization_language_index_]
|
||||
.c_str(),
|
||||
localization::video_quality_medium[localization_language_index_]
|
||||
.c_str(),
|
||||
localization::video_quality_low[localization_language_index_]
|
||||
.c_str()};
|
||||
|
||||
ImGui::SetCursorPosY(62);
|
||||
ImGui::Text(
|
||||
"%s",
|
||||
localization::video_quality[localization_language_index_].c_str());
|
||||
|
||||
if (ConfigCenter::LANGUAGE::CHINESE == localization_language_) {
|
||||
ImGui::SetCursorPosX(VIDEO_QUALITY_SELECT_WINDOW_PADDING_CN);
|
||||
} else {
|
||||
ImGui::SetCursorPosX(VIDEO_QUALITY_SELECT_WINDOW_PADDING_EN);
|
||||
}
|
||||
ImGui::SetCursorPosY(60);
|
||||
ImGui::SetNextItemWidth(SETTINGS_SELECT_WINDOW_WIDTH);
|
||||
|
||||
ImGui::Combo("##video_quality", &video_quality_button_value_,
|
||||
video_quality_items, IM_ARRAYSIZE(video_quality_items));
|
||||
}
|
||||
|
||||
ImGui::Separator();
|
||||
|
||||
{
|
||||
const char *video_encode_format_items[] = {
|
||||
localization::av1[localization_language_index_].c_str(),
|
||||
localization::h264[localization_language_index_].c_str()};
|
||||
|
||||
ImGui::SetCursorPosY(92);
|
||||
ImGui::Text(
|
||||
"%s",
|
||||
localization::video_encode_format[localization_language_index_]
|
||||
.c_str());
|
||||
|
||||
if (ConfigCenter::LANGUAGE::CHINESE == localization_language_) {
|
||||
ImGui::SetCursorPosX(VIDEO_ENCODE_FORMAT_SELECT_WINDOW_PADDING_CN);
|
||||
} else {
|
||||
ImGui::SetCursorPosX(VIDEO_ENCODE_FORMAT_SELECT_WINDOW_PADDING_EN);
|
||||
}
|
||||
ImGui::SetCursorPosY(90);
|
||||
ImGui::SetNextItemWidth(SETTINGS_SELECT_WINDOW_WIDTH);
|
||||
|
||||
ImGui::Combo(
|
||||
"##video_encode_format", &video_encode_format_button_value_,
|
||||
video_encode_format_items, IM_ARRAYSIZE(video_encode_format_items));
|
||||
}
|
||||
|
||||
ImGui::Separator();
|
||||
|
||||
{
|
||||
ImGui::SetCursorPosY(122);
|
||||
ImGui::Text("%s", localization::enable_hardware_video_codec
|
||||
[localization_language_index_]
|
||||
.c_str());
|
||||
|
||||
if (ConfigCenter::LANGUAGE::CHINESE == localization_language_) {
|
||||
ImGui::SetCursorPosX(ENABLE_HARDWARE_VIDEO_CODEC_CHECKBOX_PADDING_CN);
|
||||
} else {
|
||||
ImGui::SetCursorPosX(ENABLE_HARDWARE_VIDEO_CODEC_CHECKBOX_PADDING_EN);
|
||||
}
|
||||
ImGui::SetCursorPosY(120);
|
||||
ImGui::Checkbox("##enable_hardware_video_codec",
|
||||
&enable_hardware_video_codec_);
|
||||
}
|
||||
|
||||
if (ConfigCenter::LANGUAGE::CHINESE == localization_language_) {
|
||||
ImGui::SetCursorPosX(SETTINGS_OK_BUTTON_PADDING_CN);
|
||||
} else {
|
||||
ImGui::SetCursorPosX(SETTINGS_OK_BUTTON_PADDING_EN);
|
||||
}
|
||||
ImGui::SetCursorPosY(160.0f);
|
||||
|
||||
// OK
|
||||
if (ImGui::Button(
|
||||
localization::ok[localization_language_index_].c_str())) {
|
||||
settings_button_pressed_ = false;
|
||||
|
||||
// Language
|
||||
if (language_button_value_ == 0) {
|
||||
config_center_.SetLanguage(ConfigCenter::LANGUAGE::CHINESE);
|
||||
} else {
|
||||
config_center_.SetLanguage(ConfigCenter::LANGUAGE::ENGLISH);
|
||||
}
|
||||
language_button_value_last_ = language_button_value_;
|
||||
localization_language_ = (ConfigCenter::LANGUAGE)language_button_value_;
|
||||
localization_language_index_ = language_button_value_;
|
||||
LOG_INFO("Set localization language: {}",
|
||||
localization_language_index_ == 0 ? "zh" : "en");
|
||||
|
||||
// Video quality
|
||||
if (video_quality_button_value_ == 0) {
|
||||
config_center_.SetVideoQuality(ConfigCenter::VIDEO_QUALITY::HIGH);
|
||||
} else if (video_quality_button_value_ == 1) {
|
||||
config_center_.SetVideoQuality(ConfigCenter::VIDEO_QUALITY::MEDIUM);
|
||||
} else {
|
||||
config_center_.SetVideoQuality(ConfigCenter::VIDEO_QUALITY::LOW);
|
||||
}
|
||||
video_quality_button_value_last_ = video_quality_button_value_;
|
||||
|
||||
// Video encode format
|
||||
if (video_encode_format_button_value_ == 0) {
|
||||
config_center_.SetVideoEncodeFormat(
|
||||
ConfigCenter::VIDEO_ENCODE_FORMAT::AV1);
|
||||
} else if (video_encode_format_button_value_ == 1) {
|
||||
config_center_.SetVideoEncodeFormat(
|
||||
ConfigCenter::VIDEO_ENCODE_FORMAT::H264);
|
||||
}
|
||||
video_encode_format_button_value_last_ =
|
||||
video_encode_format_button_value_;
|
||||
|
||||
// Hardware video codec
|
||||
if (enable_hardware_video_codec_) {
|
||||
config_center_.SetHardwareVideoCodec(true);
|
||||
} else {
|
||||
config_center_.SetHardwareVideoCodec(false);
|
||||
}
|
||||
enable_hardware_video_codec_last_ = enable_hardware_video_codec_;
|
||||
|
||||
SaveSettingsIntoCacheFile();
|
||||
settings_window_pos_reset_ = true;
|
||||
|
||||
// Recreate peer instance
|
||||
LoadSettingsIntoCacheFile();
|
||||
|
||||
// Recreate peer instance
|
||||
{
|
||||
DestroyPeer(peer_);
|
||||
CreateConnectionPeer();
|
||||
LOG_INFO("Recreate peer instance successful");
|
||||
}
|
||||
}
|
||||
ImGui::SameLine();
|
||||
// Cancel
|
||||
if (ImGui::Button(
|
||||
localization::cancel[localization_language_index_].c_str())) {
|
||||
settings_button_pressed_ = false;
|
||||
if (language_button_value_ != language_button_value_last_) {
|
||||
language_button_value_ = language_button_value_last_;
|
||||
}
|
||||
|
||||
if (video_quality_button_value_ != video_quality_button_value_last_) {
|
||||
video_quality_button_value_ = video_quality_button_value_last_;
|
||||
}
|
||||
|
||||
if (video_encode_format_button_value_ !=
|
||||
video_encode_format_button_value_last_) {
|
||||
video_encode_format_button_value_ =
|
||||
video_encode_format_button_value_last_;
|
||||
}
|
||||
|
||||
if (enable_hardware_video_codec_ != enable_hardware_video_codec_last_) {
|
||||
enable_hardware_video_codec_ = enable_hardware_video_codec_last_;
|
||||
}
|
||||
|
||||
settings_window_pos_reset_ = true;
|
||||
}
|
||||
ImGui::SetWindowFontScale(1.0f);
|
||||
ImGui::SetWindowFontScale(0.5f);
|
||||
ImGui::End();
|
||||
ImGui::SetWindowFontScale(1.0f);
|
||||
}
|
||||
ImGui::SameLine();
|
||||
// Cancel
|
||||
if (ImGui::Button(
|
||||
localization::cancel[localization_language_index_].c_str())) {
|
||||
settings_button_pressed_ = false;
|
||||
if (language_button_value_ != language_button_value_last_) {
|
||||
language_button_value_ = language_button_value_last_;
|
||||
}
|
||||
|
||||
if (video_quality_button_value_ != video_quality_button_value_last_) {
|
||||
video_quality_button_value_ = video_quality_button_value_last_;
|
||||
}
|
||||
|
||||
if (video_encode_format_button_value_ !=
|
||||
video_encode_format_button_value_last_) {
|
||||
video_encode_format_button_value_ =
|
||||
video_encode_format_button_value_last_;
|
||||
}
|
||||
|
||||
if (enable_hardware_video_codec_ != enable_hardware_video_codec_last_) {
|
||||
enable_hardware_video_codec_ = enable_hardware_video_codec_last_;
|
||||
}
|
||||
|
||||
settings_window_pos_reset_ = true;
|
||||
}
|
||||
|
||||
ImGui::End();
|
||||
}
|
||||
|
||||
ImGui::PopStyleColor();
|
||||
|
||||
return 0;
|
||||
}
|
||||
39
src/single_window/status_bar.cpp
Normal file
39
src/single_window/status_bar.cpp
Normal file
@@ -0,0 +1,39 @@
|
||||
#include "localization.h"
|
||||
#include "render.h"
|
||||
|
||||
int Render::StatusBar() {
|
||||
ImGui::PushStyleColor(ImGuiCol_MenuBarBg, ImVec4(0, 0, 0, 1));
|
||||
static bool a, b, c, d, e;
|
||||
ImGui::SetNextWindowPos(
|
||||
ImVec2(0, main_window_height_ - status_bar_height_ - 1),
|
||||
ImGuiCond_Always);
|
||||
|
||||
ImGui::BeginChild(
|
||||
"StatusBar", ImVec2(main_window_width_, status_bar_height_ + 1),
|
||||
ImGuiChildFlags_Border,
|
||||
ImGuiWindowFlags_NoDecoration | ImGuiWindowFlags_NoBringToFrontOnFocus);
|
||||
|
||||
ImDrawList* draw_list = ImGui::GetWindowDrawList();
|
||||
draw_list->AddCircleFilled(
|
||||
ImVec2(15, main_window_height_ - status_bar_height_ + 9.0f), 5,
|
||||
ImColor(signal_connected_ ? 0.0f : 1.0f, signal_connected_ ? 1.0f : 0.0f,
|
||||
0.0f),
|
||||
100);
|
||||
draw_list->AddCircle(
|
||||
ImVec2(15, main_window_height_ - status_bar_height_ + 10.0f), 6,
|
||||
ImColor(1.0f, 1.0f, 1.0f), 100);
|
||||
|
||||
ImGui::SetWindowFontScale(0.5f);
|
||||
draw_list->AddText(
|
||||
ImVec2(25, main_window_height_ - status_bar_height_ + 3.0f),
|
||||
ImColor(0.0f, 0.0f, 0.0f),
|
||||
signal_connected_
|
||||
? localization::signal_connected[localization_language_index_].c_str()
|
||||
: localization::signal_disconnected[localization_language_index_]
|
||||
.c_str());
|
||||
ImGui::SetWindowFontScale(1.0f);
|
||||
|
||||
ImGui::PopStyleColor();
|
||||
ImGui::EndChild();
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user