2 * $Id: headerbuttons.c 10757 2007-05-22 14:20:18Z 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 * The Original Code is: all of this file.
28 * Contributor(s): none yet.
30 * ***** END GPL/BL DUAL LICENSE BLOCK *****
37 #include <sys/types.h>
43 #include "MEM_guardedalloc.h"
46 #include "BIF_language.h"
51 #include "BLI_blenlib.h"
52 #include "BLI_arithb.h"
53 #include "BLI_storage_types.h"
55 #include "IMB_imbuf_types.h"
56 #include "IMB_imbuf.h"
59 #include "DNA_action_types.h"
60 #include "DNA_armature_types.h"
61 #include "DNA_brush_types.h"
62 #include "DNA_camera_types.h"
63 #include "DNA_curve_types.h"
64 #include "DNA_group_types.h"
65 #include "DNA_image_types.h"
66 #include "DNA_ipo_types.h"
67 #include "DNA_key_types.h"
68 #include "DNA_lamp_types.h"
69 #include "DNA_lattice_types.h"
70 #include "DNA_material_types.h"
71 #include "DNA_mesh_types.h"
72 #include "DNA_meta_types.h"
73 #include "DNA_object_types.h"
74 #include "DNA_oops_types.h"
75 #include "DNA_packedFile_types.h"
76 #include "DNA_scene_types.h"
77 #include "DNA_screen_types.h"
78 #include "DNA_sequence_types.h"
79 #include "DNA_sound_types.h"
80 #include "DNA_space_types.h"
81 #include "DNA_texture_types.h"
82 #include "DNA_text_types.h"
83 #include "DNA_userdef_types.h"
84 #include "DNA_view2d_types.h"
85 #include "DNA_view3d_types.h"
86 #include "DNA_world_types.h"
87 #include "DNA_constraint_types.h"
89 #include "BKE_utildefines.h"
91 #include "BKE_action.h"
92 #include "BKE_armature.h"
93 #include "BKE_blender.h"
94 #include "BKE_brush.h"
95 #include "BKE_constraint.h"
96 #include "BKE_curve.h"
97 #include "BKE_depsgraph.h"
98 #include "BKE_exotic.h"
99 #include "BKE_global.h"
100 #include "BKE_image.h"
103 #include "BKE_lattice.h"
104 #include "BKE_library.h"
105 #include "BKE_main.h"
106 #include "BKE_material.h"
107 #include "BKE_mball.h"
108 #include "BKE_mesh.h"
109 #include "BKE_node.h"
110 #include "BKE_object.h"
111 #include "BKE_packedFile.h"
113 #include "BKE_scene.h"
114 #include "BKE_texture.h"
115 #include "BKE_text.h"
116 #include "BKE_world.h"
118 #include "BLO_readfile.h"
119 #include "BLO_writefile.h"
121 #include "BIF_drawimage.h"
122 #include "BIF_drawoops.h"
123 #include "BIF_drawscene.h"
124 #include "BIF_drawtext.h"
125 #include "BIF_editaction.h"
126 #include "BIF_editarmature.h"
127 #include "BIF_editfont.h"
128 #include "BIF_editlattice.h"
129 #include "BIF_editconstraint.h"
130 #include "BIF_editmesh.h"
131 #include "BIF_editmesh.h"
132 #include "BIF_editsima.h"
133 #include "BIF_editsound.h"
135 #include "BIF_imasel.h"
136 #include "BIF_interface.h"
137 #include "BIF_mainqueue.h"
138 #include "BIF_mywindow.h"
139 #include "BIF_poseobject.h"
140 #include "BIF_renderwin.h"
141 #include "BIF_resources.h"
142 #include "BIF_screen.h"
143 #include "BIF_space.h"
144 #include "BIF_toets.h"
145 #include "BIF_toolbox.h"
146 #include "BIF_usiblender.h"
147 #include "BIF_previewrender.h"
148 #include "BIF_writeimage.h"
149 #include "BIF_butspace.h"
151 #include "BPI_script.h"
153 #include "BSE_edit.h"
154 #include "BSE_filesel.h"
155 #include "BSE_headerbuttons.h"
156 #include "BSE_node.h"
157 #include "BSE_view.h"
158 #include "BSE_sequence.h"
159 #include "BSE_editipo.h"
160 #include "BSE_drawipo.h"
162 #include "BDR_drawmesh.h"
163 #include "BDR_vpaint.h"
164 #include "BDR_editface.h"
165 #include "BDR_editobject.h"
166 #include "BDR_editcurve.h"
167 #include "BDR_editmball.h"
168 #include "BDR_sculptmode.h"
170 #include "BPY_extern.h"
171 #include "BPY_menus.h"
173 #include "mydevice.h"
175 #include "interface.h"
176 #include "nla.h" /* __NLA : To be removed later */
177 #include "butspace.h" // test_idbutton
179 #include "BIF_poseobject.h"
181 #include "SYS_System.h"
183 /* WATCH IT: always give all headerbuttons for same window the same name
184 * event B_REDR is a standard redraw
188 char *windowtype_pup(void)
191 "Window type:%t" //14
196 "|Ipo Curve Editor %x2" //54
197 "|Action Editor %x12" //73
198 "|NLA Editor %x13" //94
202 "|UV/Image Editor %x6" //117
204 "|Video Sequence Editor %x8" //143
205 "|Timeline %x15" //163
206 "|Audio Window %x11" //163
207 "|Text Editor %x9" //179
212 "|User Preferences %x7" //213
213 "|Outliner %x3" //232
214 "|Buttons Window %x4" //251
218 "|Image Browser %x10" //273
219 "|File Browser %x5" //290
223 "|Scripts Window %x14"//313
227 int GetButStringLength(char *str
) {
230 rt
= BIF_GetStringWidth(G
.font
, str
, (U
.transopts
& USER_TR_BUTTONS
));
235 /* ********************** GLOBAL ****************************** */
237 int std_libbuttons(uiBlock
*block
, short xco
, short yco
,
238 int pin
, short *pinpoin
, int browse
, short id_code
, short special
, ID
*id
,
239 ID
*parid
, short *menupoin
, int users
, int lib
,
240 int del
, int autobut
, int keepbut
)
244 int len
, oldcol
, add_addbutton
=0;
245 char *str
=NULL
, str1
[10];
247 uiBlockBeginAlign(block
);
248 oldcol
= uiBlockGetCol(block
);
251 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");
256 char *extrastr
= NULL
;
258 if(ELEM3(id_code
, ID_MA
, ID_TE
, ID_BR
)) add_addbutton
= 1;
260 lb
= wich_libbase(G
.main
, id_code
);
262 if(id
&& id
->us
>1) uiBlockSetCol(block
, TH_BUT_SETTING1
);
264 if (pin
&& *pinpoin
) {
265 uiBlockSetCol(block
, TH_BUT_SETTING2
);
268 if ELEM8( id_code
, ID_SCE
, ID_SCR
, ID_MA
, ID_TE
, ID_WO
, ID_IP
, ID_AC
, ID_BR
) extrastr
= "ADD NEW %x 32767";
269 else if (id_code
==ID_TXT
) extrastr
= "OPEN NEW %x 32766 |ADD NEW %x 32767";
270 else if (id_code
==ID_SO
) extrastr
= "OPEN NEW %x 32766";
272 uiSetButLock(G
.scene
->id
.lib
!=0, ERROR_LIBDATA_MESSAGE
);
273 if( id_code
==ID_SCE
|| id_code
==ID_SCR
) uiClearButLock();
275 if(curarea
->spacetype
==SPACE_BUTS
)
276 uiSetButLock(id_code
!=ID_SCR
&& G
.obedit
!=0 && G
.buts
->mainb
==CONTEXT_EDITING
, "Cannot perform in EditMode");
278 if(parid
) uiSetButLock(parid
->lib
!=0, ERROR_LIBDATA_MESSAGE
);
282 IPOnames_to_pupstring(&str
, NULL
, extrastr
, lb
, id
, menupoin
, G
.sipo
->blocktype
);
283 else if(browse
!=B_SIMABROWSE
&& id_code
==ID_IM
)
284 IMAnames_to_pupstring(&str
, NULL
, extrastr
, lb
, id
, menupoin
);
286 IDnames_to_pupstring(&str
, NULL
, extrastr
, lb
, id
, menupoin
);
289 uiDefButS(block
, MENU
, browse
, str
, xco
,yco
,XIC
,YIC
, menupoin
, 0, 0, 0, 0, "Browses existing choices or adds NEW");
297 uiBlockSetCol(block
, oldcol
);
299 if(id
) { /* text button with name */
302 if(id
->us
>1) uiBlockSetCol(block
, TH_BUT_SETTING1
);
304 if (pin
&& *pinpoin
) {
305 uiBlockSetCol(block
, TH_BUT_SETTING2
);
307 /* Redalert overrides pin color */
308 if(id
->us
<=0) uiBlockSetCol(block
, TH_REDALERT
);
310 uiSetButLock(id
->lib
!=0, ERROR_LIBDATA_MESSAGE
);
312 if(GS(id
->name
)==ID_SCE
) strcpy(str1
, "SCE:");
313 else if(GS(id
->name
)==ID_SCE
) strcpy(str1
, "SCR:");
314 else if(GS(id
->name
)==ID_MA
) {
315 if( ((Material
*)id
)->use_nodes
)
321 str1
[0]= id
->name
[0];
322 str1
[1]= id
->name
[1];
327 if( GS(id
->name
)==ID_IP
) len
= 110;
328 else if(yco
) len
= 140; // comes from button panel
331 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.");
332 uiButSetFunc(but
, test_idbutton_cb
, id
->name
, NULL
);
340 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.");
341 else uiDefIconBut(block
, BUT
, lib
, ICON_PARLIB
, xco
,yco
,XIC
,YIC
, 0, 0, 0, 0, 0,
342 lib
?"Direct linked Library Datablock. Click to make local.":"Direct linked Library Datablock, cannot make local."
349 if(users
&& id
->us
>1) {
350 uiSetButLock (pin
&& *pinpoin
, "Can't make pinned data single-user");
352 sprintf(str1
, "%d", id
->us
);
355 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.");
359 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.");
369 uiSetButLock (pin
&& *pinpoin
, "Can't unlink pinned data");
370 if(parid
&& parid
->lib
);
372 uiDefIconBut(block
, BUT
, del
, ICON_X
, xco
,yco
,XIC
,YIC
, 0, 0, 0, 0, 0, "Deletes link to this Datablock");
380 if(parid
&& parid
->lib
);
382 uiDefIconBut(block
, BUT
, autobut
, ICON_AUTO
,xco
,yco
,XIC
,YIC
, 0, 0, 0, 0, 0, "Generates an automatic name");
389 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");
393 else if(add_addbutton
) { /* "add new" button */
394 uiBlockSetCol(block
, oldcol
);
395 uiDefButS(block
, TOG
, browse
, "Add New" ,xco
, yco
, 110, YIC
, menupoin
, (float)*menupoin
, 32767.0, 0, 0, "Add new data block");
400 uiBlockSetCol(block
, oldcol
);
401 uiBlockEndAlign(block
);
407 /* results in fully updated anim system */
408 static void do_update_for_newframe(int mute
, int events
)
410 extern void audiostream_scrub(unsigned int frame
); /* seqaudio.c */
413 allqueue(REDRAWALL
, 0);
416 /* this function applies the changes too */
417 scene_update_for_newframe(G
.scene
, screen_view3d_layers()); /* BKE_scene.h */
419 if ( (CFRA
>1) && (!mute
) && (G
.scene
->audio
.flag
& AUDIO_SCRUB
))
420 audiostream_scrub( CFRA
);
422 /* 3d window, preview */
423 BIF_view3d_previewrender_signal(curarea
, PR_DBASE
|PR_DISPRECT
);
425 /* all movie/sequence images */
426 BIF_image_update_frame();
429 if(G
.scene
->use_nodes
&& G
.scene
->nodetree
)
430 ntreeCompositTagAnimated(G
.scene
->nodetree
);
433 void update_for_newframe(void)
435 do_update_for_newframe(0, 1);
438 void update_for_newframe_muted(void)
440 do_update_for_newframe(1, 1);
443 /* used by new animated UI playback */
444 void update_for_newframe_nodraw(int nosound
)
446 do_update_for_newframe(nosound
, 0);
450 static void show_splash(void)
452 extern char datatoc_splash_jpg
[];
453 extern int datatoc_splash_jpg_size
;
458 extern char * build_date
;
459 extern char * build_time
;
460 extern char * build_rev
;
461 extern char * build_platform
;
462 extern char * build_type
;
465 sprintf(string
,"Built on %s %s, Rev-%s Version %s %s", build_date
, build_time
, build_rev
, build_platform
, build_type
);
468 splash((void *)datatoc_splash_jpg
, datatoc_splash_jpg_size
, string
);
472 /* Functions for user preferences fileselect windows */
474 /* yafray: export dir select */
475 static void filesel_u_yfexportdir(char *name
)
477 char dir
[FILE_MAXDIR
], file
[FILE_MAXFILE
];
479 BLI_cleanup_dir(G
.sce
, name
);
480 BLI_split_dirfile(name
, dir
, file
);
482 strcpy(U
.yfexportdir
, dir
);
483 allqueue(REDRAWALL
, 0);
486 static void filesel_u_fontdir(char *name
)
488 char dir
[FILE_MAXDIR
], file
[FILE_MAXFILE
];
490 BLI_cleanup_dir(G
.sce
, name
);
491 BLI_split_dirfile(name
, dir
, file
);
493 strcpy(U
.fontdir
, dir
);
494 allqueue(REDRAWALL
, 0);
497 static void filesel_u_textudir(char *name
)
499 char dir
[FILE_MAXDIR
], file
[FILE_MAXFILE
];
501 BLI_cleanup_dir(G
.sce
, name
);
502 BLI_split_dirfile(name
, dir
, file
);
504 strcpy(U
.textudir
, dir
);
505 allqueue(REDRAWALL
, 0);
508 static void filesel_u_plugtexdir(char *name
)
510 char dir
[FILE_MAXDIR
], file
[FILE_MAXFILE
];
512 BLI_cleanup_dir(G
.sce
, name
);
513 BLI_split_dirfile(name
, dir
, file
);
515 strcpy(U
.plugtexdir
, dir
);
516 allqueue(REDRAWALL
, 0);
519 static void filesel_u_plugseqdir(char *name
)
521 char dir
[FILE_MAXDIR
], file
[FILE_MAXFILE
];
523 BLI_cleanup_dir(G
.sce
, name
);
524 BLI_split_dirfile(name
, dir
, file
);
526 strcpy(U
.plugseqdir
, dir
);
527 allqueue(REDRAWALL
, 0);
530 static void filesel_u_renderdir(char *name
)
532 char dir
[FILE_MAXDIR
], file
[FILE_MAXFILE
];
534 BLI_cleanup_dir(G
.sce
, name
);
535 BLI_split_dirfile(name
, dir
, file
);
537 strcpy(U
.renderdir
, dir
);
538 allqueue(REDRAWALL
, 0);
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);
552 static void filesel_u_sounddir(char *name
)
554 char dir
[FILE_MAXDIR
], file
[FILE_MAXFILE
];
556 BLI_cleanup_dir(G
.sce
, name
);
557 BLI_split_dirfile(name
, dir
, file
);
559 strcpy(U
.sounddir
, dir
);
560 allqueue(REDRAWALL
, 0);
563 static void filesel_u_tempdir(char *name
)
565 char dir
[FILE_MAXDIR
], file
[FILE_MAXFILE
];
567 BLI_cleanup_dir(G
.sce
, name
);
568 BLI_split_dirfile(name
, dir
, file
);
570 strcpy(U
.tempdir
, dir
);
571 allqueue(REDRAWALL
, 0);
574 /* END Functions for user preferences fileselect windows */
577 void do_global_buttons(unsigned short event
)
587 ID
*id
, *idtest
, *from
=NULL
;
594 id
= NULL
; /* id at null for texbrowse */
600 scrarea_queue_winredraw(curarea
);
601 scrarea_queue_headredraw(curarea
);
603 update_for_newframe();
606 scrarea_queue_winredraw(curarea
);
607 scrarea_queue_headredraw(curarea
);
610 allqueue(REDRAWVIEW3D
, 0);
611 scrarea_queue_winredraw(curarea
);
612 scrarea_queue_headredraw(curarea
);
616 if(ob
->id
.lib
) return;
620 if(G
.buts
->menunr
== -2) {
621 activate_databrowse((ID
*)G
.buts
->lockpoin
, GS(id
->name
), 0, B_EDITBROWSE
, &G
.buts
->menunr
, do_global_buttons
);
624 if(G
.buts
->menunr
< 0) return;
626 lb
= wich_libbase(G
.main
, GS(id
->name
));
629 if(nr
==G
.buts
->menunr
) {
636 test_object_materials(idtest
);
638 if( GS(idtest
->name
)==ID_CU
) {
641 else if( ob
->type
==OB_ARMATURE
) {
642 armature_rebuild_pose(ob
, ob
->data
);
644 DAG_object_flush_update(G
.scene
, ob
, OB_RECALC_DATA
);
646 allqueue(REDRAWBUTSEDIT
, 0);
647 allqueue(REDRAWVIEW3D
, 0);
648 allqueue(REDRAWACTION
,0);
649 allqueue(REDRAWIPO
, 0);
650 allqueue(REDRAWNLA
,0);
655 idtest
= idtest
->next
;
661 if(ob
->id
.lib
) return;
664 if(id
==0) id
= G
.main
->mesh
.first
;
667 if(G
.buts
->menunr
== -2) {
668 activate_databrowse((ID
*)G
.buts
->lockpoin
, GS(id
->name
), 0, B_MESHBROWSE
, &G
.buts
->menunr
, do_global_buttons
);
671 if(G
.buts
->menunr
< 0) return;
674 idtest
= G
.main
->mesh
.first
;
676 if(nr
==G
.buts
->menunr
) {
677 set_mesh(ob
, (Mesh
*)idtest
);
679 DAG_object_flush_update(G
.scene
, ob
, OB_RECALC_DATA
);
681 BIF_undo_push("Browse Mesh");
682 allqueue(REDRAWBUTSEDIT
, 0);
683 allqueue(REDRAWVIEW3D
, 0);
684 allqueue(REDRAWACTION
,0);
685 allqueue(REDRAWIPO
, 0);
690 idtest
= idtest
->next
;
696 void *lockpoin
= NULL
;
699 /* this is called now from Node editor too, buttons might not exist */
700 if(curarea
->spacetype
==SPACE_NODE
) {
701 SpaceNode
*snode
= curarea
->spacedata
.first
;
702 menunr
= &snode
->menunr
;
706 menunr
= &G
.buts
->menunr
;
707 lockpoin
= G
.buts
->lockpoin
;
712 activate_databrowse((ID
*)lockpoin
, ID_MA
, 0, B_MATBROWSE
, menunr
, do_global_buttons
);
716 if(*menunr
< 0) return;
718 if(0) { /* future pin */
723 ma
= give_current_material(ob
, ob
->actcol
);
728 idtest
= G
.main
->mat
.first
;
734 idtest
= idtest
->next
;
736 if(idtest
==0) { /* new mat */
737 if(id
) idtest
= (ID
*)copy_material((Material
*)id
);
739 idtest
= (ID
*)add_material("Material");
744 assign_material(ob
, (Material
*)idtest
, ob
->actcol
);
746 BIF_undo_push("Browse Material");
747 allqueue(REDRAWBUTSSHADING
, 0);
748 allqueue(REDRAWIPO
, 0);
749 allqueue(REDRAWNODE
, 0);
750 BIF_preview_changed(ID_MA
);
757 if(0) { /* future pin */
761 ma
= give_current_material(ob
, ob
->actcol
);
763 assign_material(ob
, 0, ob
->actcol
);
764 BIF_undo_push("Unlink Material");
765 allqueue(REDRAWBUTSSHADING
, 0);
766 allqueue(REDRAWIPO
, 0);
767 allqueue(REDRAWOOPS
, 0);
768 allqueue(REDRAWVIEW3D
, 0);
769 BIF_preview_changed(ID_MA
);
778 if(G
.buts
->texfrom
==0) { /* from mat */
779 ma
= give_current_material(ob
, ob
->actcol
);
780 ma
= editnode_get_active_material(ma
);
782 mtex
= ma
->mtex
[ ma
->texact
];
784 if(mtex
->tex
) mtex
->tex
->id
.us
--;
786 ma
->mtex
[ ma
->texact
]= NULL
;
787 allqueue(REDRAWBUTSSHADING
, 0);
788 allqueue(REDRAWIPO
, 0);
789 BIF_preview_changed(ID_MA
);
793 else if(G
.buts
->texfrom
==1) { /* from world */
794 wrld
= G
.scene
->world
;
796 mtex
= wrld
->mtex
[ wrld
->texact
];
798 if(mtex
->tex
) mtex
->tex
->id
.us
--;
800 wrld
->mtex
[ wrld
->texact
]= NULL
;
801 allqueue(REDRAWBUTSSHADING
, 0);
802 allqueue(REDRAWIPO
, 0);
803 BIF_preview_changed(ID_WO
);
807 else if(G
.buts
->texfrom
==2) { /* from lamp */
809 if(la
&& ob
->type
==OB_LAMP
) { /* to be sure */
810 mtex
= la
->mtex
[ la
->texact
];
812 if(mtex
->tex
) mtex
->tex
->id
.us
--;
814 la
->mtex
[ la
->texact
]= NULL
;
815 allqueue(REDRAWBUTSSHADING
, 0);
816 allqueue(REDRAWIPO
, 0);
817 BIF_preview_changed(ID_LA
);
821 else { /* from brush */
822 br
= G
.scene
->toolsettings
->imapaint
.brush
;
823 if(G
.f
& G_SCULPTMODE
) {
824 sculptmode_rem_tex(NULL
, NULL
);
825 allqueue(REDRAWBUTSSHADING
, 0);
827 mtex
= br
->mtex
[ br
->texact
];
829 if(mtex
->tex
) mtex
->tex
->id
.us
--;
831 br
->mtex
[ br
->texact
]= NULL
;
832 allqueue(REDRAWBUTSSHADING
, 0);
833 allqueue(REDRAWIMAGE
, 0);
834 allqueue(REDRAWIPO
, 0);
835 /*BIF_preview_changed(ID_BR);*/
839 BIF_undo_push("Unlink Texture");
845 if(G
.buts
->texnr
== -2) {
847 id
= G
.buts
->lockpoin
;
848 if(event
==B_EXTEXBROWSE
) {
850 ma
= give_current_material(ob
, ob
->actcol
);
851 ma
= editnode_get_active_material(ma
);
853 mtex
= ma
->mtex
[ ma
->texact
];
854 if(mtex
) id
= (ID
*)mtex
->tex
;
858 activate_databrowse(id
, ID_TE
, 0, B_TEXBROWSE
, &G
.buts
->texnr
, do_global_buttons
);
861 if(G
.buts
->texnr
< 0) break;
869 ma
= give_current_material(ob
, ob
->actcol
);
870 ma
= editnode_get_active_material(ma
);
872 mtex
= ma
->mtex
[ ma
->texact
];
873 if(mtex
) id
= (ID
*)mtex
->tex
;
876 idtest
= G
.main
->tex
.first
;
878 if(nr
==G
.buts
->texnr
) {
882 idtest
= idtest
->next
;
884 if(idtest
==0) { /* new tex */
885 if(id
) idtest
= (ID
*)copy_texture((Tex
*)id
);
886 else idtest
= (ID
*)add_texture("Tex");
889 if(idtest
!=id
&& ma
) {
891 if( ma
->mtex
[ma
->texact
]==0) ma
->mtex
[ma
->texact
]= add_mtex();
893 ma
->mtex
[ ma
->texact
]->tex
= (Tex
*)idtest
;
897 BIF_undo_push("Browse Texture");
898 allqueue(REDRAWBUTSSHADING
, 0);
899 allqueue(REDRAWIPO
, 0);
900 allqueue(REDRAWOOPS
, 0);
901 BIF_preview_changed(ID_MA
);
911 if(ob
->pose
) { // clear flag, also used for draw colors
913 for(pchan
= ob
->pose
->chanbase
.first
; pchan
; pchan
= pchan
->next
)
916 BIF_undo_push("Unlink Action");
918 allqueue(REDRAWVIEW3D
, 0);
919 allqueue(REDRAWACTION
, 0);
920 allqueue(REDRAWNLA
, 0);
921 allqueue(REDRAWIPO
, 0);
929 if (G
.saction
->actnr
== -2){
930 activate_databrowse((ID
*)G
.saction
->action
, ID_AC
, 0, B_ACTIONBROWSE
, &G
.saction
->actnr
, do_global_buttons
);
934 if(G
.saction
->actnr
< 0) break;
936 /* See if we have selected a valid action */
937 for (idtest
= G
.main
->action
.first
; idtest
; idtest
= idtest
->next
) {
938 if(nr
==G
.saction
->actnr
) {
946 G
.saction
->action
= (bAction
*)idtest
;
947 allqueue(REDRAWACTION
, 0);
951 /* Store current action */
954 idtest
= (ID
*)copy_action(act
);
956 if (ID_OB
==ob
->type
) {
957 idtest
=(ID
*)add_empty_action("ObAction");
959 idtest
=(ID
*)add_empty_action("Action");
966 if(idtest
!=id
&& ob
) {
967 act
= (bAction
*)idtest
;
975 BIF_undo_push("Browse Action");
976 do_global_buttons (B_NEWFRAME
);
977 allqueue(REDRAWVIEW3D
, 0);
978 allqueue(REDRAWNLA
, 0);
979 allqueue(REDRAWACTION
, 0);
980 allqueue(REDRAWHEADERS
, 0);
990 if(from
==NULL
) return;
992 if(G
.sipo
->menunr
== -2) {
993 activate_databrowse((ID
*)G
.sipo
->ipo
, ID_IP
, G
.sipo
->blocktype
, B_IPOBROWSE
, &G
.sipo
->menunr
, do_global_buttons
);
997 if(G
.sipo
->menunr
< 0) break;
999 idtest
= G
.main
->ipo
.first
;
1001 if( ((Ipo
*)idtest
)->blocktype
== G
.sipo
->blocktype
) {
1002 if(nr
==G
.sipo
->menunr
) {
1007 idtest
= idtest
->next
;
1012 G
.sipo
->ipo
= (Ipo
*)idtest
;
1013 allspace(REMAKEIPO
, 0); // in fact it should only do this one, but there is no function for it
1017 // assign the ipo to ...
1020 if(ipo
) idtest
= (ID
*)copy_ipo(ipo
);
1022 nr
= G
.sipo
->blocktype
;
1023 if(nr
==ID_OB
) idtest
= (ID
*)add_ipo("ObIpo", ID_OB
);
1024 else if(nr
==ID_CO
) idtest
= (ID
*)add_ipo("CoIpo", ID_CO
);
1025 else if(nr
==ID_PO
) idtest
= (ID
*)add_ipo("ActIpo", nr
);
1026 else if(nr
==ID_MA
) idtest
= (ID
*)add_ipo("MatIpo", nr
);
1027 else if(nr
==ID_TE
) idtest
= (ID
*)add_ipo("TexIpo", nr
);
1028 else if(nr
==ID_SEQ
) idtest
= (ID
*)add_ipo("MatSeq", nr
);
1029 else if(nr
==ID_CU
) idtest
= (ID
*)add_ipo("CuIpo", nr
);
1030 else if(nr
==ID_KE
) idtest
= (ID
*)add_ipo("KeyIpo", nr
);
1031 else if(nr
==ID_WO
) idtest
= (ID
*)add_ipo("WoIpo", nr
);
1032 else if(nr
==ID_LA
) idtest
= (ID
*)add_ipo("LaIpo", nr
);
1033 else if(nr
==ID_CA
) idtest
= (ID
*)add_ipo("CaIpo", nr
);
1034 else if(nr
==ID_SO
) idtest
= (ID
*)add_ipo("SndIpo", nr
);
1035 else if(nr
==ID_FLUIDSIM
) idtest
= (ID
*)add_ipo("FluidsimIpo", nr
);
1036 else error("Warn bugtracker!");
1040 if(idtest
!=id
&& from
) {
1041 spaceipo_assign_ipo(G
.sipo
, (Ipo
*)idtest
);
1043 BIF_undo_push("Browse Ipo");
1051 spaceipo_assign_ipo(G
.sipo
, NULL
);
1053 editipo_changed(G
.sipo
, 1); /* doredraw */
1055 BIF_undo_push("Unlink Ipo");
1060 if(G
.buts
->menunr
==-2) {
1061 activate_databrowse((ID
*)G
.scene
->world
, ID_WO
, 0, B_WORLDBROWSE
, &G
.buts
->menunr
, do_global_buttons
);
1065 if(G
.buts
->menunr
< 0) break;
1068 wrld
= G
.scene
->world
;
1073 idtest
= G
.main
->world
.first
;
1075 if(nr
==G
.buts
->menunr
) {
1079 idtest
= idtest
->next
;
1081 if(idtest
==0) { /* new world */
1082 if(id
) idtest
= (ID
*)copy_world((World
*)id
);
1083 else idtest
= (ID
*)add_world("World");
1087 G
.scene
->world
= (World
*)idtest
;
1091 BIF_undo_push("Browse World");
1092 allqueue(REDRAWBUTSSHADING
, 0);
1093 allqueue(REDRAWIPO
, 0);
1094 allqueue(REDRAWOOPS
, 0);
1095 BIF_preview_changed(ID_WO
);
1099 if(G
.scene
->world
) {
1100 G
.scene
->world
->id
.us
--;
1101 G
.scene
->world
= NULL
;
1103 BIF_undo_push("Unlink World");
1104 allqueue(REDRAWBUTSSHADING
, 0);
1105 allqueue(REDRAWIPO
, 0);
1111 if(G
.buts
->texnr
== -2) {
1113 wrld
= G
.scene
->world
;
1115 mtex
= wrld
->mtex
[ wrld
->texact
];
1116 if(mtex
) id
= (ID
*)mtex
->tex
;
1119 activate_databrowse((ID
*)id
, ID_TE
, 0, B_WTEXBROWSE
, &G
.buts
->texnr
, do_global_buttons
);
1122 if(G
.buts
->texnr
< 0) break;
1130 wrld
= G
.scene
->world
;
1132 mtex
= wrld
->mtex
[ wrld
->texact
];
1133 if(mtex
) id
= (ID
*)mtex
->tex
;
1136 idtest
= G
.main
->tex
.first
;
1138 if(nr
==G
.buts
->texnr
) {
1142 idtest
= idtest
->next
;
1144 if(idtest
==0) { /* new tex */
1145 if(id
) idtest
= (ID
*)copy_texture((Tex
*)id
);
1146 else idtest
= (ID
*)add_texture("Tex");
1149 if(idtest
!=id
&& wrld
) {
1151 if( wrld
->mtex
[wrld
->texact
]==0) {
1152 wrld
->mtex
[wrld
->texact
]= add_mtex();
1153 wrld
->mtex
[wrld
->texact
]->texco
= TEXCO_VIEW
;
1155 wrld
->mtex
[ wrld
->texact
]->tex
= (Tex
*)idtest
;
1159 BIF_undo_push("Texture browse");
1160 allqueue(REDRAWBUTSSHADING
, 0);
1161 allqueue(REDRAWIPO
, 0);
1162 allqueue(REDRAWOOPS
, 0);
1163 BIF_preview_changed(ID_WO
);
1170 if(ob
->type
!=OB_LAMP
) return;
1172 if(G
.buts
->menunr
== -2) {
1173 activate_databrowse((ID
*)G
.buts
->lockpoin
, ID_LA
, 0, B_LAMPBROWSE
, &G
.buts
->menunr
, do_global_buttons
);
1176 if(G
.buts
->menunr
< 0) break;
1182 idtest
= G
.main
->lamp
.first
;
1184 if(nr
==G
.buts
->menunr
) {
1188 idtest
= idtest
->next
;
1190 if(idtest
==0) { /* no new lamp */
1194 ob
->data
= (Lamp
*)idtest
;
1198 BIF_undo_push("Lamp browse");
1199 allqueue(REDRAWBUTSSHADING
, 0);
1200 allqueue(REDRAWVIEW3D
, 0);
1201 allqueue(REDRAWIPO
, 0);
1202 allqueue(REDRAWOOPS
, 0);
1203 BIF_preview_changed(ID_LA
);
1210 if(ob
->type
!=OB_LAMP
) return;
1212 if(G
.buts
->texnr
== -2) {
1215 mtex
= la
->mtex
[ la
->texact
];
1216 if(mtex
) id
= (ID
*)mtex
->tex
;
1218 activate_databrowse(id
, ID_TE
, 0, B_LTEXBROWSE
, &G
.buts
->texnr
, do_global_buttons
);
1221 if(G
.buts
->texnr
< 0) break;
1230 mtex
= la
->mtex
[ la
->texact
];
1231 if(mtex
) id
= (ID
*)mtex
->tex
;
1233 idtest
= G
.main
->tex
.first
;
1235 if(nr
==G
.buts
->texnr
) {
1239 idtest
= idtest
->next
;
1241 if(idtest
==0) { /* new tex */
1242 if(id
) idtest
= (ID
*)copy_texture((Tex
*)id
);
1243 else idtest
= (ID
*)add_texture("Tex");
1246 if(idtest
!=id
&& la
) {
1248 if( la
->mtex
[la
->texact
]==0) {
1249 la
->mtex
[la
->texact
]= add_mtex();
1250 la
->mtex
[la
->texact
]->texco
= TEXCO_GLOB
;
1252 la
->mtex
[ la
->texact
]->tex
= (Tex
*)idtest
;
1256 BIF_undo_push("Texture Browse");
1257 allqueue(REDRAWBUTSSHADING
, 0);
1258 allqueue(REDRAWIPO
, 0);
1259 allqueue(REDRAWOOPS
, 0);
1260 BIF_preview_changed(ID_LA
);
1267 if(G
.sima
->image
&& BLI_streq(G
.sima
->image
->id
.name
+2, "Render Result")==0) {
1268 /* Run on non render images, unlink normally */
1269 G
.sima
->image
= NULL
;
1270 image_changed(G
.sima
, 0);
1271 BIF_undo_push("Unlink Image");
1272 allqueue(REDRAWIMAGE
, 0);
1274 /* Run if G.sima is render, remove the render and display the meshes image if it exists */
1275 G
.sima
->image
= NULL
;
1277 allqueue(REDRAWIMAGE
, 0);
1282 /* this is called now from Node editor too, buttons might not exist */
1283 if(curarea
->spacetype
==SPACE_NODE
) {
1284 SpaceNode
*snode
= curarea
->spacedata
.first
;
1285 automatname((Material
*)snode
->id
);
1288 automatname(G
.buts
->lockpoin
);
1292 BIF_undo_push("Auto name");
1293 allqueue(REDRAWBUTSSHADING
, 0);
1294 allqueue(REDRAWNODE
, 0);
1295 allqueue(REDRAWOOPS
, 0);
1298 if(G
.buts
->mainb
==CONTEXT_SHADING
) {
1299 if(G
.buts
->tab
[CONTEXT_SHADING
]==TAB_SHADING_TEX
) {
1300 autotexname(G
.buts
->lockpoin
);
1302 else if(G
.buts
->tab
[CONTEXT_SHADING
]==TAB_SHADING_MAT
) {
1303 ma
= G
.buts
->lockpoin
;
1304 if(ma
->mtex
[ ma
->texact
]) autotexname(ma
->mtex
[ma
->texact
]->tex
);
1306 else if(G
.buts
->tab
[CONTEXT_SHADING
]==TAB_SHADING_WORLD
) {
1307 wrld
= G
.buts
->lockpoin
;
1308 if(wrld
->mtex
[ wrld
->texact
]) autotexname(wrld
->mtex
[wrld
->texact
]->tex
);
1310 else if(G
.buts
->tab
[CONTEXT_SHADING
]==TAB_SHADING_LAMP
) {
1311 la
= G
.buts
->lockpoin
;
1312 if(la
->mtex
[ la
->texact
]) autotexname(la
->mtex
[la
->texact
]->tex
);
1314 BIF_undo_push("Auto name");
1315 allqueue(REDRAWBUTSSHADING
, 0);
1316 allqueue(REDRAWOOPS
, 0);
1317 allqueue(REDRAWIMAGE
, 0);
1319 else if(G
.buts
->mainb
==CONTEXT_EDITING
) {
1320 SculptData
*sd
= &G
.scene
->sculptdata
;
1321 if(sd
&& sd
->texact
!= -1) {
1322 if(sd
->mtex
[sd
->texact
]) autotexname(sd
->mtex
[sd
->texact
]->tex
);
1324 BIF_undo_push("Auto name");
1325 allqueue(REDRAWBUTSEDIT
, 0);
1326 allqueue(REDRAWOOPS
, 0);
1331 case B_RESETAUTOSAVE
:
1333 allqueue(REDRAWINFO
, 0);
1336 SYS_WriteCommandLineInt(SYS_GetSystem(), "noaudio", (U
.gameflags
& USER_DISABLE_SOUND
));
1341 case B_MIPMAPCHANGED
:
1342 set_mipmap(!(U
.gameflags
& USER_DISABLE_MIPMAP
));
1343 allqueue(REDRAWVIEW3D
, 0);
1345 case B_GLRESLIMITCHANGED
:
1346 free_all_realtime_images(); /* force reloading with new res limit */
1347 allqueue(REDRAWVIEW3D
, 0);
1350 newspace(curarea
, curarea
->butspacetype
);
1352 case B_LOADTEMP
: /* is button from space.c */
1353 BIF_read_autosavefile();
1357 allqueue(REDRAWINFO
, 0);
1360 case B_DRAWINFO
: /* is button from space.c *info* */
1361 allqueue(REDRAWVIEW3D
, 0);
1364 case B_PLAINMENUS
: /* is button from space.c *info* */
1368 case B_FLIPINFOMENU
: /* is button from space.c *info* */
1369 scrarea_queue_headredraw(curarea
);
1373 //#ifdef _WIN32 // FULLSCREEN
1374 case B_FLIPFULLSCREEN
:
1375 if(U
.uiflag
& USER_FLIPFULLSCREEN
)
1376 U
.uiflag
&= ~USER_FLIPFULLSCREEN
;
1378 U
.uiflag
|= USER_FLIPFULLSCREEN
;
1379 mainwindow_toggle_fullscreen((U
.uiflag
& USER_FLIPFULLSCREEN
));
1383 /* Fileselect windows for user preferences file paths */
1385 /* yafray: xml export dir. select */
1386 case B_YAFRAYDIRFILESEL
: /* space.c */
1387 if(curarea
->spacetype
==SPACE_INFO
) {
1388 sa
= closest_bigger_area();
1389 areawinset(sa
->win
);
1392 activate_fileselect(FILE_SPECIAL
, "SELECT YFEXPORT PATH", U
.yfexportdir
, filesel_u_yfexportdir
);
1395 case B_FONTDIRFILESEL
: /* is button from space.c *info* */
1396 if(curarea
->spacetype
==SPACE_INFO
) {
1397 sa
= closest_bigger_area();
1398 areawinset(sa
->win
);
1401 activate_fileselect(FILE_SPECIAL
, "SELECT FONT PATH", U
.fontdir
, filesel_u_fontdir
);
1404 case B_TEXTUDIRFILESEL
: /* is button from space.c *info* */
1405 if(curarea
->spacetype
==SPACE_INFO
) {
1406 sa
= closest_bigger_area();
1407 areawinset(sa
->win
);
1410 activate_fileselect(FILE_SPECIAL
, "SELECT TEXTURE PATH", U
.textudir
, filesel_u_textudir
);
1413 case B_PLUGTEXDIRFILESEL
: /* is button form space.c *info* */
1414 if(curarea
->spacetype
==SPACE_INFO
) {
1415 sa
= closest_bigger_area();
1416 areawinset(sa
->win
);
1419 activate_fileselect(FILE_SPECIAL
, "SELECT TEX PLUGIN PATH", U
.plugtexdir
, filesel_u_plugtexdir
);
1422 case B_PLUGSEQDIRFILESEL
: /* is button from space.c *info* */
1423 if(curarea
->spacetype
==SPACE_INFO
) {
1424 sa
= closest_bigger_area();
1425 areawinset(sa
->win
);
1428 activate_fileselect(FILE_SPECIAL
, "SELECT SEQ PLUGIN PATH", U
.plugseqdir
, filesel_u_plugseqdir
);
1431 case B_RENDERDIRFILESEL
: /* is button from space.c *info* */
1432 if(curarea
->spacetype
==SPACE_INFO
) {
1433 sa
= closest_bigger_area();
1434 areawinset(sa
->win
);
1437 activate_fileselect(FILE_SPECIAL
, "SELECT RENDER PATH", U
.renderdir
, filesel_u_renderdir
);
1440 case B_PYMENUEVAL
: /* is button from space.c *info* */
1441 waitcursor( 1 ); /* can take some time */
1442 BPyMenu_RemoveAllEntries(); /* free old data */
1443 if (BPyMenu_Init(1) == -1) { /* re-eval scripts registration in menus */
1445 error("Invalid scripts dir: check console");
1449 case B_PYTHONDIRFILESEL
: /* is button from space.c *info* */
1450 if(curarea
->spacetype
==SPACE_INFO
) {
1451 sa
= closest_bigger_area();
1452 areawinset(sa
->win
);
1455 activate_fileselect(FILE_SPECIAL
, "SELECT SCRIPT PATH", U
.pythondir
, filesel_u_pythondir
);
1458 case B_SOUNDDIRFILESEL
: /* is button from space.c *info* */
1459 if(curarea
->spacetype
==SPACE_INFO
) {
1460 sa
= closest_bigger_area();
1461 areawinset(sa
->win
);
1464 activate_fileselect(FILE_SPECIAL
, "SELECT SOUND PATH", U
.sounddir
, filesel_u_sounddir
);
1467 case B_TEMPDIRFILESEL
: /* is button from space.c *info* */
1468 if(curarea
->spacetype
==SPACE_INFO
) {
1469 sa
= closest_bigger_area();
1470 areawinset(sa
->win
);
1473 activate_fileselect(FILE_SPECIAL
, "SELECT TEMP FILE PATH", U
.tempdir
, filesel_u_tempdir
);
1476 /* END Fileselect windows for user preferences file paths */
1478 #ifdef INTERNATIONAL
1479 case B_LOADUIFONT
: /* is button from space.c *info* */
1480 if(curarea
->spacetype
==SPACE_INFO
) {
1481 sa
= closest_bigger_area();
1482 areawinset(sa
->win
);
1484 BLI_make_file_string("/", buf
, U
.fontdir
, U
.fontname
);
1485 activate_fileselect(FILE_SPECIAL
, "LOAD UI FONT", buf
, set_interface_font
);
1488 case B_SETLANGUAGE
: /* is button from space.c *info* */
1490 allqueue(REDRAWALL
, 0);
1493 case B_SETFONTSIZE
: /* is button from space.c *info* */
1494 refresh_interface_font();
1495 FTF_SetSize(U
.fontsize
);
1496 allqueue(REDRAWALL
, 0);
1499 case B_SETTRANSBUTS
: /* is button from space.c *info* */
1500 allqueue(REDRAWALL
, 0);
1503 case B_RESTOREFONT
: /* is button from space.c *info* */
1505 start_interface_font();
1506 allqueue(REDRAWALL
, 0);
1509 case B_USETEXTUREFONT
: /* is button from space.c *info* */
1510 refresh_interface_font();
1511 allqueue(REDRAWALL
, 0);
1514 case B_DOLANGUIFONT
: /* is button from space.c *info* */
1515 if(U
.transopts
& USER_DOTRANSLATE
)
1516 start_interface_font();
1518 G
.ui_international
= FALSE
;
1519 allqueue(REDRAWALL
, 0);
1524 if(curarea
->spacetype
!=SPACE_INFO
) {
1530 /* changing a metaballs name, sadly enough,
1531 * can require it to be updated because its
1532 * basis might have changed... -zr
1534 if (ob
&& ob
->type
==OB_MBALL
) {
1535 DAG_scene_sort(G
.scene
);
1536 DAG_object_flush_update(G
.scene
, ob
, OB_RECALC_DATA
);
1538 /* redraw because name has changed: new pup */
1539 scrarea_queue_headredraw(curarea
);
1540 allqueue(REDRAWINFO
, 1);
1541 allqueue(REDRAWOOPS
, 1);
1542 allqueue(REDRAWACTION
, 1);
1543 allqueue(REDRAWNLA
, 1);
1544 /* name scene also in set PUPmenu */
1545 allqueue(REDRAWBUTSALL
, 0);
1546 allqueue(REDRAWIMAGE
, 0);
1547 allqueue(REDRAWHEADERS
, 0);
1551 /* keep datablock. similar to pressing FKEY in a fileselect window
1552 * maybe we can move that stuff to a seperate function? -- sg
1554 if (curarea
->spacetype
==SPACE_BUTS
) {
1555 id
= (ID
*)G
.buts
->lockpoin
;
1556 } else if(curarea
->spacetype
==SPACE_IPO
) {
1557 id
= (ID
*)G
.sipo
->ipo
;
1558 } else if(curarea
->spacetype
==SPACE_NODE
) {
1559 id
= ((SpaceNode
*)curarea
->spacedata
.first
)->id
;
1560 } /* similar for other spacetypes ? */
1562 /* flag was already toggled, just need to update user count */
1563 if(id
->flag
& LIB_FAKEUSER
)
1568 allqueue(REDRAWHEADERS
, 0);
1576 void do_global_buttons2(short event
)
1593 /* general: Single User is allowed when from==LOCAL
1594 * Make Local is allowed when (from==LOCAL && id==LIB)
1597 if(event
<B_LOCAL_ALONE
) return;
1604 if(ob
&& ob
->id
.lib
==0) {
1607 if(okee("Single user")) {
1608 ob
->data
= copy_lamp(la
);
1615 if(ob
&& ob
->id
.lib
==0) {
1618 if(okee("Make local")) {
1619 make_local_lamp(la
);
1626 if (ob
&&ob
->id
.lib
==0){
1627 bArmature
*arm
=ob
->data
;
1629 if(okee("Make local")) {
1630 make_local_armature(arm
);
1636 if(ob
&& ob
->id
.lib
==0) {
1637 bArmature
*arm
=ob
->data
;
1639 if(okee("Single user")) {
1640 ob
->data
= copy_armature(arm
);
1641 armature_rebuild_pose(ob
, ob
->data
);
1648 if(ob
&& ob
->id
.lib
==0) {
1651 if(okee("Make local")) {
1652 make_local_action(act
);
1653 allqueue(REDRAWACTION
,0);
1659 if(ob
&& ob
->id
.lib
==0) {
1663 if(okee("Single user")) {
1664 ob
->action
=copy_action(act
);
1666 allqueue(REDRAWACTION
, 0);
1673 if(ob
&& ob
->id
.lib
==0) {
1674 Camera
*ca
= ob
->data
;
1676 if(okee("Single user")) {
1677 ob
->data
= copy_camera(ca
);
1684 if(ob
&& ob
->id
.lib
==0) {
1685 Camera
*ca
= ob
->data
;
1687 if(okee("Make local")) {
1688 make_local_camera(ca
);
1694 wrld
= G
.scene
->world
;
1696 if(okee("Single user")) {
1697 G
.scene
->world
= copy_world(wrld
);
1703 wrld
= G
.scene
->world
;
1704 if(wrld
&& wrld
->id
.lib
) {
1705 if(okee("Make local")) {
1706 make_local_world(wrld
);
1712 if(ob
&& ob
->id
.lib
==0) {
1715 if(okee("Single user")) {
1716 ob
->data
= copy_lattice(lt
);
1723 if(ob
&& ob
->id
.lib
==0) {
1726 if(okee("Make local")) {
1727 make_local_lattice(lt
);
1735 ma
= give_current_material(ob
, ob
->actcol
);
1736 idfrom
= material_from(ob
, ob
->actcol
);
1737 if(idfrom
&& idfrom
->lib
==0) {
1739 if(okee("Single user")) {
1740 ma
= copy_material(ma
);
1742 assign_material(ob
, ma
, ob
->actcol
);
1749 idfrom
= material_from(ob
, ob
->actcol
);
1750 if(idfrom
->lib
==0) {
1751 ma
= give_current_material(ob
, ob
->actcol
);
1752 if(ma
&& ma
->id
.lib
) {
1753 if(okee("Make local")) {
1754 make_local_material(ma
);
1761 if(ob
&& ob
->id
.lib
==0) {
1763 if(me
&& me
->id
.lib
) {
1764 if(okee("Make local")) {
1765 make_local_mesh(me
);
1766 make_local_key( me
->key
);
1768 DAG_object_flush_update(G
.scene
, ob
, OB_RECALC_DATA
);
1775 if(ob
&& ob
->id
.lib
==0) {
1778 if(okee("Single user")) {
1779 ob
->data
= copy_mball(mb
);
1781 if(ob
==G
.obedit
) allqueue(REDRAWVIEW3D
, 0);
1787 if(ob
&& ob
->id
.lib
==0) {
1790 if(okee("Make local")) {
1791 make_local_mball(mb
);
1798 if(ob
&& ob
->id
.lib
==0) {
1801 if(okee("Single user")) {
1802 ob
->data
= copy_curve(cu
);
1804 DAG_object_flush_update(G
.scene
, ob
, OB_RECALC_DATA
);
1805 if(ob
==G
.obedit
) allqueue(REDRAWVIEW3D
, 0);
1811 if(ob
&& ob
->id
.lib
==0) {
1814 if(okee("Make local")) {
1815 make_local_curve(cu
);
1816 make_local_key( cu
->key
);
1817 DAG_object_flush_update(G
.scene
, ob
, OB_RECALC_DATA
);
1824 if(G
.buts
->texfrom
==0) { /* from mat */
1826 ma
= give_current_material(ob
, ob
->actcol
);
1827 ma
= editnode_get_active_material(ma
);
1828 if(ma
&& ma
->id
.lib
==0) {
1829 mtex
= ma
->mtex
[ ma
->texact
];
1830 if(mtex
->tex
&& mtex
->tex
->id
.us
>1) {
1831 if(okee("Single user")) {
1833 mtex
->tex
= copy_texture(mtex
->tex
);
1838 else if(G
.buts
->texfrom
==1) { /* from world */
1839 wrld
= G
.scene
->world
;
1840 if(wrld
->id
.lib
==0) {
1841 mtex
= wrld
->mtex
[ wrld
->texact
];
1842 if(mtex
->tex
&& mtex
->tex
->id
.us
>1) {
1843 if(okee("Single user")) {
1845 mtex
->tex
= copy_texture(mtex
->tex
);
1850 else if(G
.buts
->texfrom
==2) { /* from lamp */
1851 if(ob
==0 || ob
->type
!=OB_LAMP
) return;
1854 mtex
= la
->mtex
[ la
->texact
];
1855 if(mtex
->tex
&& mtex
->tex
->id
.us
>1) {
1856 if(okee("Single user")) {
1858 mtex
->tex
= copy_texture(mtex
->tex
);
1863 else if(G
.buts
->texfrom
==3) { /* from brush */
1864 br
= G
.scene
->toolsettings
->imapaint
.brush
;
1867 mtex
= br
->mtex
[ br
->texact
];
1868 if(mtex
->tex
&& mtex
->tex
->id
.us
>1) {
1869 if(okee("Single user")) {
1871 mtex
->tex
= copy_texture(mtex
->tex
);
1872 allqueue(REDRAWIMAGE
, 0);
1879 if(G
.buts
->texfrom
==0) { /* from mat */
1881 ma
= give_current_material(ob
, ob
->actcol
);
1882 ma
= editnode_get_active_material(ma
);
1883 if(ma
&& ma
->id
.lib
==0) {
1884 mtex
= ma
->mtex
[ ma
->texact
];
1885 if(mtex
->tex
&& mtex
->tex
->id
.lib
) {
1886 if(okee("Make local")) {
1887 make_local_texture(mtex
->tex
);
1892 else if(G
.buts
->texfrom
==1) { /* from world */
1893 wrld
= G
.scene
->world
;
1894 if(wrld
->id
.lib
==0) {
1895 mtex
= wrld
->mtex
[ wrld
->texact
];
1896 if(mtex
->tex
&& mtex
->tex
->id
.lib
) {
1897 if(okee("Make local")) {
1898 make_local_texture(mtex
->tex
);
1903 else if(G
.buts
->texfrom
==2) { /* from lamp */
1904 if(ob
==0 || ob
->type
!=OB_LAMP
) return;
1907 mtex
= la
->mtex
[ la
->texact
];
1908 if(mtex
->tex
&& mtex
->tex
->id
.lib
) {
1909 if(okee("Make local")) {
1910 make_local_texture(mtex
->tex
);
1915 else if(G
.buts
->texfrom
==3) { /* from brush */
1916 br
= G
.scene
->toolsettings
->imapaint
.brush
;
1919 mtex
= br
->mtex
[ br
->texact
];
1920 if(mtex
->tex
&& mtex
->tex
->id
.lib
) {
1921 if(okee("Make local")) {
1922 make_local_texture(mtex
->tex
);
1923 allqueue(REDRAWIMAGE
, 0);
1932 idfrom
= G
.sipo
->from
;
1934 if(idfrom
&& idfrom
->lib
==NULL
) {
1936 if(okee("Single user")) {
1938 ipo
->id
.us
= 0; /* assign_ipo adds users, copy_ipo sets to 1 */
1939 spaceipo_assign_ipo(G
.sipo
, ipo
);
1940 allqueue(REDRAWIPO
, 0);
1947 idfrom
= G
.sipo
->from
;
1949 if(idfrom
&& idfrom
->lib
==0) {
1951 if(okee("Make local")) {
1952 make_local_ipo(ipo
);
1953 allqueue(REDRAWIPO
, 0);
1960 if(G
.scene
->id
.lib
==0) {
1962 if(okee("Single user")) {
1965 if(base
->object
==ob
) {
1966 base
->object
= copy_object(ob
);
1968 allqueue(REDRAWVIEW3D
, 0);
1978 if(G
.scene
->id
.lib
==0) {
1980 if(okee("Make local")) {
1981 make_local_object(ob
);
1982 allqueue(REDRAWVIEW3D
, 0);
1988 if(ob
&& ob
->id
.lib
==0) {
1992 if(me
&& me
->id
.us
>1) {
1993 if(okee("Single user")) {
1994 Mesh
*men
= copy_mesh(me
);
1999 DAG_object_flush_update(G
.scene
, ob
, OB_RECALC_DATA
);
2001 if(ob
==G
.obedit
) allqueue(REDRAWVIEW3D
, 0);
2008 BIF_undo_push("Make single user or local");
2009 allqueue(REDRAWBUTSALL
, 0);
2010 allqueue(REDRAWOOPS
, 0);
2013 /* ******************** GENERAL ********************** */
2015 void do_headerbuttons(short event
)
2018 if(event
<=50) do_global_buttons2(event
);
2019 else if(event
<=100) do_global_buttons(event
);
2020 else if(event
<200) do_view3d_buttons(event
);
2021 else if(event
<250) do_ipo_buttons(event
);
2022 else if(event
<300) do_oops_buttons(event
);
2023 else if(event
<350) do_info_buttons(event
);
2024 else if(event
<400) do_image_buttons(event
);
2025 else if(event
<450) do_buts_buttons(event
);
2026 else if(event
<500) do_imasel_buttons(event
);
2027 else if(event
<525) do_text_buttons(event
);
2028 else if(event
<550) do_script_buttons(event
);
2029 else if(event
<600) do_file_buttons(event
);
2030 else if(event
<650) do_seq_buttons(event
);
2031 else if(event
<700) do_sound_buttons(event
);
2032 else if(event
<750) do_action_buttons(event
);
2033 else if(event
<800) do_time_buttons(curarea
, event
);
2034 else if(event
<850) do_nla_buttons(event
);
2035 else if(event
<900) do_node_buttons(curarea
, event
);
2036 else if(event
>=REDRAWVIEW3D
) allqueue(event
, 0);