Allow larger scales on high-dpi screens.
This commit is contained in:
parent
dec1cd8cea
commit
bcb56492c4
2 changed files with 15 additions and 5 deletions
|
|
@ -34,4 +34,16 @@ void SetScale(int scale) {
|
||||||
ScaleValue = scale;
|
ScaleValue = scale;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int MaxScaleForRatio(int ratio) {
|
||||||
|
Expects(ratio > 0);
|
||||||
|
|
||||||
|
return std::max(kScaleMax / ratio, kScaleAlwaysAllowMax);
|
||||||
|
}
|
||||||
|
|
||||||
|
int CheckScale(int scale) {
|
||||||
|
return (scale == kScaleAuto)
|
||||||
|
? kScaleAuto
|
||||||
|
: std::clamp(scale, kScaleMin, MaxScaleForRatio(DevicePixelRatio()));
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace style
|
} // namespace style
|
||||||
|
|
|
||||||
|
|
@ -19,6 +19,7 @@ inline constexpr auto kScaleAuto = 0;
|
||||||
inline constexpr auto kScaleMin = 50;
|
inline constexpr auto kScaleMin = 50;
|
||||||
inline constexpr auto kScaleDefault = 100;
|
inline constexpr auto kScaleDefault = 100;
|
||||||
inline constexpr auto kScaleMax = 300;
|
inline constexpr auto kScaleMax = 300;
|
||||||
|
inline constexpr auto kScaleAlwaysAllowMax = 200;
|
||||||
|
|
||||||
[[nodiscard]] int DevicePixelRatio();
|
[[nodiscard]] int DevicePixelRatio();
|
||||||
void SetDevicePixelRatio(int ratio);
|
void SetDevicePixelRatio(int ratio);
|
||||||
|
|
@ -26,11 +27,8 @@ void SetDevicePixelRatio(int ratio);
|
||||||
[[nodiscard]] int Scale();
|
[[nodiscard]] int Scale();
|
||||||
void SetScale(int scale);
|
void SetScale(int scale);
|
||||||
|
|
||||||
[[nodiscard]] inline int CheckScale(int scale) {
|
[[nodiscard]] int MaxScaleForRatio(int ratio);
|
||||||
return (scale == kScaleAuto)
|
[[nodiscard]] int CheckScale(int scale);
|
||||||
? kScaleAuto
|
|
||||||
: std::clamp(scale, kScaleMin, kScaleMax / DevicePixelRatio());
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
[[nodiscard]] inline T ConvertScale(T value, int scale) {
|
[[nodiscard]] inline T ConvertScale(T value, int scale) {
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue