Allow interface scale of 50%.
This commit is contained in:
parent
a5766cb1f6
commit
746eb80300
2 changed files with 8 additions and 5 deletions
|
|
@ -21,7 +21,7 @@ int DevicePixelRatio() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void SetDevicePixelRatio(int ratio) {
|
void SetDevicePixelRatio(int ratio) {
|
||||||
DevicePixelRatioValue = ratio;
|
DevicePixelRatioValue = std::clamp(ratio, 1, kScaleMax / kScaleMin);
|
||||||
}
|
}
|
||||||
|
|
||||||
int Scale() {
|
int Scale() {
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,7 @@
|
||||||
namespace style {
|
namespace style {
|
||||||
|
|
||||||
inline constexpr auto kScaleAuto = 0;
|
inline constexpr auto kScaleAuto = 0;
|
||||||
inline constexpr auto kScaleMin = 75;
|
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;
|
||||||
|
|
||||||
|
|
@ -34,9 +34,12 @@ void SetScale(int scale);
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
[[nodiscard]] inline T ConvertScale(T value, int scale) {
|
[[nodiscard]] inline T ConvertScale(T value, int scale) {
|
||||||
return (value < 0.)
|
if (value < 0.) {
|
||||||
? (-ConvertScale(-value, scale))
|
return -ConvertScale(-value, scale);
|
||||||
: T(base::SafeRound((double(value) * scale / 100.) - 0.01));
|
}
|
||||||
|
const auto result = T(base::SafeRound(
|
||||||
|
(double(value) * scale / 100.) - 0.01));
|
||||||
|
return (!std::is_integral_v<T> || !value || result) ? result : 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue