From c94eefd52b4174be3b98b3e921546a7a8486d691 Mon Sep 17 00:00:00 2001 From: Nicholas Bishop Date: Sun, 16 Jan 2011 18:33:08 +0000 Subject: Fixed bug [#25649] Image editor paint icon missing until enter weight paint A couple underlying issues: * Paint icon was looking only at the object mode to determine what the "current" mode is, but that gave problems when the object mode was anything other than texpaint, but 2D image paint was turned on. Fix was to also look at what space is being drawn, and only if it's in the 3D view does it look at the ob mode. * The brushes lists weren't getting filtered correctly in the same case where 2D image paint was on but a different object mode is enabled. Fixed by changing the brush rna poll to look at the paint source, rather than the object mode. --- source/blender/editors/interface/interface_icons.c | 24 +++++++++++----------- 1 file changed, 12 insertions(+), 12 deletions(-) (limited to 'source/blender/editors/interface/interface_icons.c') diff --git a/source/blender/editors/interface/interface_icons.c b/source/blender/editors/interface/interface_icons.c index ff041c18b00..bb6738cb8cd 100644 --- a/source/blender/editors/interface/interface_icons.c +++ b/source/blender/editors/interface/interface_icons.c @@ -48,6 +48,7 @@ #include "DNA_brush_types.h" #include "DNA_object_types.h" #include "DNA_screen_types.h" +#include "DNA_space_types.h" #include "RNA_access.h" #include "RNA_enum_types.h" @@ -1028,14 +1029,15 @@ static int ui_id_brush_get_icon(bContext *C, ID *id, int preview) } else { Object *ob = CTX_data_active_object(C); - EnumPropertyItem *items; + SpaceImage *sima; + EnumPropertyItem *items = NULL; int tool, mode = 0; - /* this is not nice, should probably make brushes be - strictly in one paint mode only to avoid checking - object mode here */ + /* XXX: this is not nice, should probably make brushes + be strictly in one paint mode only to avoid + checking various context stuff here */ - if(ob) { + if(CTX_wm_view3d(C) && ob) { if(ob->mode & OB_MODE_SCULPT) mode = OB_MODE_SCULPT; else if(ob->mode & (OB_MODE_VERTEX_PAINT|OB_MODE_WEIGHT_PAINT)) @@ -1043,12 +1045,10 @@ static int ui_id_brush_get_icon(bContext *C, ID *id, int preview) else if(ob->mode & OB_MODE_TEXTURE_PAINT) mode = OB_MODE_TEXTURE_PAINT; } - - /* check if cached icon is OK */ - if(!mode || (id->icon_id && mode == br->icon_mode)) - return id->icon_id; - - br->icon_mode = mode; + else if((sima = CTX_wm_space_image(C)) && + (sima->flag & SI_DRAWTOOL)) { + mode = OB_MODE_TEXTURE_PAINT; + } /* reset the icon */ if(mode == OB_MODE_SCULPT) { @@ -1064,7 +1064,7 @@ static int ui_id_brush_get_icon(bContext *C, ID *id, int preview) tool = br->imagepaint_tool; } - if(!RNA_enum_icon_from_value(items, tool, &id->icon_id)) + if(!items || !RNA_enum_icon_from_value(items, tool, &id->icon_id)) id->icon_id = 0; } -- cgit v1.2.3