HostDisplay: Add alignment setting
This commit is contained in:
parent
3b4ba17356
commit
5cc91dc78b
|
@ -94,7 +94,22 @@ void HostDisplay::CalculateDrawRect(s32 window_width, s32 window_height, s32* ou
|
||||||
*out_left_padding = 0;
|
*out_left_padding = 0;
|
||||||
}
|
}
|
||||||
if (out_top_padding)
|
if (out_top_padding)
|
||||||
*out_top_padding = std::max<s32>((window_height - static_cast<s32>(display_height * scale)) / 2, 0);
|
{
|
||||||
|
switch (m_display_alignment)
|
||||||
|
{
|
||||||
|
case Alignment::LeftOrTop:
|
||||||
|
*out_top_padding = 0;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case Alignment::Center:
|
||||||
|
*out_top_padding = std::max<s32>((window_height - static_cast<s32>(display_height * scale)) / 2, 0);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case Alignment::RightOrBottom:
|
||||||
|
*out_top_padding = std::max<s32>(window_height - static_cast<s32>(display_height * scale), 0);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -104,7 +119,23 @@ void HostDisplay::CalculateDrawRect(s32 window_width, s32 window_height, s32* ou
|
||||||
scale = std::max(std::floor(scale), 1.0f);
|
scale = std::max(std::floor(scale), 1.0f);
|
||||||
|
|
||||||
if (out_left_padding)
|
if (out_left_padding)
|
||||||
*out_left_padding = std::max<s32>((window_width - static_cast<s32>(display_width * scale)) / 2, 0);
|
{
|
||||||
|
switch (m_display_alignment)
|
||||||
|
{
|
||||||
|
case Alignment::LeftOrTop:
|
||||||
|
*out_left_padding = 0;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case Alignment::Center:
|
||||||
|
*out_left_padding = std::max<s32>((window_width - static_cast<s32>(display_width * scale)) / 2, 0);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case Alignment::RightOrBottom:
|
||||||
|
*out_left_padding = std::max<s32>(window_width - static_cast<s32>(display_width * scale), 0);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (out_top_padding)
|
if (out_top_padding)
|
||||||
{
|
{
|
||||||
if (m_display_integer_scaling)
|
if (m_display_integer_scaling)
|
||||||
|
|
|
@ -31,6 +31,13 @@ public:
|
||||||
OpenGLES
|
OpenGLES
|
||||||
};
|
};
|
||||||
|
|
||||||
|
enum class Alignment
|
||||||
|
{
|
||||||
|
LeftOrTop,
|
||||||
|
Center,
|
||||||
|
RightOrBottom
|
||||||
|
};
|
||||||
|
|
||||||
virtual ~HostDisplay();
|
virtual ~HostDisplay();
|
||||||
|
|
||||||
ALWAYS_INLINE s32 GetWindowWidth() const { return static_cast<s32>(m_window_info.surface_width); }
|
ALWAYS_INLINE s32 GetWindowWidth() const { return static_cast<s32>(m_window_info.surface_width); }
|
||||||
|
@ -122,6 +129,7 @@ public:
|
||||||
void SetDisplayLinearFiltering(bool enabled) { m_display_linear_filtering = enabled; }
|
void SetDisplayLinearFiltering(bool enabled) { m_display_linear_filtering = enabled; }
|
||||||
void SetDisplayTopMargin(s32 height) { m_display_top_margin = height; }
|
void SetDisplayTopMargin(s32 height) { m_display_top_margin = height; }
|
||||||
void SetDisplayIntegerScaling(bool enabled) { m_display_integer_scaling = enabled; }
|
void SetDisplayIntegerScaling(bool enabled) { m_display_integer_scaling = enabled; }
|
||||||
|
void SetDisplayAlignment(Alignment alignment) { m_display_alignment = alignment; }
|
||||||
|
|
||||||
/// Sets the software cursor to the specified texture. Ownership of the texture is transferred.
|
/// Sets the software cursor to the specified texture. Ownership of the texture is transferred.
|
||||||
void SetSoftwareCursor(std::unique_ptr<HostDisplayTexture> texture, float scale = 1.0f);
|
void SetSoftwareCursor(std::unique_ptr<HostDisplayTexture> texture, float scale = 1.0f);
|
||||||
|
@ -187,6 +195,7 @@ protected:
|
||||||
s32 m_display_texture_view_height = 0;
|
s32 m_display_texture_view_height = 0;
|
||||||
|
|
||||||
s32 m_display_top_margin = 0;
|
s32 m_display_top_margin = 0;
|
||||||
|
Alignment m_display_alignment = Alignment::Center;
|
||||||
|
|
||||||
std::unique_ptr<HostDisplayTexture> m_cursor_texture;
|
std::unique_ptr<HostDisplayTexture> m_cursor_texture;
|
||||||
float m_cursor_texture_scale = 1.0f;
|
float m_cursor_texture_scale = 1.0f;
|
||||||
|
|
Loading…
Reference in New Issue