mirror of
https://github.com/kunkundi/crossdesk.git
synced 2025-12-16 20:17:10 +08:00
[refactor] update remote peer panel rendering for high-DPI scaling support
This commit is contained in:
@@ -19,7 +19,7 @@ int Render::LocalWindow() {
|
|||||||
ImGuiCond_Always);
|
ImGuiCond_Always);
|
||||||
ImGui::PushStyleVar(ImGuiStyleVar_FrameRounding, 3.0f);
|
ImGui::PushStyleVar(ImGuiStyleVar_FrameRounding, 3.0f);
|
||||||
|
|
||||||
ImGui::PushStyleColor(ImGuiCol_ChildBg, ImVec4(1.0f, 1.0f, 1.0f, 1.0f));
|
ImGui::PushStyleColor(ImGuiCol_ChildBg, ImVec4(0, 0, 0, 0));
|
||||||
ImGui::BeginChild("LocalDesktopWindow",
|
ImGui::BeginChild("LocalDesktopWindow",
|
||||||
ImVec2(local_window_width, local_window_height),
|
ImVec2(local_window_width, local_window_height),
|
||||||
ImGuiChildFlags_None,
|
ImGuiChildFlags_None,
|
||||||
@@ -46,7 +46,8 @@ int Render::LocalWindow() {
|
|||||||
"LocalDesktopPanel",
|
"LocalDesktopPanel",
|
||||||
ImVec2(local_window_width * 0.8f, local_window_height * 0.43f),
|
ImVec2(local_window_width * 0.8f, local_window_height * 0.43f),
|
||||||
ImGuiChildFlags_Border,
|
ImGuiChildFlags_Border,
|
||||||
ImGuiWindowFlags_NoDecoration | ImGuiWindowFlags_NoBringToFrontOnFocus);
|
ImGuiWindowFlags_NoDecoration | ImGuiWindowFlags_NoMove |
|
||||||
|
ImGuiWindowFlags_NoBringToFrontOnFocus);
|
||||||
ImGui::PopStyleVar();
|
ImGui::PopStyleVar();
|
||||||
ImGui::PopStyleColor();
|
ImGui::PopStyleColor();
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
#include "layout.h"
|
#include "layout_relative.h"
|
||||||
#include "localization.h"
|
#include "localization.h"
|
||||||
#include "rd_log.h"
|
#include "rd_log.h"
|
||||||
#include "render.h"
|
#include "render.h"
|
||||||
@@ -8,21 +8,28 @@ namespace crossdesk {
|
|||||||
static int InputTextCallback(ImGuiInputTextCallbackData* data);
|
static int InputTextCallback(ImGuiInputTextCallbackData* data);
|
||||||
|
|
||||||
int Render::RemoteWindow() {
|
int Render::RemoteWindow() {
|
||||||
ImGui::SetNextWindowPos(ImVec2(local_window_width_ + 1.0f, title_bar_height_),
|
ImGuiIO& io = ImGui::GetIO();
|
||||||
ImGuiCond_Always);
|
float remote_window_width = io.DisplaySize.x * 0.5f;
|
||||||
|
float remote_window_height =
|
||||||
|
io.DisplaySize.y * (1 - TITLE_BAR_HEIGHT - STATUS_BAR_HEIGHT);
|
||||||
|
float remote_window_button_width = io.DisplaySize.x * 0.046f;
|
||||||
|
float remote_window_button_height = io.DisplaySize.y * 0.075f;
|
||||||
|
|
||||||
|
ImGui::SetNextWindowPos(
|
||||||
|
ImVec2(io.DisplaySize.x * 0.5f, io.DisplaySize.y * TITLE_BAR_HEIGHT),
|
||||||
|
ImGuiCond_Always);
|
||||||
ImGui::PushStyleVar(ImGuiStyleVar_FrameRounding, 3.0f);
|
ImGui::PushStyleVar(ImGuiStyleVar_FrameRounding, 3.0f);
|
||||||
|
|
||||||
ImGui::PushStyleColor(ImGuiCol_ChildBg, ImVec4(1.0f, 1.0f, 1.0f, 1.0f));
|
ImGui::PushStyleColor(ImGuiCol_ChildBg, ImVec4(0, 0, 0, 0));
|
||||||
ImGui::BeginChild("RemoteDesktopWindow",
|
ImGui::BeginChild("RemoteDesktopWindow",
|
||||||
ImVec2(remote_window_width_, remote_window_height_),
|
ImVec2(remote_window_width, remote_window_height),
|
||||||
ImGuiChildFlags_None,
|
ImGuiChildFlags_None,
|
||||||
ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoCollapse |
|
ImGuiWindowFlags_NoDecoration | ImGuiWindowFlags_NoMove |
|
||||||
ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoTitleBar |
|
|
||||||
ImGuiWindowFlags_NoBringToFrontOnFocus);
|
ImGuiWindowFlags_NoBringToFrontOnFocus);
|
||||||
ImGui::PopStyleColor();
|
ImGui::PopStyleColor();
|
||||||
|
|
||||||
ImGui::SetCursorPosY(ImGui::GetCursorPosY() + main_window_text_y_padding_);
|
ImGui::SetCursorPos(
|
||||||
ImGui::Indent(main_child_window_x_padding_ - 1.0f);
|
ImVec2(io.DisplaySize.x * 0.545f, io.DisplaySize.y * 0.02f));
|
||||||
|
|
||||||
ImGui::TextColored(
|
ImGui::TextColored(
|
||||||
ImVec4(0.0f, 0.0f, 0.0f, 0.5f), "%s",
|
ImVec4(0.0f, 0.0f, 0.0f, 0.5f), "%s",
|
||||||
@@ -31,8 +38,7 @@ int Render::RemoteWindow() {
|
|||||||
ImGui::Spacing();
|
ImGui::Spacing();
|
||||||
{
|
{
|
||||||
ImGui::SetNextWindowPos(
|
ImGui::SetNextWindowPos(
|
||||||
ImVec2(local_window_width_ + main_child_window_x_padding_ - 1.0f,
|
ImVec2(io.DisplaySize.x * 0.56f, io.DisplaySize.y * 0.15f),
|
||||||
title_bar_height_ + main_child_window_y_padding_),
|
|
||||||
ImGuiCond_Always);
|
ImGuiCond_Always);
|
||||||
ImGui::PushStyleColor(ImGuiCol_ChildBg, ImVec4(239.0f / 255, 240.0f / 255,
|
ImGui::PushStyleColor(ImGuiCol_ChildBg, ImVec4(239.0f / 255, 240.0f / 255,
|
||||||
242.0f / 255, 1.0f));
|
242.0f / 255, 1.0f));
|
||||||
@@ -40,10 +46,9 @@ int Render::RemoteWindow() {
|
|||||||
|
|
||||||
ImGui::BeginChild(
|
ImGui::BeginChild(
|
||||||
"RemoteDesktopWindow_1",
|
"RemoteDesktopWindow_1",
|
||||||
ImVec2(remote_child_window_width_, remote_child_window_height_),
|
ImVec2(remote_window_width * 0.8f, remote_window_height * 0.43f),
|
||||||
ImGuiChildFlags_Border,
|
ImGuiChildFlags_Border,
|
||||||
ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoCollapse |
|
ImGuiWindowFlags_NoDecoration | ImGuiWindowFlags_NoMove |
|
||||||
ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoTitleBar |
|
|
||||||
ImGuiWindowFlags_NoBringToFrontOnFocus);
|
ImGuiWindowFlags_NoBringToFrontOnFocus);
|
||||||
ImGui::PopStyleVar();
|
ImGui::PopStyleVar();
|
||||||
ImGui::PopStyleColor();
|
ImGui::PopStyleColor();
|
||||||
|
|||||||
@@ -933,7 +933,7 @@ int Render::DrawMainWindow() {
|
|||||||
|
|
||||||
MainWindow();
|
MainWindow();
|
||||||
|
|
||||||
UpdateNotificationWindow();
|
// UpdateNotificationWindow();
|
||||||
|
|
||||||
#ifdef __APPLE__
|
#ifdef __APPLE__
|
||||||
if (show_request_permission_window_) {
|
if (show_request_permission_window_) {
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
#include "layout_relative.h"
|
||||||
#include "localization.h"
|
#include "localization.h"
|
||||||
#include "rd_log.h"
|
#include "rd_log.h"
|
||||||
#include "render.h"
|
#include "render.h"
|
||||||
@@ -5,30 +6,35 @@
|
|||||||
namespace crossdesk {
|
namespace crossdesk {
|
||||||
|
|
||||||
int Render::MainWindow() {
|
int Render::MainWindow() {
|
||||||
ImGui::SetNextWindowPos(ImVec2(0, title_bar_height_), ImGuiCond_Always);
|
ImGuiIO& io = ImGui::GetIO();
|
||||||
|
float local_remote_window_width = io.DisplaySize.x;
|
||||||
|
float local_remote_window_height =
|
||||||
|
io.DisplaySize.y * (1 - TITLE_BAR_HEIGHT - STATUS_BAR_HEIGHT);
|
||||||
|
|
||||||
|
ImGui::SetNextWindowPos(ImVec2(0.0f, io.DisplaySize.y * TITLE_BAR_HEIGHT),
|
||||||
|
ImGuiCond_Always);
|
||||||
ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2(0.0f, 0.0f));
|
ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2(0.0f, 0.0f));
|
||||||
ImGui::PushStyleColor(ImGuiCol_ChildBg, ImVec4(1.0f, 1.0f, 1.0f, 1.0f));
|
ImGui::PushStyleColor(ImGuiCol_ChildBg, ImVec4(1.0f, 1.0f, 1.0f, 1.0f));
|
||||||
ImGui::BeginChild("DeskWindow",
|
ImGui::BeginChild(
|
||||||
ImVec2(main_window_width_, local_window_height_),
|
"DeskWindow",
|
||||||
ImGuiChildFlags_Border,
|
ImVec2(local_remote_window_width, local_remote_window_height),
|
||||||
ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoCollapse |
|
ImGuiChildFlags_Border,
|
||||||
ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoTitleBar |
|
ImGuiWindowFlags_NoDecoration | ImGuiWindowFlags_NoMove |
|
||||||
ImGuiWindowFlags_NoBringToFrontOnFocus);
|
ImGuiWindowFlags_NoBringToFrontOnFocus);
|
||||||
ImGui::PopStyleVar();
|
ImGui::PopStyleVar();
|
||||||
ImGui::PopStyleColor();
|
ImGui::PopStyleColor();
|
||||||
|
|
||||||
LocalWindow();
|
LocalWindow();
|
||||||
|
|
||||||
ImDrawList* draw_list = ImGui::GetWindowDrawList();
|
ImDrawList* draw_list = ImGui::GetWindowDrawList();
|
||||||
draw_list->AddLine(
|
draw_list->AddLine(ImVec2(io.DisplaySize.x * 0.5f, io.DisplaySize.y * 0.1f),
|
||||||
ImVec2(main_window_width_ / 2, title_bar_height_ + 15.0f * dpi_scale_),
|
ImVec2(io.DisplaySize.x * 0.5f, io.DisplaySize.y * 0.53f),
|
||||||
ImVec2(main_window_width_ / 2, title_bar_height_ + 225.0f * dpi_scale_),
|
IM_COL32(0, 0, 0, 122), 1.0f);
|
||||||
IM_COL32(0, 0, 0, 122), 1.0f);
|
|
||||||
|
|
||||||
RemoteWindow();
|
RemoteWindow();
|
||||||
ImGui::EndChild();
|
ImGui::EndChild();
|
||||||
|
|
||||||
RecentConnectionsWindow();
|
// RecentConnectionsWindow();
|
||||||
StatusBar();
|
StatusBar();
|
||||||
|
|
||||||
if (show_connection_status_window_) {
|
if (show_connection_status_window_) {
|
||||||
|
|||||||
Reference in New Issue
Block a user