Skip to content

Commit

Permalink
Added Aspect Ratio Full
Browse files Browse the repository at this point in the history
Fixes

Fixes

Moved ASPECT_RATIO_FULL to end of list, added TODO

Fixed Full Order

Fixed UI Visibility
  • Loading branch information
HyperspaceMadness committed Jul 7, 2021
1 parent f934991 commit d14c4d2
Show file tree
Hide file tree
Showing 5 changed files with 57 additions and 2 deletions.
3 changes: 2 additions & 1 deletion gfx/video_defines.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ enum aspect_ratio
ASPECT_RATIO_SQUARE,
ASPECT_RATIO_CORE,
ASPECT_RATIO_CUSTOM,
ASPECT_RATIO_FULL,

ASPECT_RATIO_END
};
Expand Down Expand Up @@ -116,7 +117,7 @@ enum text_alignment
#define COLOR_ABGR(r, g, b, a) (((unsigned)(a) << 24) | ((b) << 16) | ((g) << 8) | ((r) << 0))
#endif

#define LAST_ASPECT_RATIO ASPECT_RATIO_CUSTOM
#define LAST_ASPECT_RATIO ASPECT_RATIO_FULL

/* ABGR color format defines */

Expand Down
47 changes: 47 additions & 0 deletions retroarch.c
Original file line number Diff line number Diff line change
Expand Up @@ -31379,6 +31379,21 @@ void video_driver_set_viewport_core(void)
(float)geom->base_width / geom->base_height;
}

void video_driver_set_viewport_full()
{
unsigned width = 0;
unsigned height = 0;

video_driver_get_size(&width, &height);

if (width == 0 || height == 0)
{
return;
}

aspectratio_lut[ASPECT_RATIO_FULL].value = (float)width / (float)height;
}

void video_driver_reset_custom_viewport(void)
{
struct rarch_state *p_rarch = &rarch_st;
Expand Down Expand Up @@ -31473,6 +31488,10 @@ void video_driver_set_aspect_ratio(void)
settings->bools.video_aspect_ratio_auto);
break;

case ASPECT_RATIO_FULL:
video_driver_set_viewport_full();
break;

default:
break;
}
Expand Down Expand Up @@ -38007,6 +38026,34 @@ static enum runloop_state runloop_check_state(
}
#endif

/*
* If the Aspect Ratio is FULL then update the aspect ratio to the
* current video driver aspect ratio (The full window)
*
* TODO/FIXME
* Should possibly be refactored to have last width & driver width & height
* only be done once when we are using an overlay OR using aspect ratio
* full
*/
if (settings->uints.video_aspect_ratio_idx == ASPECT_RATIO_FULL)
{
static unsigned last_width = 0;
static unsigned last_height = 0;
unsigned video_driver_width = p_rarch->video_driver_width;
unsigned video_driver_height = p_rarch->video_driver_height;

/* Check whether video aspect has changed */
if ((video_driver_width != last_width) ||
(video_driver_height != last_height))
{
/* Update set aspect ratio so the full matches the current video width & height */
command_event(CMD_EVENT_VIDEO_SET_ASPECT_RATIO, NULL);

last_width = video_driver_width;
last_height = video_driver_height;
}
}

/* Check quit key */
{
bool trig_quit_key, quit_press_twice;
Expand Down
2 changes: 2 additions & 0 deletions retroarch.h
Original file line number Diff line number Diff line change
Expand Up @@ -1567,6 +1567,8 @@ bool video_driver_supports_read_frame_raw(void);

void video_driver_set_viewport_core(void);

void video_driver_set_viewport_full(void);

void video_driver_reset_custom_viewport(void);

void video_driver_set_rgba(void);
Expand Down
3 changes: 2 additions & 1 deletion retroarch_data.h
Original file line number Diff line number Diff line change
Expand Up @@ -2373,7 +2373,8 @@ struct aspect_ratio_elem aspectratio_lut[ASPECT_RATIO_END] = {
{ 0.0f, "Config" },
{ 1.0f, "Square pixel" },
{ 1.0f, "Core provided" },
{ 0.0f, "Custom" }
{ 0.0f, "Custom" },
{ 1.3333f, "Full" }
};

static gfx_api_gpu_map gpu_map[] = {
Expand Down
4 changes: 4 additions & 0 deletions ui/drivers/qt/qt_options.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1352,6 +1352,7 @@ AspectRatioGroup::AspectRatioGroup(const QString &title, QWidget *parent) :
QHBoxLayout *custom = new QHBoxLayout;
QVBoxLayout *customRadio = new QVBoxLayout;
QHBoxLayout *config = new QHBoxLayout;
QHBoxLayout *full = new QHBoxLayout;
QHBoxLayout *aspectL = new QHBoxLayout;
FormLayout *leftAspectForm = new FormLayout;
FormLayout *rightAspectForm = new FormLayout;
Expand Down Expand Up @@ -1382,6 +1383,8 @@ AspectRatioGroup::AspectRatioGroup(const QString &title, QWidget *parent) :
config->setStretch(1, 1);
config->setSizeConstraint(QLayout::SetMinimumSize);

full->addWidget(new UIntRadioButton(MENU_ENUM_LABEL_VIDEO_ASPECT_RATIO_INDEX, ASPECT_RATIO_FULL));

leftAspect->addRow(new UIntRadioButton(MENU_ENUM_LABEL_VIDEO_ASPECT_RATIO_INDEX, ASPECT_RATIO_CORE));
leftAspect->addRow(preset);

Expand All @@ -1394,6 +1397,7 @@ AspectRatioGroup::AspectRatioGroup(const QString &title, QWidget *parent) :
aspectL->addLayout(rightAspect);

addRow(aspectL);
addRow(full);
addRow(custom);

connect(m_radioButton, SIGNAL(clicked(bool)), this, SLOT(onAspectRadioClicked(bool)));
Expand Down

0 comments on commit d14c4d2

Please sign in to comment.