# HG changeset patch # User hamidouk # Date 1324484647 -3600 # Node ID 756ecd1645a5ddb5dc81777a3302ffcafca75b78 # Parent 00054959ee92165cc8d40dabaa2be2d57dfe9026 defined a func to compute the width in pixels of a segment. diff -r 00054959ee92 -r 756ecd1645a5 src/js/widgets/segmentsWidget.js --- a/src/js/widgets/segmentsWidget.js Wed Dec 21 17:11:59 2011 +0100 +++ b/src/js/widgets/segmentsWidget.js Wed Dec 21 17:24:07 2011 +0100 @@ -12,6 +12,20 @@ IriSP.SegmentsWidget.prototype = new IriSP.Widget(); +/* Get the width of a segment, in pixels. */ +IriSP.SegmentsWidget.prototype.segmentToPixel(annotation) { + var duration = this._serializer.currentMedia().meta["dc:duration"] / 1000; + var id = annotation.id; + var startPourcent = IriSP.timeToPourcent(begin, duration); + var startPixel = Math.floor(this.selector.parent().width() * (endPourcent / 100)); + + /* surprisingly, the following code doesn't work on webkit - for some reason, most of the + boxes are 3 pixels smaller. + */ + var endPourcent = Math.floor(IriSP.timeToPourcent(end, duration) - startPourcent); + var endPixel = Math.floor(this.selector.parent().width() * (endPourcent / 100)); +}; + IriSP.SegmentsWidget.prototype.draw = function() { var self = this; @@ -56,6 +70,7 @@ continue; } + segments_annotations.push(annotation); var begin = Math.round((+ annotation.begin) / 1000); var end = Math.round((+ annotation.end) / 1000); var duration = this._serializer.currentMedia().meta["dc:duration"] / 1000;