Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033 import wx
00034 import wx.lib.newevent
00035
00036 import bag_helper
00037
00038 PlayheadChangedEvent, EVT_PLAYHEAD_CHANGED = wx.lib.newevent.NewEvent()
00039
00040 class TimelineStatusBar(wx.StatusBar):
00041 def __init__(self, parent, timeline):
00042 wx.StatusBar.__init__(self, parent, -1)
00043
00044 self.timeline = timeline
00045
00046 self.progress_field = 1
00047 self.timestamp_field = 2
00048 self.human_readable_field = 3
00049 self.elapsed_field = 4
00050 self.playspeed_field = 5
00051
00052 self.progress_width = 150
00053 self.timestamp_width = 125
00054 self.human_readable_width = 180
00055 self.elapsed_width = 110
00056 self.playspeed_width = 80
00057
00058 self.SetFieldsCount(6)
00059
00060 self.gauge = wx.Gauge(self, range=100)
00061 self.gauge.Hide()
00062
00063 self._reposition_progress()
00064
00065 parent.Bind(EVT_PLAYHEAD_CHANGED, lambda e: self._update())
00066 parent.Bind(wx.EVT_SIZE, self.on_size)
00067
00068 self._update()
00069
00070
00071
00072 def _get_progress(self):
00073 return self.gauge.Value
00074
00075 def _set_progress(self, value):
00076 self.gauge.Value = value
00077
00078 progress = property(_get_progress, _set_progress)
00079
00080 def on_size(self, event):
00081 main_width = self.Size[0] - (self.progress_width + self.timestamp_width + self.human_readable_width + self.elapsed_width + self.playspeed_width)
00082 self.SetStatusWidths([main_width, self.progress_width, self.timestamp_width, self.human_readable_width, self.elapsed_width, self.playspeed_width])
00083
00084 self._reposition_progress()
00085
00086 event.Skip()
00087
00088 def _reposition_progress(self):
00089 rect = self.GetFieldRect(self.progress_field)
00090
00091 self.gauge.SetPosition((rect.x + 1, rect.y + 1))
00092 self.gauge.SetSize((rect.width - 2, rect.height - 2))
00093
00094 def _update(self):
00095 if self.timeline.playhead is None or self.timeline.start_stamp is None:
00096 return
00097
00098
00099 self.SetStatusText('%d.%s' % (self.timeline.playhead.secs, str(self.timeline.playhead.nsecs)[:3]), self.timestamp_field)
00100
00101
00102 self.SetStatusText(bag_helper.stamp_to_str(self.timeline.playhead), self.human_readable_field)
00103
00104
00105 self.SetStatusText('%.3fs' % (self.timeline.playhead - self.timeline.start_stamp).to_sec(), self.elapsed_field)
00106
00107
00108 spd = self.timeline.play_speed
00109 if spd != 0.0:
00110 if spd > 1.0:
00111 spd_str = '>> %.0fx' % spd
00112 elif spd == 1.0:
00113 spd_str = '>'
00114 elif spd > 0.0:
00115 spd_str = '> 1/%.0fx' % (1.0 / spd)
00116 elif spd > -1.0:
00117 spd_str = '< 1/%.0fx' % (1.0 / -spd)
00118 elif spd == 1.0:
00119 spd_str = '<'
00120 else:
00121 spd_str = '<< %.0fx' % -spd
00122
00123 self.SetStatusText(spd_str, self.playspeed_field)
00124 else:
00125 self.SetStatusText('', self.playspeed_field)