mirror of
https://github.com/kunkundi/crossdesk.git
synced 2025-10-26 20:25:34 +08:00
Add signal and p2p connection status windows
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -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> ok = {u8"确认", "OK"};
|
||||||
static std::vector<std::string> cancel = {u8"取消", "Cancel"};
|
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
|
} // namespace localization
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
@@ -190,7 +190,7 @@ void Render::OnConnectionStatusCb(ConnectionStatus status, void *user_data) {
|
|||||||
} else if (ConnectionStatus::IncorrectPassword == status) {
|
} else if (ConnectionStatus::IncorrectPassword == status) {
|
||||||
main_window->connection_status_str_ = "Incorrect password";
|
main_window->connection_status_str_ = "Incorrect password";
|
||||||
if (main_window->connect_button_pressed_) {
|
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->connection_established_ = false;
|
||||||
main_window->connect_button_label_ =
|
main_window->connect_button_label_ =
|
||||||
main_window->connect_button_pressed_
|
main_window->connect_button_pressed_
|
||||||
@@ -202,7 +202,7 @@ void Render::OnConnectionStatusCb(ConnectionStatus status, void *user_data) {
|
|||||||
} else if (ConnectionStatus::NoSuchTransmissionId == status) {
|
} else if (ConnectionStatus::NoSuchTransmissionId == status) {
|
||||||
main_window->connection_status_str_ = "No such transmission id";
|
main_window->connection_status_str_ = "No such transmission id";
|
||||||
if (main_window->connect_button_pressed_) {
|
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->connection_established_ = false;
|
||||||
main_window->connect_button_label_ =
|
main_window->connect_button_label_ =
|
||||||
main_window->connect_button_pressed_
|
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_QUALITY_SELECT_WINDOW_PADDING_EN 147
|
||||||
#define VIDEO_ENCODE_FORMAT_SELECT_WINDOW_PADDING_CN 100
|
#define VIDEO_ENCODE_FORMAT_SELECT_WINDOW_PADDING_CN 100
|
||||||
#define VIDEO_ENCODE_FORMAT_SELECT_WINDOW_PADDING_EN 147
|
#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 ENABLE_HARDWARE_VIDEO_CODEC_CHECKBOX_PADDING_EN 201
|
||||||
#define SETTINGS_SELECT_WINDOW_WIDTH 73
|
#define SETTINGS_SELECT_WINDOW_WIDTH 73
|
||||||
#define SETTINGS_OK_BUTTON_PADDING_CN 55
|
#define SETTINGS_OK_BUTTON_PADDING_CN 55
|
||||||
|
|||||||
@@ -8,10 +8,12 @@ int Render::LocalWindow() {
|
|||||||
ImGui::PushStyleColor(ImGuiCol_ChildBg, ImVec4(255, 255, 255, 1));
|
ImGui::PushStyleColor(ImGuiCol_ChildBg, ImVec4(255, 255, 255, 1));
|
||||||
ImGui::BeginChild(
|
ImGui::BeginChild(
|
||||||
"LocalDesktopWindow",
|
"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,
|
ImGuiChildFlags_Border,
|
||||||
ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoCollapse |
|
ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoCollapse |
|
||||||
ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoTitleBar);
|
ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoTitleBar |
|
||||||
|
ImGuiWindowFlags_NoBringToFrontOnFocus);
|
||||||
|
|
||||||
ImGui::SetWindowFontScale(1.0f);
|
ImGui::SetWindowFontScale(1.0f);
|
||||||
ImGui::Text(
|
ImGui::Text(
|
||||||
@@ -21,8 +23,11 @@ int Render::LocalWindow() {
|
|||||||
{
|
{
|
||||||
ImGui::PushStyleVar(ImGuiStyleVar_ChildRounding, 10.0f);
|
ImGui::PushStyleVar(ImGuiStyleVar_ChildRounding, 10.0f);
|
||||||
ImGui::PushStyleColor(ImGuiCol_ChildBg, ImVec4(0, 0, 0, 0.05));
|
ImGui::PushStyleColor(ImGuiCol_ChildBg, ImVec4(0, 0, 0, 0.05));
|
||||||
ImGui::BeginChild("LocalDesktopWindow_1", ImVec2(330, 180),
|
ImGui::BeginChild(
|
||||||
ImGuiChildFlags_Border);
|
"LocalDesktopWindow_1", ImVec2(330, 180), ImGuiChildFlags_Border,
|
||||||
|
ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoCollapse |
|
||||||
|
ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoTitleBar |
|
||||||
|
ImGuiWindowFlags_NoBringToFrontOnFocus);
|
||||||
{
|
{
|
||||||
ImGui::SetWindowFontScale(0.5f);
|
ImGui::SetWindowFontScale(0.5f);
|
||||||
ImGui::Text("%s",
|
ImGui::Text("%s",
|
||||||
@@ -64,7 +69,7 @@ int Render::LocalWindow() {
|
|||||||
|
|
||||||
ImGui::SetWindowFontScale(0.5f);
|
ImGui::SetWindowFontScale(0.5f);
|
||||||
if (ImGui::Button(show_password_ ? ICON_FA_EYE : ICON_FA_EYE_SLASH,
|
if (ImGui::Button(show_password_ ? ICON_FA_EYE : ICON_FA_EYE_SLASH,
|
||||||
ImVec2(35, 35))) {
|
ImVec2(35, 38))) {
|
||||||
show_password_ = !show_password_;
|
show_password_ = !show_password_;
|
||||||
}
|
}
|
||||||
ImGui::PopStyleColor(3);
|
ImGui::PopStyleColor(3);
|
||||||
@@ -74,12 +79,12 @@ int Render::LocalWindow() {
|
|||||||
ImGui::PushStyleColor(ImGuiCol_ButtonHovered, ImVec4(0, 0, 0, 0));
|
ImGui::PushStyleColor(ImGuiCol_ButtonHovered, ImVec4(0, 0, 0, 0));
|
||||||
ImGui::PushStyleColor(ImGuiCol_ButtonActive, ImVec4(0, 0, 0, 0));
|
ImGui::PushStyleColor(ImGuiCol_ButtonActive, ImVec4(0, 0, 0, 0));
|
||||||
if (!regenerate_password_) {
|
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;
|
regenerate_password_ = true;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
regenerate_password_frame_count_++;
|
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) {
|
if (regenerate_password_frame_count_ == 15) {
|
||||||
regenerate_password_frame_count_ = 0;
|
regenerate_password_frame_count_ = 0;
|
||||||
|
|||||||
@@ -8,6 +8,8 @@ int Render::MainWindow() {
|
|||||||
MenuWindow();
|
MenuWindow();
|
||||||
LocalWindow();
|
LocalWindow();
|
||||||
RemoteWindow();
|
RemoteWindow();
|
||||||
|
StatusBar();
|
||||||
|
ConnectionStatusWindow();
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -1,17 +1,20 @@
|
|||||||
#include "IconsFontAwesome6.h"
|
#include "IconsFontAwesome6.h"
|
||||||
|
#include "log.h"
|
||||||
#include "render.h"
|
#include "render.h"
|
||||||
|
|
||||||
int Render::MenuWindow() {
|
int Render::MenuWindow() {
|
||||||
ImGui::PushStyleColor(ImGuiCol_MenuBarBg, ImVec4(255, 255, 255, 1));
|
ImGui::PushStyleColor(ImGuiCol_MenuBarBg, ImVec4(255, 255, 255, 1));
|
||||||
static bool a, b, c, d, e;
|
static bool a, b, c, d, e;
|
||||||
ImGui::SetNextWindowPos(ImVec2(0, 0), ImGuiCond_Always);
|
ImGui::SetNextWindowPos(ImVec2(0, 0), ImGuiCond_Always);
|
||||||
ImGui::BeginChild("MenuWindow",
|
|
||||||
ImVec2(main_window_width_, menu_window_height_),
|
|
||||||
ImGuiChildFlags_Border, ImGuiWindowFlags_MenuBar);
|
|
||||||
if (ImGui::BeginMenuBar()) {
|
|
||||||
ImGui::SetWindowFontScale(0.8f);
|
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()) {
|
||||||
if (ImGui::BeginMenu(ICON_FA_BARS, true)) {
|
if (ImGui::BeginMenu(ICON_FA_BARS, true)) {
|
||||||
ImGui::SetWindowFontScale(0.7f);
|
ImGui::SetWindowFontScale(0.5f);
|
||||||
ImGui::MenuItem("Auto-resizing window", NULL, &a);
|
ImGui::MenuItem("Auto-resizing window", NULL, &a);
|
||||||
ImGui::MenuItem("Constrained-resizing window", NULL, &b);
|
ImGui::MenuItem("Constrained-resizing window", NULL, &b);
|
||||||
ImGui::MenuItem("Fullscreen window", NULL, &c);
|
ImGui::MenuItem("Fullscreen window", NULL, &c);
|
||||||
|
|||||||
@@ -8,12 +8,14 @@ int Render::RemoteWindow() {
|
|||||||
ImGui::SetNextWindowPos(ImVec2(local_window_width_ - 1, menu_window_height_),
|
ImGui::SetNextWindowPos(ImVec2(local_window_width_ - 1, menu_window_height_),
|
||||||
ImGuiCond_Always);
|
ImGuiCond_Always);
|
||||||
ImGui::PushStyleColor(ImGuiCol_ChildBg, ImVec4(255, 255, 255, 1));
|
ImGui::PushStyleColor(ImGuiCol_ChildBg, ImVec4(255, 255, 255, 1));
|
||||||
ImGui::BeginChild("RemoteDesktopWindow",
|
ImGui::BeginChild(
|
||||||
ImVec2(main_window_width_ - local_window_width_,
|
"RemoteDesktopWindow",
|
||||||
main_window_height_ - menu_window_height_),
|
ImVec2(main_window_width_ - local_window_width_ + 1,
|
||||||
|
main_window_height_ - menu_window_height_ - status_bar_height_),
|
||||||
ImGuiChildFlags_Border,
|
ImGuiChildFlags_Border,
|
||||||
ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoCollapse |
|
ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoCollapse |
|
||||||
ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoTitleBar);
|
ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoTitleBar |
|
||||||
|
ImGuiWindowFlags_NoBringToFrontOnFocus);
|
||||||
|
|
||||||
ImGui::SetWindowFontScale(1.0f);
|
ImGui::SetWindowFontScale(1.0f);
|
||||||
ImGui::Text(
|
ImGui::Text(
|
||||||
@@ -24,7 +26,10 @@ int Render::RemoteWindow() {
|
|||||||
ImGui::PushStyleVar(ImGuiStyleVar_ChildRounding, 10.0f);
|
ImGui::PushStyleVar(ImGuiStyleVar_ChildRounding, 10.0f);
|
||||||
ImGui::PushStyleColor(ImGuiCol_ChildBg, ImVec4(0, 0, 0, 0.09));
|
ImGui::PushStyleColor(ImGuiCol_ChildBg, ImVec4(0, 0, 0, 0.09));
|
||||||
ImGui::BeginChild("RemoteDesktopWindow_1", ImVec2(330, 180),
|
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::SetWindowFontScale(0.5f);
|
||||||
ImGui::Text("%s",
|
ImGui::Text("%s",
|
||||||
@@ -38,10 +43,11 @@ int Render::RemoteWindow() {
|
|||||||
ImGuiInputTextFlags_CharsUppercase | ImGuiInputTextFlags_CharsNoBlank);
|
ImGuiInputTextFlags_CharsUppercase | ImGuiInputTextFlags_CharsNoBlank);
|
||||||
|
|
||||||
ImGui::SameLine();
|
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;
|
int ret = -1;
|
||||||
if ("SignalConnected" == signal_status_str_) {
|
if (signal_connected_) {
|
||||||
if (!connection_established_ && strlen(remote_id_)) {
|
if (!connection_established_) {
|
||||||
if (remote_id_ == local_id_ && !peer_reserved_) {
|
if (remote_id_ == local_id_ && !peer_reserved_) {
|
||||||
peer_reserved_ = CreatePeer(¶ms_);
|
peer_reserved_ = CreatePeer(¶ms_);
|
||||||
if (peer_reserved_) {
|
if (peer_reserved_) {
|
||||||
|
|||||||
@@ -38,6 +38,8 @@ class Render {
|
|||||||
int ControlWindow();
|
int ControlWindow();
|
||||||
int ControlBar();
|
int ControlBar();
|
||||||
int MenuWindow();
|
int MenuWindow();
|
||||||
|
int StatusBar();
|
||||||
|
int ConnectionStatusWindow();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static void OnReceiveVideoBufferCb(const char *data, size_t size,
|
static void OnReceiveVideoBufferCb(const char *data, size_t size,
|
||||||
@@ -123,6 +125,9 @@ class Render {
|
|||||||
int main_window_height_before_fullscreen_ = 720;
|
int main_window_height_before_fullscreen_ = 720;
|
||||||
int menu_window_height_ = 30;
|
int menu_window_height_ = 30;
|
||||||
int local_window_width_ = 350;
|
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_width_real_ = 960;
|
||||||
int main_window_height_real_ = 540;
|
int main_window_height_real_ = 540;
|
||||||
@@ -171,6 +176,7 @@ class Render {
|
|||||||
SignalStatus signal_status_ = SignalStatus::SignalClosed;
|
SignalStatus signal_status_ = SignalStatus::SignalClosed;
|
||||||
std::string signal_status_str_ = "";
|
std::string signal_status_str_ = "";
|
||||||
std::string connection_status_str_ = "";
|
std::string connection_status_str_ = "";
|
||||||
|
bool signal_connected_ = false;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
PeerPtr *peer_ = nullptr;
|
PeerPtr *peer_ = nullptr;
|
||||||
|
|||||||
@@ -149,14 +149,19 @@ void Render::OnSignalStatusCb(SignalStatus status, void *user_data) {
|
|||||||
render->signal_status_ = status;
|
render->signal_status_ = status;
|
||||||
if (SignalStatus::SignalConnecting == status) {
|
if (SignalStatus::SignalConnecting == status) {
|
||||||
render->signal_status_str_ = "SignalConnecting";
|
render->signal_status_str_ = "SignalConnecting";
|
||||||
|
render->signal_connected_ = false;
|
||||||
} else if (SignalStatus::SignalConnected == status) {
|
} else if (SignalStatus::SignalConnected == status) {
|
||||||
render->signal_status_str_ = "SignalConnected";
|
render->signal_status_str_ = "SignalConnected";
|
||||||
|
render->signal_connected_ = true;
|
||||||
} else if (SignalStatus::SignalFailed == status) {
|
} else if (SignalStatus::SignalFailed == status) {
|
||||||
render->signal_status_str_ = "SignalFailed";
|
render->signal_status_str_ = "SignalFailed";
|
||||||
|
render->signal_connected_ = false;
|
||||||
} else if (SignalStatus::SignalClosed == status) {
|
} else if (SignalStatus::SignalClosed == status) {
|
||||||
render->signal_status_str_ = "SignalClosed";
|
render->signal_status_str_ = "SignalClosed";
|
||||||
|
render->signal_connected_ = false;
|
||||||
} else if (SignalStatus::SignalReconnecting == status) {
|
} else if (SignalStatus::SignalReconnecting == status) {
|
||||||
render->signal_status_str_ = "SignalReconnecting";
|
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_status_str_ = "Connected";
|
||||||
render->connection_established_ = true;
|
render->connection_established_ = true;
|
||||||
render->streaming_ = true;
|
render->streaming_ = true;
|
||||||
|
// render->connect_button_pressed_ = false;
|
||||||
SDL_SetWindowSize(render->main_window_, render->stream_window_width_,
|
SDL_SetWindowSize(render->main_window_, render->stream_window_width_,
|
||||||
render->stream_window_height_);
|
render->stream_window_height_);
|
||||||
SDL_SetWindowPosition(render->main_window_, SDL_WINDOWPOS_CENTERED,
|
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) {
|
} else if (ConnectionStatus::IncorrectPassword == status) {
|
||||||
render->connection_status_str_ = "Incorrect password";
|
render->connection_status_str_ = "Incorrect password";
|
||||||
if (render->connect_button_pressed_) {
|
if (render->connect_button_pressed_) {
|
||||||
render->connect_button_pressed_ = false;
|
// render->connect_button_pressed_ = false;
|
||||||
render->connection_established_ = false;
|
render->connection_established_ = false;
|
||||||
render->connect_button_label_ =
|
render->connect_button_label_ =
|
||||||
render->connect_button_pressed_
|
render->connect_button_pressed_
|
||||||
@@ -206,7 +212,7 @@ void Render::OnConnectionStatusCb(ConnectionStatus status, void *user_data) {
|
|||||||
} else if (ConnectionStatus::NoSuchTransmissionId == status) {
|
} else if (ConnectionStatus::NoSuchTransmissionId == status) {
|
||||||
render->connection_status_str_ = "No such transmission id";
|
render->connection_status_str_ = "No such transmission id";
|
||||||
if (render->connect_button_pressed_) {
|
if (render->connect_button_pressed_) {
|
||||||
render->connect_button_pressed_ = false;
|
// render->connect_button_pressed_ = false;
|
||||||
render->connection_established_ = false;
|
render->connection_established_ = false;
|
||||||
render->connect_button_label_ =
|
render->connect_button_label_ =
|
||||||
render->connect_button_pressed_
|
render->connect_button_pressed_
|
||||||
|
|||||||
@@ -9,15 +9,14 @@ int Render::SettingButton() {
|
|||||||
ImGui::PushStyleColor(ImGuiCol_Button, ImVec4(0, 0, 0, 0));
|
ImGui::PushStyleColor(ImGuiCol_Button, ImVec4(0, 0, 0, 0));
|
||||||
ImGui::PushStyleColor(ImGuiCol_ButtonHovered, ImVec4(0, 0, 1, 0.4));
|
ImGui::PushStyleColor(ImGuiCol_ButtonHovered, ImVec4(0, 0, 1, 0.4));
|
||||||
ImGui::PushStyleColor(ImGuiCol_ButtonActive, ImVec4(0, 0, 0, 0));
|
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;
|
std::string gear = ICON_FA_GEAR;
|
||||||
if (ImGui::Button(gear.c_str(), ImVec2(40, 35))) {
|
if (ImGui::Button(gear.c_str(), ImVec2(40, 35))) {
|
||||||
settings_button_pressed_ = !settings_button_pressed_;
|
settings_button_pressed_ = !settings_button_pressed_;
|
||||||
settings_window_pos_reset_ = true;
|
settings_window_pos_reset_ = true;
|
||||||
}
|
}
|
||||||
ImGui::PopStyleColor(3);
|
|
||||||
|
ImGui::PopStyleColor(4);
|
||||||
|
|
||||||
if (settings_button_pressed_) {
|
if (settings_button_pressed_) {
|
||||||
if (settings_window_pos_reset_) {
|
if (settings_window_pos_reset_) {
|
||||||
@@ -49,12 +48,14 @@ int Render::SettingButton() {
|
|||||||
settings_window_pos_reset_ = false;
|
settings_window_pos_reset_ = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ImGui::SetWindowFontScale(0.5f);
|
|
||||||
// Settings
|
// Settings
|
||||||
|
{
|
||||||
|
ImGui::SetWindowFontScale(0.5f);
|
||||||
ImGui::Begin(localization::settings[localization_language_index_].c_str(),
|
ImGui::Begin(localization::settings[localization_language_index_].c_str(),
|
||||||
nullptr,
|
nullptr,
|
||||||
ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoCollapse |
|
ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoCollapse |
|
||||||
ImGuiWindowFlags_NoSavedSettings);
|
ImGuiWindowFlags_NoSavedSettings);
|
||||||
|
ImGui::SetWindowFontScale(1.0f);
|
||||||
ImGui::SetWindowFontScale(0.5f);
|
ImGui::SetWindowFontScale(0.5f);
|
||||||
{
|
{
|
||||||
const char *language_items[] = {
|
const char *language_items[] = {
|
||||||
@@ -62,8 +63,8 @@ int Render::SettingButton() {
|
|||||||
localization::language_en[localization_language_index_].c_str()};
|
localization::language_en[localization_language_index_].c_str()};
|
||||||
|
|
||||||
ImGui::SetCursorPosY(32);
|
ImGui::SetCursorPosY(32);
|
||||||
ImGui::Text("%s",
|
ImGui::Text(
|
||||||
localization::language[localization_language_index_].c_str());
|
"%s", localization::language[localization_language_index_].c_str());
|
||||||
if (ConfigCenter::LANGUAGE::CHINESE == localization_language_) {
|
if (ConfigCenter::LANGUAGE::CHINESE == localization_language_) {
|
||||||
ImGui::SetCursorPosX(LANGUAGE_SELECT_WINDOW_PADDING_CN);
|
ImGui::SetCursorPosX(LANGUAGE_SELECT_WINDOW_PADDING_CN);
|
||||||
} else {
|
} else {
|
||||||
@@ -113,7 +114,8 @@ int Render::SettingButton() {
|
|||||||
|
|
||||||
ImGui::SetCursorPosY(92);
|
ImGui::SetCursorPosY(92);
|
||||||
ImGui::Text(
|
ImGui::Text(
|
||||||
"%s", localization::video_encode_format[localization_language_index_]
|
"%s",
|
||||||
|
localization::video_encode_format[localization_language_index_]
|
||||||
.c_str());
|
.c_str());
|
||||||
|
|
||||||
if (ConfigCenter::LANGUAGE::CHINESE == localization_language_) {
|
if (ConfigCenter::LANGUAGE::CHINESE == localization_language_) {
|
||||||
@@ -124,9 +126,9 @@ int Render::SettingButton() {
|
|||||||
ImGui::SetCursorPosY(90);
|
ImGui::SetCursorPosY(90);
|
||||||
ImGui::SetNextItemWidth(SETTINGS_SELECT_WINDOW_WIDTH);
|
ImGui::SetNextItemWidth(SETTINGS_SELECT_WINDOW_WIDTH);
|
||||||
|
|
||||||
ImGui::Combo("##video_encode_format", &video_encode_format_button_value_,
|
ImGui::Combo(
|
||||||
video_encode_format_items,
|
"##video_encode_format", &video_encode_format_button_value_,
|
||||||
IM_ARRAYSIZE(video_encode_format_items));
|
video_encode_format_items, IM_ARRAYSIZE(video_encode_format_items));
|
||||||
}
|
}
|
||||||
|
|
||||||
ImGui::Separator();
|
ImGui::Separator();
|
||||||
@@ -155,7 +157,8 @@ int Render::SettingButton() {
|
|||||||
ImGui::SetCursorPosY(160.0f);
|
ImGui::SetCursorPosY(160.0f);
|
||||||
|
|
||||||
// OK
|
// OK
|
||||||
if (ImGui::Button(localization::ok[localization_language_index_].c_str())) {
|
if (ImGui::Button(
|
||||||
|
localization::ok[localization_language_index_].c_str())) {
|
||||||
settings_button_pressed_ = false;
|
settings_button_pressed_ = false;
|
||||||
|
|
||||||
// Language
|
// Language
|
||||||
@@ -237,11 +240,12 @@ int Render::SettingButton() {
|
|||||||
|
|
||||||
settings_window_pos_reset_ = true;
|
settings_window_pos_reset_ = true;
|
||||||
}
|
}
|
||||||
|
ImGui::SetWindowFontScale(1.0f);
|
||||||
|
ImGui::SetWindowFontScale(0.5f);
|
||||||
ImGui::End();
|
ImGui::End();
|
||||||
|
ImGui::SetWindowFontScale(1.0f);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ImGui::PopStyleColor();
|
|
||||||
|
|
||||||
return 0;
|
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