[pitivi] timeline: Make the timeline 2D
- From: Mathieu Duponchelle <mathieudu src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [pitivi] timeline: Make the timeline 2D
- Date: Fri, 28 Feb 2014 03:13:20 +0000 (UTC)
commit 38dba5223cb0aa1bc0650b53e9cf2ac77dab2172
Author: Alexandru Băluț <alexandru balut gmail com>
Date: Fri Jan 10 18:37:34 2014 +0100
timeline: Make the timeline 2D
pitivi/timeline/elements.py | 35 ++++++++---------
pitivi/timeline/timeline.py | 86 ++++++++++++++++++++++++++-----------------
2 files changed, 69 insertions(+), 52 deletions(-)
---
diff --git a/pitivi/timeline/elements.py b/pitivi/timeline/elements.py
index c998474..bec223a 100644
--- a/pitivi/timeline/elements.py
+++ b/pitivi/timeline/elements.py
@@ -358,6 +358,10 @@ class TimelineElement(Clutter.Actor, Zoomable):
self.add_child(self.marquee)
self._createHandles()
+
+ self._linesMarker = self._createMarker()
+ self._keyframesMarker = self._createMarker()
+
self._createGhostclip()
self.update(True)
@@ -437,11 +441,10 @@ class TimelineElement(Clutter.Actor, Zoomable):
def hideKeyframes(self):
for keyframe in self.keyframes:
self.remove_child(keyframe)
+ self.keyframes = []
self.keyframesVisible = False
- self.keyframes = []
-
if self.isSelected:
self.showKeyframes(self.default_element, self.default_prop)
@@ -451,7 +454,6 @@ class TimelineElement(Clutter.Actor, Zoomable):
x = self.nsToPixel(value.timestamp - self.bElement.props.in_point) - KEYFRAME_SIZE / 2
y = EXPANDED_SIZE - (value.value * EXPANDED_SIZE)
- keyframe.set_z_position(2)
keyframe.set_position(x, y)
def drawLines(self, line=None):
@@ -477,29 +479,22 @@ class TimelineElement(Clutter.Actor, Zoomable):
return
values = self.source.get_all()
-
if len(values) < 2 and self.bElement.props.duration > 0:
self.source.unset_all()
val = float(self.prop.default_value) / (self.prop.maximum - self.prop.minimum)
self.source.set(self.bElement.props.in_point, val)
self.source.set(self.bElement.props.duration + self.bElement.props.in_point, val)
- lastPoint = None
-
for keyframe in self.keyframes:
self.remove_child(keyframe)
self.keyframes = []
-
values = self.source.get_all()
-
- l = len(values)
+ values_count = len(values)
for i, value in enumerate(values):
- has_changeable_time = True
- if i == 0 or i == l - 1:
- has_changeable_time = False
- self._createKeyframe(value, has_changeable_time)
- lastPoint = value
+ has_changeable_time = i > 0 and i < values_count - 1
+ keyframe = self._createKeyframe(value, has_changeable_time)
+ self.keyframes.append(keyframe)
self.drawLines()
@@ -519,6 +514,11 @@ class TimelineElement(Clutter.Actor, Zoomable):
# private API
+ def _createMarker(self):
+ marker = Clutter.Actor()
+ self.add_child(marker)
+ return marker
+
def update(self, ease):
start = self.bElement.get_start()
duration = self.bElement.get_duration()
@@ -552,20 +552,19 @@ class TimelineElement(Clutter.Actor, Zoomable):
x = self.nsToPixel(value.timestamp - self.bElement.props.in_point) - KEYFRAME_SIZE / 2
y = EXPANDED_SIZE - (value.value * EXPANDED_SIZE)
- keyframe.set_z_position(2)
keyframe.set_position(x, y)
def _createKeyframe(self, value, has_changeable_time):
keyframe = Keyframe(self, value, has_changeable_time)
- self.add_child(keyframe)
- self.keyframes.append(keyframe)
+ self.insert_child_above(keyframe, self._keyframesMarker)
self.setKeyframePosition(keyframe, value)
+ return keyframe
def _createLine(self, keyframe, lastKeyframe, line):
if not line:
line = Line(self, keyframe, lastKeyframe)
self.lines.append(line)
- self.add_child(line)
+ self.insert_child_above(line, self._linesMarker)
adj = self.nsToPixel(keyframe.value.timestamp - lastKeyframe.value.timestamp)
opp = (lastKeyframe.value.value - keyframe.value.value) * EXPANDED_SIZE
diff --git a/pitivi/timeline/timeline.py b/pitivi/timeline/timeline.py
index 1dd1472..2b97672 100644
--- a/pitivi/timeline/timeline.py
+++ b/pitivi/timeline/timeline.py
@@ -106,10 +106,30 @@ class TimelineStage(Clutter.ScrollActor, Zoomable, Loggable):
self.selection = Selection()
self._scroll_point = Clutter.Point()
self.lastPosition = 0 # Saved for redrawing when paused
- self._createPlayhead()
- self._createSnapIndicator()
self.mouse = self._peekMouse()
- self._setUpDragAndDrop()
+
+ # The markers are used for placing clips at the right depth.
+ # The first marker added as a child is the furthest and
+ # the latest added marker is the closest to the viewer.
+
+ # All the audio, video, image, title clips are placed above this marker.
+ self._clips_marker = Clutter.Actor()
+ self.add_child(self._clips_marker)
+ # All the transition clips are placed above this marker.
+ self._transitions_marker = Clutter.Actor()
+ self.add_child(self._transitions_marker)
+
+ # Add the playhead later so it appears on top of all the clips.
+ self.playhead = self._createPlayhead()
+ self.add_child(self.playhead)
+
+ self._snap_indicator = self._createSnapIndicator()
+ self.add_child(self._snap_indicator)
+
+ # Add the drag and drop marquee so it appears on top of the playhead.
+ self.marquee = self._setUpDragAndDrop()
+ self.add_child(self.marquee)
+ self.drawMarquee = False
# Public API
@@ -304,23 +324,23 @@ class TimelineStage(Clutter.ScrollActor, Zoomable, Loggable):
newY = event.y
delta_y = abs(delta_y)
- return (newX, newY, delta_x, delta_y)
+ return newX, newY, delta_x, delta_y
def _setUpDragAndDrop(self):
self.set_reactive(True)
- self.marquee = Clutter.Actor()
- self.marquee.set_background_color(SELECTION_MARQUEE_COLOR)
- self.marquee.hide()
- self.add_child(self.marquee)
-
- self.drawMarquee = False
self._container.stage.connect("button-press-event", self._dragBeginCb)
self._container.stage.connect("motion-event", self._dragProgressCb)
self._container.stage.connect("button-release-event", self._dragEndCb)
self._container.gui.connect("button-release-event", self._dragEndCb)
- def _peekMouse(self):
+ marquee = Clutter.Actor()
+ marquee.set_background_color(SELECTION_MARQUEE_COLOR)
+ marquee.hide()
+ return marquee
+
+ @staticmethod
+ def _peekMouse():
manager = Clutter.DeviceManager.get_default()
for device in manager.peek_devices():
if device.props.device_type == Clutter.InputDeviceType.POINTER_DEVICE and device.props.enabled
is True:
@@ -368,31 +388,34 @@ class TimelineStage(Clutter.ScrollActor, Zoomable, Loggable):
def _movePlayhead(self, position):
self.playhead.props.x = self.nsToPixel(position)
- def _createPlayhead(self):
- self.playhead = Clutter.Actor()
- self.playhead.set_background_color(PLAYHEAD_COLOR)
- self.playhead.set_size(0, 0)
- self.playhead.set_position(0, 0)
- self.playhead.set_easing_duration(0)
- self.add_child(self.playhead)
-
- def _createSnapIndicator(self):
- self._snap_indicator = Clutter.Actor()
- self._snap_indicator.set_background_color(SNAPPING_INDICATOR_COLOR)
- self._snap_indicator.props.visible = False
- self._snap_indicator.props.width = 3
- self._snap_indicator.props.y = 0
- self.add_child(self._snap_indicator)
+ @staticmethod
+ def _createPlayhead():
+ playhead = Clutter.Actor()
+ playhead.set_background_color(PLAYHEAD_COLOR)
+ playhead.set_size(0, 0)
+ playhead.set_position(0, 0)
+ playhead.set_easing_duration(0)
+ return playhead
+
+ @staticmethod
+ def _createSnapIndicator():
+ indicator = Clutter.Actor()
+ indicator.set_background_color(SNAPPING_INDICATOR_COLOR)
+ indicator.props.visible = False
+ indicator.props.width = 3
+ indicator.props.y = 0
+ return indicator
def _addTimelineElement(self, track, bElement):
if isinstance(bElement, GES.Effect):
return
+
if isinstance(bElement, GES.Transition):
element = TransitionElement(bElement, self)
- element.set_z_position(0)
+ marker = self._transitions_marker
elif isinstance(bElement, GES.Source):
element = URISourceElement(bElement, self)
- element.set_z_position(-1)
+ marker = self._clips_marker
else:
self.warning("Unknown element: %s", bElement)
return
@@ -407,7 +430,7 @@ class TimelineStage(Clutter.ScrollActor, Zoomable, Loggable):
self._setElementX(element)
self._setElementY(element)
- self.add_child(element)
+ self.insert_child_above(element, marker)
def _removeTimelineElement(self, unused_track, bElement):
if isinstance(bElement, GES.Effect):
@@ -798,7 +821,6 @@ class TimelineContainer(Gtk.Grid, Zoomable, Loggable):
self.embed = GtkClutter.Embed()
self.embed.get_accessible().set_name("timeline canvas") # for dogtail
self.stage = self.embed.get_stage()
- perspective = self.stage.get_perspective()
self.timeline = TimelineStage(self, self._settings)
self.controls = ControlContainer(self.app, self.timeline)
@@ -806,13 +828,9 @@ class TimelineContainer(Gtk.Grid, Zoomable, Loggable):
self._shiftMask = False
self._controlMask = False
- perspective.fov_y = 90.
- self.stage.set_perspective(perspective)
-
self.stage.set_background_color(TIMELINE_BACKGROUND_COLOR)
self.timeline.set_position(CONTROL_WIDTH, 0)
self.controls.set_position(0, 0)
- self.controls.set_z_position(2)
self.stage.add_child(self.controls)
self.stage.add_child(self.timeline)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]