diff options
author | Ton Roosendaal <ton@blender.org> | 2005-10-28 20:49:48 +0400 |
---|---|---|
committer | Ton Roosendaal <ton@blender.org> | 2005-10-28 20:49:48 +0400 |
commit | b8d81d093a1de39fd21df94bd7b4a4fd81d2491a (patch) | |
tree | 3e028e0ccf586ee9cdb0e18351840ad8169d1254 | |
parent | 3957b3428eebe55ae9d18ffbaa44e708ae680f76 (diff) |
Autocomplete for buttons that need Blender data names (ID's and Bones).
Just press TAB and it completes up to the level a match is found. If
more matches exist a menu could pop up, thats for later. Now an evening
off! :)
-rw-r--r-- | source/blender/include/BIF_butspace.h | 1 | ||||
-rw-r--r-- | source/blender/include/BIF_interface.h | 13 | ||||
-rw-r--r-- | source/blender/include/butspace.h | 3 | ||||
-rw-r--r-- | source/blender/include/interface.h | 3 | ||||
-rw-r--r-- | source/blender/src/butspace.c | 2 | ||||
-rw-r--r-- | source/blender/src/buttons_editing.c | 22 | ||||
-rw-r--r-- | source/blender/src/buttons_logic.c | 30 | ||||
-rw-r--r-- | source/blender/src/buttons_object.c | 70 | ||||
-rw-r--r-- | source/blender/src/buttons_scene.c | 2 | ||||
-rw-r--r-- | source/blender/src/buttons_script.c | 2 | ||||
-rw-r--r-- | source/blender/src/buttons_shading.c | 8 | ||||
-rw-r--r-- | source/blender/src/drawipo.c | 2 | ||||
-rw-r--r-- | source/blender/src/drawview.c | 2 | ||||
-rw-r--r-- | source/blender/src/interface.c | 65 | ||||
-rw-r--r-- | source/blender/src/meshtools.c | 19 |
15 files changed, 183 insertions, 61 deletions
diff --git a/source/blender/include/BIF_butspace.h b/source/blender/include/BIF_butspace.h index 9882984a010..4dda9f6fb43 100644 --- a/source/blender/include/BIF_butspace.h +++ b/source/blender/include/BIF_butspace.h @@ -44,6 +44,7 @@ extern void redraw_test_buttons(struct Object *new); /* buttons_editing.c */ extern void validate_editbonebutton_cb(void *bonev, void *namev); +extern void autocomplete_bone(char *str, void *arg_v); /* buts->mainb old */ diff --git a/source/blender/include/BIF_interface.h b/source/blender/include/BIF_interface.h index 617c3a6f15e..944b362e732 100644 --- a/source/blender/include/BIF_interface.h +++ b/source/blender/include/BIF_interface.h @@ -234,11 +234,8 @@ uiBut *uiDefIconTextButC(uiBlock *block, int type, int retval, int icon, char *s uiBut *uiDefIconTextButBitC(uiBlock *block, int type, int bit, int retval, int icon, char *str, short x1, short y1, short x2, short y2, char *poin, float min, float max, float a1, float a2, char *tip); typedef void (*uiIDPoinFuncFP) (char *str, struct ID **idpp); -void uiDefIDPoinBut(struct uiBlock *block, - uiIDPoinFuncFP func, int retval, char *str, - short x1, short y1, - short x2, short y2, - void *idpp, char *tip); +uiBut *uiDefIDPoinBut(struct uiBlock *block, uiIDPoinFuncFP func, short blocktype, int retval, char *str, + short x1, short y1, short x2, short y2, void *idpp, char *tip); typedef uiBlock* (*uiBlockFuncFP) (void *arg1); uiBut *uiDefBlockBut(uiBlock *block, uiBlockFuncFP func, void *func_arg1, char *str, short x1, short y1, short x2, short y2, char *tip); @@ -273,12 +270,16 @@ int uiButGetRetVal (uiBut *but); void uiButSetFlag (uiBut *but, int flag); void uiButClearFlag (uiBut *but, int flag); -void uiBlockSetButmFunc (uiBlock *block, void (*butmfunc)(void *arg, int but_a2), void *arg); +void uiBlockSetButmFunc (uiBlock *block, void (*butmfunc)(void *arg, int but_a2), void *arg); void uiBlockSetFunc (uiBlock *block, void (*func)(void *arg1, void *arg2), void *arg1, void *arg2); void uiButSetFunc (uiBut *but, void (*func)(void *arg1, void *arg2), void *arg1, void *arg2); + +void uiButSetCompleteFunc(uiBut *but, void (*func)(char *str, void *arg), void *arg); + void uiBlockSetDrawExtraFunc(uiBlock *block, void (*func)()); + extern void pupmenu_set_active(int val); extern short pupmenu(char *instr); extern short pupmenu_col(char *instr, int maxrow); diff --git a/source/blender/include/butspace.h b/source/blender/include/butspace.h index 6436468e33e..a725ff18138 100644 --- a/source/blender/include/butspace.h +++ b/source/blender/include/butspace.h @@ -110,6 +110,8 @@ extern void do_ipobuts(unsigned short event); // drawipo.c (bad! ton) /* uvautocalculation */ void do_uvautocalculationbuts(unsigned short event); void get_uvautocalculationsettings(float *radius,float *cubesize, int *mapdir, int *mapalign); + + /* butspace.c */ void test_meshpoin_but(char *name, struct ID **idpp); void test_obpoin_but(char *name, struct ID **idpp); @@ -120,7 +122,6 @@ void test_actionpoin_but(char *name, ID **idpp); void test_obcurpoin_but(char *name, ID **idpp); void test_idbutton_cb(void *namev, void *arg2_unused); - /* -------------- internal event defines ------------ */ diff --git a/source/blender/include/interface.h b/source/blender/include/interface.h index ce4a56de5a5..ed6eed109e9 100644 --- a/source/blender/include/interface.h +++ b/source/blender/include/interface.h @@ -124,6 +124,9 @@ struct uiBut { void (*embossfunc)(int , int , float, float, float, float, float, int); void (*sliderfunc)(int , float, float, float, float, float, float, int); + void (*autocomplete_func)(char *, void *); + void *autofunc_arg; + uiLink *link; char *tip, *lockstr; diff --git a/source/blender/src/butspace.c b/source/blender/src/butspace.c index 5e32a41acbf..0fc59218f03 100644 --- a/source/blender/src/butspace.c +++ b/source/blender/src/butspace.c @@ -230,8 +230,6 @@ void test_scenepoin_but(char *name, ID **idpp) /* --------------------------------- */ - - void do_butspace(unsigned short event) { SpaceButs *buts; diff --git a/source/blender/src/buttons_editing.c b/source/blender/src/buttons_editing.c index 232639499ab..97129847fda 100644 --- a/source/blender/src/buttons_editing.c +++ b/source/blender/src/buttons_editing.c @@ -691,8 +691,8 @@ static void editing_panel_mesh_type(Object *ob, Mesh *me) uiBlockEndAlign(block); - uiDefIDPoinBut(block, test_meshpoin_but, 0, "TexMesh: ", 175,124,230,19, &me->texcomesh, "Enter the name of a Meshblock"); - + uiDefIDPoinBut(block, test_meshpoin_but, ID_ME, B_REDR, "TexMesh: ", 175,124,230,19, &me->texcomesh, "Enter the name of a Meshblock"); + if(me->key) { uiBlockBeginAlign(block); uiDefButS(block, NUM, B_DIFF, "Slurph:", 175,95,95,19, &(me->key->slurph), -500.0, 500.0, 0, 0, ""); @@ -1269,11 +1269,11 @@ static void draw_modifier(uiBlock *block, Object *ob, ModifierData *md, int *xco uiDefButBitS(block, TOG, eSubsurfModifierFlag_ControlEdges, B_MODIFIER_RECALC, "Optimal Draw", lx, (cy-=19), buttonWidth,19,&smd->flags, 0, 0, 0, 0, "Skip drawing/rendering of interior subdivided edges"); } else if (md->type==eModifierType_Lattice) { LatticeModifierData *lmd = (LatticeModifierData*) md; - uiDefIDPoinBut(block, modifier_testLatticeObj, B_CHANGEDEP, "Ob: ", lx, (cy-=19), buttonWidth,19, &lmd->object, "Lattice object to deform with"); + uiDefIDPoinBut(block, modifier_testLatticeObj, ID_OB, B_CHANGEDEP, "Ob: ", lx, (cy-=19), buttonWidth,19, &lmd->object, "Lattice object to deform with"); uiDefBut(block, TEX, B_MODIFIER_RECALC, "VGroup: ", lx, (cy-=19), buttonWidth,19, &lmd->name, 0.0, 31.0, 0, 0, "Vertex Group name"); } else if (md->type==eModifierType_Curve) { CurveModifierData *cmd = (CurveModifierData*) md; - uiDefIDPoinBut(block, modifier_testCurveObj, B_CHANGEDEP, "Ob: ", lx, (cy-=19), buttonWidth,19, &cmd->object, "Curve object to deform with"); + uiDefIDPoinBut(block, modifier_testCurveObj, ID_OB, B_CHANGEDEP, "Ob: ", lx, (cy-=19), buttonWidth,19, &cmd->object, "Curve object to deform with"); uiDefBut(block, TEX, B_MODIFIER_RECALC, "VGroup: ", lx, (cy-=19), buttonWidth,19, &cmd->name, 0.0, 31.0, 0, 0, "Vertex Group name"); } else if (md->type==eModifierType_Build) { BuildModifierData *bmd = (BuildModifierData*) md; @@ -1311,7 +1311,7 @@ static void draw_modifier(uiBlock *block, Object *ob, ModifierData *md, int *xco uiDefButF(block, NUMSLI, B_MODIFIER_RECALC, "Narrow:", lx,(cy-=19),220,19, &wmd->narrow, 0.0, 10.0, 0, 0, "Specify how narrow the wave follows"); } else if (md->type==eModifierType_Armature) { ArmatureModifierData *amd = (ArmatureModifierData*) md; - uiDefIDPoinBut(block, modifier_testArmatureObj, B_CHANGEDEP, "Ob: ", lx, (cy-=19), buttonWidth,19, &amd->object, "Armature object to deform with"); + uiDefIDPoinBut(block, modifier_testArmatureObj, ID_OB, B_CHANGEDEP, "Ob: ", lx, (cy-=19), buttonWidth,19, &amd->object, "Armature object to deform with"); uiDefButBitS(block, TOG, ARM_DEF_VGROUP, B_ARM_RECALCDATA, "Vert.Groups", lx,cy-=19,buttonWidth/2,20, &amd->deformflag, 0, 0, 0, 0, "Enable VertexGroups defining deform"); uiDefButBitS(block, TOG, ARM_DEF_ENVELOPE, B_ARM_RECALCDATA, "Envelopes", lx+buttonWidth/2,cy,buttonWidth/2,20, &amd->deformflag, 0, 0, 0, 0, "Enable Bone Envelopes defining deform"); @@ -1320,7 +1320,7 @@ static void draw_modifier(uiBlock *block, Object *ob, ModifierData *md, int *xco HookModifierData *hmd = (HookModifierData*) md; uiDefButF(block, NUM, B_MODIFIER_RECALC, "Falloff: ", lx, (cy-=19), buttonWidth,19, &hmd->falloff, 0.0, 100.0, 100, 0, "If not zero, the distance from hook where influence ends"); uiDefButF(block, NUMSLI, B_MODIFIER_RECALC, "Force: ", lx, (cy-=19), buttonWidth,19, &hmd->force, 0.0, 1.0, 100, 0, "Set relative force of hook"); - uiDefIDPoinBut(block, test_obpoin_but, B_CHANGEDEP, "Ob: ", lx, (cy-=19), buttonWidth,19, &hmd->object, "Parent Object for hook, also recalculates and clears offset"); + uiDefIDPoinBut(block, test_obpoin_but, ID_OB, B_CHANGEDEP, "Ob: ", lx, (cy-=19), buttonWidth,19, &hmd->object, "Parent Object for hook, also recalculates and clears offset"); if(hmd->indexar==NULL) uiDefBut(block, TEX, B_MODIFIER_RECALC, "VGroup: ", lx, (cy-=19), buttonWidth,19, &hmd->name, 0.0, 31.0, 0, 0, "Vertex Group name"); uiBlockBeginAlign(block); @@ -1340,7 +1340,7 @@ static void draw_modifier(uiBlock *block, Object *ob, ModifierData *md, int *xco } else if (md->type==eModifierType_Boolean) { BooleanModifierData *bmd = (BooleanModifierData*) md; uiDefButI(block, MENU, B_MODIFIER_RECALC, "Operation%t|Intersect%x0|Union%x1|Difference%x2", lx,(cy-=19),buttonWidth,19, &bmd->operation, 0.0, 1.0, 0, 0, "Boolean operation to perform"); - uiDefIDPoinBut(block, modifier_testMeshObj, B_CHANGEDEP, "Ob: ", lx, (cy-=19), buttonWidth,19, &bmd->object, "Mesh object to use for boolean operation"); + uiDefIDPoinBut(block, modifier_testMeshObj, ID_OB, B_CHANGEDEP, "Ob: ", lx, (cy-=19), buttonWidth,19, &bmd->object, "Mesh object to use for boolean operation"); } uiBlockEndAlign(block); @@ -1916,7 +1916,7 @@ static void editing_panel_font_type(Object *ob, Curve *cu) uiBlockEndAlign(block); uiDefButBitS(block, TOG, CU_FAST, B_FASTFONT, "Fast Edit", 715,105,78,20, &cu->flag, 0, 0, 0, 0, "Don't fill polygons while editing"); - uiDefIDPoinBut(block, test_obpoin_but, B_TEXTONCURVE, "TextOnCurve:", 480,105,220,19, &cu->textoncurve, "Apply a deforming curve to the text"); + uiDefIDPoinBut(block, test_obpoin_but, ID_OB, B_TEXTONCURVE, "TextOnCurve:", 480,105,220,19, &cu->textoncurve, "Apply a deforming curve to the text"); uiDefBut(block, TEX,REDRAWVIEW3D, "Ob Family:", 480,84,220,19, cu->family, 0.0, 20.0, 0, 0, "Blender uses font from selfmade objects"); uiBlockBeginAlign(block); @@ -2238,8 +2238,8 @@ static void editing_panel_curve_type(Object *ob, Curve *cu) uiDefButF(block, NUM, B_MAKEDISP, "Extrude:", 760,70,150,19, &cu->ext1, 0.0, 5.0, 10, 0, "Curve extrusion size when not using a bevel object"); uiDefButF(block, NUM, B_MAKEDISP, "Bevel Depth:", 760,50,150,19, &cu->ext2, 0.0, 2.0, 1, 0, "Bevel depth when not using a bevel object"); uiDefButS(block, NUM, B_MAKEDISP, "BevResol:", 760,30,150,19, &cu->bevresol, 0.0, 10.0, 0, 0, "Bevel resolution when depth is non-zero and not using a bevel object"); - uiDefIDPoinBut(block, test_obcurpoin_but, B_CHANGEDEP, "BevOb:", 760,10,150,19, &cu->bevobj, "Curve object name that defines the bevel shape"); - uiDefIDPoinBut(block, test_obcurpoin_but, B_CHANGEDEP, "TaperOb:", 760,-10,150,19, &cu->taperobj, "Curve object name that defines the taper (width)"); + uiDefIDPoinBut(block, test_obcurpoin_but, ID_OB, B_CHANGEDEP, "BevOb:", 760,10,150,19, &cu->bevobj, "Curve object name that defines the bevel shape"); + uiDefIDPoinBut(block, test_obcurpoin_but, ID_OB, B_CHANGEDEP, "TaperOb:", 760,-10,150,19, &cu->taperobj, "Curve object name that defines the taper (width)"); uiBlockBeginAlign(block); uiBlockSetCol(block, TH_BUT_SETTING1); @@ -2720,6 +2720,7 @@ static void editing_panel_armature_bones(Object *ob, bArmature *arm) /* Bone naming button */ but=uiDefBut(block, TEX, REDRAWVIEW3D, "BO:", bx-10,by,117,18, &curBone->name, 0, 24, 0, 0, "Change the bone name"); uiButSetFunc(but, validate_editbonebutton_cb, curBone, NULL); + uiButSetCompleteFunc(but, autocomplete_bone, (void *)OBACT); uiDefBut(block, LABEL, 0, "child of", bx+107,by,73,18, NULL, 0.0, 0.0, 0.0, 0.0, ""); @@ -2792,6 +2793,7 @@ static void editing_panel_pose_bones(Object *ob, bArmature *arm) uiBlockBeginAlign(block); but=uiDefBut(block, TEX, REDRAWVIEW3D, "BO:", bx-10,by,117,18, &curBone->name, 0, 24, 0, 0, "Change the bone name"); uiButSetFunc(but, validate_posebonebutton_cb, curBone, NULL); + uiButSetCompleteFunc(but, autocomplete_bone, (void *)ob); /* Dist and weight buttons */ uiDefButF(block, NUM,B_ARM_RECALCDATA, "Dist:", bx+107, by, 105, 18, &curBone->dist, 0.0, 1000.0, 10.0, 0.0, "Bone deformation distance"); diff --git a/source/blender/src/buttons_logic.c b/source/blender/src/buttons_logic.c index f0c169ddd96..f56aefbeedd 100644 --- a/source/blender/src/buttons_logic.c +++ b/source/blender/src/buttons_logic.c @@ -1026,7 +1026,7 @@ static short draw_sensorbuttons(bSensor *sens, uiBlock *block, short xco, short ts= sens->data; /* uiDefBut(block, TEX, 1, "Property:", xco,yco-22,width, 19, &ts->name, 0, 31, 0, 0, "Only look for Objects with this property"); */ - uiDefIDPoinBut(block, test_matpoin_but, 1, "MA:",(short)(xco + 10),(short)(yco-44), (short)(width - 20), 19, &ts->ma, "Only look for floors with this Material"); + uiDefIDPoinBut(block, test_matpoin_but, ID_MA, 1, "MA:",(short)(xco + 10),(short)(yco-44), (short)(width - 20), 19, &ts->ma, "Only look for floors with this Material"); ///* uiDefButF(block, NUM, 1, "Margin:", xco+width/2,yco-44,width/2, 19, &ts->dist, 0.0, 10.0, 100, 0, "Extra margin (distance) for larger sensitivity"); yco-= ysize; break; @@ -1413,7 +1413,7 @@ static short draw_controllerbuttons(bController *cont, uiBlock *block, short xco glRects(xco, yco-ysize, xco+width, yco); uiEmboss((float)xco, (float)yco-ysize, (float)xco+width, (float)yco, 1); - uiDefIDPoinBut(block, test_scriptpoin_but, 1, "Script: ", xco+45,yco-24,width-90, 19, &pc->text, ""); + uiDefIDPoinBut(block, test_scriptpoin_but, ID_SCRIPT, 1, "Script: ", xco+45,yco-24,width-90, 19, &pc->text, ""); yco-= ysize; break; @@ -1565,7 +1565,7 @@ static short draw_actuatorbuttons(bActuator *act, uiBlock *block, short xco, sho str= "Action types %t|Play %x0|Flipper %x2|Loop Stop %x3|Loop End %x4|Property %x6"; #endif uiDefButS(block, MENU, B_REDR, str, xco+30, yco-24, width-60, 19, &aa->type, 0.0, 0.0, 0.0, 0.0, "Action playback type"); - uiDefIDPoinBut(block, test_actionpoin_but, 1, "AC: ", xco+30, yco-44, width-60, 19, &aa->act, "Action name"); + uiDefIDPoinBut(block, test_actionpoin_but, ID_AC, 1, "AC: ", xco+30, yco-44, width-60, 19, &aa->act, "Action name"); if(aa->type == ACT_ACTION_FROM_PROP) { @@ -1657,7 +1657,7 @@ static short draw_actuatorbuttons(bActuator *act, uiBlock *block, short xco, sho uiDefBut(block, TEX, 1, "Prop: ", xco+30,yco-44,width-60, 19, pa->name, 0, 31, 0, 0, "Property name"); if(pa->type==ACT_PROP_COPY) { - uiDefIDPoinBut(block, test_obpoin_but, 1, "OB:", xco+10, yco-64, (width-20)/2, 19, &(pa->ob), "Copy from this Object"); + uiDefIDPoinBut(block, test_obpoin_but, ID_OB, 1, "OB:", xco+10, yco-64, (width-20)/2, 19, &(pa->ob), "Copy from this Object"); uiDefBut(block, TEX, 1, "Prop: ", xco+10+(width-20)/2, yco-64, (width-20)/2, 19, pa->value, 0, 31, 0, 0, "Copy this property"); } else { @@ -1745,7 +1745,7 @@ static short draw_actuatorbuttons(bActuator *act, uiBlock *block, short xco, sho ca= act->data; - uiDefIDPoinBut(block, test_obpoin_but, 1, "OB:", xco+10, yco-24, (width-20)/2, 19, &(ca->ob), "Look at this Object"); + uiDefIDPoinBut(block, test_obpoin_but, ID_OB, 1, "OB:", xco+10, yco-24, (width-20)/2, 19, &(ca->ob), "Look at this Object"); uiDefButF(block, NUM, 0, "Height:", xco+10+(width-20)/2, yco-24, (width-20)/2, 19, &ca->height, 0.0, 20.0, 0, 0, ""); uiDefButF(block, NUM, 0, "Min:", xco+10, yco-44, (width-60)/2, 19, &ca->min, 0.0, 20.0, 0, 0, ""); @@ -1770,7 +1770,7 @@ static short draw_actuatorbuttons(bActuator *act, uiBlock *block, short xco, sho glRects(xco, yco-ysize, xco+width, yco); uiEmboss((float)xco, (float)yco-ysize, (float)xco+width, (float)yco, 1); - uiDefIDPoinBut(block, test_obpoin_but, 1, "OB:", xco+10, yco-44, (width-20)/2, 19, &(eoa->ob), "Add this Object"); + uiDefIDPoinBut(block, test_obpoin_but, ID_OB, 1, "OB:", xco+10, yco-44, (width-20)/2, 19, &(eoa->ob), "Add this Object"); uiDefButI(block, NUM, 0, "Time:", xco+10+(width-20)/2, yco-44, (width-20)/2, 19, &eoa->time, 0.0, 2000.0, 0, 0, "Duration the new Object lives"); wval= (width-60)/3; @@ -1801,14 +1801,14 @@ static short draw_actuatorbuttons(bActuator *act, uiBlock *block, short xco, sho glRects(xco, yco-ysize, xco+width, yco); uiEmboss((float)xco, (float)yco-ysize, (float)xco+width, (float)yco, 1); - uiDefIDPoinBut(block, test_meshpoin_but, 1, "ME:", xco+40, yco-44, (width-80), 19, &(eoa->me), "Add this Object"); + uiDefIDPoinBut(block, test_meshpoin_but, ID_ME, 1, "ME:", xco+40, yco-44, (width-80), 19, &(eoa->me), "Add this Object"); } else if(eoa->type==ACT_EDOB_TRACK_TO) { ysize= 48; glRects(xco, yco-ysize, xco+width, yco); uiEmboss((float)xco, (float)yco-ysize, (float)xco+width, (float)yco, 1); - uiDefIDPoinBut(block, test_obpoin_but, 1, "OB:", xco+10, yco-44, (width-20)/2, 19, &(eoa->ob), "Track to this Object"); + uiDefIDPoinBut(block, test_obpoin_but, ID_OB, 1, "OB:", xco+10, yco-44, (width-20)/2, 19, &(eoa->ob), "Track to this Object"); uiDefButI(block, NUM, 0, "Time:", xco+10+(width-20)/2, yco-44, (width-20)/2-40, 19, &eoa->time, 0.0, 2000.0, 0, 0, "Duration the tracking takes"); uiDefButS(block, TOG, 0, "3D", xco+width-50, yco-44, 40, 19, &eoa->flag, 0.0, 0.0, 0, 0, "Enable 3D tracking"); } @@ -1865,7 +1865,7 @@ static short draw_actuatorbuttons(bActuator *act, uiBlock *block, short xco, sho glRects(xco, yco-ysize, xco+width, yco); uiEmboss((float)xco, (float)yco-ysize, (float)xco+width, (float)yco, 1); - uiDefIDPoinBut(block, test_obpoin_but, 1, "OB:", xco+40, yco-44, (width-80), 19, &(sca->camera), "Set this Camera"); + uiDefIDPoinBut(block, test_obpoin_but, ID_OB, 1, "OB:", xco+40, yco-44, (width-80), 19, &(sca->camera), "Set this Camera"); } else if(sca->type==ACT_SCENE_SET) { @@ -1873,7 +1873,7 @@ static short draw_actuatorbuttons(bActuator *act, uiBlock *block, short xco, sho glRects(xco, yco-ysize, xco+width, yco); uiEmboss((float)xco, (float)yco-ysize, (float)xco+width, (float)yco, 1); - uiDefIDPoinBut(block, test_scenepoin_but, 1, "SCE:", xco+40, yco-44, (width-80), 19, &(sca->scene), "Set this Scene"); + uiDefIDPoinBut(block, test_scenepoin_but, ID_SCE, 1, "SCE:", xco+40, yco-44, (width-80), 19, &(sca->scene), "Set this Scene"); } else if(sca->type==ACT_SCENE_ADD_FRONT) { @@ -1881,7 +1881,7 @@ static short draw_actuatorbuttons(bActuator *act, uiBlock *block, short xco, sho glRects(xco, yco-ysize, xco+width, yco); uiEmboss((float)xco, (float)yco-ysize, (float)xco+width, (float)yco, 1); - uiDefIDPoinBut(block, test_scenepoin_but, 1, "SCE:", xco+40, yco-44, (width-80), 19, &(sca->scene), "Add an Overlay Scene"); + uiDefIDPoinBut(block, test_scenepoin_but, ID_SCE, 1, "SCE:", xco+40, yco-44, (width-80), 19, &(sca->scene), "Add an Overlay Scene"); } else if(sca->type==ACT_SCENE_ADD_BACK) { @@ -1889,7 +1889,7 @@ static short draw_actuatorbuttons(bActuator *act, uiBlock *block, short xco, sho glRects(xco, yco-ysize, xco+width, yco); uiEmboss((float)xco, (float)yco-ysize, (float)xco+width, (float)yco, 1); - uiDefIDPoinBut(block, test_scenepoin_but, 1, "SCE:", xco+40, yco-44, (width-80), 19, &(sca->scene), "Add a Background Scene"); + uiDefIDPoinBut(block, test_scenepoin_but, ID_SCE, 1, "SCE:", xco+40, yco-44, (width-80), 19, &(sca->scene), "Add a Background Scene"); } else if(sca->type==ACT_SCENE_REMOVE) { @@ -1897,7 +1897,7 @@ static short draw_actuatorbuttons(bActuator *act, uiBlock *block, short xco, sho glRects(xco, yco-ysize, xco+width, yco); uiEmboss((float)xco, (float)yco-ysize, (float)xco+width, (float)yco, 1); - uiDefIDPoinBut(block, test_scenepoin_but, 1, "SCE:", xco+40, yco-44, (width-80), 19, &(sca->scene), "Remove a Scene"); + uiDefIDPoinBut(block, test_scenepoin_but, ID_SCE, 1, "SCE:", xco+40, yco-44, (width-80), 19, &(sca->scene), "Remove a Scene"); } else if(sca->type==ACT_SCENE_SUSPEND) { @@ -1905,7 +1905,7 @@ static short draw_actuatorbuttons(bActuator *act, uiBlock *block, short xco, sho glRects(xco, yco-ysize, xco+width, yco); uiEmboss((float)xco, (float)yco-ysize, (float)xco+width, (float)yco, 1); - uiDefIDPoinBut(block, test_scenepoin_but, 1, "SCE:", xco+40, yco-44, (width-80), 19, &(sca->scene), "Pause a Scene"); + uiDefIDPoinBut(block, test_scenepoin_but, ID_SCE, 1, "SCE:", xco+40, yco-44, (width-80), 19, &(sca->scene), "Pause a Scene"); } else if(sca->type==ACT_SCENE_RESUME) { @@ -1913,7 +1913,7 @@ static short draw_actuatorbuttons(bActuator *act, uiBlock *block, short xco, sho glRects(xco, yco-ysize, xco+width, yco); uiEmboss((float)xco, (float)yco-ysize, (float)xco+width, (float)yco, 1); - uiDefIDPoinBut(block, test_scenepoin_but, 1, "SCE:", xco+40, yco-44, (width-80), 19, &(sca->scene), "Unpause a Scene"); + uiDefIDPoinBut(block, test_scenepoin_but, ID_SCE, 1, "SCE:", xco+40, yco-44, (width-80), 19, &(sca->scene), "Unpause a Scene"); } str= "Scene %t|Restart %x0|Set Scene %x1|Set Camera %x2|Add OverlayScene %x3|Add BackgroundScene %x4|Remove Scene %x5|Suspend Scene %x6|Resume Scene %x7"; diff --git a/source/blender/src/buttons_object.c b/source/blender/src/buttons_object.c index 4b779429baa..06a7eb29f82 100644 --- a/source/blender/src/buttons_object.c +++ b/source/blender/src/buttons_object.c @@ -409,6 +409,45 @@ static void constraint_moveDown(void *ob_v, void *con_v) BIF_undo_push("Move constraint"); } +/* autocomplete callback for ID buttons */ +void autocomplete_bone(char *str, void *arg_v) +{ + Object *ob= (Object *)arg_v; + char truncate[40]= {0}; + + if(ob==NULL || ob->pose==NULL) return; + + /* search if str matches the beginning of an ID struct */ + if(str[0]) { + bPoseChannel *pchan; + + for(pchan= ob->pose->chanbase.first; pchan; pchan= pchan->next) { + int a; + + for(a=0; a<31; a++) { + if(str[a]==0 || str[a]!=pchan->name[a]) + break; + } + /* found a match */ + if(str[a]==0) { + /* first match */ + if(truncate[0]==0) + BLI_strncpy(truncate, pchan->name, 32); + else { + /* remove from truncate what is not in bone->name */ + for(a=0; a<31; a++) { + if(truncate[a]!=pchan->name[a]) + truncate[a]= 0; + } + } + } + } + if(truncate[0]) + BLI_strncpy(str, truncate, 32); + } +} + + static void draw_constraint (uiBlock *block, ListBase *list, bConstraint *con, short *xco, short *yco) { @@ -508,11 +547,12 @@ static void draw_constraint (uiBlock *block, ListBase *list, bConstraint *con, s /* Draw target parameters */ uiBlockBeginAlign(block); - uiDefIDPoinBut(block, test_obpoin_but, B_CONSTRAINT_CHANGETARGET, "OB:", *xco+120, *yco-24, 135, 18, &data->tar, "Target Object"); + uiDefIDPoinBut(block, test_obpoin_but, ID_OB, B_CONSTRAINT_CHANGETARGET, "OB:", *xco+120, *yco-24, 135, 18, &data->tar, "Target Object"); arm = get_armature(data->tar); if (arm){ but=uiDefBut(block, TEX, B_CONSTRAINT_CHANGETARGET, "BO:", *xco+120, *yco-42,135,18, &data->subtarget, 0, 24, 0, 0, "Subtarget Bone"); + uiButSetCompleteFunc(but, autocomplete_bone, (void *)data->tar); } else strcpy (data->subtarget, ""); @@ -521,7 +561,7 @@ static void draw_constraint (uiBlock *block, ListBase *list, bConstraint *con, s /* Draw action button */ uiBlockBeginAlign(block); uiDefButS(block, TOG, B_CONSTRAINT_TEST, "Local", *xco+((width/2)-117), *yco-46, 78, 18, &data->local, 0, 0, 0, 0, "Use true local rotation difference"); - uiDefIDPoinBut(block, test_actionpoin_but, B_CONSTRAINT_TEST, "AC:", *xco+((width/2)-117), *yco-64, 78, 18, &data->act, "Action containing the keyed motion for this bone"); + uiDefIDPoinBut(block, test_actionpoin_but, ID_AC, B_CONSTRAINT_TEST, "AC:", *xco+((width/2)-117), *yco-64, 78, 18, &data->act, "Action containing the keyed motion for this bone"); uiDefButS(block, MENU, B_CONSTRAINT_TEST, "Key on%t|X Rot%x0|Y Rot%x1|Z Rot%x2", *xco+((width/2)-117), *yco-84, 78, 18, &data->type, 0, 24, 0, 0, "Specify which transformation channel from the target is used to key the action"); uiBlockBeginAlign(block); @@ -546,11 +586,12 @@ static void draw_constraint (uiBlock *block, ListBase *list, bConstraint *con, s /* Draw target parameters */ uiBlockBeginAlign(block); - uiDefIDPoinBut(block, test_obpoin_but, B_CONSTRAINT_CHANGETARGET, "OB:", *xco+120, *yco-24, 135, 18, &data->tar, "Target Object"); + uiDefIDPoinBut(block, test_obpoin_but, ID_OB, B_CONSTRAINT_CHANGETARGET, "OB:", *xco+120, *yco-24, 135, 18, &data->tar, "Target Object"); arm = get_armature(data->tar); if (arm){ but=uiDefBut(block, TEX, B_CONSTRAINT_CHANGETARGET, "BO:", *xco+120, *yco-42,135,18, &data->subtarget, 0, 24, 0, 0, "Subtarget Bone"); + uiButSetCompleteFunc(but, autocomplete_bone, (void *)data->tar); } else strcpy (data->subtarget, ""); @@ -579,11 +620,12 @@ static void draw_constraint (uiBlock *block, ListBase *list, bConstraint *con, s /* Draw target parameters */ uiBlockBeginAlign(block); - uiDefIDPoinBut(block, test_obpoin_but, B_CONSTRAINT_CHANGETARGET, "OB:", *xco+120, *yco-24, 135, 18, &data->tar, "Target Object"); + uiDefIDPoinBut(block, test_obpoin_but, ID_OB, B_CONSTRAINT_CHANGETARGET, "OB:", *xco+120, *yco-24, 135, 18, &data->tar, "Target Object"); arm = get_armature(data->tar); if (arm){ but=uiDefBut(block, TEX, B_CONSTRAINT_CHANGETARGET, "BO:", *xco+120, *yco-42,135,18, &data->subtarget, 0, 24, 0, 0, "Subtarget Bone"); + uiButSetCompleteFunc(but, autocomplete_bone, (void *)data->tar); } else strcpy (data->subtarget, ""); @@ -611,11 +653,13 @@ static void draw_constraint (uiBlock *block, ListBase *list, bConstraint *con, s uiDefButBitS(block, TOG, CONSTRAINT_IK_ROT, B_CONSTRAINT_TEST, "Rot", *xco, *yco-24,60,19, &data->flag, 0, 0, 0, 0, "Chain follows rotation of target"); uiBlockBeginAlign(block); - uiDefIDPoinBut(block, test_obpoin_but, B_CONSTRAINT_CHANGETARGET, "OB:", *xco+120, *yco-24, 135, 19, &data->tar, "Target Object"); + uiDefIDPoinBut(block, test_obpoin_but, ID_OB, B_CONSTRAINT_CHANGETARGET, "OB:", *xco+120, *yco-24, 135, 19, &data->tar, "Target Object"); arm = get_armature(data->tar); - if (arm) + if (arm) { but=uiDefBut(block, TEX, B_CONSTRAINT_CHANGETARGET, "BO:", *xco+120, *yco-42,135,19, &data->subtarget, 0, 24, 0, 0, "Subtarget Bone"); + uiButSetCompleteFunc(but, autocomplete_bone, (void *)data->tar); + } else strcpy (data->subtarget, ""); @@ -643,11 +687,12 @@ static void draw_constraint (uiBlock *block, ListBase *list, bConstraint *con, s /* Draw target parameters */ uiBlockBeginAlign(block); - uiDefIDPoinBut(block, test_obpoin_but, B_CONSTRAINT_CHANGETARGET, "OB:", *xco+120, *yco-24, 135, 18, &data->tar, "Target Object"); + uiDefIDPoinBut(block, test_obpoin_but, ID_OB, B_CONSTRAINT_CHANGETARGET, "OB:", *xco+120, *yco-24, 135, 18, &data->tar, "Target Object"); arm = get_armature(data->tar); if (arm){ but=uiDefBut(block, TEX, B_CONSTRAINT_CHANGETARGET, "BO:", *xco+120, *yco-42,135,18, &data->subtarget, 0, 24, 0, 0, "Subtarget Bone"); + uiButSetCompleteFunc(but, autocomplete_bone, (void *)data->tar); } else strcpy (data->subtarget, ""); @@ -687,11 +732,12 @@ static void draw_constraint (uiBlock *block, ListBase *list, bConstraint *con, s /* Draw target parameters */ uiBlockBeginAlign(block); - uiDefIDPoinBut(block, test_obpoin_but, B_CONSTRAINT_CHANGETARGET, "OB:", *xco+120, *yco-24, 135, 18, &data->tar, "Target Object"); + uiDefIDPoinBut(block, test_obpoin_but, ID_OB, B_CONSTRAINT_CHANGETARGET, "OB:", *xco+120, *yco-24, 135, 18, &data->tar, "Target Object"); arm = get_armature(data->tar); if (arm){ but=uiDefBut(block, TEX, B_CONSTRAINT_CHANGETARGET, "BO:", *xco+120, *yco-42,135,18, &data->subtarget, 0, 24, 0, 0, "Subtarget Bone"); + uiButSetCompleteFunc(but, autocomplete_bone, (void *)data->tar); } else strcpy (data->subtarget, ""); @@ -722,11 +768,12 @@ static void draw_constraint (uiBlock *block, ListBase *list, bConstraint *con, s /* Draw target parameters */ uiBlockBeginAlign(block); - uiDefIDPoinBut(block, test_obpoin_but, B_CONSTRAINT_CHANGETARGET, "OB:", *xco+120, *yco-24, 135, 18, &data->tar, "Target Object"); + uiDefIDPoinBut(block, test_obpoin_but, ID_OB, B_CONSTRAINT_CHANGETARGET, "OB:", *xco+120, *yco-24, 135, 18, &data->tar, "Target Object"); arm = get_armature(data->tar); if (arm){ but=uiDefBut(block, TEX, B_CONSTRAINT_CHANGETARGET, "BO:", *xco+120, *yco-42,135,18, &data->subtarget, 0, 24, 0, 0, "Subtarget Bone"); + uiButSetCompleteFunc(but, autocomplete_bone, (void *)data->tar); } else strcpy (data->subtarget, ""); @@ -762,7 +809,7 @@ static void draw_constraint (uiBlock *block, ListBase *list, bConstraint *con, s uiDefBut(block, LABEL, B_CONSTRAINT_TEST, "Target:", *xco+65, *yco-24, 50, 18, NULL, 0.0, 0.0, 0.0, 0.0, ""); /* Draw target parameters */ - uiDefIDPoinBut(block, test_obpoin_but, B_CONSTRAINT_CHANGETARGET, "OB:", *xco+120, *yco-24, 135, 18, &data->tar, "Target Object"); + uiDefIDPoinBut(block, test_obpoin_but, ID_OB, B_CONSTRAINT_CHANGETARGET, "OB:", *xco+120, *yco-24, 135, 18, &data->tar, "Target Object"); /* Draw Curve Follow toggle */ but=uiDefButBitI(block, TOG, 1, B_CONSTRAINT_TEST, "CurveFollow", *xco+39, *yco-44, 100, 18, &data->followflag, 0, 24, 0, 0, "Object will follow the heading and banking of the curve"); @@ -803,11 +850,12 @@ static void draw_constraint (uiBlock *block, ListBase *list, bConstraint *con, s /* Draw target parameters */ uiBlockBeginAlign(block); - uiDefIDPoinBut(block, test_obpoin_but, B_CONSTRAINT_CHANGETARGET, "OB:", *xco+120, *yco-24, 135, 18, &data->tar, "Target Object"); + uiDefIDPoinBut(block, test_obpoin_but, ID_OB, B_CONSTRAINT_CHANGETARGET, "OB:", *xco+120, *yco-24, 135, 18, &data->tar, "Target Object"); arm = get_armature(data->tar); if (arm){ but=uiDefBut(block, TEX, B_CONSTRAINT_CHANGETARGET, "BO:", *xco+120, *yco-42,135,18, &data->subtarget, 0, 24, 0, 0, "Subtarget Bone"); + uiButSetCompleteFunc(but, autocomplete_bone, (void *)data->tar); } else strcpy (data->subtarget, ""); diff --git a/source/blender/src/buttons_scene.c b/source/blender/src/buttons_scene.c index e9e8d2fb64a..17760fcfa93 100644 --- a/source/blender/src/buttons_scene.c +++ b/source/blender/src/buttons_scene.c @@ -1024,7 +1024,7 @@ static void render_panel_output(void) if(G.scene->set) { uiSetButLock(1, NULL); - uiDefIDPoinBut(block, test_scenepoin_but, 0, "", 31, 120, 100, 20, &(G.scene->set), "Name of the Set"); + uiDefIDPoinBut(block, test_scenepoin_but, ID_SCE, 0, "", 31, 120, 100, 20, &(G.scene->set), "Name of the Set"); uiClearButLock(); uiDefIconBut(block, BUT, B_CLEARSET, ICON_X, 132, 120, 20, 20, 0, 0, 0, 0, 0, "Remove Set link"); } diff --git a/source/blender/src/buttons_script.c b/source/blender/src/buttons_script.c index 0d7ce4aea99..e29f0af16cb 100644 --- a/source/blender/src/buttons_script.c +++ b/source/blender/src/buttons_script.c @@ -280,7 +280,7 @@ void draw_scriptlink(uiBlock *block, ScriptLink *script, int sx, int sy, int sce uiDefButS(block, MENU, 1, str, (short)sx, (short)sy, 140, 19, &script->flag[script->actscript-1], 0, 0, 0, 0, "Script links for this event"); - uiDefIDPoinBut(block, test_scriptpoin_but, 1, "", (short)(sx+140),(short)sy, 140, 19, &script->scripts[script->actscript-1], "Name of Script to link"); + uiDefIDPoinBut(block, test_scriptpoin_but, ID_SCRIPT, 1, "", (short)(sx+140),(short)sy, 140, 19, &script->scripts[script->actscript-1], "Name of Script to link"); } sprintf(str,"%d Scr:", script->totscript); diff --git a/source/blender/src/buttons_shading.c b/source/blender/src/buttons_shading.c index 4878a7d3b48..9b07cbb2ba3 100644 --- a/source/blender/src/buttons_shading.c +++ b/source/blender/src/buttons_shading.c @@ -1163,7 +1163,7 @@ static void texture_panel_envmap(Tex *tex) uiBlockEndAlign(block); } - uiDefIDPoinBut(block, test_obpoin_but, B_ENV_OB, "Ob:", 10,90,150,20, &(env->object), "Displays object to use as viewpoint for environment map: click to change"); + uiDefIDPoinBut(block, test_obpoin_but, ID_OB, B_ENV_OB, "Ob:", 10,90,150,20, &(env->object), "Displays object to use as viewpoint for environment map: click to change"); if(env->stype!=ENV_LOAD) uiDefButS(block, NUM, B_ENV_FREE, "CubeRes", 160,90,150,20, &env->cuberes, 50, 2048.0, 0, 0, "Sets the pixel resolution of the rendered environment map"); @@ -1837,7 +1837,7 @@ static void world_panel_texture(World *wrld) uiDefButS(block, ROW, B_MATPRV, "Sphere", 200,110,55,20, &(mtex->texco), 4.0, (float)TEXCO_H_SPHEREMAP, 0, 0, "For 360 degree panorama sky, spherical mapped, only top half"); uiDefButS(block, ROW, B_MATPRV, "Tube", 255,110,45,20, &(mtex->texco), 4.0, (float)TEXCO_H_TUBEMAP, 0, 0, "For 360 degree panorama sky, cylindrical mapped, only top half"); uiDefButS(block, ROW, B_MATPRV, "Object", 100,90,70,20, &(mtex->texco), 4.0, (float)TEXCO_OBJECT, 0, 0, "Uses linked object's coordinates for texture coordinates"); - uiDefIDPoinBut(block, test_obpoin_but, B_MATPRV, "", 170,90,130,20, &(mtex->object), ""); + uiDefIDPoinBut(block, test_obpoin_but, ID_OB, B_MATPRV, "", 170,90,130,20, &(mtex->object), ""); uiBlockBeginAlign(block); uiDefButF(block, NUM, B_MATPRV, "dX", 100,50,100,19, mtex->ofs, -20.0, 20.0, 10, 0, "Fine tunes texture mapping X coordinate"); @@ -2174,7 +2174,7 @@ static void lamp_panel_texture(Object *ob, Lamp *la) uiDefButS(block, ROW, B_MATPRV, "Glob", 100,110,60,20, &(mtex->texco), 4.0, (float)TEXCO_GLOB, 0, 0, "Uses global coordinates for the texture coordinates"); uiDefButS(block, ROW, B_MATPRV, "View", 160,110,70,20, &(mtex->texco), 4.0, (float)TEXCO_VIEW, 0, 0, "Uses view coordinates for the texture coordinates"); uiDefButS(block, ROW, B_MATPRV, "Object", 230,110,70,20, &(mtex->texco), 4.0, (float)TEXCO_OBJECT, 0, 0, "Uses linked object's coordinates for texture coordinates"); - uiDefIDPoinBut(block, test_obpoin_but, B_MATPRV, "", 100,90,200,20, &(mtex->object), ""); + uiDefIDPoinBut(block, test_obpoin_but, ID_OB, B_MATPRV, "", 100,90,200,20, &(mtex->object), ""); uiBlockBeginAlign(block); uiDefButF(block, NUM, B_MATPRV, "dX", 100,50,100,18, mtex->ofs, -20.0, 20.0, 10, 0, "Fine tunes texture mapping X coordinate"); @@ -2726,7 +2726,7 @@ static void material_panel_map_input(Object *ob, Material *ma) uiBlockBeginAlign(block); uiDefButS(block, ROW, B_MATPRV, "UV", 630,166,40,18, &(mtex->texco), 4.0, (float)TEXCO_UV, 0, 0, "Uses UV coordinates for texture coordinates"); uiDefButS(block, ROW, B_MATPRV, "Object", 670,166,75,18, &(mtex->texco), 4.0, (float)TEXCO_OBJECT, 0, 0, "Uses linked object's coordinates for texture coordinates"); - uiDefIDPoinBut(block, test_obpoin_but, B_MATPRV, "",745,166,163,18, &(mtex->object), ""); + uiDefIDPoinBut(block, test_obpoin_but, ID_OB, B_MATPRV, "",745,166,163,18, &(mtex->object), ""); uiDefButS(block, ROW, B_MATPRV, "Glob", 630,146,45,18, &(mtex->texco), 4.0, (float)TEXCO_GLOB, 0, 0, "Uses global coordinates for the texture coordinates"); uiDefButS(block, ROW, B_MATPRV, "Orco", 675,146,50,18, &(mtex->texco), 4.0, (float)TEXCO_ORCO, 0, 0, "Uses the original coordinates of the mesh"); diff --git a/source/blender/src/drawipo.c b/source/blender/src/drawipo.c index a108492a5a3..59e2779fe50 100644 --- a/source/blender/src/drawipo.c +++ b/source/blender/src/drawipo.c @@ -1880,7 +1880,7 @@ static void ipo_panel_properties(short cntrl) // IPO_HANDLER_PROPERTIES uiDefBut(block, BUT, B_IPO_DRIVER, "Remove", 210,265,100,19, NULL, 0.0f, 0.0f, 0, 0, "Remove Driver for this Ipo Channel"); uiBlockBeginAlign(block); - uiDefIDPoinBut(block, test_obpoin_but, B_IPO_DEPCHANGE, "OB:", 10, 240, 150, 20, &(driver->ob), "Driver Object"); + uiDefIDPoinBut(block, test_obpoin_but, ID_OB, B_IPO_DEPCHANGE, "OB:", 10, 240, 150, 20, &(driver->ob), "Driver Object"); if(driver->ob) { int icon=ICON_OBJECT; diff --git a/source/blender/src/drawview.c b/source/blender/src/drawview.c index 0902d87cce3..e1777be225d 100644 --- a/source/blender/src/drawview.c +++ b/source/blender/src/drawview.c @@ -1787,7 +1787,7 @@ static void view3d_panel_object(short cntrl) // VIEW3D_HANDLER_OBJECT bt= uiDefBut(block, TEX, B_IDNAME, "OB: ", 10,180,140,20, ob->id.name+2, 0.0, 19.0, 0, 0, ""); uiButSetFunc(bt, test_idbutton_cb, ob->id.name, NULL); - uiDefIDPoinBut(block, test_obpoin_but, B_OBJECTPANELPARENT, "Par:", 160, 180, 140, 20, &ob->parent, "Parent Object"); + uiDefIDPoinBut(block, test_obpoin_but, ID_OB, B_OBJECTPANELPARENT, "Par:", 160, 180, 140, 20, &ob->parent, "Parent Object"); } lim= 10000.0f*MAX2(1.0, G.vd->grid); diff --git a/source/blender/src/interface.c b/source/blender/src/interface.c index c244b73559d..710bf80a999 100644 --- a/source/blender/src/interface.c +++ b/source/blender/src/interface.c @@ -72,8 +72,9 @@ #include "DNA_vfont_types.h" #include "BKE_blender.h" -#include "BKE_utildefines.h" #include "BKE_global.h" +#include "BKE_library.h" +#include "BKE_utildefines.h" #include "BIF_gl.h" #include "BIF_graphics.h" @@ -1572,6 +1573,14 @@ static int ui_do_but_TEX(uiBut *but) } } break; + case TABKEY: + if(but->autocomplete_func) { + but->autocomplete_func(str, but->autofunc_arg); + but->pos= strlen(str); + len= but->pos; + dodraw= 1; + } + break; } } @@ -4849,6 +4858,46 @@ static int findBitIndex(unsigned int x) { return idx; } } + +/* autocomplete callback for ID buttons */ +static void autocomplete_id(char *str, void *arg_v) +{ + int blocktype= (int)arg_v; + ListBase *listb= wich_libbase(G.main, blocktype); + char truncate[32]= {0}; + + if(listb==NULL) return; + + /* search if str matches the beginning of an ID struct */ + if(str[0]) { + ID *id; + + for(id= listb->first; id; id= id->next) { + int a; + + for(a=0; a<21; a++) { + if(str[a]==0 || str[a]!=id->name[a+2]) + break; + } + /* found a match */ + if(str[a]==0) { + /* first match */ + if(truncate[0]==0) + strcpy(truncate, id->name+2); + else { + /* remove from truncate what is not in id->name */ + for(a=0; a<21; a++) { + if(truncate[a]!=id->name[a+2]) + truncate[a]= 0; + } + } + } + } + if(truncate[0]) + BLI_strncpy(str, truncate, 21); + } +} + static uiBut *uiDefButBit(uiBlock *block, int type, int bit, int retval, char *str, short x1, short y1, short x2, short y2, void *poin, float min, float max, float a1, float a2, char *tip) { int bitIdx= findBitIndex(bit); @@ -5145,12 +5194,24 @@ void uiButSetFunc(uiBut *but, void (*func)(void *arg1, void *arg2), void *arg1, but->func_arg2= arg2; } -void uiDefIDPoinBut(uiBlock *block, uiIDPoinFuncFP func, int retval, char *str, short x1, short y1, short x2, short y2, void *idpp, char *tip) +void uiButSetCompleteFunc(uiBut *but, void (*func)(char *str, void *arg), void *arg) +{ + but->autocomplete_func= func; + but->autofunc_arg= arg; +} + + +uiBut *uiDefIDPoinBut(uiBlock *block, uiIDPoinFuncFP func, short blocktype, int retval, char *str, short x1, short y1, short x2, short y2, void *idpp, char *tip) { uiBut *but= ui_def_but(block, IDPOIN, retval, str, x1, y1, x2, y2, NULL, 0.0, 0.0, 0.0, 0.0, tip); but->idpoin_func= func; but->idpoin_idpp= (ID**) idpp; ui_check_but(but); + + if(blocktype) + uiButSetCompleteFunc(but, autocomplete_id, (void *)(int)blocktype); + + return but; } uiBut *uiDefBlockBut(uiBlock *block, uiBlockFuncFP func, void *arg, char *str, short x1, short y1, short x2, short y2, char *tip) diff --git a/source/blender/src/meshtools.c b/source/blender/src/meshtools.c index 13163703f75..422a10163fb 100644 --- a/source/blender/src/meshtools.c +++ b/source/blender/src/meshtools.c @@ -594,6 +594,8 @@ void sort_faces(void) /* ********************* MESH VERTEX OCTREE LOOKUP ************* */ +/* important note; this is unfinished, needs better API for editmode, and custom threshold */ + #define MOC_RES 8 #define MOC_NODE_RES 8 #define MOC_THRESH 0.0001f @@ -702,13 +704,18 @@ static int mesh_octree_find_index(MocNode **bt, MVert *mvert, float *co) for(a=0; a<MOC_NODE_RES; a++) { if((*bt)->index[a]) { /* does mesh verts and editmode, code looks potential dangerous, octree should really be filled OK! */ - if(mvert) + if(mvert) { vec= (mvert+(*bt)->index[a]-1)->co; - else - vec= ((EditVert *)INT_TO_POINTER((*bt)->index[a]))->co; - - if(FloatCompare(vec, co, MOC_THRESH)) - return (*bt)->index[a]-1; + + if(FloatCompare(vec, co, MOC_THRESH)) + return (*bt)->index[a]-1; + } + else { + EditVert *eve= (EditVert *)INT_TO_POINTER((*bt)->index[a]); + + if(FloatCompare(eve->co, co, MOC_THRESH)) + return (int)eve; + } } else return -1; } |