forked from bartvdbraak/blender
* Added support for python scripts to register themselves
in the UV/Image editor 'UVs' menu Script authors can use: Group: 'UV' in the headers of their scripts to let them appear in this menu. * Updated the UV Face Layout script to reside in the UVs menu, rather than the (incorrect) File->Export menu.
This commit is contained in:
parent
779d0d0221
commit
f9fa705cd3
@ -1,10 +1,10 @@
|
||||
#!BPY
|
||||
|
||||
"""
|
||||
Name: 'UV Face Layout'
|
||||
Name: 'Save UV Face Layout...'
|
||||
Blender: 232
|
||||
Group: 'Export'
|
||||
Tooltip: 'Export the UV Faces layout of the selected object to tga'
|
||||
Group: 'UV'
|
||||
Tooltip: 'Export the UV face layout of the selected object to a .TGA file'
|
||||
"""
|
||||
|
||||
# --------------------------------------------------------------------------
|
||||
|
@ -82,6 +82,7 @@ static int bpymenu_group_atoi (char *str)
|
||||
else if (!strcmp(str, "Wizards")) return PYMENU_WIZARDS;
|
||||
else if (!strcmp(str, "Animation")) return PYMENU_ANIMATION;
|
||||
else if (!strcmp(str, "Materials")) return PYMENU_MATERIALS;
|
||||
else if (!strcmp(str, "UV")) return PYMENU_UV;
|
||||
/* "Misc" or an inexistent group name: use misc */
|
||||
else return PYMENU_MISC;
|
||||
}
|
||||
@ -110,6 +111,8 @@ char *BPyMenu_group_itoa (short menugroup)
|
||||
case PYMENU_MATERIALS:
|
||||
return "Materials";
|
||||
break;
|
||||
case PYMENU_UV:
|
||||
return "UV";
|
||||
case PYMENU_MISC:
|
||||
return "Misc";
|
||||
break;
|
||||
|
@ -87,6 +87,7 @@ typedef enum {
|
||||
PYMENU_IMPORT,
|
||||
PYMENU_EXPORT,
|
||||
PYMENU_ANIMATION,
|
||||
PYMENU_UV, /* UV editing tools, to go in UV/Image editor space, 'UV' menu */
|
||||
PYMENU_TOTAL
|
||||
} PYMENUHOOKS;
|
||||
|
||||
|
@ -81,6 +81,8 @@
|
||||
#include "BSE_filesel.h"
|
||||
#include "BSE_headerbuttons.h"
|
||||
|
||||
#include "BPY_menus.h"
|
||||
|
||||
#include "IMB_imbuf.h"
|
||||
#include "IMB_imbuf_types.h"
|
||||
|
||||
@ -568,9 +570,9 @@ static void do_image_imagemenu(void *arg, int event)
|
||||
if(G.sima->image) strcpy(name, G.sima->image->name);
|
||||
else strcpy(name, U.textudir);
|
||||
if(G.qual==LR_CTRLKEY)
|
||||
activate_imageselect(FILE_SPECIAL, "SELECT IMAGE", name, load_space_image);
|
||||
activate_imageselect(FILE_SPECIAL, "Open Image", name, load_space_image);
|
||||
else
|
||||
activate_fileselect(FILE_SPECIAL, "SELECT IMAGE", name, load_space_image);
|
||||
activate_fileselect(FILE_SPECIAL, "Open Image", name, load_space_image);
|
||||
break;
|
||||
case 1: /* Replace */
|
||||
if(G.sima->image) strcpy(name, G.sima->image->name);
|
||||
@ -813,7 +815,13 @@ static uiBlock *image_uvs_transformmenu(void *arg_unused)
|
||||
|
||||
static void do_image_uvsmenu(void *arg, int event)
|
||||
{
|
||||
switch(event)
|
||||
extern int BPY_menu_do_python(short menutype, int event); // BPY_interface.c
|
||||
ScrArea *sa;
|
||||
|
||||
/* events >=20 are registered bpython scripts */
|
||||
if (event >= 20) BPY_menu_do_python(PYMENU_UV, event - 20);
|
||||
|
||||
else switch(event)
|
||||
{
|
||||
case 1: /* UVs Constrained Rectangular */
|
||||
if(G.sima->flag & SI_BE_SQUARE) G.sima->flag &= ~SI_BE_SQUARE;
|
||||
@ -846,6 +854,8 @@ static uiBlock *image_uvsmenu(void *arg_unused)
|
||||
{
|
||||
uiBlock *block;
|
||||
short yco= 0, menuwidth=120;
|
||||
BPyMenu *pym;
|
||||
int i = 0;
|
||||
|
||||
block= uiNewBlock(&curarea->uiblocks, "image_uvsmenu", UI_EMBOSSP, UI_HELV, curarea->headwin);
|
||||
uiBlockSetButmFunc(block, do_image_uvsmenu, NULL);
|
||||
@ -878,6 +888,16 @@ static uiBlock *image_uvsmenu(void *arg_unused)
|
||||
|
||||
uiDefBut(block, SEPR, 0, "", 0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, "");
|
||||
|
||||
/* note that we acount for the 3 previous entries with i+3: */
|
||||
for (pym = BPyMenuTable[PYMENU_UV]; pym; pym = pym->next, i++) {
|
||||
|
||||
uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, pym->name, 0, yco-=20, menuwidth, 19,
|
||||
NULL, 0.0, 0.0, 1, i+20,
|
||||
pym->tooltip?pym->tooltip:pym->filename);
|
||||
}
|
||||
|
||||
uiDefBut(block, SEPR, 0, "", 0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, "");
|
||||
|
||||
uiDefIconTextBlockBut(block, image_uvs_showhidemenu, NULL, ICON_RIGHTARROW_THIN, "Show/Hide Faces", 0, yco-=20, menuwidth, 19, "");
|
||||
|
||||
if(curarea->headertype==HEADERTOP) {
|
||||
|
@ -698,11 +698,9 @@ static uiBlock *info_file_importmenu(void *arg_unused)
|
||||
//uiBlockSetXOfs(block, -50); // offset to parent button
|
||||
|
||||
for (pym = BPyMenuTable[PYMENU_IMPORT]; pym; pym = pym->next, i++) {
|
||||
uiDefBut(block, BUTM, 1, pym->name, 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, i, pym->tooltip?pym->tooltip:pym->filename);
|
||||
uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, pym->name, 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, i, pym->tooltip?pym->tooltip:pym->filename);
|
||||
}
|
||||
|
||||
uiDefBut(block, SEPR, 0, "", 0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, "");
|
||||
|
||||
uiBlockSetDirection(block, UI_RIGHT);
|
||||
uiTextBoundsBlock(block, 60);
|
||||
|
||||
@ -751,19 +749,18 @@ static uiBlock *info_file_exportmenu(void *arg_unused)
|
||||
uiBlockSetButmFunc(block, do_info_file_exportmenu, NULL);
|
||||
//uiBlockSetXOfs(block, -50); // offset to parent button
|
||||
|
||||
uiDefBut(block, BUTM, 1, "VRML 1.0...|Ctrl F2",
|
||||
uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "VRML 1.0...|Ctrl F2",
|
||||
0, yco-=20, 120, 19, NULL, 0.0, 0.0, 1, 0, "");
|
||||
uiDefBut(block, BUTM, 1, "DXF...|Shift F2",
|
||||
uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "DXF...|Shift F2",
|
||||
0, yco-=20, 120, 19, NULL, 0.0, 0.0, 1, 1, "");
|
||||
uiDefBut(block, BUTM, 1, "Videoscape...|Alt W",
|
||||
uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Videoscape...|Alt W",
|
||||
0, yco-=20, 120, 19, NULL, 0.0, 0.0, 1, 2, "");
|
||||
|
||||
uiDefBut(block, SEPR, 0, "", 0, yco-=6, menuwidth, 6, NULL,
|
||||
0.0, 0.0, 0, 0, "");
|
||||
uiDefBut(block, SEPR, 0, "", 0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, "");
|
||||
|
||||
/* note that we acount for the 3 previous entries with i+3: */
|
||||
for (pym = BPyMenuTable[PYMENU_EXPORT]; pym; pym = pym->next, i++) {
|
||||
uiDefBut(block, BUTM, 1, pym->name, 0, yco-=20, menuwidth, 19,
|
||||
uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, pym->name, 0, yco-=20, menuwidth, 19,
|
||||
NULL, 0.0, 0.0, 1, i+3,
|
||||
pym->tooltip?pym->tooltip:pym->filename);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user