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:
Diffstat (limited to 'source/blender/src')
-rw-r--r--source/blender/src/buttons_editing.c3
-rw-r--r--source/blender/src/buttons_logic.c1
-rw-r--r--source/blender/src/buttons_object.c2
-rw-r--r--source/blender/src/buttons_scene.c2
-rw-r--r--source/blender/src/buttons_shading.c347
-rw-r--r--source/blender/src/drawimage.c2
-rw-r--r--source/blender/src/drawnode.c300
-rw-r--r--source/blender/src/editnode.c184
-rw-r--r--source/blender/src/header_action.c2
-rw-r--r--source/blender/src/header_image.c2
-rw-r--r--source/blender/src/header_info.c4
-rw-r--r--source/blender/src/header_ipo.c2
-rw-r--r--source/blender/src/header_node.c2
-rw-r--r--source/blender/src/header_script.c2
-rw-r--r--source/blender/src/header_sound.c2
-rw-r--r--source/blender/src/header_text.c2
-rw-r--r--source/blender/src/headerbuttons.c182
-rw-r--r--source/blender/src/interface.c28
-rw-r--r--source/blender/src/interface_panel.c16
-rw-r--r--source/blender/src/previewrender.c24
-rw-r--r--source/blender/src/toolbox.c4
-rw-r--r--source/blender/src/usiblender.c2
22 files changed, 544 insertions, 571 deletions
diff --git a/source/blender/src/buttons_editing.c b/source/blender/src/buttons_editing.c
index 04541def982..77a9b8580ed 100644
--- a/source/blender/src/buttons_editing.c
+++ b/source/blender/src/buttons_editing.c
@@ -150,7 +150,6 @@
#include "BSE_headerbuttons.h"
#include "BSE_trans_types.h"
#include "BSE_view.h"
-#include "BSE_buttons.h"
#include "BSE_seqaudio.h"
#include "RE_renderconverter.h" // make_sticky
@@ -3423,7 +3422,7 @@ static void editing_panel_links(Object *ob)
local= B_LATTLOCAL;
}
uiBlockSetCol(block, TH_BUT_SETTING2);
- xco= std_libbuttons(block, 143, 180, 0, NULL, browse, id, idfrom, &(G.buts->menunr), alone, local, 0, 0, B_KEEPDATA);
+ xco= std_libbuttons(block, 143, 180, 0, NULL, browse, GS(id->name), 0, id, idfrom, &(G.buts->menunr), alone, local, 0, 0, B_KEEPDATA);
uiBlockSetCol(block, TH_AUTO);
}
if(ob) {
diff --git a/source/blender/src/buttons_logic.c b/source/blender/src/buttons_logic.c
index 9933a907897..d26ade8b561 100644
--- a/source/blender/src/buttons_logic.c
+++ b/source/blender/src/buttons_logic.c
@@ -81,7 +81,6 @@
#include "BDR_editcurve.h"
-#include "BSE_buttons.h"
#include "BSE_headerbuttons.h"
#include "BSE_filesel.h"
diff --git a/source/blender/src/buttons_object.c b/source/blender/src/buttons_object.c
index ec806a138aa..33df6cce276 100644
--- a/source/blender/src/buttons_object.c
+++ b/source/blender/src/buttons_object.c
@@ -1449,7 +1449,7 @@ static void object_panel_object(Object *ob)
/* object name */
uiBlockSetCol(block, TH_BUT_SETTING2);
- xco= std_libbuttons(block, 10, 180, 0, NULL, 0, &ob->id, NULL, &(G.buts->menunr), B_OBALONE, B_OBLOCAL, 0, 0, B_KEEPDATA);
+ xco= std_libbuttons(block, 10, 180, 0, NULL, 0, ID_OB, 0, &ob->id, NULL, &(G.buts->menunr), B_OBALONE, B_OBLOCAL, 0, 0, B_KEEPDATA);
uiBlockSetCol(block, TH_AUTO);
/* parent */
diff --git a/source/blender/src/buttons_scene.c b/source/blender/src/buttons_scene.c
index 4093a0fc89a..7f565a9317c 100644
--- a/source/blender/src/buttons_scene.c
+++ b/source/blender/src/buttons_scene.c
@@ -347,7 +347,7 @@ static void sound_panel_sound(bSound *sound)
// warning: abuse of texnr here! (ton didnt code!)
buttons_active_id(&id, &idfrom);
- std_libbuttons(block, 10, 160, 0, NULL, B_SOUNDBROWSE2, id, idfrom, &(G.buts->texnr), 1, 0, 0, 0, 0);
+ std_libbuttons(block, 10, 160, 0, NULL, B_SOUNDBROWSE2, ID_SO, 0, id, idfrom, &(G.buts->texnr), 1, 0, 0, 0, 0);
if (sound) {
diff --git a/source/blender/src/buttons_shading.c b/source/blender/src/buttons_shading.c
index 51f9b2531c6..85deda481a5 100644
--- a/source/blender/src/buttons_shading.c
+++ b/source/blender/src/buttons_shading.c
@@ -1222,13 +1222,13 @@ static void texture_panel_texture(MTex *mtex, Material *ma, World *wrld, Lamp *l
uiBlockSetCol(block, TH_BUT_SETTING2);
if(ma) {
- std_libbuttons(block, 10, 180, 0, NULL, B_TEXBROWSE, id, idfrom, &(G.buts->texnr), B_TEXALONE, B_TEXLOCAL, B_TEXDELETE, B_AUTOTEXNAME, B_KEEPDATA);
+ std_libbuttons(block, 10, 180, 0, NULL, B_TEXBROWSE, ID_TE, 0, id, idfrom, &(G.buts->texnr), B_TEXALONE, B_TEXLOCAL, B_TEXDELETE, B_AUTOTEXNAME, B_KEEPDATA);
}
else if(wrld) {
- std_libbuttons(block, 10, 180, 0, NULL, B_WTEXBROWSE, id, idfrom, &(G.buts->texnr), B_TEXALONE, B_TEXLOCAL, B_TEXDELETE, B_AUTOTEXNAME, B_KEEPDATA);
+ std_libbuttons(block, 10, 180, 0, NULL, B_WTEXBROWSE, ID_TE, 0, id, idfrom, &(G.buts->texnr), B_TEXALONE, B_TEXLOCAL, B_TEXDELETE, B_AUTOTEXNAME, B_KEEPDATA);
}
else if(la) {
- std_libbuttons(block, 10, 180, 0, NULL, B_LTEXBROWSE, id, idfrom, &(G.buts->texnr), B_TEXALONE, B_TEXLOCAL, B_TEXDELETE, B_AUTOTEXNAME, B_KEEPDATA);
+ std_libbuttons(block, 10, 180, 0, NULL, B_LTEXBROWSE, ID_TE, 0, id, idfrom, &(G.buts->texnr), B_TEXALONE, B_TEXLOCAL, B_TEXDELETE, B_AUTOTEXNAME, B_KEEPDATA);
}
uiBlockSetCol(block, TH_BUT_NEUTRAL);
@@ -1813,7 +1813,7 @@ static void world_panel_world(World *wrld)
if(uiNewPanel(curarea, block, "World", "World", 320, 0, 318, 204)==0) return;
uiBlockSetCol(block, TH_BUT_SETTING2);
- std_libbuttons(block, 10, 180, 0, NULL, B_WORLDBROWSE, (ID *)wrld, (ID *)G.scene, &(G.buts->menunr), B_WORLDALONE, B_WORLDLOCAL, B_WORLDDELETE, 0, B_KEEPDATA);
+ std_libbuttons(block, 10, 180, 0, NULL, B_WORLDBROWSE, ID_WO, 0, (ID *)wrld, (ID *)G.scene, &(G.buts->menunr), B_WORLDALONE, B_WORLDLOCAL, B_WORLDDELETE, 0, B_KEEPDATA);
if(wrld==NULL) return;
@@ -2259,7 +2259,7 @@ static void lamp_panel_lamp(Object *ob, Lamp *la)
uiSetButLock(la->id.lib!=0, "Can't edit library data");
uiBlockSetCol(block, TH_BUT_SETTING2);
- xco= std_libbuttons(block, 8, 180, 0, NULL, B_LAMPBROWSE, (ID *)la, (ID *)ob, &(G.buts->menunr), B_LAMPALONE, B_LAMPLOCAL, 0, 0, 0);
+ xco= std_libbuttons(block, 8, 180, 0, NULL, B_LAMPBROWSE, ID_LA, 0, (ID *)la, (ID *)ob, &(G.buts->menunr), B_LAMPALONE, B_LAMPLOCAL, 0, 0, 0);
uiBlockSetCol(block, TH_AUTO);
uiDefButF(block, NUM,B_LAMPREDRAW,"Dist:", xco,180,300-xco,20,&la->dist, 0.01, 5000.0*grid, 100, 0, "Sets the distance value at which light intensity is half");
@@ -2568,6 +2568,7 @@ void do_matbuts(unsigned short event)
allqueue(REDRAWNODE, 0);
allqueue(REDRAWBUTSSHADING, 0);
break;
+
}
}
@@ -3004,6 +3005,7 @@ static void material_panel_shading(Material *ma)
}
}
+#if 0
static void matlayer_add(void *ma_v, void *ml_v)
{
Material *ma= ma_v;
@@ -3086,7 +3088,6 @@ static void matlayer_alone(void *ml_v, void *unused)
allqueue(REDRAWOOPS, 0);
}
-
static void material_panel_layers(Material *ma)
{
uiBlock *block;
@@ -3203,39 +3204,8 @@ static void material_panel_layers(Material *ma)
}
if(yco < 0) uiNewPanelHeight(block, 204-yco);
-
-}
-
-static void material_panel_nodes(Material *ma)
-{
- Material *nodema;
- bNode *node;
- uiBlock *block;
- char str[64];
-
- block= uiNewBlock(&curarea->uiblocks, "material_panel_nodes", UI_EMBOSS, UI_HELV, curarea->win);
- uiNewPanelTabbed("Preview", "Material");
- if(uiNewPanel(curarea, block, "Nodes", "Material", 0, 0, 318, 204)==0) return;
-
- uiDefButC(block, TOG, B_MAT_USENODES, "Use Nodes", 10,180,150,20, &ma->use_nodes, 0.0f, 0.0f, 0, 0, "");
- nodema= get_active_matlayer(ma);
- if(nodema) {
- sprintf(str, "Active: %s", nodema->id.name+2);
- uiDefBut(block, LABEL, B_NOP, str, 160,180,150,20, NULL, 0.0f, 0.0f, 0, 0, "");
- }
- node= nodeGetActive(ma->nodetree);
- if(node==NULL) return;
-
- if(node->typeinfo->butfunc) {
- rctf rct;
- rct.xmin= 10.0f;
- rct.xmax= rct.xmin+node->typeinfo->width;
- rct.ymax= 155.0;
- rct.ymin= rct.ymax - (float)node->typeinfo->butfunc(NULL, node, NULL);
- node->typeinfo->butfunc(block, node, &rct);
- }
}
-
+#endif
static void material_panel_ramps(Material *ma)
{
@@ -3306,63 +3276,20 @@ static uiBlock *strand_menu(void *mat_v)
}
-static void material_panel_material(Object *ob, Material *ma)
+static void material_panel_material(Material *ma)
{
uiBlock *block;
- ID *id, *idn, *idfrom;
- uiBut *but;
- float *colpoin = NULL, min;
+ float *colpoin = NULL;
int rgbsel = 0;
- char str[30];
block= uiNewBlock(&curarea->uiblocks, "material_panel_material", UI_EMBOSS, UI_HELV, curarea->win);
if(uiNewPanel(curarea, block, "Material", "Material", 320, 0, 318, 204)==0) return;
-
- /* first do the browse but */
- buttons_active_id(&id, &idfrom); /* base material, not the matlayer! */
-
- uiBlockSetCol(block, TH_BUT_SETTING2);
- std_libbuttons(block, 8, 200, 0, NULL, B_MATBROWSE, id, idfrom, &(G.buts->menunr), B_MATALONE, B_MATLOCAL, B_MATDELETE, B_AUTOMATNAME, B_KEEPDATA);
+
+ uiSetButLock(ma->id.lib!=NULL, "Can't edit library data");
uiDefIconBut(block, BUT, B_MATCOPY, ICON_COPYUP, 262,200,XIC,YIC, 0, 0, 0, 0, 0, "Copies Material to the buffer");
- uiSetButLock(id && id->lib, "Can't edit library data");
uiDefIconBut(block, BUT, B_MATPASTE, ICON_PASTEUP, 283,200,XIC,YIC, 0, 0, 0, 0, 0, "Pastes Material from the buffer");
- if(ob->actcol==0) ob->actcol= 1; /* because of TOG|BIT button */
-
- uiBlockBeginAlign(block);
-
- /* id is the block from which the material is used */
- if( BTST(ob->colbits, ob->actcol-1) ) id= (ID *)ob;
- else id= ob->data;
-
- /* indicate which one is linking a material */
- if(id) {
- strncpy(str, id->name, 2);
- str[2]= ':'; str[3]= 0;
- but= uiDefBut(block, TEX, B_IDNAME, str, 8,174,115,20, id->name+2, 0.0, 18.0, 0, 0, "Shows the block the material is linked to");
- uiButSetFunc(but, test_idbutton_cb, id->name, NULL);
- }
- uiBlockSetCol(block, TH_BUT_ACTION);
- uiDefButBitS(block, TOG, 1<<(ob->actcol-1), B_MATFROM, "OB", 125,174,32,20, &ob->colbits, 0, 0, 0, 0, "Links material to object");
- idn= ob->data;
- strncpy(str, idn->name, 2);
- str[2]= 0;
- uiBlockSetCol(block, TH_BUT_SETTING);
- uiDefButBitS(block, TOGN, 1<<(ob->actcol-1), B_MATFROM, str, 158,174,32,20, &ob->colbits, 0, 0, 0, 0, "Shows the block the material is linked to");
- uiBlockSetCol(block, TH_AUTO);
-
- sprintf(str, "%d Mat", ob->totcol);
- if(ob->totcol) min= 1.0; else min= 0.0;
- uiDefButC(block, NUM, B_ACTCOL, str, 191,174,112,20, &(ob->actcol), min, (float)ob->totcol, 0, 0, "Shows the number of materials on object and the active material");
- uiBlockEndAlign(block);
-
- if(ob->totcol==0) return;
- uiSetButLock(id->lib!=0, "Can't edit library data");
-
- ma= get_active_matlayer(ma);
- if(ma==NULL) return;
-
if(ma->dynamode & MA_DRAW_DYNABUTS) {
uiBlockBeginAlign(block);
uiDefButF(block, NUMSLI, B_DIFF, "Restitut ", 128,120,175,20, &ma->reflect, 0.0, 1.0, 0, 0, "Elasticity of collisions");
@@ -3377,14 +3304,14 @@ static void material_panel_material(Object *ob, Material *ma)
if(!(ma->mode & MA_HALO)) {
uiBlockBeginAlign(block);
uiBlockSetCol(block, TH_BUT_SETTING1);
- uiDefButBitI(block, TOG, MA_VERTEXCOL, B_REDR, "VCol Light", 8,146,74,20, &(ma->mode), 0, 0, 0, 0, "Adds vertex colours as extra light");
- uiDefButBitI(block, TOG, MA_VERTEXCOLP, B_REDR, "VCol Paint", 82,146,74,20, &(ma->mode), 0, 0, 0, 0, "Replaces material's colours with vertex colours");
- uiDefButBitI(block, TOG, MA_FACETEXTURE, B_REDR, "TexFace", 156,146,74,20, &(ma->mode), 0, 0, 0, 0, "Sets UV-Editor assigned texture as color and texture info for faces");
- uiDefButBitI(block, TOG, MA_SHLESS, B_MATPRV, "Shadeless", 230,146,73,20, &(ma->mode), 0, 0, 0, 0, "Makes material insensitive to light or shadow");
- uiDefButBitI(block, TOG, MA_FULL_OSA, 0, "Full Osa", 8,127,74,19, &(ma->mode), 0.0, 10.0, 0, 0, "Forces to render all OSA samples, for shading and texture antialiasing");
- uiDefBlockBut(block, strand_menu, ma, "Strands", 82,127,74, 20, "Display strand settings for static particles");
- uiDefButBitI(block, TOG, MA_WIRE, 0, "Wire", 156,127,74,19, &(ma->mode), 0, 0, 0, 0, "Renders only the edges of faces as a wireframe");
- uiDefButBitI(block, TOG, MA_ZINV, 0, "ZInvert", 230,127,73,19, &(ma->mode), 0, 0, 0, 0, "Renders material's faces with inverted Z Buffer");
+ uiDefButBitI(block, TOG, MA_VERTEXCOL, B_REDR, "VCol Light", 8,166,74,20, &(ma->mode), 0, 0, 0, 0, "Adds vertex colours as extra light");
+ uiDefButBitI(block, TOG, MA_VERTEXCOLP, B_REDR, "VCol Paint", 82,166,74,20, &(ma->mode), 0, 0, 0, 0, "Replaces material's colours with vertex colours");
+ uiDefButBitI(block, TOG, MA_FACETEXTURE, B_REDR, "TexFace", 156,166,74,20, &(ma->mode), 0, 0, 0, 0, "Sets UV-Editor assigned texture as color and texture info for faces");
+ uiDefButBitI(block, TOG, MA_SHLESS, B_MATPRV, "Shadeless", 230,166,73,20, &(ma->mode), 0, 0, 0, 0, "Makes material insensitive to light or shadow");
+ uiDefButBitI(block, TOG, MA_FULL_OSA, 0, "Full Osa", 8,147,74,19, &(ma->mode), 0.0, 10.0, 0, 0, "Forces to render all OSA samples, for shading and texture antialiasing");
+ uiDefBlockBut(block, strand_menu, ma, "Strands", 82,147,74, 20, "Display strand settings for static particles");
+ uiDefButBitI(block, TOG, MA_WIRE, 0, "Wire", 156,147,74,19, &(ma->mode), 0, 0, 0, 0, "Renders only the edges of faces as a wireframe");
+ uiDefButBitI(block, TOG, MA_ZINV, 0, "ZInvert", 230,147,73,19, &(ma->mode), 0, 0, 0, 0, "Renders material's faces with inverted Z Buffer");
}
uiBlockSetCol(block, TH_AUTO);
@@ -3435,6 +3362,104 @@ static void material_panel_material(Object *ob, Material *ma)
}
+static void material_panel_nodes(Material *ma)
+{
+ bNode *node;
+ uiBlock *block;
+
+ block= uiNewBlock(&curarea->uiblocks, "material_panel_nodes", UI_EMBOSS, UI_HELV, curarea->win);
+ uiNewPanelTabbed("Links", "Material");
+ if(uiNewPanel(curarea, block, "Nodes", "Material", 640, 0, 318, 204)==0) return;
+
+ node= nodeGetActive(ma->nodetree);
+ if(node==NULL) return;
+ /* we dont display the buttons here for the active material, is in links panel */
+ if(node==nodeGetActiveID(ma->nodetree, ID_MA)) return;
+
+ if(node->typeinfo->butfunc) {
+ rctf rct;
+ rct.xmin= 10.0f;
+ rct.xmax= rct.xmin+node->typeinfo->width;
+ rct.ymax= 155.0;
+ rct.ymin= rct.ymax - (float)node->typeinfo->butfunc(NULL, NULL, node, NULL);
+ node->typeinfo->butfunc(block, ma->nodetree, node, &rct);
+ }
+}
+
+static void material_panel_links(Object *ob, Material *ma)
+{
+ uiBlock *block;
+ uiBut *but;
+ ID *id, *idn, *idfrom;
+ bNode *node=NULL;
+ float min;
+ short xco;
+ char str[30], *cp;
+
+ block= uiNewBlock(&curarea->uiblocks, "material_panel_links", UI_EMBOSS, UI_HELV, curarea->win);
+ if(uiNewPanel(curarea, block, "Links", "Material", 310, 0, 318, 204)==0) return; /* 310 makes sorting code to put it right after preview panel */
+
+ /* Links from object to material/nodes */
+ uiDefBut(block, ROUNDBOX, 0, "", 5, 125, 310, 75, NULL, 7.0, 0.0, 15 , 20, "");
+ uiDefBut(block, LABEL, B_DIFF, "Link to Object", 10, 180, 300, 20, 0, 0, 0, 0, 0, "");
+
+ /* the main material browse but */
+ buttons_active_id(&id, &idfrom); /* base material! */
+
+ uiBlockSetCol(block, TH_BUT_SETTING2);
+ xco= std_libbuttons(block, 10, 160, 0, NULL, B_MATBROWSE, ID_MA, 0, id, idfrom, &(G.buts->menunr), B_MATALONE, B_MATLOCAL, B_MATDELETE, B_AUTOMATNAME, B_KEEPDATA);
+ if(ma) cp= &ma->use_nodes; else cp= &G.buts->use_nodes;
+ uiDefButC(block, TOG, B_MAT_USENODES, "Nodes", xco+5,160,300-xco-5,20, cp, 0.0f, 0.0f, 0, 0, "");
+ G.buts->use_nodes= *cp;
+
+ if(ob->actcol==0) ob->actcol= 1; /* because of TOG|BIT button */
+
+ uiBlockBeginAlign(block);
+
+ /* id is the block from which the material is used */
+ if( BTST(ob->colbits, ob->actcol-1) ) id= (ID *)ob;
+ else id= ob->data;
+
+ /* indicate which one is linking a material */
+ if(id) {
+ strncpy(str, id->name, 2);
+ str[2]= ':'; str[3]= 0;
+ but= uiDefBut(block, TEX, B_IDNAME, str, 10,135,115,20, id->name+2, 0.0, 18.0, 0, 0, "Shows the block the material is linked to");
+ uiButSetFunc(but, test_idbutton_cb, id->name, NULL);
+ }
+ uiBlockSetCol(block, TH_BUT_ACTION);
+ uiDefButBitS(block, TOG, 1<<(ob->actcol-1), B_MATFROM, "OB", 125,135,32,20, &ob->colbits, 0, 0, 0, 0, "Links material to object");
+ idn= ob->data;
+ strncpy(str, idn->name, 2);
+ str[2]= 0;
+ uiBlockSetCol(block, TH_BUT_SETTING);
+ uiDefButBitS(block, TOGN, 1<<(ob->actcol-1), B_MATFROM, str, 158,135,32,20, &ob->colbits, 0, 0, 0, 0, "Shows the block the material is linked to");
+ uiBlockSetCol(block, TH_AUTO);
+
+ sprintf(str, "%d Mat", ob->totcol);
+ if(ob->totcol) min= 1.0; else min= 0.0;
+ uiDefButC(block, NUM, B_ACTCOL, str, 190,135,110,20, &(ob->actcol), min, (float)ob->totcol, 0, 0, "Shows the number of materials on object and the active material");
+ uiBlockEndAlign(block);
+
+ /* Active material node */
+ if(ma && ma->use_nodes) {
+ uiDefBut(block, ROUNDBOX, 0, "", 5, 40, 310, 75, NULL, 7.0, 0.0, 15 , 20, "");
+ uiDefBut(block, LABEL, B_DIFF, "Active Material Node", 10, 95, 300, 20, 0, 0, 0, 0, 0, "");
+
+ if(ma) node= nodeGetActiveID(ma->nodetree, ID_MA);
+ if(node==NULL) return;
+
+ if(node->typeinfo->butfunc) {
+ rctf rct;
+ rct.xmin= 10.0f;
+ rct.xmax= 300.0f;
+ rct.ymax= 95.0f;
+ rct.ymin= rct.ymax - (float)node->typeinfo->butfunc(NULL, NULL, node, NULL);
+ node->typeinfo->butfunc(block, ma->nodetree, node, &rct);
+ }
+ }
+}
+
static void material_panel_preview(Material *ma)
{
uiBlock *block;
@@ -3479,34 +3504,35 @@ void material_panels()
// always draw first 2 panels
material_panel_preview(ma);
- material_panel_material(ob, ma);
+ material_panel_links(ob, ma);
- if(ma) {
- material_panel_layers(ma);
+ if(ma && ma->use_nodes) {
material_panel_nodes(ma);
+ }
+ //material_panel_layers(ma);
+
+ ma= get_active_matlayer(ma); // checks nodes too
+ if(ma) {
+ material_panel_material(ma);
+ material_panel_ramps(ma);
+ material_panel_shading(ma);
- ma= get_active_matlayer(ma);
- if(ma) {
- material_panel_ramps(ma);
- material_panel_shading(ma);
-
- if (G.scene->r.renderer==R_INTERN)
- material_panel_tramir(ma);
- else {
- if(ma->YF_ar==0.f) {
- ma->YF_ar = ma->YF_ag = ma->YF_ab = 1;
- ma->YF_dscale = 1;
- }
- material_panel_tramir_yafray(ma);
- }
-
- material_panel_texture(ma);
-
- mtex= ma->mtex[ ma->texact ];
- if(mtex && mtex->tex) {
- material_panel_map_input(ob, ma);
- material_panel_map_to(ma);
+ if (G.scene->r.renderer==R_INTERN)
+ material_panel_tramir(ma);
+ else {
+ if(ma->YF_ar==0.f) {
+ ma->YF_ar = ma->YF_ag = ma->YF_ab = 1;
+ ma->YF_dscale = 1;
}
+ material_panel_tramir_yafray(ma);
+ }
+
+ material_panel_texture(ma);
+
+ mtex= ma->mtex[ ma->texact ];
+ if(mtex && mtex->tex) {
+ material_panel_map_input(ob, ma);
+ material_panel_map_to(ma);
}
}
}
@@ -3639,93 +3665,6 @@ void texture_panels()
}
}
-/* old popup.. too hackish, should be fixed once (ton) */
-void clever_numbuts_buts()
-{
- Material *ma;
- Lamp *la;
- World *wo;
- static char hexrgb[8]; /* Uh... */
- static char hexspec[8]; /* Uh... */
- static char hexmir[8]; /* Uh... */
- static char hexho[8];
- static char hexze[8];
- int rgb[3];
-
- if(G.buts->mainb!= CONTEXT_SHADING) return;
-
- switch (G.buts->tab[CONTEXT_SHADING]) {
- case TAB_SHADING_LAMP:
- la= G.buts->lockpoin;
- if (la){
- sprintf(hexrgb, "%02X%02X%02X", (int)(la->r*255), (int)(la->g*255), (int)(la->b*255));
- add_numbut(0, TEX, "RGB:", 0, 6, hexrgb, "HTML Hex value for the lamp color");
- do_clever_numbuts("Lamp RGB Hex Values", 1, REDRAW);
- sscanf(hexrgb, "%02X%02X%02X", &rgb[0], &rgb[1], &rgb[2]);
- la->r = (rgb[0]/255.0 >= 0.0 && rgb[0]/255.0 <= 1.0 ? rgb[0]/255.0 : 0.0) ;
- la->g = (rgb[1]/255.0 >= 0.0 && rgb[1]/255.0 <= 1.0 ? rgb[1]/255.0 : 0.0) ;
- la->b = (rgb[2]/255.0 >= 0.0 && rgb[2]/255.0 <= 1.0 ? rgb[2]/255.0 : 0.0) ;
- BIF_preview_changed(ID_MA);
- }
- break;
- case TAB_SHADING_WORLD:
- wo= G.buts->lockpoin;
- if (wo){
- sprintf(hexho, "%02X%02X%02X", (int)(wo->horr*255), (int)(wo->horg*255), (int)(wo->horb*255));
- sprintf(hexze, "%02X%02X%02X", (int)(wo->zenr*255), (int)(wo->zeng*255), (int)(wo->zenb*255));
- add_numbut(0, TEX, "Zen:", 0, 6, hexze, "HTML Hex value for the Zenith color");
- add_numbut(1, TEX, "Hor:", 0, 6, hexho, "HTML Hex value for the Horizon color");
- do_clever_numbuts("World RGB Hex Values", 2, REDRAW);
-
- sscanf(hexho, "%02X%02X%02X", &rgb[0], &rgb[1], &rgb[2]);
- wo->horr = (rgb[0]/255.0 >= 0.0 && rgb[0]/255.0 <= 1.0 ? rgb[0]/255.0 : 0.0) ;
- wo->horg = (rgb[1]/255.0 >= 0.0 && rgb[1]/255.0 <= 1.0 ? rgb[1]/255.0 : 0.0) ;
- wo->horb = (rgb[2]/255.0 >= 0.0 && rgb[2]/255.0 <= 1.0 ? rgb[2]/255.0 : 0.0) ;
- sscanf(hexze, "%02X%02X%02X", &rgb[0], &rgb[1], &rgb[2]);
- wo->zenr = (rgb[0]/255.0 >= 0.0 && rgb[0]/255.0 <= 1.0 ? rgb[0]/255.0 : 0.0) ;
- wo->zeng = (rgb[1]/255.0 >= 0.0 && rgb[1]/255.0 <= 1.0 ? rgb[1]/255.0 : 0.0) ;
- wo->zenb = (rgb[2]/255.0 >= 0.0 && rgb[2]/255.0 <= 1.0 ? rgb[2]/255.0 : 0.0) ;
- BIF_preview_changed(ID_WO);
-
- }
- break;
- case TAB_SHADING_MAT:
-
- ma= get_active_matlayer(G.buts->lockpoin);
-
- /* Build a hex value */
- if (ma){
- sprintf(hexrgb, "%02X%02X%02X", (int)(ma->r*255), (int)(ma->g*255), (int)(ma->b*255));
- sprintf(hexspec, "%02X%02X%02X", (int)(ma->specr*255), (int)(ma->specg*255), (int)(ma->specb*255));
- sprintf(hexmir, "%02X%02X%02X", (int)(ma->mirr*255), (int)(ma->mirg*255), (int)(ma->mirb*255));
-
- add_numbut(0, TEX, "Col:", 0, 6, hexrgb, "HTML Hex value for the RGB color");
- add_numbut(1, TEX, "Spec:", 0, 6, hexspec, "HTML Hex value for the Spec color");
- add_numbut(2, TEX, "Mir:", 0, 6, hexmir, "HTML Hex value for the Mir color");
- do_clever_numbuts("Material RGB Hex Values", 3, REDRAW);
-
- /* Assign the new hex value */
- sscanf(hexrgb, "%02X%02X%02X", &rgb[0], &rgb[1], &rgb[2]);
- ma->r = (rgb[0]/255.0 >= 0.0 && rgb[0]/255.0 <= 1.0 ? rgb[0]/255.0 : 0.0) ;
- ma->g = (rgb[1]/255.0 >= 0.0 && rgb[1]/255.0 <= 1.0 ? rgb[1]/255.0 : 0.0) ;
- ma->b = (rgb[2]/255.0 >= 0.0 && rgb[2]/255.0 <= 1.0 ? rgb[2]/255.0 : 0.0) ;
- sscanf(hexspec, "%02X%02X%02X", &rgb[0], &rgb[1], &rgb[2]);
- ma->specr = (rgb[0]/255.0 >= 0.0 && rgb[0]/255.0 <= 1.0 ? rgb[0]/255.0 : 0.0) ;
- ma->specg = (rgb[1]/255.0 >= 0.0 && rgb[1]/255.0 <= 1.0 ? rgb[1]/255.0 : 0.0) ;
- ma->specb = (rgb[2]/255.0 >= 0.0 && rgb[2]/255.0 <= 1.0 ? rgb[2]/255.0 : 0.0) ;
- sscanf(hexmir, "%02X%02X%02X", &rgb[0], &rgb[1], &rgb[2]);
- ma->mirr = (rgb[0]/255.0 >= 0.0 && rgb[0]/255.0 <= 1.0 ? rgb[0]/255.0 : 0.0) ;
- ma->mirg = (rgb[1]/255.0 >= 0.0 && rgb[1]/255.0 <= 1.0 ? rgb[1]/255.0 : 0.0) ;
- ma->mirb = (rgb[2]/255.0 >= 0.0 && rgb[2]/255.0 <= 1.0 ? rgb[2]/255.0 : 0.0) ;
-
- BIF_preview_changed(ID_MA);
- }
- break;
- }
-}
-
-
-
void radio_panels()
{
Radio *rad;
diff --git a/source/blender/src/drawimage.c b/source/blender/src/drawimage.c
index d9a85da601e..115bcd46270 100644
--- a/source/blender/src/drawimage.c
+++ b/source/blender/src/drawimage.c
@@ -891,7 +891,7 @@ static void image_panel_paint(short cntrl) // IMAGE_HANDLER_PROPERTIES
uiBlockBeginAlign(block);
id= (ID*)Gip.clone.image;
- std_libbuttons(block, 979, 40, 0, NULL, B_SIMACLONEBROWSE, id, 0, &G.sima->menunr, 0, 0, B_SIMACLONEDELETE, 0, 0);
+ std_libbuttons(block, 979, 40, 0, NULL, B_SIMACLONEBROWSE, ID_IM, 0, id, 0, &G.sima->menunr, 0, 0, B_SIMACLONEDELETE, 0, 0);
uiDefButF(block, NUMSLI, B_SIMABRUSHCHANGE, "B ",979,20,230,19, &Gip.clone.alpha , 0.0, 1.0, 0, 0, "Blend clone image");
uiBlockEndAlign(block);
diff --git a/source/blender/src/drawnode.c b/source/blender/src/drawnode.c
index a64cc2d674e..40c40db30a5 100644
--- a/source/blender/src/drawnode.c
+++ b/source/blender/src/drawnode.c
@@ -47,6 +47,8 @@
#include "BKE_global.h"
#include "BKE_object.h"
+#include "BKE_library.h"
+#include "BKE_main.h"
#include "BKE_material.h"
#include "BKE_node.h"
#include "BKE_utildefines.h"
@@ -57,8 +59,10 @@
#include "BIF_interface_icons.h"
#include "BIF_language.h"
#include "BIF_mywindow.h"
+#include "BIF_previewrender.h"
#include "BIF_resources.h"
#include "BIF_screen.h"
+#include "BIF_space.h"
#include "BSE_drawipo.h"
#include "BSE_node.h"
@@ -101,35 +105,12 @@ static void snode_drawstring(SpaceNode *snode, char *str, int okwidth)
/* ************** Socket callbacks *********** */
/* NOTE: this is a block-menu, needs 0 events, otherwise the menu closes */
-static uiBlock *socket_value_menu(void *sock_v)
-{
- bNodeSocket *sock= sock_v;
- uiBlock *block;
- char name[NODE_MAXSTR];
-
- /* don't add new block to a listbase if caller is LABEL button */
- block= uiNewBlock(NULL, "socket menu", UI_EMBOSS, UI_HELV, curarea->win);
-
- /* use this for a fake extra empy space around the buttons */
- uiDefBut(block, LABEL, 0, "", -4, -4, 188, 28, NULL, 0, 0, 0, 0, "");
-
- BLI_strncpy(name, sock->name, NODE_MAXSTR-1);
- strcat(name, " ");
- uiDefButF(block, NUMSLI, 0, name, 0,0,180,20, sock->ns.vec, 0.0, 1.0, 10, 0, "");
-
- uiBlockSetDirection(block, UI_TOP);
-
- return block;
-}
-
-/* NOTE: this is a block-menu, needs 0 events, otherwise the menu closes */
static uiBlock *socket_vector_menu(void *sock_v)
{
bNodeSocket *sock= sock_v;
uiBlock *block;
- /* don't add new block to a listbase if caller is LABEL button */
- block= uiNewBlock(NULL, "socket menu", UI_EMBOSS, UI_HELV, curarea->win);
+ block= uiNewBlock(&curarea->uiblocks, "socket menu", UI_EMBOSS, UI_HELV, curarea->win);
/* use this for a fake extra empy space around the buttons */
uiDefBut(block, LABEL, 0, "", -4, -4, 188, 68, NULL, 0, 0, 0, 0, "");
@@ -144,71 +125,138 @@ static uiBlock *socket_vector_menu(void *sock_v)
return block;
}
-static uiBlock *socket_color_menu(void *sock_v)
+/* ****************** BUTTON CALLBACKS FOR SHADER NODES ***************** */
+
+
+static void node_ID_title_cb(void *node_v, void *unused_v)
{
- bNodeSocket *sock= sock_v;
- uiBlock *block;
-
- /* don't add new block to a listbase if caller is LABEL button */
- block= uiNewBlock(NULL, "socket menu", UI_EMBOSS, UI_HELV, curarea->win);
-
- /* use this for a fake extra empy space around the buttons */
- uiDefBut(block, LABEL, 0, "", -4, -4, 188, 68, NULL, 0, 0, 0, 0, "");
+ bNode *node= node_v;
+
+ if(node->id) {
+ test_idbutton(node->id->name+2); /* library.c, verifies unique name */
+ BLI_strncpy(node->name, node->id->name+2, 21);
+
+ allqueue(REDRAWBUTSSHADING, 0);
+ allqueue(REDRAWNODE, 0);
+ allqueue(REDRAWOOPS, 0);
+ }
+}
+
+static void node_mat_alone_cb(void *node_v, void *unused)
+{
+ bNode *node= node_v;
- uiBlockBeginAlign(block);
- uiDefButF(block, NUMSLI, 0, "R ", 0,40,180,20, sock->ns.vec, 0.0, 1.0, 10, 0, "");
- uiDefButF(block, NUMSLI, 0, "G ", 0,20,180,20, sock->ns.vec+1, 0.0, 1.0, 10, 0, "");
- uiDefButF(block, NUMSLI, 0, "B ", 0,0,180,20, sock->ns.vec+2, 0.0, 1.0, 10, 0, "");
+ node->id= (ID *)copy_material((Material *)node->id);
- uiBlockSetDirection(block, UI_TOP);
-
- return block;
+ BIF_undo_push("Single user material");
+ allqueue(REDRAWBUTSSHADING, 0);
+ allqueue(REDRAWNODE, 0);
+ allqueue(REDRAWOOPS, 0);
}
-static void node_ID_title_cb(void *node_v, void *unused_v)
+static void node_browse_mat_cb(void *ntree_v, void *node_v)
{
+ bNodeTree *ntree= ntree_v;
bNode *node= node_v;
+
+ if(node->menunr==32767 || node->menunr==0) { /* code for Add New */
+ if(node->id) {
+ /* make copy, but make sure it doesnt have the node tag nor nodes */
+ Material *ma= (Material *)node->id;
+ ma->id.us--;
+ ma= copy_material(ma);
+ ma->use_nodes= 0;
+ if(ma->nodetree) ntreeFreeTree(ma->nodetree);
+ ma->nodetree= NULL;
+ node->id= (ID *)ma;
+ }
+ else node->id= (ID *)add_material("MatNode");
+ }
+ else {
+ if(node->id) node->id->us--;
+ node->id= BLI_findlink(&G.main->mat, node->menunr-1);
+ id_us_plus(node->id);
+ }
+ BLI_strncpy(node->name, node->id->name+2, 21);
+
+ nodeSetActive(ntree, node);
- if(node->id)
- BLI_strncpy(node->name, node->id->name+2, 21);
-}
+ allqueue(REDRAWBUTSSHADING, 0);
+ allqueue(REDRAWNODE, 0);
+ BIF_preview_changed(ID_MA);
-/* ****************** BUTTON CALLBACKS FOR SHADER NODES ***************** */
+ node->menunr= 0;
+}
-static int node_shader_buts_material(uiBlock *block, bNode *node, rctf *butr)
+static int node_shader_buts_material(uiBlock *block, bNodeTree *ntree, bNode *node, rctf *butr)
{
if(block) {
uiBut *bt;
- float dx= (butr->xmax-butr->xmin)/3.0f;
+ short dx= (short)((butr->xmax-butr->xmin)/3.0f), has_us= (node->id && node->id->us>1);
+ char *strp;
uiBlockBeginAlign(block);
- bt= uiDefIDPoinBut(block, test_matpoin_but, ID_MA, B_NODE_EXEC, "",
- butr->xmin, butr->ymin+19.0f, butr->xmax-butr->xmin, 19.0f,
- &node->id, "");
- uiButSetFunc(bt, node_ID_title_cb, node, NULL);
-
- uiDefButBitS(block, TOG, SH_NODE_MAT_DIFF, B_NODE_EXEC, "Diff",
- butr->xmin, butr->ymin, dx, 19.0f,
- &node->custom1, 0, 0, 0, 0, "Material Node outputs Diffuse");
- uiDefButBitS(block, TOG, SH_NODE_MAT_SPEC, B_NODE_EXEC, "Spec",
- butr->xmin+dx, butr->ymin, dx, 19.0f,
- &node->custom1, 0, 0, 0, 0, "Material Node outputs Specular");
- uiDefButBitS(block, TOG, SH_NODE_MAT_NEG, B_NODE_EXEC, "Neg Normal",
- butr->xmin+2.0f*dx, butr->ymin, dx, 19.0f,
- &node->custom1, 0, 0, 0, 0, "Material Node uses inverted Normal");
+ if(has_us) uiBlockSetCol(block, TH_BUT_SETTING1);
+ else uiBlockSetCol(block, TH_BUT_SETTING2);
+
+ /* browse button */
+ IDnames_to_pupstring(&strp, NULL, "ADD NEW %x32767", &(G.main->mat), NULL, NULL);
+ node->menunr= 0;
+ bt= uiDefButS(block, MENU, B_NOP, strp,
+ butr->xmin, butr->ymin+19, 19, 19,
+ &node->menunr, 0, 0, 0, 0, "Browses existing choices or adds NEW");
+ uiButSetFunc(bt, node_browse_mat_cb, ntree, node);
+ if(strp) MEM_freeN(strp);
+
+ /* Add New button */
+ if(node->id==NULL) {
+ bt= uiDefBut(block, BUT, B_NOP, "Add New",
+ butr->xmin+19, butr->ymin+19, (short)(butr->xmax-butr->xmin-19.0f), 19,
+ NULL, 0.0, 0.0, 0, 0, "Add new Material");
+ uiButSetFunc(bt, node_browse_mat_cb, ntree, node);
+ }
+ else {
+ /* name button */
+ short width= (short)(butr->xmax-butr->xmin-19.0f - (has_us?19.0f:0.0f));
+ bt= uiDefBut(block, TEX, B_NOP, "MA:",
+ butr->xmin+19, butr->ymin+19, width, 19,
+ node->id->name+2, 0.0, 19.0, 0, 0, "Material name");
+ uiButSetFunc(bt, node_ID_title_cb, node, NULL);
+
+ /* user amount */
+ if(has_us) {
+ char str1[32];
+ sprintf(str1, "%d", node->id->us);
+ bt= uiDefBut(block, BUT, B_NOP, str1,
+ butr->xmax-19, butr->ymin+19, 19, 19,
+ NULL, 0, 0, 0, 0, "Displays number of users. Click to make a single-user copy.");
+ uiButSetFunc(bt, node_mat_alone_cb, node, NULL);
+ }
+
+ /* node options */
+ uiBlockSetCol(block, TH_AUTO);
+ uiDefButBitS(block, TOG, SH_NODE_MAT_DIFF, B_NODE_EXEC, "Diff",
+ butr->xmin, butr->ymin, dx, 19,
+ &node->custom1, 0, 0, 0, 0, "Material Node outputs Diffuse");
+ uiDefButBitS(block, TOG, SH_NODE_MAT_SPEC, B_NODE_EXEC, "Spec",
+ butr->xmin+dx, butr->ymin, dx, 19,
+ &node->custom1, 0, 0, 0, 0, "Material Node outputs Specular");
+ uiDefButBitS(block, TOG, SH_NODE_MAT_NEG, B_NODE_EXEC, "Neg Normal",
+ butr->xmax-dx, butr->ymin, dx, 19,
+ &node->custom1, 0, 0, 0, 0, "Material Node uses inverted Normal");
+ }
uiBlockEndAlign(block);
-
}
return 38;
}
-static int node_shader_buts_texture(uiBlock *block, bNode *node, rctf *butr)
+static int node_shader_buts_texture(uiBlock *block, bNodeTree *ntree, bNode *node, rctf *butr)
{
if(block) {
uiBut *bt;
bt= uiDefIDPoinBut(block, test_texpoin_but, ID_TE, B_NODE_EXEC, "",
- butr->xmin, butr->ymin, butr->xmax-butr->xmin, 19.0f,
+ butr->xmin, butr->ymin, butr->xmax-butr->xmin, 19,
&node->id, "");
uiButSetFunc(bt, node_ID_title_cb, node, NULL);
@@ -216,20 +264,20 @@ static int node_shader_buts_texture(uiBlock *block, bNode *node, rctf *butr)
return 19;
}
-static int node_shader_buts_value(uiBlock *block, bNode *node, rctf *butr)
+static int node_shader_buts_value(uiBlock *block, bNodeTree *ntree, bNode *node, rctf *butr)
{
if(block) {
bNodeSocket *sock= node->outputs.first; /* first socket stores value */
uiDefButF(block, NUM, B_NODE_EXEC, "",
- butr->xmin, butr->ymin, butr->xmax-butr->xmin, 20.0f,
+ butr->xmin, butr->ymin, butr->xmax-butr->xmin, 20,
sock->ns.vec, 0.0f, 1.0f, 10, 2, "");
}
return 20;
}
-static int node_shader_buts_rgb(uiBlock *block, bNode *node, rctf *butr)
+static int node_shader_buts_rgb(uiBlock *block, bNodeTree *ntree, bNode *node, rctf *butr)
{
if(block) {
bNodeSocket *sock= node->outputs.first; /* first socket stores value */
@@ -238,13 +286,13 @@ static int node_shader_buts_rgb(uiBlock *block, bNode *node, rctf *butr)
uiBlockSetEmboss(block, UI_EMBOSSP);
uiDefButF(block, HSVCUBE, B_NODE_EXEC, "",
- butr->xmin, butr->ymin, butr->xmax-butr->xmin, 12.0f,
+ butr->xmin, butr->ymin, butr->xmax-butr->xmin, 12,
sock->ns.vec, 0.0f, 1.0f, 3, 0, "");
uiDefButF(block, HSVCUBE, B_NODE_EXEC, "",
- butr->xmin, butr->ymin+15.0f, butr->xmax-butr->xmin, butr->ymax-butr->ymin -15.0f -15.0f,
+ butr->xmin, butr->ymin+15, butr->xmax-butr->xmin, butr->ymax-butr->ymin -15 -15,
sock->ns.vec, 0.0f, 1.0f, 2, 0, "");
uiDefButF(block, COL, B_NOP, "",
- butr->xmin, butr->ymax-12.0f, butr->xmax-butr->xmin, 12.0f,
+ butr->xmin, butr->ymax-12, butr->xmax-butr->xmin, 12,
sock->ns.vec, 0.0, 0.0, -1, 0, "");
/* the -1 above prevents col button to popup a color picker */
@@ -258,30 +306,25 @@ static void node_but_title_cb(void *node_v, void *but_v)
bNode *node= node_v;
uiBut *bt= but_v;
BLI_strncpy(node->name, bt->drawstr, NODE_MAXSTR);
+
+ allqueue(REDRAWNODE, 0);
}
-static int node_shader_buts_mix_rgb(uiBlock *block, bNode *node, rctf *butr)
+static int node_shader_buts_mix_rgb(uiBlock *block, bNodeTree *ntree, bNode *node, rctf *butr)
{
if(block) {
uiBut *bt;
- bNodeSocket *sock= node->inputs.first; /* first socket stores "fac" */
- uiBlockBeginAlign(block);
/* blend type */
bt=uiDefButS(block, MENU, B_NODE_EXEC, "Mix %x0|Add %x1|Subtract %x3|Multiply %x2|Screen %x4|Divide %x5|Difference %x6|Darken %x7|Lighten %x8",
- butr->xmin, butr->ymin+20.0f, butr->xmax-butr->xmin, 20.0f,
+ butr->xmin, butr->ymin, butr->xmax-butr->xmin, 20,
&node->custom1, 0, 0, 0, 0, "");
uiButSetFunc(bt, node_but_title_cb, node, bt);
- /* value */
- uiDefButF(block, NUM, B_NODE_EXEC, "",
- butr->xmin, butr->ymin, butr->xmax-butr->xmin, 20.0f,
- sock->ns.vec, 0.0f, 1.0f, 10, 2, "");
- uiBlockEndAlign(block);
}
- return 40;
+ return 20;
}
-static int node_shader_buts_valtorgb(uiBlock *block, bNode *node, rctf *butr)
+static int node_shader_buts_valtorgb(uiBlock *block, bNodeTree *ntree, bNode *node, rctf *butr)
{
if(block && (node->flag & NODE_OPTIONS)) {
if(node->storage) {
@@ -338,8 +381,6 @@ static void draw_nodespace_grid(SpaceNode *snode)
{
float start, step= 25.0f;
- /* window is 'pixel size', like buttons */
-
BIF_ThemeColorShade(TH_BACK, -10);
start= snode->v2d.cur.xmin -fmod(snode->v2d.cur.xmin, step);
@@ -355,6 +396,14 @@ static void draw_nodespace_grid(SpaceNode *snode)
glVertex2f(snode->v2d.cur.xmin, start);
glVertex2f(snode->v2d.cur.xmax, start);
}
+
+ /* X and Y axis */
+ BIF_ThemeColorShade(TH_BACK, -18);
+ glVertex2f(0.0f, snode->v2d.cur.ymin);
+ glVertex2f(0.0f, snode->v2d.cur.ymax);
+ glVertex2f(snode->v2d.cur.xmin, 0.0f);
+ glVertex2f(snode->v2d.cur.xmax, 0.0f);
+
glEnd();
}
@@ -520,7 +569,7 @@ static void node_update(bNode *node)
if((node->flag & NODE_OPTIONS) && node->typeinfo->butfunc) {
dy-= NODE_DYS/2;
node->butr.ymax= dy;
- node->butr.ymin= dy - (float)node->typeinfo->butfunc(NULL, node, NULL);
+ node->butr.ymin= dy - (float)node->typeinfo->butfunc(NULL, NULL, node, NULL);
dy= node->butr.ymin - NODE_DYS/2;
}
@@ -572,7 +621,7 @@ static int node_get_colorid(bNode *node)
return TH_NODE;
}
-static void node_basis_draw(SpaceNode *snode, bNode *node)
+static void node_basis_draw(ScrArea *sa, SpaceNode *snode, bNode *node)
{
bNodeSocket *sock;
rctf *rct= &node->totr;
@@ -645,21 +694,36 @@ static void node_basis_draw(SpaceNode *snode, bNode *node)
glDisable(GL_BLEND);
}
+ /* we make buttons for input sockets, if... */
+ if(node->flag & NODE_OPTIONS) {
+ if(node->inputs.first || node->typeinfo->butfunc) {
+ uiBlock *block= uiNewBlock(NULL, "node buttons", UI_EMBOSS, UI_HELV, sa->win);
+ BLI_addtail(&sa->uiblocks, block);
+ uiBlockSetFlag(block, UI_BLOCK_NO_HILITE);
+ node->block= block;
+ }
+ }
+
/* socket inputs, label buttons */
for(sock= node->inputs.first; sock; sock= sock->next) {
socket_circle_draw(sock->locx, sock->locy, NODE_SOCKSIZE, sock->type, sock->flag & SELECT);
- if(sock->type==SOCK_VALUE) {
- uiBut *bt= uiDefBut(snode->block, LABEL, B_NODE_EXEC, sock->name, sock->locx+5.0f, sock->locy-10.0f, node->width-NODE_DY, NODE_DY, sock, 0, 0, 0, 0, "");
- bt->block_func= socket_value_menu;
- }
- else if(sock->type==SOCK_VECTOR) {
- uiBut *bt= uiDefBut(snode->block, LABEL, B_NODE_EXEC, sock->name, sock->locx+5.0f, sock->locy-10.0f, node->width-NODE_DY, NODE_DY, sock, 0, 0, 0, 0, "");
- bt->block_func= socket_vector_menu;
- }
- else if(sock->type==SOCK_RGBA) {
- uiBut *bt= uiDefBut(snode->block, LABEL, B_NODE_EXEC, sock->name, sock->locx+5.0f, sock->locy-10.0f, node->width-NODE_DY, NODE_DY, sock, 0, 0, 0, 0, "");
- bt->block_func= socket_color_menu;
+ if(node->block && sock->link==NULL) {
+ if(sock->type==SOCK_VALUE) {
+ uiDefButF(node->block, NUM, B_NODE_EXEC, sock->name,
+ (short)node->locx+NODE_DYS, (short)(sock->locy)-7, (short)node->width-NODE_DY, 17,
+ sock->ns.vec, 0.0f, 1.0f, 10, 2, "");
+ }
+ else if(sock->type==SOCK_VECTOR) {
+ uiDefBlockBut(node->block, socket_vector_menu, sock, sock->name,
+ (short)node->locx+NODE_DYS, (short)sock->locy-7, (short)node->width-NODE_DY, 17,
+ "");
+ }
+ else if(node->block && sock->type==SOCK_RGBA) {
+ uiDefButF(node->block, COL, B_NODE_EXEC, "",
+ (short)(node->locx+NODE_DYS), (short)sock->locy-6, (short)(node->width-NODE_DY), 15,
+ sock->ns.vec, 0, 0, 0, 0, "");
+ }
}
else {
BIF_ThemeColor(TH_TEXT);
@@ -689,9 +753,12 @@ static void node_basis_draw(SpaceNode *snode, bNode *node)
node_draw_preview(node->preview, &node->prvr);
/* buttons */
- if(node->flag & NODE_OPTIONS)
- if(node->typeinfo->butfunc)
- node->typeinfo->butfunc(snode->block, node, &node->butr);
+ if(node->flag & NODE_OPTIONS) {
+ if(node->typeinfo->butfunc) {
+ node->typeinfo->butfunc(node->block, snode->nodetree, node, &node->butr);
+ }
+ uiDrawBlock(node->block);
+ }
}
@@ -724,17 +791,14 @@ void node_hidden_draw(SpaceNode *snode, bNode *node)
else
BIF_ThemeColorBlendShade(TH_TEXT, color_id, 0.4, 10);
- /* open/close entirely? */
+ /* open entirely? */
ui_draw_tria_icon(rct->xmin+9.0f, centy-6.0f, snode->aspect, 'h');
- if(node->flag & SELECT)
- BIF_ThemeColor(TH_TEXT_HI);
- else
- BIF_ThemeColor(TH_TEXT);
-
- ui_rasterpos_safe(rct->xmin+21.0f, centy-4.0f, snode->aspect);
- snode_drawstring(snode, node->name, (int)(rct->xmax - rct->xmin-18.0f -12.0f));
-
+ if(node->miniwidth>0.0f) {
+ ui_rasterpos_safe(rct->xmin+21.0f, centy-4.0f, snode->aspect);
+ snode_drawstring(snode, node->name, (int)(rct->xmax - rct->xmin-18.0f -12.0f));
+ }
+
/* scale widget thing */
BIF_ThemeColorShade(color_id, -10);
dx= 10.0f;
@@ -854,6 +918,9 @@ void drawnodespace(ScrArea *sa, void *spacedata)
bwin_clear_viewmat(sa->win); /* clear buttons view */
glLoadIdentity();
+ /* always free, blocks here have no unique identifier (1 block per node) */
+ uiFreeBlocks(&sa->uiblocks);
+
/* only set once */
glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA );
glEnable(GL_MAP1_VERTEX_3);
@@ -866,7 +933,6 @@ void drawnodespace(ScrArea *sa, void *spacedata)
draw_nodespace_grid(snode);
/* nodes */
-
snode_set_context(snode);
if(snode->nodetree) {
@@ -885,34 +951,26 @@ void drawnodespace(ScrArea *sa, void *spacedata)
glDisable(GL_BLEND);
glDisable( GL_LINE_SMOOTH );
- /* not selected */
- snode->block= uiNewBlock(&sa->uiblocks, "node buttons1", UI_EMBOSS, UI_HELV, sa->win);
- uiBlockSetFlag(snode->block, UI_BLOCK_NO_HILITE);
-
+ /* not selected first */
for(node= snode->nodetree->nodes.first; node; node= node->next) {
+ node->block= NULL; /* were freed */
if(!(node->flag & SELECT)) {
if(node->flag & NODE_HIDDEN)
node_hidden_draw(snode, node);
else
- node_basis_draw(snode, node);
+ node_basis_draw(sa, snode, node);
}
}
- uiDrawBlock(snode->block);
/* selected */
- snode->block= uiNewBlock(&sa->uiblocks, "node buttons2", UI_EMBOSS, UI_HELV, sa->win);
- uiBlockSetFlag(snode->block, UI_BLOCK_NO_HILITE);
-
for(node= snode->nodetree->nodes.first; node; node= node->next) {
if(node->flag & SELECT) {
if(node->flag & NODE_HIDDEN)
node_hidden_draw(snode, node);
else
- node_basis_draw(snode, node);
+ node_basis_draw(sa, snode, node);
}
}
-
- uiDrawBlock(snode->block);
}
/* restore viewport (not needed yet) */
diff --git a/source/blender/src/editnode.c b/source/blender/src/editnode.c
index e7d51e1221e..a7f422e4fab 100644
--- a/source/blender/src/editnode.c
+++ b/source/blender/src/editnode.c
@@ -48,7 +48,6 @@
#include "BKE_main.h"
#include "BKE_node.h"
#include "BKE_material.h"
-#include "BKE_texture.h"
#include "BKE_utildefines.h"
#include "BIF_editview.h"
@@ -138,6 +137,17 @@ static void snode_handle_recalc(SpaceNode *snode)
allqueue(REDRAWNODE, 1);
}
+static void shader_node_event(SpaceNode *snode, short event)
+{
+// bNode *node;
+
+ switch(event) {
+ case B_NODE_EXEC:
+ snode_handle_recalc(snode);
+ break;
+ }
+}
+
/* assumes nothing being done in ntree yet, sets the default in/out node */
/* called from shading buttons or header */
void node_shader_default(Material *ma)
@@ -153,10 +163,15 @@ void node_shader_default(Material *ma)
ma->nodetree= ntreeAddTree(NTREE_SHADER);
- in= nodeAddNodeType(ma->nodetree, SH_NODE_INPUT);
- in->locx= 10.0f; in->locy= 200.0f;
+ /* we add default the own material as shader */
+ in= nodeAddNodeType(ma->nodetree, SH_NODE_MATERIAL);
+ in->locx= 10.0f; in->locy= 300.0f;
+ in->id= (ID *)ma;
+ id_us_plus(in->id);
+ in->flag |= NODE_ACTIVE_ID;
+
out= nodeAddNodeType(ma->nodetree, SH_NODE_OUTPUT);
- out->locx= 200.0f; out->locy= 200.0f;
+ out->locx= 300.0f; out->locy= 300.0f;
/* only a link from color to color */
fromsock= in->outputs.first;
@@ -189,6 +204,72 @@ void snode_set_context(SpaceNode *snode)
/* ************************** Node generic ************** */
+/* allows to walk the list in order of visibility */
+static bNode *next_node(bNodeTree *ntree)
+{
+ static bNode *current=NULL, *last= NULL;
+
+ if(ntree) {
+ /* set current to the first selected node */
+ for(current= ntree->nodes.last; current; current= current->prev)
+ if(current->flag & NODE_SELECT)
+ break;
+
+ /* set last to the first unselected node */
+ for(last= ntree->nodes.last; last; last= last->prev)
+ if((last->flag & NODE_SELECT)==0)
+ break;
+
+ if(current==NULL)
+ current= last;
+
+ return NULL;
+ }
+ /* no nodes, or we are ready */
+ if(current==NULL)
+ return NULL;
+
+ /* now we walk the list backwards, but we always return current */
+ if(current->flag & NODE_SELECT) {
+ bNode *node= current;
+
+ /* find previous selected */
+ current= current->prev;
+ while(current && (current->flag & NODE_SELECT)==0)
+ current= current->prev;
+
+ /* find first unselected */
+ if(current==NULL)
+ current= last;
+
+ return node;
+ }
+ else {
+ bNode *node= current;
+
+ /* find previous unselected */
+ current= current->prev;
+ while(current && (current->flag & NODE_SELECT))
+ current= current->prev;
+
+ return node;
+ }
+
+ return NULL;
+}
+
+/* is rct in visible part of node? */
+static bNode *visible_node(SpaceNode *snode, rctf *rct)
+{
+ bNode *tnode;
+
+ for(next_node(snode->nodetree); (tnode=next_node(NULL));) {
+ if(BLI_isect_rctf(&tnode->totr, rct, NULL))
+ break;
+ }
+ return tnode;
+}
+
static void snode_home(ScrArea *sa, SpaceNode *snode)
{
bNode *node;
@@ -234,18 +315,22 @@ static int find_indicated_socket(SpaceNode *snode, bNode **nodep, bNodeSocket **
if(in_out & SOCK_IN) {
for(sock= node->inputs.first; sock; sock= sock->next) {
if(BLI_in_rctf(&rect, sock->locx, sock->locy)) {
- *nodep= node;
- *sockp= sock;
- return 1;
+ if(node == visible_node(snode, &rect)) {
+ *nodep= node;
+ *sockp= sock;
+ return 1;
+ }
}
}
}
if(in_out & SOCK_OUT) {
for(sock= node->outputs.first; sock; sock= sock->next) {
if(BLI_in_rctf(&rect, sock->locx, sock->locy)) {
- *nodep= node;
- *sockp= sock;
- return 1;
+ if(node == visible_node(snode, &rect)) {
+ *nodep= node;
+ *sockp= sock;
+ return 1;
+ }
}
}
}
@@ -455,28 +540,10 @@ void node_deselectall(SpaceNode *snode, int swap)
allqueue(REDRAWNODE, 0);
}
-/* two active flags, ID nodes have special flag for buttons display */
-static void node_set_active(SpaceNode *snode, bNode *node)
+void node_set_active(SpaceNode *snode, bNode *node)
{
- bNode *tnode;
- /* make sure only one node is active, and only one per ID type */
- for(tnode= snode->nodetree->nodes.first; tnode; tnode= tnode->next) {
- tnode->flag &= ~NODE_ACTIVE;
-
- /* activate input/output will de-active all node-id types */
- if(node->typeinfo->nclass==NODE_CLASS_INPUT || node->typeinfo->nclass==NODE_CLASS_OUTPUT)
- tnode->flag &= ~NODE_ACTIVE_ID;
-
- if(node->id && tnode->id) {
- if(GS(node->id->name) == GS(tnode->id->name))
- tnode->flag &= ~NODE_ACTIVE_ID;
- }
- }
-
- node->flag |= NODE_ACTIVE;
- if(node->id)
- node->flag |= NODE_ACTIVE_ID;
+ nodeSetActive(snode->nodetree, node);
/* tree specific activate calls */
if(snode->treetype==NTREE_SHADER) {
@@ -545,6 +612,7 @@ static int do_header_hidden_node(SpaceNode *snode, bNode *node, float mx, float
return 0;
}
+
/* return 0: nothing done */
static int node_mouse_select(SpaceNode *snode, unsigned short event)
{
@@ -555,8 +623,9 @@ static int node_mouse_select(SpaceNode *snode, unsigned short event)
getmouseco_areawin(mval);
areamouseco_to_ipoco(G.v2d, mval, &mx, &my);
- /* first check for the headers or scaling widget */
- for(node= snode->nodetree->nodes.first; node; node= node->next) {
+ for(next_node(snode->nodetree); (node=next_node(NULL));) {
+
+ /* first check for the headers or scaling widget */
if(node->flag & NODE_HIDDEN) {
if(do_header_hidden_node(snode, node, mx, my))
return 1;
@@ -565,9 +634,8 @@ static int node_mouse_select(SpaceNode *snode, unsigned short event)
if(do_header_node(snode, node, mx, my))
return 1;
}
- }
-
- for(node= snode->nodetree->nodes.first; node; node= node->next) {
+
+ /* node body */
if(BLI_in_rctf(&node->totr, mx, my))
break;
}
@@ -681,12 +749,6 @@ bNode *node_add_shadernode(SpaceNode *snode, int type, float locx, float locy)
node->locy= locy;
node->flag |= SELECT;
- /* custom storage, will become handlerized.. */
- if(node->type==SH_NODE_VALTORGB)
- node->storage= add_colorband(1);
- else if(node->type==SH_NODE_MATERIAL)
- node->custom1= SH_NODE_MAT_DIFF|SH_NODE_MAT_SPEC;
-
node_set_active(snode, node);
}
return node;
@@ -1056,6 +1118,35 @@ static void convert_nodes(SpaceNode *snode)
/* ******************** main event loop ****************** */
+/* special version to prevent overlapping buttons */
+int node_uiDoBlocks(SpaceNode *snode, ListBase *lb, short event)
+{
+ bNode *node;
+ rctf rect;
+
+ short mval[2];
+
+ getmouseco_areawin(mval);
+ areamouseco_to_ipoco(G.v2d, mval, &rect.xmin, &rect.ymin);
+
+ rect.xmin -= 2.0f;
+ rect.ymin -= 2.0f;
+ rect.xmax = rect.xmin + 4.0f;
+ rect.ymax = rect.ymin + 4.0f;
+
+ for(node= snode->nodetree->nodes.first; node; node= node->next) {
+ if(node->block) {
+ if(node == visible_node(snode, &rect)) {
+ ListBase lb;
+
+ lb.first= lb.last= node->block;
+ return uiDoBlocks(&lb, event);
+ }
+ }
+ }
+ return UI_NOTHING;
+}
+
void winqreadnodespace(ScrArea *sa, void *spacedata, BWinEvent *evt)
{
SpaceNode *snode= spacedata;
@@ -1067,8 +1158,8 @@ void winqreadnodespace(ScrArea *sa, void *spacedata, BWinEvent *evt)
if(snode->nodetree==NULL) return;
if(val) {
-
- if( uiDoBlocks(&sa->uiblocks, event)!=UI_NOTHING ) event= 0;
+
+ if( node_uiDoBlocks(snode, &sa->uiblocks, event)!=UI_NOTHING ) event= 0;
switch(event) {
case LEFTMOUSE:
@@ -1092,9 +1183,9 @@ void winqreadnodespace(ScrArea *sa, void *spacedata, BWinEvent *evt)
break;
case UI_BUT_EVENT:
- if(val==B_NODE_EXEC) {
- snode_handle_recalc(snode); /* sets redraw events too */
- }
+ /* future: handlerize this! */
+ if(snode->treetype==NTREE_SHADER)
+ shader_node_event(snode, val);
break;
case RENDERPREVIEW:
@@ -1151,7 +1242,6 @@ void winqreadnodespace(ScrArea *sa, void *spacedata, BWinEvent *evt)
case DELKEY:
case XKEY:
- if( okee("Erase selected")==0 ) break;
node_delete(snode);
break;
}
diff --git a/source/blender/src/header_action.c b/source/blender/src/header_action.c
index 3ab573ff9ce..765f6de9820 100644
--- a/source/blender/src/header_action.c
+++ b/source/blender/src/header_action.c
@@ -929,7 +929,7 @@ void action_buttons(void)
from = (ID*) ob;
xco= std_libbuttons(block, xco, 0, B_ACTPIN, &G.saction->pin,
- B_ACTIONBROWSE, (ID*)G.saction->action,
+ B_ACTIONBROWSE, ID_AC, 0, (ID*)G.saction->action,
from, &(G.saction->actnr), B_ACTALONE,
B_ACTLOCAL, B_ACTIONDELETE, 0, 0);
diff --git a/source/blender/src/header_image.c b/source/blender/src/header_image.c
index 35e7c8e577f..6bb93d41a6f 100644
--- a/source/blender/src/header_image.c
+++ b/source/blender/src/header_image.c
@@ -1159,7 +1159,7 @@ void image_buttons(void)
/* other buttons: */
uiBlockSetEmboss(block, UI_EMBOSS);
- xco= std_libbuttons(block, xco, 0, 0, NULL, B_SIMABROWSE, (ID *)G.sima->image, 0, &(G.sima->imanr), 0, 0, B_IMAGEDELETE, 0, 0);
+ xco= std_libbuttons(block, xco, 0, 0, NULL, B_SIMABROWSE, ID_IM, 0, (ID *)G.sima->image, 0, &(G.sima->imanr), 0, 0, B_IMAGEDELETE, 0, 0);
if (G.sima->image) {
xco+= 8;
diff --git a/source/blender/src/header_info.c b/source/blender/src/header_info.c
index 78490172d2c..78bdc169bfa 100644
--- a/source/blender/src/header_info.c
+++ b/source/blender/src/header_info.c
@@ -1823,12 +1823,12 @@ void info_buttons(void)
uiDefIconTextButC(block, ICONTEXTROW,B_NEWSPACE, ICON_VIEW3D, windowtype_pup(), 8,0,XIC+10,YIC, &(curarea->butspacetype), 1.0, SPACEICONMAX, 0, 0, "Displays Current Window Type. Click for menu of available types.");
/* STD SCREEN BUTTONS */
- xco= std_libbuttons(block, xco, 0, 0, NULL, B_INFOSCR, (ID *)G.curscreen, 0, &G.curscreen->screennr, 1, 1, B_INFODELSCR, 0, 0);
+ xco= std_libbuttons(block, xco, 0, 0, NULL, B_INFOSCR, ID_SCR, 0, (ID *)G.curscreen, 0, &G.curscreen->screennr, 1, 1, B_INFODELSCR, 0, 0);
xco +=8;
/* STD SCENE BUTTONS */
- xco= std_libbuttons(block, xco, 0, 0, NULL, B_INFOSCE, (ID *)G.scene, 0, &G.curscreen->scenenr, 1, 1, B_INFODELSCE, 0, 0);
+ xco= std_libbuttons(block, xco, 0, 0, NULL, B_INFOSCE, ID_SCE, 0, (ID *)G.scene, 0, &G.curscreen->scenenr, 1, 1, B_INFODELSCE, 0, 0);
}
else xco= 430;
diff --git a/source/blender/src/header_ipo.c b/source/blender/src/header_ipo.c
index edd7602a3ea..c61c726c868 100644
--- a/source/blender/src/header_ipo.c
+++ b/source/blender/src/header_ipo.c
@@ -1179,7 +1179,7 @@ void ipo_buttons(void)
uiClearButLock();
- xco= std_libbuttons(block, (short)(xco+1.5*XIC), 0, B_IPOPIN, &G.sipo->pin, B_IPOBROWSE, (ID*)G.sipo->ipo, G.sipo->from, &(G.sipo->menunr), B_IPOALONE, B_IPOLOCAL, B_IPODELETE, 0, B_KEEPDATA);
+ xco= std_libbuttons(block, (short)(xco+1.5*XIC), 0, B_IPOPIN, &G.sipo->pin, B_IPOBROWSE, ID_IP, G.sipo->blocktype, (ID*)G.sipo->ipo, G.sipo->from, &(G.sipo->menunr), B_IPOALONE, B_IPOLOCAL, B_IPODELETE, 0, B_KEEPDATA);
/* COPY PASTE */
xco-= XIC/2;
diff --git a/source/blender/src/header_node.c b/source/blender/src/header_node.c
index 2d60825730b..34c6f5e2da9 100644
--- a/source/blender/src/header_node.c
+++ b/source/blender/src/header_node.c
@@ -144,7 +144,7 @@ void node_buttons(ScrArea *sa)
if(snode->treetype==NTREE_SHADER) {
if(snode->from) {
/* 0, NULL -> pin */
- xco= std_libbuttons(block, xco, 0, 0, NULL, B_MATBROWSE, snode->id, snode->from, &(snode->menunr),
+ xco= std_libbuttons(block, xco, 0, 0, NULL, B_MATBROWSE, ID_MA, 1, snode->id, snode->from, &(snode->menunr),
B_MATALONE, B_MATLOCAL, B_MATDELETE, B_AUTOMATNAME, B_KEEPDATA);
if(snode->id) {
diff --git a/source/blender/src/header_script.c b/source/blender/src/header_script.c
index da51ddce928..1c6a9cb516b 100644
--- a/source/blender/src/header_script.c
+++ b/source/blender/src/header_script.c
@@ -265,7 +265,7 @@ void script_buttons(void)
/* STD SCRIPT BUTTONS */
xco += 2*XIC;
- xco= std_libbuttons(block, xco, 0, 0, NULL, B_SCRIPTBROWSE, (ID*)sc->script, 0, &(sc->menunr), 0, 0, 0, 0, 0);
+ xco= std_libbuttons(block, xco, 0, 0, NULL, B_SCRIPTBROWSE, ID_SCRIPT, 0, (ID*)sc->script, 0, &(sc->menunr), 0, 0, 0, 0, 0);
/* always as last */
curarea->headbutlen= xco+2*XIC;
diff --git a/source/blender/src/header_sound.c b/source/blender/src/header_sound.c
index d3a577075d6..fccbebe1350 100644
--- a/source/blender/src/header_sound.c
+++ b/source/blender/src/header_sound.c
@@ -281,7 +281,7 @@ void sound_buttons(void)
}
uiBlockSetEmboss(block, UI_EMBOSS);
- xco= std_libbuttons(block, xco+8, 0, 0, NULL, B_SOUNDBROWSE, (ID *)G.ssound->sound, 0, &(G.ssound->sndnr), 1, 0, 0, 0, 0);
+ xco= std_libbuttons(block, xco+8, 0, 0, NULL, B_SOUNDBROWSE, ID_SO, 0, (ID *)G.ssound->sound, 0, &(G.ssound->sndnr), 1, 0, 0, 0, 0);
if(G.ssound->sound) {
bSound *sound= G.ssound->sound;
diff --git a/source/blender/src/header_text.c b/source/blender/src/header_text.c
index 33cdf97f57b..0438eda08fa 100644
--- a/source/blender/src/header_text.c
+++ b/source/blender/src/header_text.c
@@ -622,7 +622,7 @@ void text_buttons(void)
/* STD TEXT BUTTONS */
xco+= 2*XIC;
- xco= std_libbuttons(block, xco, 0, 0, NULL, B_TEXTBROWSE, (ID*)st->text, 0, &(st->menunr), 0, 0, B_TEXTDELETE, 0, 0);
+ xco= std_libbuttons(block, xco, 0, 0, NULL, B_TEXTBROWSE, ID_TXT, 0, (ID*)st->text, 0, &(st->menunr), 0, 0, B_TEXTDELETE, 0, 0);
/*
if (st->text) {
diff --git a/source/blender/src/headerbuttons.c b/source/blender/src/headerbuttons.c
index 38b0e604a01..9b120428c7b 100644
--- a/source/blender/src/headerbuttons.c
+++ b/source/blender/src/headerbuttons.c
@@ -233,15 +233,13 @@ int GetButStringLength(char *str) {
/* ********************** GLOBAL ****************************** */
int std_libbuttons(uiBlock *block, short xco, short yco,
- int pin, short *pinpoin, int browse, ID *id,
+ int pin, short *pinpoin, int browse, short id_code, short special, ID *id,
ID *parid, short *menupoin, int users, int lib,
int del, int autobut, int keepbut)
{
ListBase *lb;
- Object *ob;
- Ipo *ipo;
uiBut *but;
- int len, idwasnul=0, idtype, oldcol, add_addbutton=0;
+ int len, oldcol, add_addbutton=0;
char *str=NULL, str1[10];
uiBlockBeginAlign(block);
@@ -251,141 +249,47 @@ int std_libbuttons(uiBlock *block, short xco, short yco,
uiDefIconButS(block, ICONTOG, pin, ICON_PIN_DEHLT, xco,yco,XIC,YIC, pinpoin, 0, 0, 0, 0, "Keeps this view displaying the current data regardless of what object is selected");
xco+= XIC;
}
+ /* browse menu */
if(browse) {
- if(id==0) {
- idwasnul= 1;
- /* only the browse button */
- ob= OBACT;
- if(curarea->spacetype==SPACE_IMAGE) {
- id= G.main->image.first;
- }
- else if(curarea->spacetype==SPACE_SOUND) {
- id= G.main->sound.first;
- }
- else if(curarea->spacetype==SPACE_ACTION) {
- if(ob) id= G.main->action.first;
- }
- else if(curarea->spacetype==SPACE_NLA) {
- id= NULL;
- }
- else if(curarea->spacetype==SPACE_IPO) {
- id= G.main->ipo.first;
-
- /* test for ipotype */
- while(id) {
- ipo= (Ipo *)id;
- if(G.sipo->blocktype==ipo->blocktype) break;
- id= id->next;
- }
- if(ob==NULL) {
- if(G.sipo->blocktype!=ID_SEQ && G.sipo->blocktype!=ID_WO) {
- id= NULL;
- idwasnul= 0;
- }
- }
- }
- else if(curarea->spacetype==SPACE_BUTS) {
- if(browse==B_WORLDBROWSE) {
- id= G.main->world.first;
- }
- else if(ob && ob->type && (ob->type<=OB_LAMP)) {
- if(G.buts->mainb==CONTEXT_SHADING) {
- int tab= G.buts->tab[CONTEXT_SHADING];
-
- if(tab==TAB_SHADING_MAT) id= G.main->mat.first;
- else if(tab==TAB_SHADING_TEX) id= G.main->tex.first;
-
- add_addbutton= 1;
- }
- }
- }
- else if(curarea->spacetype==SPACE_TEXT) {
- id= G.main->text.first;
- }
- else if(curarea->spacetype==SPACE_SCRIPT) {
- id= G.main->script.first;
- }
- }
- if(id) {
- char *extrastr= NULL;
-
- idtype= GS(id->name);
- lb= wich_libbase(G.main, GS(id->name));
-
- if(idwasnul) id= NULL;
- else if(id->us>1) uiBlockSetCol(block, TH_BUT_SETTING1);
-
- if (pin && *pinpoin) {
- uiBlockSetCol(block, TH_BUT_SETTING2);
- }
-
- if ELEM7( idtype, ID_SCE, ID_SCR, ID_MA, ID_TE, ID_WO, ID_IP, ID_AC) extrastr= "ADD NEW %x 32767";
- else if (idtype==ID_TXT) extrastr= "OPEN NEW %x 32766 |ADD NEW %x 32767";
- else if (idtype==ID_SO) extrastr= "OPEN NEW %x 32766";
-
- uiSetButLock(G.scene->id.lib!=0, "Can't edit library data");
- if( idtype==ID_SCE || idtype==ID_SCR ) uiClearButLock();
-
- if(curarea->spacetype==SPACE_BUTS)
- uiSetButLock(idtype!=ID_SCR && G.obedit!=0 && G.buts->mainb==CONTEXT_EDITING, NULL);
-
- if(parid) uiSetButLock(parid->lib!=0, "Can't edit library data");
-
- if (lb) {
- if( idtype==ID_IP)
- IPOnames_to_pupstring(&str, NULL, extrastr, lb, id, menupoin, G.sipo->blocktype);
- else
- IDnames_to_pupstring(&str, NULL, extrastr, lb, id, menupoin);
- }
-
- uiDefButS(block, MENU, browse, str, xco,yco,XIC,YIC, menupoin, 0, 0, 0, 0, "Browses existing choices or adds NEW");
+ char *extrastr= NULL;
+
+ if(ELEM(id_code, ID_MA, ID_TE)) add_addbutton= 1;
- uiClearButLock();
+ lb= wich_libbase(G.main, id_code);
- MEM_freeN(str);
- }
- else if(curarea->spacetype==SPACE_BUTS) {
- if(G.buts->mainb==CONTEXT_SHADING) {
- uiSetButLock(G.scene->id.lib!=0, "Can't edit library data");
- if(parid) uiSetButLock(parid->lib!=0, "Can't edit library data");
- uiDefButS(block, MENU, browse, "ADD NEW %x 32767",xco,yco,XIC,YIC, menupoin, 0, 0, 0, 0, "Browses Datablock");
- uiClearButLock();
- } else if (G.buts->mainb == CONTEXT_SCENE) {
- if(G.buts->tab[CONTEXT_SCENE]== TAB_SCENE_SOUND) {
- uiDefButS(block, MENU, browse, "OPEN NEW %x 32766",xco,yco,XIC,YIC, menupoin, 0, 0, 0, 0, "Browses Datablock");
- }
- }
- }
- else if(curarea->spacetype==SPACE_TEXT) {
- uiDefButS(block, MENU, browse, "OPEN NEW %x 32766 | ADD NEW %x 32767", xco,yco,XIC,YIC, menupoin, 0, 0, 0, 0, "Browses Datablock");
- }
- else if(curarea->spacetype==SPACE_SCRIPT) {
- uiDefButS(block, MENU, browse, "No running scripts", xco, yco, XIC, YIC, menupoin, 0, 0, 0, 0, "Browses Datablock");
- }
- else if(curarea->spacetype==SPACE_SOUND) {
- uiDefButS(block, MENU, browse, "OPEN NEW %x 32766",xco,yco,XIC,YIC, menupoin, 0, 0, 0, 0, "Browses Datablock");
- }
- else if(curarea->spacetype==SPACE_ACTION) {
- uiSetButLock(G.scene->id.lib!=0, "Can't edit library data");
- if(parid) uiSetButLock(parid->lib!=0, "Can't edit library data");
+ if(id && id->us>1) uiBlockSetCol(block, TH_BUT_SETTING1);
- uiDefButS(block, MENU, browse, "ADD NEW %x 32767", xco,yco,XIC,YIC, menupoin, 0, 0, 0, 0, "Browses Datablock");
- uiClearButLock();
+ if (pin && *pinpoin) {
+ uiBlockSetCol(block, TH_BUT_SETTING2);
}
- else if(curarea->spacetype==SPACE_IPO) {
- if(idwasnul) {
- uiSetButLock(G.scene->id.lib!=0, "Can't edit library data");
- if(parid) uiSetButLock(parid->lib!=0, "Can't edit library data");
-
- uiDefButS(block, MENU, browse, "ADD NEW %x 32767", xco,yco,XIC,YIC, menupoin, 0, 0, 0, 0, "Browses Datablock");
- uiClearButLock();
- }
+
+ if ELEM7( id_code, ID_SCE, ID_SCR, ID_MA, ID_TE, ID_WO, ID_IP, ID_AC) extrastr= "ADD NEW %x 32767";
+ else if (id_code==ID_TXT) extrastr= "OPEN NEW %x 32766 |ADD NEW %x 32767";
+ else if (id_code==ID_SO) extrastr= "OPEN NEW %x 32766";
+
+ uiSetButLock(G.scene->id.lib!=0, "Can't edit library data");
+ if( id_code==ID_SCE || id_code==ID_SCR ) uiClearButLock();
+
+ if(curarea->spacetype==SPACE_BUTS)
+ uiSetButLock(id_code!=ID_SCR && G.obedit!=0 && G.buts->mainb==CONTEXT_EDITING, NULL);
+
+ if(parid) uiSetButLock(parid->lib!=0, "Can't edit library data");
+
+ if (lb) {
+ if( id_code==ID_IP)
+ IPOnames_to_pupstring(&str, NULL, extrastr, lb, id, menupoin, G.sipo->blocktype);
+ else
+ IDnames_to_pupstring(&str, NULL, extrastr, lb, id, menupoin);
}
+ uiDefButS(block, MENU, browse, str, xco,yco,XIC,YIC, menupoin, 0, 0, 0, 0, "Browses existing choices or adds NEW");
xco+= XIC;
+
+ uiClearButLock();
+
+ MEM_freeN(str);
}
-
uiBlockSetCol(block, oldcol);
if(id) { /* text button with name */
@@ -401,12 +305,20 @@ int std_libbuttons(uiBlock *block, short xco, short yco,
uiSetButLock(id->lib!=0, "Can't edit library data");
- str1[0]= id->name[0];
- str1[1]= id->name[1];
- str1[2]= ':';
- str1[3]= 0;
- if(strcmp(str1, "SC:")==0) strcpy(str1, "SCE:");
- else if(strcmp(str1, "SR:")==0) strcpy(str1, "SCR:");
+ if(GS(id->name)==ID_SCE) strcpy(str1, "SCE:");
+ else if(GS(id->name)==ID_SCE) strcpy(str1, "SCR:");
+ else if(GS(id->name)==ID_MA) {
+ if( ((Material *)id)->use_nodes )
+ strcpy(str1, "NT:");
+ else
+ strcpy(str1, "MA:");
+ }
+ else {
+ str1[0]= id->name[0];
+ str1[1]= id->name[1];
+ str1[2]= ':';
+ str1[3]= 0;
+ }
if( GS(id->name)==ID_IP) len= 110;
else if(yco) len= 140; // comes from button panel
diff --git a/source/blender/src/interface.c b/source/blender/src/interface.c
index 351deab0e4b..77d37ea57fe 100644
--- a/source/blender/src/interface.c
+++ b/source/blender/src/interface.c
@@ -603,6 +603,7 @@ static void ui_positionblock(uiBlock *block, uiBut *but)
/* position block relative to but */
uiBut *bt;
rctf butrct;
+ float aspect;
int xsize, ysize, xof=0, yof=0, centre;
short dir1= 0, dir2=0;
@@ -637,7 +638,8 @@ static void ui_positionblock(uiBlock *block, uiBut *but)
block->minx= block->miny= 0;
block->maxx= block->maxy= 20;
}
-
+
+ aspect= (float)(block->maxx - block->minx + 4);
ui_graphics_to_window(block->win, &block->minx, &block->miny);
ui_graphics_to_window(block->win, &block->maxx, &block->maxy);
@@ -646,7 +648,14 @@ static void ui_positionblock(uiBlock *block, uiBut *but)
xsize= block->maxx - block->minx+4; // 4 for shadow
ysize= block->maxy - block->miny+4;
-
+ aspect/= (float)xsize;
+
+ /* ok, let's avoid scaling up popups */
+ if(aspect<1.0f) {
+ block->maxx= aspect*(block->maxx-block->minx) + block->minx;
+ block->maxy= aspect*(block->maxy-block->miny) + block->miny;
+ }
+
if(but) {
short left=0, right=0, top=0, down=0;
@@ -741,12 +750,17 @@ static void ui_positionblock(uiBlock *block, uiBut *but)
}
/* apply */
- bt= block->buttons.first;
- while(bt) {
+
+ for(bt= block->buttons.first; bt; bt= bt->next) {
ui_graphics_to_window(block->win, &bt->x1, &bt->y1);
ui_graphics_to_window(block->win, &bt->x2, &bt->y2);
-
+ if(aspect<1.0f) {
+ bt->x1= aspect*(bt->x1 - block->minx) + block->minx;
+ bt->x2= aspect*(bt->x2 - block->minx) + block->minx;
+ bt->y1= aspect*(bt->y1 - block->miny) + block->miny;
+ bt->y2= aspect*(bt->y2 - block->miny) + block->miny;
+ }
bt->x1 += xof;
bt->x2 += xof;
bt->y1 += yof;
@@ -755,8 +769,6 @@ static void ui_positionblock(uiBlock *block, uiBut *but)
bt->aspect= 1.0;
// ui_check_but recalculates drawstring size in pixels
ui_check_but(bt);
-
- bt= bt->next;
}
block->minx += xof;
@@ -4981,7 +4993,7 @@ void ui_check_but(uiBut *but)
but->strwidth= 0;
/* automatic width */
- if(but->x2==0.0) {
+ if(but->x2==0.0f && but->x1 > 0.0f) {
but->x2= (but->x1+but->strwidth+6);
}
diff --git a/source/blender/src/interface_panel.c b/source/blender/src/interface_panel.c
index 23f7d4218b1..2bb31032a04 100644
--- a/source/blender/src/interface_panel.c
+++ b/source/blender/src/interface_panel.c
@@ -467,7 +467,7 @@ void uiSetPanelHandler(int handler)
/* return 1 if visible (create buttons!) */
int uiNewPanel(ScrArea *sa, uiBlock *block, char *panelname, char *tabname, int ofsx, int ofsy, int sizex, int sizey)
{
- Panel *pa, *palign;
+ Panel *pa;
/* check if Panel exists, then use that one */
pa= sa->panels.first;
@@ -500,18 +500,6 @@ int uiNewPanel(ScrArea *sa, uiBlock *block, char *panelname, char *tabname, int
pa->sizex= sizex;
pa->sizey= sizey;
- /* pre align, for good sorting later on */
- if(sa->spacetype==SPACE_BUTS && pa->prev) {
- SpaceButs *sbuts= sa->spacedata.first;
-
- palign= pa->prev;
- if(sbuts->align==BUT_VERTICAL) {
- pa->ofsy= palign->ofsy - pa->sizey - PNL_HEADER;
- }
- else if(sbuts->align==BUT_HORIZONTAL) {
- pa->ofsx= palign->ofsx + palign->sizex;
- }
- }
/* make new Panel tabbed? */
if(panel_tabbed && group_tabbed) {
Panel *papar;
@@ -1249,7 +1237,7 @@ int uiAlignPanelStep(ScrArea *sa, float fac)
for(a=0 ; a<tot-1; a++, ps++) {
psnext= ps+1;
-
+
if(sbuts->align==BUT_VERTICAL) {
psnext->pa->ofsx = ps->pa->ofsx;
psnext->pa->ofsy = get_panel_real_ofsy(ps->pa) - psnext->pa->sizey-PNL_HEADER-PNL_DIST;
diff --git a/source/blender/src/previewrender.c b/source/blender/src/previewrender.c
index 5d58d19bad2..d37fd9ce04a 100644
--- a/source/blender/src/previewrender.c
+++ b/source/blender/src/previewrender.c
@@ -1029,7 +1029,6 @@ static void shade_lamp_loop_preview(ShadeInput *shi, ShadeResult *shr)
static void shade_preview_pixel(ShadeInput *shi, float *vec, int x, int y, char *rect, short pr_rectx, short pr_recty)
{
Material *mat;
- MaterialLayer *ml;
ShadeResult shr;
float v1;
float eul[3], tmat[3][3], imat[3][3], col[4];
@@ -1112,33 +1111,12 @@ static void shade_preview_pixel(ShadeInput *shi, float *vec, int x, int y, char
// Normalise(shi->vn);
}
- /* ------ main shading loop with material layers */
VECCOPY(shi->vno, shi->vn);
- if(mat->ml_flag & ML_RENDER)
- shade_lamp_loop_preview(shi, &shr);
- else {
- memset(&shr, 0, sizeof(ShadeResult));
- shr.alpha= 1.0f;
- }
-
if(mat->nodetree && mat->use_nodes) {
ntreeShaderExecTree(mat->nodetree, shi, &shr);
}
else {
- for(ml= mat->layers.first; ml; ml= ml->next) {
- if(ml->mat && (ml->flag & ML_RENDER)) {
- ShadeResult shrlay;
-
- shi->mat= ml->mat;
- shi->layerfac= ml->blendfac;
- VECCOPY(shi->vn, shi->vno);
- if(ml->flag & ML_NEG_NORMAL)
- VecMulf(shi->vn, -1.0);
-
- shade_lamp_loop_preview(shi, &shrlay);
- matlayer_blend(ml, shi->layerfac, &shr, &shrlay);
- }
- }
+ shade_lamp_loop_preview(shi, &shr);
}
shi->mat= mat; /* restore, shade input is re-used! */
diff --git a/source/blender/src/toolbox.c b/source/blender/src/toolbox.c
index 6fc1941c817..b99535119fa 100644
--- a/source/blender/src/toolbox.c
+++ b/source/blender/src/toolbox.c
@@ -105,7 +105,6 @@
#include "BDR_editmball.h"
#include "BSE_editipo.h"
-#include "BSE_buttons.h"
#include "BSE_filesel.h"
#include "BSE_edit.h"
#include "BSE_headerbuttons.h"
@@ -1494,9 +1493,6 @@ void clever_numbuts(void)
else if(curarea->spacetype==SPACE_IMASEL) {
clever_numbuts_imasel();
}
- else if(curarea->spacetype==SPACE_BUTS){
- clever_numbuts_buts();
- }
else if(curarea->spacetype==SPACE_OOPS) {
clever_numbuts_oops();
}
diff --git a/source/blender/src/usiblender.c b/source/blender/src/usiblender.c
index 52d853cd984..a3b5ba55242 100644
--- a/source/blender/src/usiblender.c
+++ b/source/blender/src/usiblender.c
@@ -656,6 +656,8 @@ static void initbuttons(void)
G.fontss= BMF_GetFont(BMF_kHelveticaBold8);
clear_matcopybuf();
+
+ glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
}