pitivi r1148 - in branches/SOC_2008_BLEWIS: . pitivi/ui



Author: blewis
Date: Fri Jun 27 15:30:20 2008
New Revision: 1148
URL: http://svn.gnome.org/viewvc/pitivi?rev=1148&view=rev

Log:
reviewed by: <delete if not using a buddy>
* pitivi/ui/complextimeline.py:
switched CompositionLayers over to goocanvas. Currently, doesn't do
anything. This is just the first step to merging in the new
complextimeline code.
* pitivi/ui/mainwindow.py:
tweaked geometry hints so that the window displays comfortably on my eeepc
(min height is now set to 480)
* pitivi/ui/testcomplex.py:
added code borrowed from complexinterface to ComplexTrack to support
zooming. test window now has a slider for zooming. had to remove labels
from complex source wigets to make zooming work properly.
* pitivi/ui/timelineobjects.py:
changed default height of simple source widets (also to make  them fit
more comfortably on my eeepc screen).
* pitivi/ui/util.py:
added function "printall" to aid with debugging.


Modified:
   branches/SOC_2008_BLEWIS/ChangeLog
   branches/SOC_2008_BLEWIS/pitivi/ui/complextimeline.py
   branches/SOC_2008_BLEWIS/pitivi/ui/mainwindow.py
   branches/SOC_2008_BLEWIS/pitivi/ui/testcomplex.py
   branches/SOC_2008_BLEWIS/pitivi/ui/timelineobjects.py
   branches/SOC_2008_BLEWIS/pitivi/ui/util.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	Fri Jun 27 15:30:20 2008
@@ -32,30 +32,24 @@
 from complexlayer import LayerInfoList
 from layerwidgets import TopLayer, CompositionLayer
 from complexinterface import ZoomableWidgetInterface
+import goocanvas
 
-class CompositionLayers(gtk.VBox, ZoomableWidgetInterface):
+class CompositionLayers(goocanvas.Canvas, ZoomableWidgetInterface):
     """ Souped-up VBox that contains the timeline's CompositionLayer """
 
     def __init__(self, leftsizegroup, hadj, layerinfolist):
-        gtk.VBox.__init__(self)
-        self.modify_bg(gtk.STATE_NORMAL, gtk.gdk.Color(1,0,0))
+        goocanvas.Canvas.__init__(self)
         self.leftSizeGroup = leftsizegroup
-        self.hadj = hadj
         self.layerInfoList = layerinfolist
         self.layerInfoList.connect('layer-added', self._layerAddedCb)
         self.layerInfoList.connect('layer-removed', self._layerRemovedCb)
         self._createUI()
 
     def _createUI(self):
-        self.set_spacing(5)
         self.set_border_width(2)
         self.layers = []
         for layerinfo in self.layerInfoList:
-            complayer = CompositionLayer(self.leftSizeGroup, self.hadj,
-                                         layerinfo)
-            self.layers.append(complayer)
-            self.pack_start(complayer, expand=False)
-
+            pass
 
     ## ZoomableWidgetInterface overrides
 
@@ -67,28 +61,18 @@
         return 0
 
     def zoomChanged(self):
-        for layer in self.layers:
-            layer.zoomChanged()
+        pass
 
     def timelinePositionChanged(self, value, frame):
-        for layer in self.layers:
-            layer.timelinePositionChanged(value, frame)
+        pass
 
     ## LayerInfoList callbacks
 
     def _layerAddedCb(self, layerInfoList, position):
-        complayer = CompositionLayer(self.leftSizeGroup, self.hadj,
-                                     layerInfoList[position])
-        self.layers.insert(position, complayer)
-        self.pack_start(complayer, expand=False)
-        self.reorder_child(complayer, position)
+        pass
 
     def _layerRemovedCb(self, unused_layerInfoList, position):
-        # find the proper child
-        child = self.layers[position]
-        # remove it
-        self.remove(child)
-
+        pass
 #
 # Complex Timeline Design v2 (08 Feb 2006)
 #

Modified: branches/SOC_2008_BLEWIS/pitivi/ui/mainwindow.py
==============================================================================
--- branches/SOC_2008_BLEWIS/pitivi/ui/mainwindow.py	(original)
+++ branches/SOC_2008_BLEWIS/pitivi/ui/mainwindow.py	Fri Jun 27 15:30:20 2008
@@ -217,7 +217,7 @@
     def _createUi(self):
         """ Create the graphical interface """
         self.set_title("%s v%s" % (APPNAME, pitivi_version))
-        self.set_geometry_hints(min_width=800, min_height=600)
+        self.set_geometry_hints(min_width=800, min_height=480)
 
         self.connect("destroy", self._destroyCb)
 
@@ -239,7 +239,7 @@
         self.timeline.showSimpleView()
         timelineframe = gtk.Frame()
         timelineframe.add(self.timeline)
-        vpaned.pack2(timelineframe, resize=False, shrink=False)
+        vpaned.pack2(timelineframe, resize=True, shrink=True)
 
         hpaned = gtk.HPaned()
         vpaned.pack1(hpaned, resize=True, shrink=False)

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	Fri Jun 27 15:30:20 2008
@@ -1,6 +1,7 @@
 
 import gobject
 gobject.threads_init()
+import gst
 import pygtk
 pygtk.require("2.0")
 import gtk
@@ -10,9 +11,9 @@
 from util import *
 
 SOURCES = (
-    ("source1", 300),
-    ("source2", 200),
-    ("source3", 50),
+    ("source1", 300 * gst.SECOND),
+    ("source2", 200 * gst.SECOND),
+    ("source3", 10 * gst.SECOND),
 )
 
 box = (
@@ -64,9 +65,6 @@
             (gobject.TYPE_PYOBJECT, gobject.TYPE_PYOBJECT, )),
     }
 
-    duration = gobject.property(type=int)
-    start = gobject.property(type=int)
-
     class Factory:
         name=None
 
@@ -84,35 +82,6 @@
             self.duration = duration
         self.emit("start-duration-changed", self.start, self.duration)
 
-#class ComplexTimelineObject(goocanvas.Rect):
-#
-#    def source_signals = (("start-duration-changed", self._set_size_position),)
-#    
-#    def __init__(self, source=None, *args, **kwargs):
-#        goocanvas.Rect.__init__(self, *args, **kwargs)
-#        if self.source:
-#            self.set_source(source)
-#
-#    def _connect(self, source):
-#        self.sigids = [source.connect(sig, hdlr) for sig, hdlr
-#            in self.source_signals]
-#
-#    def _disconnect(self):
-#        for sig in self.sigids:
-#            self.source.disconnect(sig)
-#
-#    def set_source(self, source):
-#        if self.source:
-#            self._disconnect()
-#        self.source = source
-#        if self.source:
-#            self._connect(source)
-#        self._set_size_position(source, source.props.start,
-#            source.props.duration)
-#
-#    def _set_size_position(self, source, start, duration):
-#        pass
-
 class ComplexTrack(SmartGroup):
     __gtype_name__ = 'ComplexTrack'
 
@@ -122,6 +91,23 @@
         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:
@@ -145,27 +131,40 @@
         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 = duration
-        self.set_child_pos(widget, (start, 0))
+        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 = item.get_data("element")
-        element.setStartDurationTime(max(x, 0), -1)
+        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):
-        text = make_item(label)
-        text.props.text = os.path.basename(element.factory.name)
         rect = make_item(box)
-        rect.props.width = element.props.duration
-        set_pos(text, center(rect))
-        ret = group(rect, text)
-        ret.set_data("element", element)
+        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 = element.props.start
+        ret.props.x = self.ns_to_pixel(element.start)
         return ret
 
 c = goocanvas.Canvas()
@@ -175,15 +174,21 @@
 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 = 0
+cur = long(0)
 for name, duration in SOURCES:
     model.addSource(TestTimelineObject(name, cur, duration), None)
     cur += duration
+print t.width
+c.set_size_request(int(t.width), int(t.height))
 s = gtk.ScrolledWindow()
 s.set_policy(gtk.POLICY_ALWAYS, gtk.POLICY_NEVER)
 s.add(c)
+z = gtk.HScale(t.get_zoom_adjustment())
+b = gtk.VBox()
+b.pack_start(s, True, True)
+b.pack_start(z, False, False)
 w = gtk.Window()
-w.add(s)
+w.add(b)
 w.show_all()
 w.connect("destroy", gtk.main_quit)
 gtk.main()

Modified: branches/SOC_2008_BLEWIS/pitivi/ui/timelineobjects.py
==============================================================================
--- branches/SOC_2008_BLEWIS/pitivi/ui/timelineobjects.py	(original)
+++ branches/SOC_2008_BLEWIS/pitivi/ui/timelineobjects.py	Fri Jun 27 15:30:20 2008
@@ -49,7 +49,7 @@
 DEFAULT_SIMPLE_SIZE_RATIO = 1.50 # default height / width ratio
 
 # Default simple elements size
-DEFAULT_SIMPLE_ELEMENT_WIDTH = 150
+DEFAULT_SIMPLE_ELEMENT_WIDTH = 100
 DEFAULT_SIMPLE_ELEMENT_HEIGHT = DEFAULT_SIMPLE_ELEMENT_WIDTH * DEFAULT_SIMPLE_SIZE_RATIO
 
 # Default spacing between/above elements in simple timeline

Modified: branches/SOC_2008_BLEWIS/pitivi/ui/util.py
==============================================================================
--- branches/SOC_2008_BLEWIS/pitivi/ui/util.py	(original)
+++ branches/SOC_2008_BLEWIS/pitivi/ui/util.py	Fri Jun 27 15:30:20 2008
@@ -31,6 +31,9 @@
 def null_false(*args):
     return False
 
+def printall(*args):
+    print args
+
 def event_coords(canvas, event):
     """returns the coordinates of an event"""
     return canvas.convert_from_pixels(canvas.props.scale_x * event.x, 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]