mirror of
https://github.com/kunkundi/crossdesk.git
synced 2025-10-26 20:25:34 +08:00
[feat] change UI layouts
This commit is contained in:
@@ -7,18 +7,16 @@
|
|||||||
#include "render.h"
|
#include "render.h"
|
||||||
|
|
||||||
int Render::LocalWindow() {
|
int Render::LocalWindow() {
|
||||||
ImGui::SetNextWindowPos(ImVec2(0, title_bar_height_), ImGuiCond_Always);
|
ImGui::SetNextWindowPos(ImVec2(0, title_bar_height_ + 1), ImGuiCond_Always);
|
||||||
ImGui::PushStyleVar(ImGuiStyleVar_FrameRounding, 3.0f);
|
ImGui::PushStyleVar(ImGuiStyleVar_FrameRounding, 3.0f);
|
||||||
|
|
||||||
ImGui::PushStyleColor(ImGuiCol_ChildBg, ImVec4(1.0f, 1.0f, 1.0f, 1.0f));
|
ImGui::PushStyleColor(ImGuiCol_ChildBg, ImVec4(1.0f, 1.0f, 1.0f, 1.0f));
|
||||||
ImGui::BeginChild(
|
ImGui::BeginChild("LocalDesktopWindow",
|
||||||
"LocalDesktopWindow",
|
ImVec2(local_window_width_, local_window_height_),
|
||||||
ImVec2(local_window_width_, main_window_height_default_ -
|
ImGuiChildFlags_Border,
|
||||||
title_bar_height_ - status_bar_height_),
|
ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoCollapse |
|
||||||
ImGuiChildFlags_Border,
|
ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoTitleBar |
|
||||||
ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoCollapse |
|
ImGuiWindowFlags_NoBringToFrontOnFocus);
|
||||||
ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoTitleBar |
|
|
||||||
ImGuiWindowFlags_NoBringToFrontOnFocus);
|
|
||||||
ImGui::PopStyleColor();
|
ImGui::PopStyleColor();
|
||||||
|
|
||||||
ImGui::SetWindowFontScale(1.0f);
|
ImGui::SetWindowFontScale(1.0f);
|
||||||
@@ -27,6 +25,8 @@ int Render::LocalWindow() {
|
|||||||
|
|
||||||
ImGui::Spacing();
|
ImGui::Spacing();
|
||||||
{
|
{
|
||||||
|
ImGui::SetNextWindowPos(ImVec2(30, title_bar_height_ + 50),
|
||||||
|
ImGuiCond_Always);
|
||||||
ImGui::PushStyleColor(ImGuiCol_ChildBg,
|
ImGui::PushStyleColor(ImGuiCol_ChildBg,
|
||||||
ImVec4(239.0 / 255, 240.0 / 255, 242.0 / 255, 1.0f));
|
ImVec4(239.0 / 255, 240.0 / 255, 242.0 / 255, 1.0f));
|
||||||
ImGui::PushStyleVar(ImGuiStyleVar_ChildRounding, 10.0f);
|
ImGui::PushStyleVar(ImGuiStyleVar_ChildRounding, 10.0f);
|
||||||
|
|||||||
@@ -2,9 +2,9 @@
|
|||||||
|
|
||||||
int Render::MainWindow() {
|
int Render::MainWindow() {
|
||||||
ImGui::SetNextWindowPos(ImVec2(0, 0), ImGuiCond_Always);
|
ImGui::SetNextWindowPos(ImVec2(0, 0), ImGuiCond_Always);
|
||||||
ImGui::SetNextWindowSize(
|
// ImGui::SetNextWindowSize(
|
||||||
ImVec2(main_window_width_default_, main_window_height_default_),
|
// ImVec2(main_window_width_default_, main_window_height_default_),
|
||||||
ImGuiCond_Always);
|
// ImGuiCond_Always);
|
||||||
|
|
||||||
LocalWindow();
|
LocalWindow();
|
||||||
RemoteWindow();
|
RemoteWindow();
|
||||||
|
|||||||
@@ -17,15 +17,13 @@ static int InputTextCallback(ImGuiInputTextCallbackData *data) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int Render::RemoteWindow() {
|
int Render::RemoteWindow() {
|
||||||
ImGui::SetNextWindowPos(ImVec2(local_window_width_ - 1, title_bar_height_),
|
ImGui::SetNextWindowPos(ImVec2(0, title_bar_height_ + local_window_height_),
|
||||||
ImGuiCond_Always);
|
ImGuiCond_Always);
|
||||||
ImGui::PushStyleVar(ImGuiStyleVar_FrameRounding, 3.0f);
|
ImGui::PushStyleVar(ImGuiStyleVar_FrameRounding, 3.0f);
|
||||||
|
|
||||||
ImGui::PushStyleColor(ImGuiCol_ChildBg, ImVec4(1.0f, 1.0f, 1.0f, 1.0f));
|
ImGui::PushStyleColor(ImGuiCol_ChildBg, ImVec4(1.0f, 1.0f, 1.0f, 1.0f));
|
||||||
ImGui::BeginChild("RemoteDesktopWindow",
|
ImGui::BeginChild("RemoteDesktopWindow",
|
||||||
ImVec2(main_window_width_ - local_window_width_ + 1,
|
ImVec2(remote_window_width_, remote_window_height_),
|
||||||
main_window_height_default_ - title_bar_height_ -
|
|
||||||
status_bar_height_),
|
|
||||||
ImGuiChildFlags_Border,
|
ImGuiChildFlags_Border,
|
||||||
ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoCollapse |
|
ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoCollapse |
|
||||||
ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoTitleBar |
|
ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoTitleBar |
|
||||||
@@ -37,73 +35,79 @@ int Render::RemoteWindow() {
|
|||||||
"%s", localization::remote_desktop[localization_language_index_].c_str());
|
"%s", localization::remote_desktop[localization_language_index_].c_str());
|
||||||
|
|
||||||
ImGui::Spacing();
|
ImGui::Spacing();
|
||||||
|
|
||||||
ImGui::PushStyleColor(ImGuiCol_ChildBg,
|
|
||||||
ImVec4(239.0 / 255, 240.0 / 255, 242.0 / 255, 1.0f));
|
|
||||||
ImGui::PushStyleVar(ImGuiStyleVar_ChildRounding, 10.0f);
|
|
||||||
|
|
||||||
ImGui::BeginChild("RemoteDesktopWindow_1", ImVec2(330, 180),
|
|
||||||
ImGuiChildFlags_Border,
|
|
||||||
ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoCollapse |
|
|
||||||
ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoTitleBar |
|
|
||||||
ImGuiWindowFlags_NoBringToFrontOnFocus);
|
|
||||||
ImGui::PopStyleVar();
|
|
||||||
ImGui::PopStyleColor();
|
|
||||||
{
|
{
|
||||||
ImGui::SetWindowFontScale(0.5f);
|
ImGui::SetNextWindowPos(
|
||||||
ImGui::Text("%s",
|
ImVec2(30, title_bar_height_ + local_window_height_ + 50),
|
||||||
localization::remote_id[localization_language_index_].c_str());
|
ImGuiCond_Always);
|
||||||
|
ImGui::PushStyleColor(ImGuiCol_ChildBg,
|
||||||
ImGui::Spacing();
|
ImVec4(239.0 / 255, 240.0 / 255, 242.0 / 255, 1.0f));
|
||||||
ImGui::SetNextItemWidth(IPUT_WINDOW_WIDTH);
|
ImGui::PushStyleVar(ImGuiStyleVar_ChildRounding, 10.0f);
|
||||||
ImGui::SetWindowFontScale(1.0f);
|
|
||||||
ImGui::PushStyleVar(ImGuiStyleVar_FrameBorderSize, 1.0f);
|
|
||||||
bool enter_pressed = ImGui::InputText(
|
|
||||||
"##remote_id_", remote_id_display_, IM_ARRAYSIZE(remote_id_display_),
|
|
||||||
ImGuiInputTextFlags_CharsUppercase |
|
|
||||||
ImGuiInputTextFlags_EnterReturnsTrue |
|
|
||||||
ImGuiInputTextFlags_CallbackEdit | ImGuiInputTextFlags_CharsNoBlank,
|
|
||||||
InputTextCallback);
|
|
||||||
|
|
||||||
|
ImGui::BeginChild(
|
||||||
|
"RemoteDesktopWindow_1", ImVec2(330, 180), ImGuiChildFlags_Border,
|
||||||
|
ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoCollapse |
|
||||||
|
ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoTitleBar |
|
||||||
|
ImGuiWindowFlags_NoBringToFrontOnFocus);
|
||||||
ImGui::PopStyleVar();
|
ImGui::PopStyleVar();
|
||||||
ImGui::SameLine();
|
ImGui::PopStyleColor();
|
||||||
if (ImGui::Button(ICON_FA_ARROW_RIGHT_LONG, ImVec2(55, 38)) ||
|
{
|
||||||
enter_pressed || rejoin_) {
|
ImGui::SetWindowFontScale(0.5f);
|
||||||
connect_button_pressed_ = true;
|
ImGui::Text(
|
||||||
connection_status_ = ConnectionStatus::Connecting;
|
"%s", localization::remote_id[localization_language_index_].c_str());
|
||||||
int ret = -1;
|
|
||||||
if (signal_connected_) {
|
ImGui::Spacing();
|
||||||
if (!connection_established_) {
|
ImGui::SetNextItemWidth(IPUT_WINDOW_WIDTH);
|
||||||
remote_id_ = remote_id_display_;
|
ImGui::SetWindowFontScale(1.0f);
|
||||||
remote_id_.erase(remove_if(remote_id_.begin(), remote_id_.end(),
|
ImGui::PushStyleVar(ImGuiStyleVar_FrameBorderSize, 1.0f);
|
||||||
static_cast<int (*)(int)>(&isspace)),
|
bool enter_pressed = ImGui::InputText(
|
||||||
remote_id_.end());
|
"##remote_id_", remote_id_display_, IM_ARRAYSIZE(remote_id_display_),
|
||||||
if (0 == strcmp(remote_id_.c_str(), client_id_) && !peer_reserved_) {
|
ImGuiInputTextFlags_CharsUppercase |
|
||||||
peer_reserved_ = CreatePeer(¶ms_);
|
ImGuiInputTextFlags_EnterReturnsTrue |
|
||||||
if (peer_reserved_) {
|
ImGuiInputTextFlags_CallbackEdit |
|
||||||
LOG_INFO("Create peer[reserved] instance successful");
|
ImGuiInputTextFlags_CharsNoBlank,
|
||||||
std::string client_id = "C-";
|
InputTextCallback);
|
||||||
client_id += client_id_;
|
|
||||||
Init(peer_reserved_, client_id.c_str());
|
ImGui::PopStyleVar();
|
||||||
LOG_INFO("Peer[reserved] init finish");
|
ImGui::SameLine();
|
||||||
} else {
|
if (ImGui::Button(ICON_FA_ARROW_RIGHT_LONG, ImVec2(55, 38)) ||
|
||||||
LOG_INFO("Create peer[reserved] instance failed");
|
enter_pressed || rejoin_) {
|
||||||
|
connect_button_pressed_ = true;
|
||||||
|
connection_status_ = ConnectionStatus::Connecting;
|
||||||
|
int ret = -1;
|
||||||
|
if (signal_connected_) {
|
||||||
|
if (!connection_established_) {
|
||||||
|
remote_id_ = remote_id_display_;
|
||||||
|
remote_id_.erase(remove_if(remote_id_.begin(), remote_id_.end(),
|
||||||
|
static_cast<int (*)(int)>(&isspace)),
|
||||||
|
remote_id_.end());
|
||||||
|
if (0 == strcmp(remote_id_.c_str(), client_id_) &&
|
||||||
|
!peer_reserved_) {
|
||||||
|
peer_reserved_ = CreatePeer(¶ms_);
|
||||||
|
if (peer_reserved_) {
|
||||||
|
LOG_INFO("Create peer[reserved] instance successful");
|
||||||
|
std::string client_id = "C-";
|
||||||
|
client_id += client_id_;
|
||||||
|
Init(peer_reserved_, client_id.c_str());
|
||||||
|
LOG_INFO("Peer[reserved] init finish");
|
||||||
|
} else {
|
||||||
|
LOG_INFO("Create peer[reserved] instance failed");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ret = JoinConnection(peer_reserved_ ? peer_reserved_ : peer_,
|
||||||
|
remote_id_.c_str(), remote_password_);
|
||||||
|
if (0 == ret) {
|
||||||
|
is_client_mode_ = true;
|
||||||
|
rejoin_ = false;
|
||||||
|
} else {
|
||||||
|
rejoin_ = true;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
ret = JoinConnection(peer_reserved_ ? peer_reserved_ : peer_,
|
|
||||||
remote_id_.c_str(), remote_password_);
|
|
||||||
if (0 == ret) {
|
|
||||||
is_client_mode_ = true;
|
|
||||||
rejoin_ = false;
|
|
||||||
} else {
|
|
||||||
rejoin_ = true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
ImGui::EndChild();
|
||||||
}
|
}
|
||||||
ImGui::EndChild();
|
ImGui::EndChild();
|
||||||
ImGui::EndChild();
|
|
||||||
ImGui::PopStyleVar();
|
ImGui::PopStyleVar();
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|||||||
@@ -155,9 +155,9 @@ class Render {
|
|||||||
int screen_width_ = 1280;
|
int screen_width_ = 1280;
|
||||||
int screen_height_ = 720;
|
int screen_height_ = 720;
|
||||||
int main_window_width_default_ = 960;
|
int main_window_width_default_ = 960;
|
||||||
int main_window_height_default_ = 570;
|
int main_window_height_default_ = 590;
|
||||||
int main_window_width_ = 960;
|
int main_window_width_ = 960;
|
||||||
int main_window_height_ = 570;
|
int main_window_height_ = 590;
|
||||||
int main_window_width_last_ = 960;
|
int main_window_width_last_ = 960;
|
||||||
int main_window_height_last_ = 540;
|
int main_window_height_last_ = 540;
|
||||||
int stream_window_width_default_ = 1280;
|
int stream_window_width_default_ = 1280;
|
||||||
@@ -167,12 +167,15 @@ class Render {
|
|||||||
int stream_window_width_last_ = 1280;
|
int stream_window_width_last_ = 1280;
|
||||||
int stream_window_height_last_ = 720;
|
int stream_window_height_last_ = 720;
|
||||||
int main_window_width_before_maximized_ = 960;
|
int main_window_width_before_maximized_ = 960;
|
||||||
int main_window_height_before_maximized_ = 570;
|
int main_window_height_before_maximized_ = 590;
|
||||||
int control_window_min_width_ = 20;
|
int control_window_min_width_ = 20;
|
||||||
int control_window_max_width_ = 170;
|
int control_window_max_width_ = 170;
|
||||||
int control_window_width_ = 170;
|
int control_window_width_ = 170;
|
||||||
int control_window_height_ = 40;
|
int control_window_height_ = 40;
|
||||||
int local_window_width_ = 350;
|
int local_window_width_ = 720;
|
||||||
|
int local_window_height_ = 270;
|
||||||
|
int remote_window_width_ = 720;
|
||||||
|
int remote_window_height_ = 270;
|
||||||
int status_bar_height_ = 20;
|
int status_bar_height_ = 20;
|
||||||
int connection_status_window_width_ = 200;
|
int connection_status_window_width_ = 200;
|
||||||
int connection_status_window_height_ = 150;
|
int connection_status_window_height_ = 150;
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ int Render::TitleBar(bool main_window) {
|
|||||||
"TitleBar",
|
"TitleBar",
|
||||||
ImVec2(main_window ? main_window_width_ : stream_window_width_,
|
ImVec2(main_window ? main_window_width_ : stream_window_width_,
|
||||||
title_bar_height_),
|
title_bar_height_),
|
||||||
ImGuiChildFlags_None,
|
ImGuiChildFlags_Border,
|
||||||
ImGuiWindowFlags_MenuBar | ImGuiWindowFlags_NoDecoration |
|
ImGuiWindowFlags_MenuBar | ImGuiWindowFlags_NoDecoration |
|
||||||
ImGuiWindowFlags_NoBringToFrontOnFocus);
|
ImGuiWindowFlags_NoBringToFrontOnFocus);
|
||||||
ImDrawList* draw_list = ImGui::GetWindowDrawList();
|
ImDrawList* draw_list = ImGui::GetWindowDrawList();
|
||||||
|
|||||||
Reference in New Issue
Block a user