mirror of
https://github.com/kunkundi/crossdesk.git
synced 2025-10-26 12:15:34 +08:00
[feat] add close button in control bar
This commit is contained in:
@@ -44,27 +44,33 @@ int Render::ConnectionStatusWindow() {
|
||||
text = localization::p2p_disconnected[localization_language_index_];
|
||||
ImGui::SetCursorPosX(connection_status_window_width_ * 3 / 7);
|
||||
ImGui::SetCursorPosY(connection_status_window_height_ * 2 / 3);
|
||||
// Cancel
|
||||
// ok
|
||||
if (ImGui::Button(
|
||||
localization::cancel[localization_language_index_].c_str())) {
|
||||
localization::ok[localization_language_index_].c_str()) ||
|
||||
ImGui::IsKeyPressed(ImGuiKey_Enter) ||
|
||||
ImGui::IsKeyPressed(ImGuiKey_Escape)) {
|
||||
show_connection_status_window_ = false;
|
||||
}
|
||||
} else if (ConnectionStatus::Failed == connection_status_) {
|
||||
text = localization::p2p_failed[localization_language_index_];
|
||||
ImGui::SetCursorPosX(connection_status_window_width_ * 3 / 7);
|
||||
ImGui::SetCursorPosY(connection_status_window_height_ * 2 / 3);
|
||||
// Cancel
|
||||
// ok
|
||||
if (ImGui::Button(
|
||||
localization::cancel[localization_language_index_].c_str())) {
|
||||
localization::ok[localization_language_index_].c_str()) ||
|
||||
ImGui::IsKeyPressed(ImGuiKey_Enter) ||
|
||||
ImGui::IsKeyPressed(ImGuiKey_Escape)) {
|
||||
show_connection_status_window_ = false;
|
||||
}
|
||||
} else if (ConnectionStatus::Closed == connection_status_) {
|
||||
text = localization::p2p_closed[localization_language_index_];
|
||||
ImGui::SetCursorPosX(connection_status_window_width_ * 3 / 7);
|
||||
ImGui::SetCursorPosY(connection_status_window_height_ * 2 / 3);
|
||||
// Cancel
|
||||
// ok
|
||||
if (ImGui::Button(
|
||||
localization::ok[localization_language_index_].c_str())) {
|
||||
localization::ok[localization_language_index_].c_str()) ||
|
||||
ImGui::IsKeyPressed(ImGuiKey_Enter) ||
|
||||
ImGui::IsKeyPressed(ImGuiKey_Escape)) {
|
||||
show_connection_status_window_ = false;
|
||||
}
|
||||
} else if (ConnectionStatus::IncorrectPassword == connection_status_) {
|
||||
@@ -86,19 +92,18 @@ int Render::ConnectionStatusWindow() {
|
||||
ImGui::SetKeyboardFocusHere();
|
||||
focus_on_input_widget_ = false;
|
||||
}
|
||||
bool enter_pressed = ImGui::InputText(
|
||||
"##password", remote_password_, IM_ARRAYSIZE(remote_password_),
|
||||
ImGuiInputTextFlags_CharsNoBlank |
|
||||
ImGuiInputTextFlags_EnterReturnsTrue);
|
||||
ImGui::InputText("##password", remote_password_,
|
||||
IM_ARRAYSIZE(remote_password_),
|
||||
ImGuiInputTextFlags_CharsNoBlank);
|
||||
|
||||
ImGui::PopStyleVar();
|
||||
|
||||
ImGui::SetCursorPosX(window_width * 0.315f);
|
||||
ImGui::SetCursorPosY(window_height * 0.75f);
|
||||
// OK
|
||||
if (enter_pressed ||
|
||||
ImGui::Button(
|
||||
localization::ok[localization_language_index_].c_str())) {
|
||||
// ok
|
||||
if (ImGui::Button(
|
||||
localization::ok[localization_language_index_].c_str()) ||
|
||||
ImGui::IsKeyPressed(ImGuiKey_Enter)) {
|
||||
show_connection_status_window_ = true;
|
||||
password_validating_ = true;
|
||||
rejoin_ = true;
|
||||
@@ -106,27 +111,27 @@ int Render::ConnectionStatusWindow() {
|
||||
}
|
||||
|
||||
ImGui::SameLine();
|
||||
|
||||
// cancel
|
||||
if (ImGui::Button(
|
||||
localization::cancel[localization_language_index_].c_str())) {
|
||||
localization::cancel[localization_language_index_].c_str()) ||
|
||||
ImGui::IsKeyPressed(ImGuiKey_Escape)) {
|
||||
memset(remote_password_, 0, sizeof(remote_password_));
|
||||
show_connection_status_window_ = false;
|
||||
focus_on_input_widget_ = true;
|
||||
}
|
||||
} else {
|
||||
} else if (password_validating_) {
|
||||
text = localization::validate_password[localization_language_index_];
|
||||
ImGui::SetCursorPosX(connection_status_window_width_ * 3 / 7);
|
||||
ImGui::SetCursorPosY(connection_status_window_height_ * 2 / 3);
|
||||
}
|
||||
}
|
||||
|
||||
else if (ConnectionStatus::NoSuchTransmissionId == connection_status_) {
|
||||
} else if (ConnectionStatus::NoSuchTransmissionId == connection_status_) {
|
||||
text = localization::no_such_id[localization_language_index_];
|
||||
ImGui::SetCursorPosX(connection_status_window_width_ * 3 / 7);
|
||||
ImGui::SetCursorPosY(connection_status_window_height_ * 2 / 3);
|
||||
// Cancel
|
||||
// ok
|
||||
if (ImGui::Button(
|
||||
localization::cancel[localization_language_index_].c_str())) {
|
||||
localization::ok[localization_language_index_].c_str()) ||
|
||||
ImGui::IsKeyPressed(ImGuiKey_Escape)) {
|
||||
show_connection_status_window_ = false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@ int Render::ControlBar() {
|
||||
if (control_bar_expand_) {
|
||||
ImGui::SetCursorPosX(
|
||||
is_control_bar_in_left_ ? (control_window_width_ + 5.0f) : 53.0f);
|
||||
// Mouse control
|
||||
// mouse control button
|
||||
ImDrawList* draw_list = ImGui::GetWindowDrawList();
|
||||
|
||||
if (is_control_bar_in_left_) {
|
||||
@@ -50,7 +50,7 @@ int Render::ControlBar() {
|
||||
}
|
||||
|
||||
ImGui::SameLine();
|
||||
// Audio capture
|
||||
// audio capture button
|
||||
float disable_audio_x = ImGui::GetCursorScreenPos().x + 4;
|
||||
float disable_audio_y = ImGui::GetCursorScreenPos().y + 4.0f;
|
||||
// std::string audio = audio_capture_button_pressed_ ? ICON_FA_VOLUME_HIGH
|
||||
@@ -87,7 +87,7 @@ int Render::ControlBar() {
|
||||
}
|
||||
|
||||
ImGui::SameLine();
|
||||
// Fullscreen
|
||||
// fullscreen button
|
||||
std::string fullscreen =
|
||||
fullscreen_button_pressed_ ? ICON_FA_COMPRESS : ICON_FA_EXPAND;
|
||||
if (ImGui::Button(fullscreen.c_str(), ImVec2(25, 25))) {
|
||||
@@ -103,6 +103,15 @@ int Render::ControlBar() {
|
||||
}
|
||||
}
|
||||
|
||||
ImGui::SameLine();
|
||||
// close button
|
||||
std::string close_button = ICON_FA_XMARK;
|
||||
if (ImGui::Button(close_button.c_str(), ImVec2(25, 25))) {
|
||||
SDL_Event event;
|
||||
event.type = SDL_QUIT;
|
||||
SDL_PushEvent(&event);
|
||||
}
|
||||
|
||||
ImGui::SameLine();
|
||||
|
||||
if (!is_control_bar_in_left_) {
|
||||
|
||||
@@ -24,6 +24,9 @@
|
||||
SDL_HitTestResult Render::HitTestCallback(SDL_Window *window,
|
||||
const SDL_Point *area, void *data) {
|
||||
Render *render = (Render *)data;
|
||||
if (!render) {
|
||||
return SDL_HITTEST_NORMAL;
|
||||
}
|
||||
|
||||
int window_width, window_height;
|
||||
SDL_GetWindowSize(window, &window_width, &window_height);
|
||||
@@ -387,7 +390,8 @@ int Render::Run() {
|
||||
IMGUI_CHECKVERSION();
|
||||
ImGui::CreateContext();
|
||||
ImGuiIO &io = ImGui::GetIO();
|
||||
|
||||
// Master keyboard navigation enable flag. Enable full Tabbing + directional
|
||||
// arrows + space/enter to activate.
|
||||
io.ConfigFlags |=
|
||||
ImGuiConfigFlags_NavEnableKeyboard; // Enable Keyboard Controls
|
||||
io.ConfigFlags |=
|
||||
|
||||
@@ -146,8 +146,8 @@ class Render {
|
||||
int main_window_width_before_maximized_ = 960;
|
||||
int main_window_height_before_maximized_ = 570;
|
||||
int control_window_min_width_ = 20;
|
||||
int control_window_max_width_ = 150;
|
||||
int control_window_width_ = 150;
|
||||
int control_window_max_width_ = 170;
|
||||
int control_window_width_ = 170;
|
||||
int control_window_height_ = 40;
|
||||
int local_window_width_ = 350;
|
||||
int status_bar_height_ = 20;
|
||||
|
||||
Reference in New Issue
Block a user