52 #ifndef __PCL_UIScaling_h
53 #define __PCL_UIScaling_h
58 #include <pcl/Diagnostics.h>
73 #define PCL_UIScaling_LUT_Length 7
75 extern PCL_DATA
const double PCL_UIScalingFactor_LUT[ PCL_UIScaling_LUT_Length ];
76 extern PCL_DATA
const char* PCL_UIScalingSubdir_LUT[ PCL_UIScaling_LUT_Length ];
89 if ( scalingFactor > 1 )
91 int index =
Min(
RoundInt( 2*scalingFactor ), PCL_UIScaling_LUT_Length+1 );
135 return PCL_UIScalingFactor_LUT[
Range( index, 0, PCL_UIScaling_LUT_Length-1 )];
145 inline int UIScaled(
double scalingFactor,
int size )
147 return (scalingFactor <= 1) ? size :
RoundInt( scalingFactor*size );
159 return (scalingFactor <= 1) ? size :
RoundInt( size/scalingFactor );
179 index =
Range( index, 0, PCL_UIScaling_LUT_Length-1 );
184 return path.Left( p+1 ) + PCL_UIScalingSubdir_LUT[index] + path.Substring( p );
211 struct PCL_UIStringSection
222 PCL_UIStringSection() =
default;
223 PCL_UIStringSection(
const PCL_UIStringSection& ) =
default;
261 #define PCL_UI_IS_NUMBER_DIGIT( c ) (CharTraits::IsDigit( c ) || CharTraits::IsDecimalSeparator( c ))
263 String cssCode( styleSheet );
268 if ( resourceScalingFactor > 0 )
273 p = cssCode.Find(
":/", p );
279 urlSections.
Add( PCL_UIStringSection( p, q ) );
296 if ( displayScalingFactor > 0 )
301 q = cssCode.Find(
"px", q );
305 while ( p > 0 && PCL_UI_IS_NUMBER_DIGIT( cssCode[p-1] ) )
308 pxSections.
Add( PCL_UIStringSection( p, q ) );
313 if ( cssCode.Substring( s.pos, s.len ).
TryToDouble( px ) )
314 cssCode.Replace( s.pos, s.len,
String().Format(
"%d",
RoundInt( px * displayScalingFactor ) ) );
332 q = cssCode.Find(
"pt", q );
336 while ( p > 0 && PCL_UI_IS_NUMBER_DIGIT( cssCode[p-1] ) )
339 ptSections.
Add( PCL_UIStringSection( p, q ) );
344 if ( cssCode.Substring( s.pos, s.len ).
TryToDouble( pt ) )
345 cssCode.Replace( s.pos, s.len+2,
String().Format(
"%dpx",
RoundInt( displayScalingFactor*pt*fontDPI/72 ) ) );
352 #undef PCL_UI_IS_NUMBER_DIGIT
bool IsEmpty() const noexcept
static const size_type notFound
static int GlobalInteger(const IsoString &globalId)
Reverse container adaptor.
bool TryToDouble(double &value) const noexcept
int RoundInt(T x) noexcept
int UIScaled(double scalingFactor, int size)
double UIResourceScalingFactor(double scalingFactor)
String UIScaledResourceForIndex(int index, R resource)
String UIScaledStyleSheet(double displayScalingFactor, double resourceScalingFactor, S styleSheet, int fontDPI=0)
String UIScaledResource(double scalingFactor, R resource)
int UIUnscaled(double scalingFactor, int size)
int UIResourceScalingIndex(double scalingFactor)
double UIResourceScalingFactorForIndex(int index)
constexpr const T & Min(const T &a, const T &b) noexcept
constexpr const T & Range(const T &x, const T &a, const T &b) noexcept