[AD] some small patches

[ Thread Index | Date Index | More lists.liballeg.org/allegro-developers Archives ]


Some minor feature additions, maybe someone finds them useful :)

1. nopal.diff
Doesn't create a useless palette when NULL is passed to load_bitmap and
a truecolor image is loaded. (Useful when loading true-color images into
8bit modes, for example when using the generate_332_palette
truecolor-emulation.)

2. menu.diff
Provides gui_menu_callback. Extremely useful, for example it's the only
way I know (but probably I'm overlooking something obvious) to write a
music player (using streams) with a GUI-menu.

3. noflicker.diff
This reduces the flicker of the mouse cursor when a GUI object somewhere
else on the screen is redrawn. (For example, in a music player which
updates a waveform, it now only flickers when over the waveform object,
instead of all the time.)

4. euro.diff
Euro character. Even in X-windows they added it, and my keyboard also
has it. (Btw., I just sort of merged the C and = characters to get €, no
idea if this is the right way).

And this is a small comment in the docs for set_clip, because I got
caught by it:
5. clipcomment.diff

--
Elias Pschernig
Index: src/bmp.c
===================================================================
RCS file: /cvsroot/alleg/allegro/src/bmp.c,v
retrieving revision 1.10
diff -u -r1.10 bmp.c
--- src/bmp.c	16 Oct 2002 12:03:04 -0000	1.10
+++ src/bmp.c	31 Oct 2002 19:11:17 -0000
@@ -473,11 +473,13 @@
    PALETTE tmppal;
    int ncol;
    unsigned long biSize;
-   int bpp, dest_depth;
+   int bpp, dest_depth, nopal;
    ASSERT(filename);
 
-   if (!pal)
+   if (!pal) {
+      nopal = 1;
       pal = tmppal;
+   }
 
    f = pack_fopen(filename, F_READ);
    if (!f)
@@ -550,7 +552,7 @@
    }
 
    if (dest_depth != bpp)
-      bmp = _fixup_loaded_bitmap(bmp, pal, dest_depth);
+      bmp = _fixup_loaded_bitmap(bmp, pal, dest_depth, nopal);
 
    pack_fclose(f);
    return bmp;
Index: src/readbmp.c
===================================================================
RCS file: /cvsroot/alleg/allegro/src/readbmp.c,v
retrieving revision 1.14
diff -u -r1.14 readbmp.c
--- src/readbmp.c	16 Oct 2002 12:03:04 -0000	1.14
+++ src/readbmp.c	31 Oct 2002 19:11:18 -0000
@@ -116,7 +116,7 @@
 /* _fixup_loaded_bitmap:
  *  Helper function for adjusting the color depth of a loaded image.
  */
-BITMAP *_fixup_loaded_bitmap(BITMAP *bmp, PALETTE pal, int bpp)
+BITMAP *_fixup_loaded_bitmap(BITMAP *bmp, PALETTE pal, int bpp, int nopal)
 {
    BITMAP *b2;
 
@@ -129,7 +129,12 @@
    if (bpp == 8) {
       RGB_MAP *old_map = rgb_map;
 
-      generate_optimized_palette(bmp, pal, NULL);
+      if (nopal) {
+	 pal = _current_palette;
+      }
+      else {
+	 generate_optimized_palette(bmp, pal, NULL);
+      }
 
       rgb_map = malloc(sizeof(RGB_MAP));
       if (rgb_map != NULL)
Index: src/pcx.c
===================================================================
RCS file: /cvsroot/alleg/allegro/src/pcx.c,v
retrieving revision 1.11
diff -u -r1.11 pcx.c
--- src/pcx.c	16 Oct 2002 12:03:04 -0000	1.11
+++ src/pcx.c	31 Oct 2002 19:11:18 -0000
@@ -37,11 +37,13 @@
    int xx, po;
    int x, y;
    char ch;
-   int dest_depth;
+   int dest_depth, nopal;
    ASSERT(filename);
    
-   if (!pal)
+   if (!pal) {
+      nopal = 1;
       pal = tmppal;
+   }
 
    f = pack_fopen(filename, F_READ);
    if (!f)
@@ -154,7 +156,7 @@
    }
 
    if (dest_depth != bpp)
-      b = _fixup_loaded_bitmap(b, pal, dest_depth);
+      b = _fixup_loaded_bitmap(b, pal, dest_depth, nopal);
 
    return b;
 }
Index: src/tga.c
===================================================================
RCS file: /cvsroot/alleg/allegro/src/tga.c,v
retrieving revision 1.10
diff -u -r1.10 tga.c
--- src/tga.c	10 Oct 2002 16:25:18 -0000	1.10
+++ src/tga.c	31 Oct 2002 19:11:18 -0000
@@ -184,15 +184,17 @@
    short unsigned int left, top, image_width, image_height;
    unsigned int c, i, x, y, yc;
    unsigned short *s;
-   int dest_depth;
+   int dest_depth, nopal;
    int compressed;
    PACKFILE *f;
    BITMAP *bmp;
    PALETTE tmppal;
    ASSERT(filename);
 
-   if (!pal)
+   if (!pal) {
+      nopal = 1;
       pal = tmppal;
+   }
 
    f = pack_fopen(filename, F_READ);
    if (!f)
@@ -383,7 +385,7 @@
    }
 
    if (dest_depth != bpp)
-      bmp = _fixup_loaded_bitmap(bmp, pal, dest_depth);
+      bmp = _fixup_loaded_bitmap(bmp, pal, dest_depth, nopal);
 
    return bmp;
 }
Index: include/allegro/internal/aintern.h
===================================================================
RCS file: /cvsroot/alleg/allegro/include/allegro/internal/aintern.h,v
retrieving revision 1.10
diff -u -r1.10 aintern.h
--- include/allegro/internal/aintern.h	2 Oct 2002 18:29:56 -0000	1.10
+++ include/allegro/internal/aintern.h	31 Oct 2002 19:11:19 -0000
@@ -309,7 +309,7 @@
 
 AL_VAR(int, _color_conv);
 
-AL_FUNC(BITMAP *, _fixup_loaded_bitmap, (BITMAP *bmp, PALETTE pal, int bpp));
+AL_FUNC(BITMAP *, _fixup_loaded_bitmap, (BITMAP *bmp, PALETTE pal, int bpp, int nopal));
 
 
 /* display switching support */
Index: include/allegro/gui.h
===================================================================
RCS file: /cvsroot/alleg/allegro/include/allegro/gui.h,v
retrieving revision 1.10
diff -u -r1.10 gui.h
--- include/allegro/gui.h	31 Oct 2002 12:56:24 -0000	1.10
+++ include/allegro/gui.h	31 Oct 2002 19:49:07 -0000
@@ -160,6 +160,8 @@
 
 AL_VAR(int, gui_font_baseline);
 
+AL_FUNCPTR(void, gui_menu_callback, (void));
+
 AL_FUNCPTR(int, gui_mouse_x, (void));
 AL_FUNCPTR(int, gui_mouse_y, (void));
 AL_FUNCPTR(int, gui_mouse_z, (void));
Index: src/gui.c
===================================================================
RCS file: /cvsroot/alleg/allegro/src/gui.c,v
retrieving revision 1.51
diff -u -r1.51 gui.c
--- src/gui.c	3 Oct 2002 06:49:40 -0000	1.51
+++ src/gui.c	31 Oct 2002 19:49:08 -0000
@@ -111,6 +111,9 @@
 int (*gui_mouse_b)(void) = default_mouse_b;
 
 
+/* callback function, called continuously while a menu is processed */
+void (*gui_menu_callback)(void) = NULL;
+
 /* timer to handle menu auto-opening */
 static int gui_timer;
 
@@ -1564,6 +1567,10 @@
    unscare_mouse();
 
    do {                                               /* main event loop */
+      
+      if (gui_menu_callback)
+	 gui_menu_callback ();
+      
       yield_timeslice();
 
       old_sel = m.sel;
Index: src/gui.c
===================================================================
RCS file: /cvsroot/alleg/allegro/src/gui.c,v
retrieving revision 1.51
diff -u -r1.51 gui.c
--- src/gui.c	3 Oct 2002 06:49:40 -0000	1.51
+++ src/gui.c	31 Oct 2002 20:53:46 -0000
@@ -111,6 +111,9 @@
 int (*gui_mouse_b)(void) = default_mouse_b;
 
 
+/* callback function, called continuously while a menu is processed */
+void (*gui_menu_callback)(void) = NULL;
+
 /* timer to handle menu auto-opening */
 static int gui_timer;
 
@@ -337,7 +340,8 @@
    ASSERT(dialog);
 
    if (msg == MSG_DRAW) {
-      scare_mouse();
+      if (dialog[c].x >= 0 && dialog[c].y >= 0 && dialog[c].w > 0 && dialog[c].h > 0)
+	 scare_mouse_area(dialog[c].x, dialog[c].y, dialog[c].w, dialog[c].h);
       acquire_screen();
    }
 
@@ -362,7 +366,8 @@
 
 	 if ((msg == MSG_IDLE) && (dialog[count].flags & (D_DIRTY | D_HIDDEN)) == D_DIRTY) {
 	    dialog[count].flags &= ~D_DIRTY;
-	    scare_mouse();
+	    if (dialog[count].x >= 0 && dialog[count].y >= 0 && dialog[count].w > 0 && dialog[count].h > 0)
+	       scare_mouse_area(dialog[count].x, dialog[count].y, dialog[count].w, dialog[count].h);
 	    object_message(dialog+count, MSG_DRAW, 0);
 	    unscare_mouse();
 	 }
@@ -848,7 +853,8 @@
    for (c=0; player->dialog[c].proc; c++) {
       if ((player->dialog[c].flags & (D_DIRTY | D_HIDDEN)) == D_DIRTY) {
 	 player->dialog[c].flags &= ~D_DIRTY;
-	 scare_mouse();
+	 if ( player->dialog[c].x >= 0 &&  player->dialog[c].y >= 0 &&  player->dialog[c].w > 0 &&  player->dialog[c].h > 0)
+	    scare_mouse_area( player->dialog[c].x,  player->dialog[c].y,  player->dialog[c].w,  player->dialog[c].h);
 	 MESSAGE(c, MSG_DRAW, 0);
 	 unscare_mouse();
       }
@@ -1564,6 +1570,10 @@
    unscare_mouse();
 
    do {                                               /* main event loop */
+      
+      if (gui_menu_callback)
+	 gui_menu_callback ();
+      
       yield_timeslice();
 
       old_sel = m.sel;
Index: src/font.c
===================================================================
RCS file: /cvsroot/alleg/allegro/src/font.c,v
retrieving revision 1.7
diff -u -r1.7 font.c
--- src/font.c	2 Oct 2002 18:29:56 -0000	1.7
+++ src/font.c	21 Oct 2002 17:17:04 -0000
@@ -417,6 +417,19 @@
 
 
 
+/* euro character (0x20AC) */
+static FONT_GLYPH f_0x20AC = { 8, 8, { 0x3C, 0x62, 0xF8, 0x60, 0xF8, 0x62, 0x3C, 0x00 } };
+
+	
+	
+/* euro character */
+static FONT_GLYPH* euro_data[] =
+{
+	&f_0x20AC
+};
+
+
+
 /* allegro_404_char:
  *  This is what we render missing glyphs as.
  */
@@ -719,10 +732,16 @@
  * Declaration of `_default_font' and `font'
  ********/
 
+static FONT_MONO_DATA euro_monofont = {
+    0x20AC, 0x20AD,             /* begin, end characters */
+    euro_data,                  /* the data set */
+    0                           /* next */
+};
+
 static FONT_MONO_DATA extended_a_monofont = {
     0x100, 0x180,               /* begin, end characters */
     extended_a_data,            /* the data set */
-    0                           /* next */
+    & euro_monofont             /* next */
 };
 
 static FONT_MONO_DATA latin1_monofont = {
--- resource/keyboard/de.cfg	2002-10-31 18:40:13.000000000 +0100
+++ resource/keyboard/de.cfg	2002-10-18 18:30:50.000000000 +0200
@@ -77,3 +77,4 @@
 key66 = 126
 key13 = 181
 key71 = 124
+key5 = 8364
Index: docs/src/allegro._tx
===================================================================
RCS file: /cvsroot/alleg/allegro/docs/src/allegro._tx,v
retrieving revision 1.101
diff -u -r1.101 allegro._tx
--- docs/src/allegro._tx	31 Oct 2002 11:02:50 -0000	1.101
+++ docs/src/allegro._tx	31 Oct 2002 20:16:56 -0000
@@ -3153,6 +3153,7 @@
    Shortcut version of release_bitmap(screen);
 
 @@void @set_clip(BITMAP *bitmap, int x1, int y1, int x2, int y2);
+@xref create_sub_bitmap
    Each bitmap has an associated clipping rectangle, which is the area of 
    the image that it is ok to draw on. Nothing will be drawn to positions 
    outside this space. Pass the two opposite corners of the clipping 
@@ -3162,6 +3163,13 @@
    may slightly speed up some drawing operations (usually a negligible 
    difference, although every little helps) but will result in your program 
    dying a horrible death if you try to draw beyond the edges of the bitmap.
+
+   Note: If you pass coordinates which would set the clipping rectangle
+   completely out of the bitmap, they will be adjusted to be inside the
+   bitmap. So in case your clipping rectangle is auto-calculated, be careful
+   to have special cases for this. Although note that it's not possible to
+   set the clipping rectangle to the point in the upper left corner of a
+   bitmap (see above about all zero parameters).
 
    There's no get_clip like function. To obtain the clipping rectangle of an
    existing bitmap, check the appropiate fields of the BITMAP structure


Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/