2 * $Id: BPY_menus.h 10443 2007-04-02 09:58:01Z campbellbarton $
4 * ***** BEGIN GPL/BL DUAL LICENSE BLOCK *****
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version 2
9 * of the License, or (at your option) any later version. The Blender
10 * Foundation also sells licenses for use in proprietary software under
11 * the Blender License. See http://www.blender.org/BL/ for information
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software Foundation,
21 * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
23 * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
24 * All rights reserved.
26 * This is a new part of Blender.
28 * Contributor(s): Willian P. Germano, Matt Ebb
30 * ***** END GPL/BL DUAL LICENSE BLOCK *****
36 /* This header exposes BPyMenu related public declarations. The implementation
37 * adds 'dynamic' menus to Blender, letting scripts register themselves in any
38 * of a few pre-defined (trivial to upgrade) places in menus. These places or
39 * slots are called groups here (Import, Export, etc). This is how it works:
40 * - scripts at dirs user pref U.pythondir and .blender/scripts/ are scanned
41 * for registration info.
42 * - this data is also saved to a Bpymenus file at the user's .blender/ dir and
43 * only re-created when the scripts folder gets modified.
44 * - on start-up Blender uses this info to fill a table, which is used to
45 * create the menu entries when they are needed (see header_info.c or
46 * header_script.c, under source/blender/src/, for examples).
49 /* These two structs hold py menu/submenu info.
50 * BPyMenu holds a script's name (as should appear in the menu) and filename,
51 * plus an optional list of submenus. Each submenu is related to a string
52 * (arg) that the script can get from the __script__ pydict, to know which
53 * submenu was chosen. */
55 typedef struct BPySubMenu
{
58 struct BPySubMenu
*next
;
61 typedef struct BPyMenu
{
65 short version
; /* Blender version */
66 int dir
; /* 0: default, 1: U.pythondir */
67 struct BPySubMenu
*submenus
;
71 /* Scripts can be added to only a few pre-defined places in menus, like
72 * File->Import, File->Export, etc. (for speed and better control).
73 * To make a new menu 'slot' available for scripts:
74 * - add an entry to the enum below, before PYMENU_TOTAL, of course;
75 * - update the bpymenu_group_atoi() and BPyMenu_group_itoa() functions in
77 * - add the necessary code to the header_***.c file in
78 * source/blender/src/, like done in header_info.c for import/export;
81 PYMENU_ADD
,/* creates new objects */
89 PYMENU_RENDER
,/* exporters to external renderers */
92 PYMENU_UV
,/* UV editing tools, to go in UV/Image editor space, 'UV' menu */
93 PYMENU_IMAGE
,/* Image editing tools, to go in UV/Image editor space, 'Image' menu */
94 PYMENU_WIZARDS
,/* complex 'app' scripts */
96 /* entries put after Wizards don't appear at the Scripts win->Scripts menu;
97 * see define right below */
102 PYMENU_UVCALCULATION
,
104 PYMENU_SCRIPTTEMPLATE
,
105 PYMENU_HELP
,/*Main Help menu items - prob best to leave for 'official' ones*/
106 PYMENU_HELPSYSTEM
,/* Resources, troubleshooting, system tools */
107 PYMENU_HELPWEBSITES
,/* Help -> Websites submenu */
108 PYMENU_MESHFACEKEY
, /* face key in mesh editmode */
109 PYMENU_ADDMESH
, /* adds mesh */
113 #define PYMENU_SCRIPTS_MENU_TOTAL (PYMENU_WIZARDS + 1)
115 /* BPyMenuTable holds all registered pymenus, as linked lists for each menu
116 * where they can appear (see PYMENUHOOKS enum above).
118 extern BPyMenu
*BPyMenuTable
[]; /* defined in BPY_menus.c */
120 /* public functions: */
121 int BPyMenu_Init( int usedir
);
122 void BPyMenu_RemoveAllEntries( void );
123 void BPyMenu_PrintAllEntries( void );
124 char *BPyMenu_CreatePupmenuStr( BPyMenu
* pym
, short group
);
125 char *BPyMenu_group_itoa( short group
);
126 struct BPyMenu
*BPyMenu_GetEntry( short group
, short pos
);
128 #endif /* BPY_MENUS_H */