]> git.proxmox.com Git - mirror_edk2.git/commitdiff
MdeModulePkg/DisplayEngine: Fix incorrect display issue
authorDandan Bi <dandan.bi@intel.com>
Fri, 28 Jul 2017 02:40:14 +0000 (10:40 +0800)
committerHao Wu <hao.a.wu@intel.com>
Fri, 4 Aug 2017 06:32:43 +0000 (14:32 +0800)
In a form, some new menus may be dynamically inserted between highlight
menu and previous top of screen menu when some question are refreshed.
So the highlight menu and previous top of screen menu perhaps can't be
shown in one page. Existing codes miss to handle this case then will
cause incorrect display.This patch is to fix this display issue.

Cc: Eric Dong <eric.dong@intel.com>
Cc: Liming Gao <liming.gao@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Dandan Bi <dandan.bi@intel.com>
Reviewed-by: Eric Dong <eric.dong@intel.com>
MdeModulePkg/Universal/DisplayEngineDxe/FormDisplay.c

index dc4ae4bda1bf7ba0eacfd066975b0e72b9c076fa..bbb267569785c56fc602b85e6f249ec70dd54121 100644 (file)
@@ -1718,23 +1718,56 @@ IsTopOfScreeMenuOption (
 }\r
 \r
 /**\r
-  Find the Top of screen menu.\r
+  Calculate the distance between two menus and include the skip value of StartMenu.\r
 \r
-  If the input is NULL, base on the record highlight info in\r
-  gHighligthMenuInfo to find the last highlight menu.\r
+  @param  StartMenu             The link_entry pointer to start menu.\r
+  @param  EndMenu               The link_entry pointer to end menu.\r
 \r
-  @param  HighLightedStatement      The input highlight statement.\r
+**/\r
+UINTN\r
+GetDistanceBetweenMenus(\r
+  IN LIST_ENTRY  *StartMenu,\r
+  IN LIST_ENTRY  *EndMenu\r
+)\r
+{\r
+  LIST_ENTRY                 *Link;\r
+  UI_MENU_OPTION             *MenuOption;\r
+  UINTN                      Distance;\r
 \r
-  @retval  The highlight menu index.\r
+  Distance = 0;\r
+\r
+  Link = StartMenu;\r
+  while (Link != EndMenu) {\r
+    MenuOption = MENU_OPTION_FROM_LINK (Link);\r
+    if (MenuOption->Row == 0) {\r
+      UpdateOptionSkipLines (MenuOption);\r
+    }\r
+    Distance += MenuOption->Skip;\r
+    Link = Link->BackLink;\r
+  }\r
+  return Distance;\r
+}\r
+\r
+/**\r
+  Find the top of screen menu base on the previous record menu info.\r
+\r
+  @param  HighLightMenu      The link_entry pointer to highlight menu.\r
+\r
+  @retval  Return the the link_entry pointer top of screen menu.\r
 \r
 **/\r
 LIST_ENTRY *\r
 FindTopOfScreenMenuOption (\r
- VOID\r
- )\r
+  IN LIST_ENTRY                   *HighLightMenu\r
 )\r
 {\r
   LIST_ENTRY                      *NewPos;\r
   UI_MENU_OPTION                  *MenuOption;\r
+  UINTN                           TopRow;\r
+  UINTN                           BottomRow;\r
+\r
+  TopRow    = gStatementDimensions.TopRow    + SCROLL_ARROW_HEIGHT;\r
+  BottomRow = gStatementDimensions.BottomRow - SCROLL_ARROW_HEIGHT;\r
 \r
   NewPos = gMenuOption.ForwardLink;\r
   MenuOption = MENU_OPTION_FROM_LINK (NewPos);\r
@@ -1754,7 +1787,16 @@ FindTopOfScreenMenuOption (
   // Last time top of screen menu has disappeared.\r
   //\r
   if (NewPos == &gMenuOption) {\r
-    NewPos = NULL;\r
+    return NULL;\r
+  }\r
+  //\r
+  // Check whether highlight menu and top of screen menu can be shown within one page,\r
+  // if can't, return NULL to re-calcaulate the top of scrren menu. Because some new menus\r
+  // may be dynamically inserted between highlightmenu and previous top of screen menu,\r
+  // So previous record top of screen menu is not appropriate for current display.\r
+  //\r
+  if (GetDistanceBetweenMenus (HighLightMenu, NewPos) + 1 > BottomRow - TopRow) {\r
+    return NULL;\r
   }\r
 \r
   return NewPos;\r
@@ -1805,7 +1847,7 @@ FindTopMenu (
       //\r
       // Found the last time highlight menu.\r
       //\r
-      *TopOfScreen = FindTopOfScreenMenuOption();\r
+      *TopOfScreen = FindTopOfScreenMenuOption(*HighlightMenu);\r
       if (*TopOfScreen != NULL) {\r
         //\r
         // Found the last time selectable top of screen menu.\r
@@ -1858,7 +1900,7 @@ FindTopMenu (
       MenuOption = MENU_OPTION_FROM_LINK (*HighlightMenu);\r
       UpdateOptionSkipLines (MenuOption);\r
       \r
-      *TopOfScreen = FindTopOfScreenMenuOption();\r
+      *TopOfScreen = FindTopOfScreenMenuOption(*HighlightMenu);\r
       if (*TopOfScreen == NULL) {\r
         //\r
         // Not found last time top of screen menu, so base on current highlight menu\r