Commit 92701fca authored by Edward Hervey's avatar Edward Hervey

* pitivi/playground.py:

Added switchToTimeline() method.
Don't seek to values lower than 0.
* pitivi/timeline.py:
Add default sources behaviours in compositions.
Added setDefaultSource() and getDefaultSource() methods.
* pitivi/ui/complexinterface.py:
pixelToNs should return a long (to cope with 2**64 values).
* pitivi/ui/complexlayer.py:
Don't expand audio tracks at startup.
* pitivi/ui/ruler.py:
Allow seeking on the ruler.
* pitivi/ui/sourcefactories.py:
Use the source thumbnail as the icon pixbuf when doing drag and drop.
* pitivi/ui/timelineobjects.py:
Switch to Timeline in the playground if we drop something in it.
* pitivi/ui/viewer.py:
Use bilinear scaling method with videoscale.
Use videosink pad to figure out caps modifications.


git-svn-id: svn+ssh://svn.gnome.org/svn/pitivi/trunk@801 d3729300-e425-0410-8a4c-d956edccc248
parent 6f2e4c74
2006-08-09 Edward Hervey <edward@fluendo.com>
* pitivi/playground.py:
Added switchToTimeline() method.
Don't seek to values lower than 0.
* pitivi/timeline.py:
Add default sources behaviours in compositions.
Added setDefaultSource() and getDefaultSource() methods.
* pitivi/ui/complexinterface.py:
pixelToNs should return a long (to cope with 2**64 values).
* pitivi/ui/complexlayer.py:
Don't expand audio tracks at startup.
* pitivi/ui/ruler.py:
Allow seeking on the ruler.
* pitivi/ui/sourcefactories.py:
Use the source thumbnail as the icon pixbuf when doing drag and drop.
* pitivi/ui/timelineobjects.py:
Switch to Timeline in the playground if we drop something in it.
* pitivi/ui/viewer.py:
Use bilinear scaling method with videoscale.
Use videosink pad to figure out caps modifications.
2006-08-08 Edward Hervey <edward@fluendo.com>
* pitivi/ui/viewer.py:
......
......@@ -26,7 +26,7 @@ Where all gstreamer pipelines play.
import gobject
import gst
from bin import SmartBin, SmartDefaultBin, SmartFileBin
from bin import SmartBin, SmartDefaultBin, SmartFileBin, SmartTimelineBin
from utils import bin_contains
class PlayGround(gobject.GObject):
......@@ -190,6 +190,21 @@ class PlayGround(gobject.GObject):
gst.debug("switching to default")
return self.switchToPipeline(self.default)
def switchToTimeline(self):
"""
switch to the timeline.
Warning : if there's more than one timeline controlled, the first one
will be taken.
"""
if isinstance(self.current, SmartTimelineBin):
# fast path
return True
for pipeline in self.pipelines:
if isinstance(pipeline, SmartTimelineBin):
self.switchToPipeline(pipeline)
return True
return False
def setVideoSinkThread(self, vsinkthread):
""" sets the video sink thread """
gst.debug("video sink thread : %s" % vsinkthread)
......@@ -256,6 +271,9 @@ class PlayGround(gobject.GObject):
gobject.source_remove(self._positiontimeoutid)
self._positiontimeoutid = 0
if value < 0:
value = long(0)
# actual seeking
res = target.seek(1.0, format, gst.SEEK_FLAG_FLUSH,
gst.SEEK_TYPE_SET, value,
......
......@@ -76,6 +76,19 @@ class Timeline(gobject.GObject):
self.videocomp = TimelineComposition(media_type = MEDIA_TYPE_VIDEO, name="videocomp")
self.videocomp.linkObject(self.audiocomp)
# add default audio/video sources
defaultaudio = gst.element_factory_make("audiotestsrc")
defaultaudio.props.volume = 0
defaultaudiosource = gst.element_factory_make("gnlsource", "defaultaudiosource")
defaultaudiosource.add(defaultaudio)
self.audiocomp.setDefaultSource(defaultaudiosource)
defaultvideo = gst.element_factory_make("videotestsrc")
defaultvideo.props.pattern = 2
defaultvideosource = gst.element_factory_make("gnlsource", "defaultvideosource")
defaultvideosource.add(defaultvideo)
self.videocomp.setDefaultSource(defaultvideosource)
self.timeline.add(self.audiocomp.gnlobject,
self.videocomp.gnlobject)
self.audiocomp.gnlobject.connect("pad-added", self._newAudioPadCb)
......@@ -470,6 +483,7 @@ class TimelineComposition(TimelineSource):
#sources = [(2048, 2060, [])]
self.condensed = [] # list of sources/transitions seen from a top-level view
self.sources = [(2048, 2060, [])]
self.defaultSource = None
TimelineSource.__init__(self, **kw)
def _makeGnlObject(self):
......@@ -763,6 +777,22 @@ class TimelineComposition(TimelineSource):
"""
raise NotImplementedError
def setDefaultSource(self, source):
"""
Adds a default source to the composition.
Default sources will be used for gaps within the composition.
"""
if self.defaultSource:
self.gnlobject.remove(self.defaultSource)
source.props.priority = 2 ** 32 - 1
self.gnlobject.add(source)
self.defaultSource = source
def getDefaultSource(self, source):
"""
Returns the default source.
"""
return self.defaultSource
class TimelineEffect(TimelineObject):
"""
......
......@@ -75,7 +75,7 @@ class ZoomableWidgetInterface:
"""
Returns the pixel equivalent in nanoseconds according to the zoomratio
"""
return int(pixel * gst.SECOND / self.getZoomRatio())
return long(pixel * gst.SECOND / self.getZoomRatio())
def nsToPixel(self, duration):
"""
......
......@@ -27,6 +27,8 @@ Layer system for the complex view
import gobject
import gst
import pitivi.timeline
#
# Layer system v2 (16 Feb 2006)
#
......@@ -94,7 +96,11 @@ class LayerInfoList(gobject.GObject):
if self.findCompositionLayerInfo(composition):
gst.warning("composition[%r] is already controlled!" % composition)
return
layer = LayerInfo(composition)
if composition.media_type == pitivi.timeline.MEDIA_TYPE_AUDIO:
expanded = False
else:
expanded = True
layer = LayerInfo(composition, expanded)
if pos == -1:
self._list.append(layer)
else:
......
......@@ -23,8 +23,10 @@
Widget for the complex view ruler
"""
import gobject
import gtk
import gst
import pitivi.instance as instance
from complexinterface import ZoomableWidgetInterface
class ScaleRuler(gtk.Layout, ZoomableWidgetInterface):
......@@ -33,6 +35,9 @@ class ScaleRuler(gtk.Layout, ZoomableWidgetInterface):
"expose-event":"override",
"size-allocate":"override",
"realize":"override",
"button-press-event":"override",
"button-release-event":"override",
"motion-notify-event":"override",
}
border = 5
......@@ -40,11 +45,16 @@ class ScaleRuler(gtk.Layout, ZoomableWidgetInterface):
def __init__(self, hadj):
gst.log("Creating new ScaleRule")
gtk.Layout.__init__(self)
self.add_events(gtk.gdk.POINTER_MOTION_MASK | gtk.gdk.BUTTON_PRESS_MASK | gtk.gdk.BUTTON_RELEASE_MASK)
self.set_hadjustment(hadj)
self.pixmap = None
# position is in nanoseconds
self.position = 0
self.requested_time = long(0)
self.currentlySeeking = False
self.pressed = False
## ZoomableWidgetInterface methods are handled by the container (LayerStack)
## Except for ZoomChanged
......@@ -94,6 +104,45 @@ class ScaleRuler(gtk.Layout, ZoomableWidgetInterface):
self.drawPosition(context, self.get_allocation())
return False
def do_button_press_event(self, event):
gst.debug("button pressed at x:%d" % event.x)
instance.PiTiVi.playground.switchToTimeline()
self.pressed = True
# seek at position
cur = self.pixelToNs(event.x)
self._doSeek(cur)
return True
def do_button_release_event(self, event):
gst.debug("button released at x:%d" % event.x)
self.pressed = False
return False
def do_motion_notify_event(self, event):
gst.debug("motion at event.x %d" % event.x)
if self.pressed:
# seek at position
cur = self.pixelToNs(event.x)
self._doSeek(cur)
return False
## Seeking methods
def _seekTimeoutCb(self):
gst.debug("timeout")
self.currentlySeeking = False
if not self.position == self.requested_time:
self._doSeek(self.requested_time)
def _doSeek(self, value, format=gst.FORMAT_TIME):
gst.debug("seeking to %s" % gst.TIME_ARGS (value))
if not self.currentlySeeking:
self.currentlySeeking = True
self.requested_time = value
gobject.timeout_add(80, self._seekTimeoutCb)
instance.PiTiVi.playground.seekInCurrent(value, format)
elif format == gst.FORMAT_TIME:
self.requested_time = value
## Drawing methods
......@@ -146,7 +195,7 @@ class ScaleRuler(gtk.Layout, ZoomableWidgetInterface):
zoomRatio = self.getZoomRatio()
for i in range(self.border, allocation.width, zoomRatio):
for i in range(self.border, allocation.width, int(zoomRatio)):
context.move_to(i, 0)
if (i - self.border) % (10 * zoomRatio):
......
......@@ -387,6 +387,8 @@ class SourceListWidget(gtk.VBox):
model, rows = self.treeview.get_selection().get_selected_rows()
if len(rows) < 1:
context.drag_abort(int(time.time()))
else:
self.treeview.drag_source_set_icon_pixbuf(model[rows[0]][0])
def getSelectedItems(self):
""" returns a list of selected items uri """
......
......@@ -251,6 +251,7 @@ class SimpleTimeline(gtk.Layout):
x = x + int(self.hadjustment.get_value())
self._gotFileFactory(instance.PiTiVi.current.sources[uri], x, y)
context.finish(True, False, timestamp)
instance.PiTiVi.playground.switchToTimeline()
def _realizeCb(self, unused_layout):
self.modify_bg(gtk.STATE_NORMAL, self.style.white)
......
......@@ -195,6 +195,7 @@ class PitiviViewer(gtk.VBox):
vqueue = gst.element_factory_make('queue')
cspace = gst.element_factory_make('ffmpegcolorspace')
vscale = gst.element_factory_make('videoscale')
vscale.props.method = 1
vsinkthread.add(self.videosink, vqueue, vscale, cspace)
vqueue.link(self.videosink)
cspace.link(vscale)
......@@ -202,7 +203,7 @@ class PitiviViewer(gtk.VBox):
vsinkthread.videosink = self.videosink
vsinkthread.add_pad(gst.GhostPad("sink", cspace.get_pad('sink')))
vsinkthread.get_pad("sink").connect("notify::caps", self._videosinkCapsNotifyCb)
self.videosink.get_pad("sink").connect("notify::caps", self._videosinkCapsNotifyCb)
self.drawingarea.videosink = self.videosink
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment