~ubuntu-branches/ubuntu/gutsy/blender/gutsy-security

« back to all changes in this revision

Viewing changes to source/blender/src/toolbox.c

  • Committer: Bazaar Package Importer
  • Author(s): Florian Ernst
  • Date: 2007-05-17 11:47:59 UTC
  • mfrom: (1.2.6 upstream)
  • Revision ID: james.westby@ubuntu.com-20070517114759-yp4ybrnhp2u7pk66
Tags: 2.44-1
* New upstream release.
* Drop debian/patches/01_64bits_stupidity, not needed anymore: as of this
  version blender is 64 bits safe again. Adjust README.Debian accordingly.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/**
2
 
 * $Id: toolbox.c,v 1.156 2007/02/01 14:14:07 ton Exp $
 
2
 * $Id: toolbox.c,v 1.167 2007/05/10 05:44:44 bebraw Exp $
3
3
 *
4
4
 * ***** BEGIN GPL/BL DUAL LICENSE BLOCK *****
5
5
 *
122
122
#include "butspace.h"
123
123
#include "mydevice.h"
124
124
 
 
125
/* bpymenu */
 
126
#include "BPY_extern.h"
 
127
#include "BPY_menus.h"
 
128
 
125
129
void asciitoraw(int ch, unsigned short *event, unsigned short *qual)
126
130
{
127
131
        if( isalpha(ch)==0 ) return;
232
236
        va_end(ap);
233
237
}
234
238
 
 
239
void error_libdata(void)
 
240
{
 
241
        error(ERROR_LIBDATA_MESSAGE);
 
242
}
 
243
 
235
244
int saveover(char *file)
236
245
{
237
246
        int len= strlen(file);
389
398
        /* buttons have 0 as return event, to prevent menu to close on hotkeys */
390
399
        uiBlockBeginAlign(block);
391
400
        for(a=0; a<5; a++) 
392
 
                uiDefButBitI(block, TOGR, 1<<a, 0, "",(short)(x1+a*dx),(short)(y1+dy),(short)dx,(short)dy, lay, 0, 0, 0, 0, "");
 
401
                uiDefButBitI(block, TOGR, 1<<a, 0, "",(short)(x1+a*dx),(short)(y1+dy),(short)dx,(short)dy, (int *)lay, 0, 0, 0, 0, "");
393
402
        for(a=0; a<5; a++) 
394
 
                uiDefButBitI(block, TOGR, 1<<(a+10), 0, "",(short)(x1+a*dx),(short)y1,(short)dx,(short)dy, lay, 0, 0, 0, 0, "");
 
403
                uiDefButBitI(block, TOGR, 1<<(a+10), 0, "",(short)(x1+a*dx),(short)y1,(short)dx,(short)dy, (int *)lay, 0, 0, 0, 0, "");
395
404
        x1+= 5;
396
405
        
397
406
        uiBlockBeginAlign(block);
398
407
        for(a=5; a<10; a++) 
399
 
                uiDefButBitI(block, TOGR, 1<<a, 0, "",(short)(x1+a*dx),(short)(y1+dy),(short)dx,(short)dy, lay, 0, 0, 0, 0, "");
 
408
                uiDefButBitI(block, TOGR, 1<<a, 0, "",(short)(x1+a*dx),(short)(y1+dy),(short)dx,(short)dy, (int *)lay, 0, 0, 0, 0, "");
400
409
        for(a=5; a<10; a++) 
401
 
                uiDefButBitI(block, TOGR, 1<<(a+10), 0, "",(short)(x1+a*dx),(short)y1,(short)dx,(short)dy, lay, 0, 0, 0, 0, "");
 
410
                uiDefButBitI(block, TOGR, 1<<(a+10), 0, "",(short)(x1+a*dx),(short)y1,(short)dx,(short)dy, (int *)lay, 0, 0, 0, 0, "");
402
411
        uiBlockEndAlign(block);
403
412
 
404
413
        x1-= 5;
561
570
                
562
571
                if(varstr->type==TEX) {
563
572
                        uiDefBut(block, TEX, 0, varstr->name,(short)((x1+15) + (sizex*xi)),(short)(y2-55- 20*yi),(short)(sizex), 19, numbpoin[a], varstr->min, varstr->max, 0, 0, varstr->tip);
564
 
                }
565
 
                else  {
 
573
                } else if(varstr->type==COL) {
 
574
                        uiDefButF(block, COL, 0, "",(short)((x1+15) + (sizex*xi)),(short)(y2-55- 20*yi),(short)(sizex), 19, numbpoin[a], varstr->min, varstr->max, 0, 0, "");
 
575
                } else  {
566
576
                        if(varstr->type==LABEL) {/* dont include the label when rounding the buttons */
567
577
                                uiBlockEndAlign(block);
568
578
                        
1119
1129
 
1120
1130
static TBitem tb_curve_hide[]= {
1121
1131
{       0, "Show Hidden|Alt H",                 10,             NULL},
1122
 
{       0, "Hide Selected|H",                   11,             NULL},
 
1132
{       0, "Hide Selected|Alt Ctrl H",                  11,             NULL},
1123
1133
{  -1, "",                      0, do_view3d_edit_curve_showhidemenu}};
1124
1134
 
1125
1135
 
1178
1188
{  -1, "",                      0, tb_do_view_dt}};
1179
1189
 
1180
1190
static TBitem tb_view_alignview[]= {
1181
 
{       0, "Centre View to Cursor|C",           'c', NULL},
 
1191
{       0, "Center View to Cursor|C",           'c', NULL},
1182
1192
{       0, "Align Active Camera to View|Ctrl Alt NumPad 0",
1183
1193
TB_CTRL|TB_ALT|TB_PAD|'0', NULL}, 
1184
1194
{       0, "Align View to Selected|NumPad *",           TB_PAD|'*', NULL},
1318
1328
                        else G.scene->proportional= 1;
1319
1329
                        break;
1320
1330
                case 10:
1321
 
                        docentre(0);
 
1331
                        docenter(0);
1322
1332
                        break;
1323
1333
                case 11:
1324
 
                        docentre_new();
 
1334
                        docenter_new();
1325
1335
                        break;
1326
1336
                case 12:
1327
 
                        docentre_cursor();
 
1337
                        docenter_cursor();
1328
1338
                        break;
1329
1339
        }
1330
1340
        allqueue(REDRAWVIEW3D, 0);
1410
1420
 
1411
1421
/* *************ADD ********** */
1412
1422
 
1413
 
static TBitem addmenu_mesh[]= {
1414
 
{       0, "Plane",     0, NULL},
1415
 
{       0, "Cube",              1, NULL},
1416
 
{       0, "Circle",    2, NULL},
1417
 
{       0, "UVsphere",  3, NULL},
1418
 
{       0, "Icosphere", 4, NULL},
1419
 
{       0, "Cylinder",  5, NULL},
1420
 
{       0, "Tube",              6, NULL},
1421
 
{       0, "Cone",              7, NULL},
1422
 
{       0, "SEPR",              0, NULL},
1423
 
{       0, "Grid",              8, NULL},
1424
 
{       0, "Monkey",    9, NULL},
1425
 
{  -1, "",                      0, do_info_add_meshmenu}};
1426
 
 
1427
1423
static TBitem addmenu_curve[]= {
1428
1424
{       0, "Bezier Curve",      0, NULL},
1429
1425
{       0, "Bezier Circle", 1, NULL},
1472
1468
{  -1, "",                      0, do_info_addmenu}};
1473
1469
 
1474
1470
/* dynamic items */
 
1471
#define TB_ADD_MESH             0
1475
1472
#define TB_ADD_GROUP    7
1476
1473
#define TB_ADD_LAMP             10
1477
1474
 
1478
1475
static TBitem tb_add[]= {
1479
 
{       0, "Mesh",              0, addmenu_mesh},
 
1476
{       0, "Mesh",              0, NULL},
1480
1477
{       0, "Curve",     1, addmenu_curve},
1481
1478
{       0, "Surface",   2, addmenu_surf},
1482
1479
{       0, "Meta",      3, addmenu_meta},
1576
1573
{
1577
1574
        static TBitem _addmenu[]= { {   0, " ",         0, NULL}, {  -1, "",                    0, NULL}};
1578
1575
        Link *link;
1579
 
        bNodeType **typedefs;
1580
1576
        TBitem *addmenu;
1581
1577
        int tot= 0, a;
1582
1578
        
1588
1584
                                        tot++;
1589
1585
                }
1590
1586
                else {
1591
 
                        for(typedefs= ntree->alltypes; *typedefs; typedefs++)
1592
 
                                if( (*typedefs)->nclass == nodeclass )
 
1587
                        bNodeType *ntype = ntree->alltypes.first;
 
1588
                        while(ntype) {
 
1589
                                if(ntype->nclass == nodeclass) {
1593
1590
                                        tot++;
 
1591
                                }
 
1592
                                ntype= ntype->next;
 
1593
                        }
1594
1594
                }
1595
1595
        }       
1596
1596
        if(tot==0) {
1612
1612
                }
1613
1613
        }
1614
1614
        else {
1615
 
                for(a=0, typedefs= ntree->alltypes; *typedefs; typedefs++) {
1616
 
                        if( (*typedefs)->nclass == nodeclass ) {
1617
 
                                addmenu[a].name= (*typedefs)->name;
1618
 
                                addmenu[a].retval= (*typedefs)->type;
 
1615
                bNodeType *ntype= ntree->alltypes.first;
 
1616
                for(a=0; ntype; ntype= ntype->next) {
 
1617
                        if( ntype->nclass == nodeclass ) {
 
1618
                                addmenu[a].name= ntype->name;
 
1619
                                addmenu[a].retval= ntype->type;
1619
1620
                                a++;
1620
1621
                        }
1621
1622
                }
1622
1623
        }
1623
 
 
 
1624
        
1624
1625
        addmenu[a].icon= -1;    /* end signal */
1625
1626
        addmenu[a].name= "";
1626
1627
        addmenu[a].retval= a;
1711
1712
        if(U.uiflag & USER_PLAINMENUS)
1712
1713
                uiBlockSetDirection(block, UI_RIGHT);
1713
1714
        else
1714
 
                uiBlockSetDirection(block, UI_RIGHT|UI_CENTRE);
 
1715
                uiBlockSetDirection(block, UI_RIGHT|UI_CENTER);
1715
1716
 
1716
1717
        return block;
1717
1718
}
1719
1720
static int tb_mainx= 1234, tb_mainy= 0;
1720
1721
static void store_main(void *arg1, void *arg2)
1721
1722
{
1722
 
        tb_mainx= (int)arg1;
1723
 
        tb_mainy= (int)arg2;
 
1723
        tb_mainx= (long)arg1;
 
1724
        tb_mainy= (long)arg2;
1724
1725
}
1725
1726
 
1726
1727
static void do_group_addmenu(void *arg, int event)
1875
1876
        return groupmenu;
1876
1877
}
1877
1878
 
 
1879
static TBitem *create_mesh_sublevel(ListBase *storage)
 
1880
{
 
1881
        Link *link;
 
1882
        TBitem *meshmenu, *mm;
 
1883
        int totmenu= 10, totpymenu=0, a=0;
 
1884
        
 
1885
        /* Python Menu */
 
1886
        BPyMenu *pym;
 
1887
        
 
1888
        /* count the python menu items*/
 
1889
        for (pym = BPyMenuTable[PYMENU_ADDMESH]; pym; pym = pym->next, totpymenu++) {}
 
1890
        if (totpymenu) totmenu += totpymenu+1; /* add 1 for the seperator */
 
1891
        
 
1892
        link= MEM_callocN(sizeof(Link) + sizeof(TBitem)*(totmenu+1), "mesh menu");
 
1893
        BLI_addtail(storage, link);
 
1894
        mm= meshmenu= (TBitem *)(link+1);
 
1895
        
 
1896
        mm->icon = 0; mm->retval= a; mm->name = "Plane";                mm++; a++;
 
1897
        mm->icon = 0; mm->retval= a; mm->name = "Cube";                 mm++; a++;
 
1898
        mm->icon = 0; mm->retval= a; mm->name = "Circle";               mm++; a++;
 
1899
        mm->icon = 0; mm->retval= a; mm->name = "UVsphere";     mm++; a++;
 
1900
        mm->icon = 0; mm->retval= a; mm->name = "Icosphere";    mm++; a++;
 
1901
        mm->icon = 0; mm->retval= a; mm->name = "Cylinder";     mm++; a++; a++;
 
1902
        mm->icon = 0; mm->retval= a; mm->name = "Cone";                 mm++; a++; 
 
1903
        mm->icon = 0; mm->retval= 0; mm->name = "SEPR";                 mm++;
 
1904
        mm->icon = 0; mm->retval= a; mm->name = "Grid";                 mm++; a++;
 
1905
        mm->icon = 0; mm->retval= a; mm->name = "Monkey";               mm++; a++;
 
1906
        /* a == 10 */
 
1907
        
 
1908
        if (totpymenu) {
 
1909
                int i=0;
 
1910
                mm->icon = 0; mm->retval= 0; mm->name = "SEPR";         mm++;
 
1911
                
 
1912
                /* note that we account for the 10 previous entries with i+4: */
 
1913
                for (pym = BPyMenuTable[PYMENU_ADDMESH]; pym; pym = pym->next, i++) {
 
1914
                        mm->icon = 0;
 
1915
                        mm->retval= i+20;
 
1916
                        mm->name = pym->name;   
 
1917
                        mm++; a++;
 
1918
                }
 
1919
        }
 
1920
        
 
1921
        /* terminate the menu */
 
1922
        mm->icon= -1; mm->retval= a; mm->name= ""; mm->poin= do_info_add_meshmenu;
 
1923
        
 
1924
        return meshmenu;
 
1925
}
 
1926
 
 
1927
 
1878
1928
 
1879
1929
void toolbox_n(void)
1880
1930
{
1910
1960
 
1911
1961
                /* dynamic menu entries */
1912
1962
                tb_add[TB_ADD_GROUP].poin= create_group_all_sublevels(&storage);
 
1963
                tb_add[TB_ADD_MESH].poin= create_mesh_sublevel(&storage);
1913
1964
                
1914
1965
                /* static */
1915
1966
                if (G.scene->r.renderer==R_YAFRAY)
1945
1996
                        if(U.uiflag & USER_PLAINMENUS) {
1946
1997
                                switch(G.obedit->type){
1947
1998
                                case OB_MESH:
1948
 
                                        menu1= addmenu_mesh;
 
1999
                                        menu1= create_mesh_sublevel(&storage);
1949
2000
                                        menu2= tb_mesh_edit;
1950
2001
                                        menu3= tb_mesh_select;
1951
2002
                                        menu4= tb_transform_editmode1;
1990
2041
                        } else {
1991
2042
                                if(G.obedit->type==OB_MESH) {
1992
2043
                                        menu1= tb_mesh; str1= "Mesh";
1993
 
                                        menu2= addmenu_mesh; 
 
2044
                                        menu2= create_mesh_sublevel(&storage); 
1994
2045
                                        menu3= tb_mesh_select;
1995
2046
                                        menu4= tb_mesh_edit; 
1996
2047
                                        menu5= tb_transform_editmode1;
2091
2142
        
2092
2143
                but=uiDefBlockBut(block, tb_makemenu, menu1, str1,      mval[0]-(1.5*dx)+tb_mainx,mval[1]+tb_mainy, dx, 19, "");
2093
2144
                uiButSetFlag(but, UI_MAKE_TOP|UI_MAKE_RIGHT);
2094
 
                uiButSetFunc(but, store_main, (void *)dx, (void *)-5);
 
2145
                uiButSetFunc(but, store_main, (void *)(long)dx, (void *)(long)-5);
2095
2146
 
2096
2147
                but=uiDefBlockBut(block, tb_makemenu, menu2, str2,      mval[0]-(0.5*dx)+tb_mainx,mval[1]+tb_mainy, dx, 19, "");
2097
2148
                uiButSetFlag(but, UI_MAKE_TOP);
2098
 
                uiButSetFunc(but, store_main, (void *)0, (void *)-5);
 
2149
                uiButSetFunc(but, store_main, (void *)(long)0, (void *)(long)-5);
2099
2150
 
2100
2151
                but=uiDefBlockBut(block, tb_makemenu, menu3, str3,      mval[0]+(0.5*dx)+tb_mainx,mval[1]+tb_mainy, dx, 19, "");
2101
2152
                uiButSetFlag(but, UI_MAKE_TOP|UI_MAKE_LEFT);
2102
 
                uiButSetFunc(but, store_main, (void *)-dx, (void *)-5);
 
2153
                uiButSetFunc(but, store_main, (void *)(long)-dx, (void *)(long)-5);
2103
2154
 
2104
2155
                but=uiDefBlockBut(block, tb_makemenu, menu4, str4,      mval[0]-(1.5*dx)+tb_mainx,mval[1]+tb_mainy-20, dx, 19, "");
2105
2156
                uiButSetFlag(but, UI_MAKE_DOWN|UI_MAKE_RIGHT);
2106
 
                uiButSetFunc(but, store_main, (void *)dx, (void *)5);
 
2157
                uiButSetFunc(but, store_main, (void *)(long)dx, (void *)(long)5);
2107
2158
 
2108
2159
                but=uiDefBlockBut(block, tb_makemenu, menu5, str5,      mval[0]-(0.5*dx)+tb_mainx,mval[1]+tb_mainy-20, dx, 19, "");
2109
2160
                uiButSetFlag(but, UI_MAKE_DOWN);
2110
 
                uiButSetFunc(but, store_main, (void *)0, (void *)5);
 
2161
                uiButSetFunc(but, store_main, (void *)(long)0, (void *)(long)5);
2111
2162
 
2112
2163
                but=uiDefBlockBut(block, tb_makemenu, menu6, str6,      mval[0]+(0.5*dx)+tb_mainx,mval[1]+tb_mainy-20, dx, 19, "");
2113
2164
                uiButSetFlag(but, UI_MAKE_DOWN|UI_MAKE_LEFT);
2114
 
                uiButSetFunc(but, store_main, (void *)-dx, (void *)5);
 
2165
                uiButSetFunc(but, store_main, (void *)(long)-dx, (void *)(long)5);
2115
2166
        } else if (tot==5 || tot==7) {
2116
2167
                /* check if it fits, dubious */
2117
2168
                if(mval[0]-0.25*dx+tb_mainx < 6) mval[0]= 6 + 0.25*dx -tb_mainx;