Skip to content

Commit dd13c20

Browse files
committed
Merge branch 'master' of https://github.com/kivy/kivy
2 parents 9ed42e8 + f126288 commit dd13c20

File tree

4 files changed

+18
-22
lines changed

4 files changed

+18
-22
lines changed

kivy/gesture.py

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -38,20 +38,9 @@
3838
import zlib
3939
import math
4040

41-
from kivy.compat import PY2
4241
from kivy.vector import Vector
4342

44-
# XXX we can't use io.StringIO in PY2 cause it require unicode
45-
# PY2 / StringIO ( str or unicode )
46-
# PY2 / cStringIO ( str )
47-
# PY3 / io.StringIO ( unicode )
48-
if PY2:
49-
try:
50-
from cStringIO import StringIO
51-
except ImportError:
52-
from StringIO import StringIO
53-
else:
54-
from io import StringIO
43+
from io import BytesIO
5544

5645

5746
class GestureDatabase(object):
@@ -83,15 +72,15 @@ def find(self, gesture, minscore=0.9, rotation_invariant=True):
8372

8473
def gesture_to_str(self, gesture):
8574
'''Convert a gesture into a unique string.'''
86-
io = StringIO()
75+
io = BytesIO()
8776
p = pickle.Pickler(io)
8877
p.dump(gesture)
8978
data = base64.b64encode(zlib.compress(io.getvalue(), 9))
9079
return data
9180

9281
def str_to_gesture(self, data):
9382
'''Convert a unique string to a gesture.'''
94-
io = StringIO(zlib.decompress(base64.b64decode(data)))
83+
io = BytesIO(zlib.decompress(base64.b64decode(data)))
9584
p = pickle.Unpickler(io)
9685
gesture = p.load()
9786
return gesture

kivy/graphics/instructions.pxd

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ cdef class Canvas
77
cdef class RenderContext
88

99
from vbo cimport *
10-
from context_instructions cimport *
1110
from compiler cimport *
1211
from shader cimport *
1312
from texture cimport Texture
@@ -58,6 +57,9 @@ cdef class ContextInstruction(Instruction):
5857
cdef void push_state(self, str name) except *
5958
cdef void pop_state(self, str name) except *
6059

60+
61+
from context_instructions cimport BindTexture
62+
6163
cdef class VertexInstruction(Instruction):
6264
cdef BindTexture texture_binding
6365
cdef VertexBatch batch

kivy/uix/scatter.py

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -415,24 +415,29 @@ def transform_with_touch(self, touch):
415415
if len(self._touches) == 1:
416416
return changed
417417

418-
# we have more than one touch...
419-
points = [Vector(self._last_touch_pos[t]) for t in self._touches]
418+
# we have more than one touch... list of last known pos
419+
points = [Vector(self._last_touch_pos[t]) for t in self._touches
420+
if t is not touch]
421+
# add current touch last
422+
points.append(Vector(touch.pos))
420423

421424
# we only want to transform if the touch is part of the two touches
422-
# furthest apart! So first we find anchor, the point to transform
423-
# around as the touch farthest away from touch
424-
anchor = max(points, key=lambda p: p.distance(touch.pos))
425+
# farthest apart! So first we find anchor, the point to transform
426+
# around as another touch farthest away from current touch's pos
427+
anchor = max(points[:-1], key=lambda p: p.distance(touch.pos))
425428

426429
# now we find the touch farthest away from anchor, if its not the
427430
# same as touch. Touch is not one of the two touches used to transform
428431
farthest = max(points, key=anchor.distance)
429-
if points.index(farthest) != self._touches.index(touch):
432+
if farthest is not points[-1]:
430433
return changed
431434

432435
# ok, so we have touch, and anchor, so we can actually compute the
433436
# transformation
434437
old_line = Vector(*touch.ppos) - anchor
435438
new_line = Vector(*touch.pos) - anchor
439+
if not old_line.length(): # div by zero
440+
return changed
436441

437442
angle = radians(new_line.angle(old_line)) * self.do_rotation
438443
self.apply_transform(Matrix().rotate(angle, 0, 0, 1), anchor=anchor)

kivy/uix/tabbedpanel.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -521,7 +521,7 @@ def add_widget(self, widget, index=0):
521521
super(TabbedPanel, self).add_widget(widget, index)
522522
elif isinstance(widget, TabbedPanelHeader):
523523
self_tabs = self._tab_strip
524-
self_tabs.add_widget(widget)
524+
self_tabs.add_widget(widget, index)
525525
widget.group = '__tab%r__' % self_tabs.uid
526526
self.on_tab_width()
527527
else:

0 commit comments

Comments
 (0)