]> code.delx.au - refind/blobdiff - libeg/screen.c
0.6.8 version.
[refind] / libeg / screen.c
index da934cf3c6736c154398e41b218f35e3737741b2..9049d85ba224914a862264da5daa470261c895bf 100644 (file)
@@ -236,7 +236,6 @@ BOOLEAN egSetTextMode(UINT32 RequestedMode) {
    BOOLEAN       ChangedIt = FALSE;
 
    if ((RequestedMode != DONT_CHANGE_TEXT_MODE) && (RequestedMode != ST->ConOut->Mode->Mode)) {
-//      SwitchToGraphics();
       Status = refit_call2_wrapper(ST->ConOut->SetMode, ST->ConOut, RequestedMode);
       if (Status == EFI_SUCCESS) {
          ChangedIt = TRUE;
@@ -364,11 +363,6 @@ VOID egDrawImage(IN EG_IMAGE *Image, IN UINTN ScreenPosX, IN UINTN ScreenPosY)
         (ScreenPosX > egScreenWidth) || (ScreenPosY > egScreenHeight))
         return;
 
-//     if (Image->HasAlpha) {
-//         Image->HasAlpha = FALSE;
-//         egSetPlane(PLPTR(Image, a), 0, Image->Width * Image->Height);
-//     }
-
     if ((GlobalConfig.ScreenBackground == NULL) || ((Image->Width == egScreenWidth) && (Image->Height == egScreenHeight))) {
        CompImage = Image;
     } else if (GlobalConfig.ScreenBackground == Image) {
@@ -376,7 +370,7 @@ VOID egDrawImage(IN EG_IMAGE *Image, IN UINTN ScreenPosX, IN UINTN ScreenPosY)
     } else {
        CompImage = egCropImage(GlobalConfig.ScreenBackground, ScreenPosX, ScreenPosY, Image->Width, Image->Height);
        if (CompImage == NULL) {
-          Print(L"Error! Can't compose image in egDrawImage()!\n");
+          Print(L"Error! Can't crop image in egDrawImage()!\n");
           return;
        }
        egComposeImage(CompImage, Image, 0, 0);
@@ -393,6 +387,19 @@ VOID egDrawImage(IN EG_IMAGE *Image, IN UINTN ScreenPosX, IN UINTN ScreenPosY)
        egFreeImage(CompImage);
 } /* VOID egDrawImage() */
 
+// Display an unselected icon on the screen, so that the background image shows
+// through the transparency areas. The BadgeImage may be NULL, in which case
+// it's not composited in.
+VOID egDrawImageWithTransparency(EG_IMAGE *Image, EG_IMAGE *BadgeImage, UINTN XPos, UINTN YPos, UINTN Width, UINTN Height) {
+   EG_IMAGE *Background;
+
+   Background = egCropImage(GlobalConfig.ScreenBackground, XPos, YPos, Width, Height);
+   if (Background != NULL) {
+      BltImageCompositeBadge(Background, Image, BadgeImage, XPos, YPos);
+      egFreeImage(Background);
+   }
+} // VOID DrawImageWithTransparency()
+
 VOID egDrawImageArea(IN EG_IMAGE *Image,
                      IN UINTN AreaPosX, IN UINTN AreaPosY,
                      IN UINTN AreaWidth, IN UINTN AreaHeight,
@@ -405,11 +412,6 @@ VOID egDrawImageArea(IN EG_IMAGE *Image,
     if (AreaWidth == 0)
         return;
 
-//     if (Image->HasAlpha) {
-//         Image->HasAlpha = FALSE;
-//         egSetPlane(PLPTR(Image, a), 0, Image->Width * Image->Height);
-//     }
-
     if (GraphicsOutput != NULL) {
         refit_call10_wrapper(GraphicsOutput->Blt, GraphicsOutput, (EFI_GRAPHICS_OUTPUT_BLT_PIXEL *)Image->PixelData,
                              EfiBltBufferToVideo, AreaPosX, AreaPosY, ScreenPosX, ScreenPosY, AreaWidth, AreaHeight,
@@ -428,12 +430,13 @@ VOID egDisplayMessage(IN CHAR16 *Text, EG_PIXEL *BGColor) {
    EG_IMAGE *Box;
 
    if ((Text != NULL) && (BGColor != NULL)) {
-      BoxWidth = (StrLen(Text) + 2) * FONT_CELL_WIDTH;
+      egMeasureText(Text, &BoxWidth, &BoxHeight);
+      BoxWidth += 14;
+      BoxHeight *= 2;
       if (BoxWidth > egScreenWidth)
          BoxWidth = egScreenWidth;
-      BoxHeight = 2 * FONT_CELL_HEIGHT;
       Box = egCreateFilledImage(BoxWidth, BoxHeight, FALSE, BGColor);
-      egRenderText(Text, Box, FONT_CELL_WIDTH, FONT_CELL_HEIGHT / 2);
+      egRenderText(Text, Box, 7, BoxHeight / 4, (BGColor->r + BGColor->g + BGColor->b) / 3);
       egDrawImage(Box, (egScreenWidth - BoxWidth) / 2, (egScreenHeight - BoxHeight) / 2);
    } // if non-NULL inputs
 } // VOID egDisplayMessage()