58563166847be8b86b3b74f80aac234cca31b808
[blender.git] / source / blender / editors / interface / interface_utils.c
1 /**
2  * ***** BEGIN GPL LICENSE BLOCK *****
3  *
4  * This program is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU General Public License
6  * as published by the Free Software Foundation; either version 2
7  * of the License, or (at your option) any later version. 
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software Foundation,
16  * Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
17  *
18  * The Original Code is Copyright (C) 2009 Blender Foundation.
19  * All rights reserved.
20  * 
21  * Contributor(s): Blender Foundation
22  *
23  * ***** END GPL LICENSE BLOCK *****
24  */
25
26 #include <math.h>
27 #include <stdlib.h>
28 #include <string.h>
29
30 #include "MEM_guardedalloc.h"
31
32 #include "DNA_action_types.h"
33 #include "DNA_color_types.h"
34 #include "DNA_listBase.h"
35 #include "DNA_material_types.h"
36 #include "DNA_object_types.h"
37 #include "DNA_screen_types.h"
38 #include "DNA_windowmanager_types.h"
39
40 #include "BKE_colortools.h"
41 #include "BKE_context.h"
42 #include "BKE_idprop.h"
43 #include "BKE_library.h"
44 #include "BKE_main.h"
45 #include "BKE_utildefines.h"
46
47 #include "RNA_access.h"
48
49 #include "UI_interface.h"
50 #include "UI_resources.h"
51
52 #include "ED_screen.h"
53 #include "ED_util.h"
54
55 #include "WM_api.h"
56 #include "WM_types.h"
57
58 #define DEF_BUT_WIDTH           150
59 #define DEF_ICON_BUT_WIDTH      20
60 #define DEF_BUT_HEIGHT          20
61
62 /*************************** RNA Utilities ******************************/
63
64 int UI_GetIconRNA(PointerRNA *ptr)
65 {
66         StructRNA *rnatype= ptr->type;
67
68         if(rnatype == &RNA_Scene)
69                 return ICON_SCENE_DATA;
70         else if(rnatype == &RNA_World)
71                 return ICON_WORLD_DATA;
72         else if(rnatype == &RNA_Object)
73                 return ICON_OBJECT_DATA;
74         else if(rnatype == &RNA_Mesh)
75                 return ICON_MESH_DATA;
76         else if(rnatype == &RNA_MeshVertex)
77                 return ICON_VERTEXSEL;
78         else if(rnatype == &RNA_MeshEdge)
79                 return ICON_EDGESEL;
80         else if(rnatype == &RNA_MeshFace)
81                 return ICON_FACESEL;
82         else if(rnatype == &RNA_MeshTextureFace)
83                 return ICON_FACESEL_HLT;
84         else if(rnatype == &RNA_VertexGroup)
85                 return ICON_VGROUP;
86         else if(rnatype == &RNA_VertexGroupElement)
87                 return ICON_VGROUP;
88         else if(rnatype == &RNA_Curve)
89                 return ICON_CURVE_DATA;
90         else if(rnatype == &RNA_MetaBall)
91                 return ICON_MBALL_DATA;
92         else if(rnatype == &RNA_MetaElement)
93                 return ICON_OUTLINER_DATA_META;
94         else if(rnatype == &RNA_Lattice)
95                 return ICON_LATTICE_DATA;
96         else if(rnatype == &RNA_Armature)
97                 return ICON_ARMATURE_DATA;
98         else if(rnatype == &RNA_Bone)
99                 return ICON_BONE_DATA;
100         else if(rnatype == &RNA_Camera)
101                 return ICON_CAMERA_DATA;
102         else if(rnatype == &RNA_LocalLamp)
103                 return ICON_LAMP_DATA;
104         else if(rnatype == &RNA_AreaLamp)
105                 return ICON_LAMP_DATA;
106         else if(rnatype == &RNA_SpotLamp)
107                 return ICON_LAMP_DATA;
108         else if(rnatype == &RNA_SunLamp)
109                 return ICON_LAMP_DATA;
110         else if(rnatype == &RNA_HemiLamp)
111                 return ICON_LAMP_DATA;
112         else if(rnatype == &RNA_Lamp)
113                 return ICON_LAMP_DATA;
114         else if(rnatype == &RNA_Group)
115                 return ICON_GROUP;
116         else if(rnatype == &RNA_ParticleSystem)
117                 return ICON_PARTICLE_DATA;
118         else if(rnatype == &RNA_ParticleSettings)
119                 return ICON_PARTICLE_DATA;
120         else if(rnatype == &RNA_Material)
121                 return ICON_MATERIAL_DATA;
122         else if(rnatype == &RNA_Texture)
123                 return ICON_TEXTURE_DATA;
124         else if(rnatype == &RNA_TextureSlot)
125                 return ICON_TEXTURE_DATA;
126         else if(rnatype == &RNA_WorldTextureSlot)
127                 return ICON_TEXTURE_DATA;
128         else if(rnatype == &RNA_MaterialTextureSlot)
129                 return ICON_TEXTURE_DATA;
130         else if(rnatype == &RNA_Image)
131                 return ICON_IMAGE_DATA;
132         else if(rnatype == &RNA_Screen)
133                 return ICON_SPLITSCREEN;
134         else if(rnatype == &RNA_NodeTree)
135                 return ICON_NODE;
136         else if(rnatype == &RNA_Text)
137                 return ICON_TEXT;
138         else if(rnatype == &RNA_Sound)
139                 return ICON_SOUND;
140         else if(rnatype == &RNA_Brush)
141                 return ICON_BRUSH_DATA;
142         else if(rnatype == &RNA_VectorFont)
143                 return ICON_FONT;
144         else if(rnatype == &RNA_Library)
145                 return ICON_LIBRARY_DATA_DIRECT;
146         else if(rnatype == &RNA_Action)
147                 return ICON_ACTION;
148         else if(rnatype == &RNA_FCurve)
149                 return ICON_ANIM_DATA;
150         //else if(rnatype == &RNA_Ipo)
151         //      return ICON_ANIM_DATA;
152         else if(rnatype == &RNA_Key)
153                 return ICON_SHAPEKEY_DATA;
154         else if(rnatype == &RNA_Main)
155                 return ICON_BLENDER;
156         else if(rnatype == &RNA_Struct)
157                 return ICON_RNA;
158         else if(rnatype == &RNA_Property)
159                 return ICON_RNA;
160         else if(rnatype == &RNA_BooleanProperty)
161                 return ICON_RNA;
162         else if(rnatype == &RNA_IntProperty)
163                 return ICON_RNA;
164         else if(rnatype == &RNA_FloatProperty)
165                 return ICON_RNA;
166         else if(rnatype == &RNA_StringProperty)
167                 return ICON_RNA;
168         else if(rnatype == &RNA_EnumProperty)
169                 return ICON_RNA;
170         else if(rnatype == &RNA_EnumPropertyItem)
171                 return ICON_RNA;
172         else if(rnatype == &RNA_PointerProperty)
173                 return ICON_RNA;
174         else if(rnatype == &RNA_CollectionProperty)
175                 return ICON_RNA;
176         else if(rnatype == &RNA_GameObjectSettings)
177                 return ICON_GAME;
178         else if(rnatype == &RNA_ScriptLink)
179                 return ICON_PYTHON;
180         
181         /* modifiers */
182         else if(rnatype == &RNA_SubsurfModifier)
183                 return ICON_MOD_SUBSURF;
184         else if(rnatype == &RNA_ArmatureModifier)
185                 return ICON_MOD_ARMATURE;
186         else if(rnatype == &RNA_LatticeModifier)
187                 return ICON_MOD_LATTICE;
188         else if(rnatype == &RNA_CurveModifier)
189                 return ICON_MOD_CURVE;
190         else if(rnatype == &RNA_BuildModifier)
191                 return ICON_MOD_BUILD;
192         else if(rnatype == &RNA_MirrorModifier)
193                 return ICON_MOD_MIRROR;
194         else if(rnatype == &RNA_DecimateModifier)
195                 return ICON_MOD_DECIM;
196         else if(rnatype == &RNA_WaveModifier)
197                 return ICON_MOD_WAVE;
198         else if(rnatype == &RNA_HookModifier)
199                 return ICON_HOOK;
200         else if(rnatype == &RNA_SoftbodyModifier)
201                 return ICON_MOD_SOFT;
202         else if(rnatype == &RNA_BooleanModifier)
203                 return ICON_MOD_BOOLEAN;
204         else if(rnatype == &RNA_ParticleInstanceModifier)
205                 return ICON_MOD_PARTICLEINSTANCE;
206         else if(rnatype == &RNA_ParticleSystemModifier)
207                 return ICON_MOD_PARTICLES;
208         else if(rnatype == &RNA_EdgeSplitModifier)
209                 return ICON_MOD_EDGESPLIT;
210         else if(rnatype == &RNA_ArrayModifier)
211                 return ICON_MOD_ARRAY;
212         else if(rnatype == &RNA_UVProjectModifier)
213                 return ICON_MOD_UVPROJECT;
214         else if(rnatype == &RNA_DisplaceModifier)
215                 return ICON_MOD_DISPLACE;
216         else
217                 return ICON_DOT;
218 }
219
220 uiBut *uiDefAutoButR(uiBlock *block, PointerRNA *ptr, PropertyRNA *prop, int index, char *name, int x1, int y1, int x2, int y2)
221 {
222         uiBut *but=NULL;
223         const char *propname= RNA_property_identifier(ptr, prop);
224         int arraylen= RNA_property_array_length(ptr, prop);
225
226         switch(RNA_property_type(ptr, prop)) {
227                 case PROP_BOOLEAN: {
228                         int value, length;
229
230                         if(arraylen && index == -1)
231                                 return NULL;
232
233                         length= RNA_property_array_length(ptr, prop);
234
235                         if(length)
236                                 value= RNA_property_boolean_get_index(ptr, prop, index);
237                         else
238                                 value= RNA_property_boolean_get(ptr, prop);
239
240                         if(name && strcmp(name, "") == 0)
241                                 name= (value)? "Enabled": "Disabled";
242
243                         but= uiDefButR(block, TOG, 0, name, x1, y1, x2, y2, ptr, propname, index, 0, 0, -1, -1, NULL);
244                         break;
245                 }
246                 case PROP_INT:
247                 case PROP_FLOAT:
248                         if(arraylen && index == -1) {
249                                 if(RNA_property_subtype(ptr, prop) == PROP_COLOR)
250                                         but= uiDefButR(block, COL, 0, name, x1, y1, x2, y2, ptr, propname, 0, 0, 0, -1, -1, NULL);
251                         }
252                         else if(RNA_property_subtype(ptr, prop) == PROP_PERCENTAGE)
253                                 but= uiDefButR(block, NUMSLI, 0, name, x1, y1, x2, y2, ptr, propname, index, 0, 0, -1, -1, NULL);
254                         else
255                                 but= uiDefButR(block, NUM, 0, name, x1, y1, x2, y2, ptr, propname, index, 0, 0, -1, -1, NULL);
256                         break;
257                 case PROP_ENUM:
258                         but= uiDefButR(block, MENU, 0, NULL, x1, y1, x2, y2, ptr, propname, index, 0, 0, -1, -1, NULL);
259                         break;
260                 case PROP_STRING:
261                         but= uiDefButR(block, TEX, 0, name, x1, y1, x2, y2, ptr, propname, index, 0, 0, -1, -1, NULL);
262                         break;
263                 case PROP_POINTER: {
264                         PointerRNA pptr;
265                         PropertyRNA *nameprop;
266                         char *text, *descr, textbuf[256];
267                         int icon;
268
269                         pptr= RNA_property_pointer_get(ptr, prop);
270
271                         if(!pptr.data)
272                                 return NULL;
273
274                         icon= UI_GetIconRNA(&pptr);
275                         nameprop= RNA_struct_name_property(&pptr);
276
277                         if(nameprop) {
278                                 text= RNA_property_string_get_alloc(&pptr, nameprop, textbuf, sizeof(textbuf));
279                                 descr= (char*)RNA_property_ui_description(&pptr, prop);
280                                 but= uiDefIconTextBut(block, LABEL, 0, icon, text, x1, y1, x2, y2, NULL, 0, 0, 0, 0, descr);
281                                 if(text != textbuf)
282                                         MEM_freeN(text);
283                         }
284                         else {
285                                 text= (char*)RNA_struct_ui_name(&pptr);
286                                 descr= (char*)RNA_property_ui_description(&pptr, prop);
287                                 but= uiDefIconTextBut(block, LABEL, 0, icon, text, x1, y1, x2, y2, NULL, 0, 0, 0, 0, descr);
288                         }
289                         break;
290                 }
291                 case PROP_COLLECTION: {
292                         char text[256];
293                         sprintf(text, "%d items", RNA_property_collection_length(ptr, prop));
294                         but= uiDefBut(block, LABEL, 0, text, x1, y1, x2, y2, NULL, 0, 0, 0, 0, NULL);
295                         uiButSetFlag(but, UI_BUT_DISABLED);
296                         break;
297                 }
298                 default:
299                         but= NULL;
300                         break;
301         }
302
303         return but;
304 }
305
306 int uiDefAutoButsRNA(uiBlock *block, PointerRNA *ptr)
307 {
308         CollectionPropertyIterator iter;
309         PropertyRNA *iterprop, *prop;
310         PropertySubType subtype;
311         char *name, namebuf[128];
312         int a= 0, length, x= 0, y= 0;
313
314         x= 0;
315         y= 0;
316
317         /* create buttons */
318         uiSetCurFont(block, UI_HELVB);
319         uiDefBut(block, LABEL, 0, (char*)RNA_struct_ui_name(ptr), x, y, DEF_BUT_WIDTH, DEF_BUT_HEIGHT-1, NULL, 0, 0, 0, 0, "");
320         y -= DEF_BUT_HEIGHT;
321         uiSetCurFont(block, UI_HELV);
322
323         iterprop= RNA_struct_iterator_property(ptr);
324         RNA_property_collection_begin(ptr, iterprop, &iter);
325
326         for(; iter.valid; RNA_property_collection_next(&iter)) {
327                 prop= iter.ptr.data;
328
329                 if(strcmp(RNA_property_identifier(ptr, prop), "rna_type") == 0)
330                         continue;
331
332                 if((length= RNA_property_array_length(ptr, prop))) {
333                         name= (char*)RNA_property_ui_name(ptr, prop);
334                         uiDefBut(block, LABEL, 0, name, x, y, DEF_BUT_WIDTH, DEF_BUT_HEIGHT-1, NULL, 0, 0, 0, 0, "");
335                 }
336                 else
337                         length= 1;
338
339                 subtype= RNA_property_subtype(ptr, prop);
340
341                 name= (char*)RNA_property_ui_name(ptr, prop);
342                 uiDefBut(block, LABEL, 0, name, x, y, DEF_BUT_WIDTH, DEF_BUT_HEIGHT-1, NULL, 0, 0, 0, 0, "");
343
344                 uiBlockBeginAlign(block);
345
346                 if(length <= 16 && subtype == PROP_MATRIX) {
347                         /* matrix layout */
348                         int size, row, col, butwidth;
349
350                         size= ceil(sqrt(length));
351                         butwidth= DEF_BUT_WIDTH*2/size;
352                         y -= DEF_BUT_HEIGHT;
353
354                         for(a=0; a<length; a++) {
355                                 col= a%size;
356                                 row= a/size;
357
358                                 uiDefAutoButR(block, ptr, prop, a, "", x+butwidth*col, y-row*DEF_BUT_HEIGHT, butwidth, DEF_BUT_HEIGHT-1);
359                         }
360
361                         y -= DEF_BUT_HEIGHT*(length/size);
362                 }
363                 else if(length <= 4 && ELEM3(subtype, PROP_ROTATION, PROP_VECTOR, PROP_COLOR)) {
364                         static char *vectoritem[4]= {"X:", "Y:", "Z:", "W:"};
365                         static char *quatitem[4]= {"W:", "X:", "Y:", "Z:"};
366                         static char *coloritem[4]= {"R:", "G:", "B:", "A:"};
367                         int butwidth;
368
369                         butwidth= DEF_BUT_WIDTH*2/length;
370                         y -= DEF_BUT_HEIGHT;
371
372                         for(a=0; a<length; a++) {
373                                 if(length == 4 && subtype == PROP_ROTATION)
374                                         name= quatitem[a];
375                                 else if(subtype == PROP_VECTOR || subtype == PROP_ROTATION)
376                                         name= vectoritem[a];
377                                 else
378                                         name= coloritem[a];
379
380                                 uiDefAutoButR(block, ptr, prop, a, name, x+butwidth*a, y, butwidth, DEF_BUT_HEIGHT-1);
381                         }
382                         y -= DEF_BUT_HEIGHT;
383                 }
384                 else {
385                         if(RNA_property_array_length(ptr, prop)) {
386                                 sprintf(namebuf, "%d:", a+1);
387                                 name= namebuf;
388                         }
389                         else
390                                 name= "";
391
392                         uiDefAutoButR(block, ptr, prop, 0, name, x+DEF_BUT_WIDTH, y, DEF_BUT_WIDTH, DEF_BUT_HEIGHT-1);
393                         y -= DEF_BUT_HEIGHT;
394                 }
395
396                 uiBlockEndAlign(block);
397         }
398
399         RNA_property_collection_end(&iter);
400
401         return -y;
402 }
403
404 /***************************** ID Utilities *******************************/
405
406 typedef struct uiIDPoinParams {
407         uiIDPoinFunc func;
408         ID *id;
409         short id_code;
410         short browsenr;
411 } uiIDPoinParams;
412
413 static void idpoin_cb(bContext *C, void *arg_params, void *arg_event)
414 {
415         Main *bmain;
416         ListBase *lb;
417         uiIDPoinParams *params= (uiIDPoinParams*)arg_params;
418         uiIDPoinFunc func= params->func;
419         ID *id= params->id, *idtest;
420         int nr, event= GET_INT_FROM_POINTER(arg_event);
421
422         bmain= CTX_data_main(C);
423         lb= wich_libbase(bmain, params->id_code);
424         
425         if(event == UI_ID_BROWSE && params->browsenr == 32767)
426                 event= UI_ID_ADD_NEW;
427         else if(event == UI_ID_BROWSE && params->browsenr == 32766)
428                 event= UI_ID_OPEN;
429
430         switch(event) {
431                 case UI_ID_RENAME:
432                         if(id) test_idbutton(id->name+2);
433                         else return;
434                         break;
435                 case UI_ID_BROWSE: {
436                         if(id==0) id= lb->first;
437                         if(id==0) return;
438
439                         if(params->browsenr== -2) {
440                                 /* XXX implement or find a replacement
441                                  * activate_databrowse((ID *)G.buts->lockpoin, GS(id->name), 0, B_MESHBROWSE, &params->browsenr, do_global_buttons); */
442                                 return;
443                         }
444                         if(params->browsenr < 0)
445                                 return;
446
447                         for(idtest=lb->first, nr=1; idtest; idtest=idtest->next, nr++) {
448                                 if(nr==params->browsenr) {
449                                         if(id == idtest)
450                                                 return;
451
452                                         id= idtest;
453
454                                         break;
455                                 }
456                         }
457                         break;
458                 }
459                 case UI_ID_DELETE:
460                         id= NULL;
461                         break;
462                 case UI_ID_FAKE_USER:
463                         if(id) {
464                                 if(id->flag & LIB_FAKEUSER) id->us++;
465                                 else id->us--;
466                         }
467                         else return;
468                         break;
469                 case UI_ID_PIN:
470                         break;
471                 case UI_ID_ADD_NEW:
472                         break;
473                 case UI_ID_OPEN:
474                         break;
475                 case UI_ID_ALONE:
476                         if(!id || id->us < 1)
477                                 return;
478                         break;
479                 case UI_ID_LOCAL:
480                         if(!id || id->us < 1)
481                                 return;
482                         break;
483                 case UI_ID_AUTO_NAME:
484                         break;
485         }
486
487         if(func)
488                 func(C, id, event);
489 }
490
491 int uiDefIDPoinButs(uiBlock *block, Main *bmain, ID *parid, ID *id, int id_code, short *pin_p, int x, int y, uiIDPoinFunc func, int events)
492 {
493         ListBase *lb;
494         uiBut *but;
495         uiIDPoinParams *params, *dup_params;
496         char *str=NULL, str1[10];
497         int len, oldcol, add_addbutton=0;
498
499         /* setup struct that we will pass on with the buttons */
500         params= MEM_callocN(sizeof(uiIDPoinParams), "uiIDPoinParams");
501         params->id= id;
502         params->id_code= id_code;
503         params->func= func;
504
505         lb= wich_libbase(bmain, id_code);
506
507         /* create buttons */
508         uiBlockBeginAlign(block);
509         oldcol= uiBlockGetCol(block);
510
511         if(id && id->us>1)
512                 uiBlockSetCol(block, TH_BUT_SETTING1);
513
514         if((events & UI_ID_PIN) && *pin_p)
515                 uiBlockSetCol(block, TH_BUT_SETTING2);
516
517         /* pin button */
518         if(id && (events & UI_ID_PIN)) {
519                 but= uiDefIconButS(block, ICONTOG, (events & UI_ID_PIN), ICON_KEY_DEHLT, x, y ,DEF_ICON_BUT_WIDTH,DEF_BUT_HEIGHT, pin_p, 0, 0, 0, 0, "Keeps this view displaying the current data regardless of what object is selected");
520                 uiButSetNFunc(but, idpoin_cb, MEM_dupallocN(params), SET_INT_IN_POINTER(UI_ID_PIN));
521                 x+= DEF_ICON_BUT_WIDTH;
522         }
523
524         /* browse menu */
525         if(events & UI_ID_BROWSE) {
526                 char *extrastr= NULL;
527                 
528                 if(ELEM4(id_code, ID_MA, ID_TE, ID_BR, ID_PA))
529                         add_addbutton= 1;
530                 
531                 if(ELEM8(id_code, ID_SCE, ID_SCR, ID_MA, ID_TE, ID_WO, ID_IP, ID_AC, ID_BR) || id_code == ID_PA)
532                         extrastr= "ADD NEW %x 32767";
533                 else if(id_code==ID_TXT)
534                         extrastr= "OPEN NEW %x 32766 |ADD NEW %x 32767";
535                 else if(id_code==ID_SO)
536                         extrastr= "OPEN NEW %x 32766";
537
538                 /* XXX should be moved out of this function
539                 uiBlockSetButLock(block, G.scene->id.lib!=0, "Can't edit external libdata");
540                 if( id_code==ID_SCE || id_code==ID_SCR ) uiBlockClearButLock(block); */
541                 
542                 /* XXX should be moved out of this function
543                 if(curarea->spacetype==SPACE_BUTS)
544                         uiBlockSetButLock(block, id_code!=ID_SCR && G.obedit!=0 && G.buts->mainb==CONTEXT_EDITING, "Cannot perform in EditMode"); */
545                 
546                 if(parid)
547                         uiBlockSetButLock(block, parid->lib!=0, "Can't edit external libdata");
548
549                 if(lb) {
550                         if(id_code!=ID_IM || (events & UI_ID_BROWSE_RENDER))
551                                 IDnames_to_pupstring(&str, NULL, extrastr, lb, id, &params->browsenr);
552                         else
553                                 IMAnames_to_pupstring(&str, NULL, extrastr, lb, id, &params->browsenr);
554                 }
555
556                 dup_params= MEM_dupallocN(params);
557                 but= uiDefButS(block, MENU, 0, str, x, y, DEF_ICON_BUT_WIDTH, DEF_BUT_HEIGHT, &dup_params->browsenr, 0, 0, 0, 0, "Browse existing choices, or add new");
558                 uiButSetNFunc(but, idpoin_cb, dup_params, SET_INT_IN_POINTER(UI_ID_BROWSE));
559                 x+= DEF_ICON_BUT_WIDTH;
560                 
561                 uiBlockClearButLock(block);
562         
563                 MEM_freeN(str);
564         }
565
566         uiBlockSetCol(block, oldcol);
567
568         /* text button with name */
569         if(id) {
570                 /* name */
571                 if(id->us > 1)
572                         uiBlockSetCol(block, TH_BUT_SETTING1);
573
574                 /* pinned data? */
575                 if((events & UI_ID_PIN) && *pin_p)
576                         uiBlockSetCol(block, TH_BUT_SETTING2);
577
578                 /* redalert overrides pin color */
579                 if(id->us<=0)
580                         uiBlockSetCol(block, TH_REDALERT);
581
582                 uiBlockSetButLock(block, id->lib!=0, "Can't edit external libdata");
583                 
584                 /* name button */
585                 if(GS(id->name)==ID_SCE)
586                         strcpy(str1, "SCE:");
587                 else if(GS(id->name)==ID_SCE)
588                         strcpy(str1, "SCR:");
589                 else if(GS(id->name)==ID_MA && ((Material*)id)->use_nodes)
590                         strcpy(str1, "NT:");
591                 else {
592                         str1[0]= id->name[0];
593                         str1[1]= id->name[1];
594                         str1[2]= ':';
595                         str1[3]= 0;
596                 }
597                 
598                 if(GS(id->name)==ID_IP) len= 110;
599                 else if((y) && (GS(id->name)==ID_AC)) len= 100; // comes from button panel (poselib)
600                 else if(y) len= 140;    // comes from button panel
601                 else len= 120;
602                 
603                 but= uiDefBut(block, TEX, 0, str1,x, y, (short)len, DEF_BUT_HEIGHT, id->name+2, 0.0, 21.0, 0, 0, "Displays current Datablock name. Click to change.");
604                 uiButSetNFunc(but, idpoin_cb, MEM_dupallocN(params), SET_INT_IN_POINTER(UI_ID_RENAME));
605
606                 x+= len;
607
608                 uiBlockClearButLock(block);
609                 
610                 /* lib make local button */
611                 if(id->lib) {
612                         if(id->flag & LIB_INDIRECT) uiDefIconBut(block, BUT, 0, 0 /* XXX ICON_DATALIB */,x,y,DEF_ICON_BUT_WIDTH,DEF_BUT_HEIGHT, 0, 0, 0, 0, 0, "Indirect Library Datablock. Cannot change.");
613                         else {
614                                 but= uiDefIconBut(block, BUT, 0, 0 /* XXX ICON_PARLIB */, x,y,DEF_ICON_BUT_WIDTH,DEF_BUT_HEIGHT, 0, 0, 0, 0, 0, 
615                                                           (events & UI_ID_LOCAL)? "Direct linked Library Datablock. Click to make local.": "Direct linked Library Datablock, cannot make local.");
616                                 uiButSetNFunc(but, idpoin_cb, MEM_dupallocN(params), SET_INT_IN_POINTER(UI_ID_ALONE));
617                         }
618                         
619                         x+= DEF_ICON_BUT_WIDTH;
620                 }
621                 
622                 /* number of users / make local button */
623                 if((events & UI_ID_ALONE) && id->us>1) {
624                         int butwidth;
625
626                         uiBlockSetButLock(block, (events & UI_ID_PIN) && *pin_p, "Can't make pinned data single-user");
627                         
628                         sprintf(str1, "%d", id->us);
629                         butwidth= (id->us<10)? DEF_ICON_BUT_WIDTH: DEF_ICON_BUT_WIDTH+10;
630
631                         but= uiDefBut(block, BUT, 0, str1, x, y, butwidth, DEF_BUT_HEIGHT, 0, 0, 0, 0, 0, "Displays number of users of this data. Click to make a single-user copy.");
632                         uiButSetNFunc(but, idpoin_cb, MEM_dupallocN(params), SET_INT_IN_POINTER(UI_ID_ALONE));
633                         x+= butwidth;
634                         
635                         uiBlockClearButLock(block);
636                 }
637                 
638                 /* delete button */
639                 if(events & UI_ID_DELETE) {
640                         uiBlockSetButLock(block, (events & UI_ID_PIN) && *pin_p, "Can't unlink pinned data");
641                         if(parid && parid->lib);
642                         else {
643                                 but= uiDefIconBut(block, BUT, 0, ICON_X, x,y,DEF_ICON_BUT_WIDTH,DEF_BUT_HEIGHT, 0, 0, 0, 0, 0, "Deletes link to this Datablock");
644                                 uiButSetNFunc(but, idpoin_cb, MEM_dupallocN(params), SET_INT_IN_POINTER(UI_ID_DELETE));
645                                 x+= DEF_ICON_BUT_WIDTH;
646                         }
647                         
648                         uiBlockClearButLock(block);
649                 }
650
651                 /* auto name button */
652                 if(events & UI_ID_AUTO_NAME) {
653                         if(parid && parid->lib);
654                         else {
655                                 but= uiDefIconBut(block, BUT, 0, ICON_AUTO,x,y,DEF_ICON_BUT_WIDTH,DEF_BUT_HEIGHT, 0, 0, 0, 0, 0, "Generates an automatic name");
656                                 uiButSetNFunc(but, idpoin_cb, MEM_dupallocN(params), SET_INT_IN_POINTER(UI_ID_AUTO_NAME));
657                                 x+= DEF_ICON_BUT_WIDTH;
658                         }
659                 }
660
661                 /* fake user button */
662                 if(events & UI_ID_FAKE_USER) {
663                         but= uiDefButBitS(block, TOG, LIB_FAKEUSER, 0, "F", x,y,DEF_ICON_BUT_WIDTH,DEF_BUT_HEIGHT, &id->flag, 0, 0, 0, 0, "Saves this datablock even if it has no users");
664                         uiButSetNFunc(but, idpoin_cb, MEM_dupallocN(params), SET_INT_IN_POINTER(UI_ID_FAKE_USER));
665                         x+= DEF_ICON_BUT_WIDTH;
666                 }
667         }
668         /* add new button */
669         else if(add_addbutton) {
670                 uiBlockSetCol(block, oldcol);
671                 if(parid) uiBlockSetButLock(block, parid->lib!=0, "Can't edit external libdata");
672                 dup_params= MEM_dupallocN(params);
673                 but= uiDefButS(block, TOG, 0, "Add New", x, y, 110, DEF_BUT_HEIGHT, &dup_params->browsenr, params->browsenr, 32767.0, 0, 0, "Add new data block");
674                 uiButSetNFunc(but, idpoin_cb, dup_params, SET_INT_IN_POINTER(UI_ID_ADD_NEW));
675                 x+= 110;
676         }
677         
678         uiBlockSetCol(block, oldcol);
679         uiBlockEndAlign(block);
680
681         MEM_freeN(params);
682
683         return x;
684 }
685
686 /* ****************************** default button callbacks ******************* */
687 /* ************ LEGACY WARNING, only to get things work with 2.48 code! ****** */
688
689 void test_idbutton_cb(struct bContext *C, void *namev, void *arg2)
690 {
691         char *name= namev;
692         
693         test_idbutton(name+2);
694 }
695
696
697 void test_scriptpoin_but(struct bContext *C, char *name, ID **idpp)
698 {
699         ID *id;
700         
701         id= CTX_data_main(C)->text.first;
702         while(id) {
703                 if( strcmp(name, id->name+2)==0 ) {
704                         *idpp= id;
705                         return;
706                 }
707                 id= id->next;
708         }
709         *idpp= NULL;
710 }
711
712 void test_actionpoin_but(struct bContext *C, char *name, ID **idpp)
713 {
714         ID *id;
715         
716         id= CTX_data_main(C)->action.first;
717         while(id) {
718                 if( strcmp(name, id->name+2)==0 ) {
719                         id_us_plus(id);
720                         *idpp= id;
721                         return;
722                 }
723                 id= id->next;
724         }
725         *idpp= NULL;
726 }
727
728
729 void test_obpoin_but(struct bContext *C, char *name, ID **idpp)
730 {
731         ID *id;
732         
733 // XXX  if(idpp == (ID **)&(emptytex.object)) {
734 //              error("You must add a texture first");
735 //              *idpp= 0;
736 //              return;
737 //      }
738         
739         id= CTX_data_main(C)->object.first;
740         while(id) {
741                 if( strcmp(name, id->name+2)==0 ) {
742                         *idpp= id;
743                         id_lib_extern(id);      /* checks lib data, sets correct flag for saving then */
744                         return;
745                 }
746                 id= id->next;
747         }
748         *idpp= NULL;
749 }
750
751 /* tests for an object of type OB_MESH */
752 void test_meshobpoin_but(struct bContext *C, char *name, ID **idpp)
753 {
754         ID *id;
755
756         id = CTX_data_main(C)->object.first;
757         while(id) {
758                 Object *ob = (Object *)id;
759                 if(ob->type == OB_MESH && strcmp(name, id->name + 2) == 0) {
760                         *idpp = id;
761                         /* checks lib data, sets correct flag for saving then */
762                         id_lib_extern(id);
763                         return;
764                 }
765                 id = id->next;
766         }
767         *idpp = NULL;
768 }
769
770 void test_meshpoin_but(struct bContext *C, char *name, ID **idpp)
771 {
772         ID *id;
773
774         if( *idpp ) (*idpp)->us--;
775         
776         id= CTX_data_main(C)->mesh.first;
777         while(id) {
778                 if( strcmp(name, id->name+2)==0 ) {
779                         *idpp= id;
780                         id_us_plus(id);
781                         return;
782                 }
783                 id= id->next;
784         }
785         *idpp= NULL;
786 }
787
788 void test_matpoin_but(struct bContext *C, char *name, ID **idpp)
789 {
790         ID *id;
791
792         if( *idpp ) (*idpp)->us--;
793         
794         id= CTX_data_main(C)->mat.first;
795         while(id) {
796                 if( strcmp(name, id->name+2)==0 ) {
797                         *idpp= id;
798                         id_us_plus(id);
799                         return;
800                 }
801                 id= id->next;
802         }
803         *idpp= NULL;
804 }
805
806 void test_scenepoin_but(struct bContext *C, char *name, ID **idpp)
807 {
808         ID *id;
809         
810         if( *idpp ) (*idpp)->us--;
811         
812         id= CTX_data_main(C)->scene.first;
813         while(id) {
814                 if( strcmp(name, id->name+2)==0 ) {
815                         *idpp= id;
816                         id_us_plus(id);
817                         return;
818                 }
819                 id= id->next;
820         }
821         *idpp= NULL;
822 }
823
824 void test_grouppoin_but(struct bContext *C, char *name, ID **idpp)
825 {
826         ID *id;
827         
828         if( *idpp ) (*idpp)->us--;
829         
830         id= CTX_data_main(C)->group.first;
831         while(id) {
832                 if( strcmp(name, id->name+2)==0 ) {
833                         *idpp= id;
834                         id_us_plus(id);
835                         return;
836                 }
837                 id= id->next;
838         }
839         *idpp= NULL;
840 }
841
842 void test_texpoin_but(struct bContext *C, char *name, ID **idpp)
843 {
844         ID *id;
845         
846         if( *idpp ) (*idpp)->us--;
847         
848         id= CTX_data_main(C)->tex.first;
849         while(id) {
850                 if( strcmp(name, id->name+2)==0 ) {
851                         *idpp= id;
852                         id_us_plus(id);
853                         return;
854                 }
855                 id= id->next;
856         }
857         *idpp= NULL;
858 }
859
860 void test_imapoin_but(struct bContext *C, char *name, ID **idpp)
861 {
862         ID *id;
863         
864         if( *idpp ) (*idpp)->us--;
865         
866         id= CTX_data_main(C)->image.first;
867         while(id) {
868                 if( strcmp(name, id->name+2)==0 ) {
869                         *idpp= id;
870                         id_us_plus(id);
871                         return;
872                 }
873                 id= id->next;
874         }
875         *idpp= NULL;
876 }
877
878 /* autocomplete callback for  buttons */
879 void autocomplete_bone(struct bContext *C, char *str, void *arg_v)
880 {
881         Object *ob= (Object *)arg_v;
882         
883         if(ob==NULL || ob->pose==NULL) return;
884         
885         /* search if str matches the beginning of name */
886         if(str[0]) {
887                 AutoComplete *autocpl= autocomplete_begin(str, 32);
888                 bPoseChannel *pchan;
889                 
890                 for(pchan= ob->pose->chanbase.first; pchan; pchan= pchan->next)
891                         autocomplete_do_name(autocpl, pchan->name);
892                 
893                 autocomplete_end(autocpl, str);
894         }
895 }
896
897 /* autocomplete callback for buttons */
898 void autocomplete_vgroup(struct bContext *C, char *str, void *arg_v)
899 {
900         Object *ob= (Object *)arg_v;
901         
902         if(ob==NULL) return;
903         
904         /* search if str matches the beginning of a name */
905         if(str[0]) {
906                 AutoComplete *autocpl= autocomplete_begin(str, 32);
907                 bDeformGroup *dg;
908                 
909                 for(dg= ob->defbase.first; dg; dg= dg->next)
910                         if(dg->name!=str)
911                                 autocomplete_do_name(autocpl, dg->name);
912                 
913                 autocomplete_end(autocpl, str);
914         }
915 }
916
917
918 /* ----------- custom button group ---------------------- */
919
920 static void curvemap_buttons_zoom_in(bContext *C, void *cumap_v, void *unused)
921 {
922         CurveMapping *cumap = cumap_v;
923         float d;
924         
925         /* we allow 20 times zoom */
926         if( (cumap->curr.xmax - cumap->curr.xmin) > 0.04f*(cumap->clipr.xmax - cumap->clipr.xmin) ) {
927                 d= 0.1154f*(cumap->curr.xmax - cumap->curr.xmin);
928                 cumap->curr.xmin+= d;
929                 cumap->curr.xmax-= d;
930                 d= 0.1154f*(cumap->curr.ymax - cumap->curr.ymin);
931                 cumap->curr.ymin+= d;
932                 cumap->curr.ymax-= d;
933         }
934 }
935
936 static void curvemap_buttons_zoom_out(bContext *C, void *cumap_v, void *unused)
937 {
938         CurveMapping *cumap = cumap_v;
939         float d, d1;
940         
941         /* we allow 20 times zoom, but dont view outside clip */
942         if( (cumap->curr.xmax - cumap->curr.xmin) < 20.0f*(cumap->clipr.xmax - cumap->clipr.xmin) ) {
943                 d= d1= 0.15f*(cumap->curr.xmax - cumap->curr.xmin);
944                 
945                 if(cumap->flag & CUMA_DO_CLIP) 
946                         if(cumap->curr.xmin-d < cumap->clipr.xmin)
947                                 d1= cumap->curr.xmin - cumap->clipr.xmin;
948                 cumap->curr.xmin-= d1;
949                 
950                 d1= d;
951                 if(cumap->flag & CUMA_DO_CLIP) 
952                         if(cumap->curr.xmax+d > cumap->clipr.xmax)
953                                 d1= -cumap->curr.xmax + cumap->clipr.xmax;
954                 cumap->curr.xmax+= d1;
955                 
956                 d= d1= 0.15f*(cumap->curr.ymax - cumap->curr.ymin);
957                 
958                 if(cumap->flag & CUMA_DO_CLIP) 
959                         if(cumap->curr.ymin-d < cumap->clipr.ymin)
960                                 d1= cumap->curr.ymin - cumap->clipr.ymin;
961                 cumap->curr.ymin-= d1;
962                 
963                 d1= d;
964                 if(cumap->flag & CUMA_DO_CLIP) 
965                         if(cumap->curr.ymax+d > cumap->clipr.ymax)
966                                 d1= -cumap->curr.ymax + cumap->clipr.ymax;
967                 cumap->curr.ymax+= d1;
968         }
969 }
970
971 static void curvemap_buttons_setclip(bContext *C, void *cumap_v, void *unused)
972 {
973         CurveMapping *cumap = cumap_v;
974         
975         curvemapping_changed(cumap, 0);
976 }       
977
978 static void curvemap_buttons_delete(bContext *C, void *cumap_v, void *unused)
979 {
980         CurveMapping *cumap = cumap_v;
981         
982         curvemap_remove(cumap->cm+cumap->cur, SELECT);
983         curvemapping_changed(cumap, 0);
984 }
985
986 /* NOTE: this is a block-menu, needs 0 events, otherwise the menu closes */
987 static uiBlock *curvemap_clipping_func(struct bContext *C, struct ARegion *ar, void *cumap_v)
988 {
989         CurveMapping *cumap = cumap_v;
990         uiBlock *block;
991         uiBut *bt;
992         
993         block= uiBeginBlock(C, ar, "curvemap_clipping_func", UI_EMBOSS, UI_HELV);
994         
995         /* use this for a fake extra empy space around the buttons */
996         uiDefBut(block, LABEL, 0, "",                   -4, 16, 128, 106, NULL, 0, 0, 0, 0, "");
997         
998         bt= uiDefButBitI(block, TOG, CUMA_DO_CLIP, 1, "Use Clipping",    
999                                                                                 0,100,120,18, &cumap->flag, 0.0, 0.0, 10, 0, "");
1000         uiButSetFunc(bt, curvemap_buttons_setclip, cumap, NULL);
1001
1002         uiBlockBeginAlign(block);
1003         uiDefButF(block, NUM, 0, "Min X ",       0,74,120,18, &cumap->clipr.xmin, -100.0, cumap->clipr.xmax, 10, 0, "");
1004         uiDefButF(block, NUM, 0, "Min Y ",       0,56,120,18, &cumap->clipr.ymin, -100.0, cumap->clipr.ymax, 10, 0, "");
1005         uiDefButF(block, NUM, 0, "Max X ",       0,38,120,18, &cumap->clipr.xmax, cumap->clipr.xmin, 100.0, 10, 0, "");
1006         uiDefButF(block, NUM, 0, "Max Y ",       0,20,120,18, &cumap->clipr.ymax, cumap->clipr.ymin, 100.0, 10, 0, "");
1007         
1008         uiBlockSetDirection(block, UI_RIGHT);
1009         
1010         uiEndBlock(C, block);
1011         return block;
1012 }
1013
1014
1015 static void curvemap_tools_dofunc(bContext *C, void *cumap_v, int event)
1016 {
1017         CurveMapping *cumap = cumap_v;
1018         CurveMap *cuma= cumap->cm+cumap->cur;
1019         
1020         switch(event) {
1021                 case 0:
1022                         curvemap_reset(cuma, &cumap->clipr);
1023                         curvemapping_changed(cumap, 0);
1024                         break;
1025                 case 1:
1026                         cumap->curr= cumap->clipr;
1027                         break;
1028                 case 2: /* set vector */
1029                         curvemap_sethandle(cuma, 1);
1030                         curvemapping_changed(cumap, 0);
1031                         break;
1032                 case 3: /* set auto */
1033                         curvemap_sethandle(cuma, 0);
1034                         curvemapping_changed(cumap, 0);
1035                         break;
1036                 case 4: /* extend horiz */
1037                         cuma->flag &= ~CUMA_EXTEND_EXTRAPOLATE;
1038                         curvemapping_changed(cumap, 0);
1039                         break;
1040                 case 5: /* extend extrapolate */
1041                         cuma->flag |= CUMA_EXTEND_EXTRAPOLATE;
1042                         curvemapping_changed(cumap, 0);
1043                         break;
1044         }
1045         ED_region_tag_redraw(CTX_wm_region(C));
1046 }
1047
1048 static uiBlock *curvemap_tools_func(struct bContext *C, struct ARegion *ar, void *cumap_v)
1049 {
1050         uiBlock *block;
1051         short yco= 0, menuwidth=120;
1052         
1053         block= uiBeginBlock(C, ar, "curvemap_tools_func", UI_EMBOSSP, UI_HELV);
1054         uiBlockSetButmFunc(block, curvemap_tools_dofunc, cumap_v);
1055         
1056         uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Reset View",                             0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 1, "");
1057         uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Vector Handle",                  0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 2, "");
1058         uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Auto Handle",                    0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 3, "");
1059         uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Extend Horizontal",              0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 4, "");
1060         uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Extend Extrapolated",    0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 5, "");
1061         uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Reset Curve",                    0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 0, "");
1062         
1063         uiBlockSetDirection(block, UI_RIGHT);
1064         uiTextBoundsBlock(block, 50);
1065         
1066         uiEndBlock(C, block);
1067         return block;
1068 }
1069
1070 /* still unsure how this call evolves... we use labeltype for defining what curve-channels to show */
1071 void curvemap_buttons(uiBlock *block, CurveMapping *cumap, char labeltype, short event, short redraw, rctf *rect)
1072 {
1073         uiBut *bt;
1074         float dx, fy= rect->ymax-18.0f;
1075         int icon;
1076         short xco, yco;
1077         
1078         yco= (short)(rect->ymax-18.0f);
1079         
1080         /* curve choice options + tools/settings, 8 icons + spacer */
1081         dx= (rect->xmax-rect->xmin)/(9.0f);
1082         
1083         uiBlockBeginAlign(block);
1084         if(labeltype=='v') {    /* vector */
1085                 xco= (short)rect->xmin;
1086                 if(cumap->cm[0].curve)
1087                         uiDefButI(block, ROW, redraw, "X", xco, yco+2, dx, 16, &cumap->cur, 0.0, 0.0, 0.0, 0.0, "");
1088                 xco= (short)(rect->xmin+1.0f*dx);
1089                 if(cumap->cm[1].curve)
1090                         uiDefButI(block, ROW, redraw, "Y", xco, yco+2, dx, 16, &cumap->cur, 0.0, 1.0, 0.0, 0.0, "");
1091                 xco= (short)(rect->xmin+2.0f*dx);
1092                 if(cumap->cm[2].curve)
1093                         uiDefButI(block, ROW, redraw, "Z", xco, yco+2, dx, 16, &cumap->cur, 0.0, 2.0, 0.0, 0.0, "");
1094         }
1095         else if(labeltype=='c') { /* color */
1096                 xco= (short)rect->xmin;
1097                 if(cumap->cm[3].curve)
1098                         uiDefButI(block, ROW, redraw, "C", xco, yco+2, dx, 16, &cumap->cur, 0.0, 3.0, 0.0, 0.0, "");
1099                 xco= (short)(rect->xmin+1.0f*dx);
1100                 if(cumap->cm[0].curve)
1101                         uiDefButI(block, ROW, redraw, "R", xco, yco+2, dx, 16, &cumap->cur, 0.0, 0.0, 0.0, 0.0, "");
1102                 xco= (short)(rect->xmin+2.0f*dx);
1103                 if(cumap->cm[1].curve)
1104                         uiDefButI(block, ROW, redraw, "G", xco, yco+2, dx, 16, &cumap->cur, 0.0, 1.0, 0.0, 0.0, "");
1105                 xco= (short)(rect->xmin+3.0f*dx);
1106                 if(cumap->cm[2].curve)
1107                         uiDefButI(block, ROW, redraw, "B", xco, yco+2, dx, 16, &cumap->cur, 0.0, 2.0, 0.0, 0.0, "");
1108         }
1109         /* else no channels ! */
1110         uiBlockEndAlign(block);
1111
1112         xco= (short)(rect->xmin+4.5f*dx);
1113         uiBlockSetEmboss(block, UI_EMBOSSN);
1114         bt= uiDefIconBut(block, BUT, redraw, ICON_ZOOMIN, xco, yco, dx, 14, NULL, 0.0, 0.0, 0.0, 0.0, "Zoom in");
1115         uiButSetFunc(bt, curvemap_buttons_zoom_in, cumap, NULL);
1116         
1117         xco= (short)(rect->xmin+5.25f*dx);
1118         bt= uiDefIconBut(block, BUT, redraw, ICON_ZOOMOUT, xco, yco, dx, 14, NULL, 0.0, 0.0, 0.0, 0.0, "Zoom out");
1119         uiButSetFunc(bt, curvemap_buttons_zoom_out, cumap, NULL);
1120         
1121         xco= (short)(rect->xmin+6.0f*dx);
1122         bt= uiDefIconBlockBut(block, curvemap_tools_func, cumap, event, ICON_MODIFIER, xco, yco, dx, 18, "Tools");
1123         
1124         xco= (short)(rect->xmin+7.0f*dx);
1125         if(cumap->flag & CUMA_DO_CLIP) icon= ICON_CLIPUV_HLT; else icon= ICON_CLIPUV_DEHLT;
1126         bt= uiDefIconBlockBut(block, curvemap_clipping_func, cumap, event, icon, xco, yco, dx, 18, "Clipping Options");
1127         
1128         xco= (short)(rect->xmin+8.0f*dx);
1129         bt= uiDefIconBut(block, BUT, event, ICON_X, xco, yco, dx, 18, NULL, 0.0, 0.0, 0.0, 0.0, "Delete points");
1130         uiButSetFunc(bt, curvemap_buttons_delete, cumap, NULL);
1131         
1132         uiBlockSetEmboss(block, UI_EMBOSS);
1133         
1134         uiDefBut(block, BUT_CURVE, event, "", 
1135                           rect->xmin, rect->ymin, rect->xmax-rect->xmin, fy-rect->ymin, 
1136                           cumap, 0.0f, 1.0f, 0, 0, "");
1137 }
1138