From e62ca9a3986166f6a63a11426f9637dbcb8c6c4c Mon Sep 17 00:00:00 2001 From: asava Date: Sun, 19 Apr 2020 17:40:03 +0300 Subject: [PATCH] Correct positioning for legacy anime --- rEFIt_UEFI/refit/screen.cpp | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/rEFIt_UEFI/refit/screen.cpp b/rEFIt_UEFI/refit/screen.cpp index 7ae1161c5..4118680d5 100644 --- a/rEFIt_UEFI/refit/screen.cpp +++ b/rEFIt_UEFI/refit/screen.cpp @@ -437,14 +437,14 @@ VOID REFIT_MENU_SCREEN::InitAnime() // DBG("Path=%ls\n", FilmC->Path.wc_str()); // DBG("LastFrame=%lld\n\n", FilmC->LastFrameID()); + XImage FirstFrame = FilmC->GetImage(FilmC->LastFrameID()); //can not be absent + INTN CWidth = FirstFrame.GetWidth(); + INTN CHeight = FirstFrame.GetHeight(); if ((FilmC->FilmX >=0) && (FilmC->FilmX <=100) && (FilmC->FilmY >=0) && (FilmC->FilmY <=100)) { //default is 0xFFFF // Check if screen size being used is different from theme origination size. // If yes, then recalculate the animation placement % value. // This is necessary because screen can be a different size, but anim is not scaled. - XImage FirstFrame = FilmC->GetImage(FilmC->LastFrameID()); //can not be absent - INTN CWidth = FirstFrame.GetWidth(); - INTN CHeight = FirstFrame.GetHeight(); FilmC->FilmPlace.XPos = HybridRepositioning(FilmC->ScreenEdgeHorizontal, FilmC->FilmX, CWidth, UGAWidth, ThemeX.ThemeDesignWidth ); FilmC->FilmPlace.YPos = HybridRepositioning(FilmC->ScreenEdgeVertical, FilmC->FilmY, CHeight, UGAHeight, ThemeX.ThemeDesignHeight); @@ -459,6 +459,17 @@ VOID REFIT_MENU_SCREEN::InitAnime() // We are here if there is no anime, or if we use oldstyle placement values // For both these cases, FilmPlace will be set after banner/menutitle positions are known FilmC->FilmPlace = ThemeX.BannerPlace; + if (CWidth > 0 && CHeight > 0) { + // Retained for legacy themes without new anim placement options. + FilmC->FilmPlace.XPos += (FilmC->FilmPlace.Width - CWidth) / 2; + if (FilmC->FilmPlace.XPos < 0) { + FilmPlace.XPos = 0; + } + FilmC->FilmPlace.YPos += (FilmC->FilmPlace.Height - CHeight) / 2; + if (FilmC->FilmPlace.YPos < 0) { + FilmPlace.XPos = 0; + } + } } if (FilmC->NumFrames != 0) { DBG(" Anime seems OK, init it\n");