[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [pygame] Cursors again



> A while ago I asked about custom mousepointers (cursors), and was told
> that this is still a weak part in pygame. I was wondering wether any
> progress has been made in that area?
> 
> I could happily use something like:
> 
>     cursor = [ '        ',
>                '   ..   ',       
>                '   .X   ',       
>                ' ...X.. ',       
>                ' XXXXXX ',       
>                '   .X   ',       
>                '   .X   ',       
>                '        ' ]
> 
> pygame.mouse.set_cursor( (8,8), (4,4), cursor, 'X', '.', ' ' )
> 
> Where parameters are:
> 
> (8,8)  - size of the cursor
> (4,4)  - hotspot location
> cursor - list of strings (8 strings a 8 characters)
> 'X'    - character for a black pixel
> '.'    - character for a white pixel
> ' '    - character for a transparent pixel
> 
> Maybe cursors should be created manually using pygame.mouse.Cursor() which
> could return a cursor object and the set using pygame.mouse.set_cursor
> which would take as argument a predefined cursor?
> 
> What do you think? I know this is asking for much, but at this stage I
> need the cursors so that I can tell that player the state the game is in,
> i.e. what is expected from the player. If this is planned or just not
> doable it is ok. 

at this point cursors can use some more attention. there is an all
python module named pygame.cursors which for now simply contains
the data for two cursors. (argh, and the diamond one is bitswapped)

i also think simple cursors defined by strings (like above) make
a lot of good sense. the good news is there is already code to 
do this in the sdl documentation. my current plan is to put some
sort of compile function in the cursors module. the compile will
take the strings and turn it into a sequence of bytedata which
can be passed to pygame.mouse.set_cursor()

other things i would like are the ability to load XBM and CUR files
into these cursor byte sequences. XBM should be easy, CUR files are
pretty much a BMP with a few extra headers.

what would be best for now is a strings to bytes cursor compiler and
a few more good default cursors available in the cursor module.
i think we can shoot for the 0.5 release with this stuff.

my current project is tackling the problems in surfarray. it will
be a couple days before i can get to cursors, so the door is wide
open for someone else to enhance that cursor module (wink wink)

just in case, the compiler can be found here,
http://sdldoc.sourceforge.net/current/sdlcreatecursor.html .
(should be easy to convert to python) i liked the args jan
gave as an example earlier, but i think the size argument might
be a little redundant.


____________________________________
pygame mailing list
pygame-users@seul.org
http://pygame.seul.org