Re: [AD] Using system mouse cursor

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


> That sounds like a good idea to me. The distinction between
> software/hardware cursor should be as transparent as possible in any
> case, and with the set_mouse_cursor also the OS cursors are unified. So
> I can do:

I'm still not sure I like the idea of having to use a different function to
set a custom mouse cursor for the hardware mouse though...
I prefer the case where Allegro will use a hardware mouse to draw my custom
cursor if possible, without having to write seperate code depending on
wether it is available or not. In other words, I wouldn't like having to do

if (can_use_hardware_mouse)
   set_hardware_pointer();
else
   set_software_pointer();

if (can_use_hardware_mouse)
   show_hardware_pointer();
else
   show_software_pointer();

instead of

set_mouse_sprite()
show_mouse()

although if a majority prefers the other approach, I suppose I should
change it.

> set_mouse_cursor(CURSOR_WAIT, NULL);
> select_mouse_cursor(CURSOR_WAIT);
> 
> And now, no matter if a software, hardware or OS cursor is used
> subsequently - it will always just work. In the first 2 cases the
> Allegro default waiting cursor (yet to be drawn I guess) is used,

The grabber has one, we can use that.

> in the latter case the OS cursor is used.

Just one problem: suppose I want to use the OS cursor if available, but not
Allegro's default cursor if not. Ok, I suppose a return value could be used
for that. So, in summary, that would mean:

int set_mouse_cursor(int cursor_id, BITMAP *sprite);
Sets the cursor ID to the bitmap sprite. If sprite is NULL, the default OS
cursor is used. Returns (something) on success or (not something) on failure.

void select_mouse_cursor(int cursor_id);
Selects the mouse pointer pointed at by cursor_id.

How about going a step further: use the same function to set Allegro's
software cursor. This would be trivial to add, and we could then deprecate
set_mouse_sprite() (less functions for doing a similar task is good).
Allegro could use a custom hardware cursor if this has been allowed to draw
its own cursor. This would lead to

mouse_cursor_id: ALLEGRO_CURSOR
 - this can be a hardware or software cursor

mouse_cursor_id: other
 - this can be the system default cursor (if sprite was NULL), or a custom
hardware cursor.

I'll play with this and see how it feels.

> In the current design, users would first have to check if an OS cursor
> can be used at all (e.g. CURSOR_QUESTION in X11), and if it cannot, use
> their own bitmap instead.

But with your new system, you would need to pass NULL to set_mouse_cursor()
to select the OS default cursor, or non-null to use a custom one. In other
words, you would still need to check if the OS cursor can be used if you
want, because you don't want to override it by default.

> Oh, and I think you should add CURSOR_EDIT by default as well, i.e. the
> | shaped one you get while hovering over any input box or text window
> in
> X11 (and I got a very nice transparent one with a shadow here, so I'd
> like to have it in Allegro apps as well :)

Makes sense. Actually, the only reason it's not there is that I was too
lazy to look it up :)
The next step would be to make Allegro's GUI objects aware of the OS cursor
and be able to change it when they have focus. ;)

Evert




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