mirror of
				https://github.com/kunkundi/crossdesk.git
				synced 2025-10-26 20:25:34 +08:00 
			
		
		
		
	[feat] make control bar can only move along left border of the main window
This commit is contained in:
		| @@ -5,9 +5,12 @@ | ||||
| #include "render.h" | ||||
|  | ||||
| int Render::ControlBar() { | ||||
|   ImVec2 bar_pos = ImGui::GetWindowPos(); | ||||
|  | ||||
|   ImGui::PushStyleVar(ImGuiStyleVar_FrameRounding, 3.0f); | ||||
|  | ||||
|   if (control_bar_button_pressed_) { | ||||
|     ImGui::SetCursorPosX(control_winodw_pos_.x + 22); | ||||
|     // Mouse control | ||||
|     std::string mouse = ICON_FA_COMPUTER_MOUSE; | ||||
|     if (ImGui::Button(mouse.c_str(), ImVec2(25, 25))) { | ||||
| @@ -40,12 +43,17 @@ int Render::ControlBar() { | ||||
|     } | ||||
|  | ||||
|     ImGui::SameLine(); | ||||
|     ImGui::SetCursorPosX(control_window_max_width_ - 35); | ||||
|     ImGui::SetCursorPosX(control_winodw_pos_.x + control_window_max_width_ - | ||||
|                          35); | ||||
|   } | ||||
|  | ||||
|   ImGui::SetCursorPosX(control_winodw_pos_.x + | ||||
|                        (control_bar_button_pressed_ | ||||
|                             ? (control_window_max_width_ - 18) | ||||
|                             : (control_window_min_width_))); | ||||
|   std::string control_bar = | ||||
|       control_bar_button_pressed_ ? ICON_FA_ANGLE_LEFT : ICON_FA_ANGLE_RIGHT; | ||||
|   if (ImGui::Button(control_bar.c_str(), ImVec2(25, 25))) { | ||||
|   if (ImGui::Button(control_bar.c_str(), ImVec2(15, 25))) { | ||||
|     control_bar_button_pressed_ = !control_bar_button_pressed_; | ||||
|     control_bar_button_pressed_time_ = ImGui::GetTime(); | ||||
|   } | ||||
|   | ||||
| @@ -15,9 +15,13 @@ int Render::ControlWindow() { | ||||
|                     time_duration | ||||
|           : control_window_max_width_; | ||||
|  | ||||
|   ImGui::PushStyleColor(ImGuiCol_WindowBg, ImVec4(0, 0, 0, 0)); | ||||
|   ImGui::PushStyleColor(ImGuiCol_WindowBg, ImVec4(1, 1, 1, 1)); | ||||
|   ImGui::PushStyleVar(ImGuiStyleVar_ChildRounding, 10.0f); | ||||
|   ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2(0, 0)); | ||||
|   ImGui::SetNextWindowPos(ImVec2(0, title_bar_height_), ImGuiCond_Once); | ||||
|   ImGui::SetNextWindowPos( | ||||
|       ImVec2(-control_window_min_width_ / 2, title_bar_height_), | ||||
|       ImGuiCond_Once); | ||||
|  | ||||
|   ImGui::SetNextWindowSize(ImVec2(control_window_width, control_window_height_), | ||||
|                            ImGuiCond_Always); | ||||
|   ImGui::Begin("ControlWindow", nullptr, | ||||
| @@ -26,6 +30,13 @@ int Render::ControlWindow() { | ||||
|                    ImGuiWindowFlags_NoBringToFrontOnFocus); | ||||
|   ImGui::PopStyleVar(); | ||||
|  | ||||
|   control_winodw_pos_ = ImGui::GetWindowPos(); | ||||
|   if (control_winodw_pos_.x != -control_window_min_width_ / 2) { | ||||
|     ImGui::SetWindowPos( | ||||
|         ImVec2(-control_window_min_width_ / 2, control_winodw_pos_.y), | ||||
|         ImGuiCond_Always); | ||||
|   } | ||||
|  | ||||
|   ImGui::PushStyleColor(ImGuiCol_ChildBg, ImVec4(1.0f, 1.0f, 1.0f, 1.0f)); | ||||
|   static bool a, b, c, d, e; | ||||
|   ImGui::SetNextWindowPos(ImVec2(0, title_bar_height_), ImGuiCond_Once); | ||||
| @@ -40,8 +51,8 @@ int Render::ControlWindow() { | ||||
|   ControlBar(); | ||||
|  | ||||
|   ImGui::EndChild(); | ||||
|  | ||||
|   ImGui::End(); | ||||
|   ImGui::PopStyleVar(); | ||||
|   ImGui::PopStyleColor(); | ||||
|  | ||||
|   return 0; | ||||
|   | ||||
| @@ -123,7 +123,6 @@ class Render { | ||||
|   std::string local_id_ = ""; | ||||
|   char remote_id_[20] = ""; | ||||
|   char client_password_[20] = ""; | ||||
|   bool is_client_mode_ = false; | ||||
|  | ||||
|  private: | ||||
|   int title_bar_width_ = 960; | ||||
| @@ -192,15 +191,18 @@ class Render { | ||||
|   bool show_password_ = true; | ||||
|   bool password_inited_ = false; | ||||
|   bool regenerate_password_ = false; | ||||
|   bool streaming_ = false; | ||||
|   bool show_about_window_ = false; | ||||
|   bool show_connection_status_window_ = false; | ||||
|   bool window_maximized_ = false; | ||||
|   bool streaming_ = true; | ||||
|   bool is_client_mode_ = true; | ||||
|  | ||||
|   double copy_start_time_ = 0; | ||||
|   double regenerate_password_start_time_ = 0; | ||||
|   double control_bar_button_pressed_time_ = 0; | ||||
|  | ||||
|   ImVec2 control_winodw_pos_; | ||||
|  | ||||
|   int fps_ = 0; | ||||
|   uint32_t start_time_; | ||||
|   uint32_t end_time_; | ||||
|   | ||||
		Reference in New Issue
	
	Block a user