add overlay parameter to control x/y separation in auto-scale mode (#15106)

This commit is contained in:
Valentin 2023-03-31 03:33:39 +03:00 committed by GitHub
parent d28417ca84
commit b0b5a40d44
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 32 additions and 11 deletions

View File

@ -1750,9 +1750,9 @@ static void input_overlay_parse_layout(
return; return;
} }
/* If X separation is permitted, move elements /* If auto-scale X separation is enabled, move elements
* horizontally towards the edges of the screen */ * horizontally towards the edges of the screen */
if (!(ol->flags & OVERLAY_BLOCK_X_SEPARATION)) if (ol->flags & OVERLAY_AUTO_X_SEPARATION)
overlay_layout->x_separation = ((1.0f / overlay_layout->x_scale) - 1.0f) * 0.5f; overlay_layout->x_separation = ((1.0f / overlay_layout->x_scale) - 1.0f) * 0.5f;
} }
/* If display is taller than overlay, /* If display is taller than overlay,
@ -1768,14 +1768,9 @@ static void input_overlay_parse_layout(
return; return;
} }
/* If Y separation is permitted and display has /* If auto-scale Y separation is enabled, move elements
* a *landscape* orientation, move elements * vertically towards the edges of the screen */
* vertically towards the edges of the screen if (ol->flags & OVERLAY_AUTO_Y_SEPARATION)
* > Portrait overlays typically have all elements
* below the centre line, so Y separation
* provides no real benefit */
if ((display_aspect_ratio > 1.0f) &&
!(ol->flags & OVERLAY_BLOCK_Y_SEPARATION))
overlay_layout->y_separation = ((1.0f / overlay_layout->y_scale) - 1.0f) * 0.5f; overlay_layout->y_separation = ((1.0f / overlay_layout->y_scale) - 1.0f) * 0.5f;
} }

View File

@ -141,7 +141,9 @@ enum OVERLAY_FLAGS
OVERLAY_FULL_SCREEN = (1 << 0), OVERLAY_FULL_SCREEN = (1 << 0),
OVERLAY_BLOCK_SCALE = (1 << 1), OVERLAY_BLOCK_SCALE = (1 << 1),
OVERLAY_BLOCK_X_SEPARATION = (1 << 2), OVERLAY_BLOCK_X_SEPARATION = (1 << 2),
OVERLAY_BLOCK_Y_SEPARATION = (1 << 3) OVERLAY_BLOCK_Y_SEPARATION = (1 << 3),
OVERLAY_AUTO_X_SEPARATION = (1 << 4),
OVERLAY_AUTO_Y_SEPARATION = (1 << 5)
}; };
enum OVERLAY_DESC_FLAGS enum OVERLAY_DESC_FLAGS

View File

@ -860,6 +860,30 @@ static void task_overlay_deferred_load(retro_task_t *task)
if (config_get_bool(conf, conf_key, &tmp_bool) if (config_get_bool(conf, conf_key, &tmp_bool)
&& tmp_bool) && tmp_bool)
overlay->flags |= OVERLAY_BLOCK_Y_SEPARATION; overlay->flags |= OVERLAY_BLOCK_Y_SEPARATION;
/* Check whether x/y separation are enabled
* for this overlay in auto-scale mode */
snprintf(conf_key, sizeof(conf_key),
"overlay%u_auto_x_separation", loader->pos);
overlay->flags |= OVERLAY_AUTO_X_SEPARATION;
if (config_get_bool(conf, conf_key, &tmp_bool))
{
if (!tmp_bool)
overlay->flags &= ~OVERLAY_AUTO_X_SEPARATION;
}
else
{
if (overlay->flags & OVERLAY_BLOCK_X_SEPARATION
|| overlay->image.width != 0)
overlay->flags &= ~OVERLAY_AUTO_X_SEPARATION;
}
snprintf(conf_key, sizeof(conf_key),
"overlay%u_auto_y_separation", loader->pos);
overlay->flags &= ~OVERLAY_AUTO_Y_SEPARATION;
if (config_get_bool(conf, conf_key, &tmp_bool)
&& tmp_bool)
overlay->flags |= OVERLAY_AUTO_Y_SEPARATION;
} }
return; return;