From 48a63498ae5fd5ea203230c3eb919c024cac7822 Mon Sep 17 00:00:00 2001 From: Matt Ebb Date: Fri, 22 Feb 2008 01:28:48 +0000 Subject: [PATCH] * Let 'Add' scripts appear in the Add header menu, not just the scripts window --- source/blender/src/header_info.c | 91 +++++++++++++++++++------------- 1 file changed, 53 insertions(+), 38 deletions(-) diff --git a/source/blender/src/header_info.c b/source/blender/src/header_info.c index 4679df9f9ba..fb7b57ddb8d 100644 --- a/source/blender/src/header_info.c +++ b/source/blender/src/header_info.c @@ -1453,44 +1453,48 @@ static uiBlock *info_add_groupmenu(void *arg_unused) void do_info_addmenu(void *arg, int event) { - switch(event) { - case 0: - /* Mesh */ - break; - case 1: - /* Curve */ - break; - case 2: - /* Surface */ - break; - case 3: - /* Metaball */ - break; - case 4: - /* Text (argument is discarded) */ - add_primitiveFont(event); - break; - case 5: - /* Empty */ - add_object_draw(OB_EMPTY); - break; - case 6: - /* Camera */ - add_object_draw(OB_CAMERA); - break; - case 8: - /* Armature */ - add_primitiveArmature(OB_ARMATURE); - break; - case 9: - /* Lattice */ - add_object_draw(OB_LATTICE); - break; - case 10: - /* group instance not yet */ - break; - default: - break; + if (event>=20) { + BPY_menu_do_python(PYMENU_ADD, event - 20); + } else { + switch(event) { + case 0: + /* Mesh */ + break; + case 1: + /* Curve */ + break; + case 2: + /* Surface */ + break; + case 3: + /* Metaball */ + break; + case 4: + /* Text (argument is discarded) */ + add_primitiveFont(event); + break; + case 5: + /* Empty */ + add_object_draw(OB_EMPTY); + break; + case 6: + /* Camera */ + add_object_draw(OB_CAMERA); + break; + case 8: + /* Armature */ + add_primitiveArmature(OB_ARMATURE); + break; + case 9: + /* Lattice */ + add_object_draw(OB_LATTICE); + break; + case 10: + /* group instance not yet */ + break; + default: + break; + } } allqueue(REDRAWINFO, 0); } @@ -1500,6 +1504,8 @@ static uiBlock *info_addmenu(void *arg_unused) { /* static short tog=0; */ uiBlock *block; + BPyMenu *pym; + int i=0; short yco= 0; block= uiNewBlock(&curarea->uiblocks, "addmenu", UI_EMBOSSP, UI_HELV, curarea->headwin); @@ -1526,6 +1532,15 @@ static uiBlock *info_addmenu(void *arg_unused) uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Armature", 0, yco-=20, 120, 19, NULL, 0.0, 0.0, 1, 8, ""); uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Lattice", 0, yco-=20, 120, 19, NULL, 0.0, 0.0, 1, 9, ""); + pym = BPyMenuTable[PYMENU_ADD]; + if (pym) { + uiDefIconTextBut(block, SEPR, 0, ICON_BLANK1, "", 0, yco-=6, 1620, 6, NULL, 0.0, 0.0, 0, 0, ""); + + for (; pym; pym = pym->next, i++) { + uiDefIconTextBut(block, BUTM, 1, ICON_PYTHON, pym->name, 0, yco-=20, 120, 19, NULL, 0.0, 0.0, 1, i+20, pym->tooltip?pym->tooltip:pym->filename); + } + } + uiBlockSetDirection(block, UI_DOWN); uiTextBoundsBlock(block, 80);