mirror of
https://github.com/kunkundi/crossdesk.git
synced 2025-12-16 12:06:50 +08:00
[fix] fix control bar dpi scaling
This commit is contained in:
@@ -71,10 +71,10 @@ class Render {
|
|||||||
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_ = 230;
|
float control_window_max_width_ = 230;
|
||||||
float control_window_min_height_ = 35;
|
float control_window_min_height_ = 38;
|
||||||
float control_window_max_height_ = 180;
|
float control_window_max_height_ = 180;
|
||||||
float control_window_width_ = 230;
|
float control_window_width_ = 230;
|
||||||
float control_window_height_ = 35;
|
float control_window_height_ = 38;
|
||||||
float control_bar_pos_x_ = 0;
|
float control_bar_pos_x_ = 0;
|
||||||
float control_bar_pos_y_ = 30;
|
float control_bar_pos_y_ = 30;
|
||||||
float mouse_diff_control_bar_pos_x_ = 0;
|
float mouse_diff_control_bar_pos_x_ = 0;
|
||||||
|
|||||||
@@ -35,8 +35,9 @@ int Render::ControlBar(std::shared_ptr<SubStreamWindowProperties>& props) {
|
|||||||
ImGui::PushStyleVar(ImGuiStyleVar_FrameRounding, 3.0f * dpi_scale_);
|
ImGui::PushStyleVar(ImGuiStyleVar_FrameRounding, 3.0f * dpi_scale_);
|
||||||
|
|
||||||
if (props->control_bar_expand_) {
|
if (props->control_bar_expand_) {
|
||||||
float button_width = 25.0f * dpi_scale_;
|
float button_width = 24.0f * dpi_scale_;
|
||||||
float button_height = 25.0f * dpi_scale_;
|
float button_height = 24.0f * dpi_scale_;
|
||||||
|
float line_padding = 4.0f * dpi_scale_;
|
||||||
|
|
||||||
ImGui::SetCursorPosX(
|
ImGui::SetCursorPosX(
|
||||||
props->is_control_bar_in_left_
|
props->is_control_bar_in_left_
|
||||||
@@ -56,17 +57,16 @@ int Render::ControlBar(std::shared_ptr<SubStreamWindowProperties>& props) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
std::string display = ICON_FA_DISPLAY;
|
std::string display = ICON_FA_DISPLAY;
|
||||||
ImGui::SetWindowFontScale(0.9f);
|
ImGui::SetWindowFontScale(0.5f);
|
||||||
if (ImGui::Button(display.c_str(), ImVec2(button_width, button_height))) {
|
if (ImGui::Button(display.c_str(), ImVec2(button_width, button_height))) {
|
||||||
ImGui::OpenPopup("display");
|
ImGui::OpenPopup("display");
|
||||||
}
|
}
|
||||||
ImGui::SetWindowFontScale(1.0f);
|
|
||||||
|
|
||||||
ImVec2 btn_min = ImGui::GetItemRectMin();
|
ImVec2 btn_min = ImGui::GetItemRectMin();
|
||||||
ImVec2 btn_size_actual = ImGui::GetItemRectSize();
|
ImVec2 btn_size_actual = ImGui::GetItemRectSize();
|
||||||
|
|
||||||
if (ImGui::BeginPopup("display")) {
|
if (ImGui::BeginPopup("display")) {
|
||||||
ImGui::SetWindowFontScale(0.8f);
|
ImGui::SetWindowFontScale(0.5f);
|
||||||
for (int i = 0; i < props->display_info_list_.size(); i++) {
|
for (int i = 0; i < props->display_info_list_.size(); i++) {
|
||||||
if (ImGui::Selectable(props->display_info_list_[i].name.c_str())) {
|
if (ImGui::Selectable(props->display_info_list_[i].name.c_str())) {
|
||||||
props->selected_display_ = i;
|
props->selected_display_ = i;
|
||||||
@@ -85,7 +85,7 @@ int Render::ControlBar(std::shared_ptr<SubStreamWindowProperties>& props) {
|
|||||||
ImGui::EndPopup();
|
ImGui::EndPopup();
|
||||||
}
|
}
|
||||||
|
|
||||||
ImGui::SetWindowFontScale(0.6f);
|
ImGui::SetWindowFontScale(0.5f);
|
||||||
ImVec2 text_size = ImGui::CalcTextSize(
|
ImVec2 text_size = ImGui::CalcTextSize(
|
||||||
std::to_string(props->selected_display_ + 1).c_str());
|
std::to_string(props->selected_display_ + 1).c_str());
|
||||||
ImVec2 text_pos =
|
ImVec2 text_pos =
|
||||||
@@ -94,15 +94,15 @@ int Render::ControlBar(std::shared_ptr<SubStreamWindowProperties>& props) {
|
|||||||
ImGui::GetWindowDrawList()->AddText(
|
ImGui::GetWindowDrawList()->AddText(
|
||||||
text_pos, IM_COL32(0, 0, 0, 255),
|
text_pos, IM_COL32(0, 0, 0, 255),
|
||||||
std::to_string(props->selected_display_ + 1).c_str());
|
std::to_string(props->selected_display_ + 1).c_str());
|
||||||
ImGui::SetWindowFontScale(1.0f);
|
|
||||||
|
|
||||||
ImGui::SameLine();
|
ImGui::SameLine();
|
||||||
float disable_mouse_x = ImGui::GetCursorScreenPos().x + 4.0f;
|
float mouse_x = ImGui::GetCursorScreenPos().x;
|
||||||
float disable_mouse_y = ImGui::GetCursorScreenPos().y + 4.0f;
|
float mouse_y = ImGui::GetCursorScreenPos().y;
|
||||||
|
float disable_mouse_x = mouse_x + line_padding;
|
||||||
|
float disable_mouse_y = mouse_y + line_padding;
|
||||||
std::string mouse = props->mouse_control_button_pressed_
|
std::string mouse = props->mouse_control_button_pressed_
|
||||||
? ICON_FA_COMPUTER_MOUSE
|
? ICON_FA_COMPUTER_MOUSE
|
||||||
: ICON_FA_COMPUTER_MOUSE;
|
: ICON_FA_COMPUTER_MOUSE;
|
||||||
ImGui::SetWindowFontScale(0.9f);
|
|
||||||
if (ImGui::Button(mouse.c_str(), ImVec2(button_width, button_height))) {
|
if (ImGui::Button(mouse.c_str(), ImVec2(button_width, button_height))) {
|
||||||
if (props->connection_established_) {
|
if (props->connection_established_) {
|
||||||
start_keyboard_capturer_ = !start_keyboard_capturer_;
|
start_keyboard_capturer_ = !start_keyboard_capturer_;
|
||||||
@@ -115,33 +115,34 @@ int Render::ControlBar(std::shared_ptr<SubStreamWindowProperties>& props) {
|
|||||||
: localization::control_mouse[localization_language_index_];
|
: localization::control_mouse[localization_language_index_];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ImGui::SetWindowFontScale(1.0f);
|
|
||||||
if (!props->mouse_control_button_pressed_) {
|
if (!props->mouse_control_button_pressed_) {
|
||||||
|
float line_thickness = 2.0f * dpi_scale_;
|
||||||
draw_list->AddLine(ImVec2(disable_mouse_x, disable_mouse_y),
|
draw_list->AddLine(ImVec2(disable_mouse_x, disable_mouse_y),
|
||||||
ImVec2(disable_mouse_x + button_width * 0.75f,
|
ImVec2(mouse_x + button_width - line_padding,
|
||||||
disable_mouse_y + button_height * 0.75f),
|
mouse_y + button_height - line_padding),
|
||||||
IM_COL32(0, 0, 0, 255), 2.0f * dpi_scale_);
|
IM_COL32(0, 0, 0, 255), line_thickness);
|
||||||
draw_list->AddLine(
|
draw_list->AddLine(
|
||||||
ImVec2(disable_mouse_x - 1.2f * dpi_scale_,
|
ImVec2(disable_mouse_x - line_thickness * 0.7f,
|
||||||
disable_mouse_y + 1.2f * dpi_scale_),
|
disable_mouse_y + line_thickness * 0.7f),
|
||||||
ImVec2(disable_mouse_x + button_width * 0.75f - 1.2f * dpi_scale_,
|
ImVec2(
|
||||||
disable_mouse_y + button_height * 0.75f + 1.2f * dpi_scale_),
|
mouse_x + button_width - line_padding - line_thickness * 0.7f,
|
||||||
|
mouse_y + button_height - line_padding + line_thickness * 0.7f),
|
||||||
ImGui::IsItemHovered() ? IM_COL32(66, 150, 250, 255)
|
ImGui::IsItemHovered() ? IM_COL32(66, 150, 250, 255)
|
||||||
: IM_COL32(179, 213, 253, 255),
|
: IM_COL32(179, 213, 253, 255),
|
||||||
2.0f * dpi_scale_);
|
line_thickness);
|
||||||
}
|
}
|
||||||
|
|
||||||
ImGui::SameLine();
|
ImGui::SameLine();
|
||||||
// audio capture button
|
// audio capture button
|
||||||
float disable_audio_x = ImGui::GetCursorScreenPos().x + 4;
|
float audio_x = ImGui::GetCursorScreenPos().x;
|
||||||
float disable_audio_y = ImGui::GetCursorScreenPos().y + 4.0f;
|
float audio_y = ImGui::GetCursorScreenPos().y;
|
||||||
// std::string audio = audio_capture_button_pressed_ ? ICON_FA_VOLUME_HIGH
|
float disable_audio_x = audio_x + line_padding;
|
||||||
// :
|
float disable_audio_y = audio_y + line_padding;
|
||||||
// ICON_FA_VOLUME_XMARK;
|
|
||||||
std::string audio = props->audio_capture_button_pressed_
|
std::string audio = props->audio_capture_button_pressed_
|
||||||
? ICON_FA_VOLUME_HIGH
|
? ICON_FA_VOLUME_HIGH
|
||||||
: ICON_FA_VOLUME_HIGH;
|
: ICON_FA_VOLUME_HIGH;
|
||||||
ImGui::SetWindowFontScale(0.9f);
|
|
||||||
if (ImGui::Button(audio.c_str(), ImVec2(button_width, button_height))) {
|
if (ImGui::Button(audio.c_str(), ImVec2(button_width, button_height))) {
|
||||||
if (props->connection_established_) {
|
if (props->connection_established_) {
|
||||||
props->audio_capture_button_pressed_ =
|
props->audio_capture_button_pressed_ =
|
||||||
@@ -159,20 +160,22 @@ int Render::ControlBar(std::shared_ptr<SubStreamWindowProperties>& props) {
|
|||||||
props->data_label_.c_str());
|
props->data_label_.c_str());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ImGui::SetWindowFontScale(1.0f);
|
|
||||||
if (!props->audio_capture_button_pressed_) {
|
if (!props->audio_capture_button_pressed_) {
|
||||||
|
float line_thickness = 2.0f * dpi_scale_;
|
||||||
draw_list->AddLine(ImVec2(disable_audio_x, disable_audio_y),
|
draw_list->AddLine(ImVec2(disable_audio_x, disable_audio_y),
|
||||||
ImVec2(disable_audio_x + button_width * 0.75f,
|
ImVec2(audio_x + button_width - line_padding,
|
||||||
disable_audio_y + button_height * 0.75f),
|
audio_y + button_height - line_padding),
|
||||||
IM_COL32(0, 0, 0, 255), 2.0f * dpi_scale_);
|
IM_COL32(0, 0, 0, 255), line_thickness);
|
||||||
draw_list->AddLine(
|
draw_list->AddLine(
|
||||||
ImVec2(disable_audio_x - 1.2f * dpi_scale_,
|
ImVec2(disable_audio_x - line_thickness * 0.7f,
|
||||||
disable_audio_y + 1.2f * dpi_scale_),
|
disable_audio_y + line_thickness * 0.7f),
|
||||||
ImVec2(disable_audio_x + button_width * 0.75f - 1.2f * dpi_scale_,
|
ImVec2(
|
||||||
disable_audio_y + button_height * 0.75f + 1.2f * dpi_scale_),
|
audio_x + button_width - line_padding - line_thickness * 0.7f,
|
||||||
|
audio_y + button_height - line_padding + line_thickness * 0.7f),
|
||||||
ImGui::IsItemHovered() ? IM_COL32(66, 150, 250, 255)
|
ImGui::IsItemHovered() ? IM_COL32(66, 150, 250, 255)
|
||||||
: IM_COL32(179, 213, 253, 255),
|
: IM_COL32(179, 213, 253, 255),
|
||||||
2.0f * dpi_scale_);
|
line_thickness);
|
||||||
}
|
}
|
||||||
|
|
||||||
ImGui::SameLine();
|
ImGui::SameLine();
|
||||||
@@ -184,7 +187,6 @@ int Render::ControlBar(std::shared_ptr<SubStreamWindowProperties>& props) {
|
|||||||
button_color_style_pushed = true;
|
button_color_style_pushed = true;
|
||||||
}
|
}
|
||||||
std::string net_traffic_stats = ICON_FA_SIGNAL;
|
std::string net_traffic_stats = ICON_FA_SIGNAL;
|
||||||
ImGui::SetWindowFontScale(0.9f);
|
|
||||||
if (ImGui::Button(net_traffic_stats.c_str(),
|
if (ImGui::Button(net_traffic_stats.c_str(),
|
||||||
ImVec2(button_width, button_height))) {
|
ImVec2(button_width, button_height))) {
|
||||||
props->net_traffic_stats_button_pressed_ =
|
props->net_traffic_stats_button_pressed_ =
|
||||||
@@ -198,7 +200,7 @@ int Render::ControlBar(std::shared_ptr<SubStreamWindowProperties>& props) {
|
|||||||
: localization::show_net_traffic_stats
|
: localization::show_net_traffic_stats
|
||||||
[localization_language_index_];
|
[localization_language_index_];
|
||||||
}
|
}
|
||||||
ImGui::SetWindowFontScale(1.0f);
|
|
||||||
if (button_color_style_pushed) {
|
if (button_color_style_pushed) {
|
||||||
ImGui::PopStyleColor();
|
ImGui::PopStyleColor();
|
||||||
button_color_style_pushed = false;
|
button_color_style_pushed = false;
|
||||||
@@ -208,7 +210,6 @@ int Render::ControlBar(std::shared_ptr<SubStreamWindowProperties>& props) {
|
|||||||
// fullscreen button
|
// fullscreen button
|
||||||
std::string fullscreen =
|
std::string fullscreen =
|
||||||
fullscreen_button_pressed_ ? ICON_FA_COMPRESS : ICON_FA_EXPAND;
|
fullscreen_button_pressed_ ? ICON_FA_COMPRESS : ICON_FA_EXPAND;
|
||||||
ImGui::SetWindowFontScale(0.9f);
|
|
||||||
if (ImGui::Button(fullscreen.c_str(),
|
if (ImGui::Button(fullscreen.c_str(),
|
||||||
ImVec2(button_width, button_height))) {
|
ImVec2(button_width, button_height))) {
|
||||||
fullscreen_button_pressed_ = !fullscreen_button_pressed_;
|
fullscreen_button_pressed_ = !fullscreen_button_pressed_;
|
||||||
@@ -224,17 +225,14 @@ int Render::ControlBar(std::shared_ptr<SubStreamWindowProperties>& props) {
|
|||||||
}
|
}
|
||||||
props->reset_control_bar_pos_ = true;
|
props->reset_control_bar_pos_ = true;
|
||||||
}
|
}
|
||||||
ImGui::SetWindowFontScale(1.0f);
|
|
||||||
|
|
||||||
ImGui::SameLine();
|
ImGui::SameLine();
|
||||||
// close button
|
// close button
|
||||||
std::string close_button = ICON_FA_XMARK;
|
std::string close_button = ICON_FA_XMARK;
|
||||||
ImGui::SetWindowFontScale(0.9f);
|
|
||||||
if (ImGui::Button(close_button.c_str(),
|
if (ImGui::Button(close_button.c_str(),
|
||||||
ImVec2(button_width, button_height))) {
|
ImVec2(button_width, button_height))) {
|
||||||
CleanupPeer(props);
|
CleanupPeer(props);
|
||||||
}
|
}
|
||||||
ImGui::SetWindowFontScale(1.0f);
|
|
||||||
|
|
||||||
ImGui::SameLine();
|
ImGui::SameLine();
|
||||||
|
|
||||||
@@ -259,7 +257,6 @@ int Render::ControlBar(std::shared_ptr<SubStreamWindowProperties>& props) {
|
|||||||
: ICON_FA_ANGLE_RIGHT)
|
: ICON_FA_ANGLE_RIGHT)
|
||||||
: (props->is_control_bar_in_left_ ? ICON_FA_ANGLE_RIGHT
|
: (props->is_control_bar_in_left_ ? ICON_FA_ANGLE_RIGHT
|
||||||
: ICON_FA_ANGLE_LEFT);
|
: ICON_FA_ANGLE_LEFT);
|
||||||
ImGui::SetWindowFontScale(0.9f);
|
|
||||||
if (ImGui::Button(control_bar.c_str(),
|
if (ImGui::Button(control_bar.c_str(),
|
||||||
ImVec2(15.0f * dpi_scale_, 25.0f * dpi_scale_))) {
|
ImVec2(15.0f * dpi_scale_, 25.0f * dpi_scale_))) {
|
||||||
props->control_bar_expand_ = !props->control_bar_expand_;
|
props->control_bar_expand_ = !props->control_bar_expand_;
|
||||||
@@ -271,7 +268,6 @@ int Render::ControlBar(std::shared_ptr<SubStreamWindowProperties>& props) {
|
|||||||
props->net_traffic_stats_button_pressed_ = false;
|
props->net_traffic_stats_button_pressed_ = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ImGui::SetWindowFontScale(1.0f);
|
|
||||||
|
|
||||||
if (props->net_traffic_stats_button_pressed_ && props->control_bar_expand_) {
|
if (props->net_traffic_stats_button_pressed_ && props->control_bar_expand_) {
|
||||||
NetTrafficStats(props);
|
NetTrafficStats(props);
|
||||||
|
|||||||
@@ -154,6 +154,8 @@ int Render::StreamWindow() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
// lock.lock();
|
// lock.lock();
|
||||||
|
ImGui::End();
|
||||||
|
ImGui::EndTabItem();
|
||||||
it = client_properties_.begin();
|
it = client_properties_.begin();
|
||||||
continue;
|
continue;
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Reference in New Issue
Block a user