2.5 3DView Header:
authorThomas Dinges <blender@dingto.org>
Sat, 15 Aug 2009 22:28:48 +0000 (22:28 +0000)
committerThomas Dinges <blender@dingto.org>
Sat, 15 Aug 2009 22:28:48 +0000 (22:28 +0000)
* "Object" Menu is now written in python.

release/ui/space_view3d.py
source/blender/editors/space_view3d/view3d_header.c

index bbb3861b868c0237b6b9e75346e057c955d28cbe..89e34fc1dc3dadc0a3ed1cb09333135c07e6baa1 100644 (file)
@@ -23,7 +23,10 @@ class VIEW3D_HT_header(bpy.types.Header):
                        # Select Menu
                        selectmenu = "VIEW3D_MT_select_%s" % mode_string
                        if selectmenu in dir(bpy.types):
-                               layout.itemM(selectmenu)
+                               row.itemM(selectmenu)
+                       
+                       if mode_string == 'objectmode':
+                               row.itemM("VIEW3D_MT_object")
 
                layout.template_header_3D()
 
@@ -334,6 +337,130 @@ class VIEW3D_MT_select_facesel(bpy.types.Menu):
 
                layout.view3d_select_faceselmenu()
 
+# ********** Object menu **********
+
+class VIEW3D_MT_object(bpy.types.Menu):
+       __space_type__ = "VIEW_3D"
+       __context__ = "objectmode"
+       __label__ = "Object"
+
+       def draw(self, context):
+               layout = self.layout
+
+               layout.itemM("VIEW3D_MT_object_clear")
+               layout.itemM("VIEW3D_MT_object_snap")
+               
+               layout.itemS()
+               
+               layout.itemO("anim.insert_keyframe_menu")
+               layout.itemO("anim.delete_keyframe_v3d")
+               
+               layout.itemS()
+               
+               layout.itemO("object.duplicate")
+               layout.item_booleanO("object.duplicate", "linked", True, text="Duplicate Linked")
+               layout.itemO("object.delete")
+               layout.itemO("object.proxy_make")
+               
+               layout.itemS()
+               
+               layout.itemM("VIEW3D_MT_object_parent")
+               layout.itemM("VIEW3D_MT_object_track")
+               layout.itemM("VIEW3D_MT_object_group")
+               layout.itemM("VIEW3D_MT_object_constraints")
+               
+               layout.itemS()
+               
+               layout.itemO("object.join")
+               
+               layout.itemS()
+               
+               layout.itemM("VIEW3D_MT_object_show")
+               
+class VIEW3D_MT_object_clear(bpy.types.Menu):
+       __space_type__ = "VIEW_3D"
+       __label__ = "Clear"
+
+       def draw(self, context):
+               layout = self.layout
+               
+               layout.itemO("object.location_clear")
+               layout.itemO("object.rotation_clear")
+               layout.itemO("object.scale_clear")
+               layout.itemO("object.origin_clear")
+               
+class VIEW3D_MT_object_snap(bpy.types.Menu):
+       __space_type__ = "VIEW_3D"
+       __label__ = "Snap"
+
+       def draw(self, context):
+               layout = self.layout
+               
+               layout.itemO("view3d.snap_selected_to_grid")
+               layout.itemO("view3d.snap_selected_to_cursor")
+               layout.itemO("view3d.snap_selected_to_center")
+               
+               layout.itemS()
+               
+               layout.itemO("view3d.snap_cursor_to_selected")
+               layout.itemO("view3d.snap_cursor_to_grid")
+               layout.itemO("view3d.snap_cursor_to_active")
+               
+class VIEW3D_MT_object_parent(bpy.types.Menu):
+       __space_type__ = "VIEW_3D"
+       __label__ = "Parent"
+
+       def draw(self, context):
+               layout = self.layout
+               
+               layout.itemO("object.parent_set")
+               layout.itemO("object.parent_clear")
+               
+class VIEW3D_MT_object_track(bpy.types.Menu):
+       __space_type__ = "VIEW_3D"
+       __label__ = "Track"
+
+       def draw(self, context):
+               layout = self.layout
+               
+               layout.itemO("object.track_set")
+               layout.itemO("object.track_clear")
+               
+class VIEW3D_MT_object_group(bpy.types.Menu):
+       __space_type__ = "VIEW_3D"
+       __label__ = "Group"
+
+       def draw(self, context):
+               layout = self.layout
+               
+               layout.itemO("group.group_create")
+               layout.itemO("group.objects_remove")
+               
+               layout.itemS()
+               
+               layout.itemO("group.objects_add_active")
+               layout.itemO("group.objects_remove_active")
+               
+class VIEW3D_MT_object_constraints(bpy.types.Menu):
+       __space_type__ = "VIEW_3D"
+       __label__ = "Constraints"
+
+       def draw(self, context):
+               layout = self.layout
+               
+               layout.itemO("object.constraint_add_with_targets")
+               layout.itemO("object.constraints_clear")
+               
+class VIEW3D_MT_object_show(bpy.types.Menu):
+       __space_type__ = "VIEW_3D"
+       __label__ = "Show/Hide"
+
+       def draw(self, context):
+               layout = self.layout
+               
+               layout.itemO("object.restrictview_clear")
+               layout.itemO("object.restrictview_set")
+               layout.item_booleanO("object.restrictview_set", "unselected", True, text="Hide Unselected")
 
 # ********** Panel **********
 
@@ -454,6 +581,15 @@ bpy.types.register(VIEW3D_MT_select_lattice_edit)
 bpy.types.register(VIEW3D_MT_select_armature_edit)
 bpy.types.register(VIEW3D_MT_select_facesel)
 
+bpy.types.register(VIEW3D_MT_object) # Object Menu
+bpy.types.register(VIEW3D_MT_object_clear)
+bpy.types.register(VIEW3D_MT_object_snap)
+bpy.types.register(VIEW3D_MT_object_parent)
+bpy.types.register(VIEW3D_MT_object_track)
+bpy.types.register(VIEW3D_MT_object_group)
+bpy.types.register(VIEW3D_MT_object_constraints)
+bpy.types.register(VIEW3D_MT_object_show)
+
 bpy.types.register(VIEW3D_PT_3dview_properties) # Panels
 bpy.types.register(VIEW3D_PT_3dview_display)
 bpy.types.register(VIEW3D_PT_background_image)
index 20ce252a4a39f9878f6a4067f8023dd0198a8329..31490dd22cc08383355bc0fa26bf28fcad507ac5 100644 (file)
@@ -1834,42 +1834,6 @@ static uiBlock *view3d_edit_object_copyattrmenu(bContext *C, ARegion *ar, void *
 }
 #endif
 
-static void view3d_edit_object_parentmenu(bContext *C, uiLayout *layout, void *arg_unused)
-{
-       uiItemO(layout, "Make Parent...", 0, "OBJECT_OT_parent_set");
-       uiItemO(layout, "Clear Parent...", 0, "OBJECT_OT_parent_clear");
-}
-
-static void view3d_edit_object_groupmenu(bContext *C, uiLayout *layout, void *arg_unused)
-{
-       uiItemO(layout, NULL, 0, "GROUP_OT_group_create");
-       uiItemO(layout, NULL, 0, "GROUP_OT_objects_remove");
-
-       uiItemS(layout);
-
-       uiItemO(layout, NULL, 0, "GROUP_OT_objects_add_active");
-       uiItemO(layout, NULL, 0, "GROUP_OT_objects_remove_active");
-}
-
-static void view3d_edit_object_trackmenu(bContext *C, uiLayout *layout, void *arg_unused)
-{
-       uiItemO(layout, "Make Track...", 0, "OBJECT_OT_track_set");
-       uiItemO(layout, "Clear Track...", 0, "OBJECT_OT_track_clear");
-}
-
-static void view3d_edit_object_constraintsmenu(bContext *C, uiLayout *layout, void *arg_unused)
-{
-       uiItemO(layout, NULL, 0, "OBJECT_OT_constraint_add_with_targets");
-       uiItemO(layout, NULL, 0, "OBJECT_OT_constraints_clear");
-}
-
-static void view3d_edit_object_showhidemenu(bContext *C, uiLayout *layout, void *arg_unused)
-{
-       uiItemO(layout, "Show Hidden", 0, "OBJECT_OT_restrictview_clear");
-       uiItemO(layout, "Hide Selected", 0, "OBJECT_OT_restrictview_set");
-       uiItemBooleanO(layout, "Hide Unselected", 0, "OBJECT_OT_restrictview_set", "unselected", 1);
-}
-
 #if 0
 #ifndef DISABLE_PYTHON
 static void do_view3d_edit_object_scriptsmenu(bContext *C, void *arg, int event)
@@ -1943,74 +1907,6 @@ static void do_view3d_edit_objectmenu(bContext *C, void *arg, int event)
 }
 #endif
 
-static void view3d_edit_objectmenu(bContext *C, uiLayout *layout, void *arg_unused)
-{
-#if 0
-       Object *ob= CTX_data_active_object(C);
-
-       uiDefIconTextBlockBut(block, view3d_transformmenu, NULL, ICON_RIGHTARROW_THIN, "Transform", 0, yco-=20, 120, 19, "");
-       uiDefIconTextBlockBut(block, view3d_object_mirrormenu, NULL, ICON_RIGHTARROW_THIN, "Mirror", 0, yco-=20, menuwidth, 19, "");
-#endif
-
-       uiItemMenuF(layout, "Clear/Apply", 0, view3d_edit_object_transformmenu);
-       uiItemMenuF(layout, "Snap", 0, view3d_edit_snapmenu);
-
-       uiItemS(layout);
-
-       // TODO: these operators may get renamed
-       uiItemO(layout, NULL, 0, "ANIM_OT_insert_keyframe_menu");
-       uiItemO(layout, NULL, 0, "ANIM_OT_delete_keyframe_v3d");
-       
-       uiItemS(layout);
-       
-       uiItemO(layout, NULL, 0, "OBJECT_OT_duplicate");
-       uiItemBooleanO(layout, "Duplicate Linked", 0, "OBJECT_OT_duplicate", "linked", 1);
-       uiItemO(layout, NULL, 0, "OBJECT_OT_delete");
-       
-       uiItemO(layout, NULL, 0, "OBJECT_OT_proxy_make");
-#if 0
-       uiDefIconTextBlockBut(block, view3d_edit_object_makelinksmenu, NULL, ICON_RIGHTARROW_THIN, "Make Links", 0, yco-=20, 120, 19, "");
-       uiDefIconTextBlockBut(block, view3d_edit_object_singleusermenu, NULL, ICON_RIGHTARROW_THIN, "Make Single User", 0, yco-=20, 120, 19, "");
-       uiDefIconTextBlockBut(block, view3d_edit_object_makelocalmenu, NULL, ICON_RIGHTARROW_THIN, "Make Local", 0, yco-=20, 120, 19, "");
-       uiDefIconTextBlockBut(block, view3d_edit_object_copyattrmenu, NULL, ICON_RIGHTARROW_THIN, "Copy Attributes", 0, yco-=20, 120, 19, "");
-#endif
-       
-       uiItemS(layout);
-       
-       uiItemMenuF(layout, "Parent", 0, view3d_edit_object_parentmenu);
-       uiItemMenuF(layout, "Track", 0, view3d_edit_object_trackmenu);
-       uiItemMenuF(layout, "Group", 0, view3d_edit_object_groupmenu);
-       uiItemMenuF(layout, "Constraints", 0, view3d_edit_object_constraintsmenu);
-
-#if 0
-       if(ob && ob->type == OB_MESH) {
-               uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Boolean Operation...|W",                         0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 7, "");
-       }
-       
-       // join... (added already)
-       
-       uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Convert Object Type...|Alt C",                           0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 9, "");
-#endif
-       uiItemS(layout);
-       
-       uiItemO(layout, NULL, 0, "OBJECT_OT_join");
-
-       uiItemS(layout);
-       
-#if 0
-       uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Move to Layer...|M",                             0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 10, "");
-#endif
-
-       uiItemMenuF(layout, "Show/Hide", 0, view3d_edit_object_showhidemenu);
-       
-#if 0
-#ifndef DISABLE_PYTHON
-       uiDefBut(block, SEPR, 0, "",                            0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, "");
-       uiDefIconTextBlockBut(block, view3d_edit_object_scriptsmenu, NULL, ICON_RIGHTARROW_THIN, "Scripts", 0, yco-=20, 120, 19, "");
-#endif
-#endif
-}
-
 static void view3d_edit_mesh_verticesmenu(bContext *C, uiLayout *layout, void *arg_unused)
 {
        uiItemO(layout, "Merge...", 0, "MESH_OT_merge");
@@ -3738,11 +3634,6 @@ static void view3d_header_pulldowns(const bContext *C, uiBlock *block, Object *o
                        uiDefMenuBut(block, view3d_pose_armaturemenu, NULL, "Pose",     xco,yco, xmax-3, 20, "");
                        xco+= xmax;
                }
-               else {
-                       xmax= GetButStringLength("Object");
-                       uiDefMenuBut(block, view3d_edit_objectmenu, NULL, "Object",     xco,yco, xmax-3, 20, "");
-                       xco+= xmax;
-               }
        }
 
        *xcoord= xco;