[Bf-python] callback_add() on a timeline region and its frame numbers

Thomas Krijnen t.krijnen at gmail.com
Sat Feb 23 20:06:42 CET 2013


Hi all,

Using the following snippet I can attach a bgl draw handler to the timeline
to draw over it, but I have only been able to get this to work using the
POST_PIXEL callback. I was wondering if there is something like a POST_VIEW
context for this callback as well, in which coordinates would relate to
frame numbers? Alternatively is there another way of relating the pixel
coordinates to actual frame numbers, eg by somehow detecting the amount of
zoom and pan in the timeline? Thanks!

import bgl

timeline_area = next(a for a in bpy.context.screen.areas if a.type ==
'TIMELINE')
timeline_region = next(r for r in timeline_area.regions if r.type ==
'WINDOW')

def draw():
    bgl.glColor4f(1,1,1,1)
    bgl.glBegin(bgl.GL_LINES)
    for i in range(-1000,1000,10):
        bgl.glVertex3f(i,-1000,0)
        bgl.glVertex3f(i,1000,0)
    bgl.glEnd()

timeline_region.callback_add(draw, (), 'POST_PIXEL')

Kind regards,
Thomas
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.blender.org/pipermail/bf-python/attachments/20130223/b01c608e/attachment.html>


More information about the Bf-python mailing list