Matt's lamp submenu.
authorMartin Poirier <theeth@yahoo.com>
Sun, 19 Sep 2004 19:27:57 +0000 (19:27 +0000)
committerMartin Poirier <theeth@yahoo.com>
Sun, 19 Sep 2004 19:27:57 +0000 (19:27 +0000)
And reorganized the #includes in editobject by "modules"

source/blender/include/BDR_editobject.h
source/blender/include/BSE_headerbuttons.h
source/blender/src/editobject.c
source/blender/src/header_info.c
source/blender/src/toolbox.c

index 6feee2d8a88dea5979a7ec7ccf038be7cd671d1b..6e5c3e9872013cddd9d4bd673125a62b9dc622e5 100644 (file)
@@ -41,6 +41,7 @@ struct Material;
 struct Base;
 
 void add_object_draw(int type);
+void add_objectLamp(short type);
 void free_and_unlink_base(struct Base *base);
 void delete_obj(int ok);
 void make_track(void);
index c80b84f67ac393ec2e8c94c1e50c647caaae10a0..b843fde530782ada95f8a7f747490866677f0fd7 100644 (file)
@@ -113,6 +113,7 @@ void do_info_add_meshmenu(void *arg, int event);
 void do_info_add_curvemenu(void *arg, int event);
 void do_info_add_surfacemenu(void *arg, int event);
 void do_info_add_metamenu(void *arg, int event);
+void do_info_add_lampmenu(void *arg, int event);
 void do_info_addmenu(void *arg, int event);
 
 /* header_view3d.c */
index 431f997411e03742cfd03bd72b52252837344acc..02db911e1aa9bc85d6100a3c5a32aa1a2f6e3d0d 100644 (file)
@@ -57,6 +57,8 @@
 
 #include "IMB_imbuf_types.h"
 
+#include "DNA_action_types.h"
+#include "DNA_armature_types.h"
 #include "DNA_camera_types.h"
 #include "DNA_curve_types.h"
 #include "DNA_effect_types.h"
 #include "BLI_editVert.h"
 #include "BLI_ghash.h"
 
+#include "BKE_constraint.h"
+#include "BKE_action.h"
+#include "BKE_armature.h"
+#include "BKE_utildefines.h"
 #include "BKE_anim.h"
 #include "BKE_blender.h"
 #include "BKE_booleanops.h"
 #include "BIF_space.h"
 #include "BIF_toets.h"
 #include "BIF_butspace.h"
+#include "BIF_editconstraint.h"
 #include "BIF_editdeform.h"
 #include "BIF_editfont.h"
 #include "BIF_editika.h"
 
 #include "blendef.h"
 
-#include "BKE_constraint.h"
-#include "BIF_editconstraint.h"
-
-#include "BKE_action.h"
-#include "DNA_action_types.h"
-#include "BKE_armature.h"
-#include "DNA_armature_types.h"
 #include "BIF_poseobject.h"
 
 /*  extern Lattice *copy_lattice(Lattice *lt); */
@@ -208,7 +208,24 @@ void add_object_draw(int type)     /* for toolbox */
        deselect_all_area_oops();
        set_select_flag_oops();
        allqueue(REDRAWINFO, 1);        /* 1, because header->win==0! */
+}
+
+void add_objectLamp(short type)
+{
+       Lamp *la;
 
+       /* this function also comes from an info window */
+       if ELEM(curarea->spacetype, SPACE_VIEW3D, SPACE_INFO); else return;
+       
+       if(G.obedit==0) {
+               add_object_draw(OB_LAMP);
+               base_init_from_view3d(BASACT, G.vd);
+       }
+       
+       la = BASACT->object->data;
+       la->type = type;        
+
+       allqueue(REDRAWALL, 0);
 }
 
 void free_and_unlink_base(Base *base)
@@ -4882,8 +4899,6 @@ static char *transform_mode_to_string(int mode)
 't'            -> Tilt
 'w'            -> Warp
 'N'            -> Shrink/Fatten
-'V'            -> Snap vertice
-'e'     -> Edge crease edit
 */
 void transform(int mode)
 {
@@ -8015,5 +8030,4 @@ void mirrormenu(void){
                BIF_undo_push("Mirror");
 
        }
-}
-
+}
\ No newline at end of file
index 788c67891ef451673beb48ebacab57a94c5a0cd3..76fdbae52f0c21ac515b11504ebb41759afd0836 100644 (file)
@@ -1203,6 +1203,58 @@ static uiBlock *info_add_metamenu(void *arg_unused)
        return block;
 }
 
+void do_info_add_lampmenu(void *arg, int event)
+{
+
+       switch(event) {         
+               case 0: /* lamp */
+                       add_objectLamp(LA_LOCAL);
+                       break;
+               case 1: /* sun */
+                       add_objectLamp(LA_SUN);
+                       break;
+               case 2: /* spot */
+                       add_objectLamp(LA_SPOT);
+                       break;
+               case 3: /* hemi */
+                       add_objectLamp(LA_HEMI);
+                       break;
+               case 4: /* area */
+                       add_objectLamp(LA_AREA);
+                       break;
+               case 5: /* YafRay photon lamp */
+                       if (G.scene->r.renderer==R_YAFRAY)
+                               add_objectLamp(LA_YF_PHOTON);
+                       break;
+               default:
+                       break;
+       }
+       allqueue(REDRAWINFO, 0);
+}
+
+static uiBlock *info_add_lampmenu(void *arg_unused)
+{
+/*             static short tog=0; */
+       uiBlock *block;
+       short yco= 0;
+       
+       block= uiNewBlock(&curarea->uiblocks, "add_lampmenu", UI_EMBOSSP, UI_HELV, G.curscreen->mainwin);
+       uiBlockSetButmFunc(block, do_info_add_lampmenu, NULL);
+       
+       uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Lamp|",                          0, yco-=20, 160, 19, NULL, 0.0, 0.0, 1, 0, "");
+       uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Sun|",                           0, yco-=20, 160, 19, NULL, 0.0, 0.0, 1, 1, "");
+       uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Spot|",                          0, yco-=20, 160, 19, NULL, 0.0, 0.0, 1, 2, "");
+       uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Hemi|",                          0, yco-=20, 160, 19, NULL, 0.0, 0.0, 1, 3, "");
+       uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Area|",                          0, yco-=20, 160, 19, NULL, 0.0, 0.0, 1, 4, "");
+       if (G.scene->r.renderer==R_YAFRAY)
+               uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Photon|",                                0, yco-=20, 160, 19, NULL, 0.0, 0.0, 1, 5, "");
+       
+       uiBlockSetDirection(block, UI_RIGHT);
+       uiTextBoundsBlock(block, 50);
+               
+       return block;
+}
+
 void do_info_addmenu(void *arg, int event)
 {
        switch(event) {         
@@ -1232,7 +1284,7 @@ void do_info_addmenu(void *arg, int event)
                        break;
                case 7:
                        /* Lamp */
-                       add_object_draw(OB_LAMP);
+               //      add_object_draw(OB_LAMP);
                        break;
                case 8:
                        /* Armature */
@@ -1264,10 +1316,15 @@ static uiBlock *info_addmenu(void *arg_unused)
        uiDefIconTextBlockBut(block, info_add_metamenu, NULL, ICON_RIGHTARROW_THIN, "Meta", 0, yco-=20, 120, 19, "");
        uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Text",                           0, yco-=20, 120, 19, NULL, 0.0, 0.0, 1, 4, "");
        uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Empty",                          0, yco-=20, 120, 19, NULL, 0.0, 0.0, 1, 5, "");
+       
        uiDefBut(block, SEPR, 0, "",                                    0, yco-=6, 120, 6, NULL, 0.0, 0.0, 0, 0, "");
+       
        uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Camera",                         0, yco-=20, 120, 19, NULL, 0.0, 0.0, 1, 6, "");
-       uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Lamp",                           0, yco-=20, 120, 19, NULL, 0.0, 0.0, 1, 7, "");
+//     uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Lamp",                           0, yco-=20, 120, 19, NULL, 0.0, 0.0, 1, 7, "");
+       uiDefIconTextBlockBut(block, info_add_lampmenu, NULL, ICON_RIGHTARROW_THIN, "Lamp", 0, yco-=20, 120, 19, "");
+       
        uiDefBut(block, SEPR, 0, "",                                    0, yco-=6, 120, 6, NULL, 0.0, 0.0, 0, 0, "");
+       
        /* armature needs 3d window to draw */
        //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, "");
index 561eade72374bdb67362ecac9a6026b431cba9aa..0a09399b16bd4541c314c3aa47a6b5b8611a08b3 100644 (file)
@@ -212,7 +212,7 @@ void tbox_setinfo(int x, int y)
                                case 9: tbstr= "Save VRML";                     tbstr1= "c|F2";         keystr= "Ctrl F2";      break;
                                case 10: tbstr= "Save DXF";                     tbstr1= "shift+F2";     keystr= "Shift F2";     break;
                                case 11: tbstr= "Save VideoScape";      tbstr1= "a|w";          keystr= "Alt W";        break;
-                               case 12: tbstr= "Save UserPrefs";                                       tbstr1= "c|u";                  keystr= "Ctrl U";                       break;
+                               case 12: tbstr= "Save UserPrefs";       tbstr1= "c|u";          keystr= "Ctrl U";       break;
                                case 13: tbstr= "Quit";                         tbstr1= "q";            keystr= "Q";            break;
                        }
                }
@@ -222,15 +222,15 @@ void tbox_setinfo(int x, int y)
                        switch(y) {
                                case 0: tbstr= "(De)Select All";        tbstr1= "a";    keystr= "A";            break;
                                case 1: tbstr= "Border Select";         tbstr1= "b";    keystr= "B";            break;
-                               case 2: tbstr= "Select Linked";                                 tbstr1= "l";            keystr= "L";                    break;
-                               case 3: tbstr= "Hide Selected";                                 tbstr1= "h";            keystr= "H";                    break;
+                               case 2: tbstr= "Select Linked";         tbstr1= "l";    keystr= "L";            break;
+                               case 3: tbstr= "Hide Selected";         tbstr1= "h";    keystr= "H";            break;
                                case 4: tbstr= "Duplicate";                     tbstr1= "D";    keystr= "Shift D";      break;
                                case 5: tbstr= "Delete";                        tbstr1= "x";    keystr= "X";            break;
                                case 6: tbstr= "Edit Mode";                     tbstr1= "Tab";  keystr= "Tab";          break;
                                case 7: tbstr= "Grabber";                       tbstr1= "g";    keystr= "G";            break;
                                case 8: tbstr= "Rotate";                        tbstr1= "r";    keystr= "R";            break;
                                case 9: tbstr= "Scale";                         tbstr1= "s";    keystr= "S";            break;
-                               case 10: tbstr= "Shrink/Fatten";                                        tbstr1= "a|s";          keystr= "Alt S";                        break;
+                               case 10: tbstr= "Shrink/Fatten";        tbstr1= "a|s";  keystr= "Alt S";        break;
                                case 11: tbstr= "Shear";                        tbstr1= "c|s";  keystr= "Ctrl S";       break;
                                case 12: tbstr= "Warp/Bend";            tbstr1= "W";    keystr= "Shift W";      break;
                                case 13: tbstr= "Snap Menu";            tbstr1= "S";    keystr= "Shift S";      break;
@@ -243,11 +243,10 @@ void tbox_setinfo(int x, int y)
                        if(addmode==0) {
                                switch(y) {
                                        case 0: tbstr= "Mesh";          tbstr1= ">>";   keystr= ">>";   tbval=OB_MESH;                                                                          break;
-                                       case 1: tbstr= "Curve";         tbstr1= ">>";   keystr= ">>";   tbval=OB_CURVE; ;                                                                       break;
+                                       case 1: tbstr= "Curve";         tbstr1= ">>";   keystr= ">>";   tbval=OB_CURVE;                                                                         break;
                                        case 2: tbstr= "Surface";       tbstr1= ">>";   keystr= ">>";   tbval=OB_SURF;                                                                          break;
-                                       case 3: tbstr= "Meta";          tbstr1= ">>";   keystr= ">>";   tbval=OB_MBALL;
-                                               break;
-                                       case 4: tbstr= "Text";          tbstr1= "";             keystr= "";             tbval=OB_FONT;          tbfunc= add_primitiveFont;              break;
+                                       case 3: tbstr= "Meta";          tbstr1= ">>";   keystr= ">>";   tbval=OB_MBALL;                                                                         break;
+                                       case 4: tbstr= "Text";          tbstr1= "";             keystr= "";             tbval=OB_FONT;  tbfunc= add_primitiveFont;                      break;
                                        case 5: tbstr= "Empty";         tbstr1= "A";    keystr= "";             tbval=OB_EMPTY;                                                                         break;
                                        case 6: tbstr= "";                      tbstr1= "";             keystr= "";             tbval=0;                                                                                        break;
                                        case 7: tbstr= "Camera";        tbstr1= "A";    keystr= "";             tbval=OB_CAMERA;                                                                        break;
@@ -258,7 +257,7 @@ void tbox_setinfo(int x, int y)
                                        case 12: tbstr= "";                     tbstr1= "";             keystr= "";             tbval=0;                                                                                        break;
                                        case 13: tbstr= "";                     tbstr1= "";             keystr= "";             tbval=0;                                                                                        break;
                                }
-                               if(tbstr1 && tbstr1[0]=='A') tbfunc= (void (*)(int) )add_object_draw;
+                               if(tbstr1 && tbstr1[0]=='A') tbfunc= (void (*)(int))add_object_draw;
                        }
                        else if(addmode==OB_MESH) {             
                                switch(y) {
@@ -341,7 +340,7 @@ void tbox_setinfo(int x, int y)
 */
                                case 7: tbstr= "Make Track";            tbstr1= "c|t";  keystr= "Ctrl T";       break;
                                case 8: tbstr= "Clear Track";           tbstr1= "a|t";  keystr= "Alt T";        break;
-/*                             case 9: tbstr= "";                                      tbstr1= "";             keystr= "";                     break; */
+/*                             case 9: tbstr= "";                                      tbstr1= "";             keystr= "";                     break; */
                                case 10: tbstr= "Image Displist";       tbstr1= "c|d";  keystr= "Ctrl D";       break;
                                case 11: tbstr= "Image Aspect";         tbstr1= "a|v";  keystr= "Alt V";        break;
                                case 12: tbstr= "Vect Paint";           tbstr1= "v";    keystr= "V";    break;
@@ -423,11 +422,11 @@ void tbox_setinfo(int x, int y)
 /* SEQUENCER TOPICS */
                 else if(tbmain==TBOX_MAIN_SEQ) {
                         switch(y) {
-                                case 0: tbstr= "Add Strip"; tbstr1= "A";  keystr= "Shift A";          break;
-                                case 1: tbstr= "Change Str"; tbstr1= "c";  keystr= "C";          break;
-                                case 2: tbstr= "Delete Str";                              tbstr1= "x";             keystr= "X";                     break;
-                                case 3: tbstr= "Make Meta";    tbstr1= "m";    keystr= "M";      break;
-                                case 4: tbstr= "Str Params";    tbstr1= "n";    keystr= "N";            break;
+                                case 0: tbstr= "Add Strip";  tbstr1= "A"; keystr= "Shift A"; break;
+                                case 1: tbstr= "Change Str"; tbstr1= "c"; keystr= "C";       break;
+                                case 2: tbstr= "Delete Str"; tbstr1= "x"; keystr= "X";       break;
+                                case 3: tbstr= "Make Meta";  tbstr1= "m"; keystr= "M";       break;
+                                case 4: tbstr= "Str Params"; tbstr1= "n"; keystr= "N";       break;
                         }
                 }
 
@@ -1119,8 +1118,7 @@ short button(short *var, short min, short max, char *str)
        if(mval[1]>G.curscreen->sizey) mval[1]= G.curscreen->sizey-10;
 
        block= uiNewBlock(&listb, "button", UI_EMBOSS, UI_HELV, G.curscreen->mainwin);
-       uiBlockSetFlag(block, UI_BLOCK_LOOP|UI_BLOCK_REDRAW|UI_BLOCK_RET_1|
-                                  UI_BLOCK_ENTER_OK);
+       uiBlockSetFlag(block, UI_BLOCK_LOOP|UI_BLOCK_REDRAW|UI_BLOCK_RET_1|UI_BLOCK_ENTER_OK);
 
        x1=mval[0]-150; 
        y1=mval[1]-20; 
@@ -1169,7 +1167,8 @@ short sbutton(char *var, float min, float max, char *str)
        return 0;
 }
 
-short fbutton(float *var, float min, float max, float a1, float a2, char *str)
+short fbutton(float *var, float min, float max, float a1, float a2, 
+char *str)
 {
        uiBlock *block;
        ListBase listb={0, 0};
@@ -1317,7 +1316,8 @@ int do_clever_numbuts(char *name, int tot, int winevent)
        uiBlockSetFlag(block, UI_BLOCK_LOOP|UI_BLOCK_REDRAW|UI_BLOCK_RET_1|UI_BLOCK_ENTER_OK);
        
        /* WATCH IT: TEX BUTTON EXCEPTION */
-       /* WARNING: ONLY A SINGLE BIT-BUTTON POSSIBLE: WE WORK AT COPIED DATA! */
+       /* WARNING: ONLY A SINGLE BIT-BUTTON POSSIBLE: WE WORK AT COPIED DATA! 
+*/
 
        uiDefBut(block, LABEL, 0, name, (short)(x1+15), (short)(y2-35), (short)(sizex-60), 19, 0, 1.0, 0.0, 0, 0, ""); 
 
@@ -1332,7 +1332,7 @@ int do_clever_numbuts(char *name, int tot, int winevent)
                        uiDefBut(block, TEX, 0, varstr->name,(short)(x1+15),(short)(y2-55-20*a),(short)(sizex-60), 19, numbpoin[a], varstr->min, varstr->max, 0, 0, varstr->tip);
                }
                else  {
-                       uiDefBut(block, varstr->type, 0,        varstr->name,(short)(x1+15),(short)(y2-55-20*a), (short)(sizex-60), 19, &(numbdata[a]), varstr->min, varstr->max, 100, 0, varstr->tip);
+                       uiDefBut(block, varstr->type, 0, varstr->name,(short)(x1+15),(short)(y2-55-20*a), (short)(sizex-60), 19, &(numbdata[a]), varstr->min, varstr->max, 100, 0, varstr->tip);
                }
        }
 
@@ -1869,7 +1869,8 @@ static TBitem tb_view_dt[]= {
 
 static TBitem tb_view_alignview[]= {
 {      0, "Centre View to Cursor|C",           'c', NULL},
-{      0, "Align Active Camera to View|Shift NumPad 0",                TB_SHIFT|TB_PAD|'0', NULL},
+{      0, "Align Active Camera to View|Shift NumPad 0",                
+TB_SHIFT|TB_PAD|'0', NULL},
 {      0, "Align View to Selected|NumPad *",           TB_PAD|'*', NULL},
 {  -1, "",                     0, tb_do_hotkey}};
 
@@ -2101,11 +2102,28 @@ static TBitem addmenu_meta[]= {
 {      0, "Meta Cube",         4, NULL},
 {  -1, "",                     0, do_info_add_metamenu}};
 
+static TBitem addmenu_lamp[]= {
+{      0, "Lamp",      0, NULL},
+{      0, "Sun",       1, NULL},
+{      0, "Spot",      2, NULL},
+{      0, "Hemi", 3, NULL},
+{      0, "Area",      4, NULL},
+{  -1, "",                     0, do_info_add_lampmenu}};
+
+static TBitem addmenu_YF_lamp[]= {
+{      0, "Lamp",      0, NULL},
+{      0, "Sun",       1, NULL},
+{      0, "Spot",      2, NULL},
+{      0, "Hemi", 3, NULL},
+{      0, "Area",      4, NULL},
+{      0, "Photon",    5, NULL},
+{  -1, "",                     0, do_info_add_lampmenu}};
+
+
 static TBitem addmenu_armature[]= {
 {      0, "Bones",     8, NULL},
 {  -1, "",                     0, do_info_addmenu}};
 
-
 static TBitem tb_add[]= {
 {      0, "Mesh",              0, addmenu_mesh},
 {      0, "Curve",     1, addmenu_curve},
@@ -2115,7 +2133,22 @@ static TBitem tb_add[]= {
 {      0, "Empty",     5, NULL},
 {      0, "SEPR",              0, NULL},
 {      0, "Camera",    6, NULL},
-{      0, "Lamp",              7, NULL},
+{      0, "Lamp",              7, addmenu_lamp},
+{      0, "SEPR",              0, NULL},
+{      0, "Armature",  8, NULL},
+{      0, "Lattice",   9, NULL},
+{  -1, "",                     0, do_info_addmenu}};
+
+static TBitem tb_add_YF[]= {
+{      0, "Mesh",              0, addmenu_mesh},
+{      0, "Curve",     1, addmenu_curve},
+{      0, "Surface",   2, addmenu_surf},
+{      0, "Meta",      3, addmenu_meta},
+{      0, "Text",              4, NULL},
+{      0, "Empty",     5, NULL},
+{      0, "SEPR",              0, NULL},
+{      0, "Camera",    6, NULL},
+{      0, "Lamp",              7, addmenu_YF_lamp},
 {      0, "SEPR",              0, NULL},
 {      0, "Armature",  8, NULL},
 {      0, "Lattice",   9, NULL},
@@ -2200,7 +2233,11 @@ void toolbox_n(void)
        if(curarea->spacetype==SPACE_VIEW3D) {
                /* standard menu */
                menu1= tb_object; str1= "Object";
-               menu2= tb_add; str2= "Add";
+               if (G.scene->r.renderer==R_YAFRAY) {
+                       menu2= tb_add_YF; str2= "Add";
+               } else {
+                       menu2= tb_add; str2= "Add";
+               }
                menu3= tb_object_select; str3= "Select";
                menu4= tb_object_edit; str4= "Edit";
                menu5= tb_transform; str5= "Transform";
@@ -2306,5 +2343,4 @@ void toolbox_n_add(void)
        tb_mainx= 0;
        tb_mainy= -5;
        toolbox_n();
-}
-
+}
\ No newline at end of file