diff options
author | Campbell Barton <ideasman42@gmail.com> | 2007-02-21 14:17:17 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2007-02-21 14:17:17 +0300 |
commit | f71458b90483e33923e706e1b6aa6612dd0fd425 (patch) | |
tree | 7850f63e7ee8bb4462d7125041434fa35c358a8a /source/blender | |
parent | 6831c0453371f7b90428686e74b485f76620cf9d (diff) |
adding menu slot Armature
adding menu slot ScriptTemplate
new script scripttemplate_mesh_edit is a template for an editmesh script.
The function Text makeCurrent() is a dummy until I can get it working when the script runs from a menu.
Diffstat (limited to 'source/blender')
-rw-r--r-- | source/blender/python/BPY_menus.c | 10 | ||||
-rw-r--r-- | source/blender/python/BPY_menus.h | 2 | ||||
-rw-r--r-- | source/blender/python/api2_2x/Text.c | 25 | ||||
-rw-r--r-- | source/blender/python/api2_2x/Window.c | 1 | ||||
-rw-r--r-- | source/blender/python/api2_2x/doc/Text.py | 7 | ||||
-rw-r--r-- | source/blender/src/header_text.c | 36 | ||||
-rw-r--r-- | source/blender/src/header_view3d.c | 40 |
7 files changed, 118 insertions, 3 deletions
diff --git a/source/blender/python/BPY_menus.c b/source/blender/python/BPY_menus.c index 2a53ba1adf1..9b4a5721d4c 100644 --- a/source/blender/python/BPY_menus.c +++ b/source/blender/python/BPY_menus.c @@ -105,6 +105,10 @@ static int bpymenu_group_atoi( char *str ) return PYMENU_VERTEXPAINT; else if( !strcmp( str, "UVCalculation" ) ) return PYMENU_UVCALCULATION; + else if( !strcmp( str, "Armature" ) ) + return PYMENU_ARMATURE; + else if( !strcmp( str, "ScriptTemplate" ) ) + return PYMENU_SCRIPTTEMPLATE; /* "Misc" or an inexistent group name: use misc */ else return PYMENU_MISC; @@ -173,6 +177,12 @@ char *BPyMenu_group_itoa( short menugroup ) case PYMENU_UVCALCULATION: return "UVCalculation"; break; + case PYMENU_ARMATURE: + return "Armature"; + break; + case PYMENU_SCRIPTTEMPLATE: + return "ScriptTemplate"; + break; case PYMENU_MISC: return "Misc"; break; diff --git a/source/blender/python/BPY_menus.h b/source/blender/python/BPY_menus.h index d66f1acf1fc..dfa16853157 100644 --- a/source/blender/python/BPY_menus.h +++ b/source/blender/python/BPY_menus.h @@ -100,6 +100,8 @@ typedef enum { PYMENU_WEIGHTPAINT, PYMENU_VERTEXPAINT, PYMENU_UVCALCULATION, + PYMENU_ARMATURE, + PYMENU_SCRIPTTEMPLATE, PYMENU_HELP,/*Main Help menu items - prob best to leave for 'official' ones*/ PYMENU_HELPSYSTEM,/* Resources, troubleshooting, system tools */ PYMENU_HELPWEBSITES,/* Help -> Websites submenu */ diff --git a/source/blender/python/api2_2x/Text.c b/source/blender/python/api2_2x/Text.c index ddfb1b0044f..b0f82bc8f49 100644 --- a/source/blender/python/api2_2x/Text.c +++ b/source/blender/python/api2_2x/Text.c @@ -43,6 +43,11 @@ #include "gen_utils.h" #include "../BPY_extern.h" +/* used only for makeCurrent, this may be deprecated when Blender.Base is implimented */ +#include "BIF_screen.h" +#include "DNA_space_types.h" +#include "DNA_screen_types.h" + #define EXPP_TEXT_MODE_FOLLOW TXT_FOLLOW /*****************************************************************************/ @@ -106,6 +111,7 @@ static PyObject *Text_clear( BPy_Text * self ); static PyObject *Text_write( BPy_Text * self, PyObject * args ); static PyObject *Text_set( BPy_Text * self, PyObject * args ); static PyObject *Text_asLines( BPy_Text * self ); +static PyObject *Text_makeCurrent( BPy_Text * self ); /*****************************************************************************/ /* Python BPy_Text methods table: */ @@ -128,6 +134,8 @@ static PyMethodDef BPy_Text_methods[] = { "(name, val) - Set attribute 'name' to value 'val'"}, {"asLines", ( PyCFunction ) Text_asLines, METH_NOARGS, "() - Return text buffer as a list of lines"}, + {"makeCurrent", ( PyCFunction ) Text_makeCurrent, METH_NOARGS, + "() - display this text."}, {NULL, NULL, 0, NULL} }; @@ -528,6 +536,23 @@ static PyObject *Text_asLines( BPy_Text * self ) return list; } +static PyObject *Text_makeCurrent( BPy_Text * self ) +{ + /* + SpaceText *st= curarea->spacedata.first; + + if( !self->text ) + return EXPP_ReturnPyObjError( PyExc_RuntimeError, + "This object isn't linked to a Blender Text Object" ); + + if(st->spacetype!=SPACE_TEXT) + Py_RETURN_NONE; + + st->text = self->text; + */ + Py_RETURN_NONE; +} + /*****************************************************************************/ /* Function: Text_dealloc */ /* Description: This is a callback function for the BPy_Text type. It is */ diff --git a/source/blender/python/api2_2x/Window.c b/source/blender/python/api2_2x/Window.c index 1aae671708e..ae97ee8b8b4 100644 --- a/source/blender/python/api2_2x/Window.c +++ b/source/blender/python/api2_2x/Window.c @@ -363,7 +363,6 @@ struct PyMethodDef M_Window_methods[] = { PyObject *M_Window_Redraw( PyObject * self, PyObject * args ) { ScrArea *tempsa, *sa; - SpaceText *st; int wintype = SPACE_VIEW3D; short redraw_all = 0; diff --git a/source/blender/python/api2_2x/doc/Text.py b/source/blender/python/api2_2x/doc/Text.py index edb88d0f3f0..ad37de8171c 100644 --- a/source/blender/python/api2_2x/doc/Text.py +++ b/source/blender/python/api2_2x/doc/Text.py @@ -125,3 +125,10 @@ class Text: @rtype: list of strings @return: A list of strings, one for each line in the buffer """ + + def makeCurrent(): + """ + Display this text in the current 3d view if any + @rtype: None + @return: None + """
\ No newline at end of file diff --git a/source/blender/src/header_text.c b/source/blender/src/header_text.c index e370a1deb10..d14ee33354a 100644 --- a/source/blender/src/header_text.c +++ b/source/blender/src/header_text.c @@ -67,6 +67,7 @@ #include "BSE_filesel.h" #include "BPY_extern.h" +#include "BPY_menus.h" #include "blendef.h" #include "mydevice.h" @@ -197,6 +198,37 @@ void do_text_buttons(unsigned short event) } } +static void do_text_template_scriptsmenu(void *arg, int event) +{ + BPY_menu_do_python(PYMENU_SCRIPTTEMPLATE, event); + + allqueue(REDRAWIMAGE, 0); +} + +static uiBlock *text_template_scriptsmenu (void *args_unused) +{ + uiBlock *block; + BPyMenu *pym; + int i= 0; + short yco = 20, menuwidth = 120; + + block= uiNewBlock(&curarea->uiblocks, "text_template_scriptsmenu", UI_EMBOSSP, UI_HELV, G.curscreen->mainwin); + uiBlockSetButmFunc(block, do_text_template_scriptsmenu, NULL); + + /* note that we acount for the N previous entries with i+20: */ + for (pym = BPyMenuTable[PYMENU_SCRIPTTEMPLATE]; pym; pym = pym->next, i++) { + + uiDefIconTextBut(block, BUTM, 1, ICON_PYTHON, pym->name, 0, yco-=20, menuwidth, 19, + NULL, 0.0, 0.0, 1, i, + pym->tooltip?pym->tooltip:pym->filename); + } + + uiBlockSetDirection(block, UI_RIGHT); + uiTextBoundsBlock(block, 60); + + return block; +} + /* action executed after clicking in File menu */ static void do_text_filemenu(void *arg, int event) { @@ -577,13 +609,15 @@ static uiBlock *text_filemenu(void *arg_unused) uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "New|Alt N", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 1, ""); uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Open...|Alt O", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 2, ""); if(text) { - uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Reopen|Alt R", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 3, ""); + uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Reopen|Alt R", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 3, ""); uiDefBut(block, SEPR, 0, "", 0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, ""); uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Save|Alt S", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 4, ""); uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Save As...", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 5, ""); uiDefBut(block, SEPR, 0, "", 0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, ""); uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Run Python Script|Alt P", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 6, ""); } + + uiDefIconTextBlockBut(block, text_template_scriptsmenu, NULL, ICON_RIGHTARROW_THIN, "Script Templates", 0, yco-=20, 120, 19, ""); if(curarea->headertype==HEADERTOP) { uiBlockSetDirection(block, UI_DOWN); diff --git a/source/blender/src/header_view3d.c b/source/blender/src/header_view3d.c index 66f69ac3a78..2b966aacc8b 100644 --- a/source/blender/src/header_view3d.c +++ b/source/blender/src/header_view3d.c @@ -3576,6 +3576,40 @@ static void do_view3d_edit_armaturemenu(void *arg, int event) allqueue(REDRAWVIEW3D, 0); } + + +static void do_view3d_scripts_armaturemenu(void *arg, int event) +{ + BPY_menu_do_python(PYMENU_SCRIPTTEMPLATE, event); + + allqueue(REDRAWIMAGE, 0); +} + +static uiBlock *view3d_scripts_armaturemenu(void *args_unused) +{ + uiBlock *block; + BPyMenu *pym; + int i= 0; + short yco = 20, menuwidth = 120; + + block= uiNewBlock(&curarea->uiblocks, "view3d_scripts_armaturemenu", UI_EMBOSSP, UI_HELV, G.curscreen->mainwin); + uiBlockSetButmFunc(block, do_view3d_scripts_armaturemenu, NULL); + + /* note that we acount for the N previous entries with i+20: */ + for (pym = BPyMenuTable[PYMENU_ARMATURE]; pym; pym = pym->next, i++) { + + uiDefIconTextBut(block, BUTM, 1, ICON_PYTHON, pym->name, 0, yco-=20, menuwidth, 19, + NULL, 0.0, 0.0, 1, i, + pym->tooltip?pym->tooltip:pym->filename); + } + + uiBlockSetDirection(block, UI_RIGHT); + uiTextBoundsBlock(block, 60); + + return block; +} + + static uiBlock *view3d_edit_armaturemenu(void *arg_unused) { bArmature *arm= G.obedit->data; @@ -3613,7 +3647,11 @@ static uiBlock *view3d_edit_armaturemenu(void *arg_unused) uiDefBut(block, SEPR, 0, "", 0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, ""); uiDefIconTextBlockBut(block, view3d_edit_armature_parentmenu, NULL, ICON_RIGHTARROW_THIN, "Parent", 0, yco-=20, 120, 19, ""); - + + uiDefBut(block, SEPR, 0, "", 0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, ""); + + uiDefIconTextBlockBut(block, view3d_scripts_armaturemenu, NULL, ICON_RIGHTARROW_THIN, "Scripts", 0, yco-=20, 120, 19, ""); + if(curarea->headertype==HEADERTOP) { uiBlockSetDirection(block, UI_DOWN); } |