From 6b81373e4af93bf5a5b87eab915d00a43d431d6e Mon Sep 17 00:00:00 2001 From: Fabian Schuetz Date: Wed, 4 Mar 2015 15:12:55 +0100 Subject: [PATCH 1/4] touchring and cursor are now two modules, added better cursor, fixed positioning of cursor (depends on image aswell) --- kivy/data/images/cursor.png | Bin 0 -> 8271 bytes kivy/modules/cursor.py | 87 ++++++++++++++++++++++++++++++++++++ kivy/modules/touchring.py | 53 ++++------------------ 3 files changed, 96 insertions(+), 44 deletions(-) create mode 100644 kivy/data/images/cursor.png create mode 100644 kivy/modules/cursor.py diff --git a/kivy/data/images/cursor.png b/kivy/data/images/cursor.png new file mode 100644 index 0000000000000000000000000000000000000000..56c5055652c496669bdd19127263720c39e213fe GIT binary patch literal 8271 zcmV-VAh6$wP)zwbF!)!hjOh=OQDz;#pvQ4|?v5C<2~k2{W_abZN1aUDir)H}|_xz~#$ z=ygL8Q3TO(8y&qkE>TnnTM{5Z=qx}8CM*d_)9G5zIq&cOao$?GyE=WUx~saXa-RB- zknXB;>b$@A*_YPOiM77yv&*-&aXxP3R|jZ3^+=0X(eFDpVjz+NzIge<9?>5MPrn zQQrfMPSf2A6(~|5=@)v9gV>~eJQx5Up`WRwk|e88(zrh7^l>Vx2Lj?H`kX2%ONvxd zsIta%tzNIijT$+ne&*r#=^geUVmRTw^E4vl#CHNKwoxRSdt!fFjrL2Hho@4HA4K3bjkWsNT0083f z40c7K`&UsV6}4X9(hG%1gPFZgMrc1>pt7PS07tTtN-8^EmMSVJP^8s*uO64`WA$5=U3JG)DmpD(sf9A7P!$E* zt?Tts<%F^+C-<(5_Jj`97gcNuuvI~UDw9kwTYG1uvVNwQG>YmJ;vOKck%KL;oy`Pf znxJFx@yIlMB*Y*r0`f$hz$JW=C&arY7Wygmo{;`qU8i6MAw4w>5ex33`#Z0KB3OCHQqt+=*0I@WoKzZjhNmh}pBIOlGx<_A0GswNEg`cG# zxTM4ELOM{P!LF_cG|P%Ku0QHDJtnoQd&G(cFcGkYjgze98T~52X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6@6+(a>K!9LJ(wt?N~AC&yS-v|CnX z$bYiM``&UfA+8I$LNhO7~9;Ue1_C9^e8CI$0?Nf-e`i3SHDX&1G@)~zJ z;7|pP>H_VjYVlsWV13HN&(wt)cVpaa&A{5Jt8`o{ng;{o!!;`F;?bc3RaDXU^&(}{ zLc2kL*cW=2*1O@PWmU9EXVga>r{MNG#J9;X?Op?iRqW=NBW0)rl{xPH7Rl}ggp?j1hLz-tn~i+r2x0a#ZZN|PgXAlxDAL+ zZ&ZP%lu}A5rIb=iDW#NBN-3q3Qc5YMlu}A5rIb=iDW#NBN-6D${y*C_;aph|)9L^K N002ovPDHLkV1k)@y#D|I literal 0 HcmV?d00001 diff --git a/kivy/modules/cursor.py b/kivy/modules/cursor.py new file mode 100644 index 000000000..18a70c621 --- /dev/null +++ b/kivy/modules/cursor.py @@ -0,0 +1,87 @@ +''' +Touchring +========= + +Shows rings around every touch on the surface / screen. You can use this module +to check that you don't have any calibration issues with touches. + +Configuration +------------- + +:Parameters: + `image`: str, defaults to '/data/images/ring.png' + Filename of the image to use. + `scale`: float, defaults to 1. + Scale of the image. + `alpha`: float, defaults to 1. + Opacity of the image. + `show_cursor`: boolean, defaults to False + .. versionadded:: 1.8.0 + `cursor_texture`: str, defaults to + 'data/images/cursor.png' Image used to + represent the cursor if displayed + .. versionadded:: 1.8.0 + `cursor_size`: tuple, defaults to (40, 40) + Apparent size of the mouse cursor, if displayed, (None,None) value + will keep its real size. + .. versionadded:: 1.8.0 + `cursor_offset`: tuple, defaults to (None, None) + Offset of the texture image. The default value will align the + top-left corner of the image to the mouse pos. + .. versionadded:: 1.8.0 + +Example +------- + +In your configuration (`~/.kivy/config.ini`), you can add something like +this:: + + [modules] + touchring = image=mypointer.png,scale=.3,alpha=.7 + +''' + +__all__ = ('start', 'stop') + +from kivy.core.image import Image +from kivy.graphics import Color, Rectangle +from kivy import kivy_data_dir +from os.path import join + +cursor_texture = None +cursor_offset = (0, 0) +cursor_size = (20, 20) + + + +def _mouse_move(win, pos, *args): + print "move" + if hasattr(win, '_cursor'): + c = win._cursor + else: + with win.canvas.after: + Color(1, 1, 1, 1, mode='rgba') + win._cursor = c = Rectangle(texture=cursor_texture, + size=cursor_size) + + c.pos = pos[0] + cursor_offset[0], pos[1] -cursor_size[1] + cursor_offset[1] + + +def start(win, ctx): + # XXX use ctx ! + global cursor_size, cursor_texture, cursor_offset + + cursor_texture = Image(join(kivy_data_dir, 'images', 'cursor.png')).texture + cursor_size = ctx.config.get('cursor_size', cursor_size) + if isinstance(cursor_size, str): + cursor_size = [int(x) for x in cursor_size.split('x')] + + cursor_offset = ctx.config.get('cursor_offset', (0, 0)) + if isinstance(cursor_offset, str): + cursor_offset = [int(x) for x in cursor_offset.split('x')] + + win.bind(mouse_pos=_mouse_move) + + +def stop(win, ctx): + win.unbind(mouse_pos=_mouse_move) diff --git a/kivy/modules/touchring.py b/kivy/modules/touchring.py index af4218444..d6375a3b4 100644 --- a/kivy/modules/touchring.py +++ b/kivy/modules/touchring.py @@ -17,13 +17,13 @@ Configuration Opacity of the image. `show_cursor`: boolean, defaults to False .. versionadded:: 1.8.0 - `cursor_image`: str, defaults to - 'atlas://data/images/defaulttheme/slider_cursor' Image used to + `cursor_texture`: str, defaults to + 'data/images/cursor.png' Image used to represent the cursor if displayed .. versionadded:: 1.8.0 - `cursor_size`: tuple, defaults to (None, None) - Apparent size of the mouse cursor, if displayed, default value + `cursor_size`: tuple, defaults to (40, 40) + Apparent size of the mouse cursor, if displayed, (None,None) value will keep its real size. .. versionadded:: 1.8.0 @@ -49,13 +49,12 @@ __all__ = ('start', 'stop') from kivy.core.image import Image from kivy.graphics import Color, Rectangle from kivy.logger import Logger +from kivy import kivy_data_dir +from os.path import join pointer_image = None pointer_scale = 1.0 pointer_alpha = 0.7 -cursor_image = '' -cursor_offset = (0, 0) -cursor_size = (None, None) def _touch_down(win, touch): @@ -94,56 +93,22 @@ def _touch_up(win, touch): ud['tr.grab'] = False -def _mouse_move(win, pos, *args): - global cursor_size - if hasattr(win, '_cursor'): - c = win._cursor - else: - with win.canvas.after: - img = Image(cursor_image) - Color(1, 1, 1, 1, mode='rgba') - size = ( - cursor_size[0] or img.texture.size[0], - cursor_size[1] or img.texture.size[1] - ) - print(size) - win._cursor = c = Rectangle(texture=img.texture, - size=size) - - c.pos = pos[0] + cursor_offset[0], pos[1] - c.size[1] + cursor_offset[1] - - def start(win, ctx): # XXX use ctx ! - global pointer_image, pointer_scale, pointer_alpha, cursor_size,\ - cursor_image, cursor_offset + global pointer_image, pointer_scale, pointer_alpha + pointer_fn = ctx.config.get('image', 'atlas://data/images/defaulttheme/ring') pointer_scale = float(ctx.config.get('scale', 1.0)) pointer_alpha = float(ctx.config.get('alpha', 1.0)) pointer_image = Image(pointer_fn) - cursor_image = ctx.config.get( - 'cursor_image', - 'atlas://data/images/defaulttheme/slider_cursor') - cursor_size = ctx.config.get('cursor_size', (None, None)) - if isinstance(cursor_size, str): - cursor_size = [int(x) for x in cursor_size.split('x')] - - cursor_offset = ctx.config.get('cursor_offset', (0, 0)) - if isinstance(cursor_offset, str): - cursor_offset = [int(x) for x in cursor_offset.split('x')] win.bind(on_touch_down=_touch_down, on_touch_move=_touch_move, on_touch_up=_touch_up) - if ctx.config.get('show_cursor', False): - Logger.info('Base: Adding binding for mouse move') - win.bind(mouse_pos=_mouse_move) - def stop(win, ctx): win.unbind(on_touch_down=_touch_down, on_touch_move=_touch_move, - on_touch_up=_touch_up, - on_mouse_pos=_mouse_move) + on_touch_up=_touch_up) From 72ac4297b3cf0bf3865d19fde270ecf42c15d138 Mon Sep 17 00:00:00 2001 From: Fabian Schuetz Date: Wed, 4 Mar 2015 15:12:55 +0100 Subject: [PATCH 2/4] touchring and cursor are now two modules, added better cursor, fixed positioning of cursor (depends on image aswell) --- kivy/modules/touchring.py | 1 - 1 file changed, 1 deletion(-) diff --git a/kivy/modules/touchring.py b/kivy/modules/touchring.py index d6375a3b4..5644db2b8 100644 --- a/kivy/modules/touchring.py +++ b/kivy/modules/touchring.py @@ -48,7 +48,6 @@ __all__ = ('start', 'stop') from kivy.core.image import Image from kivy.graphics import Color, Rectangle -from kivy.logger import Logger from kivy import kivy_data_dir from os.path import join From 96ac53eb85d5506105f28b4166c3a34b90226042 Mon Sep 17 00:00:00 2001 From: gabriel pettier Date: Thu, 10 Nov 2016 01:34:16 +0100 Subject: [PATCH 3/4] replace cursor image image is cc0, from http://www.cursor.cc/?action=icon&file_id=67141 --- kivy/data/images/cursor.png | Bin 8271 -> 386 bytes 1 file changed, 0 insertions(+), 0 deletions(-) diff --git a/kivy/data/images/cursor.png b/kivy/data/images/cursor.png index 56c5055652c496669bdd19127263720c39e213fe..cbce704f7a630fd4c391cb4c3905f413c83f1fda 100644 GIT binary patch literal 386 zcmeAS@N?(olHy`uVBq!ia0vp^3LwnE0wix1Z>k4UEa{HEjtmSN`?>!lvVtU&J%W50 z7^>757#dm_7=8hT8eT9klo~KFyh>nTu$sZZAYL$MSD+10f+@+{-G$+Qd;gjJKpuOE zr>`sf18yz`1@reu9)fgsdAc};cpQH_=^)<$1rFzhH~;@Pvexk{e5G-k&-<8XmrYmT zlYV8L`(4X9=KS?^DV*T8K(3f$izgf7{7)QTn7R*yJ`#}V^rbVz%?PROL2pi zo4{?45dVt?4zCZSUQS^Z4OHFsp25p!@4D>XOk*w%b}#D>j+F=gir!;<`cReqsr-`p z--0(XOH5Xi-RbDp4s?}jiEBhjN@7W>RdP`(kYX@0Ff`LOG}JXT2r)3UGB&a@G}Q(& o3=E=Kg1)0@$jwj5OsmAyU|mdKI;Vst0KN)(!~g&Q literal 8271 zcmV-VAh6$wP)zwbF!)!hjOh=OQDz;#pvQ4|?v5C<2~k2{W_abZN1aUDir)H}|_xz~#$ z=ygL8Q3TO(8y&qkE>TnnTM{5Z=qx}8CM*d_)9G5zIq&cOao$?GyE=WUx~saXa-RB- zknXB;>b$@A*_YPOiM77yv&*-&aXxP3R|jZ3^+=0X(eFDpVjz+NzIge<9?>5MPrn zQQrfMPSf2A6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#+Qo-ul}Dk|y`9n}lF-hGEJYr>VuCMk)psNl+Z0!0c`(k(hYEs(D+=d-m* zWqn$?9sxKbbcDXCqEj77+S9CxD%1`Ii6mX87o|C-*kjyBmujbu?v>?m-{KhEuA+7& zbd;txqgqw;6CK(!F4IEkU=vTF8|8c4S`7d#^vohRW9vq~N}iF#@vNx>&pl4!-8|97 z=k{JM7DCJF>3#K%WI_L1TN7o5n{jodNDt`$q+%LPdi4gqIM&2Z)z>xQit<_;-V(ad z>zGc}Pz>_kZffh9H2i+E{Rxjp6={UQ(kMdygooJ1-O?Dz*p%S72P>%;T{JtSyvS@uFLei-ZLIk zYVI%@y+=D#R-k-s1XHsz_=*D8_Ij0GQa=(Pg|{EL_=_q@$~PI`Qau+Uay=2N^g->P z@^0VIi(_N!8M;^%g|2ZuYB=_?df-=HMFqM^@6@6+(a>K!9LJ(wt?N~AC&yS-v|CnX z$bYiM``&UfA+8I$LNhO7~9;Ue1_C9^e8CI$0?Nf-e`i3SHDX&1G@)~zJ z;7|pP>H_VjYVlsWV13HN&(wt)cVpaa&A{5Jt8`o{ng;{o!!;`F;?bc3RaDXU^&(}{ zLc2kL*cW=2*1O@PWmU9EXVga>r{MNG#J9;X?Op?iRqW=NBW0)rl{xPH7Rl}ggp?j1hLz-tn~i+r2x0a#ZZN|PgXAlxDAL+ zZ&ZP%lu}A5rIb=iDW#NBN-3q3Qc5YMlu}A5rIb=iDW#NBN-6D${y*C_;aph|)9L^K N002ovPDHLkV1k)@y#D|I From a7550498775e587e96e71d28dbfb076cda25efdb Mon Sep 17 00:00:00 2001 From: gabriel pettier Date: Thu, 10 Nov 2016 01:34:47 +0100 Subject: [PATCH 4/4] cleanup cursor and touchring code and doc rework of pr #3097 --- kivy/modules/cursor.py | 72 +++++++++++++++++---------------------- kivy/modules/touchring.py | 17 --------- 2 files changed, 31 insertions(+), 58 deletions(-) diff --git a/kivy/modules/cursor.py b/kivy/modules/cursor.py index 18a70c621..14ca2505c 100644 --- a/kivy/modules/cursor.py +++ b/kivy/modules/cursor.py @@ -1,34 +1,23 @@ ''' -Touchring -========= +Cursor +====== -Shows rings around every touch on the surface / screen. You can use this module -to check that you don't have any calibration issues with touches. +Shows a cursor following mouse motion events, useful on systems with no +visible native mouse cursor. Configuration ------------- :Parameters: - `image`: str, defaults to '/data/images/ring.png' - Filename of the image to use. - `scale`: float, defaults to 1. - Scale of the image. - `alpha`: float, defaults to 1. - Opacity of the image. - `show_cursor`: boolean, defaults to False - .. versionadded:: 1.8.0 - `cursor_texture`: str, defaults to - 'data/images/cursor.png' Image used to - represent the cursor if displayed - .. versionadded:: 1.8.0 - `cursor_size`: tuple, defaults to (40, 40) + `texture`: str, defaults to + 'data/images/cursor.png' Image used to represent the cursor if + displayed + `size`: tuple, defaults to (40, 40) Apparent size of the mouse cursor, if displayed, (None,None) value will keep its real size. - .. versionadded:: 1.8.0 - `cursor_offset`: tuple, defaults to (None, None) + `offset`: tuple, defaults to (None, None) Offset of the texture image. The default value will align the top-left corner of the image to the mouse pos. - .. versionadded:: 1.8.0 Example ------- @@ -37,8 +26,9 @@ In your configuration (`~/.kivy/config.ini`), you can add something like this:: [modules] - touchring = image=mypointer.png,scale=.3,alpha=.7 + cursor = texture=mypointer.png,size=20x20,offset=20x20 +.. versionadded:: 1.9.2 ''' __all__ = ('start', 'stop') @@ -46,41 +36,41 @@ __all__ = ('start', 'stop') from kivy.core.image import Image from kivy.graphics import Color, Rectangle from kivy import kivy_data_dir +from kivy.compat import string_types from os.path import join - -cursor_texture = None -cursor_offset = (0, 0) -cursor_size = (20, 20) +from functools import partial - -def _mouse_move(win, pos, *args): - print "move" +def _mouse_move(texture, size, offset, win, pos, *args): if hasattr(win, '_cursor'): c = win._cursor else: - with win.canvas.after: + with win.canvas.after: Color(1, 1, 1, 1, mode='rgba') - win._cursor = c = Rectangle(texture=cursor_texture, - size=cursor_size) + win._cursor = c = Rectangle(texture=texture, size=size) - c.pos = pos[0] + cursor_offset[0], pos[1] -cursor_size[1] + cursor_offset[1] + c.pos = pos[0] + offset[0], pos[1] - size[1] + offset[1] def start(win, ctx): - # XXX use ctx ! - global cursor_size, cursor_texture, cursor_offset - - cursor_texture = Image(join(kivy_data_dir, 'images', 'cursor.png')).texture - cursor_size = ctx.config.get('cursor_size', cursor_size) - if isinstance(cursor_size, str): + cursor_texture = Image( + ctx.config.get('texture', join(kivy_data_dir, 'images', 'cursor.png')) + ).texture + cursor_size = ctx.config.get('size') + print type(cursor_size) + if isinstance(cursor_size, string_types): cursor_size = [int(x) for x in cursor_size.split('x')] + elif not cursor_size: + cursor_size = cursor_texture.size + print cursor_size - cursor_offset = ctx.config.get('cursor_offset', (0, 0)) - if isinstance(cursor_offset, str): + cursor_offset = ctx.config.get('offset', (0, 0)) + if isinstance(cursor_offset, string_types): cursor_offset = [int(x) for x in cursor_offset.split('x')] - win.bind(mouse_pos=_mouse_move) + win.bind( + mouse_pos=partial( + _mouse_move, cursor_texture, cursor_size, cursor_offset)) def stop(win, ctx): diff --git a/kivy/modules/touchring.py b/kivy/modules/touchring.py index 5644db2b8..e579e28f8 100644 --- a/kivy/modules/touchring.py +++ b/kivy/modules/touchring.py @@ -15,23 +15,6 @@ Configuration Scale of the image. `alpha`: float, defaults to 1. Opacity of the image. - `show_cursor`: boolean, defaults to False - .. versionadded:: 1.8.0 - `cursor_texture`: str, defaults to - 'data/images/cursor.png' Image used to - represent the cursor if displayed - - .. versionadded:: 1.8.0 - `cursor_size`: tuple, defaults to (40, 40) - Apparent size of the mouse cursor, if displayed, (None,None) value - will keep its real size. - - .. versionadded:: 1.8.0 - `cursor_offset`: tuple, defaults to (None, None) - Offset of the texture image. The default value will align the - top-left corner of the image to the mouse pos. - - .. versionadded:: 1.8.0 Example -------