本文整理汇总了Python中pitivi.ui.zoominterface.Zoomable类的典型用法代码示例。如果您正苦于以下问题:Python Zoomable类的具体用法?Python Zoomable怎么用?Python Zoomable使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Zoomable类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _setBestZoomRatio
def _setBestZoomRatio(self):
ruler_width = self.timeline.ruler.get_allocation()[2]
timeline_duration = self.project.timeline.duration
ideal_zoom_ratio = ruler_width / float(timeline_duration / gst.SECOND)
nearest_zoom_level = Zoomable.computeZoomLevel(ideal_zoom_ratio)
Zoomable.setZoomLevel(nearest_zoom_level)
示例2: __init__
def __init__(self, instance, element, height=46, **kwargs):
super(Preview, self).__init__(**kwargs)
Zoomable.__init__(self)
self.app = instance
self.height = float(height)
self.element = element
self.props.pointer_events = False
示例3: __init__
def __init__(self, instance, hadj):
gtk.DrawingArea.__init__(self)
Zoomable.__init__(self)
Loggable.__init__(self)
self.log("Creating new ScaleRule")
self.add_events(gtk.gdk.POINTER_MOTION_MASK |
gtk.gdk.BUTTON_PRESS_MASK | gtk.gdk.BUTTON_RELEASE_MASK)
self.hadj = hadj
hadj.connect("value-changed", self._hadjValueChangedCb)
# double-buffering properties
self.pixmap = None
# all values are in pixels
self.pixmap_offset = 0
self.pixmap_visible_width = 0
self.pixmap_allocated_width = 0
self.pixmap_old_allocated_width = -1
# This is the number of visible_width we allocate for the pixmap
self.pixmap_multiples = 2
# position is in nanoseconds
self.position = 0
self.pressed = False
self.shaded_duration = gst.CLOCK_TIME_NONE
self.max_duration = gst.CLOCK_TIME_NONE
self.min_frame_spacing = 5.0
self.frame_height = 5.0
self.frame_rate = gst.Fraction(1/1)
self.app = instance
self.need_update = True
示例4: __init__
def __init__(self, instance, track, timeline=None):
goocanvas.Group.__init__(self)
Zoomable.__init__(self)
self.app = instance
self.widgets = {}
self.timeline = timeline
self.track = track
self.max_priority = 0
self._expanded = True
示例5: do_scroll_event
def do_scroll_event(self, event):
if event.direction == gtk.gdk.SCROLL_UP:
Zoomable.zoomIn()
elif event.direction == gtk.gdk.SCROLL_DOWN:
Zoomable.zoomOut()
# TODO: seek timeline back/forward
elif event.direction == gtk.gdk.SCROLL_LEFT:
pass
elif event.direction == gtk.gdk.SCROLL_RIGHT:
pass
示例6: run
def run(self):
self.watchdog.start()
if self.no_ui:
self.instance.run(["--no-ui"])
else:
from pitivi.ui.zoominterface import Zoomable
# set a common zoom ratio so that things like edge snapping values
# are consistent
Zoomable.setZoomLevel((3 * Zoomable.zoom_steps) / 4)
self.instance.run([])
示例7: setBestZoomRatio
def setBestZoomRatio(self, p=0):
"""Set the zoom level so that the entire timeline is in view."""
ruler_width = self.timeline.ruler.get_allocation()[2]
# Add gst.SECOND - 1 to the timeline duration to make sure the
# last second of the timeline will be in view.
timeline_duration = self.project.timeline.duration + gst.SECOND - 1
timeline_duration_s = int(timeline_duration / gst.SECOND)
ideal_zoom_ratio = float(ruler_width) / timeline_duration_s
nearest_zoom_level = Zoomable.computeZoomLevel(ideal_zoom_ratio)
Zoomable.setZoomLevel(nearest_zoom_level)
示例8: render_cairo
def render_cairo(self, cr, bounds, element, hscroll_pos, y1):
if not self._view:
return
# The idea is to conceptually divide the clip into a sequence of
# rectangles beginning at the start of the file, and
# pixelsToNs(twidth) nanoseconds long. The thumbnail within the
# rectangle is the frame produced from the timestamp corresponding to
# rectangle's left edge. We speed things up by only drawing the
# rectangles which intersect the given bounds. FIXME: how would we
# handle timestretch?
height = bounds.y2 - bounds.y1
width = bounds.x2 - bounds.x1
# we actually draw the rectangles just to the left of the clip's in
# point and just to the right of the clip's out-point, so we need to
# mask off the actual bounds.
cr.rectangle(bounds.x1, bounds.y1, width, height)
cr.clip()
# tdur = duration in ns of thumbnail
# sof = start of file in pixel coordinates
x1 = bounds.x1
sof = Zoomable.nsToPixel(element.start - element.in_point) +\
hscroll_pos
# i = left edge of thumbnail to be drawn. We start with x1 and
# subtract the distance to the nearest leftward rectangle.
# Justification of the following:
# i = sof + k * twidth
# i = x1 - delta
# sof + k * twidth = x1 - delta
# i * tw = (x1 - sof) - delta
# <=> delta = x1 - sof (mod twidth).
# Fortunately for us, % works on floats in python.
i = x1 - ((x1 - sof) % (self.twidth + self._spacing()))
# j = timestamp *within the element* of thumbnail to be drawn. we want
# timestamps to be numerically stable, but in practice this seems to
# give good enough results. It might be possible to improve this
# further, which would result in fewer thumbnails needing to be
# generated.
j = Zoomable.pixelToNs(i - sof)
istep = self.twidth + self._spacing()
jstep = self.tdur + Zoomable.pixelToNs(self.spacing)
while i < bounds.x2:
self._thumbForTime(cr, j, i, y1)
cr.rectangle(i - 1, y1, self.twidth + 2, self.theight)
i += istep
j += jstep
cr.fill()
示例9: __init__
def __init__(self, instance, element, interpolator, height=LAYER_HEIGHT_EXPANDED, **kwargs):
super(Curve, self).__init__(**kwargs)
View.__init__(self)
Zoomable.__init__(self)
self.app = instance
self.keyframes = {}
self.height = float(height)
self.element = element
self.props.pointer_events = goocanvas.EVENTS_STROKE
self.interpolator = interpolator
self._focused_kf = None
self.normal()
self.set_simple_transform(0, -KW_LABEL_Y_OVERFLOW, 1.0, 0)
示例10: do_simple_update
def do_simple_update(self, cr):
cr.identity_matrix()
if self.element.factory:
border_width = self.previewer._spacing()
self.bounds = goocanvas.Bounds(border_width, 4,
max(0, Zoomable.nsToPixel(self.element.duration) -
border_width), self.height)
示例11: xyToTimeValue
def xyToTimeValue(self, pos):
view = self._view
interpolator = view.interpolator
bounds = view.bounds
time = Zoomable.pixelToNs(pos[0] - bounds.x1) + view.element.in_point
value = (
(1 - (pos[1] - KW_LABEL_Y_OVERFLOW - bounds.y1 - view._min) / view._range) * interpolator.range
) + interpolator.lower
return time, value
示例12: __init__
def __init__(self, instance, factory, stream_):
if stream_.dar and stream_.par:
self.aspect = float(stream_.dar)
rate = stream_.framerate
RandomAccessPreviewer.__init__(self, instance, factory, stream_)
self.tstep = Zoomable.pixelToNsAt(self.twidth, Zoomable.max_zoom)
if rate.num:
frame_duration = (gst.SECOND * rate.denom) / rate.num
self.tstep = max(frame_duration, self.tstep)
示例13: __init__
def __init__(self, instance, timeline=None):
goocanvas.Canvas.__init__(self)
Zoomable.__init__(self)
Loggable.__init__(self)
self.app = instance
self._selected_sources = []
self._tracks = []
self._height = 0
self._position = 0
self._block_size_request = False
self.props.integer_layout = True
self.props.automatic_bounds = False
self.props.clear_background = False
self.get_root_item().set_simple_transform(0, 2.0, 1.0, 0)
self._createUI()
self.timeline = timeline
self.settings = instance.settings
示例14: do_size_allocate
def do_size_allocate(self, allocation):
self.debug("ScaleRuler got %s", list(allocation))
gtk.Layout.do_size_allocate(self, allocation)
width = max(self.getMaxDurationWidth(), allocation.width)
self.debug("Setting layout size to %d x %d",
width, allocation.height)
self.set_size(width, allocation.height)
new_pos = Zoomable.nsToPixel(self.position) -\
self.pixel_position_offset
self.hadj.set_value(new_pos)
# the size has changed, therefore we want to redo our pixmap
self.doPixmap()
示例15: do_scroll_event
def do_scroll_event(self, event):
if event.state & gtk.gdk.SHIFT_MASK:
# shift + scroll => vertical (up/down) scroll
if event.direction == gtk.gdk.SCROLL_LEFT:
event.direction = gtk.gdk.SCROLL_UP
elif event.direction == gtk.gdk.SCROLL_RIGHT:
event.direction = gtk.gdk.SCROLL_DOWN
event.state &= ~gtk.gdk.SHIFT_MASK
elif event.state & gtk.gdk.CONTROL_MASK:
# zoom + scroll => zooming (up: zoom in)
if event.direction == gtk.gdk.SCROLL_UP:
Zoomable.zoomIn()
return True
elif event.direction == gtk.gdk.SCROLL_DOWN:
Zoomable.zoomOut()
return True
return False
else:
if event.direction == gtk.gdk.SCROLL_UP:
event.direction = gtk.gdk.SCROLL_LEFT
elif event.direction == gtk.gdk.SCROLL_DOWN:
event.direction = gtk.gdk.SCROLL_RIGHT
return goocanvas.Canvas.do_scroll_event(self, event)