[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[E-devel] e_menu patch for smarter placement



Hello,

I made a patch for e_menu that minimizes the need for vertical
scrolling. 

The submenu starts either above or below the actual
Item, not only below. It works as follows: if the menu is larger than
the screen then place the menu so that more is shown. e.g. if its start
in the lower half of the screen more is shown when the menu is above.
If the menu is smaller than the screen but it goes offscreen then it is
also tested if the menu should go above.

The submenu starts of  course direct next to the actual item. The terms
above and below could be misleading.

If this should be made an option I can change the patch, though i could
hardly understand why someone would like it less comfortable :) 


Hannes


 
Index: e_menu.c
===================================================================
RCS file: /var/cvs/e/e17/apps/e/src/bin/e_menu.c,v
retrieving revision 1.58
diff -u -r1.58 e_menu.c
--- e_menu.c	9 Aug 2006 15:24:34 -0000	1.58
+++ e_menu.c	13 Aug 2006 21:14:34 -0000
@@ -1823,7 +1823,29 @@
    
    if (!m->parent_item) return;
    m->cur.x = m->parent_item->menu->cur.x + m->parent_item->menu->cur.w;
-   m->cur.y = m->parent_item->menu->cur.y + m->parent_item->y - m->container_y;
+
+   int parent_item_bottom = m->parent_item->menu->cur.y + m->parent_item->y;
+   if(m->cur.h > m->zone->h)
+     {
+   /* menu is larger than screen */
+   if(parent_item_bottom > (m->zone->h / 2))
+     /* more is shown if menu goes up */
+     m->cur.y = (parent_item_bottom - (m->container_h + 1)); 
+   else
+     /* more is shown if menu goes down */
+     m->cur.y = parent_item_bottom - m->container_y;
+     }
+   else
+     {  
+   /* menu is smaller than screen */
+   if(((parent_item_bottom + m->cur.h - m->container_y) > m->zone->h) && 
+       (parent_item_bottom > (m->zone->h / 2)))
+     /* menu is partially out of screen and more is shown if menu goes up */
+     m->cur.y = (parent_item_bottom - (m->container_h + 1)); 
+   else
+     m->cur.y = parent_item_bottom - m->container_y;
+     }
+   
    /* FIXME: this will suck for big menus */
    for (l = _e_active_menus; l; l = l->next)
      {