mirror of
https://github.com/kunkundi/crossdesk.git
synced 2025-10-26 20:25:34 +08:00
[feat] remove menu bar and move menu button to title bar
This commit is contained in:
5658
fonts/fa_regular_400.h
Normal file
5658
fonts/fa_regular_400.h
Normal file
File diff suppressed because it is too large
Load Diff
@@ -28,7 +28,7 @@ static std::vector<std::string> exit_fullscreen = {u8" 退出全屏",
|
||||
" Exit fullscreen"};
|
||||
static std::vector<std::string> control_mouse = {u8" 控制", " Control"};
|
||||
static std::vector<std::string> release_mouse = {u8" 释放", " Release"};
|
||||
static std::vector<std::string> settings = {u8" 设置", " Settings"};
|
||||
static std::vector<std::string> settings = {u8"设置", "Settings"};
|
||||
static std::vector<std::string> language = {u8"语言:", "Language:"};
|
||||
static std::vector<std::string> language_zh = {u8"中文", "Chinese"};
|
||||
static std::vector<std::string> language_en = {u8"英文", "English"};
|
||||
|
||||
@@ -544,11 +544,11 @@ int Render::Run() {
|
||||
ImGui::Spacing();
|
||||
|
||||
if (ImGui::Button(settings_button_label_.c_str())) {
|
||||
settings_button_pressed_ = !settings_button_pressed_;
|
||||
show_settings_window_ = !show_settings_window_;
|
||||
settings_window_pos_reset_ = true;
|
||||
}
|
||||
|
||||
if (settings_button_pressed_) {
|
||||
if (show_settings_window_) {
|
||||
if (settings_window_pos_reset_) {
|
||||
const ImGuiViewport *viewport = ImGui::GetMainViewport();
|
||||
if (ConfigCenter::LANGUAGE::CHINESE == localization_language_) {
|
||||
@@ -690,7 +690,7 @@ int Render::Run() {
|
||||
// OK
|
||||
if (ImGui::Button(
|
||||
localization::ok[localization_language_index_].c_str())) {
|
||||
settings_button_pressed_ = false;
|
||||
show_settings_window_ = false;
|
||||
|
||||
// Language
|
||||
if (language_button_value_ == 0) {
|
||||
@@ -751,7 +751,7 @@ int Render::Run() {
|
||||
// Cancel
|
||||
if (ImGui::Button(
|
||||
localization::cancel[localization_language_index_].c_str())) {
|
||||
settings_button_pressed_ = false;
|
||||
show_settings_window_ = false;
|
||||
if (language_button_value_ != language_button_value_last_) {
|
||||
language_button_value_ = language_button_value_last_;
|
||||
}
|
||||
|
||||
@@ -122,7 +122,7 @@ class Render {
|
||||
bool connect_button_pressed_ = false;
|
||||
bool fullscreen_button_pressed_ = false;
|
||||
bool mouse_control_button_pressed_ = false;
|
||||
bool settings_button_pressed_ = false;
|
||||
bool show_settings_window_ = false;
|
||||
bool received_frame_ = false;
|
||||
bool is_create_connection_ = false;
|
||||
bool audio_buffer_fresh_ = false;
|
||||
|
||||
@@ -7,8 +7,8 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#define FONT_ICON_FILE_NAME_FAR "fa-regular-400.ttf"
|
||||
#define FONT_ICON_FILE_NAME_FAS "fa-solid-900.ttf"
|
||||
// #define FONT_ICON_FILE_NAME_FAR "fa-regular-400.ttf"
|
||||
// #define FONT_ICON_FILE_NAME_FAS "fa-solid-900.ttf"
|
||||
|
||||
#define ICON_MIN_FA 0xe005
|
||||
#define ICON_MAX_16_FA 0xf8ff
|
||||
|
||||
56
src/single_window/about_window.cpp
Normal file
56
src/single_window/about_window.cpp
Normal file
@@ -0,0 +1,56 @@
|
||||
#include "IconsFontAwesome6.h"
|
||||
#include "layout_style.h"
|
||||
#include "localization.h"
|
||||
#include "rd_log.h"
|
||||
#include "render.h"
|
||||
|
||||
int Render::AboutWindow() {
|
||||
if (show_about_window_) {
|
||||
const ImGuiViewport *viewport = ImGui::GetMainViewport();
|
||||
|
||||
ImGui::SetNextWindowPos(ImVec2(
|
||||
(viewport->WorkSize.x - viewport->WorkPos.x - about_window_width_) / 2,
|
||||
(viewport->WorkSize.y - viewport->WorkPos.y - about_window_height_) /
|
||||
2));
|
||||
|
||||
ImGui::SetNextWindowSize(ImVec2(about_window_width_, about_window_height_));
|
||||
|
||||
ImGui::PushStyleColor(ImGuiCol_WindowBg, ImVec4(1.0f, 1.0f, 1.0f, 1.0f));
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_WindowBorderSize, 1.0f);
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_WindowRounding, 5.0f);
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_FrameRounding, 3.0f);
|
||||
ImGui::SetWindowFontScale(0.5f);
|
||||
ImGui::Begin(
|
||||
localization::about[localization_language_index_].c_str(), nullptr,
|
||||
ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoCollapse |
|
||||
ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoSavedSettings);
|
||||
ImGui::SetWindowFontScale(1.0f);
|
||||
ImGui::SetWindowFontScale(0.5f);
|
||||
|
||||
std::string version;
|
||||
#ifdef RD_VERSION
|
||||
version = RD_VERSION;
|
||||
#else
|
||||
version = "Unknown";
|
||||
#endif
|
||||
|
||||
std::string text =
|
||||
localization::version[localization_language_index_] + ": " + version;
|
||||
ImGui::Text("%s", text.c_str());
|
||||
|
||||
ImGui::SetCursorPosX(about_window_width_ * 0.42f);
|
||||
ImGui::SetCursorPosY(about_window_height_ * 0.75f);
|
||||
// OK
|
||||
if (ImGui::Button(localization::ok[localization_language_index_].c_str())) {
|
||||
show_about_window_ = false;
|
||||
}
|
||||
|
||||
ImGui::SetWindowFontScale(1.0f);
|
||||
ImGui::SetWindowFontScale(0.5f);
|
||||
ImGui::End();
|
||||
ImGui::SetWindowFontScale(1.0f);
|
||||
ImGui::PopStyleVar(3);
|
||||
ImGui::PopStyleColor();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@@ -3,7 +3,7 @@
|
||||
int Render::ControlWindow() {
|
||||
ImGui::PushStyleColor(ImGuiCol_ChildBg, ImVec4(1.0f, 1.0f, 1.0f, 1.0f));
|
||||
static bool a, b, c, d, e;
|
||||
ImGui::SetNextWindowPos(ImVec2(0, 0 + title_bar_height_), ImGuiCond_Always);
|
||||
ImGui::SetNextWindowPos(ImVec2(0, title_bar_height_ + 2), ImGuiCond_Always);
|
||||
ImGui::SetWindowFontScale(0.5f);
|
||||
|
||||
auto time_duration = ImGui::GetTime() - control_bar_button_pressed_time_;
|
||||
|
||||
@@ -7,19 +7,18 @@
|
||||
#include "render.h"
|
||||
|
||||
int Render::LocalWindow() {
|
||||
ImGui::SetNextWindowPos(ImVec2(0, menu_window_height_ + title_bar_height_),
|
||||
ImGuiCond_Always);
|
||||
ImGui::SetNextWindowPos(ImVec2(0, title_bar_height_), ImGuiCond_Always);
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_FrameRounding, 3.0f);
|
||||
|
||||
ImGui::PushStyleColor(ImGuiCol_ChildBg, ImVec4(1.0f, 1.0f, 1.0f, 1.0f));
|
||||
ImGui::BeginChild("LocalDesktopWindow",
|
||||
ImVec2(local_window_width_,
|
||||
main_window_height_default_ - title_bar_height_ -
|
||||
menu_window_height_ - status_bar_height_),
|
||||
ImGuiChildFlags_Border,
|
||||
ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoCollapse |
|
||||
ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoTitleBar |
|
||||
ImGuiWindowFlags_NoBringToFrontOnFocus);
|
||||
ImGui::BeginChild(
|
||||
"LocalDesktopWindow",
|
||||
ImVec2(local_window_width_, main_window_height_default_ -
|
||||
title_bar_height_ - status_bar_height_),
|
||||
ImGuiChildFlags_Border,
|
||||
ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoCollapse |
|
||||
ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoTitleBar |
|
||||
ImGuiWindowFlags_NoBringToFrontOnFocus);
|
||||
ImGui::PopStyleColor();
|
||||
|
||||
ImGui::SetWindowFontScale(1.0f);
|
||||
|
||||
@@ -5,7 +5,7 @@ int Render::MainWindow() {
|
||||
ImGui::SetNextWindowSize(
|
||||
ImVec2(main_window_width_default_, main_window_height_default_),
|
||||
ImGuiCond_Always);
|
||||
MenuWindow();
|
||||
|
||||
LocalWindow();
|
||||
RemoteWindow();
|
||||
StatusBar();
|
||||
|
||||
@@ -1,91 +0,0 @@
|
||||
#include "IconsFontAwesome6.h"
|
||||
#include "layout_style.h"
|
||||
#include "localization.h"
|
||||
#include "rd_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 + title_bar_height_), ImGuiCond_Always);
|
||||
ImGui::SetWindowFontScale(0.8f);
|
||||
ImGui::BeginChild(
|
||||
"MenuWindow", ImVec2(main_window_width_, menu_window_height_),
|
||||
ImGuiChildFlags_Border,
|
||||
ImGuiWindowFlags_MenuBar | ImGuiWindowFlags_NoBringToFrontOnFocus);
|
||||
ImGui::PopStyleColor();
|
||||
|
||||
ImGui::SetWindowFontScale(1.0f);
|
||||
if (ImGui::BeginMenuBar()) {
|
||||
if (ImGui::BeginMenu(ICON_FA_BARS, true)) {
|
||||
ImGui::SetWindowFontScale(0.5f);
|
||||
if (ImGui::MenuItem(
|
||||
localization::about[localization_language_index_].c_str())) {
|
||||
show_about_window_ = true;
|
||||
}
|
||||
ImGui::SetWindowFontScale(1.0f);
|
||||
ImGui::EndMenu();
|
||||
}
|
||||
|
||||
ImGui::Dummy(ImVec2(main_window_width_ - 97, 0));
|
||||
|
||||
SettingButton();
|
||||
|
||||
if (show_about_window_) {
|
||||
AboutWindow();
|
||||
}
|
||||
}
|
||||
|
||||
ImGui::EndChild();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int Render::AboutWindow() {
|
||||
const ImGuiViewport *viewport = ImGui::GetMainViewport();
|
||||
|
||||
ImGui::SetNextWindowPos(ImVec2(
|
||||
(viewport->WorkSize.x - viewport->WorkPos.x - about_window_width_) / 2,
|
||||
(viewport->WorkSize.y - viewport->WorkPos.y - about_window_height_) / 2));
|
||||
|
||||
ImGui::SetNextWindowSize(ImVec2(about_window_width_, about_window_height_));
|
||||
|
||||
ImGui::PushStyleColor(ImGuiCol_WindowBg, ImVec4(1.0f, 1.0f, 1.0f, 1.0f));
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_WindowBorderSize, 1.0f);
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_WindowRounding, 5.0f);
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_FrameRounding, 3.0f);
|
||||
ImGui::SetWindowFontScale(0.5f);
|
||||
ImGui::Begin(localization::about[localization_language_index_].c_str(),
|
||||
nullptr,
|
||||
ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoCollapse |
|
||||
ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoSavedSettings);
|
||||
ImGui::SetWindowFontScale(1.0f);
|
||||
ImGui::SetWindowFontScale(0.5f);
|
||||
|
||||
std::string version;
|
||||
#ifdef RD_VERSION
|
||||
version = RD_VERSION;
|
||||
#else
|
||||
version = "Unknown";
|
||||
#endif
|
||||
|
||||
std::string text =
|
||||
localization::version[localization_language_index_] + ": " + version;
|
||||
ImGui::Text("%s", text.c_str());
|
||||
|
||||
ImGui::SetCursorPosX(about_window_width_ * 0.42f);
|
||||
ImGui::SetCursorPosY(about_window_height_ * 0.75f);
|
||||
// OK
|
||||
if (ImGui::Button(localization::ok[localization_language_index_].c_str())) {
|
||||
show_about_window_ = false;
|
||||
}
|
||||
|
||||
ImGui::SetWindowFontScale(1.0f);
|
||||
ImGui::SetWindowFontScale(0.5f);
|
||||
ImGui::End();
|
||||
ImGui::SetWindowFontScale(1.0f);
|
||||
ImGui::PopStyleVar(3);
|
||||
ImGui::PopStyleColor();
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -5,16 +5,15 @@
|
||||
#include "render.h"
|
||||
|
||||
int Render::RemoteWindow() {
|
||||
ImGui::SetNextWindowPos(
|
||||
ImVec2(local_window_width_ - 1, menu_window_height_ + title_bar_height_),
|
||||
ImGuiCond_Always);
|
||||
ImGui::SetNextWindowPos(ImVec2(local_window_width_ - 1, title_bar_height_),
|
||||
ImGuiCond_Always);
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_FrameRounding, 3.0f);
|
||||
|
||||
ImGui::PushStyleColor(ImGuiCol_ChildBg, ImVec4(1.0f, 1.0f, 1.0f, 1.0f));
|
||||
ImGui::BeginChild("RemoteDesktopWindow",
|
||||
ImVec2(main_window_width_ - local_window_width_ + 1,
|
||||
main_window_height_default_ - title_bar_height_ -
|
||||
menu_window_height_ - status_bar_height_),
|
||||
status_bar_height_),
|
||||
ImGuiChildFlags_Border,
|
||||
ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoCollapse |
|
||||
ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoTitleBar |
|
||||
|
||||
@@ -7,7 +7,8 @@
|
||||
#include "IconsFontAwesome6.h"
|
||||
#include "OPPOSans_Regular.h"
|
||||
#include "device_controller_factory.h"
|
||||
#include "fa-solid-900.h"
|
||||
#include "fa_regular_400.h"
|
||||
#include "fa_solid_900.h"
|
||||
#include "layout_style.h"
|
||||
#include "localization.h"
|
||||
#include "platform.h"
|
||||
@@ -18,44 +19,47 @@
|
||||
#define REFRESH_EVENT (SDL_USEREVENT + 1)
|
||||
#define NV12_BUFFER_SIZE 1280 * 720 * 3 / 2
|
||||
|
||||
#define MOUSE_GRAB_PADDING 10
|
||||
#define MOUSE_GRAB_PADDING 5
|
||||
|
||||
SDL_HitTestResult HitTestCallback(SDL_Window *Window, const SDL_Point *Area,
|
||||
void *Data) {
|
||||
int Width, Height;
|
||||
SDL_GetWindowSize(Window, &Width, &Height);
|
||||
SDL_HitTestResult Render::HitTestCallback(SDL_Window *window,
|
||||
const SDL_Point *area, void *data) {
|
||||
Render *render = (Render *)data;
|
||||
|
||||
if (Area->y < 30 && Area->x < 30) {
|
||||
int window_width, window_height;
|
||||
SDL_GetWindowSize(window, &window_width, &window_height);
|
||||
|
||||
if (area->y < 30 && area->y > MOUSE_GRAB_PADDING &&
|
||||
area->x < window_width - 120 && area->x > MOUSE_GRAB_PADDING) {
|
||||
return SDL_HITTEST_DRAGGABLE;
|
||||
} else {
|
||||
}
|
||||
|
||||
if (!render->streaming_) {
|
||||
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;
|
||||
// }
|
||||
if (area->y < MOUSE_GRAB_PADDING) {
|
||||
if (area->x < MOUSE_GRAB_PADDING) {
|
||||
return SDL_HITTEST_RESIZE_TOPLEFT;
|
||||
} else if (area->x > window_width - MOUSE_GRAB_PADDING) {
|
||||
return SDL_HITTEST_RESIZE_TOPRIGHT;
|
||||
} else {
|
||||
return SDL_HITTEST_RESIZE_TOP;
|
||||
}
|
||||
} else if (area->y > window_height - MOUSE_GRAB_PADDING) {
|
||||
if (area->x < MOUSE_GRAB_PADDING) {
|
||||
return SDL_HITTEST_RESIZE_BOTTOMLEFT;
|
||||
} else if (area->x > window_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 > window_width - MOUSE_GRAB_PADDING) {
|
||||
return SDL_HITTEST_RESIZE_RIGHT;
|
||||
}
|
||||
|
||||
// return SDL_HITTEST_DRAGGABLE; // SDL_HITTEST_NORMAL <- Windows behaviour
|
||||
return SDL_HITTEST_NORMAL;
|
||||
}
|
||||
|
||||
Render::Render() {}
|
||||
@@ -260,7 +264,7 @@ int Render::Run() {
|
||||
"Remote Desk", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED,
|
||||
main_window_width_default_, main_window_height_default_, window_flags);
|
||||
|
||||
SDL_SetWindowHitTest(main_window_, HitTestCallback, 0);
|
||||
SDL_SetWindowHitTest(main_window_, HitTestCallback, this);
|
||||
|
||||
main_renderer_ = SDL_CreateRenderer(
|
||||
main_window_, -1, SDL_RENDERER_PRESENTVSYNC | SDL_RENDERER_ACCELERATED);
|
||||
@@ -295,11 +299,11 @@ int Render::Run() {
|
||||
want_in.callback = SdlCaptureAudioIn;
|
||||
want_in.userdata = this;
|
||||
|
||||
input_dev_ = SDL_OpenAudioDevice(NULL, 1, &want_in, &have_in, 0);
|
||||
if (input_dev_ == 0) {
|
||||
SDL_Log("Failed to open input: %s", SDL_GetError());
|
||||
// return 1;
|
||||
}
|
||||
// input_dev_ = SDL_OpenAudioDevice(NULL, 1, &want_in, &have_in, 0);
|
||||
// if (input_dev_ == 0) {
|
||||
// SDL_Log("Failed to open input: %s", SDL_GetError());
|
||||
// // return 1;
|
||||
// }
|
||||
|
||||
SDL_zero(want_out);
|
||||
want_out.freq = 48000;
|
||||
@@ -316,7 +320,7 @@ int Render::Run() {
|
||||
// return 1;
|
||||
}
|
||||
|
||||
SDL_PauseAudioDevice(input_dev_, 0);
|
||||
// SDL_PauseAudioDevice(input_dev_, 0);
|
||||
SDL_PauseAudioDevice(output_dev_, 0);
|
||||
|
||||
// Setup Dear ImGui context
|
||||
@@ -339,6 +343,8 @@ int Render::Run() {
|
||||
config.GlyphMinAdvanceX =
|
||||
13.0f; // Use if you want to make the icon monospaced
|
||||
static const ImWchar icon_ranges[] = {ICON_MIN_FA, ICON_MAX_FA, 0};
|
||||
io.Fonts->AddFontFromMemoryTTF(fa_regular_400_ttf, sizeof(fa_regular_400_ttf),
|
||||
30.0f, &config, icon_ranges);
|
||||
io.Fonts->AddFontFromMemoryTTF(fa_solid_900_ttf, sizeof(fa_solid_900_ttf),
|
||||
30.0f, &config, icon_ranges);
|
||||
|
||||
@@ -432,20 +438,20 @@ int Render::Run() {
|
||||
ImGui_ImplSDL2_NewFrame();
|
||||
ImGui::NewFrame();
|
||||
|
||||
// ImGui::PushStyleColor(ImGuiCol_WindowBg,
|
||||
// ImVec4(1.0f, 1.0f, 1.0f, streaming_ ? 0 : 1.0f));
|
||||
ImGui::PushStyleColor(ImGuiCol_WindowBg, ImVec4(0, 0, 0, 0));
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_WindowBorderSize, 0);
|
||||
ImGui::SetNextWindowPos(ImVec2(0, 0), ImGuiCond_Always);
|
||||
ImGui::SetNextWindowSize(
|
||||
ImVec2(main_window_width_,
|
||||
streaming_ ? title_bar_height_ : main_window_height_default_),
|
||||
streaming_ ? title_bar_height_ + control_window_height_
|
||||
: main_window_height_default_),
|
||||
ImGuiCond_Always);
|
||||
ImGui::Begin("Render", nullptr,
|
||||
ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoTitleBar |
|
||||
ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoScrollbar |
|
||||
ImGuiWindowFlags_NoBringToFrontOnFocus);
|
||||
ImGui::PopStyleVar();
|
||||
// ImGui::PopStyleColor();
|
||||
ImGui::PopStyleColor();
|
||||
|
||||
TitleBar();
|
||||
|
||||
@@ -455,7 +461,7 @@ int Render::Run() {
|
||||
SDL_SetWindowResizable(main_window_, SDL_TRUE);
|
||||
}
|
||||
|
||||
// ControlWindow();
|
||||
ControlWindow();
|
||||
} else {
|
||||
if (resizable_) {
|
||||
resizable_ = !resizable_;
|
||||
@@ -489,23 +495,26 @@ int Render::Run() {
|
||||
} else if (event.window.event == SDL_WINDOWEVENT_SIZE_CHANGED) {
|
||||
SDL_GetWindowSize(main_window_, &main_window_width_,
|
||||
&main_window_height_);
|
||||
if (main_window_width_ * 9 < main_window_height_ * 16) {
|
||||
|
||||
int video_width = main_window_width_;
|
||||
int video_height = main_window_height_ - title_bar_height_;
|
||||
|
||||
if (video_width * 9 < video_height * 16) {
|
||||
stream_render_rect_.x = 0;
|
||||
stream_render_rect_.y =
|
||||
abs(main_window_height_ - main_window_width_ * 9 / 16) / 2;
|
||||
stream_render_rect_.w = main_window_width_;
|
||||
stream_render_rect_.h = main_window_width_ * 9 / 16;
|
||||
} else if (main_window_width_ * 9 > main_window_height_ * 16) {
|
||||
stream_render_rect_.x =
|
||||
abs(main_window_width_ - main_window_height_ * 16 / 9) / 2;
|
||||
stream_render_rect_.y = 0;
|
||||
stream_render_rect_.w = main_window_height_ * 16 / 9;
|
||||
stream_render_rect_.h = main_window_height_;
|
||||
abs(video_height - video_width * 9 / 16) / 2 + title_bar_height_;
|
||||
stream_render_rect_.w = video_width;
|
||||
stream_render_rect_.h = video_width * 9 / 16;
|
||||
} else if (video_width * 9 > video_height * 16) {
|
||||
stream_render_rect_.x = abs(video_width - video_height * 16 / 9) / 2;
|
||||
stream_render_rect_.y = title_bar_height_;
|
||||
stream_render_rect_.w = video_height * 16 / 9;
|
||||
stream_render_rect_.h = video_height;
|
||||
} else {
|
||||
stream_render_rect_.x = 0;
|
||||
stream_render_rect_.y = 0;
|
||||
stream_render_rect_.w = main_window_width_;
|
||||
stream_render_rect_.h = main_window_height_;
|
||||
stream_render_rect_.y = title_bar_height_;
|
||||
stream_render_rect_.w = video_width;
|
||||
stream_render_rect_.h = video_height;
|
||||
}
|
||||
} else if (event.type == SDL_WINDOWEVENT &&
|
||||
event.window.event == SDL_WINDOWEVENT_CLOSE) {
|
||||
@@ -566,7 +575,7 @@ int Render::Run() {
|
||||
}
|
||||
|
||||
SDL_CloseAudioDevice(output_dev_);
|
||||
SDL_CloseAudioDevice(input_dev_);
|
||||
// SDL_CloseAudioDevice(input_dev_);
|
||||
|
||||
ImGui_ImplSDLRenderer2_Shutdown();
|
||||
ImGui_ImplSDL2_Shutdown();
|
||||
|
||||
@@ -36,10 +36,9 @@ class Render {
|
||||
int MainWindow();
|
||||
int LocalWindow();
|
||||
int RemoteWindow();
|
||||
int SettingButton();
|
||||
int SettingWindow();
|
||||
int ControlWindow();
|
||||
int ControlBar();
|
||||
int MenuWindow();
|
||||
int AboutWindow();
|
||||
int StatusBar();
|
||||
int ConnectionStatusWindow();
|
||||
@@ -64,6 +63,9 @@ class Render {
|
||||
static void NetStatusReport(TraversalMode mode, const unsigned short send,
|
||||
const unsigned short receive, void *user_ptr);
|
||||
|
||||
static SDL_HitTestResult HitTestCallback(SDL_Window *window,
|
||||
const SDL_Point *area, void *data);
|
||||
|
||||
private:
|
||||
int ProcessMouseKeyEven(SDL_Event &ev);
|
||||
|
||||
@@ -142,7 +144,6 @@ class Render {
|
||||
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 control_window_min_width_ = 40;
|
||||
int control_window_height_ = 40;
|
||||
int local_window_width_ = 350;
|
||||
@@ -182,7 +183,7 @@ class Render {
|
||||
bool control_bar_button_pressed_ = false;
|
||||
bool fullscreen_button_pressed_ = false;
|
||||
bool mouse_control_button_pressed_ = false;
|
||||
bool settings_button_pressed_ = false;
|
||||
bool show_settings_window_ = false;
|
||||
bool received_frame_ = false;
|
||||
bool is_create_connection_ = false;
|
||||
bool audio_buffer_fresh_ = false;
|
||||
|
||||
@@ -4,22 +4,8 @@
|
||||
#include "rd_log.h"
|
||||
#include "render.h"
|
||||
|
||||
int Render::SettingButton() {
|
||||
ImGui::PushStyleColor(ImGuiCol_WindowBg, ImVec4(255, 255, 255, 1));
|
||||
ImGui::PushStyleColor(ImGuiCol_Button, ImVec4(0, 0, 0, 0));
|
||||
ImGui::PushStyleColor(ImGuiCol_ButtonHovered,
|
||||
ImVec4(104.0 / 255, 171.0 / 255, 251.0 / 255, 1.0f));
|
||||
ImGui::PushStyleColor(ImGuiCol_ButtonActive, ImVec4(0, 0, 0, 0));
|
||||
|
||||
std::string gear = ICON_FA_GEAR;
|
||||
if (ImGui::Button(gear.c_str(), ImVec2(40, 30))) {
|
||||
settings_button_pressed_ = !settings_button_pressed_;
|
||||
settings_window_pos_reset_ = true;
|
||||
}
|
||||
|
||||
ImGui::PopStyleColor(4);
|
||||
|
||||
if (settings_button_pressed_) {
|
||||
int Render::SettingWindow() {
|
||||
if (show_settings_window_) {
|
||||
if (settings_window_pos_reset_) {
|
||||
const ImGuiViewport *viewport = ImGui::GetMainViewport();
|
||||
if (ConfigCenter::LANGUAGE::CHINESE == localization_language_) {
|
||||
@@ -166,7 +152,7 @@ int Render::SettingButton() {
|
||||
// OK
|
||||
if (ImGui::Button(
|
||||
localization::ok[localization_language_index_].c_str())) {
|
||||
settings_button_pressed_ = false;
|
||||
show_settings_window_ = false;
|
||||
|
||||
// Language
|
||||
if (language_button_value_ == 0) {
|
||||
@@ -227,7 +213,7 @@ int Render::SettingButton() {
|
||||
// Cancel
|
||||
if (ImGui::Button(
|
||||
localization::cancel[localization_language_index_].c_str())) {
|
||||
settings_button_pressed_ = false;
|
||||
show_settings_window_ = false;
|
||||
if (language_button_value_ != language_button_value_last_) {
|
||||
language_button_value_ = language_button_value_last_;
|
||||
}
|
||||
@@ -2,7 +2,7 @@
|
||||
#include "render.h"
|
||||
|
||||
int Render::StatusBar() {
|
||||
ImGui::PushStyleColor(ImGuiCol_MenuBarBg, ImVec4(0, 0, 0, 1));
|
||||
ImGui::PushStyleColor(ImGuiCol_ChildBg, ImVec4(1.0f, 1.0f, 1.0f, 1.0f));
|
||||
static bool a, b, c, d, e;
|
||||
ImGui::SetNextWindowPos(
|
||||
ImVec2(0, main_window_height_default_ - status_bar_height_ - 1),
|
||||
|
||||
@@ -2,84 +2,77 @@
|
||||
#include "localization.h"
|
||||
#include "render.h"
|
||||
|
||||
#define BUTTON_PADDING 36.0f
|
||||
|
||||
int Render::TitleBar() {
|
||||
ImGui::PushStyleColor(ImGuiCol_MenuBarBg, ImVec4(0, 0, 0, 0.05f));
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_ChildBorderSize, 0);
|
||||
|
||||
ImGui::PushStyleColor(ImGuiCol_MenuBarBg, ImVec4(1, 1, 1, 1.0f));
|
||||
ImGui::SetNextWindowPos(ImVec2(0, 0), ImGuiCond_Always);
|
||||
ImGui::SetWindowFontScale(0.8f);
|
||||
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::SetCursorPosX(main_window_width_ - (streaming_
|
||||
? BUTTON_PADDING * 4 - 3
|
||||
: BUTTON_PADDING * 3 - 3));
|
||||
ImGui::PushStyleColor(ImGuiCol_HeaderHovered, ImVec4(0, 0, 0, 0.1f));
|
||||
ImGui::PushStyleColor(ImGuiCol_HeaderActive,
|
||||
ImVec4(1.0f, 1.0f, 1.0f, 1.0f));
|
||||
if (ImGui::BeginMenu(ICON_FA_BARS)) {
|
||||
ImGui::SetWindowFontScale(0.5f);
|
||||
if (ImGui::MenuItem(
|
||||
localization::settings[localization_language_index_].c_str())) {
|
||||
show_settings_window_ = true;
|
||||
}
|
||||
|
||||
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_;
|
||||
}
|
||||
if (ImGui::MenuItem(
|
||||
localization::about[localization_language_index_].c_str())) {
|
||||
show_about_window_ = true;
|
||||
}
|
||||
ImGui::SetWindowFontScale(1.0f);
|
||||
ImGui::EndMenu();
|
||||
}
|
||||
ImGui::PopStyleColor(2);
|
||||
|
||||
{
|
||||
SettingWindow();
|
||||
AboutWindow();
|
||||
}
|
||||
|
||||
ImGui::SetCursorPosX(main_window_width_ - (streaming_ ? 90 : 60));
|
||||
ImGui::PushStyleColor(ImGuiCol_Button, ImVec4(0, 0, 0, 0));
|
||||
ImGui::SetCursorPosX(main_window_width_ - (streaming_
|
||||
? BUTTON_PADDING * 3
|
||||
: BUTTON_PADDING * 2));
|
||||
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))) {
|
||||
if (ImGui::Button(window_minimize_button.c_str(),
|
||||
ImVec2(BUTTON_PADDING, 30))) {
|
||||
SDL_MinimizeWindow(main_window_);
|
||||
}
|
||||
ImGui::PopStyleColor(2);
|
||||
|
||||
if (streaming_) {
|
||||
ImGui::SetCursorPosX(main_window_width_ - 60);
|
||||
ImGui::SetCursorPosX(main_window_width_ - BUTTON_PADDING * 2);
|
||||
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))) {
|
||||
if (ImGui::Button(window_restore_button.c_str(),
|
||||
ImVec2(BUTTON_PADDING, 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_);
|
||||
std::string window_maximize_button = ICON_FA_SQUARE_FULL;
|
||||
if (ImGui::Button(window_maximize_button.c_str(),
|
||||
ImVec2(BUTTON_PADDING, 30))) {
|
||||
SDL_MaximizeWindow(main_window_);
|
||||
window_maximized_ = !window_maximized_;
|
||||
}
|
||||
@@ -87,11 +80,11 @@ int Render::TitleBar() {
|
||||
ImGui::PopStyleColor(2);
|
||||
}
|
||||
|
||||
ImGui::SetCursorPosX(main_window_width_ - 30);
|
||||
ImGui::SetCursorPosX(main_window_width_ - BUTTON_PADDING);
|
||||
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))) {
|
||||
if (ImGui::Button(close_button.c_str(), ImVec2(BUTTON_PADDING, 30))) {
|
||||
SDL_Event event;
|
||||
event.type = SDL_QUIT;
|
||||
SDL_PushEvent(&event);
|
||||
@@ -104,5 +97,6 @@ int Render::TitleBar() {
|
||||
|
||||
ImGui::EndChild();
|
||||
ImGui::PopStyleColor(2);
|
||||
ImGui::PopStyleVar();
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user