Re: [AD] OS cursor followup

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


Commited the attached, very slightly modified, patch. Still lacks 
documentation.

Evert
Index: src/mouse.c
===================================================================
RCS file: /cvsroot/alleg/allegro/src/mouse.c,v
retrieving revision 1.30
diff -u -r1.30 mouse.c
--- src/mouse.c	9 Dec 2004 09:03:38 -0000	1.30
+++ src/mouse.c	20 Dec 2004 14:20:47 -0000
@@ -124,6 +124,7 @@
 
 BITMAP *_mouse_screen = NULL;          /* where to draw the pointer */
 
+static BITMAP *default_cursors[NUM_MOUSE_CURSORS];
 static BITMAP *cursors[NUM_MOUSE_CURSORS];
 
 static int allow_system_cursor;        /* Allow native OS cursor? */
@@ -487,6 +488,18 @@
 
 
 
+/* set_mouse_cursor_bitmap:
+ *  Changes the default Allegro cursor for a mouse cursor
+ */
+void set_mouse_cursor_bitmap(int cursor, struct BITMAP *bmp)
+{
+   ASSERT(cursor < NUM_MOUSE_CURSORS);
+
+   cursors[cursor] = bmp?bmp:default_cursors[cursor];
+}
+
+
+ 
 /* set_mouse_sprite_focus:
  *  Sets co-ordinate (x, y) in the sprite to be the mouse location.
  *  Call after set_mouse_sprite(). Doesn't redraw the sprite.
@@ -958,14 +971,19 @@
    LOCK_FUNCTION(_handle_mouse_input);
    
    /* Construct mouse pointers */
-   if (!cursors[MOUSE_CURSOR_ARROW])
-      cursors[MOUSE_CURSOR_ARROW] = create_mouse_pointer(mouse_arrow_data);
-   if (!cursors[MOUSE_CURSOR_BUSY])
-      cursors[MOUSE_CURSOR_BUSY] = create_mouse_pointer(mouse_busy_data);
-   if (!cursors[MOUSE_CURSOR_QUESTION])
-      cursors[MOUSE_CURSOR_QUESTION] = create_mouse_pointer(mouse_arrow_data);
-   if (!cursors[MOUSE_CURSOR_EDIT])
-      cursors[MOUSE_CURSOR_EDIT] = create_mouse_pointer(mouse_arrow_data);
+   if (!default_cursors[MOUSE_CURSOR_ARROW])
+      default_cursors[MOUSE_CURSOR_ARROW] = create_mouse_pointer(mouse_arrow_data);
+   if (!default_cursors[MOUSE_CURSOR_BUSY])
+      default_cursors[MOUSE_CURSOR_BUSY] = create_mouse_pointer(mouse_busy_data);
+   if (!default_cursors[MOUSE_CURSOR_QUESTION])
+      default_cursors[MOUSE_CURSOR_QUESTION] = create_mouse_pointer(mouse_arrow_data);
+   if (!default_cursors[MOUSE_CURSOR_EDIT])
+      default_cursors[MOUSE_CURSOR_EDIT] = create_mouse_pointer(mouse_arrow_data);
+
+   cursors[MOUSE_CURSOR_ARROW] = default_cursors[MOUSE_CURSOR_ARROW];
+   cursors[MOUSE_CURSOR_BUSY] = default_cursors[MOUSE_CURSOR_BUSY];
+   cursors[MOUSE_CURSOR_QUESTION] = default_cursors[MOUSE_CURSOR_QUESTION];
+   cursors[MOUSE_CURSOR_EDIT] = default_cursors[MOUSE_CURSOR_EDIT];
 
    if (system_driver->mouse_drivers)
       driver_list = system_driver->mouse_drivers();
@@ -1062,6 +1080,16 @@
 
    mouse_polled = FALSE;
 
+   free(default_cursors[MOUSE_CURSOR_ARROW]);
+   free(default_cursors[MOUSE_CURSOR_BUSY]);
+   free(default_cursors[MOUSE_CURSOR_QUESTION]);
+   free(default_cursors[MOUSE_CURSOR_EDIT]);
+
+   cursors[MOUSE_CURSOR_ARROW] = default_cursors[MOUSE_CURSOR_ARROW] = NULL;
+   cursors[MOUSE_CURSOR_BUSY] = default_cursors[MOUSE_CURSOR_BUSY] = NULL;
+   cursors[MOUSE_CURSOR_QUESTION] = default_cursors[MOUSE_CURSOR_QUESTION] = NULL;
+   cursors[MOUSE_CURSOR_EDIT] = default_cursors[MOUSE_CURSOR_EDIT] = NULL;
+
    if (_mouse_pointer) {
       destroy_bitmap(_mouse_pointer);
       _mouse_pointer = NULL;
Index: include/allegro/mouse.h
===================================================================
RCS file: /cvsroot/alleg/allegro/include/allegro/mouse.h,v
retrieving revision 1.4
diff -u -r1.4 mouse.h
--- include/allegro/mouse.h	4 Dec 2004 13:24:15 -0000	1.4
+++ include/allegro/mouse.h	20 Dec 2004 14:20:48 -0000
@@ -103,6 +103,7 @@
 AL_FUNC(void, set_mouse_range, (int x1, int y1, int x2, int y2));
 AL_FUNC(void, set_mouse_speed, (int xspeed, int yspeed));
 AL_FUNC(void, select_mouse_cursor, (int cursor));
+AL_FUNC(void, set_mouse_cursor_bitmap, (int cursor, struct BITMAP *bmp));
 AL_FUNC(void, set_mouse_sprite_focus, (int x, int y));
 AL_FUNC(void, get_mouse_mickeys, (int *mickeyx, int *mickeyy));
 AL_FUNC(void, set_mouse_sprite, (struct BITMAP *sprite));


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