mirror of
https://github.com/kunkundi/crossdesk.git
synced 2025-10-26 12:15:34 +08:00
[feat] use self designed title bar instead of system default title bar
This commit is contained in:
@@ -17,7 +17,6 @@ int Render::ConnectionStatusWindow() {
|
|||||||
ImGui::SetNextWindowSize(ImVec2(connection_status_window_width_,
|
ImGui::SetNextWindowSize(ImVec2(connection_status_window_width_,
|
||||||
connection_status_window_height_));
|
connection_status_window_height_));
|
||||||
|
|
||||||
ImGui::SetWindowFontScale(0.5f);
|
|
||||||
ImGui::PushStyleVar(ImGuiStyleVar_FrameRounding, 3.0f);
|
ImGui::PushStyleVar(ImGuiStyleVar_FrameRounding, 3.0f);
|
||||||
|
|
||||||
ImGui::PushStyleColor(ImGuiCol_WindowBg, ImVec4(1.0, 1.0, 1.0, 1.0));
|
ImGui::PushStyleColor(ImGuiCol_WindowBg, ImVec4(1.0, 1.0, 1.0, 1.0));
|
||||||
@@ -30,7 +29,6 @@ int Render::ConnectionStatusWindow() {
|
|||||||
ImGuiWindowFlags_NoSavedSettings);
|
ImGuiWindowFlags_NoSavedSettings);
|
||||||
ImGui::PopStyleVar(2);
|
ImGui::PopStyleVar(2);
|
||||||
ImGui::PopStyleColor();
|
ImGui::PopStyleColor();
|
||||||
ImGui::SetWindowFontScale(1.0f);
|
|
||||||
|
|
||||||
ImGui::SetWindowFontScale(0.5f);
|
ImGui::SetWindowFontScale(0.5f);
|
||||||
std::string text;
|
std::string text;
|
||||||
@@ -130,10 +128,8 @@ int Render::ConnectionStatusWindow() {
|
|||||||
ImGui::Text("%s", text.c_str());
|
ImGui::Text("%s", text.c_str());
|
||||||
ImGui::SetWindowFontScale(1.0f);
|
ImGui::SetWindowFontScale(1.0f);
|
||||||
|
|
||||||
ImGui::SetWindowFontScale(0.5f);
|
|
||||||
ImGui::End();
|
ImGui::End();
|
||||||
ImGui::PopStyleVar();
|
ImGui::PopStyleVar();
|
||||||
ImGui::SetWindowFontScale(1.0f);
|
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -3,7 +3,7 @@
|
|||||||
int Render::ControlWindow() {
|
int Render::ControlWindow() {
|
||||||
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));
|
||||||
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 + title_bar_height_), ImGuiCond_Always);
|
||||||
ImGui::SetWindowFontScale(0.5f);
|
ImGui::SetWindowFontScale(0.5f);
|
||||||
|
|
||||||
auto time_duration = ImGui::GetTime() - control_bar_button_pressed_time_;
|
auto time_duration = ImGui::GetTime() - control_bar_button_pressed_time_;
|
||||||
|
|||||||
@@ -7,18 +7,19 @@
|
|||||||
#include "render.h"
|
#include "render.h"
|
||||||
|
|
||||||
int Render::LocalWindow() {
|
int Render::LocalWindow() {
|
||||||
ImGui::SetNextWindowPos(ImVec2(0, menu_window_height_), ImGuiCond_Always);
|
ImGui::SetNextWindowPos(ImVec2(0, menu_window_height_ + title_bar_height_),
|
||||||
|
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_,
|
||||||
ImVec2(local_window_width_,
|
main_window_height_default_ - title_bar_height_ -
|
||||||
main_window_height_ - menu_window_height_ - status_bar_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);
|
ImGuiWindowFlags_NoBringToFrontOnFocus);
|
||||||
ImGui::PopStyleColor();
|
ImGui::PopStyleColor();
|
||||||
|
|
||||||
ImGui::SetWindowFontScale(1.0f);
|
ImGui::SetWindowFontScale(1.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(ImVec2(main_window_width_, main_window_height_),
|
ImGui::SetNextWindowSize(
|
||||||
ImGuiCond_Always);
|
ImVec2(main_window_width_default_, main_window_height_default_),
|
||||||
|
ImGuiCond_Always);
|
||||||
MenuWindow();
|
MenuWindow();
|
||||||
LocalWindow();
|
LocalWindow();
|
||||||
RemoteWindow();
|
RemoteWindow();
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
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 + title_bar_height_), ImGuiCond_Always);
|
||||||
ImGui::SetWindowFontScale(0.8f);
|
ImGui::SetWindowFontScale(0.8f);
|
||||||
ImGui::BeginChild(
|
ImGui::BeginChild(
|
||||||
"MenuWindow", ImVec2(main_window_width_, menu_window_height_),
|
"MenuWindow", ImVec2(main_window_width_, menu_window_height_),
|
||||||
|
|||||||
@@ -5,19 +5,20 @@
|
|||||||
#include "render.h"
|
#include "render.h"
|
||||||
|
|
||||||
int Render::RemoteWindow() {
|
int Render::RemoteWindow() {
|
||||||
ImGui::SetNextWindowPos(ImVec2(local_window_width_ - 1, menu_window_height_),
|
ImGui::SetNextWindowPos(
|
||||||
ImGuiCond_Always);
|
ImVec2(local_window_width_ - 1, menu_window_height_ + title_bar_height_),
|
||||||
|
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("RemoteDesktopWindow",
|
||||||
"RemoteDesktopWindow",
|
ImVec2(main_window_width_ - local_window_width_ + 1,
|
||||||
ImVec2(main_window_width_ - local_window_width_ + 1,
|
main_window_height_default_ - title_bar_height_ -
|
||||||
main_window_height_ - menu_window_height_ - status_bar_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);
|
ImGuiWindowFlags_NoBringToFrontOnFocus);
|
||||||
ImGui::PopStyleColor();
|
ImGui::PopStyleColor();
|
||||||
|
|
||||||
ImGui::SetWindowFontScale(1.0f);
|
ImGui::SetWindowFontScale(1.0f);
|
||||||
|
|||||||
@@ -18,6 +18,46 @@
|
|||||||
#define REFRESH_EVENT (SDL_USEREVENT + 1)
|
#define REFRESH_EVENT (SDL_USEREVENT + 1)
|
||||||
#define NV12_BUFFER_SIZE 1280 * 720 * 3 / 2
|
#define NV12_BUFFER_SIZE 1280 * 720 * 3 / 2
|
||||||
|
|
||||||
|
#define MOUSE_GRAB_PADDING 10
|
||||||
|
|
||||||
|
SDL_HitTestResult HitTestCallback(SDL_Window *Window, const SDL_Point *Area,
|
||||||
|
void *Data) {
|
||||||
|
int Width, Height;
|
||||||
|
SDL_GetWindowSize(Window, &Width, &Height);
|
||||||
|
|
||||||
|
if (Area->y < 30 && Area->x < 30) {
|
||||||
|
return SDL_HITTEST_DRAGGABLE;
|
||||||
|
} else {
|
||||||
|
return SDL_HITTEST_NORMAL;
|
||||||
|
}
|
||||||
|
|
||||||
|
// if (Area->y < MOUSE_GRAB_PADDING) {
|
||||||
|
// if (Area->x < MOUSE_GRAB_PADDING) {
|
||||||
|
// return SDL_HITTEST_RESIZE_TOPLEFT;
|
||||||
|
// } else if (Area->x > Width - MOUSE_GRAB_PADDING) {
|
||||||
|
// return SDL_HITTEST_RESIZE_TOPRIGHT;
|
||||||
|
// } else {
|
||||||
|
// return SDL_HITTEST_RESIZE_TOP;
|
||||||
|
// }
|
||||||
|
// } else if (Area->y > Height - MOUSE_GRAB_PADDING) {
|
||||||
|
// if (Area->x < MOUSE_GRAB_PADDING) {
|
||||||
|
// return SDL_HITTEST_RESIZE_BOTTOMLEFT;
|
||||||
|
// } else if (Area->x > Width - MOUSE_GRAB_PADDING) {
|
||||||
|
// return SDL_HITTEST_RESIZE_BOTTOMRIGHT;
|
||||||
|
// } else {
|
||||||
|
// return SDL_HITTEST_RESIZE_BOTTOM;
|
||||||
|
// }
|
||||||
|
// } else if (Area->x < MOUSE_GRAB_PADDING) {
|
||||||
|
// return SDL_HITTEST_RESIZE_LEFT;
|
||||||
|
// } else if (Area->x > Width - MOUSE_GRAB_PADDING) {
|
||||||
|
// return SDL_HITTEST_RESIZE_RIGHT;
|
||||||
|
// } else if (Area->y < 70) {
|
||||||
|
// return SDL_HITTEST_DRAGGABLE;
|
||||||
|
// }
|
||||||
|
|
||||||
|
// return SDL_HITTEST_DRAGGABLE; // SDL_HITTEST_NORMAL <- Windows behaviour
|
||||||
|
}
|
||||||
|
|
||||||
Render::Render() {}
|
Render::Render() {}
|
||||||
|
|
||||||
Render::~Render() {}
|
Render::~Render() {}
|
||||||
@@ -213,17 +253,15 @@ int Render::Run() {
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
// From 2.0.18: Enable native IME.
|
|
||||||
#ifdef SDL_HINT_IME_SHOW_UI
|
|
||||||
SDL_SetHint(SDL_HINT_IME_SHOW_UI, "1");
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// Create main window with SDL_Renderer graphics context
|
// Create main window with SDL_Renderer graphics context
|
||||||
SDL_WindowFlags window_flags = (SDL_WindowFlags)(SDL_WINDOW_ALLOW_HIGHDPI);
|
SDL_WindowFlags window_flags =
|
||||||
|
(SDL_WindowFlags)(SDL_WINDOW_ALLOW_HIGHDPI | SDL_WINDOW_BORDERLESS);
|
||||||
main_window_ = SDL_CreateWindow(
|
main_window_ = SDL_CreateWindow(
|
||||||
"Remote Desk", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED,
|
"Remote Desk", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED,
|
||||||
main_window_width_default_, main_window_height_default_, window_flags);
|
main_window_width_default_, main_window_height_default_, window_flags);
|
||||||
|
|
||||||
|
SDL_SetWindowHitTest(main_window_, HitTestCallback, 0);
|
||||||
|
|
||||||
main_renderer_ = SDL_CreateRenderer(
|
main_renderer_ = SDL_CreateRenderer(
|
||||||
main_window_, -1, SDL_RENDERER_PRESENTVSYNC | SDL_RENDERER_ACCELERATED);
|
main_window_, -1, SDL_RENDERER_PRESENTVSYNC | SDL_RENDERER_ACCELERATED);
|
||||||
if (main_renderer_ == nullptr) {
|
if (main_renderer_ == nullptr) {
|
||||||
@@ -238,7 +276,7 @@ int Render::Run() {
|
|||||||
texture_width_, texture_height_);
|
texture_width_, texture_height_);
|
||||||
|
|
||||||
stream_render_rect_.x = 0;
|
stream_render_rect_.x = 0;
|
||||||
stream_render_rect_.y = 0;
|
stream_render_rect_.y = title_bar_height_;
|
||||||
stream_render_rect_.w = main_window_width_;
|
stream_render_rect_.w = main_window_width_;
|
||||||
stream_render_rect_.h = main_window_height_;
|
stream_render_rect_.h = main_window_height_;
|
||||||
|
|
||||||
@@ -394,26 +432,30 @@ int Render::Run() {
|
|||||||
ImGui_ImplSDL2_NewFrame();
|
ImGui_ImplSDL2_NewFrame();
|
||||||
ImGui::NewFrame();
|
ImGui::NewFrame();
|
||||||
|
|
||||||
ImGui::PushStyleColor(ImGuiCol_WindowBg,
|
// ImGui::PushStyleColor(ImGuiCol_WindowBg,
|
||||||
ImVec4(1.0f, 1.0f, 1.0f, streaming_ ? 0 : 1.0f));
|
// ImVec4(1.0f, 1.0f, 1.0f, streaming_ ? 0 : 1.0f));
|
||||||
ImGui::PushStyleVar(ImGuiStyleVar_WindowBorderSize, 0);
|
ImGui::PushStyleVar(ImGuiStyleVar_WindowBorderSize, 0);
|
||||||
ImGui::SetNextWindowPos(ImVec2(0, 0), ImGuiCond_Always);
|
ImGui::SetNextWindowPos(ImVec2(0, 0), ImGuiCond_Always);
|
||||||
ImGui::SetNextWindowSize(
|
ImGui::SetNextWindowSize(
|
||||||
ImVec2(main_window_width_,
|
ImVec2(main_window_width_,
|
||||||
streaming_ ? control_window_height_ : main_window_height_),
|
streaming_ ? title_bar_height_ : main_window_height_default_),
|
||||||
ImGuiCond_Always);
|
ImGuiCond_Always);
|
||||||
ImGui::Begin("Render", nullptr,
|
ImGui::Begin("Render", nullptr,
|
||||||
ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoTitleBar |
|
ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoTitleBar |
|
||||||
ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoScrollbar);
|
ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoScrollbar |
|
||||||
|
ImGuiWindowFlags_NoBringToFrontOnFocus);
|
||||||
ImGui::PopStyleVar();
|
ImGui::PopStyleVar();
|
||||||
ImGui::PopStyleColor();
|
// ImGui::PopStyleColor();
|
||||||
|
|
||||||
|
TitleBar();
|
||||||
|
|
||||||
if (streaming_ && is_client_mode_) {
|
if (streaming_ && is_client_mode_) {
|
||||||
if (!resizable_) {
|
if (!resizable_) {
|
||||||
resizable_ = !resizable_;
|
resizable_ = !resizable_;
|
||||||
SDL_SetWindowResizable(main_window_, SDL_TRUE);
|
SDL_SetWindowResizable(main_window_, SDL_TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
ControlWindow();
|
// ControlWindow();
|
||||||
} else {
|
} else {
|
||||||
if (resizable_) {
|
if (resizable_) {
|
||||||
resizable_ = !resizable_;
|
resizable_ = !resizable_;
|
||||||
@@ -491,7 +533,7 @@ int Render::Run() {
|
|||||||
&stream_render_rect_);
|
&stream_render_rect_);
|
||||||
}
|
}
|
||||||
|
|
||||||
ImGui_ImplSDLRenderer2_RenderDrawData(ImGui::GetDrawData());
|
ImGui_ImplSDLRenderer2_RenderDrawData(ImGui::GetDrawData(), main_renderer_);
|
||||||
SDL_RenderPresent(main_renderer_);
|
SDL_RenderPresent(main_renderer_);
|
||||||
|
|
||||||
// frame_count_++;
|
// frame_count_++;
|
||||||
|
|||||||
@@ -32,6 +32,7 @@ class Render {
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
int CreateStreamRenderWindow();
|
int CreateStreamRenderWindow();
|
||||||
|
int TitleBar();
|
||||||
int MainWindow();
|
int MainWindow();
|
||||||
int LocalWindow();
|
int LocalWindow();
|
||||||
int RemoteWindow();
|
int RemoteWindow();
|
||||||
@@ -61,7 +62,7 @@ class Render {
|
|||||||
static void OnConnectionStatusCb(ConnectionStatus status, void *user_data);
|
static void OnConnectionStatusCb(ConnectionStatus status, void *user_data);
|
||||||
|
|
||||||
static void NetStatusReport(TraversalMode mode, const unsigned short send,
|
static void NetStatusReport(TraversalMode mode, const unsigned short send,
|
||||||
const unsigned short receive, void *user_ptr);
|
const unsigned short receive, void *user_ptr);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
int ProcessMouseKeyEven(SDL_Event &ev);
|
int ProcessMouseKeyEven(SDL_Event &ev);
|
||||||
@@ -123,10 +124,12 @@ class Render {
|
|||||||
bool is_client_mode_ = false;
|
bool is_client_mode_ = false;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
int title_bar_width_ = 960;
|
||||||
|
int title_bar_height_ = 30;
|
||||||
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_ = 540;
|
int main_window_height_default_ = 570;
|
||||||
int main_window_width_ = 960;
|
int main_window_width_ = 960;
|
||||||
int main_window_height_ = 540;
|
int main_window_height_ = 540;
|
||||||
int main_window_width_last_ = 960;
|
int main_window_width_last_ = 960;
|
||||||
@@ -137,6 +140,8 @@ class Render {
|
|||||||
int stream_window_height_last_ = 720;
|
int stream_window_height_last_ = 720;
|
||||||
int main_window_width_before_fullscreen_ = 1280;
|
int main_window_width_before_fullscreen_ = 1280;
|
||||||
int main_window_height_before_fullscreen_ = 720;
|
int main_window_height_before_fullscreen_ = 720;
|
||||||
|
int main_window_width_before_maximized_ = 960;
|
||||||
|
int main_window_height_before_maximized_ = 570;
|
||||||
int menu_window_height_ = 30;
|
int menu_window_height_ = 30;
|
||||||
int control_window_min_width_ = 40;
|
int control_window_min_width_ = 40;
|
||||||
int control_window_height_ = 40;
|
int control_window_height_ = 40;
|
||||||
@@ -190,6 +195,7 @@ class Render {
|
|||||||
bool streaming_ = false;
|
bool streaming_ = false;
|
||||||
bool show_about_window_ = false;
|
bool show_about_window_ = false;
|
||||||
bool show_connection_status_window_ = false;
|
bool show_connection_status_window_ = false;
|
||||||
|
bool window_maximized_ = false;
|
||||||
|
|
||||||
double copy_start_time_ = 0;
|
double copy_start_time_ = 0;
|
||||||
double regenerate_password_start_time_ = 0;
|
double regenerate_password_start_time_ = 0;
|
||||||
@@ -207,6 +213,7 @@ class Render {
|
|||||||
std::string signal_status_str_ = "";
|
std::string signal_status_str_ = "";
|
||||||
std::string connection_status_str_ = "";
|
std::string connection_status_str_ = "";
|
||||||
bool signal_connected_ = false;
|
bool signal_connected_ = false;
|
||||||
|
bool p2p_mode_ = true;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
PeerPtr *peer_ = nullptr;
|
PeerPtr *peer_ = nullptr;
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ int Render::StatusBar() {
|
|||||||
ImGui::PushStyleColor(ImGuiCol_MenuBarBg, ImVec4(0, 0, 0, 1));
|
ImGui::PushStyleColor(ImGuiCol_MenuBarBg, ImVec4(0, 0, 0, 1));
|
||||||
static bool a, b, c, d, e;
|
static bool a, b, c, d, e;
|
||||||
ImGui::SetNextWindowPos(
|
ImGui::SetNextWindowPos(
|
||||||
ImVec2(0, main_window_height_ - status_bar_height_ - 1),
|
ImVec2(0, main_window_height_default_ - status_bar_height_ - 1),
|
||||||
ImGuiCond_Always);
|
ImGuiCond_Always);
|
||||||
|
|
||||||
ImGui::BeginChild(
|
ImGui::BeginChild(
|
||||||
@@ -15,17 +15,17 @@ int Render::StatusBar() {
|
|||||||
|
|
||||||
ImDrawList* draw_list = ImGui::GetWindowDrawList();
|
ImDrawList* draw_list = ImGui::GetWindowDrawList();
|
||||||
draw_list->AddCircleFilled(
|
draw_list->AddCircleFilled(
|
||||||
ImVec2(15, main_window_height_ - status_bar_height_ + 9.0f), 5,
|
ImVec2(15, main_window_height_default_ - status_bar_height_ + 9.0f), 5,
|
||||||
ImColor(signal_connected_ ? 0.0f : 1.0f, signal_connected_ ? 1.0f : 0.0f,
|
ImColor(signal_connected_ ? 0.0f : 1.0f, signal_connected_ ? 1.0f : 0.0f,
|
||||||
0.0f),
|
0.0f),
|
||||||
100);
|
100);
|
||||||
draw_list->AddCircle(
|
draw_list->AddCircle(
|
||||||
ImVec2(15, main_window_height_ - status_bar_height_ + 10.0f), 6,
|
ImVec2(15, main_window_height_default_ - status_bar_height_ + 10.0f), 6,
|
||||||
ImColor(1.0f, 1.0f, 1.0f), 100);
|
ImColor(1.0f, 1.0f, 1.0f), 100);
|
||||||
|
|
||||||
ImGui::SetWindowFontScale(0.5f);
|
ImGui::SetWindowFontScale(0.5f);
|
||||||
draw_list->AddText(
|
draw_list->AddText(
|
||||||
ImVec2(25, main_window_height_ - status_bar_height_ + 3.0f),
|
ImVec2(25, main_window_height_default_ - status_bar_height_ + 3.0f),
|
||||||
ImColor(0.0f, 0.0f, 0.0f),
|
ImColor(0.0f, 0.0f, 0.0f),
|
||||||
signal_connected_
|
signal_connected_
|
||||||
? localization::signal_connected[localization_language_index_].c_str()
|
? localization::signal_connected[localization_language_index_].c_str()
|
||||||
|
|||||||
108
src/single_window/title_bar.cpp
Normal file
108
src/single_window/title_bar.cpp
Normal file
@@ -0,0 +1,108 @@
|
|||||||
|
#include "IconsFontAwesome6.h"
|
||||||
|
#include "localization.h"
|
||||||
|
#include "render.h"
|
||||||
|
|
||||||
|
int Render::TitleBar() {
|
||||||
|
ImGui::PushStyleColor(ImGuiCol_MenuBarBg, ImVec4(0, 0, 0, 0.05f));
|
||||||
|
ImGui::SetNextWindowPos(ImVec2(0, 0), ImGuiCond_Always);
|
||||||
|
ImGui::BeginChild("TitleBar", ImVec2(main_window_width_, title_bar_height_),
|
||||||
|
ImGuiChildFlags_Border,
|
||||||
|
ImGuiWindowFlags_MenuBar | ImGuiWindowFlags_NoDecoration |
|
||||||
|
ImGuiWindowFlags_NoBringToFrontOnFocus);
|
||||||
|
|
||||||
|
ImGui::SetWindowFontScale(1.0f);
|
||||||
|
if (ImGui::BeginMenuBar()) {
|
||||||
|
ImGui::PushStyleColor(ImGuiCol_Button, ImVec4(0, 0, 0, 0));
|
||||||
|
|
||||||
|
ImGui::SetCursorPosX(60);
|
||||||
|
if (streaming_) {
|
||||||
|
std::string mouse = ICON_FA_COMPUTER_MOUSE;
|
||||||
|
if (ImGui::Button(mouse.c_str(), ImVec2(30, 30))) {
|
||||||
|
if (mouse_control_button_label_ ==
|
||||||
|
localization::control_mouse[localization_language_index_] &&
|
||||||
|
connection_established_) {
|
||||||
|
mouse_control_button_pressed_ = true;
|
||||||
|
control_mouse_ = true;
|
||||||
|
mouse_control_button_label_ =
|
||||||
|
localization::release_mouse[localization_language_index_];
|
||||||
|
} else {
|
||||||
|
control_mouse_ = false;
|
||||||
|
mouse_control_button_label_ =
|
||||||
|
localization::control_mouse[localization_language_index_];
|
||||||
|
}
|
||||||
|
mouse_control_button_pressed_ = !mouse_control_button_pressed_;
|
||||||
|
}
|
||||||
|
|
||||||
|
ImGui::SameLine();
|
||||||
|
// Fullscreen
|
||||||
|
std::string fullscreen =
|
||||||
|
fullscreen_button_pressed_ ? ICON_FA_COMPRESS : ICON_FA_EXPAND;
|
||||||
|
if (ImGui::Button(fullscreen.c_str(), ImVec2(30, 30))) {
|
||||||
|
fullscreen_button_pressed_ = !fullscreen_button_pressed_;
|
||||||
|
if (fullscreen_button_pressed_) {
|
||||||
|
main_window_width_before_fullscreen_ = main_window_width_;
|
||||||
|
main_window_height_before_fullscreen_ = main_window_height_;
|
||||||
|
SDL_SetWindowFullscreen(main_window_, SDL_WINDOW_FULLSCREEN_DESKTOP);
|
||||||
|
} else {
|
||||||
|
SDL_SetWindowFullscreen(main_window_, SDL_FALSE);
|
||||||
|
SDL_SetWindowSize(main_window_, main_window_width_before_fullscreen_,
|
||||||
|
main_window_height_before_fullscreen_);
|
||||||
|
main_window_width_ = main_window_width_before_fullscreen_;
|
||||||
|
main_window_height_ = main_window_height_before_fullscreen_;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ImGui::SetCursorPosX(main_window_width_ - (streaming_ ? 90 : 60));
|
||||||
|
ImGui::PushStyleColor(ImGuiCol_ButtonHovered, ImVec4(0, 0, 0, 0.1f));
|
||||||
|
ImGui::PushStyleColor(ImGuiCol_ButtonActive,
|
||||||
|
ImVec4(1.0f, 1.0f, 1.0f, 1.0f));
|
||||||
|
std::string window_minimize_button = ICON_FA_MINUS;
|
||||||
|
if (ImGui::Button(window_minimize_button.c_str(), ImVec2(30, 30))) {
|
||||||
|
SDL_MinimizeWindow(main_window_);
|
||||||
|
}
|
||||||
|
ImGui::PopStyleColor(2);
|
||||||
|
|
||||||
|
if (streaming_) {
|
||||||
|
ImGui::SetCursorPosX(main_window_width_ - 60);
|
||||||
|
ImGui::PushStyleColor(ImGuiCol_ButtonHovered, ImVec4(0, 0, 0, 0.1f));
|
||||||
|
ImGui::PushStyleColor(ImGuiCol_ButtonActive,
|
||||||
|
ImVec4(1.0f, 1.0f, 1.0f, 1.0f));
|
||||||
|
|
||||||
|
if (window_maximized_) {
|
||||||
|
std::string window_restore_button = ICON_FA_WINDOW_RESTORE;
|
||||||
|
if (ImGui::Button(window_restore_button.c_str(), ImVec2(30, 30))) {
|
||||||
|
SDL_RestoreWindow(main_window_);
|
||||||
|
window_maximized_ = !window_maximized_;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
std::string window_maximize_button = ICON_FA_SQUARE;
|
||||||
|
if (ImGui::Button(window_maximize_button.c_str(), ImVec2(30, 30))) {
|
||||||
|
SDL_GetWindowSize(main_window_, &main_window_width_before_maximized_,
|
||||||
|
&main_window_height_before_maximized_);
|
||||||
|
SDL_MaximizeWindow(main_window_);
|
||||||
|
window_maximized_ = !window_maximized_;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ImGui::PopStyleColor(2);
|
||||||
|
}
|
||||||
|
|
||||||
|
ImGui::SetCursorPosX(main_window_width_ - 30);
|
||||||
|
ImGui::PushStyleColor(ImGuiCol_ButtonHovered, ImVec4(1.0f, 0, 0, 1.0f));
|
||||||
|
ImGui::PushStyleColor(ImGuiCol_ButtonActive, ImVec4(1.0f, 0, 0, 0.5f));
|
||||||
|
std::string close_button = ICON_FA_XMARK;
|
||||||
|
if (ImGui::Button(close_button.c_str(), ImVec2(30, 30))) {
|
||||||
|
SDL_Event event;
|
||||||
|
event.type = SDL_QUIT;
|
||||||
|
SDL_PushEvent(&event);
|
||||||
|
}
|
||||||
|
ImGui::PopStyleColor(2);
|
||||||
|
|
||||||
|
ImGui::PopStyleColor(1);
|
||||||
|
}
|
||||||
|
ImGui::SetWindowFontScale(1.0f);
|
||||||
|
|
||||||
|
ImGui::EndChild();
|
||||||
|
ImGui::PopStyleColor(2);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
2
thirdparty/projectx
vendored
2
thirdparty/projectx
vendored
Submodule thirdparty/projectx updated: 54179722e5...66fc4d3f95
@@ -18,7 +18,7 @@ if is_mode("debug") then
|
|||||||
end
|
end
|
||||||
|
|
||||||
add_requires("spdlog 1.14.1", {system = false})
|
add_requires("spdlog 1.14.1", {system = false})
|
||||||
add_requires("imgui 1.90.6", {configs = {sdl2 = true, sdl2_renderer = true}})
|
add_requires("imgui v1.91.0", {configs = {sdl2 = true, sdl2_renderer = true}})
|
||||||
add_requires("libyuv")
|
add_requires("libyuv")
|
||||||
|
|
||||||
if is_os("windows") then
|
if is_os("windows") then
|
||||||
|
|||||||
Reference in New Issue
Block a user