[AD] Menus not honoring gui screen |
[ Thread Index |
Date Index
| More lists.liballeg.org/allegro-developers Archives
]
- To: alleg-developers@xxxxxxxxxx
- Subject: [AD] Menus not honoring gui screen
- From: Chris <chris.kcat@xxxxxxxxxx>
- Date: Sat, 13 Aug 2005 22:54:55 -0700
- Domainkey-signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:from:to:subject:date:user-agent:mime-version:content-type:message-id; b=RmI5UuQr5O9vhFiTfxTyhGIoXnl/QmuYh0+A/BLiUu+ZFraGtYrpbTWhhOgdz/bL6wgz+cHEd9LojetlqHRm58r92oPTRSPotcxUDiTvUZxSNVxVMom3R5Da/NK9DMH1PWj8f20KE7Zw85ct2kSXmhSw8jcXu1ubBQiNO/88N4w=
Despite having a way to change the bitmap the GUI draws to, the menus still
draw directly to the screen. I made this patch to fix the problem. Someone
may want to comb over it though, to make sure I didn't miss something or mess
it up somehow.
Index: src/gui.c
===================================================================
RCS file: /cvsroot/alleg/allegro/src/gui.c,v
retrieving revision 1.78
diff -u -r1.78 gui.c
--- src/gui.c 11 Jun 2005 17:14:36 -0000 1.78
+++ src/gui.c 14 Aug 2005 05:47:17 -0000
@@ -1462,6 +1462,7 @@
int x, y, w;
char *buf, *tok1, *tok2;
int my;
+ BITMAP *gui_screen = gui_get_screen();
get_menu_pos(m, c, &x, &y, &w);
@@ -1492,35 +1493,35 @@
}
}
- rectfill(screen, x, y, x+w-1, y+text_height(font)+3, bg);
+ rectfill(gui_screen, x, y, x+w-1, y+text_height(font)+3, bg);
if (ugetc(m->menu[c].text)) {
buf = split_around_tab(m->menu[c].text, &tok1, &tok2);
- gui_textout_ex(screen, tok1, x+8, y+1, fg, bg, FALSE);
+ gui_textout_ex(gui_screen, tok1, x+8, y+1, fg, bg, FALSE);
if (tok2)
- gui_textout_ex(screen, tok2, x+w-gui_strlen(tok2)-10, y+1, fg, bg, FALSE);
+ gui_textout_ex(gui_screen, tok2, x+w-gui_strlen(tok2)-10, y+1, fg, bg, 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);
+ hline(gui_screen, x+w-8, my+1, x+w-4, fg);
+ hline(gui_screen, x+w-8, my+0, x+w-5, fg);
+ hline(gui_screen, x+w-8, my-1, x+w-6, fg);
+ hline(gui_screen, x+w-8, my-2, x+w-7, fg);
+ putpixel(gui_screen, x+w-8, my-3, fg);
+ hline(gui_screen, x+w-8, my+2, x+w-5, fg);
+ hline(gui_screen, x+w-8, my+3, x+w-6, fg);
+ hline(gui_screen, x+w-8, my+4, x+w-7, fg);
+ putpixel(gui_screen, x+w-8, my+5, fg);
}
free(buf);
}
else
- hline(screen, x, y+text_height(font)/2+2, x+w, fg);
+ hline(gui_screen, x, y+text_height(font)/2+2, x+w, fg);
if (m->menu[c].flags & D_SELECTED) {
- line(screen, x+1, y+text_height(font)/2+1, x+3, y+text_height(font)+1, fg);
- line(screen, x+3, y+text_height(font)+1, x+6, y+2, fg);
+ line(gui_screen, x+1, y+text_height(font)/2+1, x+3, y+text_height(font)+1, fg);
+ line(gui_screen, x+3, y+text_height(font)+1, x+6, y+2, fg);
}
}
@@ -1536,9 +1537,10 @@
if (gui_menu_draw_menu)
gui_menu_draw_menu(m->x, m->y, m->w, m->h);
else {
- rect(screen, m->x, m->y, m->x+m->w-2, m->y+m->h-2, gui_fg_color);
- vline(screen, m->x+m->w-1, m->y+1, m->y+m->h-1, gui_fg_color);
- hline(screen, m->x+1, m->y+m->h-1, m->x+m->w-1, gui_fg_color);
+ BITMAP *gui_screen = gui_get_screen();
+ rect(gui_screen, m->x, m->y, m->x+m->w-2, m->y+m->h-2, gui_fg_color);
+ vline(gui_screen, m->x+m->w-1, m->y+1, m->y+m->h-1, gui_fg_color);
+ hline(gui_screen, m->x+1, m->y+m->h-1, m->x+m->w-1, gui_fg_color);
}
for (c=0; m->menu[c].text; c++)
@@ -1771,6 +1773,7 @@
*/
static MENU_PLAYER *init_single_menu(MENU *menu, MENU_PLAYER *parent, DIALOG *dialog, int bar, int x, int y, int repos, int minw, int minh)
{
+ BITMAP *gui_screen = gui_get_screen();
MENU_PLAYER *player;
ASSERT(menu);
@@ -1787,20 +1790,22 @@
player->y = MID(0, player->y, SCREEN_H-player->h-1);
}
- scare_mouse_area(player->x, player->y, player->w, player->h);
+ if (is_same_bitmap(gui_screen, _mouse_screen))
+ scare_mouse_area(player->x, player->y, player->w, player->h);
/* save screen under the menu */
player->saved = create_bitmap(player->w, player->h);
if (player->saved)
- blit(screen, player->saved, player->x, player->y, 0, 0, player->w, player->h);
+ blit(gui_screen, player->saved, player->x, player->y, 0, 0, player->w, player->h);
else
*allegro_errno = ENOMEM;
/* setup state variables */
player->sel = menu_mouse_object(player);
- unscare_mouse();
+ if (is_same_bitmap(gui_screen, _mouse_screen))
+ unscare_mouse();
player->mouse_button_was_pressed = gui_mouse_b();
player->back_from_child = FALSE;
@@ -1988,10 +1993,12 @@
} /* end of input processing */
if ((player->redraw) || (player->sel != old_sel)) { /* selection changed? */
+ BITMAP *gui_screen = gui_get_screen();
player->timestamp = gui_timer;
- scare_mouse_area(player->x, player->y, player->w, player->h);
- acquire_screen();
+ if (is_same_bitmap(gui_screen, _mouse_screen))
+ scare_mouse_area(player->x, player->y, player->w, player->h);
+ acquire_bitmap(gui_screen);
if (player->redraw) {
draw_menu(player);
@@ -2005,8 +2012,9 @@
draw_menu_item(player, player->sel);
}
- release_screen();
- unscare_mouse();
+ release_bitmap(gui_screen);
+ if (is_same_bitmap(gui_screen, _mouse_screen))
+ unscare_mouse();
}
if (player->auto_open && (gui_menu_opening_delay >= 0)) { /* menu auto-opening on? */
@@ -2128,9 +2136,12 @@
/* restore screen */
if (player->saved) {
- scare_mouse_area(player->x, player->y, player->w, player->h);
- blit(player->saved, screen, 0, 0, player->x, player->y, player->w, player->h);
- unscare_mouse();
+ BITMAP *gui_screen = gui_get_screen();
+ if (is_same_bitmap(gui_screen, _mouse_screen))
+ scare_mouse_area(player->x, player->y, player->w, player->h);
+ blit(player->saved, gui_screen, 0, 0, player->x, player->y, player->w, player->h);
+ if (is_same_bitmap(gui_screen, _mouse_screen))
+ unscare_mouse();
destroy_bitmap(player->saved);
}