From 984554fe7cc757684c5cfbe13651e53b7ff22176 Mon Sep 17 00:00:00 2001 From: Henrik Rydgard Date: Mon, 10 Feb 2014 16:08:19 +0100 Subject: [PATCH] Make the UI scale and move correctly when the UI bounds are modified. --- UI/EmuScreen.cpp | 6 +++--- UI/MiscScreens.cpp | 24 +++++++++++++----------- UI/NativeApp.cpp | 3 +++ native | 2 +- 4 files changed, 20 insertions(+), 15 deletions(-) diff --git a/UI/EmuScreen.cpp b/UI/EmuScreen.cpp index 9b8a4d5e31..6fb4fc70b3 100644 --- a/UI/EmuScreen.cpp +++ b/UI/EmuScreen.cpp @@ -647,10 +647,10 @@ void EmuScreen::render() { return; } - float xres = screenManager()->getUIContext()->GetBounds().w; + const Bounds &bounds = screenManager()->getUIContext()->GetBounds(); ui_draw2d.SetFontScale(0.7f, 0.7f); - ui_draw2d.DrawText(UBUNTU24, fpsbuf, xres - 8, 12, 0xc0000000, ALIGN_TOPRIGHT | FLAG_DYNAMIC_ASCII); - ui_draw2d.DrawText(UBUNTU24, fpsbuf, xres - 10, 10, 0xFF3fFF3f, ALIGN_TOPRIGHT | FLAG_DYNAMIC_ASCII); + ui_draw2d.DrawText(UBUNTU24, fpsbuf, bounds.x2() - 8, 12, 0xc0000000, ALIGN_TOPRIGHT | FLAG_DYNAMIC_ASCII); + ui_draw2d.DrawText(UBUNTU24, fpsbuf, bounds.x2() - 10, 10, 0xFF3fFF3f, ALIGN_TOPRIGHT | FLAG_DYNAMIC_ASCII); ui_draw2d.SetFontScale(1.0f, 1.0f); } diff --git a/UI/MiscScreens.cpp b/UI/MiscScreens.cpp index d2bf6c7228..a830f2643a 100644 --- a/UI/MiscScreens.cpp +++ b/UI/MiscScreens.cpp @@ -92,11 +92,11 @@ void DrawBackground(UIContext &dc, float alpha = 1.0f) { #ifdef GOLD img = I_BG_GOLD; #endif - ui_draw2d.DrawImageStretch(img, 0, 0, xres, yres); + ui_draw2d.DrawImageStretch(img, dc.GetBounds()); float t = time_now(); for (int i = 0; i < 100; i++) { - float x = xbase[i]; - float y = ybase[i] + 40 * cosf(i * 7.2f + t * 1.3f); + float x = xbase[i] + dc.GetBounds().x; + float y = ybase[i] + dc.GetBounds().y + 40 * cosf(i * 7.2f + t * 1.3f); float angle = sinf(i + t); int n = i & 3; ui_draw2d.DrawImageRotated(symbols[n], x, y, 1.0f, angle, colorAlpha(colors[n], alpha * 0.1f)); @@ -118,7 +118,7 @@ void DrawGameBackground(UIContext &dc, const std::string &gamePath) { } if (hasPic) { uint32_t color = whiteAlpha(ease((time_now_d() - ginfo->timePic1WasLoaded) * 3)) & 0xFFc0c0c0; - dc.Draw()->DrawTexRect(0,0, dc.GetBounds().w, dc.GetBounds().h, 0,0,1,1, color); + dc.Draw()->DrawTexRect(dc.GetBounds(), 0,0,1,1, color); dc.Flush(); dc.RebindTexture(); } else { @@ -370,6 +370,8 @@ void LogoScreen::render() { UIContext &dc = *screenManager()->getUIContext(); + const Bounds &bounds = dc.GetBounds(); + float xres = dc.GetBounds().w; float yres = dc.GetBounds().h; @@ -389,19 +391,19 @@ void LogoScreen::render() { char temp[256]; sprintf(temp, "%s Henrik Rydg\xc3\xa5rd", c->T("created", "Created by")); #ifdef GOLD - dc.Draw()->DrawImage(I_ICONGOLD, (xres / 2) - 120, (yres / 2) - 30, 1.2f, colorAlpha(0xFFFFFFFF, alphaText), ALIGN_CENTER); + dc.Draw()->DrawImage(I_ICONGOLD, bounds.centerX() - 120, bounds.centerY() - 30, 1.2f, colorAlpha(0xFFFFFFFF, alphaText), ALIGN_CENTER); #else - dc.Draw()->DrawImage(I_ICON, (xres / 2) - 120, (yres / 2) - 30, 1.2f, colorAlpha(0xFFFFFFFF, alphaText), ALIGN_CENTER); + dc.Draw()->DrawImage(I_ICON, bounds.centerX() - 120, bounds.centerY() - 30, 1.2f, colorAlpha(0xFFFFFFFF, alphaText), ALIGN_CENTER); #endif - dc.Draw()->DrawImage(I_LOGO, (xres / 2) + 40, yres / 2 - 30, 1.5f, colorAlpha(0xFFFFFFFF, alphaText), ALIGN_CENTER); + dc.Draw()->DrawImage(I_LOGO, bounds.centerX() + 40, bounds.centerY() - 30, 1.5f, colorAlpha(0xFFFFFFFF, alphaText), ALIGN_CENTER); //dc.Draw()->DrawTextShadow(UBUNTU48, "PPSSPP", xres / 2, yres / 2 - 30, colorAlpha(0xFFFFFFFF, alphaText), ALIGN_CENTER); dc.Draw()->SetFontScale(1.0f, 1.0f); dc.SetFontStyle(dc.theme->uiFont); - dc.DrawText(temp, xres / 2, yres / 2 + 40, colorAlpha(0xFFFFFFFF, alphaText), ALIGN_CENTER); - dc.DrawText(c->T("license", "Free Software under GPL 2.0"), xres / 2, yres / 2 + 70, colorAlpha(0xFFFFFFFF, alphaText), ALIGN_CENTER); - dc.DrawText("www.ppsspp.org", xres / 2, yres / 2 + 130, colorAlpha(0xFFFFFFFF, alphaText), ALIGN_CENTER); + dc.DrawText(temp, bounds.centerX(), bounds.centerY() + 40, colorAlpha(0xFFFFFFFF, alphaText), ALIGN_CENTER); + dc.DrawText(c->T("license", "Free Software under GPL 2.0"), bounds.centerX(), bounds.centerY() + 70, colorAlpha(0xFFFFFFFF, alphaText), ALIGN_CENTER); + dc.DrawText("www.ppsspp.org", bounds.centerX(), yres / 2 + 130, colorAlpha(0xFFFFFFFF, alphaText), ALIGN_CENTER); if (boot_filename.size()) { - ui_draw2d.DrawTextShadow(UBUNTU24, boot_filename.c_str(), xres / 2, yres / 2 + 180, colorAlpha(0xFFFFFFFF, alphaText), ALIGN_CENTER); + ui_draw2d.DrawTextShadow(UBUNTU24, boot_filename.c_str(), bounds.centerX(), bounds.centerY() + 180, colorAlpha(0xFFFFFFFF, alphaText), ALIGN_CENTER); } dc.End(); diff --git a/UI/NativeApp.cpp b/UI/NativeApp.cpp index 6ac882bf20..cee8b9b715 100644 --- a/UI/NativeApp.cpp +++ b/UI/NativeApp.cpp @@ -784,7 +784,10 @@ void NativeMessageReceived(const char *message, const char *value) { void NativeResized() { if (uiContext) { + // Modifying the bounds here can be used to "inset" the whole image to gain borders for TV overscan etc. + // The UI now supports any offset but not the EmuScreen yet. uiContext->SetBounds(Bounds(0, 0, dp_xres, dp_yres)); + // uiContext->SetBounds(Bounds(dp_xres/2, 0, dp_xres / 2, dp_yres / 2)); } } diff --git a/native b/native index 52a7af1ed3..35e00807d3 160000 --- a/native +++ b/native @@ -1 +1 @@ -Subproject commit 52a7af1ed33af7f1244d4c09de8e3da6a7b47dc5 +Subproject commit 35e00807d3c762cc9f799121636790e97b2a757b