[Bf-extensions-cvs] SVN commit: /data/svn/bf-extensions [4314] contrib/py/scripts/addons: Addons: Talked to ideasman42 an decided to use @staticmethod over @ classmethod for draw handler managing functions, as it's more explicit ( but no difference for python).

Sebastian Nell codemanx at gmx.de
Wed Feb 20 17:41:08 CET 2013


Revision: 4314
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-extensions&revision=4314
Author:   codemanx
Date:     2013-02-20 16:41:08 +0000 (Wed, 20 Feb 2013)
Log Message:
-----------
Addons: Talked to ideasman42 an decided to use @staticmethod over @classmethod for draw handler managing functions, as it's more explicit (but no difference for python).

Modified Paths:
--------------
    contrib/py/scripts/addons/animation_motion_trail.py
    contrib/py/scripts/addons/cursor_control/history.py
    contrib/py/scripts/addons/cursor_control/memory.py
    contrib/py/scripts/addons/mesh_show_vgroup_weights.py
    contrib/py/scripts/addons/space_view3d_game_props_visualiser.py

Modified: contrib/py/scripts/addons/animation_motion_trail.py
===================================================================
--- contrib/py/scripts/addons/animation_motion_trail.py	2013-02-20 15:28:32 UTC (rev 4313)
+++ contrib/py/scripts/addons/animation_motion_trail.py	2013-02-20 16:41:08 UTC (rev 4314)
@@ -1308,21 +1308,21 @@
     _handle_calc = None
     _handle_draw = None
 
-    @classmethod
-    def handle_add(cls, self, context):
-        cls._handle_calc = bpy.types.SpaceView3D.draw_handler_add(
+    @staticmethod
+    def handle_add(self, context):
+        MotionTrailOperator._handle_calc = bpy.types.SpaceView3D.draw_handler_add(
             calc_callback, (self, context), 'WINDOW', 'POST_VIEW')
-        cls._handle_draw = bpy.types.SpaceView3D.draw_handler_add(
+        MotionTrailOperator._handle_draw = bpy.types.SpaceView3D.draw_handler_add(
             draw_callback, (self, context), 'WINDOW', 'POST_PIXEL')
 
-    @classmethod
-    def handle_remove(cls):
-        if cls._handle_calc is not None:
-            bpy.types.SpaceView3D.draw_handler_remove(cls._handle_calc, 'WINDOW')
-        if cls._handle_draw is not None:
-            bpy.types.SpaceView3D.draw_handler_remove(cls._handle_draw, 'WINDOW')
-        cls._handle_calc = None
-        cls._handle_draw = None
+    @staticmethod
+    def handle_remove():
+        if MotionTrailOperator._handle_calc is not None:
+            bpy.types.SpaceView3D.draw_handler_remove(MotionTrailOperator._handle_calc, 'WINDOW')
+        if MotionTrailOperator._handle_draw is not None:
+            bpy.types.SpaceView3D.draw_handler_remove(MotionTrailOperator._handle_draw, 'WINDOW')
+        MotionTrailOperator._handle_calc = None
+        MotionTrailOperator._handle_draw = None
 
 
     def modal(self, context, event):

Modified: contrib/py/scripts/addons/cursor_control/history.py
===================================================================
--- contrib/py/scripts/addons/cursor_control/history.py	2013-02-20 15:28:32 UTC (rev 4313)
+++ contrib/py/scripts/addons/cursor_control/history.py	2013-02-20 16:41:08 UTC (rev 4314)
@@ -227,16 +227,16 @@
     initDone = False
     _handle = None
 
-    @classmethod
-    def handle_add(cls, self, context):
-        cls._handle = bpy.types.SpaceView3D.draw_handler_add(
+    @staticmethod
+    def handle_add(self, context):
+        VIEW3D_PT_cursor_history_init._handle = bpy.types.SpaceView3D.draw_handler_add(
             cursor_history_draw, (self, context), 'WINDOW', 'POST_PIXEL')
 
-    @classmethod
-    def handle_remove(cls):
-        if cls._handle is not None:
-            bpy.types.SpaceView3D.draw_handler_remove(cls._handle, 'WINDOW')
-        cls._handle = None
+    @staticmethod
+    def handle_remove():
+        if VIEW3D_PT_cursor_history_init._handle is not None:
+            bpy.types.SpaceView3D.draw_handler_remove(VIEW3D_PT_cursor_history_init._handle, 'WINDOW')
+        VIEW3D_PT_cursor_history_init._handle = None
 
     @classmethod
     def poll(cls, context):

Modified: contrib/py/scripts/addons/cursor_control/memory.py
===================================================================
--- contrib/py/scripts/addons/cursor_control/memory.py	2013-02-20 15:28:32 UTC (rev 4313)
+++ contrib/py/scripts/addons/cursor_control/memory.py	2013-02-20 16:41:08 UTC (rev 4314)
@@ -205,16 +205,16 @@
     initDone = False
     _handle = None
 
-    @classmethod
-    def handle_add(cls, self, context):
-        cls._handle = bpy.types.SpaceView3D.draw_handler_add(
+    @staticmethod
+    def handle_add(self, context):
+        VIEW3D_PT_cursor_memory_init._handle = bpy.types.SpaceView3D.draw_handler_add(
             cursor_memory_draw, (self, context), 'WINDOW', 'POST_PIXEL')
 
-    @classmethod
-    def handle_remove(cls):
-        if cls._handle is not None:
-            bpy.types.SpaceView3D.draw_handler_remove(cls._handle, 'WINDOW')
-        cls._handle = None
+    @staticmethod
+    def handle_remove():
+        if VIEW3D_PT_cursor_memory_init._handle is not None:
+            bpy.types.SpaceView3D.draw_handler_remove(VIEW3D_PT_cursor_memory_init._handle, 'WINDOW')
+        VIEW3D_PT_cursor_memory_init._handle = None
 
     @classmethod
     def poll(cls, context):

Modified: contrib/py/scripts/addons/mesh_show_vgroup_weights.py
===================================================================
--- contrib/py/scripts/addons/mesh_show_vgroup_weights.py	2013-02-20 15:28:32 UTC (rev 4313)
+++ contrib/py/scripts/addons/mesh_show_vgroup_weights.py	2013-02-20 16:41:08 UTC (rev 4314)
@@ -174,21 +174,21 @@
     _handle_calc = None
     _handle_draw = None
 
-    @classmethod
-    def handle_add(cls, self, context):
-        cls._handle_calc = bpy.types.SpaceView3D.draw_handler_add(
+    @staticmethod
+    def handle_add(self, context):
+        ShowVGroupWeights._handle_calc = bpy.types.SpaceView3D.draw_handler_add(
             calc_callback, (self, context), 'WINDOW', 'POST_VIEW')
-        cls._handle_draw = bpy.types.SpaceView3D.draw_handler_add(
+        ShowVGroupWeights._handle_draw = bpy.types.SpaceView3D.draw_handler_add(
             draw_callback, (self, context), 'WINDOW', 'POST_PIXEL')
 
-    @classmethod
-    def handle_remove(cls):
-        if cls._handle_calc is not None:
-            bpy.types.SpaceView3D.draw_handler_remove(cls._handle_calc, 'WINDOW')
-        if cls._handle_draw is not None:
-            bpy.types.SpaceView3D.draw_handler_remove(cls._handle_draw, 'WINDOW')
-        cls._handle_calc = None
-        cls._handle_draw = None
+    @staticmethod
+    def handle_remove():
+        if ShowVGroupWeights._handle_calc is not None:
+            bpy.types.SpaceView3D.draw_handler_remove(ShowVGroupWeights._handle_calc, 'WINDOW')
+        if ShowVGroupWeights._handle_draw is not None:
+            bpy.types.SpaceView3D.draw_handler_remove(ShowVGroupWeights._handle_draw, 'WINDOW')
+        ShowVGroupWeights._handle_calc = None
+        ShowVGroupWeights._handle_draw = None
 
     @classmethod
     def poll(cls, context):

Modified: contrib/py/scripts/addons/space_view3d_game_props_visualiser.py
===================================================================
--- contrib/py/scripts/addons/space_view3d_game_props_visualiser.py	2013-02-20 15:28:32 UTC (rev 4313)
+++ contrib/py/scripts/addons/space_view3d_game_props_visualiser.py	2013-02-20 16:41:08 UTC (rev 4314)
@@ -136,21 +136,21 @@
     _handle_calc = None
     _handle_draw = None
 
-    @classmethod
-    def handle_add(cls, self, context):
-        cls._handle_calc = bpy.types.SpaceView3D.draw_handler_add(
+    @staticmethod
+    def handle_add(self, context):
+        GamePropertyVisualizer._handle_calc = bpy.types.SpaceView3D.draw_handler_add(
             calc_callback, (self, context), 'WINDOW', 'POST_VIEW')
-        cls._handle_draw = bpy.types.SpaceView3D.draw_handler_add(
+        GamePropertyVisualizer._handle_draw = bpy.types.SpaceView3D.draw_handler_add(
             draw_callback, (self, context), 'WINDOW', 'POST_PIXEL')
 
-    @classmethod
-    def handle_remove(cls):
-        if cls._handle_calc is not None:
-            bpy.types.SpaceView3D.draw_handler_remove(cls._handle_calc, 'WINDOW')
-        if cls._handle_draw is not None:
-            bpy.types.SpaceView3D.draw_handler_remove(cls._handle_draw, 'WINDOW')
-        cls._handle_calc = None
-        cls._handle_draw = None
+    @staticmethod
+    def handle_remove():
+        if GamePropertyVisualizer._handle_calc is not None:
+            bpy.types.SpaceView3D.draw_handler_remove(GamePropertyVisualizer._handle_calc, 'WINDOW')
+        if GamePropertyVisualizer._handle_draw is not None:
+            bpy.types.SpaceView3D.draw_handler_remove(GamePropertyVisualizer._handle_draw, 'WINDOW')
+        GamePropertyVisualizer._handle_calc = None
+        GamePropertyVisualizer._handle_draw = None
 
     @classmethod
     def poll(cls, context):



More information about the Bf-extensions-cvs mailing list