[feat] change UI layouts

This commit is contained in:
dijunkun
2024-11-05 17:29:39 +08:00
parent 863070a8a7
commit 19ea426efc
5 changed files with 85 additions and 78 deletions

View File

@@ -7,14 +7,12 @@
#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_ -
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 |
@@ -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);

View File

@@ -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();

View File

@@ -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,13 +35,16 @@ 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::SetNextWindowPos(
ImVec2(30, title_bar_height_ + local_window_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);
ImGui::BeginChild("RemoteDesktopWindow_1", ImVec2(330, 180), ImGui::BeginChild(
ImGuiChildFlags_Border, "RemoteDesktopWindow_1", ImVec2(330, 180), ImGuiChildFlags_Border,
ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoCollapse |
ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoTitleBar |
ImGuiWindowFlags_NoBringToFrontOnFocus); ImGuiWindowFlags_NoBringToFrontOnFocus);
@@ -51,8 +52,8 @@ int Render::RemoteWindow() {
ImGui::PopStyleColor(); ImGui::PopStyleColor();
{ {
ImGui::SetWindowFontScale(0.5f); ImGui::SetWindowFontScale(0.5f);
ImGui::Text("%s", ImGui::Text(
localization::remote_id[localization_language_index_].c_str()); "%s", localization::remote_id[localization_language_index_].c_str());
ImGui::Spacing(); ImGui::Spacing();
ImGui::SetNextItemWidth(IPUT_WINDOW_WIDTH); ImGui::SetNextItemWidth(IPUT_WINDOW_WIDTH);
@@ -62,7 +63,8 @@ int Render::RemoteWindow() {
"##remote_id_", remote_id_display_, IM_ARRAYSIZE(remote_id_display_), "##remote_id_", remote_id_display_, IM_ARRAYSIZE(remote_id_display_),
ImGuiInputTextFlags_CharsUppercase | ImGuiInputTextFlags_CharsUppercase |
ImGuiInputTextFlags_EnterReturnsTrue | ImGuiInputTextFlags_EnterReturnsTrue |
ImGuiInputTextFlags_CallbackEdit | ImGuiInputTextFlags_CharsNoBlank, ImGuiInputTextFlags_CallbackEdit |
ImGuiInputTextFlags_CharsNoBlank,
InputTextCallback); InputTextCallback);
ImGui::PopStyleVar(); ImGui::PopStyleVar();
@@ -78,7 +80,8 @@ int Render::RemoteWindow() {
remote_id_.erase(remove_if(remote_id_.begin(), remote_id_.end(), remote_id_.erase(remove_if(remote_id_.begin(), remote_id_.end(),
static_cast<int (*)(int)>(&isspace)), static_cast<int (*)(int)>(&isspace)),
remote_id_.end()); remote_id_.end());
if (0 == strcmp(remote_id_.c_str(), client_id_) && !peer_reserved_) { if (0 == strcmp(remote_id_.c_str(), client_id_) &&
!peer_reserved_) {
peer_reserved_ = CreatePeer(&params_); peer_reserved_ = CreatePeer(&params_);
if (peer_reserved_) { if (peer_reserved_) {
LOG_INFO("Create peer[reserved] instance successful"); LOG_INFO("Create peer[reserved] instance successful");
@@ -103,6 +106,7 @@ int Render::RemoteWindow() {
} }
} }
ImGui::EndChild(); ImGui::EndChild();
}
ImGui::EndChild(); ImGui::EndChild();
ImGui::PopStyleVar(); ImGui::PopStyleVar();

View File

@@ -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;

View File

@@ -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();