From af047db78d297ca33dd74e5e749166bb17a4cc4e Mon Sep 17 00:00:00 2001 From: Eric Dong Date: Fri, 27 Sep 2013 12:19:51 +0000 Subject: Fix form flash issue. Signed-off-by: Eric Dong Reviewed-by: Liming Gao git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@14735 6f19259b-4bc3-4df7-8a09-765794883524 --- .../CustomizedDisplayLib/CustomizedDisplayLib.c | 103 +++++++++++++-------- .../CustomizedDisplayLib/CustomizedDisplayLib.inf | 35 +++---- .../CustomizedDisplayLibInternal.c | 100 +++++++++++++------- .../CustomizedDisplayLibInternal.h | 4 +- 4 files changed, 146 insertions(+), 96 deletions(-) (limited to 'MdeModulePkg/Library/CustomizedDisplayLib') diff --git a/MdeModulePkg/Library/CustomizedDisplayLib/CustomizedDisplayLib.c b/MdeModulePkg/Library/CustomizedDisplayLib/CustomizedDisplayLib.c index aa28146..4328761 100644 --- a/MdeModulePkg/Library/CustomizedDisplayLib/CustomizedDisplayLib.c +++ b/MdeModulePkg/Library/CustomizedDisplayLib/CustomizedDisplayLib.c @@ -144,6 +144,12 @@ RefreshKeyHelp ( EFI_IFR_DATE *DateOp; EFI_IFR_TIME *TimeOp; BOOLEAN HexDisplay; + UINTN ColumnWidth1; + UINTN ColumnWidth2; + UINTN ColumnWidth3; + CHAR16 *ColumnStr1; + CHAR16 *ColumnStr2; + CHAR16 *ColumnStr3; ASSERT (FormData != NULL); if (FormData == NULL) { @@ -161,17 +167,27 @@ RefreshKeyHelp ( StartColumnOfHelp = gScreenDimensions.LeftColumn + 2; LeftColumnOfHelp = gScreenDimensions.LeftColumn + 1; - RightColumnOfHelp = gScreenDimensions.RightColumn - 2; + RightColumnOfHelp = gScreenDimensions.RightColumn - 1; TopRowOfHelp = gScreenDimensions.BottomRow - STATUS_BAR_HEIGHT - gFooterHeight + 1; BottomRowOfHelp = gScreenDimensions.BottomRow - STATUS_BAR_HEIGHT - 2; - ClearLines (LeftColumnOfHelp, RightColumnOfHelp, TopRowOfHelp, BottomRowOfHelp, KEYHELP_TEXT | KEYHELP_BACKGROUND); + ColumnWidth1 = SecCol - StartColumnOfHelp; + ColumnWidth2 = ThdCol - SecCol; + ColumnWidth3 = RightColumnOfHelp - ThdCol; + ColumnStr1 = gLibEmptyString; + ColumnStr2 = gLibEmptyString; + ColumnStr3 = gLibEmptyString; + if (Statement == NULL) { // // Print Key for Form without showable statement. // - PrintHotKeyHelpString (FormData); - PrintStringAt (ThdCol, BottomRowOfHelp, gEscapeString); + PrintHotKeyHelpString (FormData, TRUE); + PrintStringAtWithWidth (StartColumnOfHelp, BottomRowOfHelp, gLibEmptyString, ColumnWidth1); + PrintStringAtWithWidth (SecCol, BottomRowOfHelp, gLibEmptyString, ColumnWidth2); + PrintStringAtWithWidth (StartColumnOfHelp, TopRowOfHelp, gLibEmptyString, ColumnWidth1); + PrintStringAtWithWidth (ThdCol, BottomRowOfHelp, gEscapeString, ColumnWidth3); + return; } @@ -196,16 +212,17 @@ RefreshKeyHelp ( case EFI_IFR_TIME_OP: case EFI_IFR_DATE_OP: if (!Selected) { - PrintHotKeyHelpString (FormData); + PrintHotKeyHelpString (FormData, TRUE); if (gClassOfVfr == FORMSET_CLASS_PLATFORM_SETUP) { - PrintStringAt (ThdCol, BottomRowOfHelp, gEscapeString); + ColumnStr3 = gEscapeString; } + PrintStringAtWithWidth (ThdCol, BottomRowOfHelp, ColumnStr3, ColumnWidth3); if ((Statement->OpCode->OpCode == EFI_IFR_DATE_OP) || (Statement->OpCode->OpCode == EFI_IFR_TIME_OP)) { PrintAt ( - 0, + ColumnWidth1, StartColumnOfHelp, BottomRowOfHelp, L"%c%c%c%c%s", @@ -215,17 +232,19 @@ RefreshKeyHelp ( ARROW_LEFT, gMoveHighlight ); - PrintStringAt (SecCol, BottomRowOfHelp, gEnterString); - PrintStringAt (StartColumnOfHelp, TopRowOfHelp, gAdjustNumber); + PrintStringAtWithWidth (SecCol, BottomRowOfHelp, gEnterString, ColumnWidth2); + PrintStringAtWithWidth (StartColumnOfHelp, TopRowOfHelp, gAdjustNumber, ColumnWidth1); } else { - PrintAt (0, StartColumnOfHelp, BottomRowOfHelp, L"%c%c%s", ARROW_UP, ARROW_DOWN, gMoveHighlight); + PrintAt (ColumnWidth1, StartColumnOfHelp, BottomRowOfHelp, L"%c%c%s", ARROW_UP, ARROW_DOWN, gMoveHighlight); if (Statement->OpCode->OpCode == EFI_IFR_NUMERIC_OP && NumericOp != NULL && LibGetFieldFromNum(Statement->OpCode) != 0) { - PrintStringAt (StartColumnOfHelp, TopRowOfHelp, gAdjustNumber); - } - PrintStringAt (SecCol, BottomRowOfHelp, gEnterString); + ColumnStr1 = gAdjustNumber; + } + PrintStringAtWithWidth (StartColumnOfHelp, TopRowOfHelp, ColumnStr1, ColumnWidth1); + PrintStringAtWithWidth (SecCol, BottomRowOfHelp, gEnterString, ColumnWidth2); } } else { - PrintStringAt (SecCol, BottomRowOfHelp, gEnterCommitString); + PrintHotKeyHelpString (FormData, FALSE); + PrintStringAtWithWidth (SecCol, BottomRowOfHelp, gEnterCommitString, ColumnWidth2); // // If it is a selected numeric with manual input, display different message @@ -233,33 +252,35 @@ RefreshKeyHelp ( if ((Statement->OpCode->OpCode == EFI_IFR_NUMERIC_OP) || (Statement->OpCode->OpCode == EFI_IFR_DATE_OP) || (Statement->OpCode->OpCode == EFI_IFR_TIME_OP)) { - PrintStringAt ( - SecCol, - TopRowOfHelp, - HexDisplay ? gHexNumericInput : gDecNumericInput - ); - } else if (Statement->OpCode->OpCode != EFI_IFR_ORDERED_LIST_OP) { - PrintAt (0, StartColumnOfHelp, BottomRowOfHelp, L"%c%c%s", ARROW_UP, ARROW_DOWN, gMoveHighlight); + ColumnStr2 = HexDisplay ? gHexNumericInput : gDecNumericInput; + PrintStringAtWithWidth (StartColumnOfHelp, BottomRowOfHelp, gLibEmptyString, ColumnWidth1); + } else { + PrintAt (ColumnWidth1, StartColumnOfHelp, BottomRowOfHelp, L"%c%c%s", ARROW_UP, ARROW_DOWN, gMoveHighlight); } if (Statement->OpCode->OpCode == EFI_IFR_ORDERED_LIST_OP) { - PrintStringAt (StartColumnOfHelp, TopRowOfHelp, gPlusString); - PrintStringAt (ThdCol, TopRowOfHelp, gMinusString); + ColumnStr1 = gPlusString; + ColumnStr3 = gMinusString; } + PrintStringAtWithWidth (StartColumnOfHelp, TopRowOfHelp, ColumnStr1, ColumnWidth1); + PrintStringAtWithWidth (ThdCol, TopRowOfHelp, ColumnStr3, ColumnWidth3); + PrintStringAtWithWidth (SecCol, TopRowOfHelp, ColumnStr2, ColumnWidth2); - PrintStringAt (ThdCol, BottomRowOfHelp, gEnterEscapeString); + PrintStringAtWithWidth (ThdCol, BottomRowOfHelp, gEnterEscapeString, ColumnWidth3); } break; case EFI_IFR_CHECKBOX_OP: - PrintHotKeyHelpString (FormData); + PrintHotKeyHelpString (FormData, TRUE); if (gClassOfVfr == FORMSET_CLASS_PLATFORM_SETUP) { - PrintStringAt (ThdCol, BottomRowOfHelp, gEscapeString); + ColumnStr3 = gEscapeString; } + PrintStringAtWithWidth (ThdCol, BottomRowOfHelp, ColumnStr3, ColumnWidth3); - PrintAt (0, StartColumnOfHelp, BottomRowOfHelp, L"%c%c%s", ARROW_UP, ARROW_DOWN, gMoveHighlight); - PrintStringAt (SecCol, BottomRowOfHelp, gToggleCheckBox); + PrintAt (ColumnWidth1, StartColumnOfHelp, BottomRowOfHelp, L"%c%c%s", ARROW_UP, ARROW_DOWN, gMoveHighlight); + PrintStringAtWithWidth (SecCol, BottomRowOfHelp, gToggleCheckBox, ColumnWidth2); + PrintStringAtWithWidth (StartColumnOfHelp, TopRowOfHelp, gLibEmptyString, ColumnWidth1); break; case EFI_IFR_REF_OP: @@ -270,25 +291,29 @@ RefreshKeyHelp ( case EFI_IFR_RESET_BUTTON_OP: case EFI_IFR_SUBTITLE_OP: if (!Selected) { - PrintHotKeyHelpString (FormData); + PrintHotKeyHelpString (FormData, TRUE); if (gClassOfVfr == FORMSET_CLASS_PLATFORM_SETUP) { - PrintStringAt (ThdCol, BottomRowOfHelp, gEscapeString); + ColumnStr3 = gEscapeString; } + PrintStringAtWithWidth (ThdCol, BottomRowOfHelp, ColumnStr3, ColumnWidth3); - PrintAt (0, StartColumnOfHelp, BottomRowOfHelp, L"%c%c%s", ARROW_UP, ARROW_DOWN, gMoveHighlight); + PrintAt (ColumnWidth1, StartColumnOfHelp, BottomRowOfHelp, L"%c%c%s", ARROW_UP, ARROW_DOWN, gMoveHighlight); if (Statement->OpCode->OpCode != EFI_IFR_TEXT_OP && Statement->OpCode->OpCode != EFI_IFR_SUBTITLE_OP) { - PrintStringAt (SecCol, BottomRowOfHelp, gEnterString); + ColumnStr2 = gEnterString; } + PrintStringAtWithWidth (SecCol, BottomRowOfHelp, ColumnStr2, ColumnWidth2); + PrintStringAtWithWidth (StartColumnOfHelp, TopRowOfHelp, ColumnStr1, ColumnWidth1); } else { - if (Statement->OpCode->OpCode != EFI_IFR_REF_OP) { - PrintStringAt ( - (gScreenDimensions.RightColumn - LibGetStringWidth (gEnterCommitString) / 2) / 2, - BottomRowOfHelp, - gEnterCommitString - ); - PrintStringAt (ThdCol, BottomRowOfHelp, gEnterEscapeString); + PrintHotKeyHelpString (FormData, FALSE); + if (Statement->OpCode->OpCode != EFI_IFR_REF_OP) { + ColumnStr2 = gEnterCommitString; + ColumnStr3 = gEnterEscapeString; } + PrintStringAtWithWidth (StartColumnOfHelp, TopRowOfHelp, ColumnStr1, ColumnWidth1); + PrintStringAtWithWidth (StartColumnOfHelp, BottomRowOfHelp, ColumnStr1, ColumnWidth1); + PrintStringAtWithWidth (SecCol, BottomRowOfHelp, ColumnStr2, ColumnWidth2); + PrintStringAtWithWidth (ThdCol, BottomRowOfHelp, ColumnStr3, ColumnWidth3); } break; diff --git a/MdeModulePkg/Library/CustomizedDisplayLib/CustomizedDisplayLib.inf b/MdeModulePkg/Library/CustomizedDisplayLib/CustomizedDisplayLib.inf index ade45b6..841e013 100644 --- a/MdeModulePkg/Library/CustomizedDisplayLib/CustomizedDisplayLib.inf +++ b/MdeModulePkg/Library/CustomizedDisplayLib/CustomizedDisplayLib.inf @@ -1,27 +1,16 @@ -## -# This file contains an 'Intel Peripheral Driver' and is -# licensed for Intel CPUs and chipsets under the terms of your -# license agreement with Intel or your vendor. This file may -# be modified by the user, subject to additional terms of the -# license agreement -## ## @file -# -# General BDS defines and produce general interfaces for platform BDS driver including: -# 1) BDS boot policy interface; -# 2) BDS boot device connect interface; -# 3) BDS Misc interfaces for mainting boot variable, ouput string, etc. -# -# Copyright (c) 2007 - 2010, Intel Corporation. All rights reserved.
-# This software and associated documentation (if any) is furnished -# under a license and may only be used or copied in accordance -# with the terms of the license. Except as permitted by such -# license, no part of this software or documentation may be -# reproduced, stored in a retrieval system, or transmitted in any -# form or by any means without the express written consent of -# Intel Corporation. -# -## +# Customize display library used by display engine. +# +# Copyright (c) 2013, Intel Corporation. All rights reserved.
+# +# This program and the accompanying materials +# are licensed and made available under the terms and conditions of the BSD License +# which accompanies this distribution. The full text of the license may be found at +# http://opensource.org/licenses/bsd-license.php +# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +# +# [Defines] INF_VERSION = 0x00010005 diff --git a/MdeModulePkg/Library/CustomizedDisplayLib/CustomizedDisplayLibInternal.c b/MdeModulePkg/Library/CustomizedDisplayLib/CustomizedDisplayLibInternal.c index b6b4055..82ab82b 100644 --- a/MdeModulePkg/Library/CustomizedDisplayLib/CustomizedDisplayLibInternal.c +++ b/MdeModulePkg/Library/CustomizedDisplayLib/CustomizedDisplayLibInternal.c @@ -144,6 +144,7 @@ PrintFramework ( CHAR16 *Buffer; UINTN Row; CHAR16 *TitleStr; + UINTN TitleColumn; if (gClassOfVfr != FORMSET_CLASS_PLATFORM_SETUP) { // @@ -190,20 +191,15 @@ PrintFramework ( // // Print Form Title // - ClearLines ( - gScreenDimensions.LeftColumn + 1, - gScreenDimensions.RightColumn - 1, - gScreenDimensions.TopRow + 1, - gScreenDimensions.TopRow + 1, - TITLE_TEXT | TITLE_BACKGROUND - ); - TitleStr = LibGetToken (FormData->FormTitle, FormData->HiiHandle); ASSERT (TitleStr != NULL); - PrintStringAt ( - (gScreenDimensions.RightColumn + gScreenDimensions.LeftColumn - LibGetStringWidth (TitleStr) / 2) / 2, + TitleColumn = (gScreenDimensions.RightColumn + gScreenDimensions.LeftColumn - LibGetStringWidth (TitleStr) / 2) / 2; + PrintStringAtWithWidth (gScreenDimensions.LeftColumn + 1, gScreenDimensions.TopRow + 1, gLibEmptyString, TitleColumn - gScreenDimensions.LeftColumn - 1); + PrintStringAtWithWidth ( + TitleColumn, gScreenDimensions.TopRow + 1, - TitleStr + TitleStr, + gScreenDimensions.RightColumn - 1 - TitleColumn ); FreePool (TitleStr); @@ -524,29 +520,32 @@ LibGetStringWidth ( Show all registered HotKey help strings on bottom Rows. @param FormData The curent input form data info. + @param SetState Set HotKey or Clear HotKey **/ VOID PrintHotKeyHelpString ( - IN FORM_DISPLAY_ENGINE_FORM *FormData + IN FORM_DISPLAY_ENGINE_FORM *FormData, + IN BOOLEAN SetState ) { UINTN CurrentCol; UINTN CurrentRow; UINTN BottomRowOfHotKeyHelp; + UINTN ColumnIndexWidth; UINTN ColumnWidth; + UINTN ColumnIndex; UINTN Index; EFI_SCREEN_DESCRIPTOR LocalScreen; LIST_ENTRY *Link; BROWSER_HOT_KEY *HotKey; - - if (IsListEmpty (&FormData->HotKeyListHead)) { - return; - } + CHAR16 BakChar; + CHAR16 *ColumnStr; CopyMem (&LocalScreen, &gScreenDimensions, sizeof (EFI_SCREEN_DESCRIPTOR)); ColumnWidth = (LocalScreen.RightColumn - LocalScreen.LeftColumn) / 3; BottomRowOfHotKeyHelp = LocalScreen.BottomRow - STATUS_BAR_HEIGHT - 3; + ColumnStr = gLibEmptyString; // // Calculate total number of Register HotKeys. @@ -556,25 +555,41 @@ PrintHotKeyHelpString ( while (!IsNull (&FormData->HotKeyListHead, Link)) { HotKey = BROWSER_HOT_KEY_FROM_LINK (Link); // - // Help string can't exceed ColumnWidth. One Row will show three Help information. - // - if (StrLen (HotKey->HelpString) > ColumnWidth) { - HotKey->HelpString[ColumnWidth] = L'\0'; - } - // // Calculate help information Column and Row. // - if ((Index % 3) != 2) { - CurrentCol = LocalScreen.LeftColumn + (2 - Index % 3) * ColumnWidth; + ColumnIndex = Index % 3; + if (ColumnIndex == 0) { + CurrentCol = LocalScreen.LeftColumn + 2 * ColumnWidth; + ColumnIndexWidth = ColumnWidth - 1; + } else if (ColumnIndex == 1) { + CurrentCol = LocalScreen.LeftColumn + ColumnWidth; + ColumnIndexWidth = ColumnWidth; } else { - CurrentCol = LocalScreen.LeftColumn + 2; + CurrentCol = LocalScreen.LeftColumn + 2; + ColumnIndexWidth = ColumnWidth - 2; } CurrentRow = BottomRowOfHotKeyHelp - Index / 3; + + // + // Help string can't exceed ColumnWidth. One Row will show three Help information. + // + BakChar = L'\0'; + if (StrLen (HotKey->HelpString) > ColumnIndexWidth) { + BakChar = HotKey->HelpString[ColumnIndexWidth]; + HotKey->HelpString[ColumnIndexWidth] = L'\0'; + } + // // Print HotKey help string on bottom Row. // - PrintStringAt (CurrentCol, CurrentRow, HotKey->HelpString); + if (SetState) { + ColumnStr = HotKey->HelpString; + } + PrintStringAtWithWidth (CurrentCol, CurrentRow, ColumnStr, ColumnIndexWidth); + if (BakChar != L'\0') { + HotKey->HelpString[ColumnIndexWidth] = BakChar; + } // // Get Next Hot Key. // @@ -582,6 +597,25 @@ PrintHotKeyHelpString ( Index ++; } + if (SetState) { + // + // Clear KeyHelp + // + CurrentRow = BottomRowOfHotKeyHelp - Index / 3; + ColumnIndex = Index % 3; + if (ColumnIndex == 0) { + CurrentCol = LocalScreen.LeftColumn + 2 * ColumnWidth; + ColumnIndexWidth = ColumnWidth - 1; + ColumnIndex ++; + PrintStringAtWithWidth (CurrentCol, CurrentRow, gLibEmptyString, ColumnIndexWidth); + } + if (ColumnIndex == 1) { + CurrentCol = LocalScreen.LeftColumn + ColumnWidth; + ColumnIndexWidth = ColumnWidth; + PrintStringAtWithWidth (CurrentCol, CurrentRow, gLibEmptyString, ColumnIndexWidth); + } + } + return; } @@ -788,6 +822,7 @@ PrintInternal ( UINTN Index; UINTN PreviousIndex; UINTN Count; + UINTN TotalCount; UINTN PrintWidth; UINTN CharWidth; @@ -812,6 +847,7 @@ PrintInternal ( Index = 0; PreviousIndex = 0; Count = 0; + TotalCount = 0; PrintWidth = 0; CharWidth = 1; @@ -823,17 +859,14 @@ PrintInternal ( if (Buffer[Index] == 0) { break; } - // - // Null-terminate the temporary string - // - BackupBuffer[Index] = 0; // // Print this out, we are about to switch widths // Out->OutputString (Out, &BackupBuffer[PreviousIndex]); - Count += StrLen (&BackupBuffer[PreviousIndex]); + Count = StrLen (&BackupBuffer[PreviousIndex]); PrintWidth += Count * CharWidth; + TotalCount += Count; // // Preserve the current index + 1, since this is where we will start printing from next @@ -867,8 +900,9 @@ PrintInternal ( // We hit the end of the string - print it // Out->OutputString (Out, &BackupBuffer[PreviousIndex]); - Count += StrLen (&BackupBuffer[PreviousIndex]); + Count = StrLen (&BackupBuffer[PreviousIndex]); PrintWidth += Count * CharWidth; + TotalCount += Count; if (PrintWidth < Width) { Out->Mode->Attribute = Out->Mode->Attribute & 0x7f; Out->SetAttribute (Out, Out->Mode->Attribute); @@ -877,7 +911,7 @@ PrintInternal ( FreePool (Buffer); FreePool (BackupBuffer); - return Count; + return TotalCount; } /** diff --git a/MdeModulePkg/Library/CustomizedDisplayLib/CustomizedDisplayLibInternal.h b/MdeModulePkg/Library/CustomizedDisplayLib/CustomizedDisplayLibInternal.h index ccbd45f..7342b50 100644 --- a/MdeModulePkg/Library/CustomizedDisplayLib/CustomizedDisplayLibInternal.h +++ b/MdeModulePkg/Library/CustomizedDisplayLib/CustomizedDisplayLibInternal.h @@ -193,11 +193,13 @@ LibGetStringWidth ( Show all registered HotKey help strings on bottom Rows. @param FormData The curent input form data info. + @param SetState Set HotKey or Clear HotKey **/ VOID PrintHotKeyHelpString ( - IN FORM_DISPLAY_ENGINE_FORM *FormData + IN FORM_DISPLAY_ENGINE_FORM *FormData, + IN BOOLEAN SetState ); /** -- cgit v1.1