Add OSXMakeDPIFromScaleFactor() helper
No real changes, just avoid repeating wxRound(scaleFactor*72) in several places and do it in this single function instead.
This commit is contained in:
parent
a2c55fa834
commit
a8bb796f8c
@ -294,6 +294,9 @@ public:
|
||||
// internal response to size events
|
||||
virtual void MacOnInternalSize() {}
|
||||
|
||||
// Return the DPI corresponding to the given scale factor.
|
||||
static wxSize OSXMakeDPIFromScaleFactor(double scaleFactor);
|
||||
|
||||
protected:
|
||||
// For controls like radio buttons which are genuinely composite
|
||||
wxList m_subControls;
|
||||
|
@ -629,8 +629,8 @@ extern int wxOSXGetIdFromSelector(SEL action );
|
||||
doubleValue];
|
||||
if (newBackingScaleFactor != oldBackingScaleFactor)
|
||||
{
|
||||
wxSize oldDPI((int)(oldBackingScaleFactor*72.0),(int)(oldBackingScaleFactor*72.0));
|
||||
wxSize newDPI((int)(newBackingScaleFactor*72.0),(int)(newBackingScaleFactor*72.0));
|
||||
const wxSize oldDPI = wxWindow::OSXMakeDPIFromScaleFactor(oldBackingScaleFactor);
|
||||
const wxSize newDPI = wxWindow::OSXMakeDPIFromScaleFactor(newBackingScaleFactor);
|
||||
|
||||
wxDPIChangedEvent event(oldDPI, newDPI);
|
||||
event.SetEventObject(wxpeer);
|
||||
|
@ -2620,6 +2620,14 @@ bool wxWindowMac::OSXHandleKeyEvent( wxKeyEvent& event )
|
||||
return handled ;
|
||||
}
|
||||
|
||||
/* static */
|
||||
wxSize wxWindowMac::OSXMakeDPIFromScaleFactor(double scaleFactor)
|
||||
{
|
||||
const int dpi = wxRound(scaleFactor*72.0);
|
||||
|
||||
return wxSize(dpi, dpi);
|
||||
}
|
||||
|
||||
wxSize wxWindowMac::GetDPI() const
|
||||
{
|
||||
double scaleFactor;
|
||||
@ -2628,7 +2636,7 @@ wxSize wxWindowMac::GetDPI() const
|
||||
else
|
||||
scaleFactor = wxOSXGetMainScreenContentScaleFactor();
|
||||
|
||||
return wxSize(wxRound(scaleFactor*72.0),wxRound(scaleFactor*72.0));
|
||||
return OSXMakeDPIFromScaleFactor(scaleFactor);
|
||||
}
|
||||
|
||||
//
|
||||
|
Loading…
Reference in New Issue
Block a user