A bit more clang-format
This commit is contained in:
@@ -32,79 +32,83 @@ extern "C" {
|
||||
|
||||
RendererCommon::RendererCommon() = default;
|
||||
|
||||
extern MainWindow* main_window;
|
||||
extern MainWindow *main_window;
|
||||
|
||||
static void integer_scale(double *d, double *g) {
|
||||
static void
|
||||
integer_scale(double *d, double *g)
|
||||
{
|
||||
double ratio;
|
||||
|
||||
if (*d > *g) {
|
||||
ratio = std::floor(*d / *g);
|
||||
*d = *g * ratio;
|
||||
*d = *g * ratio;
|
||||
} else {
|
||||
ratio = std::ceil(*d / *g);
|
||||
*d = *g / ratio;
|
||||
*d = *g / ratio;
|
||||
}
|
||||
}
|
||||
|
||||
void RendererCommon::onResize(int width, int height) {
|
||||
void
|
||||
RendererCommon::onResize(int width, int height)
|
||||
{
|
||||
if ((video_fullscreen == 0) && (video_fullscreen_scale_maximized ? ((parentWidget->isMaximized() == false) && (main_window->isAncestorOf(parentWidget) && main_window->isMaximized() == false)) : 1)) {
|
||||
destination.setRect(0, 0, width, height);
|
||||
return;
|
||||
}
|
||||
double dx, dy, dw, dh, gsr;
|
||||
|
||||
double hw = width;
|
||||
double hh = height;
|
||||
double gw = source.width();
|
||||
double gh = source.height();
|
||||
double hw = width;
|
||||
double hh = height;
|
||||
double gw = source.width();
|
||||
double gh = source.height();
|
||||
double hsr = hw / hh;
|
||||
|
||||
switch (video_fullscreen_scale) {
|
||||
case FULLSCR_SCALE_INT:
|
||||
gsr = gw / gh;
|
||||
if (gsr <= hsr) {
|
||||
dw = hh * gsr;
|
||||
dh = hh;
|
||||
} else {
|
||||
dw = hw;
|
||||
dh = hw / gsr;
|
||||
}
|
||||
integer_scale(&dw, &gw);
|
||||
integer_scale(&dh, &gh);
|
||||
dx = (hw - dw) / 2.0;
|
||||
dy = (hh - dh) / 2.0;
|
||||
destination.setRect(dx, dy, dw, dh);
|
||||
break;
|
||||
case FULLSCR_SCALE_43:
|
||||
case FULLSCR_SCALE_KEEPRATIO:
|
||||
if (video_fullscreen_scale == FULLSCR_SCALE_43) {
|
||||
gsr = 4.0 / 3.0;
|
||||
} else {
|
||||
case FULLSCR_SCALE_INT:
|
||||
gsr = gw / gh;
|
||||
}
|
||||
if (gsr <= hsr) {
|
||||
dw = hh * gsr;
|
||||
dh = hh;
|
||||
} else {
|
||||
dw = hw;
|
||||
dh = hw / gsr;
|
||||
}
|
||||
integer_scale(&dw, &gw);
|
||||
integer_scale(&dh, &gh);
|
||||
dx = (hw - dw) / 2.0;
|
||||
dy = (hh - dh) / 2.0;
|
||||
destination.setRect(dx, dy, dw, dh);
|
||||
break;
|
||||
case FULLSCR_SCALE_43:
|
||||
case FULLSCR_SCALE_KEEPRATIO:
|
||||
if (video_fullscreen_scale == FULLSCR_SCALE_43) {
|
||||
gsr = 4.0 / 3.0;
|
||||
} else {
|
||||
gsr = gw / gh;
|
||||
}
|
||||
|
||||
if (gsr <= hsr) {
|
||||
dw = hh * gsr;
|
||||
dh = hh;
|
||||
} else {
|
||||
dw = hw;
|
||||
dh = hw / gsr;
|
||||
}
|
||||
dx = (hw - dw) / 2.0;
|
||||
dy = (hh - dh) / 2.0;
|
||||
destination.setRect(dx, dy, dw, dh);
|
||||
break;
|
||||
case FULLSCR_SCALE_FULL:
|
||||
default:
|
||||
destination.setRect(0, 0, hw, hh);
|
||||
break;
|
||||
if (gsr <= hsr) {
|
||||
dw = hh * gsr;
|
||||
dh = hh;
|
||||
} else {
|
||||
dw = hw;
|
||||
dh = hw / gsr;
|
||||
}
|
||||
dx = (hw - dw) / 2.0;
|
||||
dy = (hh - dh) / 2.0;
|
||||
destination.setRect(dx, dy, dw, dh);
|
||||
break;
|
||||
case FULLSCR_SCALE_FULL:
|
||||
default:
|
||||
destination.setRect(0, 0, hw, hh);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
bool RendererCommon::eventDelegate(QEvent *event, bool& result)
|
||||
bool
|
||||
RendererCommon::eventDelegate(QEvent *event, bool &result)
|
||||
{
|
||||
switch (event->type())
|
||||
{
|
||||
switch (event->type()) {
|
||||
default:
|
||||
return false;
|
||||
case QEvent::KeyPress:
|
||||
|
||||
Reference in New Issue
Block a user