mirror of
https://github.com/RetroDECK/Duckstation.git
synced 2025-01-18 14:25:38 +00:00
FullscreenUI: Draw quick menu at screen bounds, not scaled bounds
This commit is contained in:
parent
8318cdb3c1
commit
28fdc5537f
|
@ -86,13 +86,6 @@ bool NoGUIHostInterface::CreateDisplay()
|
|||
return false;
|
||||
}
|
||||
|
||||
// imgui init from window
|
||||
ImGui::GetIO().DisplayFramebufferScale.x = wi->surface_scale;
|
||||
ImGui::GetIO().DisplayFramebufferScale.y = wi->surface_scale;
|
||||
ImGui::GetStyle() = ImGuiStyle();
|
||||
ImGui::GetStyle().ScaleAllSizes(wi->surface_scale);
|
||||
ImGui::StyleColorsDarker();
|
||||
|
||||
Assert(!m_display);
|
||||
switch (g_settings.gpu_renderer)
|
||||
{
|
||||
|
|
|
@ -1992,7 +1992,8 @@ void DrawSettingsWindow()
|
|||
void DrawQuickMenu(MainWindowType type)
|
||||
{
|
||||
ImDrawList* dl = ImGui::GetBackgroundDrawList();
|
||||
dl->AddRectFilled(ImVec2(0.0f, 0.0f), ImGui::GetIO().DisplaySize, IM_COL32(0x21, 0x21, 0x21, 200));
|
||||
const ImVec2 display_size(ImGui::GetIO().DisplaySize);
|
||||
dl->AddRectFilled(ImVec2(0.0f, 0.0f), display_size, IM_COL32(0x21, 0x21, 0x21, 200));
|
||||
|
||||
// title info
|
||||
{
|
||||
|
@ -2009,21 +2010,23 @@ void DrawQuickMenu(MainWindowType type)
|
|||
const ImVec2 subtitle_size(
|
||||
g_medium_font->CalcTextSizeA(g_medium_font->FontSize, std::numeric_limits<float>::max(), -1.0f, subtitle));
|
||||
|
||||
const ImVec2 title_pos(LayoutScale(LAYOUT_SCREEN_WIDTH - 20.0f - 50.0f - 20.0f) - title_size.x,
|
||||
LayoutScale(LAYOUT_SCREEN_HEIGHT - 20.0f - 50.0f));
|
||||
const ImVec2 subtitle_pos(LayoutScale(LAYOUT_SCREEN_WIDTH - 20.0f - 50.0f - 20.0f) - subtitle_size.x,
|
||||
const ImVec2 title_pos(display_size.x - LayoutScale(20.0f + 50.0f + 20.0f) - title_size.x,
|
||||
display_size.y - LayoutScale(20.0f + 50.0f));
|
||||
const ImVec2 subtitle_pos(display_size.x - LayoutScale(20.0f + 50.0f + 20.0f) - subtitle_size.x,
|
||||
title_pos.y + g_large_font->FontSize + LayoutScale(4.0f));
|
||||
|
||||
dl->AddText(g_large_font, g_large_font->FontSize, title_pos, IM_COL32(255, 255, 255, 255), title.c_str());
|
||||
dl->AddText(g_medium_font, g_medium_font->FontSize, subtitle_pos, IM_COL32(255, 255, 255, 255), subtitle);
|
||||
|
||||
const ImVec2 image_min(LayoutScale(LAYOUT_SCREEN_WIDTH - 20.0f - 50.0f, LAYOUT_SCREEN_HEIGHT - 20.0f - 50.0f));
|
||||
const ImVec2 image_min(display_size - LayoutScale(20.0f + 50.0f, 20.0f + 50.0f));
|
||||
const ImVec2 image_max(image_min + LayoutScale(50.0f, 50.0f));
|
||||
dl->AddImage(GetCoverForCurrentGame()->GetHandle(), image_min, image_max);
|
||||
}
|
||||
|
||||
if (BeginFullscreenWindow(0.0f, 0.0f, 500.0f, LAYOUT_SCREEN_HEIGHT, "pause_menu", ImVec4(0.0f, 0.0f, 0.0f, 0.0f),
|
||||
0.0f, 10.0f, ImGuiWindowFlags_NoBackground))
|
||||
const ImVec2 window_size(LayoutScale(500.0f, LAYOUT_SCREEN_HEIGHT));
|
||||
const ImVec2 window_pos(0.0f, display_size.y - window_size.y);
|
||||
if (BeginFullscreenWindow(window_pos, window_size, "pause_menu", ImVec4(0.0f, 0.0f, 0.0f, 0.0f), 0.0f, 10.0f,
|
||||
ImGuiWindowFlags_NoBackground))
|
||||
{
|
||||
BeginMenuButtons(11, 1.0f, ImGuiFullscreen::LAYOUT_MENU_BUTTON_X_PADDING,
|
||||
ImGuiFullscreen::LAYOUT_MENU_BUTTON_Y_PADDING,
|
||||
|
|
|
@ -291,8 +291,17 @@ bool BeginFullscreenWindow(float left, float top, float width, float height, con
|
|||
if (top < 0.0f)
|
||||
top = (LAYOUT_SCREEN_HEIGHT - height) * -top;
|
||||
|
||||
ImGui::SetNextWindowSize(LayoutScale(ImVec2(width, height)));
|
||||
ImGui::SetNextWindowPos(ImVec2(LayoutScale(left) + g_layout_padding_left, LayoutScale(top) + g_layout_padding_top));
|
||||
const ImVec2 pos(ImVec2(LayoutScale(left) + g_layout_padding_left, LayoutScale(top) + g_layout_padding_top));
|
||||
const ImVec2 size(LayoutScale(ImVec2(width, height)));
|
||||
return BeginFullscreenWindow(pos, size, name, background, rounding, padding, flags);
|
||||
}
|
||||
|
||||
bool BeginFullscreenWindow(const ImVec2& position, const ImVec2& size, const char* name,
|
||||
const ImVec4& background /* = HEX_TO_IMVEC4(0x212121, 0xFF) */, float rounding /*= 0.0f*/,
|
||||
float padding /*= 0.0f*/, ImGuiWindowFlags flags /*= 0*/)
|
||||
{
|
||||
ImGui::SetNextWindowPos(position);
|
||||
ImGui::SetNextWindowSize(size);
|
||||
|
||||
ImGui::PushStyleColor(ImGuiCol_WindowBg, background);
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, LayoutScale(padding, padding));
|
||||
|
|
|
@ -10,7 +10,7 @@ namespace ImGuiFullscreen {
|
|||
ImVec4(static_cast<float>((hex >> 16) & 0xFFu) / 255.0f, static_cast<float>((hex >> 8) & 0xFFu) / 255.0f, \
|
||||
static_cast<float>(hex & 0xFFu) / 255.0f, static_cast<float>(alpha) / 255.0f)
|
||||
|
||||
using ResolveTextureHandleCallback = ImTextureID(*)(const std::string& path);
|
||||
using ResolveTextureHandleCallback = ImTextureID (*)(const std::string& path);
|
||||
|
||||
static constexpr float LAYOUT_SCREEN_WIDTH = 1280.0f;
|
||||
static constexpr float LAYOUT_SCREEN_HEIGHT = 720.0f;
|
||||
|
@ -71,6 +71,11 @@ static ALWAYS_INLINE ImVec2 LayoutScale(float x, float y)
|
|||
return ImVec2(x * g_layout_scale, y * g_layout_scale);
|
||||
}
|
||||
|
||||
static ALWAYS_INLINE ImVec2 LayoutScaleAndOffset(float x, float y)
|
||||
{
|
||||
return ImVec2(g_layout_padding_left + x * g_layout_scale, g_layout_padding_top + y * g_layout_scale);
|
||||
}
|
||||
|
||||
static ALWAYS_INLINE ImVec4 UIPrimaryColor()
|
||||
{
|
||||
return HEX_TO_IMVEC4(0x212121, 0xff);
|
||||
|
@ -161,6 +166,9 @@ void EndFullscreenColumnWindow();
|
|||
bool BeginFullscreenWindow(float left, float top, float width, float height, const char* name,
|
||||
const ImVec4& background = HEX_TO_IMVEC4(0x212121, 0xFF), float rounding = 0.0f,
|
||||
float padding = 0.0f, ImGuiWindowFlags flags = 0);
|
||||
bool BeginFullscreenWindow(const ImVec2& position, const ImVec2& size, const char* name,
|
||||
const ImVec4& background = HEX_TO_IMVEC4(0x212121, 0xFF), float rounding = 0.0f,
|
||||
float padding = 0.0f, ImGuiWindowFlags flags = 0);
|
||||
void EndFullscreenWindow();
|
||||
|
||||
void BeginMenuButtons(u32 num_items = 0, float y_align = 0.0f, float x_padding = LAYOUT_MENU_BUTTON_X_PADDING,
|
||||
|
|
Loading…
Reference in a new issue