Re: [AD] Using system mouse cursor

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


On Thu, 2004-09-30 at 11:44 +0200, Evert Glebbeek wrote:
> > 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.
> 

Heh, never noticed.

> > 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.
> 

Yes, that's just how I thought Chris' two functions would work.

> > 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.
> 

I see. But I think it is a good idea. For one, if there's no OS cursor,
this could just select Allegro's default (as Chris said). This is what
99% of users will want. In the 1% of cases where you want to force a HW
cursor which looks like the Allegro cursor, you could simply use:

set_mouse_cursor(CURSOR_NORMAL, mouse_sprite)

Not sure how we would handle the other default cursor bitmaps, maybe
have an array, so you could use: al_mouse_sprites[CURSOR_WAIT], or even
better a wrapper function: al_builtin_cursor_bitmap(id). In any case,
NULL selecting the OS cursor when possible seems the right thing to me.

> > 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. ;)
> 

Heh, just what I was thinking. Since the GUI has messages for
[de]activation of everything, it should be fairly simple to add.
Probably just fill in two messages to d_edit_proc to have it switch to
an edit cursor :)

-- 
Elias Pschernig





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