[AD] visual improvement for gui menus |
[ Thread Index |
Date Index
| More lists.liballeg.org/allegro-developers Archives
]
hi,
i was playing a bit with the gui menus and two things annoyed me. The first
was that when a menu item has a sub-menu, the user doesn't know this (the
designer of the menu has to add "..." or something). The second thing is,
that when a menu item has a submenu and the user clicks on the item in the
third 1/3 of the width (from the left), he will probably click on the first
menu item of the child menu, even if he doesn't want to.
So I wrote a small patch to improve (I hope) these things. Solution for the
first thing is adding of a small triangle (or better said, "wannabe arrow")
to the right of an item (if it has a submenu). I assumed that noone uses
fonts smaller than 8 pixels :-) The second thing is repositioning of the child
menus more to the right.
Peter
--
------------------------------------------------------------------------------
Mail: pavlovic@xxxxxxxxxx
WEB : http://redbull.dcs.fmph.uniba.sk/~pavlovic
------------------------------------------------------------------------------
diff -r -U 3 -N allegro.old/src/gui.c allegro/src/gui.c
--- allegro.old/src/gui.c Mon Mar 13 00:23:52 2000
+++ allegro/src/gui.c Sat Apr 15 07:44:06 2000
@@ -12,6 +12,8 @@
*
* By Shawn Hargreaves.
*
+ * Peter Pavlovic modified the drawing and positioning of menus.
+ *
* See readme.txt for copyright information.
*/
@@ -1060,6 +1062,7 @@
int fg, bg;
int i, j, x, y, w;
char buf[256], *tok;
+ int my;
if (m->menu[c].flags & D_DISABLED) {
if (c == m->sel) {
@@ -1102,8 +1105,22 @@
if (j == '\t') {
tok = m->menu[c].text+i + uwidth(m->menu[c].text+i);
- gui_textout(screen, tok, x+w-gui_strlen(tok)-8, y+1, fg, FALSE);
+ gui_textout(screen, tok, x+w-gui_strlen(tok)-10, y+1, fg, FALSE);
+ }
+
+ if ((m->menu[c].child) && (!m->bar)) {
+ my = y + text_height(font)/2;
+ hline(screen, x+w-8, my+1, x+w-4, fg);
+ hline(screen, x+w-8, my+0, x+w-5, fg);
+ hline(screen, x+w-8, my-1, x+w-6, fg);
+ hline(screen, x+w-8, my-2, x+w-7, fg);
+ putpixel(screen, x+w-8, my-3, fg);
+ hline(screen, x+w-8, my+2, x+w-5, fg);
+ hline(screen, x+w-8, my+3, x+w-6, fg);
+ hline(screen, x+w-8, my+4, x+w-7, fg);
+ putpixel(screen, x+w-8, my+5, fg);
}
+
}
else
hline(screen, x, y+text_height(font)/2+2, x+w, fg);
@@ -1181,6 +1198,7 @@
char buf[80], *tok;
int extra = 0;
int c, i, j;
+ int child = FALSE;
m->menu = menu;
m->parent = parent;
@@ -1194,6 +1212,9 @@
/* calculate size of the menu */
for (m->size=0; m->menu[m->size].text; m->size++) {
+
+ if ((m->menu[m->size].child) && (m->parent)) child = TRUE;
+
i = 0;
j = ugetc(m->menu[m->size].text);
@@ -1224,6 +1245,9 @@
if (extra)
m->w += extra+16;
+ if (child)
+ m->w += 22;
+
m->w = MAX(m->w, minw);
m->h = MAX(m->h, minh);
}
@@ -1496,8 +1520,8 @@
_y += text_height(font)+7;
}
else {
- _x = m.x+m.w*2/3;
- _y = m.y + (text_height(font)+4)*ret + text_height(font)/4+2;
+ _x = m.x+m.w-3;
+ _y = m.y + (text_height(font)+4)*ret + text_height(font)/4+1;
}
c = _do_menu(m.menu[ret].child, &m, FALSE, _x, _y, TRUE, NULL, 0, 0);
if (c < 0) {
diff -r -U 3 -N allegro.old/tools/grabber.c allegro/tools/grabber.c
--- allegro.old/tools/grabber.c Mon Mar 13 00:23:48 2000
+++ allegro/tools/grabber.c Sun Apr 9 13:37:56 2000
@@ -136,7 +136,7 @@
{ "Set &Property\t(ctrl+P)", property_insert, NULL, 0, NULL },
{ "&Shell Edit\t(ctrl+Z)", sheller, NULL, 0, NULL },
{ "", NULL, NULL, 0, NULL },
- { "&New...", NULL, new_menu, 0, NULL },
+ { "&New ", NULL, new_menu, 0, NULL },
{ NULL, NULL, NULL, 0, NULL }
};
@@ -170,7 +170,7 @@
{ "&Rename", renamer, NULL, 0, NULL },
{ "&Shell Edit", sheller, NULL, 0, NULL },
{ "", NULL, NULL, 0, NULL },
- { "&New...", NULL, new_menu, 0, NULL },
+ { "&New ", NULL, new_menu, 0, NULL },
{ NULL, NULL, NULL, 0, NULL }
};
@@ -673,7 +673,7 @@
if ((dat) && (dat->type != DAT_FILE))
ok = TRUE;
}
- else if (compare_menu_names(popup_menu[i].text, "New...") == 0) {
+ else if (compare_menu_names(popup_menu[i].text, "New ") == 0) {
ok = TRUE;
}
else if (!popup_menu[i].text[0]) {
diff -r -U 3 -N allegro.old/tools/plugins/datalpha.c allegro/tools/plugins/datalpha.c
--- allegro.old/tools/plugins/datalpha.c Mon Mar 13 00:23:48 2000
+++ allegro/tools/plugins/datalpha.c Sun Apr 9 13:29:20 2000
@@ -382,7 +382,7 @@
/* per-object alpha channel menu */
static MENU alpha_menu =
{
- "Alpha Channel...",
+ "Alpha Channel",
NULL,
alpha_sub_menu,
0,
diff -r -U 3 -N allegro.old/tools/plugins/datitype.c allegro/tools/plugins/datitype.c
--- allegro.old/tools/plugins/datitype.c Mon Mar 13 00:23:48 2000
+++ allegro/tools/plugins/datitype.c Sun Apr 9 13:29:46 2000
@@ -248,7 +248,7 @@
/* hook ourselves into the grabber menu system */
static MENU change_type_menu =
{
- "Change Type...",
+ "Change Type",
NULL,
type_menu,
0,
@@ -269,7 +269,7 @@
static MENU change_depth_menu =
{
- "Color Depth...",
+ "Color Depth",
NULL,
depth_menu,
0,