mirror of
https://github.com/kunkundi/crossdesk.git
synced 2025-12-16 20:17:10 +08:00
[refactor] update status bar rendering for high-DPI scaling support
This commit is contained in:
@@ -12,6 +12,7 @@
|
|||||||
#define TITLE_BAR_HEIGHT 0.0625f
|
#define TITLE_BAR_HEIGHT 0.0625f
|
||||||
#define TITLE_BAR_BUTTON_WIDTH 0.0625f
|
#define TITLE_BAR_BUTTON_WIDTH 0.0625f
|
||||||
#define TITLE_BAR_BUTTON_HEIGHT 0.0625f
|
#define TITLE_BAR_BUTTON_HEIGHT 0.0625f
|
||||||
|
#define STATUS_BAR_HEIGHT 0.05f
|
||||||
#define MENU_WINDOW_WIDTH_CN 300
|
#define MENU_WINDOW_WIDTH_CN 300
|
||||||
#define MENU_WINDOW_HEIGHT_CN 280
|
#define MENU_WINDOW_HEIGHT_CN 280
|
||||||
#define LOCAL_WINDOW_WIDTH_CN 300
|
#define LOCAL_WINDOW_WIDTH_CN 300
|
||||||
|
|||||||
@@ -1,34 +1,38 @@
|
|||||||
|
#include "layout_relative.h"
|
||||||
#include "localization.h"
|
#include "localization.h"
|
||||||
#include "render.h"
|
#include "render.h"
|
||||||
|
|
||||||
namespace crossdesk {
|
namespace crossdesk {
|
||||||
|
|
||||||
int Render::StatusBar() {
|
int Render::StatusBar() {
|
||||||
|
ImGuiIO& io = ImGui::GetIO();
|
||||||
|
float status_bar_width = io.DisplaySize.x;
|
||||||
|
float status_bar_height = io.DisplaySize.y * STATUS_BAR_HEIGHT;
|
||||||
|
|
||||||
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));
|
||||||
static bool a, b, c, d, e;
|
static bool a, b, c, d, e;
|
||||||
ImGui::SetNextWindowPos(
|
ImGui::SetNextWindowPos(ImVec2(0, io.DisplaySize.y * (1 - STATUS_BAR_HEIGHT)),
|
||||||
ImVec2(0, main_window_height_ - status_bar_height_ - 1),
|
ImGuiCond_Always);
|
||||||
ImGuiCond_Always);
|
|
||||||
|
|
||||||
ImGui::BeginChild(
|
ImGui::BeginChild(
|
||||||
"StatusBar", ImVec2(main_window_width_, status_bar_height_ + 1),
|
"StatusBar", ImVec2(status_bar_width, status_bar_height),
|
||||||
ImGuiChildFlags_Border,
|
ImGuiChildFlags_Border,
|
||||||
ImGuiWindowFlags_NoDecoration | ImGuiWindowFlags_NoBringToFrontOnFocus);
|
ImGuiWindowFlags_NoDecoration | ImGuiWindowFlags_NoBringToFrontOnFocus);
|
||||||
|
|
||||||
ImVec2 dot_pos = ImVec2(13.0f * dpi_scale_,
|
ImVec2 dot_pos = ImVec2(status_bar_width * 0.025f,
|
||||||
(main_window_height_ - status_bar_height_) * 1.025f);
|
io.DisplaySize.y * (1 - STATUS_BAR_HEIGHT * 0.5f));
|
||||||
ImDrawList* draw_list = ImGui::GetWindowDrawList();
|
ImDrawList* draw_list = ImGui::GetWindowDrawList();
|
||||||
draw_list->AddCircleFilled(dot_pos, 5.0f * dpi_scale_,
|
draw_list->AddCircleFilled(dot_pos, status_bar_height * 0.2f,
|
||||||
ImColor(signal_connected_ ? 0.0f : 1.0f,
|
ImColor(signal_connected_ ? 0.0f : 1.0f,
|
||||||
signal_connected_ ? 1.0f : 0.0f, 0.0f),
|
signal_connected_ ? 1.0f : 0.0f, 0.0f),
|
||||||
100);
|
100);
|
||||||
draw_list->AddCircle(dot_pos, 6.0f * dpi_scale_, ImColor(1.0f, 1.0f, 1.0f),
|
draw_list->AddCircle(dot_pos, status_bar_height * 0.25f,
|
||||||
100);
|
ImColor(1.0f, 1.0f, 1.0f), 100);
|
||||||
|
|
||||||
ImGui::SetWindowFontScale(0.6f);
|
ImGui::SetWindowFontScale(0.6f);
|
||||||
draw_list->AddText(
|
draw_list->AddText(
|
||||||
ImVec2(25.0f * dpi_scale_,
|
ImVec2(status_bar_width * 0.045f,
|
||||||
(main_window_height_ - status_bar_height_) * 1.003f),
|
io.DisplaySize.y * (1 - STATUS_BAR_HEIGHT * 0.9f)),
|
||||||
ImColor(0.0f, 0.0f, 0.0f),
|
ImColor(0.0f, 0.0f, 0.0f),
|
||||||
signal_connected_
|
signal_connected_
|
||||||
? localization::signal_connected[localization_language_index_].c_str()
|
? localization::signal_connected[localization_language_index_].c_str()
|
||||||
|
|||||||
Reference in New Issue
Block a user