diff options
author | Campbell Barton <ideasman42@gmail.com> | 2012-12-20 17:29:58 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2012-12-20 17:29:58 +0400 |
commit | 0e3d637ad040f55412856d10197f66f166591e49 (patch) | |
tree | 1ff87859407f73a72b67834d41085eacb1c33740 /release | |
parent | 80bcc20835cfd328984c3fbc60774d6e6bed6482 (diff) |
Change region drawing callbacks to work much closer to how blender manages them internally.
- yes, this does break scripts, but the api is marked experimental.
ED_region_draw_cb_activate() adds a callback to a region type whereas the api made it look like the callback was being added to the region instance.
Use a class method on bpy.types.Space to manage region drawing, eg.
was:
self._handle = context.region.callback_add(draw_callback_px, args, 'POST_PIXEL')
is now:
self._handle = bpy.types.SpaceView3D.draw_handler_add(draw_callback_px, args, 'WINDOW', 'POST_PIXEL')
Diffstat (limited to 'release')
-rw-r--r-- | release/scripts/templates/operator_modal_draw.py | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/release/scripts/templates/operator_modal_draw.py b/release/scripts/templates/operator_modal_draw.py index f1c4e113b0a..d11ddf0b467 100644 --- a/release/scripts/templates/operator_modal_draw.py +++ b/release/scripts/templates/operator_modal_draw.py @@ -42,20 +42,22 @@ class ModalDrawOperator(bpy.types.Operator): self.mouse_path.append((event.mouse_region_x, event.mouse_region_y)) elif event.type == 'LEFTMOUSE': - context.region.callback_remove(self._handle) + bpy.types.SpaceView3D.draw_handler_remove(self._handle, 'WINDOW') return {'FINISHED'} elif event.type in {'RIGHTMOUSE', 'ESC'}: - context.region.callback_remove(self._handle) + bpy.types.SpaceView3D.draw_handler_remove(self._handle, 'WINDOW') return {'CANCELLED'} return {'RUNNING_MODAL'} def invoke(self, context, event): if context.area.type == 'VIEW_3D': + # the arguments we pass the the callback + args = (self, context) # Add the region OpenGL drawing callback # draw in view space with 'POST_VIEW' and 'PRE_VIEW' - self._handle = context.region.callback_add(draw_callback_px, (self, context), 'POST_PIXEL') + self._handle = bpy.types.SpaceView3D.draw_handler_add(draw_callback_px, args, 'WINDOW', 'POST_PIXEL') self.mouse_path = [] |