[pitivi] previewers: Try to make sense out of _compute_geometry
- From: Mathieu Duponchelle <mathieudu src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [pitivi] previewers: Try to make sense out of _compute_geometry
- Date: Fri, 28 Feb 2014 03:10:34 +0000 (UTC)
commit 43d92487b9ee0239432b854b7aa5cf7cc6a09139
Author: Alexandru Băluț <alexandru balut gmail com>
Date: Mon Jan 13 17:25:03 2014 +0100
previewers: Try to make sense out of _compute_geometry
pitivi/timeline/previewers.py | 34 +++++++++++++++++-----------------
1 files changed, 17 insertions(+), 17 deletions(-)
---
diff --git a/pitivi/timeline/previewers.py b/pitivi/timeline/previewers.py
index 464782b..bb7d2ed 100644
--- a/pitivi/timeline/previewers.py
+++ b/pitivi/timeline/previewers.py
@@ -806,34 +806,34 @@ class AudioPreviewer(Clutter.Actor, PreviewGenerator, Zoomable, Loggable):
def _compute_geometry(self):
self.log("Computing the clip's geometry for waveforms")
- start = self.timeline.get_scroll_point().x - self.nsToPixel(self.bElement.props.start)
- start = max(0, start)
- end = min(self.timeline.get_scroll_point().x + self.timeline._container.get_allocation().width -
CONTROL_WIDTH + MARGIN,
- self.nsToPixel(self.bElement.props.duration))
-
width_px = self.nsToPixel(self.bElement.props.duration)
if width_px <= 0:
return
-
- asset_duration = self.bElement.get_parent().get_asset().get_duration()
+ start = self.timeline.get_scroll_point().x - self.nsToPixel(self.bElement.props.start)
+ start = max(0, start)
+ # Take into account the timeline width, to avoid building
+ # huge clips when the timeline is zoomed in a lot.
+ timeline_width = self.timeline._container.get_allocation().width - CONTROL_WIDTH
+ end = min(width_px,
+ self.timeline.get_scroll_point().x + timeline_width + MARGIN)
+ self.width = int(end - start)
+ if self.width < 0: # We've been called at a moment where size was updated but not scroll_point.
+ return
# We need to take duration and inpoint into account.
-
- nbSamples = self.nbSamples
- startOffsetSamples = 0
-
- if self.bElement.props.duration != 0:
+ asset_duration = self.bElement.get_parent().get_asset().get_duration()
+ if self.bElement.props.duration:
nbSamples = self.nbSamples / (float(asset_duration) / float(self.bElement.props.duration))
- if self.bElement.props.in_point != 0:
+ else:
+ nbSamples = self.nbSamples
+ if self.bElement.props.in_point:
startOffsetSamples = self.nbSamples / (float(asset_duration) /
float(self.bElement.props.in_point))
+ else:
+ startOffsetSamples = 0
self.start = int(start / width_px * nbSamples + startOffsetSamples)
self.end = int(end / width_px * nbSamples + startOffsetSamples)
- self.width = int(end - start)
- if self.width < 0: # We've been called at a moment where size was updated but not scroll_point.
- return
-
self.canvas.set_size(self.width, EXPANDED_SIZE)
Clutter.Actor.set_size(self, self.width, EXPANDED_SIZE)
self.set_position(start, self.props.y)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]