pitivi r1387 - in trunk: bin pitivi pitivi/ui
- From: edwardrv svn gnome org
- To: svn-commits-list gnome org
- Subject: pitivi r1387 - in trunk: bin pitivi pitivi/ui
- Date: Fri, 28 Nov 2008 17:27:52 +0000 (UTC)
Author: edwardrv
Date: Fri Nov 28 17:27:52 2008
New Revision: 1387
URL: http://svn.gnome.org/viewvc/pitivi?rev=1387&view=rev
Log:
point-event code into Controller, bug-fixes in drag-and-drop code
Modified:
trunk/bin/pitivi.in
trunk/pitivi/pitivi.py
trunk/pitivi/signalinterface.py
trunk/pitivi/ui/complexlayer.py
trunk/pitivi/ui/controller.py
trunk/pitivi/ui/point.py
trunk/pitivi/ui/timeline.py
trunk/pitivi/ui/timelinecanvas.py
trunk/pitivi/ui/timelineobject.py
trunk/pitivi/ui/track.py
Modified: trunk/bin/pitivi.in
==============================================================================
--- trunk/bin/pitivi.in (original)
+++ trunk/bin/pitivi.in Fri Nov 28 17:27:52 2008
@@ -109,7 +109,6 @@
def _run_pitivi():
import pitivi.pitivi as ptv
-
sys.exit(ptv.main(sys.argv))
try:
Modified: trunk/pitivi/pitivi.py
==============================================================================
--- trunk/pitivi/pitivi.py (original)
+++ trunk/pitivi/pitivi.py Fri Nov 28 17:27:52 2008
@@ -226,7 +226,6 @@
from ui.mainwindow import PitiviMainWindow
self._gui = PitiviMainWindow(self)
self._gui.load()
-
self._gui.show()
if filepath:
Modified: trunk/pitivi/signalinterface.py
==============================================================================
--- trunk/pitivi/signalinterface.py (original)
+++ trunk/pitivi/signalinterface.py Fri Nov 28 17:27:52 2008
@@ -57,7 +57,8 @@
""" connect """
# get a unique id
if not signame in self.handlers.keys():
- raise Exception("Signal %s does not exist" % signame)
+ raise Exception("Signal %s is not one of %s" % (signame,
+ ",\n\t".join(self.handlers.keys())))
if not callable(cb):
raise Exception("Provided callable '%r' is not callable" % cb)
Modified: trunk/pitivi/ui/complexlayer.py
==============================================================================
--- trunk/pitivi/ui/complexlayer.py (original)
+++ trunk/pitivi/ui/complexlayer.py Fri Nov 28 17:27:52 2008
@@ -134,7 +134,6 @@
else:
self._list.insert(pos, layer)
self.emit('layer-added', layer, pos)
- print 'added layer'
return layer
def removeComposition(self, composition):
Modified: trunk/pitivi/ui/controller.py
==============================================================================
--- trunk/pitivi/ui/controller.py (original)
+++ trunk/pitivi/ui/controller.py Fri Nov 28 17:27:52 2008
@@ -22,11 +22,26 @@
_canvas = None
_ptr_within = False
_last_click = None
+ _mousedown = None
def __init__(self, view=None):
object.__init__(self)
self._view = view
+## convenience functions
+
+ def from_event(self, event):
+ """returns the coordinates of an event"""
+ return Point(*self._canvas.convert_from_pixels(event.x, event.y))
+
+ def from_item_event(self, item, event):
+ return Point(*self._canvas.convert_from_item_space(item,
+ *self.from_event(event)))
+
+ def pos(self, item):
+ bounds = item.get_bounds()
+ return Point(bounds.x1, bounds.y1)
+
## signal handlers
@handler(_view, "enter_notify_event")
@@ -46,6 +61,8 @@
def button_press_event(self, item, target, event):
if not self._canvas:
self._canvas = item.get_canvas()
+ self._mousedown = self.pos(item) - self.transform(self.from_item_event(
+ item, event))
self._dragging = target
self._drag_start(item, target, event)
return True
@@ -54,9 +71,8 @@
def motion_notify_event(self, item, target, event):
if self._dragging:
self.set_pos(self._dragging,
- self.transform(
- Point.from_event(self._canvas, event).from_item_space(
- self._canvas, item)))
+ self.transform(self._mousedown + self.from_item_event(item,
+ event)))
return True
return False
@@ -77,9 +93,9 @@
if self._ptr_within:
self._view.focus()
if self._last_click and (event.time - self._last_click < 400):
- self.double_click(event_coords(self._canvas, event))
+ self.double_click(Point.from_event(self._canvas, event))
else:
- self.click(event_coords(self._canvas, event))
+ self.click(Point.from_event(self._canvas, event))
self._last_click = event.time
else:
self._view.normal()
@@ -101,9 +117,6 @@
def set_pos(self, obj, pos):
obj.props.x, obj.props.y = pos
- def pos(self, obj):
- return obj.props.x, obj.props.y
-
def transform(self, pos):
return pos
Modified: trunk/pitivi/ui/point.py
==============================================================================
--- trunk/pitivi/ui/point.py (original)
+++ trunk/pitivi/ui/point.py Fri Nov 28 17:27:52 2008
@@ -40,3 +40,6 @@
def from_item_space(self, canvas, item):
return Point(*canvas.convert_from_item_space(item, self[0], self[1]))
+ @classmethod
+ def from_item_event(cls, canvas, item, event):
+ return Point.from_event(canvas, event).from_item_space(canvas, item)
Modified: trunk/pitivi/ui/timeline.py
==============================================================================
--- trunk/pitivi/ui/timeline.py (original)
+++ trunk/pitivi/ui/timeline.py Fri Nov 28 17:27:52 2008
@@ -127,11 +127,12 @@
self.pack_start(self.ruler, expand=False, fill=True)
# List of TimelineCanvas
- self.compositionLayers = TimelineCanvas(self.layerInfoList)
- self.compositionLayers.setZoomAdjustment(self._zoom_adj)
+ self.__canvas = TimelineCanvas(self.layerInfoList)
+ self.__canvas.setZoomAdjustment(self._zoom_adj)
+
self.scrolledWindow = gtk.ScrolledWindow(self.hadj)
self.scrolledWindow.set_policy(gtk.POLICY_ALWAYS, gtk.POLICY_AUTOMATIC)
- self.scrolledWindow.add(self.compositionLayers)
+ self.scrolledWindow.add(self.__canvas)
#FIXME: remove padding between scrollbar and scrolled window
self.pack_start(self.scrolledWindow, expand=True)
@@ -151,9 +152,9 @@
("ZoomOut", gtk.STOCK_ZOOM_OUT, None, None, ZOOM_OUT,
self._zoomOutCb),
("DeleteObj", gtk.STOCK_DELETE, None, None, DELETE,
- self.compositionLayers.deleteSelected),
+ self.__canvas.deleteSelected),
("Razor", gtk.STOCK_CUT, None, None, RAZOR,
- self.compositionLayers.activateRazor)
+ self.__canvas.activateRazor)
)
self.actiongroup = gtk.ActionGroup("complextimeline")
self.actiongroup.add_actions(actions)
@@ -196,7 +197,7 @@
def _newProjectLoadedCb(self, unused_inst, unused_project):
# force set deadband when new timeline loads
- self.compositionLayers.zoomChanged()
+ self.__canvas.zoomChanged()
def _newProjectFailedCb(self, unused_inst, unused_reason, unused_uri):
self.layerInfoList.setTimeline(None)
@@ -238,4 +239,3 @@
if isinstance(smartbin, SmartTimelineBin):
# for the time being we only inform the ruler
self.ruler.timelinePositionChanged(value, 0)
- self.compositionLayers.timelinePositionChanged(value, 0)
Modified: trunk/pitivi/ui/timelinecanvas.py
==============================================================================
--- trunk/pitivi/ui/timelinecanvas.py (original)
+++ trunk/pitivi/ui/timelinecanvas.py Fri Nov 28 17:27:52 2008
@@ -29,7 +29,6 @@
def __init__(self, layerinfolist):
goocanvas.Canvas.__init__(self)
self._selected_sources = []
- self._timeline_position = 0
self.__layers = []
self.__last_row = 0
@@ -46,9 +45,7 @@
self._cursor = ARROW
root = self.get_root_item()
- self.tracks = goocanvas.Table(
- homogeneous_rows=True,
- row_spacing=5)
+ self.tracks = goocanvas.Group()
root.add_child(self.tracks)
root.connect("enter_notify_event", self._mouseEnterCb)
@@ -206,9 +203,6 @@
parent = item.get_parent()
self._selected_sources.remove(parent)
- def timelinePositionChanged(self, value, unused_frame):
- self._timeline_position = value
-
## Zoomable Override
def zoomChanged(self):
@@ -222,13 +216,11 @@
@handler(layerInfoList, "layer-added")
def _layerAddedCb(self, unused_infolist, layer, position):
- track = goocanvas.Rect(width=800, height=50, fill_color="gray")
+ track = Track(comp=layer.composition)
self.__layers.append(track)
- #track.setZoomAdjustment(self.getZoomAdjustment())
- #track.set_composition(layer.composition)
- #track.set_canvas(self)
+ track.setZoomAdjustment(self.getZoomAdjustment())
+ track.set_canvas(self)
self.tracks.add_child(track)
- self.tracks.set_child_properties(track, column=0, rows=1, columns=1)
self._regroup_tracks()
@handler(layerInfoList, "layer-removed")
@@ -240,4 +232,6 @@
def _regroup_tracks(self):
for i, track in enumerate(self.__layers):
- self.tracks.set_child_properties(track, row=i)
+ b = track.get_bounds()
+ height = b.y2 - b.y1
+ track.set_simple_transform(0, i * (height + 10), 1, 0)
Modified: trunk/pitivi/ui/timelineobject.py
==============================================================================
--- trunk/pitivi/ui/timelineobject.py (original)
+++ trunk/pitivi/ui/timelineobject.py Fri Nov 28 17:27:52 2008
@@ -57,7 +57,6 @@
class Controller(controller.Controller):
def drag_start(self):
- item.raise_(None)
instance.PiTiVi.current.timeline.disableEdgeUpdates()
def drag_end(self):
@@ -70,7 +69,7 @@
def click(self, pos):
self._view.select()
- def __init__(self, element, composition, style):
+ def __init__(self, element, composition):
goocanvas.Group.__init__(self)
View.__init__(self)
@@ -95,7 +94,6 @@
#for thing in (self.bg, self.start_handle, self.end_handle, self.name):
for thing in (self.bg, self.name):
self.add_child(thing)
-
self.normal()
def select(self):
@@ -104,26 +102,16 @@
def normal(self):
self.bg.props.fill_color_rgba = self.__NORMAL__
- ## only temporary
- x = gobject.property(type=float)
- y = gobject.property(type=float)
- width = gobject.property(type=float)
- height = gobject.property(type=float, default=__HEIGHT__)
+ def zoomChanged(self):
+ self._start_duration_cb(self.element, self.element.start,
+ self.element.duration)
@handler(element, "start-duration-changed")
def _start_duration_cb(self, obj, start, duration):
- # set our position with set_simple_transform
- self.x = self.nsToPixel(start)
self.set_simple_transform(self.nsToPixel(start), 0, 1, 0)
-
- # clip text to within object bounds
width = self.nsToPixel(duration)
- self.width = width
self.name.props.clip_path = "M%g,%g h%g v%g h-%g z" % (
- 10, 0, width, self.__HEIGHT__, width - 10)
-
- # size background according to duration
+ 0, 0, width, self.__HEIGHT__, width - 10)
self.bg.props.width = width
-
# place end handle at appropriate distance
#self.end_handle.props.x = width - 10
Modified: trunk/pitivi/ui/track.py
==============================================================================
--- trunk/pitivi/ui/track.py (original)
+++ trunk/pitivi/ui/track.py Fri Nov 28 17:27:52 2008
@@ -1,46 +1,41 @@
-from util import *
from complexinterface import Zoomable
from timelineobject import TimelineObject
from pitivi.timeline.objects import MEDIA_TYPE_VIDEO
+from pitivi.receiver import receiver, handler
import pitivi.instance as instance
+import goocanvas
-class Track(SmartGroup, Zoomable):
+# TODO: layer managment controls
+
+class Track(goocanvas.Group, Zoomable):
__gtype_name__ = 'Track'
- def __init__(self, *args, **kwargs):
- SmartGroup.__init__(self, *args, **kwargs)
- # FIXME: all of these should be private
+ comp = receiver()
+
+ def __init__(self, comp=None):
+ goocanvas.Group.__init__(self)
+ self.bg = goocanvas.Rect(
+ line_width=0,
+ width=800,
+ height=50,
+ fill_color="gray")
+ self.add_child(self.bg)
self.widgets = {}
- self.elements = {}
- self.sig_ids = None
- self.comp = None
- self.object_style = None
-
- # FIXME: this should be set_model(), overriding BaseView
- 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)
+ @handler(comp, "source-added")
def _objectAdded(self, unused_timeline, element):
- w = TimelineObject(element, self.comp, self.object_style)
+ w = TimelineObject(element, self.comp)
w.setZoomAdjustment(self.getZoomAdjustment())
self.widgets[element] = w
- self.elements[w] = element
self.add_child(w)
+ @handler(comp, "source-removed")
def _objectRemoved(self, unused_timeline, element):
w = self.widgets[element]
self.remove_child(w)
- w.comp = None
del self.widgets[element]
- del self.elements[w]
def setChildZoomAdjustment(self, adj):
- for widget in self.elements:
+ for widget in self.widgets.itervalues():
widget.setZoomAdjustment(adj)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]