Files
c-evo-evo/widget/include/Dpi/DpiCommon.h
T

44 lines
1.5 KiB
C++

#pragma once
#include <QPoint>
#include <QRect>
#include <QSize>
#include <QString>
namespace Dpi {
// Mirrors the role of Dpi.Common.pas / its ScreenInfo record: conversion
// between the DPI-independent coordinate space used for widget geometry
// (Qt's logical / device-independent pixels) and the native physical pixel
// space used by raw pixel buffers (QImage scanlines, screen grabs, etc.).
// Qt widgets already scale logical pixels to the physical display
// automatically, so these helpers are only needed where code must address
// physical pixels directly (e.g. custom raster rendering).
class ScreenInfo {
public:
// Effective DPI of the primary screen (96 == 100% scaling), kept for API
// parity with the Pascal ScreenInfo.Dpi property.
static int dpi();
// Multiplier from DPI-independent to native/physical pixels.
static double toNative();
// Multiplier from native/physical to DPI-independent pixels.
static double fromNative();
};
int scaleToNative(int value);
int scaleFromNative(int value);
int scaleToNativeDist(int base, int value);
QPoint scalePointToNative(const QPoint &value);
QPoint scalePointFromNative(const QPoint &value);
QSize scaleSizeToNative(const QSize &value);
QSize scaleSizeFromNative(const QSize &value);
QRect scaleRectToNative(const QRect &value);
QRect scaleRectFromNative(const QRect &value);
double scaleFloatToNative(double value);
double scaleFloatFromNative(double value);
void writeLog(const QString &text);
} // namespace Dpi