4 * ***** BEGIN GPL 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.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software Foundation,
18 * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20 * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
21 * All rights reserved.
23 * The Original Code is: all of this file.
25 * Contributor(s): none yet.
27 * ***** END GPL LICENSE BLOCK *****
34 #include <sys/types.h>
40 #include "MEM_guardedalloc.h"
43 #include "BIF_language.h"
48 #include "BLI_blenlib.h"
49 #include "BLI_arithb.h"
50 #include "BLI_storage_types.h"
52 #include "IMB_imbuf_types.h"
53 #include "IMB_imbuf.h"
56 #include "DNA_action_types.h"
57 #include "DNA_armature_types.h"
58 #include "DNA_brush_types.h"
59 #include "DNA_camera_types.h"
60 #include "DNA_curve_types.h"
61 #include "DNA_group_types.h"
62 #include "DNA_image_types.h"
63 #include "DNA_ipo_types.h"
64 #include "DNA_key_types.h"
65 #include "DNA_lamp_types.h"
66 #include "DNA_lattice_types.h"
67 #include "DNA_material_types.h"
68 #include "DNA_mesh_types.h"
69 #include "DNA_meta_types.h"
70 #include "DNA_object_types.h"
71 #include "DNA_oops_types.h"
72 #include "DNA_packedFile_types.h"
73 #include "DNA_scene_types.h"
74 #include "DNA_screen_types.h"
75 #include "DNA_sequence_types.h"
76 #include "DNA_sound_types.h"
77 #include "DNA_space_types.h"
78 #include "DNA_texture_types.h"
79 #include "DNA_text_types.h"
80 #include "DNA_userdef_types.h"
81 #include "DNA_view2d_types.h"
82 #include "DNA_view3d_types.h"
83 #include "DNA_world_types.h"
84 #include "DNA_constraint_types.h"
86 #include "BKE_utildefines.h"
88 #include "BKE_action.h"
89 #include "BKE_armature.h"
90 #include "BKE_blender.h"
91 #include "BKE_brush.h"
92 #include "BKE_constraint.h"
93 #include "BKE_curve.h"
94 #include "BKE_depsgraph.h"
95 #include "BKE_exotic.h"
96 #include "BKE_global.h"
97 #include "BKE_image.h"
100 #include "BKE_lattice.h"
101 #include "BKE_library.h"
102 #include "BKE_main.h"
103 #include "BKE_material.h"
104 #include "BKE_mball.h"
105 #include "BKE_mesh.h"
106 #include "BKE_node.h"
107 #include "BKE_object.h"
108 #include "BKE_packedFile.h"
110 #include "BKE_scene.h"
111 #include "BKE_texture.h"
112 #include "BKE_text.h"
113 #include "BKE_world.h"
115 #include "BLO_readfile.h"
116 #include "BLO_writefile.h"
118 #include "BIF_drawimage.h"
119 #include "BIF_drawoops.h"
120 #include "BIF_drawscene.h"
121 #include "BIF_drawtext.h"
122 #include "BIF_editaction.h"
123 #include "BIF_editarmature.h"
124 #include "BIF_editfont.h"
125 #include "BIF_editlattice.h"
126 #include "BIF_editconstraint.h"
127 #include "BIF_editmesh.h"
128 #include "BIF_editmesh.h"
129 #include "BIF_editsima.h"
130 #include "BIF_editsound.h"
132 #include "BIF_imasel.h"
133 #include "BIF_interface.h"
134 #include "BIF_mainqueue.h"
135 #include "BIF_mywindow.h"
136 #include "BIF_poseobject.h"
137 #include "BIF_renderwin.h"
138 #include "BIF_resources.h"
139 #include "BIF_screen.h"
140 #include "BIF_space.h"
141 #include "BIF_toets.h"
142 #include "BIF_toolbox.h"
143 #include "BIF_usiblender.h"
144 #include "BIF_previewrender.h"
145 #include "BIF_writeimage.h"
146 #include "BIF_butspace.h"
148 #include "BSE_edit.h"
149 #include "BSE_filesel.h"
150 #include "BSE_headerbuttons.h"
151 #include "BSE_node.h"
152 #include "BSE_view.h"
153 #include "BSE_sequence.h"
154 #include "BSE_editipo.h"
155 #include "BSE_drawipo.h"
157 #include "BDR_vpaint.h"
158 #include "BDR_editface.h"
159 #include "BDR_editobject.h"
160 #include "BDR_editcurve.h"
161 #include "BDR_editmball.h"
162 #include "BDR_sculptmode.h"
164 #ifndef DISABLE_PYTHON
165 #include "BPY_extern.h"
166 #include "BPY_menus.h"
169 #include "GPU_draw.h"
171 #include "mydevice.h"
173 #include "interface.h"
174 #include "nla.h" /* __NLA : To be removed later */
175 #include "butspace.h" // test_idbutton
177 #include "BIF_poseobject.h"
179 #include "SYS_System.h"
181 /* WATCH IT: always give all headerbuttons for same window the same name
182 * event B_REDR is a standard redraw
186 char *windowtype_pup(void)
189 "Window type:%t" //14
194 "|Ipo Curve Editor %x2" //54
195 "|Action Editor %x12" //73
196 "|NLA Editor %x13" //94
200 "|UV/Image Editor %x6" //117
202 "|Video Sequence Editor %x8" //143
203 "|Timeline %x15" //163
204 "|Audio Window %x11" //163
205 "|Text Editor %x9" //179
210 "|User Preferences %x7" //213
211 "|Outliner %x3" //232
212 "|Buttons Window %x4" //251
216 "|Image Browser %x10" //273
217 "|File Browser %x5" //290
221 "|Scripts Window %x14"//313
225 int GetButStringLength(char *str) {
228 rt= BIF_GetStringWidth(G.font, str, (U.transopts & USER_TR_BUTTONS));
233 /* ********************** GLOBAL ****************************** */
235 int std_libbuttons(uiBlock *block, short xco, short yco,
236 int pin, short *pinpoin, int browse, short id_code, short special, ID *id,
237 ID *parid, short *menupoin, int users, int lib,
238 int del, int autobut, int keepbut)
242 int len, oldcol, add_addbutton=0;
243 char *str=NULL, str1[10];
245 uiBlockBeginAlign(block);
246 oldcol= uiBlockGetCol(block);
249 uiDefIconButS(block, ICONTOG, pin, ICON_PIN_DEHLT, xco,yco,XIC,YIC, pinpoin, 0, 0, 0, 0, "Keeps this view displaying the current data regardless of what object is selected");
254 char *extrastr= NULL;
256 if(ELEM4(id_code, ID_MA, ID_TE, ID_BR, ID_PA)) add_addbutton= 1;
258 lb= wich_libbase(G.main, id_code);
260 if(id && id->us>1) uiBlockSetCol(block, TH_BUT_SETTING1);
262 if (pin && *pinpoin) {
263 uiBlockSetCol(block, TH_BUT_SETTING2);
266 if (ELEM8( id_code, ID_SCE, ID_SCR, ID_MA, ID_TE, ID_WO, ID_IP, ID_AC, ID_BR) || id_code == ID_PA) extrastr= "ADD NEW %x 32767";
267 else if (id_code==ID_TXT) extrastr= "OPEN NEW %x 32766 |ADD NEW %x 32767";
268 else if (id_code==ID_SO) extrastr= "OPEN NEW %x 32766";
270 uiSetButLock(G.scene->id.lib!=0, ERROR_LIBDATA_MESSAGE);
271 if( id_code==ID_SCE || id_code==ID_SCR ) uiClearButLock();
273 if(curarea->spacetype==SPACE_BUTS)
274 uiSetButLock(id_code!=ID_SCR && G.obedit!=0 && G.buts->mainb==CONTEXT_EDITING, "Cannot perform in EditMode");
276 if(parid) uiSetButLock(parid->lib!=0, ERROR_LIBDATA_MESSAGE);
280 IPOnames_to_pupstring(&str, NULL, extrastr, lb, id, menupoin, G.sipo->blocktype);
281 else if(browse!=B_SIMABROWSE && id_code==ID_IM )
282 IMAnames_to_pupstring(&str, NULL, extrastr, lb, id, menupoin);
284 IDnames_to_pupstring(&str, NULL, extrastr, lb, id, menupoin);
287 uiDefButS(block, MENU, browse, str, xco,yco,XIC,YIC, menupoin, 0, 0, 0, 0, "Browses existing choices or adds NEW");
295 uiBlockSetCol(block, oldcol);
297 if(id) { /* text button with name */
300 if(id->us>1) uiBlockSetCol(block, TH_BUT_SETTING1);
302 if (pin && *pinpoin) {
303 uiBlockSetCol(block, TH_BUT_SETTING2);
305 /* Redalert overrides pin color */
306 if(id->us<=0) uiBlockSetCol(block, TH_REDALERT);
308 uiSetButLock(id->lib!=0, ERROR_LIBDATA_MESSAGE);
310 if(GS(id->name)==ID_SCE) strcpy(str1, "SCE:");
311 else if(GS(id->name)==ID_SCE) strcpy(str1, "SCR:");
312 else if(GS(id->name)==ID_MA) {
313 if( ((Material *)id)->use_nodes )
319 str1[0]= id->name[0];
320 str1[1]= id->name[1];
325 if( GS(id->name)==ID_IP) len= 110;
326 else if((yco) && (GS(id->name)==ID_AC)) len= 100; // comes from button panel (poselib)
327 else if(yco) len= 140; // comes from button panel
330 but= uiDefBut(block, TEX, B_IDNAME, str1,xco, yco, (short)len, YIC, id->name+2, 0.0, 21.0, 0, 0, "Displays current Datablock name. Click to change.");
331 uiButSetFunc(but, test_idbutton_cb, id->name, NULL);
339 if(id->flag & LIB_INDIRECT) uiDefIconBut(block, BUT, 0, ICON_DATALIB,xco,yco,XIC,YIC, 0, 0, 0, 0, 0, "Indirect Library Datablock. Cannot change.");
340 else uiDefIconBut(block, BUT, lib, ICON_PARLIB, xco,yco,XIC,YIC, 0, 0, 0, 0, 0,
341 lib?"Direct linked Library Datablock. Click to make local.":"Direct linked Library Datablock, cannot make local."
348 if(users && id->us>1) {
349 uiSetButLock (pin && *pinpoin, "Can't make pinned data single-user");
351 sprintf(str1, "%d", id->us);
354 uiDefBut(block, BUT, users, str1, xco,yco,XIC,YIC, 0, 0, 0, 0, 0, "Displays number of users of this data. Click to make a single-user copy.");
358 uiDefBut(block, BUT, users, str1, xco, yco, XIC+10, YIC, 0, 0, 0, 0, 0, "Displays number of users of this data. Click to make a single-user copy.");
367 uiSetButLock (pin && *pinpoin, "Can't unlink pinned data");
368 if(parid && parid->lib);
370 uiDefIconBut(block, BUT, del, ICON_X, xco,yco,XIC,YIC, 0, 0, 0, 0, 0, "Deletes link to this Datablock");
378 if(parid && parid->lib);
380 uiDefIconBut(block, BUT, autobut, ICON_AUTO,xco,yco,XIC,YIC, 0, 0, 0, 0, 0, "Generates an automatic name");
387 uiDefButBitS(block, TOG, LIB_FAKEUSER, keepbut, "F", xco,yco,XIC,YIC, &id->flag, 0, 0, 0, 0, "Saves this datablock even if it has no users");
391 else if(add_addbutton) { /* "add new" button */
392 uiBlockSetCol(block, oldcol);
393 if(parid) uiSetButLock(parid->lib!=0, ERROR_LIBDATA_MESSAGE);
394 uiDefButS(block, TOG, browse, "Add New" ,xco, yco, 110, YIC, menupoin, (float)*menupoin, 32767.0, 0, 0, "Add new data block");
399 uiBlockSetCol(block, oldcol);
400 uiBlockEndAlign(block);
406 /* results in fully updated anim system */
407 static void do_update_for_newframe(int mute, int events)
409 extern void audiostream_scrub(unsigned int frame); /* seqaudio.c */
412 allqueue(REDRAWALL, 0);
415 /* this function applies the changes too */
416 scene_update_for_newframe(G.scene, screen_view3d_layers()); /* BKE_scene.h */
418 if ( (CFRA>1) && (!mute) && (G.scene->audio.flag & AUDIO_SCRUB))
419 audiostream_scrub( CFRA );
421 /* 3d window, preview */
422 BIF_view3d_previewrender_signal(curarea, PR_DBASE|PR_DISPRECT);
424 /* all movie/sequence images */
425 BIF_image_update_frame();
428 if(G.scene->use_nodes && G.scene->nodetree)
429 ntreeCompositTagAnimated(G.scene->nodetree);
432 void update_for_newframe(void)
434 do_update_for_newframe(0, 1);
437 void update_for_newframe_muted(void)
439 do_update_for_newframe(1, 1);
442 /* used by new animated UI playback */
443 void update_for_newframe_nodraw(int nosound)
445 do_update_for_newframe(nosound, 0);
449 static void show_splash(void)
451 extern char datatoc_splash_jpg[];
452 extern int datatoc_splash_jpg_size;
457 extern char * build_date;
458 extern char * build_time;
459 extern char * build_rev;
460 extern char * build_platform;
461 extern char * build_type;
464 sprintf(string,"Built on %s %s, Rev-%s Version %s %s", build_date, build_time, build_rev, build_platform, build_type);
467 splash((void *)datatoc_splash_jpg, datatoc_splash_jpg_size, string);
471 /* Functions for user preferences fileselect windows */
473 /* yafray: export dir select */
474 static void filesel_u_yfexportdir(char *name)
476 char dir[FILE_MAXDIR], file[FILE_MAXFILE];
478 BLI_cleanup_dir(G.sce, name);
479 BLI_split_dirfile(name, dir, file);
481 strcpy(U.yfexportdir, dir);
482 allqueue(REDRAWALL, 0);
485 static void filesel_u_fontdir(char *name)
487 char dir[FILE_MAXDIR], file[FILE_MAXFILE];
489 BLI_cleanup_dir(G.sce, name);
490 BLI_split_dirfile(name, dir, file);
492 strcpy(U.fontdir, dir);
493 allqueue(REDRAWALL, 0);
496 static void filesel_u_textudir(char *name)
498 char dir[FILE_MAXDIR], file[FILE_MAXFILE];
500 BLI_cleanup_dir(G.sce, name);
501 BLI_split_dirfile(name, dir, file);
503 strcpy(U.textudir, dir);
504 allqueue(REDRAWALL, 0);
507 static void filesel_u_plugtexdir(char *name)
509 char dir[FILE_MAXDIR], file[FILE_MAXFILE];
511 BLI_cleanup_dir(G.sce, name);
512 BLI_split_dirfile(name, dir, file);
514 strcpy(U.plugtexdir, dir);
515 allqueue(REDRAWALL, 0);
518 static void filesel_u_plugseqdir(char *name)
520 char dir[FILE_MAXDIR], file[FILE_MAXFILE];
522 BLI_cleanup_dir(G.sce, name);
523 BLI_split_dirfile(name, dir, file);
525 strcpy(U.plugseqdir, dir);
526 allqueue(REDRAWALL, 0);
529 static void filesel_u_renderdir(char *name)
531 char dir[FILE_MAXDIR], file[FILE_MAXFILE];
533 BLI_cleanup_dir(G.sce, name);
534 BLI_split_dirfile(name, dir, file);
536 strcpy(U.renderdir, dir);
537 allqueue(REDRAWALL, 0);
540 #ifndef DISABLE_PYTHON
541 static void filesel_u_pythondir(char *name)
543 char dir[FILE_MAXDIR], file[FILE_MAXFILE];
545 BLI_cleanup_dir(G.sce, name);
546 BLI_split_dirfile(name, dir, file);
548 strcpy(U.pythondir, dir);
549 allqueue(REDRAWALL, 0);
551 /* act on the change */
552 if (BPY_path_update()==0) {
553 error("Invalid scripts dir: check console");
558 static void filesel_u_sounddir(char *name)
560 char dir[FILE_MAXDIR], file[FILE_MAXFILE];
562 BLI_cleanup_dir(G.sce, name);
563 BLI_split_dirfile(name, dir, file);
565 strcpy(U.sounddir, dir);
566 allqueue(REDRAWALL, 0);
569 static void filesel_u_tempdir(char *name)
571 char dir[FILE_MAXDIR], file[FILE_MAXFILE];
573 BLI_cleanup_dir(G.sce, name);
574 BLI_split_dirfile(name, dir, file);
576 strcpy(U.tempdir, dir);
577 BLI_where_is_temp( btempdir, 1 );
579 allqueue(REDRAWALL, 0);
582 /* END Functions for user preferences fileselect windows */
585 void do_global_buttons(unsigned short event)
595 ID *id, *idtest, *from=NULL;
606 id= NULL; /* id at null for texbrowse */
612 scrarea_queue_winredraw(curarea);
613 scrarea_queue_headredraw(curarea);
615 update_for_newframe();
618 scrarea_queue_winredraw(curarea);
619 scrarea_queue_headredraw(curarea);
622 allqueue(REDRAWVIEW3D, 0);
623 scrarea_queue_winredraw(curarea);
624 scrarea_queue_headredraw(curarea);
628 if(ob->id.lib) return;
632 if(G.buts->menunr== -2) {
633 activate_databrowse((ID *)G.buts->lockpoin, GS(id->name), 0, B_EDITBROWSE, &G.buts->menunr, do_global_buttons);
636 if(G.buts->menunr < 0) return;
638 lb= wich_libbase(G.main, GS(id->name));
641 if(nr==G.buts->menunr) {
648 test_object_materials(idtest);
650 if( GS(idtest->name)==ID_CU ) {
653 else if( ob->type==OB_ARMATURE) {
654 armature_rebuild_pose(ob, ob->data);
656 DAG_object_flush_update(G.scene, ob, OB_RECALC_DATA);
658 allqueue(REDRAWBUTSEDIT, 0);
659 allqueue(REDRAWVIEW3D, 0);
660 allqueue(REDRAWACTION,0);
661 allqueue(REDRAWIPO, 0);
662 allqueue(REDRAWNLA,0);
667 idtest= idtest->next;
673 if(ob->id.lib) return;
676 if(id==0) id= G.main->mesh.first;
679 if(G.buts->menunr== -2) {
680 activate_databrowse((ID *)G.buts->lockpoin, GS(id->name), 0, B_MESHBROWSE, &G.buts->menunr, do_global_buttons);
683 if(G.buts->menunr < 0) return;
686 idtest= G.main->mesh.first;
688 if(nr==G.buts->menunr) {
689 set_mesh(ob, (Mesh *)idtest);
691 DAG_object_flush_update(G.scene, ob, OB_RECALC_DATA);
693 BIF_undo_push("Browse Mesh");
694 allqueue(REDRAWBUTSEDIT, 0);
695 allqueue(REDRAWVIEW3D, 0);
696 allqueue(REDRAWACTION,0);
697 allqueue(REDRAWIPO, 0);
702 idtest= idtest->next;
708 void *lockpoin= NULL;
711 /* this is called now from Node editor too, buttons might not exist */
712 if(curarea->spacetype==SPACE_NODE) {
713 SpaceNode *snode= curarea->spacedata.first;
714 menunr= &snode->menunr;
718 menunr= &G.buts->menunr;
719 lockpoin= G.buts->lockpoin;
724 if(G.qual & LR_CTRLKEY) {
725 activate_databrowse_imasel((ID *)lockpoin, ID_MA, 0, B_MATBROWSE, menunr, do_global_buttons);
728 activate_databrowse((ID *)lockpoin, ID_MA, 0, B_MATBROWSE, menunr, do_global_buttons);
733 if(*menunr < 0) return;
735 if(0) { /* future pin */
740 ma= give_current_material(ob, ob->actcol);
745 idtest= G.main->mat.first;
751 idtest= idtest->next;
753 if(idtest==0) { /* new mat */
754 if(id) idtest= (ID *)copy_material((Material *)id);
756 idtest= (ID *)add_material("Material");
761 assign_material(ob, (Material *)idtest, ob->actcol);
763 BIF_undo_push("Browse Material");
764 allqueue(REDRAWBUTSSHADING, 0);
765 allqueue(REDRAWIPO, 0);
766 allqueue(REDRAWNODE, 0);
767 BIF_preview_changed(ID_MA);
774 if(0) { /* future pin */
778 ma= give_current_material(ob, ob->actcol);
780 assign_material(ob, 0, ob->actcol);
781 BIF_undo_push("Unlink Material");
782 allqueue(REDRAWBUTSSHADING, 0);
783 allqueue(REDRAWIPO, 0);
784 allqueue(REDRAWOOPS, 0);
785 allqueue(REDRAWVIEW3D, 0);
786 BIF_preview_changed(ID_MA);
795 if(G.buts->texfrom==0) { /* from mat */
796 ma= give_current_material(ob, ob->actcol);
797 ma= editnode_get_active_material(ma);
799 mtex= ma->mtex[ ma->texact ];
801 if(mtex->tex) mtex->tex->id.us--;
803 ma->mtex[ ma->texact ]= NULL;
804 allqueue(REDRAWBUTSSHADING, 0);
805 allqueue(REDRAWIPO, 0);
806 BIF_preview_changed(ID_MA);
810 else if(G.buts->texfrom==1) { /* from world */
811 wrld= G.scene->world;
813 mtex= wrld->mtex[ wrld->texact ];
815 if(mtex->tex) mtex->tex->id.us--;
817 wrld->mtex[ wrld->texact ]= NULL;
818 allqueue(REDRAWBUTSSHADING, 0);
819 allqueue(REDRAWIPO, 0);
820 BIF_preview_changed(ID_WO);
824 else if(G.buts->texfrom==2) { /* from lamp */
826 if(la && ob->type==OB_LAMP) { /* to be sure */
827 mtex= la->mtex[ la->texact ];
829 if(mtex->tex) mtex->tex->id.us--;
831 la->mtex[ la->texact ]= NULL;
832 allqueue(REDRAWBUTSSHADING, 0);
833 allqueue(REDRAWIPO, 0);
834 BIF_preview_changed(ID_LA);
838 else { /* from brush */
839 br= G.scene->toolsettings->imapaint.brush;
840 if(G.f & G_SCULPTMODE) {
841 sculptmode_rem_tex(NULL, NULL);
842 allqueue(REDRAWBUTSSHADING, 0);
844 mtex= br->mtex[ br->texact ];
846 if(mtex->tex) mtex->tex->id.us--;
848 br->mtex[ br->texact ]= NULL;
849 allqueue(REDRAWBUTSSHADING, 0);
850 allqueue(REDRAWIMAGE, 0);
851 allqueue(REDRAWIPO, 0);
852 /*BIF_preview_changed(ID_BR);*/
856 BIF_undo_push("Unlink Texture");
862 if(G.buts->texnr== -2) {
864 id= G.buts->lockpoin;
865 if(event==B_EXTEXBROWSE) {
867 ma= give_current_material(ob, ob->actcol);
868 ma= editnode_get_active_material(ma);
870 mtex= ma->mtex[ ma->texact ];
871 if(mtex) id= (ID *)mtex->tex;
874 if(G.qual & LR_CTRLKEY) {
875 activate_databrowse_imasel(id, ID_TE, 0, B_TEXBROWSE, &G.buts->texnr, do_global_buttons);
878 activate_databrowse(id, ID_TE, 0, B_TEXBROWSE, &G.buts->texnr, do_global_buttons);
882 if(G.buts->texnr < 0) break;
890 ma= give_current_material(ob, ob->actcol);
891 ma= editnode_get_active_material(ma);
893 mtex= ma->mtex[ ma->texact ];
894 if(mtex) id= (ID *)mtex->tex;
897 idtest= G.main->tex.first;
899 if(nr==G.buts->texnr) {
903 idtest= idtest->next;
905 if(idtest==0) { /* new tex */
906 if(id) idtest= (ID *)copy_texture((Tex *)id);
907 else idtest= (ID *)add_texture("Tex");
910 if(idtest!=id && ma) {
912 if( ma->mtex[ma->texact]==0) ma->mtex[ma->texact]= add_mtex();
914 ma->mtex[ ma->texact ]->tex= (Tex *)idtest;
918 BIF_undo_push("Browse Texture");
919 allqueue(REDRAWBUTSSHADING, 0);
920 allqueue(REDRAWIPO, 0);
921 allqueue(REDRAWOOPS, 0);
922 BIF_preview_changed(ID_MA);
927 /* only available when not pinned */
928 if (G.saction->pin == 0) {
931 /* decrement user-count of action (as ob no longer uses it) */
935 /* make sure object doesn't hold reference to it anymore */
937 if (ob->pose) { /* clear flag (POSE_LOC/ROT/SIZE), also used for draw colors */
939 for (pchan= ob->pose->chanbase.first; pchan; pchan= pchan->next)
943 BIF_undo_push("Unlink Action");
945 allqueue(REDRAWVIEW3D, 0);
946 allqueue(REDRAWACTION, 0);
947 allqueue(REDRAWNLA, 0);
948 allqueue(REDRAWIPO, 0);
949 allqueue(REDRAWBUTSEDIT, 0);
958 if (G.saction->actnr== -2){
959 activate_databrowse((ID *)G.saction->action, ID_AC, 0, B_ACTIONBROWSE, &G.saction->actnr, do_global_buttons);
963 if (G.saction->actnr < 0) break;
965 /* See if we have selected a valid action */
966 for (idtest= G.main->action.first; idtest; idtest= idtest->next) {
967 if (nr==G.saction->actnr)
972 if (G.saction->pin) {
973 if (idtest == NULL) {
974 /* assign new/copy of pinned action only - messy as it doesn't assign to any obj's */
975 if (G.saction->action)
976 G.saction->action= (bAction *)copy_action(G.saction->action);
978 G.saction->action= (bAction *)add_empty_action("PinnedAction");
981 G.saction->action= (bAction *)idtest;
983 allqueue(REDRAWACTION, 0);
986 /* Store current action */
987 if (idtest == NULL) {
989 * - make a copy of an exisiting action
990 * - or make a new empty action if no existing action
993 idtest= (ID *)copy_action(act);
996 if ((ob->ipo) && (ob->ipoflag & OB_ACTION_OB)==0) {
997 /* object ipo - like if B_IPO_ACTION_OB is triggered */
998 bActionChannel *achan;
1000 if (has_ipo_code(ob->ipo, OB_LAY))
1001 notice("Note: Layer Ipo doesn't work in Actions");
1003 ob->ipoflag |= OB_ACTION_OB;
1005 act = add_empty_action("ObAction");
1009 achan= verify_action_channel(act, "Object");
1010 achan->flag = (ACHAN_HILIGHTED|ACHAN_SELECTED|ACHAN_EXPANDED|ACHAN_SHOWIPO);
1012 if (achan->ipo==NULL) {
1013 achan->ipo= ob->ipo;
1016 allqueue(REDRAWIPO, 0);
1017 allqueue(REDRAWOOPS, 0);
1020 /* object constraints */
1021 if (ob->constraintChannels.first) {
1022 free_constraint_channels(&achan->constraintChannels);
1023 achan->constraintChannels= ob->constraintChannels;
1024 ob->constraintChannels.first= ob->constraintChannels.last= NULL;
1027 else if (ELEM(ob->type, OB_MESH, OB_LATTICE) && ob_get_key(ob)) {
1028 /* shapekey - like if B_IPO_ACTION_KEY is triggered */
1029 bActionChannel *achan;
1030 Key *key= ob_get_key(ob);
1032 ob->ipoflag |= OB_ACTION_KEY;
1034 act = add_empty_action("ShapeAction");
1037 achan= verify_action_channel(act, "Shape");
1038 achan->flag = (ACHAN_HILIGHTED|ACHAN_SELECTED|ACHAN_EXPANDED|ACHAN_SHOWIPO);
1040 if ((achan->ipo==NULL) && (key->ipo)) {
1041 achan->ipo= key->ipo;
1044 allqueue(REDRAWIPO, 0);
1045 allqueue(REDRAWOOPS, 0);
1049 /* a plain action */
1050 idtest=(ID *)add_empty_action("Action");
1057 if ((idtest!=id) && (ob)) {
1058 act= (bAction *)idtest;
1065 /* Update everything */
1066 BIF_undo_push("Browse Action");
1067 do_global_buttons (B_NEWFRAME);
1068 allqueue(REDRAWVIEW3D, 0);
1069 allqueue(REDRAWNLA, 0);
1070 allqueue(REDRAWACTION, 0);
1071 allqueue(REDRAWHEADERS, 0);
1072 allqueue(REDRAWBUTSEDIT, 0);
1082 if(from==NULL) return;
1084 if(G.sipo->menunr== -2) {
1085 activate_databrowse((ID *)G.sipo->ipo, ID_IP, G.sipo->blocktype, B_IPOBROWSE, &G.sipo->menunr, do_global_buttons);
1089 if(G.sipo->menunr < 0) break;
1091 idtest= G.main->ipo.first;
1093 if( ((Ipo *)idtest)->blocktype == G.sipo->blocktype) {
1094 if(nr==G.sipo->menunr) {
1099 idtest= idtest->next;
1104 G.sipo->ipo= (Ipo *)idtest;
1105 allspace(REMAKEIPO, 0); // in fact it should only do this one, but there is no function for it
1109 // assign the ipo to ...
1112 if(ipo) idtest= (ID *)copy_ipo(ipo);
1114 nr= G.sipo->blocktype;
1115 if(nr==ID_OB) idtest= (ID *)add_ipo("ObIpo", ID_OB);
1116 else if(nr==ID_CO) idtest= (ID *)add_ipo("CoIpo", ID_CO);
1117 else if(nr==ID_PO) idtest= (ID *)add_ipo("ActIpo", nr);
1118 else if(nr==ID_MA) idtest= (ID *)add_ipo("MatIpo", nr);
1119 else if(nr==ID_TE) idtest= (ID *)add_ipo("TexIpo", nr);
1120 else if(nr==ID_SEQ) idtest= (ID *)add_ipo("MatSeq", nr);
1121 else if(nr==ID_CU) idtest= (ID *)add_ipo("CuIpo", nr);
1122 else if(nr==ID_KE) idtest= (ID *)add_ipo("KeyIpo", nr);
1123 else if(nr==ID_WO) idtest= (ID *)add_ipo("WoIpo", nr);
1124 else if(nr==ID_LA) idtest= (ID *)add_ipo("LaIpo", nr);
1125 else if(nr==ID_CA) idtest= (ID *)add_ipo("CaIpo", nr);
1126 else if(nr==ID_SO) idtest= (ID *)add_ipo("SndIpo", nr);
1127 else if(nr==ID_FLUIDSIM) idtest= (ID *)add_ipo("FluidsimIpo", nr);
1128 else if(nr==ID_PA) idtest= (ID *)add_ipo("PaIpo", nr);
1129 else error("Warn bugtracker!");
1133 if(idtest!=id && from) {
1134 spaceipo_assign_ipo(G.sipo, (Ipo *)idtest);
1136 BIF_undo_push("Browse Ipo");
1144 spaceipo_assign_ipo(G.sipo, NULL);
1146 editipo_changed(G.sipo, 1); /* doredraw */
1148 BIF_undo_push("Unlink Ipo");
1153 if(G.buts->menunr==-2) {
1154 activate_databrowse((ID *)G.scene->world, ID_WO, 0, B_WORLDBROWSE, &G.buts->menunr, do_global_buttons);
1158 if(G.buts->menunr < 0) break;
1161 wrld= G.scene->world;
1166 idtest= G.main->world.first;
1168 if(nr==G.buts->menunr) {
1172 idtest= idtest->next;
1174 if(idtest==0) { /* new world */
1175 if(id) idtest= (ID *)copy_world((World *)id);
1176 else idtest= (ID *)add_world("World");
1180 G.scene->world= (World *)idtest;
1184 BIF_undo_push("Browse World");
1185 allqueue(REDRAWBUTSSHADING, 0);
1186 allqueue(REDRAWIPO, 0);
1187 allqueue(REDRAWOOPS, 0);
1188 BIF_preview_changed(ID_WO);
1192 if(G.scene->world) {
1193 G.scene->world->id.us--;
1194 G.scene->world= NULL;
1196 BIF_undo_push("Unlink World");
1197 allqueue(REDRAWBUTSSHADING, 0);
1198 allqueue(REDRAWIPO, 0);
1204 if(G.buts->texnr== -2) {
1206 wrld= G.scene->world;
1208 mtex= wrld->mtex[ wrld->texact ];
1209 if(mtex) id= (ID *)mtex->tex;
1212 activate_databrowse((ID *)id, ID_TE, 0, B_WTEXBROWSE, &G.buts->texnr, do_global_buttons);
1215 if(G.buts->texnr < 0) break;
1223 wrld= G.scene->world;
1225 mtex= wrld->mtex[ wrld->texact ];
1226 if(mtex) id= (ID *)mtex->tex;
1229 idtest= G.main->tex.first;
1231 if(nr==G.buts->texnr) {
1235 idtest= idtest->next;
1237 if(idtest==0) { /* new tex */
1238 if(id) idtest= (ID *)copy_texture((Tex *)id);
1239 else idtest= (ID *)add_texture("Tex");
1242 if(idtest!=id && wrld) {
1244 if( wrld->mtex[wrld->texact]==0) {
1245 wrld->mtex[wrld->texact]= add_mtex();
1246 wrld->mtex[wrld->texact]->texco= TEXCO_VIEW;
1248 wrld->mtex[ wrld->texact ]->tex= (Tex *)idtest;
1252 BIF_undo_push("Texture browse");
1253 allqueue(REDRAWBUTSSHADING, 0);
1254 allqueue(REDRAWIPO, 0);
1255 allqueue(REDRAWOOPS, 0);
1256 BIF_preview_changed(ID_WO);
1263 if(ob->type!=OB_LAMP) return;
1265 if(G.buts->menunr== -2) {
1266 activate_databrowse((ID *)G.buts->lockpoin, ID_LA, 0, B_LAMPBROWSE, &G.buts->menunr, do_global_buttons);
1269 if(G.buts->menunr < 0) break;
1275 idtest= G.main->lamp.first;
1277 if(nr==G.buts->menunr) {
1281 idtest= idtest->next;
1283 if(idtest==0) { /* no new lamp */
1287 ob->data= (Lamp *)idtest;
1291 BIF_undo_push("Lamp browse");
1292 allqueue(REDRAWBUTSSHADING, 0);
1293 allqueue(REDRAWVIEW3D, 0);
1294 allqueue(REDRAWIPO, 0);
1295 allqueue(REDRAWOOPS, 0);
1296 BIF_preview_changed(ID_LA);
1303 if(ob->type!=OB_LAMP) return;
1305 if(G.buts->texnr== -2) {
1308 mtex= la->mtex[ la->texact ];
1309 if(mtex) id= (ID *)mtex->tex;
1311 activate_databrowse(id, ID_TE, 0, B_LTEXBROWSE, &G.buts->texnr, do_global_buttons);
1314 if(G.buts->texnr < 0) break;
1323 mtex= la->mtex[ la->texact ];
1324 if(mtex) id= (ID *)mtex->tex;
1326 idtest= G.main->tex.first;
1328 if(nr==G.buts->texnr) {
1332 idtest= idtest->next;
1334 if(idtest==0) { /* new tex */
1335 if(id) idtest= (ID *)copy_texture((Tex *)id);
1336 else idtest= (ID *)add_texture("Tex");
1339 if(idtest!=id && la) {
1341 if( la->mtex[la->texact]==0) {
1342 la->mtex[la->texact]= add_mtex();
1343 la->mtex[la->texact]->texco= TEXCO_GLOB;
1345 la->mtex[ la->texact ]->tex= (Tex *)idtest;
1349 BIF_undo_push("Texture Browse");
1350 allqueue(REDRAWBUTSSHADING, 0);
1351 allqueue(REDRAWIPO, 0);
1352 allqueue(REDRAWOOPS, 0);
1353 BIF_preview_changed(ID_LA);
1359 if(G.sima->image && (G.sima->image->type == IMA_TYPE_R_RESULT || G.sima->image->type == IMA_TYPE_COMPOSITE)) {
1360 /* Run if G.sima is render, remove the render and display the meshes image if it exists */
1361 G.sima->image= NULL;
1363 allqueue(REDRAWIMAGE, 0);
1365 /* Run on non render images, unlink normally */
1366 image_changed(G.sima, NULL);
1367 BIF_undo_push("Unlink Image");
1368 allqueue(REDRAWIMAGE, 0);
1373 /* this is called now from Node editor too, buttons might not exist */
1374 if(curarea->spacetype==SPACE_NODE) {
1375 SpaceNode *snode= curarea->spacedata.first;
1376 automatname((Material *)snode->id);
1379 automatname(G.buts->lockpoin);
1383 BIF_undo_push("Auto name");
1384 allqueue(REDRAWBUTSSHADING, 0);
1385 allqueue(REDRAWNODE, 0);
1386 allqueue(REDRAWOOPS, 0);
1389 if(G.buts->mainb==CONTEXT_SHADING) {
1390 if(G.buts->tab[CONTEXT_SHADING]==TAB_SHADING_TEX) {
1391 autotexname(G.buts->lockpoin);
1393 else if(G.buts->tab[CONTEXT_SHADING]==TAB_SHADING_MAT) {
1394 ma= G.buts->lockpoin;
1395 if(ma->mtex[ ma->texact]) autotexname(ma->mtex[ma->texact]->tex);
1397 else if(G.buts->tab[CONTEXT_SHADING]==TAB_SHADING_WORLD) {
1398 wrld= G.buts->lockpoin;
1399 if(wrld->mtex[ wrld->texact]) autotexname(wrld->mtex[wrld->texact]->tex);
1401 else if(G.buts->tab[CONTEXT_SHADING]==TAB_SHADING_LAMP) {
1402 la= G.buts->lockpoin;
1403 if(la->mtex[ la->texact]) autotexname(la->mtex[la->texact]->tex);
1405 BIF_undo_push("Auto name");
1406 allqueue(REDRAWBUTSSHADING, 0);
1407 allqueue(REDRAWOOPS, 0);
1408 allqueue(REDRAWIMAGE, 0);
1410 else if(G.buts->mainb==CONTEXT_EDITING) {
1411 SculptData *sd= &G.scene->sculptdata;
1412 if(sd && sd->texact != -1) {
1413 if(sd->mtex[sd->texact]) autotexname(sd->mtex[sd->texact]->tex);
1415 BIF_undo_push("Auto name");
1416 allqueue(REDRAWBUTSEDIT, 0);
1417 allqueue(REDRAWOOPS, 0);
1422 case B_RESETAUTOSAVE:
1424 allqueue(REDRAWINFO, 0);
1427 SYS_WriteCommandLineInt(SYS_GetSystem(), "noaudio", (U.gameflags & USER_DISABLE_SOUND));
1432 case B_MIPMAPCHANGED:
1433 GPU_set_mipmap(!(U.gameflags & USER_DISABLE_MIPMAP));
1434 allqueue(REDRAWVIEW3D, 0);
1436 case B_GLRESLIMITCHANGED:
1437 GPU_free_images(); /* force reloading with new res limit */
1438 allqueue(REDRAWVIEW3D, 0);
1441 newspace(curarea, curarea->butspacetype);
1442 reset_filespace(curarea);
1443 reset_imaselspace(curarea);
1445 case B_LOADTEMP: /* is button from space.c */
1446 BIF_read_autosavefile();
1450 allqueue(REDRAWINFO, 0);
1453 case B_DRAWINFO: /* is button from space.c *info* */
1454 allqueue(REDRAWVIEW3D, 0);
1457 case B_PLAINMENUS: /* is button from space.c *info* */
1461 case B_FLIPINFOMENU: /* is button from space.c *info* */
1462 scrarea_queue_headredraw(curarea);
1466 //#ifdef _WIN32 // FULLSCREEN
1467 case B_FLIPFULLSCREEN:
1468 if(U.uiflag & USER_FLIPFULLSCREEN)
1469 U.uiflag &= ~USER_FLIPFULLSCREEN;
1471 U.uiflag |= USER_FLIPFULLSCREEN;
1472 mainwindow_toggle_fullscreen((U.uiflag & USER_FLIPFULLSCREEN));
1476 /* Fileselect windows for user preferences file paths */
1478 /* yafray: xml export dir. select */
1479 case B_YAFRAYDIRFILESEL: /* space.c */
1480 if(curarea->spacetype==SPACE_INFO) {
1481 sa= closest_bigger_area();
1482 areawinset(sa->win);
1485 activate_fileselect(FILE_SPECIAL, "SELECT YFEXPORT PATH", U.yfexportdir, filesel_u_yfexportdir);
1488 case B_FONTDIRFILESEL: /* is button from space.c *info* */
1489 if(curarea->spacetype==SPACE_INFO) {
1490 sa= closest_bigger_area();
1491 areawinset(sa->win);
1494 activate_fileselect(FILE_SPECIAL, "SELECT FONT PATH", U.fontdir, filesel_u_fontdir);
1497 case B_TEXTUDIRFILESEL: /* is button from space.c *info* */
1498 if(curarea->spacetype==SPACE_INFO) {
1499 sa= closest_bigger_area();
1500 areawinset(sa->win);
1503 activate_fileselect(FILE_SPECIAL, "SELECT TEXTURE PATH", U.textudir, filesel_u_textudir);
1506 case B_PLUGTEXDIRFILESEL: /* is button form space.c *info* */
1507 if(curarea->spacetype==SPACE_INFO) {
1508 sa= closest_bigger_area();
1509 areawinset(sa->win);
1512 activate_fileselect(FILE_SPECIAL, "SELECT TEX PLUGIN PATH", U.plugtexdir, filesel_u_plugtexdir);
1515 case B_PLUGSEQDIRFILESEL: /* is button from space.c *info* */
1516 if(curarea->spacetype==SPACE_INFO) {
1517 sa= closest_bigger_area();
1518 areawinset(sa->win);
1521 activate_fileselect(FILE_SPECIAL, "SELECT SEQ PLUGIN PATH", U.plugseqdir, filesel_u_plugseqdir);
1524 case B_RENDERDIRFILESEL: /* is button from space.c *info* */
1525 if(curarea->spacetype==SPACE_INFO) {
1526 sa= closest_bigger_area();
1527 areawinset(sa->win);
1530 activate_fileselect(FILE_SPECIAL, "SELECT RENDER PATH", U.renderdir, filesel_u_renderdir);
1532 #ifndef DISABLE_PYTHON
1533 case B_PYMENUEVAL: /* is button from space.c *info* */
1534 waitcursor( 1 ); /* can take some time */
1535 if (BPY_path_update() == 0) { /* re-eval scripts registration in menus */
1537 error("Invalid scripts dir: check console");
1541 case B_PYTHONDIRFILESEL: /* is button from space.c *info* */
1542 if(curarea->spacetype==SPACE_INFO) {
1543 sa= closest_bigger_area();
1544 areawinset(sa->win);
1547 activate_fileselect(FILE_SPECIAL, "SELECT SCRIPT PATH", U.pythondir, filesel_u_pythondir);
1550 case B_SOUNDDIRFILESEL: /* is button from space.c *info* */
1551 if(curarea->spacetype==SPACE_INFO) {
1552 sa= closest_bigger_area();
1553 areawinset(sa->win);
1556 activate_fileselect(FILE_SPECIAL, "SELECT SOUND PATH", U.sounddir, filesel_u_sounddir);
1559 case B_TEMPDIRFILESEL: /* is button from space.c *info* */
1560 if(curarea->spacetype==SPACE_INFO) {
1561 sa= closest_bigger_area();
1562 areawinset(sa->win);
1565 activate_fileselect(FILE_SPECIAL, "SELECT TEMP FILE PATH", U.tempdir, filesel_u_tempdir);
1568 /* END Fileselect windows for user preferences file paths */
1570 #ifdef INTERNATIONAL
1571 case B_LOADUIFONT: /* is button from space.c *info* */
1572 if(curarea->spacetype==SPACE_INFO) {
1573 sa= closest_bigger_area();
1574 areawinset(sa->win);
1576 BLI_make_file_string("/", buf, U.fontdir, U.fontname);
1577 activate_fileselect(FILE_SPECIAL, "LOAD UI FONT", buf, set_interface_font);
1580 case B_SETLANGUAGE: /* is button from space.c *info* */
1582 allqueue(REDRAWALL, 0);
1585 case B_SETFONTSIZE: /* is button from space.c *info* */
1586 refresh_interface_font();
1587 FTF_SetSize(U.fontsize);
1588 allqueue(REDRAWALL, 0);
1591 case B_SETTRANSBUTS: /* is button from space.c *info* */
1592 allqueue(REDRAWALL, 0);
1595 case B_RESTOREFONT: /* is button from space.c *info* */
1597 start_interface_font();
1598 allqueue(REDRAWALL, 0);
1601 case B_USETEXTUREFONT: /* is button from space.c *info* */
1602 refresh_interface_font();
1603 allqueue(REDRAWALL, 0);
1606 case B_DOLANGUIFONT: /* is button from space.c *info* */
1607 if(U.transopts & USER_DOTRANSLATE)
1608 start_interface_font();
1610 G.ui_international = FALSE;
1611 allqueue(REDRAWALL, 0);
1616 if(curarea->spacetype!=SPACE_INFO) {
1622 /* changing a metaballs name, sadly enough,
1623 * can require it to be updated because its
1624 * basis might have changed... -zr
1626 if (ob && ob->type==OB_MBALL) {
1627 DAG_scene_sort(G.scene);
1628 DAG_object_flush_update(G.scene, ob, OB_RECALC_DATA);
1630 /* redraw because name has changed: new pup */
1631 scrarea_queue_headredraw(curarea);
1632 allqueue(REDRAWINFO, 1);
1633 allqueue(REDRAWOOPS, 1);
1634 allqueue(REDRAWACTION, 1);
1635 allqueue(REDRAWNLA, 1);
1636 allqueue(REDRAWVIEW3D, 1);
1637 /* name scene also in set PUPmenu */
1638 allqueue(REDRAWBUTSALL, 0);
1639 allqueue(REDRAWIMAGE, 0);
1640 allqueue(REDRAWHEADERS, 0);
1644 /* keep datablock. similar to pressing FKEY in a fileselect window
1645 * maybe we can move that stuff to a seperate function? -- sg
1647 if (curarea->spacetype==SPACE_BUTS) {
1648 id= (ID *)G.buts->lockpoin;
1649 } else if(curarea->spacetype==SPACE_IPO) {
1650 id = (ID *)G.sipo->ipo;
1651 } else if(curarea->spacetype==SPACE_NODE) {
1652 id = ((SpaceNode *)curarea->spacedata.first)->id;
1653 } else if(curarea->spacetype==SPACE_ACTION) {
1654 id= (ID *)G.saction->action;
1655 }/* similar for other spacetypes ? */
1657 /* flag was already toggled, just need to update user count */
1658 if(id->flag & LIB_FAKEUSER)
1663 allqueue(REDRAWHEADERS, 0);
1671 void do_global_buttons2(short event)
1688 /* general: Single User is allowed when from==LOCAL
1689 * Make Local is allowed when (from==LOCAL && id==LIB)
1692 if(event<B_LOCAL_ALONE) return;
1699 if(ob && ob->id.lib==0) {
1702 if(okee("Single user")) {
1703 ob->data= copy_lamp(la);
1710 if(ob && ob->id.lib==0) {
1713 if(okee("Make local")) {
1714 make_local_lamp(la);
1721 if (ob&&ob->id.lib==0){
1722 bArmature *arm=ob->data;
1724 if(okee("Make local")) {
1725 make_local_armature(arm);
1731 if(ob && ob->id.lib==0) {
1732 bArmature *arm=ob->data;
1734 if(okee("Single user")) {
1735 ob->data= copy_armature(arm);
1736 armature_rebuild_pose(ob, ob->data);
1743 if(ob && ob->id.lib==0) {
1746 if(okee("Make local")) {
1747 make_local_action(act);
1748 allqueue(REDRAWACTION, 0);
1749 allqueue(REDRAWBUTSEDIT, 0);
1755 if(ob && ob->id.lib==0) {
1759 if(okee("Single user")) {
1760 ob->action=copy_action(act);
1762 allqueue(REDRAWACTION, 0);
1763 allqueue(REDRAWBUTSEDIT, 0);
1770 if(ob && ob->id.lib==0) {
1771 Camera *ca= ob->data;
1773 if(okee("Single user")) {
1774 ob->data= copy_camera(ca);
1781 if(ob && ob->id.lib==0) {
1782 Camera *ca= ob->data;
1784 if(okee("Make local")) {
1785 make_local_camera(ca);
1791 wrld= G.scene->world;
1793 if(okee("Single user")) {
1794 G.scene->world= copy_world(wrld);
1800 wrld= G.scene->world;
1801 if(wrld && wrld->id.lib) {
1802 if(okee("Make local")) {
1803 make_local_world(wrld);
1809 if(ob && ob->id.lib==0) {
1812 if(okee("Single user")) {
1813 ob->data= copy_lattice(lt);
1820 if(ob && ob->id.lib==0) {
1823 if(okee("Make local")) {
1824 make_local_lattice(lt);
1832 ma= give_current_material(ob, ob->actcol);
1833 idfrom= material_from(ob, ob->actcol);
1834 if(idfrom && idfrom->lib==0) {
1836 if(okee("Single user")) {
1837 ma= copy_material(ma);
1839 assign_material(ob, ma, ob->actcol);
1846 idfrom= material_from(ob, ob->actcol);
1847 if(idfrom->lib==0) {
1848 ma= give_current_material(ob, ob->actcol);
1849 if(ma && ma->id.lib) {
1850 if(okee("Make local")) {
1851 make_local_material(ma);
1858 if(ob && ob->id.lib==0) {
1860 if(me && me->id.lib) {
1861 if(okee("Make local")) {
1862 make_local_mesh(me);
1863 make_local_key( me->key );
1865 DAG_object_flush_update(G.scene, ob, OB_RECALC_DATA);
1872 if(ob && ob->id.lib==0) {
1875 if(okee("Single user")) {
1876 ob->data= copy_mball(mb);
1878 if(ob==G.obedit) allqueue(REDRAWVIEW3D, 0);
1884 if(ob && ob->id.lib==0) {
1887 if(okee("Make local")) {
1888 make_local_mball(mb);
1895 if(ob && ob->id.lib==0) {
1898 if(okee("Single user")) {
1899 ob->data= copy_curve(cu);
1901 DAG_object_flush_update(G.scene, ob, OB_RECALC_DATA);
1902 if(ob==G.obedit) allqueue(REDRAWVIEW3D, 0);
1908 if(ob && ob->id.lib==0) {
1911 if(okee("Make local")) {
1912 make_local_curve(cu);
1913 make_local_key( cu->key );
1914 DAG_object_flush_update(G.scene, ob, OB_RECALC_DATA);
1921 if(G.buts->texfrom==0) { /* from mat */
1923 ma= give_current_material(ob, ob->actcol);
1924 ma= editnode_get_active_material(ma);
1925 if(ma && ma->id.lib==0) {
1926 mtex= ma->mtex[ ma->texact ];
1927 if(mtex->tex && mtex->tex->id.us>1) {
1928 if(okee("Single user")) {
1930 mtex->tex= copy_texture(mtex->tex);
1935 else if(G.buts->texfrom==1) { /* from world */
1936 wrld= G.scene->world;
1937 if(wrld->id.lib==0) {
1938 mtex= wrld->mtex[ wrld->texact ];
1939 if(mtex->tex && mtex->tex->id.us>1) {
1940 if(okee("Single user")) {
1942 mtex->tex= copy_texture(mtex->tex);
1947 else if(G.buts->texfrom==2) { /* from lamp */
1948 if(ob==0 || ob->type!=OB_LAMP) return;
1951 mtex= la->mtex[ la->texact ];
1952 if(mtex->tex && mtex->tex->id.us>1) {
1953 if(okee("Single user")) {
1955 mtex->tex= copy_texture(mtex->tex);
1960 else if(G.buts->texfrom==3) { /* from brush */
1961 br= G.scene->toolsettings->imapaint.brush;
1964 mtex= br->mtex[ br->texact ];
1965 if(mtex->tex && mtex->tex->id.us>1) {
1966 if(okee("Single user")) {
1968 mtex->tex= copy_texture(mtex->tex);
1969 allqueue(REDRAWIMAGE, 0);
1976 if(G.buts->texfrom==0) { /* from mat */
1978 ma= give_current_material(ob, ob->actcol);
1979 ma= editnode_get_active_material(ma);
1980 if(ma && ma->id.lib==0) {
1981 mtex= ma->mtex[ ma->texact ];
1982 if(mtex->tex && mtex->tex->id.lib) {
1983 if(okee("Make local")) {
1984 make_local_texture(mtex->tex);
1989 else if(G.buts->texfrom==1) { /* from world */
1990 wrld= G.scene->world;
1991 if(wrld->id.lib==0) {
1992 mtex= wrld->mtex[ wrld->texact ];
1993 if(mtex->tex && mtex->tex->id.lib) {
1994 if(okee("Make local")) {
1995 make_local_texture(mtex->tex);
2000 else if(G.buts->texfrom==2) { /* from lamp */
2001 if(ob==0 || ob->type!=OB_LAMP) return;
2004 mtex= la->mtex[ la->texact ];
2005 if(mtex->tex && mtex->tex->id.lib) {
2006 if(okee("Make local")) {
2007 make_local_texture(mtex->tex);
2012 else if(G.buts->texfrom==3) { /* from brush */
2013 br= G.scene->toolsettings->imapaint.brush;
2016 mtex= br->mtex[ br->texact ];
2017 if(mtex->tex && mtex->tex->id.lib) {
2018 if(okee("Make local")) {
2019 make_local_texture(mtex->tex);
2020 allqueue(REDRAWIMAGE, 0);
2029 idfrom= G.sipo->from;
2031 if(idfrom && idfrom->lib==NULL) {
2033 if(okee("Single user")) {
2035 ipo->id.us= 0; /* assign_ipo adds users, copy_ipo sets to 1 */
2036 spaceipo_assign_ipo(G.sipo, ipo);
2037 allqueue(REDRAWIPO, 0);
2044 idfrom= G.sipo->from;
2046 if(idfrom && idfrom->lib==0) {
2048 if(okee("Make local")) {
2049 make_local_ipo(ipo);
2050 allqueue(REDRAWIPO, 0);
2057 if(G.scene->id.lib==0) {
2059 if(okee("Single user")) {
2062 if(base->object==ob) {
2063 base->object= copy_object(ob);
2065 allqueue(REDRAWVIEW3D, 0);
2075 if(G.scene->id.lib==0) {
2077 if(okee("Make local")) {
2078 make_local_object(ob);
2079 allqueue(REDRAWVIEW3D, 0);
2085 if(ob && ob->id.lib==0) {
2089 if(me && me->id.us>1) {
2090 if(okee("Single user")) {
2091 Mesh *men= copy_mesh(me);
2096 DAG_object_flush_update(G.scene, ob, OB_RECALC_DATA);
2098 if(ob==G.obedit) allqueue(REDRAWVIEW3D, 0);
2105 BIF_undo_push("Make single user or local");
2106 allqueue(REDRAWBUTSALL, 0);
2107 allqueue(REDRAWOOPS, 0);
2110 /* ******************** GENERAL ********************** */
2112 void do_headerbuttons(short event)
2115 if(event<=50) do_global_buttons2(event);
2116 else if(event<=100) do_global_buttons(event);
2117 else if(event<200) do_view3d_buttons(event);
2118 else if(event<250) do_ipo_buttons(event);
2119 else if(event<300) do_oops_buttons(event);
2120 else if(event<350) do_info_buttons(event);
2121 else if(event<400) do_image_buttons(event);
2122 else if(event<450) do_buts_buttons(event);
2123 else if(event<500) do_imasel_buttons(event);
2124 else if(event<525) do_text_buttons(event);
2125 else if(event<550) do_script_buttons(event);
2126 else if(event<600) do_file_buttons(event);
2127 else if(event<650) do_seq_buttons(event);
2128 else if(event<700) do_sound_buttons(event);
2129 else if(event<750) do_action_buttons(event);
2130 else if(event<800) do_time_buttons(curarea, event);
2131 else if(event<850) do_nla_buttons(event);
2132 else if(event<900) do_node_buttons(curarea, event);
2133 else if(event>=REDRAWVIEW3D) allqueue(event, 0);