[pitivi] curve: curve is now a view, with its own controller
- From: Edward Hervey <edwardrv src gnome org>
- To: svn-commits-list gnome org
- Subject: [pitivi] curve: curve is now a view, with its own controller
- Date: Wed, 24 Jun 2009 14:01:31 +0000 (UTC)
commit b579dd81e972e71f431e2e9c5b1ddb0d47c0c58a
Author: Brandon Lewis <brandon_lewis berkeley edu>
Date: Fri May 29 16:43:05 2009 -0700
curve: curve is now a view, with its own controller
pitivi/ui/curve.py | 74 +++++++++++++++++++++++++++++++++------------------
1 files changed, 48 insertions(+), 26 deletions(-)
---
diff --git a/pitivi/ui/curve.py b/pitivi/ui/curve.py
index 82f58bd..4edc558 100644
--- a/pitivi/ui/curve.py
+++ b/pitivi/ui/curve.py
@@ -28,6 +28,9 @@ import gobject
from pitivi.receiver import receiver, handler
from pitivi.ui.zoominterface import Zoomable
import pitivi.ui.previewer as previewer
+from pitivi.ui.view import View
+from pitivi.ui.controller import Controller
+from pitivi.ui.common import LAYER_HEIGHT_EXPANDED
def between(a, b, c):
return (a <= b) and (b <= c)
@@ -36,17 +39,31 @@ def intersect(b1, b2):
return goocanvas.Bounds(max(b1.x1, b2.x1), max(b1.y1, b2.y1),
min(b1.x2, b2.x2), min(b1.y2, b2.y2))
-class Curve(goocanvas.ItemSimple, goocanvas.Item, Zoomable):
+class Curve(goocanvas.ItemSimple, goocanvas.Item, View, Zoomable):
__gtype_name__ = 'Curve'
- def __init__(self, element, interpolator, height=50, **kwargs):
+ class Controller(Controller):
+
+ def set_pos(self, obj, pos):
+ pass
+
+ def enter(self, item ,target):
+ self._view.focus()
+
+ def leave(self, item, target):
+ self._view.normal()
+
+ def __init__(self, element, interpolator, height=LAYER_HEIGHT_EXPANDED,
+ **kwargs):
super(Curve, self).__init__(**kwargs)
+ View.__init__(self)
Zoomable.__init__(self)
self.height = float(height)
self.element = element
- self.props.pointer_events = False
+ self.props.pointer_events = goocanvas.EVENTS_STROKE
self.interpolator = interpolator
+ self.normal()
## properties
@@ -75,7 +92,7 @@ class Curve(goocanvas.ItemSimple, goocanvas.Item, Zoomable):
@handler(interpolator, "keyframe-added")
@handler(interpolator, "keyframe-removed")
@handler(interpolator, "keyframe-moved")
- def keyframeAdded(self, keyframe):
+ def curveChanged(self, keyframe, unused):
self.changed(False)
## Zoomable interface overries
@@ -96,34 +113,39 @@ class Curve(goocanvas.ItemSimple, goocanvas.Item, Zoomable):
y = kf.value * self._height
return x, y
- def _drawKeyframe(self, cr, kf):
- x, y = self._getKeyframeXY(kf)
- cr.rectangle(x - 5, y - 5, 10, 10)
- cr.set_source_rgb(1, 1, 1)
- cr.fill()
- cr.set_source_rgb(0, 0, 0)
- cr.stroke()
-
def do_simple_paint(self, cr, bounds):
bounds = intersect(self.bounds, bounds)
cr.identity_matrix()
+ cr.set_line_width(self.line_width)
+ if self.interpolator:
+ cr.set_source_rgb(1, 0, 0)
+ self.make_path(cr, bounds)
+ cr.stroke()
+
+ def make_path(self, cr, bounds):
height = bounds.y2 - bounds.y1
width = bounds.x2 - bounds.x1
- cr.set_line_width(2.0)
+ cr.rectangle(bounds.x1, bounds.y1, width, height)
+ cr.clip()
+ cr.move_to(*self._getKeyframeXY(self.interpolator.start))
if self.interpolator:
- cr.rectangle(bounds.x1, bounds.y1, width, height)
- cr.clip()
- cr.move_to(*self._getKeyframeXY(self.interpolator.start))
- if self.interpolator:
- for kf in self.interpolator.keyframes:
- cr.line_to(*self._getKeyframeXY(kf))
- cr.line_to(*self._getKeyframeXY(self.interpolator.end))
- cr.stroke()
- self._drawKeyframe(cr, self.interpolator.start)
for kf in self.interpolator.keyframes:
- self._drawKeyframe(cr, kf)
- self._drawKeyframe(cr, self.interpolator.end)
+ cr.line_to(*self._getKeyframeXY(kf))
+ cr.line_to(*self._getKeyframeXY(self.interpolator.end))
def do_simple_is_item_at(self, x, y, cr, pointer_event):
- return (between(0, x, self.nsToPixel(self.element.duration)) and
- between(0, y, self.height))
+ if (between(0, x, self.nsToPixel(self.element.duration)) and
+ between(0, y, self.height)):
+ cr.set_line_width(self.line_width)
+ self.make_path(cr, self.get_bounds())
+ return cr.in_stroke(x, y)
+ return False
+
+ def focus(self):
+ self.line_width = 3.0
+ self.changed(False)
+
+ def normal(self):
+ self.line_width = 2.0
+ self.changed(False)
+
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]