diff --git a/rEFIt_UEFI/libeg/XTheme.h b/rEFIt_UEFI/libeg/XTheme.h index 89a409283..8989e4bd2 100644 --- a/rEFIt_UEFI/libeg/XTheme.h +++ b/rEFIt_UEFI/libeg/XTheme.h @@ -78,16 +78,19 @@ public: void Init(); XImage Background; //Background and Banner will not be in array as they live own life - XImage BigBack; //not sure is needed - XImage Banner; //same as logo in the array + XImage BigBack; //it size is not equal to screen size will be scaled or cropped + XImage Banner; //same as logo in the array, make a link? + //fill the theme XImage& GetIcon(XStringW& Name, BOOLEAN Night); //get by name XImage& GetIcon(INTN Id, BOOLEAN Night); //get by id void AddIcon(Icon& NewIcon); //return EFI_STATUS? - void FillByEmbedded(); - VOID ClearScreen(); + + //screen operations + void ClearScreen(); + VOID FillRectAreaOfScreen(IN INTN XPos, IN INTN YPos, IN INTN Width, IN INTN Height); XTheme(); //default constructor ~XTheme(); diff --git a/rEFIt_UEFI/refit/menu.cpp b/rEFIt_UEFI/refit/menu.cpp index 6ea18c6b1..9a5608d89 100644 --- a/rEFIt_UEFI/refit/menu.cpp +++ b/rEFIt_UEFI/refit/menu.cpp @@ -3830,7 +3830,7 @@ VOID DrawMainMenuEntry(REFIT_ABSTRACT_MENU_ENTRY *Entry, BOOLEAN selected, INTN } else { MainImage = Entry->Image; } - +//this should be inited by the Theme if (!MainImage) { if (!IsEmbeddedTheme()) { MainImage = egLoadIcon(ThemeDir, GetIconsExt(L"icons\\os_mac", L"icns"), Scale << 3); @@ -3843,14 +3843,40 @@ VOID DrawMainMenuEntry(REFIT_ABSTRACT_MENU_ENTRY *Entry, BOOLEAN selected, INTN } } // DBG("Entry title=%s; Width=%d\n", Entry->Title, MainImage->Width); +#if USE_XTHEME + float fScale; + if (TypeSVG) { + fScale = (selected ? 1.f : -1.f); + } else { + fScale = ((Entry->Row == 0) ? (MainEntriesSize/128.f * (selected ? 1.f : -1.f)): 1.f) ; + } + +#else if (GlobalConfig.TypeSVG) { Scale = 16 * (selected ? 1 : -1); } else { Scale = ((Entry->Row == 0) ? (Scale * (selected ? 1 : -1)): 16) ; } +#endif + if (Entry->Row == 0) { BadgeImage = Entry->getBadgeImage(); } //else null +#if USE_XTHEME + INTN index = ((Entry->Row == 0) ? 0 : 2) + (selected ? 0 : 1); + XImage& TopImage = *SelectionImages[index]; + + if(SelectionOnTop) { + BaseImage.Draw(XPos, YPos, fScale); + BadgeImage.Draw(XPos, YPos, fScale); + TopImage.Draw(XPos, YPos, fScale); + } else { + TopImage.Draw(XPos, YPos, fScale); + BaseImage.Draw(XPos, YPos, fScale); + BadgeImage.Draw(XPos, YPos, fScale); + } + +#else if (GlobalConfig.SelectionOnTop) { SelectionImages[0]->HasAlpha = TRUE; SelectionImages[2]->HasAlpha = TRUE; @@ -3865,13 +3891,13 @@ VOID DrawMainMenuEntry(REFIT_ABSTRACT_MENU_ENTRY *Entry, BOOLEAN selected, INTN BadgeImage, XPos, YPos, Scale); } - +#endif // draw BCS indicator // Needy: if Labels (Titles) are hidden there is no point to draw the indicator if (GlobalConfig.BootCampStyle && !(GlobalConfig.HideUIFlags & HIDEUI_FLAG_LABEL)) { SelectionImages[4]->HasAlpha = TRUE; - // inidcator is for row 0, main entries, only + // indicator is for row 0, main entries, only if (Entry->Row == 0) { BltImageAlpha(SelectionImages[4 + (selected ? 0 : 1)], XPos + (row0TileSize / 2) - (INTN)(INDICATOR_SIZE * 0.5f * GlobalConfig.Scale), @@ -3890,7 +3916,16 @@ VOID DrawMainMenuEntry(REFIT_ABSTRACT_MENU_ENTRY *Entry, BOOLEAN selected, INTN egFreeImage(MainImage); } } - +//the purpose of the procedure is restore Background in rect +//XAlign is always centre, Color is the Backgrounf fill +#if USE_XTHEME +VOID XTheme::FillRectAreaOfScreen(IN INTN XPos, IN INTN YPos, IN INTN Width, IN INTN Height) +{ + XImage TmpBuffer(Width, Height); + TmpBuffer.CopyScaled(Background, 1.f); + TmpBuffer.Draw(XPos, YPos); +} +#else VOID FillRectAreaOfScreen(IN INTN XPos, IN INTN YPos, IN INTN Width, IN INTN Height, IN EG_PIXEL *Color, IN UINT8 XAlign) { EG_IMAGE *TmpBuffer = NULL; @@ -3911,6 +3946,7 @@ VOID FillRectAreaOfScreen(IN INTN XPos, IN INTN YPos, IN INTN Width, IN INTN Hei BltImage(TmpBuffer, X, YPos); egFreeImage(TmpBuffer); } +#endif VOID REFIT_MENU_SCREEN::DrawMainMenuLabel(IN CONST CHAR16 *Text, IN INTN XPos, IN INTN YPos) { diff --git a/rEFIt_UEFI/refit/screen.cpp b/rEFIt_UEFI/refit/screen.cpp index 12c978389..7e651f55c 100644 --- a/rEFIt_UEFI/refit/screen.cpp +++ b/rEFIt_UEFI/refit/screen.cpp @@ -396,9 +396,13 @@ BOOLEAN CheckError(IN EFI_STATUS Status, IN CONST CHAR16 *where) VOID SwitchToGraphicsAndClear(VOID) //called from MENU_FUNCTION_INIT { SwitchToGraphics(); - if (GraphicsScreenDirty) { +#if USE_XTHEME + Theme.ClearScreen(); +#else + if (GraphicsScreenDirty) { //Invented in rEFIt 15 years ago BltClearScreen(); } +#endif } /* @@ -408,10 +412,11 @@ typedef struct { INTN Width; INTN Height; } EG_RECT; + //same as EgRect but INTN <-> UINTN */ #if USE_XTHEME -VOID XTheme::BltClearScreen() +VOID XTheme::ClearScreen() { if (BanHeight < 2) { BanHeight = ((UGAHeight - (int)(LayoutHeight * Scale)) >> 1); @@ -736,7 +741,8 @@ VOID BltImageAlpha(IN EG_IMAGE *Image, IN INTN XPos, IN INTN YPos, IN EG_PIXEL * egDrawImageArea(NewImage, 0, 0, 0, 0, XPos, YPos); egFreeImage(NewImage); } - +//not used +/* VOID BltImageComposite(IN EG_IMAGE *BaseImage, IN EG_IMAGE *TopImage, IN INTN XPos, IN INTN YPos) { INTN TotalWidth, TotalHeight, CompWidth, CompHeight, OffsetX, OffsetY; @@ -768,7 +774,7 @@ VOID BltImageComposite(IN EG_IMAGE *BaseImage, IN EG_IMAGE *TopImage, IN INTN XP egFreeImage(CompImage); GraphicsScreenDirty = TRUE; } - +*/ /* -------------------------------------------------------------------- Pos : Bottom -> Mid -> Top @@ -780,6 +786,21 @@ VOID BltImageComposite(IN EG_IMAGE *BaseImage, IN EG_IMAGE *TopImage, IN INTN XP BaseImage = MainImage, TopImage = Selection */ +#if USE_XTHEME +/* +// TopImage = SelectionImages[index] +// The procedure will be replaced by +if(SelectionOnTop) { + BaseImage.Draw(XPos, YPos, Scale/16.f); + BadgeImage.Draw(XPos, YPos, Scale/16.f); + TopImage.Draw(XPos, YPos, Scale/16.f); +} else { + TopImage.Draw(XPos, YPos, Scale/16.f); + BaseImage.Draw(XPos, YPos, Scale/16.f); + BadgeImage.Draw(XPos, YPos, Scale/16.f); +} + */ +#else VOID BltImageCompositeBadge(IN EG_IMAGE *BaseImage, IN EG_IMAGE *TopImage, IN EG_IMAGE *BadgeImage, IN INTN XPos, IN INTN YPos, INTN Scale) { INTN TotalWidth, TotalHeight, CompWidth, CompHeight, OffsetX, OffsetY, OffsetXTmp, OffsetYTmp; @@ -901,7 +922,8 @@ VOID BltImageCompositeBadge(IN EG_IMAGE *BaseImage, IN EG_IMAGE *TopImage, IN EG egFreeImage(NewTopImage); GraphicsScreenDirty = TRUE; } - +#endif + #define MAX_SIZE_ANIME 256 VOID FreeAnime(GUI_ANIME *Anime) diff --git a/rEFIt_UEFI/refit/screen.h b/rEFIt_UEFI/refit/screen.h index d2b543679..df26ed319 100644 --- a/rEFIt_UEFI/refit/screen.h +++ b/rEFIt_UEFI/refit/screen.h @@ -20,6 +20,6 @@ VOID SwitchToGraphicsAndClear(VOID); VOID BltClearScreen(); VOID BltImage(IN EG_IMAGE *Image, IN INTN XPos, IN INTN YPos); VOID BltImageAlpha(IN EG_IMAGE *Image, IN INTN XPos, IN INTN YPos, IN EG_PIXEL *BackgroundPixel, INTN Scale); -VOID BltImageComposite(IN EG_IMAGE *BaseImage, IN EG_IMAGE *TopImage, IN INTN XPos, IN INTN YPos); +//VOID BltImageComposite(IN EG_IMAGE *BaseImage, IN EG_IMAGE *TopImage, IN INTN XPos, IN INTN YPos); VOID BltImageCompositeBadge(IN EG_IMAGE *BaseImage, IN EG_IMAGE *TopImage, IN EG_IMAGE *BadgeImage, IN INTN XPos, IN INTN YPos, INTN Scale); //VOID BltImageCompositeIndicator(IN EG_IMAGE *BaseImage, IN EG_IMAGE *TopImage, IN INTN XPos, IN INTN YPos, INTN Scale);