mirror of
https://github.com/visualboyadvance-m/visualboyadvance-m
synced 2025-10-05 23:52:49 +02:00
Compare commits
1 Commits
e889e895f2
...
hidpi-supp
Author | SHA1 | Date | |
---|---|---|---|
|
3f77a55f7c |
@@ -7,22 +7,6 @@
|
||||
#include "wxvbam.h"
|
||||
#include "drawing.h"
|
||||
|
||||
double HiDPIAware::HiDPIScaleFactor()
|
||||
{
|
||||
if (hidpi_scale_factor == 0) {
|
||||
NSWindow* window = [(NSView*)GetWindow()->GetHandle() window];
|
||||
|
||||
if ([window respondsToSelector:@selector(backingScaleFactor)]) {
|
||||
hidpi_scale_factor = [window backingScaleFactor];
|
||||
}
|
||||
else {
|
||||
hidpi_scale_factor = 1.0;
|
||||
}
|
||||
}
|
||||
|
||||
return hidpi_scale_factor;
|
||||
}
|
||||
|
||||
void HiDPIAware::RequestHighResolutionOpenGLSurface()
|
||||
{
|
||||
NSView* view = (NSView*)(GetWindow()->GetHandle());
|
||||
@@ -32,16 +16,6 @@ void HiDPIAware::RequestHighResolutionOpenGLSurface()
|
||||
}
|
||||
}
|
||||
|
||||
void HiDPIAware::GetRealPixelClientSize(int* x, int* y)
|
||||
{
|
||||
NSView* view = (NSView*)(GetWindow()->GetHandle());
|
||||
|
||||
NSSize backing_size = [view convertSizeToBacking:view.bounds.size];
|
||||
|
||||
*x = backing_size.width;
|
||||
*y = backing_size.height;
|
||||
}
|
||||
|
||||
Quartz2DDrawingPanel::Quartz2DDrawingPanel(wxWindow* parent, int _width, int _height)
|
||||
: BasicDrawingPanel(parent, _width, _height)
|
||||
{
|
||||
|
@@ -745,12 +745,12 @@ void GameArea::DelBorder()
|
||||
void GameArea::AdjustMinSize()
|
||||
{
|
||||
wxWindow* frame = wxGetApp().frame;
|
||||
double hidpi_scale_factor = HiDPIScaleFactor();
|
||||
double hidpi_scale_factor = GetDPIScaleFactor();
|
||||
|
||||
// note: could safely set min size to 1x or less regardless of video_scale
|
||||
// but setting it to scaled size makes resizing to default easier
|
||||
wxSize sz((std::ceil(basic_width * gopts.video_scale) / hidpi_scale_factor),
|
||||
(std::ceil(basic_height * gopts.video_scale) / hidpi_scale_factor));
|
||||
wxSize sz((std::ceil(basic_width * gopts.video_scale) * hidpi_scale_factor),
|
||||
(std::ceil(basic_height * gopts.video_scale) * hidpi_scale_factor));
|
||||
SetMinSize(sz);
|
||||
#if wxCHECK_VERSION(2, 8, 8)
|
||||
sz = frame->ClientToWindowSize(sz);
|
||||
@@ -763,10 +763,10 @@ void GameArea::AdjustMinSize()
|
||||
void GameArea::LowerMinSize()
|
||||
{
|
||||
wxWindow* frame = wxGetApp().frame;
|
||||
double hidpi_scale_factor = HiDPIScaleFactor();
|
||||
double hidpi_scale_factor = GetDPIScaleFactor();
|
||||
|
||||
wxSize sz(std::ceil(basic_width / hidpi_scale_factor),
|
||||
std::ceil(basic_height / hidpi_scale_factor));
|
||||
wxSize sz(std::ceil(basic_width * hidpi_scale_factor),
|
||||
std::ceil(basic_height * hidpi_scale_factor));
|
||||
|
||||
SetMinSize(sz);
|
||||
// do not take decorations into account
|
||||
@@ -780,9 +780,9 @@ void GameArea::AdjustSize(bool force)
|
||||
if (fullscreen)
|
||||
return;
|
||||
|
||||
double hidpi_scale_factor = HiDPIScaleFactor();
|
||||
const wxSize newsz((std::ceil(basic_width * gopts.video_scale) / hidpi_scale_factor),
|
||||
(std::ceil(basic_height * gopts.video_scale) / hidpi_scale_factor));
|
||||
double hidpi_scale_factor = GetDPIScaleFactor();
|
||||
const wxSize newsz((std::ceil(basic_width * gopts.video_scale) * hidpi_scale_factor),
|
||||
(std::ceil(basic_height * gopts.video_scale) * hidpi_scale_factor));
|
||||
|
||||
if (!force) {
|
||||
wxSize sz = GetClientSize();
|
||||
@@ -2251,7 +2251,7 @@ void GLDrawingPanel::AdjustViewport()
|
||||
#endif
|
||||
|
||||
int x, y;
|
||||
GetRealPixelClientSize(&x, &y);
|
||||
GetClientSize(&x, &y);
|
||||
glViewport(0, 0, x, y);
|
||||
|
||||
#ifdef DEBUG
|
||||
@@ -2515,23 +2515,7 @@ void GameArea::ShowMenuBar()
|
||||
#endif
|
||||
}
|
||||
|
||||
// stub HiDPI methods, see macsupport.mm for the Mac support
|
||||
#ifndef __WXMAC__
|
||||
double HiDPIAware::HiDPIScaleFactor()
|
||||
{
|
||||
if (hidpi_scale_factor == 0) {
|
||||
hidpi_scale_factor = 1.0;
|
||||
}
|
||||
|
||||
return hidpi_scale_factor;
|
||||
}
|
||||
|
||||
void HiDPIAware::RequestHighResolutionOpenGLSurface()
|
||||
{
|
||||
}
|
||||
|
||||
void HiDPIAware::GetRealPixelClientSize(int* x, int* y)
|
||||
{
|
||||
GetWindow()->GetClientSize(x, y);
|
||||
}
|
||||
#endif // HiDPI stubs
|
||||
// stub HiDPI method, see macsupport.mm for the Mac support
|
||||
void HiDPIAware::RequestHighResolutionOpenGLSurface() {}
|
||||
#endif // __WXMAC__ stub
|
||||
|
@@ -391,13 +391,9 @@ private:
|
||||
// helper class to add HiDPI awareness (mostly for Mac OS X)
|
||||
class HiDPIAware {
|
||||
public:
|
||||
HiDPIAware() { hidpi_scale_factor = 0; }
|
||||
virtual double HiDPIScaleFactor();
|
||||
HiDPIAware() = default;
|
||||
virtual void RequestHighResolutionOpenGLSurface();
|
||||
virtual void GetRealPixelClientSize(int* x, int* y);
|
||||
virtual wxWindow* GetWindow() = 0;
|
||||
private:
|
||||
double hidpi_scale_factor;
|
||||
};
|
||||
|
||||
// a class for polling joystick keys
|
||||
|
Reference in New Issue
Block a user