pitivi r1149 - in branches/SOC_2008_BLEWIS: . pitivi/ui
- From: blewis svn gnome org
- To: svn-commits-list gnome org
- Subject: pitivi r1149 - in branches/SOC_2008_BLEWIS: . pitivi/ui
- Date: Sun, 29 Jun 2008 21:20:02 +0000 (UTC)
Author: blewis
Date: Sun Jun 29 21:20:02 2008
New Revision: 1149
URL: http://svn.gnome.org/viewvc/pitivi?rev=1149&view=rev
Log:
reviewed by: <delete if not using a buddy>
* pitivi/ui/complextimeline.py:
ComplexTrack moved out of testcomplex.py and into complextimeline.py
ComplexLayers now contains VList() of ComplexTrack objects.
* pitivi/ui/testcomplex.py:
ComplexTrack move out of here and into complextimeline.py
Code now inserts current directory into pitivi path, so that pitivi code
can be imported properly
Modified:
branches/SOC_2008_BLEWIS/ChangeLog
branches/SOC_2008_BLEWIS/pitivi/ui/complextimeline.py
branches/SOC_2008_BLEWIS/pitivi/ui/testcomplex.py
Modified: branches/SOC_2008_BLEWIS/pitivi/ui/complextimeline.py
==============================================================================
--- branches/SOC_2008_BLEWIS/pitivi/ui/complextimeline.py (original)
+++ branches/SOC_2008_BLEWIS/pitivi/ui/complextimeline.py Sun Jun 29 21:20:02 2008
@@ -33,28 +33,187 @@
from layerwidgets import TopLayer, CompositionLayer
from complexinterface import ZoomableWidgetInterface
import goocanvas
+from util import *
+from pitivi.timeline.objects import MEDIA_TYPE_AUDIO, MEDIA_TYPE_VIDEO
+
+VIDEO_TRACK_HEIGHT = 50
+AUDIO_TRACK_HEIGHT = 20
+VIDEO_SOURCE = (
+ goocanvas.Rect,
+ {
+ "height" : VIDEO_TRACK_HEIGHT,
+ "stroke_color" : "black",
+ "fill_color_rgba" : 0x55663388
+ },
+ {}
+)
+
+AUDIO_SOURCE = (
+ goocanvas.Rect,
+ {
+ "height" : AUDIO_TRACK_HEIGHT,
+ "stroke_color" : "black",
+ "fill_color_rgba" : 0x556633FF
+ },
+ {}
+)
+
+BACKGROUND = (
+ goocanvas.Rect,
+ {
+ "height" : 32.0,
+ "width" : 100,
+ "stroke_color" : "gray",
+ "fill_color" : "gray",
+ },
+ {}
+)
+
+LABEL = (
+ Text,
+ {
+ "font" : "Sans 9",
+ "text" : "will be replaced",
+ "fill_color_rgba" : 0x66AA66FF,
+ "anchor" : gtk.ANCHOR_CENTER
+ },
+ {}
+)
+
+class ComplexTrack(SmartGroup):
+ __gtype_name__ = 'ComplexTrack'
+
+ def __init__(self, *args, **kwargs):
+ SmartGroup.__init__(self, *args, **kwargs)
+ self.widgets = {}
+ self.elements = {}
+ self.sig_ids = None
+ self.comp = None
+ # more of a factor, really
+ self._zoom_adjustment = gtk.Adjustment()
+ self._zoom_ratio = 0.0
+ self._zoom_adjustment.lower = 0.1
+ self._zoom_adjustment.upper = 10
+ self._zoom_adjustment.connect("value-changed", self._adjust_zoom)
+ self.set_zoom_ratio(1.0)
+ self.object_style = None
+ self.bg = make_item(BACKGROUND)
+ #self.add_child(self.bg)
+
+ def get_zoom_adjustment(self):
+ return self._zoom_adjustment
+
+ def _adjust_zoom(self, adjustment):
+ self._zoom_ratio = adjustment.get_value()
+ self._zoom()
+
+ def set_zoom_ratio(self, ratio):
+ self._zoom_adjustment.set_value(ratio)
+
+ def set_composition(self, comp):
+ if self.sig_ids:
+ for sig in self.sig_ids:
+ comp.disconnect(sig)
+ self.comp = comp
+ self.object_style = VIDEO_SOURCE
+ if comp:
+ added = comp.connect("source-added", self._objectAdded)
+ removed = comp.connect("source-removed", self._objectRemoved)
+ self.sig_ids = (added, removed)
+ if comp.media_type == MEDIA_TYPE_VIDEO:
+ self.object_style = VIDEO_SOURCE
+ self.bg.props.height = VIDEO_TRACK_HEIGHT
+ else:
+ self.object_style = AUDIO_SOURCE
+ self.bg.props.height = AUDIO_TRACK_HEIGHT
+
+
+ def _objectAdded(self, timeline, element):
+ w = self.make_element_widget(element)
+ self.widgets[element] = w
+ self.elements[w] = element
+ self.add_child(w)
+
+ def _objectRemoved(self, timeline, element):
+ w = self.widgets[element]
+ self.remove(w)
+ del self.widgets[element]
+ del self.element[w]
+
+ def ns_to_pixel(self, time):
+ if time == gst.CLOCK_TIME_NONE:
+ return 0
+ return (float(time) / gst.SECOND) * self._zoom_ratio
+
+ def pixel_to_ns(self, pixel):
+ return long(pixel * gst.SECOND / self._zoom_ratio)
+
+ def start_duration_cb(self, obj, start, duration, widget):
+ widget.props.width = self.ns_to_pixel(duration)
+ self.set_child_pos(widget, (self.ns_to_pixel(start), 0))
+
+ def _drag_cb(self, item, pos):
+ x, y = pos
+ element = self.elements[item]
+ element.setStartDurationTime(max(self.pixel_to_ns(x), 0), -1)
+
+ def _zoom(self):
+ """Force resize if zoom ratio changes"""
+ for child in self.widgets:
+ element = self.elements[child]
+ start = element.start
+ duration = element.duration
+ self.start_duration_cb(self, start, duration, child)
+
+ def make_element_widget(self, element):
+ rect = make_item(self.object_style)
+ rect.props.width = self.ns_to_pixel(element.duration)
+ # for the moment, not labeling sources
+ ret = rect
+ make_dragable(self.canvas, ret, moved=self._drag_cb)
+ element.connect("start-duration-changed", self.start_duration_cb, ret)
+ ret.props.x = self.ns_to_pixel(element.start)
+ return ret
class CompositionLayers(goocanvas.Canvas, ZoomableWidgetInterface):
""" Souped-up VBox that contains the timeline's CompositionLayer """
- def __init__(self, leftsizegroup, hadj, layerinfolist):
+ def __init__(self, leftsizegroup, layerinfolist):
goocanvas.Canvas.__init__(self)
self.leftSizeGroup = leftsizegroup
self.layerInfoList = layerinfolist
self.layerInfoList.connect('layer-added', self._layerAddedCb)
self.layerInfoList.connect('layer-removed', self._layerRemovedCb)
self._createUI()
+ self.props.automatic_bounds = False
+ self.props.integer_layout = True
+ self.connect("size_allocate", self._size_allocate)
+
+ def _size_allocate(self, unused_layout, allocation):
+ width = max(allocation.width, self.layers.width)
+ for layer in self.layers:
+ layer.bg.props.width = width
+
+ def _request_size(self, item, prop):
+ self.set_size_request(int(self.layers.width), int(
+ self.layers.height))
+ self.set_bounds(0, 0, self.layers.width, self.layers.height)
+ return True
def _createUI(self):
self.set_border_width(2)
- self.layers = []
+ self.layers = VList(canvas=self)
+ self.layers.connect("notify::width", self._request_size)
+ self.layers.connect("notify::height", self._request_size)
+ self.get_root_item().add_child(self.layers)
for layerinfo in self.layerInfoList:
- pass
+ self._layerAddedCb(layerinfo)
## ZoomableWidgetInterface overrides
def getDuration(self):
- return max([layer.getDuration() for layer in self.layers])
+ return max([layer.composition.duration for layer in
+ self.layerInfoList])
def getStartTime(self):
# the start time is always 0 (for display reason)
@@ -68,10 +227,14 @@
## LayerInfoList callbacks
- def _layerAddedCb(self, layerInfoList, position):
- pass
+ def _layerAddedCb(self, layer, position=-1):
+ track = ComplexTrack()
+ track.set_composition(layer.composition)
+ track.set_canvas(self)
+ self.layers.add_child(track)
def _layerRemovedCb(self, unused_layerInfoList, position):
+ #TODO handle this, and test it somehow
pass
#
# Complex Timeline Design v2 (08 Feb 2006)
@@ -107,9 +270,6 @@
self.zoomratio = 10.0
- self.hadj = gtk.Adjustment()
- self.vadj = gtk.Adjustment()
-
# common LayerInfoList
self.layerInfoList = LayerInfoList(instance.PiTiVi.current.timeline)
instance.PiTiVi.playground.connect('position', self._playgroundPositionCb)
@@ -123,6 +283,8 @@
self.set_border_width(4)
self.leftSizeGroup = gtk.SizeGroup(gtk.SIZE_GROUP_HORIZONTAL)
+ self.hadj = gtk.Adjustment()
+
# top layer (TopLayer)
self.topLayer = TopLayer(self.leftSizeGroup, self.hadj)
# overriding topLayer's ZoomableWidgetInterface methods
@@ -133,12 +295,12 @@
# List of CompositionLayers
self.compositionLayers = CompositionLayers(self.leftSizeGroup,
- self.hadj, self.layerInfoList)
+ self.layerInfoList)
# ... in a scrolled window
- self.scrolledWindow = gtk.ScrolledWindow(self.hadj, self.vadj)
+ self.scrolledWindow = gtk.ScrolledWindow(self.hadj)
self.scrolledWindow.set_policy(gtk.POLICY_ALWAYS, gtk.POLICY_AUTOMATIC)
- self.scrolledWindow.add_with_viewport(self.compositionLayers)
+ self.scrolledWindow.add(self.compositionLayers)
self.pack_start(self.scrolledWindow, expand=True)
def _layerStartDurationChangedCb(self, unused_composition, unused_start,
Modified: branches/SOC_2008_BLEWIS/pitivi/ui/testcomplex.py
==============================================================================
--- branches/SOC_2008_BLEWIS/pitivi/ui/testcomplex.py (original)
+++ branches/SOC_2008_BLEWIS/pitivi/ui/testcomplex.py Sun Jun 29 21:20:02 2008
@@ -1,4 +1,3 @@
-
import gobject
gobject.threads_init()
import gst
@@ -6,37 +5,26 @@
pygtk.require("2.0")
import gtk
import goocanvas
+import sys
import os
from itertools import cycle
from util import *
+
+root = os.path.abspath(os.path.curdir)
+print root
+if not root in sys.path:
+ sys.path.insert(0, root)
+
+from complextimeline import ComplexTrack
+from pitivi.timeline.objects import MEDIA_TYPE_VIDEO
+
SOURCES = (
("source1", 300 * gst.SECOND),
("source2", 200 * gst.SECOND),
("source3", 10 * gst.SECOND),
)
-box = (
- goocanvas.Rect,
- {
- "height" : 30,
- "stroke_color" : "black",
- "fill_color_rgba" : 0x55663388
- },
- {}
-)
-
-label = (
- Text,
- {
- "font" : "Sans 9",
- "text" : "will be replaced",
- "fill_color_rgba" : 0x66AA66FF,
- "anchor" : gtk.ANCHOR_CENTER
- },
- {}
-)
-
class TestComposition(gobject.GObject):
__gtype_name__ = "TestComposition"
__gsignals__ = {
@@ -50,6 +38,7 @@
def __init__(self, *args, **kwargs):
gobject.GObject.__init__(self, *args, **kwargs)
+ self.media_type = MEDIA_TYPE_VIDEO
def addSource(self, source, position):
self.emit("source-added", source)
@@ -82,98 +71,11 @@
self.duration = duration
self.emit("start-duration-changed", self.start, self.duration)
-class ComplexTrack(SmartGroup):
- __gtype_name__ = 'ComplexTrack'
-
- def __init__(self, *args, **kwargs):
- SmartGroup.__init__(self, *args, **kwargs)
- self.widgets = {}
- self.elements = {}
- self.sig_ids = None
- self.comp = None
- # more of a factor, really
- self._zoom_adjustment = gtk.Adjustment()
- self._zoom_ratio = 0.0
- self._zoom_adjustment.lower = 0.1
- self._zoom_adjustment.upper = 10
- self._zoom_adjustment.connect("value-changed", self._adjust_zoom)
- self.set_zoom_ratio(1.0)
-
- def get_zoom_adjustment(self):
- return self._zoom_adjustment
-
- def _adjust_zoom(self, adjustment):
- self._zoom_ratio = adjustment.get_value()
- self._zoom()
-
- def set_zoom_ratio(self, ratio):
- self._zoom_adjustment.set_value(ratio)
-
- def set_composition(self, comp):
- if self.sig_ids:
- for sig in self.sig_ids:
- comp.disconnect(sig)
- self.comp = comp
- if comp:
- added = comp.connect("source-added", self._objectAdded)
- removed = comp.connect("source-removed", self._objectRemoved)
- self.sig_ids = (added, removed)
-
- def _objectAdded(self, timeline, element):
- w = self.make_element_widget(element)
- self.widgets[element] = w
- self.elements[w] = element
- self.add_child(w)
-
- def _objectRemoved(self, timeline, element):
- w = self.widgets[element]
- self.remove(w)
- del self.widgets[element]
- del self.element[w]
-
- def ns_to_pixel(self, time):
- if time == gst.CLOCK_TIME_NONE:
- return 0
- return (float(time) / gst.SECOND) * self._zoom_ratio
-
- def pixel_to_ns(self, pixel):
- return long(pixel * gst.SECOND / self._zoom_ratio)
-
- def start_duration_cb(self, obj, start, duration, widget):
- widget.props.width = self.ns_to_pixel(duration)
- self.set_child_pos(widget, (self.ns_to_pixel(start), 0))
-
- def _drag_cb(self, item, pos):
- x, y = pos
- pos_label.props.text = "(%g, %g)" % pos
- element = self.elements[item]
- element.setStartDurationTime(max(self.pixel_to_ns(x), 0), -1)
-
- def _zoom(self):
- """Force resize if zoom ratio changes"""
- for child in self.children:
- element = self.elements[child]
- start = element.start
- duration = element.duration
- self.start_duration_cb(self, start, duration, child)
-
- def make_element_widget(self, element):
- rect = make_item(box)
- rect.props.width = self.ns_to_pixel(element.duration)
- # for the moment, not labeling sources
- ret = rect
- make_dragable(self.canvas, ret, moved=self._drag_cb)
- element.connect("start-duration-changed", self.start_duration_cb, ret)
- ret.props.x = self.ns_to_pixel(element.start)
- return ret
-
c = goocanvas.Canvas()
t = ComplexTrack(c)
model = TestComposition()
t.set_composition(model)
-pos_label = goocanvas.Text(x=0, y=0, anchor=gtk.ANCHOR_NW)
c.get_root_item().add_child(t)
-c.get_root_item().add_child(pos_label)
cur = long(0)
for name, duration in SOURCES:
model.addSource(TestTimelineObject(name, cur, duration), None)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]