mirror of
https://github.com/kunkundi/crossdesk.git
synced 2025-10-27 04:35:34 +08:00
[feat] add remote display selection button in control bar
This commit is contained in:
@@ -32,7 +32,6 @@ int LossRateDisplay(float loss_rate) {
|
|||||||
int Render::ControlBar(std::shared_ptr<SubStreamWindowProperties>& props) {
|
int Render::ControlBar(std::shared_ptr<SubStreamWindowProperties>& props) {
|
||||||
ImGui::PushStyleVar(ImGuiStyleVar_FrameRounding, 3.0f);
|
ImGui::PushStyleVar(ImGuiStyleVar_FrameRounding, 3.0f);
|
||||||
|
|
||||||
ImVec2 mouse_button_pos = ImVec2(0, 0);
|
|
||||||
if (props->control_bar_expand_) {
|
if (props->control_bar_expand_) {
|
||||||
ImGui::SetCursorPosX(props->is_control_bar_in_left_
|
ImGui::SetCursorPosX(props->is_control_bar_in_left_
|
||||||
? (props->control_window_width_ + 5.0f)
|
? (props->control_window_width_ + 5.0f)
|
||||||
@@ -49,7 +48,41 @@ int Render::ControlBar(std::shared_ptr<SubStreamWindowProperties>& props) {
|
|||||||
IM_COL32(178, 178, 178, 255), 1.0f);
|
IM_COL32(178, 178, 178, 255), 1.0f);
|
||||||
}
|
}
|
||||||
|
|
||||||
mouse_button_pos = ImGui::GetCursorScreenPos();
|
std::string display = ICON_FA_DISPLAY;
|
||||||
|
if (ImGui::Button(display.c_str(), ImVec2(25, 25))) {
|
||||||
|
ImGui::OpenPopup("display");
|
||||||
|
}
|
||||||
|
|
||||||
|
ImVec2 btn_min = ImGui::GetItemRectMin();
|
||||||
|
ImVec2 btn_size_actual = ImGui::GetItemRectSize();
|
||||||
|
|
||||||
|
if (ImGui::BeginPopup("display")) {
|
||||||
|
std::vector<ScreenCapturer::DisplayInfo> display_list;
|
||||||
|
if (screen_capturer_) {
|
||||||
|
display_list = screen_capturer_->GetDisplayList();
|
||||||
|
}
|
||||||
|
ImGui::SetWindowFontScale(0.5f);
|
||||||
|
for (int i = 0; i < display_list.size(); i++) {
|
||||||
|
if (ImGui::Selectable(display_list[i].name.c_str())) {
|
||||||
|
selected_display_ = i + 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ImGui::SetWindowFontScale(1.0f);
|
||||||
|
ImGui::EndPopup();
|
||||||
|
}
|
||||||
|
|
||||||
|
ImGui::SetWindowFontScale(0.6f);
|
||||||
|
ImVec2 text_size =
|
||||||
|
ImGui::CalcTextSize(std::to_string(selected_display_).c_str());
|
||||||
|
ImVec2 text_pos =
|
||||||
|
ImVec2(btn_min.x + (btn_size_actual.x - text_size.x) * 0.5f,
|
||||||
|
btn_min.y + (btn_size_actual.y - text_size.y) * 0.5f - 2.0f);
|
||||||
|
ImGui::GetWindowDrawList()->AddText(
|
||||||
|
text_pos, IM_COL32(0, 0, 0, 255),
|
||||||
|
std::to_string(selected_display_).c_str());
|
||||||
|
ImGui::SetWindowFontScale(1.0f);
|
||||||
|
|
||||||
|
ImGui::SameLine();
|
||||||
float disable_mouse_x = ImGui::GetCursorScreenPos().x + 4.0f;
|
float disable_mouse_x = ImGui::GetCursorScreenPos().x + 4.0f;
|
||||||
float disable_mouse_y = ImGui::GetCursorScreenPos().y + 4.0f;
|
float disable_mouse_y = ImGui::GetCursorScreenPos().y + 4.0f;
|
||||||
std::string mouse = props->mouse_control_button_pressed_
|
std::string mouse = props->mouse_control_button_pressed_
|
||||||
@@ -80,28 +113,6 @@ int Render::ControlBar(std::shared_ptr<SubStreamWindowProperties>& props) {
|
|||||||
2.0f);
|
2.0f);
|
||||||
}
|
}
|
||||||
|
|
||||||
// const char* items[] = {"1", "2", "3"};
|
|
||||||
// static int item_selected_idx = 0;
|
|
||||||
// ImGui::Text("Display:");
|
|
||||||
// ImGui::SameLine();
|
|
||||||
// ImGui::SetNextItemWidth(25.0f);
|
|
||||||
// ImGuiComboFlags flags =
|
|
||||||
// ImGuiComboFlags_HeightSmall | ImGuiComboFlags_NoArrowButton;
|
|
||||||
// const char* combo_preview_value = items[item_selected_idx];
|
|
||||||
// ImGui::SetWindowFontScale(1.2f);
|
|
||||||
// if (ImGui::BeginCombo("##display", combo_preview_value, flags)) {
|
|
||||||
// ImGui::SetWindowFontScale(0.5f);
|
|
||||||
// for (int n = 0; n < IM_ARRAYSIZE(items); n++) {
|
|
||||||
// const bool is_selected = (item_selected_idx == n);
|
|
||||||
// if (ImGui::Selectable(items[n], is_selected)) item_selected_idx = n;
|
|
||||||
|
|
||||||
// if (is_selected) ImGui::SetItemDefaultFocus();
|
|
||||||
// }
|
|
||||||
// ImGui::SetWindowFontScale(1.0f);
|
|
||||||
// ImGui::EndCombo();
|
|
||||||
// }
|
|
||||||
// ImGui::SetWindowFontScale(1.0f);
|
|
||||||
|
|
||||||
ImGui::SameLine();
|
ImGui::SameLine();
|
||||||
// audio capture button
|
// audio capture button
|
||||||
float disable_audio_x = ImGui::GetCursorScreenPos().x + 4;
|
float disable_audio_x = ImGui::GetCursorScreenPos().x + 4;
|
||||||
|
|||||||
@@ -58,10 +58,10 @@ class Render {
|
|||||||
float sub_stream_window_width_ = 1280;
|
float sub_stream_window_width_ = 1280;
|
||||||
float sub_stream_window_height_ = 720;
|
float sub_stream_window_height_ = 720;
|
||||||
float control_window_min_width_ = 20;
|
float control_window_min_width_ = 20;
|
||||||
float control_window_max_width_ = 200;
|
float control_window_max_width_ = 230;
|
||||||
float control_window_min_height_ = 40;
|
float control_window_min_height_ = 40;
|
||||||
float control_window_max_height_ = 150;
|
float control_window_max_height_ = 150;
|
||||||
float control_window_width_ = 200;
|
float control_window_width_ = 230;
|
||||||
float control_window_height_ = 40;
|
float control_window_height_ = 40;
|
||||||
float control_bar_pos_x_ = 0;
|
float control_bar_pos_x_ = 0;
|
||||||
float control_bar_pos_y_ = 30;
|
float control_bar_pos_y_ = 30;
|
||||||
@@ -396,6 +396,7 @@ class Render {
|
|||||||
bool enable_hardware_video_codec_last_ = false;
|
bool enable_hardware_video_codec_last_ = false;
|
||||||
bool enable_turn_last_ = false;
|
bool enable_turn_last_ = false;
|
||||||
bool settings_window_pos_reset_ = true;
|
bool settings_window_pos_reset_ = true;
|
||||||
|
int selected_display_ = 1;
|
||||||
/* ------ main window property end ------ */
|
/* ------ main window property end ------ */
|
||||||
|
|
||||||
/* ------ sub stream window property start ------ */
|
/* ------ sub stream window property start ------ */
|
||||||
|
|||||||
Reference in New Issue
Block a user