]> git.mxchange.org Git - flightgear.git/blobdiff - PUI/puPopupMenu.cxx
Incorporated next version of PUI.
[flightgear.git] / PUI / puPopupMenu.cxx
index 52ffbd9ac3d5815c0d5d6dabc4da32486492b009..0eed102316cf61b9660bec0670b017ffdae63c79 100644 (file)
@@ -1,4 +1,3 @@
-
 #include "puLocal.h"
 
 #define PUMENU_BUTTON_HEIGHT       25
@@ -26,17 +25,30 @@ void puPopupMenu::close ( void )
   int widest = 0 ;
   puObject *ob = dlist ;
 
+  /*
+   * June 17th, 1998, Shammi
+   * There seems to be some mismatch with the
+   * #define pumenusize and the actual size
+   * There seems to be some overlap resulting
+   * in more than one option being highlighted.
+   * By setting the size to the actual values,
+   * the overlap area seems to be less now.
+   */
+
+  int w, h ;
+
   for ( ob = dlist ; ob != NULL ; ob = ob -> next )
   {
-    int w, h ;
-
     ob -> getSize ( &w, &h ) ;
 
     if ( w > widest ) widest = w ;
   }
 
   for ( ob = dlist ; ob != NULL ; ob = ob -> next )
-    ob -> setSize ( widest, PUMENU_BUTTON_HEIGHT ) ;
+  {
+    ob -> getSize ( &w, &h ) ;
+    ob -> setSize ( widest, h ) ;
+  }
 
   recalc_bbox () ;
 }
@@ -84,38 +96,73 @@ int puPopupMenu::checkHit ( int button, int updown, int x, int y )
 
   int hit = isHit ( x, y ) ;
 
-  if ( updown == active_mouse_edge || active_mouse_edge == PU_UP_AND_DOWN )
+  /*
+   * June 17th, 1998, Shammi :
+   * There seemed to be a miscalculation with the menus initially
+   * Therefore I moved the recalculation stuff before the clearing.
+   */
+
+  /*
+    This might be a bit redundant - but it's too hard to keep
+    track of changing abox sizes when daughter objects are
+    changing sizes.
+  */
+
+  recalc_bbox();
+  x -= abox.min[0] ;
+  y -= abox.min[1] ;
+
+  /*
+   * June 17th, 1998, Shammi :
+   * Also clear the menu when the dragging the mouse and not hit.
+   */
+
+  if (   updown == active_mouse_edge || active_mouse_edge == PU_UP_AND_DOWN ||
+       ( updown == PU_DRAG && !hit ) )
   {
-    hide () ;
+
+    /* June 17th, 1998, Shammi :
+     * Do not hide the menu if mouse is dragged out
+     */
+
+    if ( updown != PU_DRAG )
+      hide () ;
 
     /* Turn everything off ready for next time. */
 
+    /* June 17th, 1998, Shammi:
+     * Make sure we check for a hit, if the mouse is moved
+     * out of the menu.
+     */
+
     for ( puObject *bo = dlist ; bo != NULL ; bo = bo->next )
+    {
+      if ( ! hit )
+       bo -> checkHit ( button, updown, x , y ) ;
+
       bo -> clrValue () ;
+    }
   }
 
   if ( ! hit )
     return FALSE ;
 
-  /*
-    This might be a bit redundant - but it's too hard to keep
-    track of changing abox sizes when daughter objects are
-    changing sizes.
-  */
-
-  recalc_bbox () ;
-
   puObject *bo ;
-
-  x -= abox.min[0] ;
-  y -= abox.min[1] ;
-
+  
   /*
     We have to walk the list backwards to ensure that
     the click order is the same as the DRAW order.
   */
 
+  /* June 17th, 1998, Shammi :
+   * If the mouse is dragged and the menuItem is not hit, 
+   * clear it
+   */
+
   for ( bo = dlist ; bo->next != NULL ; bo = bo->next )
+    if ( updown == PU_DRAG && ! bo -> checkHit ( button, updown, x, y ) )
+      bo -> clrValue () ;
+
     /* Find the last object in our list. */ ;
 
   for ( ; bo != NULL ; bo = bo->prev )
@@ -125,3 +172,4 @@ int puPopupMenu::checkHit ( int button, int updown, int x, int y )
   return FALSE ;
 }
 
+