Added (hacky) cursor visibility toggle
authorDima Glib <dima.glib@gmail.com>
Thu, 19 Jul 2012 19:13:11 +0000 (19:13 +0000)
committerDima Glib <dima.glib@gmail.com>
Thu, 19 Jul 2012 19:13:11 +0000 (19:13 +0000)
space_view3d_enhanced_3d_cursor.py

index 56cedbb7fd6dc75d4fea7a622f74880aef802e40..7774e80b65323e987f820ce54ac88f2d9dfa07c7 100644 (file)
@@ -3980,6 +3980,11 @@ class Cursor3DToolsSettings(bpy.types.PropertyGroup):
         type=TransformExtraOptionsProp,
         options={'HIDDEN'})
     
+    cursor_visible = bpy.props.BoolProperty(
+        name="Cursor visibility",
+        description="Cursor visibility",
+        default=True)
+    
     draw_guides = bpy.props.BoolProperty(
         name="Guides",
         description="Display guides",
@@ -4140,7 +4145,12 @@ class Cursor3DTools(bpy.types.Panel):
             text="", icon='SNAP_ON', toggle=True)
         
         row = layout.row()
-        row.label(text="Draw")
+        #row.label(text="Draw")
+        #row.prop(settings, "cursor_visible", text="", toggle=True,
+        #         icon=('RESTRICT_VIEW_OFF' if settings.cursor_visible
+        #               else 'RESTRICT_VIEW_ON'))
+        row.prop(settings, "cursor_visible", text="", toggle=True,
+                 icon='RESTRICT_VIEW_OFF')
         row = row.split(1 / 3, align=True)
         row.prop(settings, "draw_N",
             text="N", toggle=True, index=0)
@@ -5073,11 +5083,19 @@ def gl_matrix_to_buffer(m):
 
 
 # ===== DRAWING CALLBACKS ===== #
+cursor_save_location = Vector()
+
 def draw_callback_view(self, context):
+    global cursor_save_location
+    
     settings = find_settings()
     if settings is None:
         return
     
+    cursor_save_location = Vector(bpy.context.space_data.cursor_location)
+    if not settings.cursor_visible:
+        bpy.context.space_data.cursor_location = Vector([float('nan')] * 3)
+    
     update_stick_to_obj(context)
     
     if "EDIT" not in context.mode:
@@ -5152,11 +5170,15 @@ def draw_callback_header_px(self, context):
     bgl.glColor4f(0.0, 0.0, 0.0, 1.0)
 
 def draw_callback_px(self, context):
+    global cursor_save_location
     settings = find_settings()
     if settings is None:
         return
     library = settings.libraries.get_item()
     
+    if not settings.cursor_visible:
+        bpy.context.space_data.cursor_location = cursor_save_location
+    
     tfm_operator = CursorDynamicSettings.active_transform_operator
     
     if settings.show_bookmarks and library: