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:
authorBrecht Van Lommel <brechtvanlommel@pandora.be>2009-07-26 02:31:02 +0400
committerBrecht Van Lommel <brechtvanlommel@pandora.be>2009-07-26 02:31:02 +0400
commit756488fbe2c0beaf205cb28d6f4ca1e62a64588a (patch)
tree488e0c746833e1eccea3c2488a2198b9b5aa688e /source/blender/editors/space_buttons/buttons_context.c
parent5d240af42b0199a7832aa2acbc866283cfab49cb (diff)
2.5: Painting
Various fixes for painting, sculpting and particle edit, still much to be done... * Move RNA paint and sculpt structs into rna_sculpt_paint.c, * Added Particle Edit RNA. * Some tweaks to existing Paint RNA. * Put texture paint and particle edit object in context. * Fix some errors in the brush layout, properly doing None checks, fixing some wrong property identifiers. * Added tool enum for texture paint and particle edit in panels. * Allow editing brush textures in the texture buttons, still with a stupid toggle, ideas for how to make the connection better are welcome.
Diffstat (limited to 'source/blender/editors/space_buttons/buttons_context.c')
-rw-r--r--source/blender/editors/space_buttons/buttons_context.c79
1 files changed, 68 insertions, 11 deletions
diff --git a/source/blender/editors/space_buttons/buttons_context.c b/source/blender/editors/space_buttons/buttons_context.c
index 3a3f5bd83ee..1bc663a789b 100644
--- a/source/blender/editors/space_buttons/buttons_context.c
+++ b/source/blender/editors/space_buttons/buttons_context.c
@@ -31,6 +31,7 @@
#include "MEM_guardedalloc.h"
#include "DNA_armature_types.h"
+#include "DNA_brush_types.h"
#include "DNA_lamp_types.h"
#include "DNA_material_types.h"
#include "DNA_modifier_types.h"
@@ -45,6 +46,7 @@
#include "BLI_listbase.h"
#include "BKE_context.h"
+#include "BKE_global.h"
#include "BKE_material.h"
#include "BKE_modifier.h"
#include "BKE_particle.h"
@@ -65,7 +67,7 @@
typedef struct ButsContextPath {
PointerRNA ptr[8];
int len;
- int worldtex;
+ int flag;
} ButsContextPath;
static int set_pointer_type(ButsContextPath *path, bContextDataResult *result, StructRNA *type)
@@ -302,10 +304,48 @@ static int buttons_context_path_particle(ButsContextPath *path)
return 0;
}
+static int buttons_context_path_brush(ButsContextPath *path)
+{
+ Scene *scene;
+ ToolSettings *ts;
+ Brush *br= NULL;
+ PointerRNA *ptr= &path->ptr[path->len-1];
+
+ /* if we already have a (pinned) brush, we're done */
+ if(RNA_struct_is_a(ptr->type, &RNA_Brush)) {
+ return 1;
+ }
+ /* if we have a scene, use the toolsettings brushes */
+ else if(buttons_context_path_scene(path)) {
+ scene= path->ptr[path->len-1].data;
+ ts= scene->toolsettings;
+
+ if(G.f & G_SCULPTMODE)
+ br= ts->sculpt->brush;
+ else if(G.f & G_VERTEXPAINT)
+ br= ts->vpaint->brush;
+ else if(G.f & G_WEIGHTPAINT)
+ br= ts->wpaint->brush;
+ else if(G.f & G_TEXTUREPAINT)
+ br= ts->imapaint.brush;
+
+ if(br) {
+ RNA_id_pointer_create(&br->id, &path->ptr[path->len]);
+ path->len++;
+
+ return 1;
+ }
+ }
+
+ /* no path to a world possible */
+ return 0;
+}
+
static int buttons_context_path_texture(ButsContextPath *path)
{
Material *ma;
Lamp *la;
+ Brush *br;
World *wo;
MTex *mtex;
Tex *tex;
@@ -315,8 +355,21 @@ static int buttons_context_path_texture(ButsContextPath *path)
if(RNA_struct_is_a(ptr->type, &RNA_Texture)) {
return 1;
}
+ /* try brush */
+ else if((path->flag & SB_BRUSH_TEX) && buttons_context_path_brush(path)) {
+ br= path->ptr[path->len-1].data;
+
+ if(br) {
+ mtex= br->mtex[(int)br->texact];
+ tex= (mtex)? mtex->tex: NULL;
+
+ RNA_id_pointer_create(&tex->id, &path->ptr[path->len]);
+ path->len++;
+ return 1;
+ }
+ }
/* try world */
- else if(path->worldtex && buttons_context_path_world(path)) {
+ else if((path->flag & SB_WORLD_TEX) && buttons_context_path_world(path)) {
wo= path->ptr[path->len-1].data;
if(wo) {
@@ -354,21 +407,21 @@ static int buttons_context_path_texture(ButsContextPath *path)
return 1;
}
}
- /* TODO: material nodes, brush */
+ /* TODO: material nodes */
- /* no path to a particle system possible */
+ /* no path to a texture possible */
return 0;
}
-static int buttons_context_path(const bContext *C, ButsContextPath *path, int mainb, int worldtex)
+static int buttons_context_path(const bContext *C, ButsContextPath *path, int mainb, int flag)
{
SpaceButs *sbuts= (SpaceButs*)CTX_wm_space_data(C);
ID *id;
int found;
memset(path, 0, sizeof(*path));
- path->worldtex= worldtex;
+ path->flag= flag;
/* if some ID datablock is pinned, set the root pointer */
if(sbuts->pinid) {
@@ -431,18 +484,18 @@ void buttons_context_compute(const bContext *C, SpaceButs *sbuts)
{
ButsContextPath *path;
PointerRNA *ptr;
- int a, worldtex, flag= 0;
+ int a, pflag, flag= 0;
if(!sbuts->path)
sbuts->path= MEM_callocN(sizeof(ButsContextPath), "ButsContextPath");
path= sbuts->path;
- worldtex= (sbuts->flag & SB_WORLD_TEX);
+ pflag= (sbuts->flag & (SB_WORLD_TEX|SB_BRUSH_TEX));
/* for each context, see if we can compute a valid path to it, if
* this is the case, we know we have to display the button */
for(a=0; a<BCONTEXT_TOT; a++) {
- if(buttons_context_path(C, path, a, worldtex)) {
+ if(buttons_context_path(C, path, a, pflag)) {
flag |= (1<<a);
/* setting icon for data context */
@@ -477,7 +530,7 @@ void buttons_context_compute(const bContext *C, SpaceButs *sbuts)
}
}
- buttons_context_path(C, path, sbuts->mainb, worldtex);
+ buttons_context_path(C, path, sbuts->mainb, pflag);
if(!(flag & (1 << sbuts->mainb))) {
if(flag & (1 << BCONTEXT_OBJECT))
@@ -505,7 +558,7 @@ int buttons_context(const bContext *C, const char *member, bContextDataResult *r
"world", "object", "mesh", "armature", "lattice", "curve",
"meta_ball", "lamp", "camera", "material", "material_slot",
"texture", "texture_slot", "bone", "edit_bone", "particle_system",
- "cloth", "soft_body", "fluid", "collision", NULL};
+ "cloth", "soft_body", "fluid", "collision", "brush", NULL};
CTX_data_dir_set(result, dir);
return 1;
@@ -648,6 +701,10 @@ int buttons_context(const bContext *C, const char *member, bContextDataResult *r
return 1;
}
}
+ else if(CTX_data_equals(member, "brush")) {
+ set_pointer_type(path, result, &RNA_Brush);
+ return 1;
+ }
return 0;
}