mirror of
https://github.com/kunkundi/crossdesk.git
synced 2025-10-26 20:25:34 +08:00
Make control bar scrollable
This commit is contained in:
@@ -5,44 +5,59 @@
|
|||||||
#include "render.h"
|
#include "render.h"
|
||||||
|
|
||||||
int Render::ControlBar() {
|
int Render::ControlBar() {
|
||||||
ImGui::SetWindowFontScale(0.5f);
|
|
||||||
ImGui::PushStyleVar(ImGuiStyleVar_FrameRounding, 3.0f);
|
ImGui::PushStyleVar(ImGuiStyleVar_FrameRounding, 3.0f);
|
||||||
// Mouse control
|
|
||||||
std::string mouse = ICON_FA_COMPUTER_MOUSE;
|
if (control_bar_button_pressed_) {
|
||||||
if (ImGui::Button(mouse.c_str(), ImVec2(25, 25))) {
|
// Mouse control
|
||||||
if (mouse_control_button_label_ ==
|
std::string mouse = ICON_FA_COMPUTER_MOUSE;
|
||||||
localization::control_mouse[localization_language_index_] &&
|
if (ImGui::Button(mouse.c_str(), ImVec2(25, 25))) {
|
||||||
connection_established_) {
|
if (mouse_control_button_label_ ==
|
||||||
mouse_control_button_pressed_ = true;
|
localization::control_mouse[localization_language_index_] &&
|
||||||
control_mouse_ = true;
|
connection_established_) {
|
||||||
mouse_control_button_label_ =
|
mouse_control_button_pressed_ = true;
|
||||||
localization::release_mouse[localization_language_index_];
|
control_mouse_ = true;
|
||||||
} else {
|
mouse_control_button_label_ =
|
||||||
control_mouse_ = false;
|
localization::release_mouse[localization_language_index_];
|
||||||
mouse_control_button_label_ =
|
} else {
|
||||||
localization::control_mouse[localization_language_index_];
|
control_mouse_ = false;
|
||||||
|
mouse_control_button_label_ =
|
||||||
|
localization::control_mouse[localization_language_index_];
|
||||||
|
}
|
||||||
|
mouse_control_button_pressed_ = !mouse_control_button_pressed_;
|
||||||
}
|
}
|
||||||
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(25, 25))) {
|
||||||
|
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::SameLine();
|
||||||
|
ImGui::Dummy(ImVec2(main_window_width_ * 0.91f, 0));
|
||||||
|
ImGui::SameLine();
|
||||||
}
|
}
|
||||||
|
|
||||||
ImGui::SameLine();
|
std::string control_bar =
|
||||||
// Fullscreen
|
control_bar_button_pressed_ ? ICON_FA_ANGLE_LEFT : ICON_FA_ANGLE_RIGHT;
|
||||||
std::string fullscreen =
|
if (ImGui::Button(control_bar.c_str(), ImVec2(25, 25))) {
|
||||||
fullscreen_button_pressed_ ? ICON_FA_COMPRESS : ICON_FA_EXPAND;
|
control_bar_button_pressed_ = !control_bar_button_pressed_;
|
||||||
if (ImGui::Button(fullscreen.c_str(), ImVec2(25, 25))) {
|
control_bar_button_pressed_time_ = ImGui::GetTime();
|
||||||
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::PopStyleVar();
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -1,16 +1,31 @@
|
|||||||
#include "render.h"
|
#include "render.h"
|
||||||
|
|
||||||
int Render::ControlWindow() {
|
int Render::ControlWindow() {
|
||||||
ImGui::PushStyleColor(ImGuiCol_MenuBarBg, ImVec4(0, 0, 0, 0));
|
ImGui::PushStyleColor(ImGuiCol_WindowBg, ImVec4(0, 0, 0, 0));
|
||||||
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::SetWindowFontScale(0.5f);
|
||||||
|
|
||||||
|
auto time_duration = ImGui::GetTime() - control_bar_button_pressed_time_;
|
||||||
|
auto control_window_width =
|
||||||
|
!control_bar_button_pressed_
|
||||||
|
? time_duration < 0.25f
|
||||||
|
? main_window_width_ -
|
||||||
|
(main_window_width_ - control_window_min_width_) * 4 *
|
||||||
|
time_duration
|
||||||
|
: control_window_min_width_
|
||||||
|
: time_duration < 0.25f
|
||||||
|
? control_window_min_width_ +
|
||||||
|
(main_window_width_ - control_window_min_width_) * 4 *
|
||||||
|
time_duration
|
||||||
|
: main_window_width_;
|
||||||
ImGui::BeginChild("ControlWindow",
|
ImGui::BeginChild("ControlWindow",
|
||||||
ImVec2(main_window_width_, menu_window_height_),
|
ImVec2(control_window_width, control_window_height_),
|
||||||
ImGuiChildFlags_Border, ImGuiWindowFlags_NoScrollbar);
|
ImGuiChildFlags_Border, ImGuiWindowFlags_NoDecoration);
|
||||||
|
ImGui::SetWindowFontScale(1.0f);
|
||||||
|
|
||||||
ControlBar();
|
ControlBar();
|
||||||
|
|
||||||
ImGui::SetWindowFontScale(1.0f);
|
|
||||||
ImGui::PopStyleColor();
|
ImGui::PopStyleColor();
|
||||||
ImGui::EndChild();
|
ImGui::EndChild();
|
||||||
|
|
||||||
|
|||||||
@@ -26,11 +26,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(
|
ImGui::BeginChild("LocalDesktopWindow_1", ImVec2(330, 180),
|
||||||
"LocalDesktopWindow_1", ImVec2(330, 180), ImGuiChildFlags_Border,
|
ImGuiChildFlags_Border,
|
||||||
ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoCollapse |
|
ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoCollapse |
|
||||||
ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoTitleBar |
|
ImGuiWindowFlags_NoTitleBar |
|
||||||
ImGuiWindowFlags_NoBringToFrontOnFocus);
|
ImGuiWindowFlags_NoBringToFrontOnFocus);
|
||||||
{
|
{
|
||||||
ImGui::SetWindowFontScale(0.5f);
|
ImGui::SetWindowFontScale(0.5f);
|
||||||
ImGui::Text("%s",
|
ImGui::Text("%s",
|
||||||
|
|||||||
@@ -325,15 +325,18 @@ int Render::Run() {
|
|||||||
ImGui_ImplSDL2_NewFrame();
|
ImGui_ImplSDL2_NewFrame();
|
||||||
ImGui::NewFrame();
|
ImGui::NewFrame();
|
||||||
|
|
||||||
|
ImGui::PushStyleColor(ImGuiCol_WindowBg, ImVec4(0, 0, 0, 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_ ? menu_window_height_ : main_window_height_),
|
streaming_ ? control_window_height_ : main_window_height_),
|
||||||
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);
|
||||||
|
ImGui::PopStyleVar();
|
||||||
|
ImGui::PopStyleColor();
|
||||||
if (!streaming_) {
|
if (!streaming_) {
|
||||||
MainWindow();
|
MainWindow();
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -127,6 +127,8 @@ class Render {
|
|||||||
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 menu_window_height_ = 30;
|
int menu_window_height_ = 30;
|
||||||
|
int control_window_min_width_ = 40;
|
||||||
|
int control_window_height_ = 40;
|
||||||
int local_window_width_ = 350;
|
int local_window_width_ = 350;
|
||||||
int status_bar_height_ = 20;
|
int status_bar_height_ = 20;
|
||||||
int connection_status_window_width_ = 200;
|
int connection_status_window_width_ = 200;
|
||||||
@@ -156,6 +158,7 @@ class Render {
|
|||||||
bool connection_established_ = false;
|
bool connection_established_ = false;
|
||||||
bool subwindow_hovered_ = false;
|
bool subwindow_hovered_ = false;
|
||||||
bool connect_button_pressed_ = false;
|
bool connect_button_pressed_ = false;
|
||||||
|
bool control_bar_button_pressed_ = false;
|
||||||
bool fullscreen_button_pressed_ = false;
|
bool fullscreen_button_pressed_ = false;
|
||||||
bool mouse_control_button_pressed_ = false;
|
bool mouse_control_button_pressed_ = false;
|
||||||
bool settings_button_pressed_ = false;
|
bool settings_button_pressed_ = false;
|
||||||
@@ -172,6 +175,7 @@ class Render {
|
|||||||
|
|
||||||
double copy_start_time_ = 0;
|
double copy_start_time_ = 0;
|
||||||
double regenerate_password_start_time_ = 0;
|
double regenerate_password_start_time_ = 0;
|
||||||
|
double control_bar_button_pressed_time_ = 0;
|
||||||
|
|
||||||
int fps_ = 0;
|
int fps_ = 0;
|
||||||
uint32_t start_time_;
|
uint32_t start_time_;
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ int Render::SettingButton() {
|
|||||||
ImGui::PushStyleColor(ImGuiCol_ButtonActive, ImVec4(0, 0, 0, 0));
|
ImGui::PushStyleColor(ImGuiCol_ButtonActive, ImVec4(0, 0, 0, 0));
|
||||||
|
|
||||||
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, 30))) {
|
||||||
settings_button_pressed_ = !settings_button_pressed_;
|
settings_button_pressed_ = !settings_button_pressed_;
|
||||||
settings_window_pos_reset_ = true;
|
settings_window_pos_reset_ = true;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user