Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJuho Vepsalainen <bebraw@gmail.com>2007-08-22 10:26:37 +0400
committerJuho Vepsalainen <bebraw@gmail.com>2007-08-22 10:26:37 +0400
commit941ee4139ea1583b6c4e83d5ed7ad693f8709db9 (patch)
treec32fb97df02a40df66150b599e6bf7eb1a60c799 /source/blender/src
parent567e63425305084712527b9e24604558f1ea3881 (diff)
Autocompletion to Geometry input node:
This commit adds autocompletion and "red alert" feature to text input fields (UV and VCol) of the Geometry material input node. The functionality is similar to one found in UV part of the "Map Input" panel found in Material buttons context of the Buttons Window.
Diffstat (limited to 'source/blender/src')
-rw-r--r--source/blender/src/buttons_shading.c4
-rw-r--r--source/blender/src/drawnode.c59
2 files changed, 59 insertions, 4 deletions
diff --git a/source/blender/src/buttons_shading.c b/source/blender/src/buttons_shading.c
index c3531e14161..9309a07642a 100644
--- a/source/blender/src/buttons_shading.c
+++ b/source/blender/src/buttons_shading.c
@@ -3029,7 +3029,7 @@ static void material_panel_map_to(Material *ma, int from_nodes)
}
/* autocomplete callback for buttons */
-static void autocomplete_uv(char *str, void *arg_v)
+void autocomplete_uv(char *str, void *arg_v)
{
Mesh *me;
CustomDataLayer *layer;
@@ -3050,7 +3050,7 @@ static void autocomplete_uv(char *str, void *arg_v)
autocomplete_end(autocpl, str);
}
-static int verify_valid_uv_name(char *str)
+int verify_valid_uv_name(char *str)
{
Mesh *me;
CustomDataLayer *layer;
diff --git a/source/blender/src/drawnode.c b/source/blender/src/drawnode.c
index 883fd05909f..d9878d40d8e 100644
--- a/source/blender/src/drawnode.c
+++ b/source/blender/src/drawnode.c
@@ -36,10 +36,12 @@
#include "DNA_action_types.h"
#include "DNA_color_types.h"
+#include "DNA_customdata_types.h"
#include "DNA_ipo_types.h"
#include "DNA_ID.h"
#include "DNA_image_types.h"
#include "DNA_material_types.h"
+#include "DNA_mesh_types.h"
#include "DNA_node_types.h"
#include "DNA_object_types.h"
#include "DNA_scene_types.h"
@@ -88,6 +90,49 @@
#include "interface.h" /* urm... for rasterpos_safe, roundbox */
#include "mydevice.h"
+extern void autocomplete_uv(char *str, void *arg_v);
+extern int verify_valid_uv_name(char *str);
+
+/* autocomplete callback for buttons */
+static void autocomplete_vcol(char *str, void *arg_v)
+{
+ Mesh *me;
+ CustomDataLayer *layer;
+ AutoComplete *autocpl;
+ int a;
+
+ if(str[0]==0)
+ return;
+
+ autocpl= autocomplete_begin(str, 32);
+
+ /* search if str matches the beginning of name */
+ for(me= G.main->mesh.first; me; me=me->id.next)
+ for(a=0, layer= me->fdata.layers; a<me->fdata.totlayer; a++, layer++)
+ if(layer->type == CD_MCOL)
+ autocomplete_do_name(autocpl, layer->name);
+
+ autocomplete_end(autocpl, str);
+}
+
+static int verify_valid_vcol_name(char *str)
+{
+ Mesh *me;
+ CustomDataLayer *layer;
+ int a;
+
+ if(str[0]==0)
+ return 1;
+
+ /* search if str matches the name */
+ for(me= G.main->mesh.first; me; me=me->id.next)
+ for(a=0, layer= me->fdata.layers; a<me->fdata.totlayer; a++, layer++)
+ if(layer->type == CD_MCOL)
+ if(strcmp(layer->name, str)==0)
+ return 1;
+
+ return 0;
+}
static void snode_drawstring(SpaceNode *snode, char *str, int okwidth)
{
@@ -606,10 +651,20 @@ static int node_shader_buts_vect_math(uiBlock *block, bNodeTree *ntree, bNode *n
static int node_shader_buts_geometry(uiBlock *block, bNodeTree *ntree, bNode *node, rctf *butr)
{
if(block) {
+ uiBut *but;
NodeGeometry *ngeo= (NodeGeometry*)node->storage;
- uiDefBut(block, TEX, B_NODE_EXEC+node->nr, "UV:", butr->xmin, butr->ymin+20, butr->xmax-butr->xmin, 20, ngeo->uvname, 0, 31, 0, 0, "Set name of UV layer to use, default is active UV layer");
- uiDefBut(block, TEX, B_NODE_EXEC+node->nr, "Col:", butr->xmin, butr->ymin, butr->xmax-butr->xmin, 20, ngeo->colname, 0, 31, 0, 0, "Set name of vertex color layer to use, default is active vertex color layer");
+ if(!verify_valid_uv_name(ngeo->uvname))
+ uiBlockSetCol(block, TH_REDALERT);
+ but= uiDefBut(block, TEX, B_NODE_EXEC+node->nr, "UV:", butr->xmin, butr->ymin+20, butr->xmax-butr->xmin, 20, ngeo->uvname, 0, 31, 0, 0, "Set name of UV layer to use, default is active UV layer");
+ uiButSetCompleteFunc(but, autocomplete_uv, NULL);
+ uiBlockSetCol(block, TH_AUTO);
+
+ if(!verify_valid_vcol_name(ngeo->colname))
+ uiBlockSetCol(block, TH_REDALERT);
+ but= uiDefBut(block, TEX, B_NODE_EXEC+node->nr, "Col:", butr->xmin, butr->ymin, butr->xmax-butr->xmin, 20, ngeo->colname, 0, 31, 0, 0, "Set name of vertex color layer to use, default is active vertex color layer");
+ uiButSetCompleteFunc(but, autocomplete_vcol, NULL);
+ uiBlockSetCol(block, TH_AUTO);
}
return 40;