Re: [AD] Using system mouse cursor

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


On Wed, 2004-09-29 at 16:12 -0700, Chris wrote:
> Evert Glebbeek wrote:
> > Basically, what we have now is thwe 
> > following division of mouse pointers:
> 
> Right. Except on systems where Allegro implements a true hardware 
> cursor, you can't have a system pointer since there is no default cursor 
> there. IMO, it would cause an unnecessarry system-specific option on top 
> of something that's already system-specific.
> 
> Basically with your way, the programmer would have to try to enable the 
> hardware cursor. If this fails, system behavior won't be all that 
> affected since Allegro will still draw the pointer. Then he has to try 
> setting the OS cursor type. Now, this will only work on systems where 
> the OS has default cursors.. if it doesn't work, the programmer has to 
> do addition work to try and get suitable behavior.
> 
> With my way, the programmer still has to try setting up the hardware 
> cursor, but beyond that, the API makes no distinction between a true 
> hardware mouse, or an OS-based one. If you don't set any cursors, the 
> default one (Allegro's for systems that don't have their own.. their can 
> be a function to test this) is automatically set up. Then all you have 
> to do is select which one of the pre-set cursor types you want to use. 
> Any additional work that might happen would be done once at setup.
> 
> The latter also has the advantage of not needing to hijack 
> set_mouse_sprite, since the hardware functions can call back onto that 
> function if we're in a non-hardware mode. So really, we could rename 
> set/select_hardware_cursor to set/select_mouse_cursor and have them 
> behave the same not only between systems where their may or may not be a 
> system cursor, but also on systems where there may or may not be a 
> "hardware" cursor. Plus, set_mouse_cursor can be set up to return if the 
> current system (eg. Windows in hardware mode) can accept the mouse 
> cursor and allow the programmer to set something else if it can't 
> (set_mouse_sprite doesn't have a return value, so there's no way to know 
> if your mouse pointer was really set or not).
> 
> You could even have a few CURSOR_USER# types to make it easier to cycle 
> through custom cursors (for animations or other uses).
> 

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:

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, in the
latter case the OS cursor is used.

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.

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 :)

-- 
Elias Pschernig





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