mirror of
https://github.com/kunkundi/crossdesk.git
synced 2025-12-16 12:06:50 +08:00
[fix] correct title bar display
This commit is contained in:
@@ -189,12 +189,12 @@ int Render::ConnectTo(const std::string& remote_id, const char* password,
|
||||
props->params_.user_id = props->local_id_.c_str();
|
||||
props->peer_ = CreatePeer(&props->params_);
|
||||
|
||||
props->control_window_width_ = title_bar_button_height_ * 7.5f;
|
||||
props->control_window_height_ = title_bar_button_height_ * 1.16f;
|
||||
props->control_window_min_width_ = title_bar_button_height_ * 0.65f;
|
||||
props->control_window_min_height_ = title_bar_button_height_ * 1.16f;
|
||||
props->control_window_max_width_ = title_bar_button_height_ * 7.5f;
|
||||
props->control_window_max_height_ = title_bar_button_height_ * 6.0f;
|
||||
props->control_window_width_ = title_bar_height_ * 7.5f;
|
||||
props->control_window_height_ = title_bar_height_ * 1.16f;
|
||||
props->control_window_min_width_ = title_bar_height_ * 0.65f;
|
||||
props->control_window_min_height_ = title_bar_height_ * 1.16f;
|
||||
props->control_window_max_width_ = title_bar_height_ * 7.5f;
|
||||
props->control_window_max_height_ = title_bar_height_ * 6.0f;
|
||||
|
||||
if (!props->peer_) {
|
||||
LOG_INFO("Create peer [{}] instance failed", props->local_id_);
|
||||
|
||||
@@ -605,53 +605,6 @@ void Render::UpdateInteractions() {
|
||||
}
|
||||
}
|
||||
|
||||
int Render::UpdateWindowSizeWithDpiScale(float dpi_scale) {
|
||||
main_window_width_ = (int)(main_window_width_default_ * dpi_scale);
|
||||
main_window_height_ = (int)(main_window_height_default_ * dpi_scale);
|
||||
stream_window_width_ = (int)(stream_window_width_default_ * dpi_scale);
|
||||
stream_window_height_ = (int)(stream_window_height_default_ * dpi_scale);
|
||||
|
||||
local_window_width_ = (int)(local_window_width_ * dpi_scale);
|
||||
local_window_height_ = (int)(local_window_height_ * dpi_scale);
|
||||
remote_window_width_ = (int)(remote_window_width_ * dpi_scale);
|
||||
remote_window_height_ = (int)(remote_window_height_ * dpi_scale);
|
||||
local_child_window_width_ = (int)(local_child_window_width_ * dpi_scale);
|
||||
local_child_window_height_ = (int)(local_child_window_height_ * dpi_scale);
|
||||
remote_child_window_width_ = (int)(remote_child_window_width_ * dpi_scale);
|
||||
remote_child_window_height_ = (int)(remote_child_window_height_ * dpi_scale);
|
||||
main_window_text_y_padding_ = (int)(main_window_text_y_padding_ * dpi_scale);
|
||||
main_child_window_x_padding_ =
|
||||
(int)(main_child_window_x_padding_ * dpi_scale);
|
||||
main_child_window_y_padding_ =
|
||||
(int)(main_child_window_y_padding_ * dpi_scale);
|
||||
title_bar_width_ = (int)(title_bar_width_ * dpi_scale);
|
||||
title_bar_height_ = (int)(title_bar_height_ * dpi_scale);
|
||||
status_bar_height_ = (int)(status_bar_height_ * dpi_scale);
|
||||
connection_status_window_width_ =
|
||||
(int)(connection_status_window_width_ * dpi_scale);
|
||||
connection_status_window_height_ =
|
||||
(int)(connection_status_window_height_ * dpi_scale);
|
||||
notification_window_width_ = (int)(notification_window_width_ * dpi_scale);
|
||||
notification_window_height_ = (int)(notification_window_height_ * dpi_scale);
|
||||
about_window_width_ = (int)(about_window_width_ * dpi_scale);
|
||||
about_window_height_ = (int)(about_window_height_ * dpi_scale);
|
||||
update_notification_window_width_ =
|
||||
(int)(update_notification_window_width_ * dpi_scale);
|
||||
update_notification_window_height_ =
|
||||
(int)(update_notification_window_height_ * dpi_scale);
|
||||
|
||||
recent_connection_image_width_ =
|
||||
(int)(recent_connection_image_width_ * dpi_scale);
|
||||
recent_connection_image_height_ =
|
||||
(int)(recent_connection_image_height_ * dpi_scale);
|
||||
|
||||
if (thumbnail_) {
|
||||
thumbnail_->SetThumbnailDpiScale(dpi_scale);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int Render::CreateMainWindow() {
|
||||
main_ctx_ = ImGui::CreateContext();
|
||||
if (!main_ctx_) {
|
||||
@@ -759,6 +712,10 @@ int Render::CreateStreamWindow() {
|
||||
|
||||
SetupFontAndStyle(false);
|
||||
|
||||
ImGuiStyle& style = ImGui::GetStyle();
|
||||
style.ScaleAllSizes(dpi_scale_);
|
||||
style.FontScaleDpi = dpi_scale_;
|
||||
|
||||
ImGui_ImplSDL3_InitForSDLRenderer(stream_window_, stream_renderer_);
|
||||
ImGui_ImplSDLRenderer3_Init(stream_renderer_);
|
||||
|
||||
@@ -924,9 +881,9 @@ int Render::DrawMainWindow() {
|
||||
ImGui::SetNextWindowSize(ImVec2(io.DisplaySize.x, io.DisplaySize.y),
|
||||
ImGuiCond_Always);
|
||||
ImGui::Begin("MainRender", nullptr,
|
||||
ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoTitleBar |
|
||||
ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoScrollbar |
|
||||
ImGuiWindowFlags_NoBringToFrontOnFocus);
|
||||
ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoDecoration |
|
||||
ImGuiWindowFlags_NoBringToFrontOnFocus |
|
||||
ImGuiWindowFlags_NoDocking);
|
||||
ImGui::PopStyleColor();
|
||||
|
||||
TitleBar(true);
|
||||
@@ -968,24 +925,31 @@ int Render::DrawStreamWindow() {
|
||||
|
||||
StreamWindow();
|
||||
|
||||
if (!fullscreen_button_pressed_) {
|
||||
ImGuiIO& io = ImGui::GetIO();
|
||||
ImGui::SetNextWindowPos(ImVec2(0, 0), ImGuiCond_Always);
|
||||
ImGui::SetNextWindowSize(
|
||||
ImVec2(io.DisplaySize.x,
|
||||
fullscreen_button_pressed_ ? 0 : title_bar_button_height_),
|
||||
ImGuiCond_Always);
|
||||
ImGui::Begin("StreamWindowTitleBar", nullptr,
|
||||
ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoDecoration |
|
||||
ImGuiWindowFlags_NoBringToFrontOnFocus |
|
||||
ImGuiWindowFlags_NoDocking);
|
||||
ImGuiIO& io = ImGui::GetIO();
|
||||
float stream_title_window_height =
|
||||
fullscreen_button_pressed_ ? 0 : title_bar_height_;
|
||||
|
||||
ImGui::PushStyleColor(ImGuiCol_WindowBg, ImVec4(1.0f, 1.0f, 1.0f, 1.0f));
|
||||
// Set minimum window size to 0 to allow exact height control
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_WindowMinSize, ImVec2(0, 0));
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2(0, 0));
|
||||
ImGui::SetNextWindowPos(ImVec2(0, 0), ImGuiCond_Always);
|
||||
ImGui::SetNextWindowSize(ImVec2(io.DisplaySize.x, stream_title_window_height),
|
||||
ImGuiCond_Always);
|
||||
ImGui::Begin("StreamTitleWindow", nullptr,
|
||||
ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoDecoration |
|
||||
ImGuiWindowFlags_NoBringToFrontOnFocus |
|
||||
ImGuiWindowFlags_NoDocking);
|
||||
ImGui::PopStyleVar(2);
|
||||
ImGui::PopStyleColor();
|
||||
|
||||
if (!fullscreen_button_pressed_) {
|
||||
TitleBar(false);
|
||||
ImGui::End();
|
||||
}
|
||||
|
||||
ImGui::End();
|
||||
|
||||
// Rendering
|
||||
ImGuiIO& io = ImGui::GetIO();
|
||||
(void)io;
|
||||
ImGui::Render();
|
||||
SDL_SetRenderScale(stream_renderer_, io.DisplayFramebufferScale.x,
|
||||
|
||||
@@ -175,7 +175,6 @@ class Render {
|
||||
private:
|
||||
int ConnectTo(const std::string& remote_id, const char* password,
|
||||
bool remember_password);
|
||||
int UpdateWindowSizeWithDpiScale(float dpi_scale);
|
||||
int CreateMainWindow();
|
||||
int DestroyMainWindow();
|
||||
int CreateStreamWindow();
|
||||
|
||||
@@ -32,10 +32,10 @@ int LossRateDisplay(float loss_rate) {
|
||||
}
|
||||
|
||||
int Render::ControlBar(std::shared_ptr<SubStreamWindowProperties>& props) {
|
||||
float button_width = title_bar_button_height_ * 0.8f;
|
||||
float button_height = title_bar_button_height_ * 0.8f;
|
||||
float line_padding = title_bar_button_height_ * 0.12f;
|
||||
float line_thickness = title_bar_button_height_ * 0.07f;
|
||||
float button_width = title_bar_height_ * 0.8f;
|
||||
float button_height = title_bar_height_ * 0.8f;
|
||||
float line_padding = title_bar_height_ * 0.12f;
|
||||
float line_thickness = title_bar_height_ * 0.07f;
|
||||
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_FrameRounding, 3.0f);
|
||||
if (props->control_bar_expand_) {
|
||||
|
||||
@@ -11,11 +11,13 @@ int Render::TitleBar(bool main_window) {
|
||||
ImGuiIO& io = ImGui::GetIO();
|
||||
float title_bar_width = title_bar_width_;
|
||||
float title_bar_height = title_bar_height_;
|
||||
float title_bar_height_padding = title_bar_height_;
|
||||
float title_bar_button_width = title_bar_button_width_;
|
||||
float title_bar_button_height = title_bar_button_height_;
|
||||
if (main_window) {
|
||||
title_bar_width = io.DisplaySize.x;
|
||||
title_bar_height = io.DisplaySize.y * (TITLE_BAR_HEIGHT + 0.01f);
|
||||
title_bar_height = io.DisplaySize.y * TITLE_BAR_HEIGHT;
|
||||
title_bar_height_padding = io.DisplaySize.y * (TITLE_BAR_HEIGHT + 0.01f);
|
||||
title_bar_button_width = io.DisplaySize.x * TITLE_BAR_BUTTON_WIDTH;
|
||||
title_bar_button_height = io.DisplaySize.y * TITLE_BAR_BUTTON_HEIGHT;
|
||||
title_bar_height_ = title_bar_height;
|
||||
@@ -32,7 +34,7 @@ int Render::TitleBar(bool main_window) {
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2(0, 0));
|
||||
ImGui::SetNextWindowPos(ImVec2(0, 0), ImGuiCond_Always);
|
||||
ImGui::BeginChild(main_window ? "MainTitleBar" : "StreamTitleBar",
|
||||
ImVec2(title_bar_width, title_bar_height),
|
||||
ImVec2(title_bar_width, title_bar_height_padding),
|
||||
ImGuiChildFlags_Border,
|
||||
ImGuiWindowFlags_NoDecoration | ImGuiWindowFlags_NoMove |
|
||||
ImGuiWindowFlags_NoBringToFrontOnFocus);
|
||||
@@ -120,7 +122,7 @@ int Render::TitleBar(bool main_window) {
|
||||
|
||||
if (update_available_ && ImGui::IsItemHovered()) {
|
||||
ImGui::BeginTooltip();
|
||||
ImGui::SetWindowFontScale(0.5f * dpi_scale_);
|
||||
ImGui::SetWindowFontScale(0.5f);
|
||||
std::string new_version_available_str =
|
||||
localization::new_version_available[localization_language_index_] +
|
||||
": " + latest_version_;
|
||||
|
||||
@@ -70,11 +70,10 @@ int Render::StreamWindow() {
|
||||
|
||||
if (!fullscreen_button_pressed_) {
|
||||
ImGui::SetNextWindowPos(
|
||||
ImVec2(title_bar_height_ * 0.2f, title_bar_height_ * 0.2f),
|
||||
ImGuiCond_Always);
|
||||
ImGui::SetNextWindowSize(
|
||||
ImVec2(title_bar_height_ * 4.0f, title_bar_height_ * 0.8f),
|
||||
ImVec2(title_bar_button_width_ * 0.8f, title_bar_button_width_ * 0.1f),
|
||||
ImGuiCond_Always);
|
||||
ImGui::SetNextWindowSize(ImVec2(0, title_bar_button_width_ * 0.8f),
|
||||
ImGuiCond_Always);
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2(0.0f, 0.0f));
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_WindowBorderSize, 0.0f);
|
||||
ImGui::PushStyleColor(ImGuiCol_WindowBg, ImVec4(0, 0, 0, 0.0f));
|
||||
@@ -115,7 +114,7 @@ int Render::StreamWindow() {
|
||||
: props->remote_id_;
|
||||
if (ImGui::BeginTabItem(tab_label.c_str(), &props->tab_opened_)) {
|
||||
props->tab_selected_ = true;
|
||||
ImGui::SetWindowFontScale(0.6f * dpi_scale_);
|
||||
ImGui::SetWindowFontScale(0.6f);
|
||||
|
||||
ImGui::SetNextWindowSize(
|
||||
ImVec2(stream_window_width_, stream_window_height_),
|
||||
|
||||
Reference in New Issue
Block a user