Package pyforms :: Package gui :: Package Controls :: Package ControlEventTimeline :: Module TimelinePointer
[hide private]
[frames] | no frames]

Source Code for Module pyforms.gui.Controls.ControlEventTimeline.TimelinePointer

 1  #!/usr/bin/python 
 2  # -*- coding: utf-8 -*- 
 3   
 4  """ pyforms.gui.Controls.ControlEventTimeline.TimelinePointer 
 5   
 6  """ 
 7   
 8  from PyQt4 import QtGui, QtCore 
 9   
10  __author__ = ["Ricardo Ribeiro", "Hugo Cachitas"] 
11  __credits__ = ["Ricardo Ribeiro", "Hugo Cachitas"] 
12  __license__ = "MIT" 
13  __version__ = "0.0" 
14  __maintainer__ = "Ricardo Ribeiro" 
15  __email__ = "ricardojvr@gmail.com" 
16  __status__ = "Development" 
17 18 19 -class TimelinePointer(object):
20
21 - def __init__(self, position, parent):
22 self._position = position 23 self._parent = parent
24
25 - def draw(self, painter, showvalues=False):
26 painter.setPen(QtGui.QColor(0, 255, 0)) 27 painter.setBrush(QtGui.QColor(0, 255, 0)) 28 painter.drawLine( 29 self.position, 8, self.position, self._parent.height()) 30 painter.drawEllipse(QtCore.QPoint(self.position, 8), 5, 5) 31 painter.drawText(self.position + 8, 8 + 4, str(self._position))
32 33 ########################################################################## 34 #### HELPERS/FUNCTIONS ################################################### 35 ########################################################################## 36
37 - def moveEvent(self):
38 pass
39
40 - def collide(self, x, y):
41 return (self.position - 5) <= x <= (self.position + 5) and 3 <= y <= 11
42
43 - def canSlideBegin(self, x, y):
44 return False
45
46 - def canSlideEnd(self, x, y):
47 return False
48
49 - def move(self, x, y):
50 x = int(round(x / self._parent._scale)) 51 if (self._position - x) >= 0 and (self._position - x) <= (self._parent.width() / self._parent._scale): 52 self._position += x 53 self.moveEvent()
54 55 ########################################################################## 56 #### PROPERTIES ########################################################## 57 ########################################################################## 58 59 @property
60 - def position(self): return self._position * self._parent._scale
61 62 @position.setter
63 - def position(self, value):
64 self._position = int(round(value / self._parent._scale)) 65 self.moveEvent()
66 67 @property
68 - def frame(self): return self._position
69