[Bf-committers] Review: Auto select active paint image, please review

Konrad Kleine konrad at konradwilhelm.de
Thu Jul 8 14:40:08 CEST 2010


Hi Nicholas and Hi Xavier,

Thank you for your help!

I've moved my the boolean state information from image painting to image
space (SpaceImage) as you've suggested. What's itching me now is that
neither the listener function of the image space nor the RNA update
function for texture changes (rna_Texture_update) have access to the
current context (bContext). Fortunately the rna_Texture_update function
notifies of a texture change via a call to WM_main_add_notifier.

 static void rna_Texture_update(Main *bmain, Scene *scene, PointerRNA
*ptr)
 { 
	Tex *tex= ptr->id.data;
 	DAG_id_flush_update(&tex->id, 0);
 	WM_main_add_notifier(NC_TEXTURE, tex);
 }

This is good because it allows me to do all the image space related stuff
by listening to NC_TEXTURE in the listener function in space_image.c

I think it would be great if I can simply listen to the notifier
NC_TEXTURE and automatically all space image windows get updated (after a
refresh/redraw of course). But I couldn't figure out how to get the active
object without a bContext variable. Can you think of a workaround here?

Another approach would be to explicitly set the image for each image space
from within the invoke or exec callback in the texture code. This is a bit
ugly, I think

 wmWindowManager *wm= CTX_wm_manager(C);
 wmWindow *win;
 ScrArea *sa = NULL;
 SpaceImage *sima;

 for(win=wm->windows.first; win; win=win->next) {
 		for(sa=win->screen->areabase.first; sa; sa= sa->next) {
 				if(sa->spacetype==SPACE_IMAGE) {
 						sima= sa->spacedata.first;
 						if(sima->image && sima->flag & SI_AUTO_SELECT_IMAGE)
 								/* Set image of sima to active texture */
 				}
 		}
 }	

What do you think? Have I forgotten something or are there any examples
you can remember?

Thank you
Konrad


Am Dienstag, den 06.07.2010, 01:26 +0200 schrieb Nicholas Bishop
<nicholasbishop at gmail.com>:
> Depending on the situation, you can also receive updates via RNA
> callbacks (that'll at least notify you when a value is updated in the
> UI.)
> 
> -Nicholas
> 
> On Mon, Jul 5, 2010 at 6:59 PM, Xavier Thomas
> <xavier.thomas.1980 at gmail.com> wrote:
>> Hi,
>>
>> To allow different operating mode to different uv/image editor, you
>> can add the IMAGEPAINT_AUTO_SELECT_IMAGE to sima (SpaceImage) instead
>> of the tool settings.
>>
>> To be notified of "active texture changes" (both implicit or explicit)
>> I thing it can be done in the image space listener function, but you
>> might need to add some notifiers and/or to modify notifiers of some
>> operators.
>>
>> To display the active texture if no UV/image editor is open there is
>> still the texture preview in the properties panels.
>>
>> I Hope it helped even if it seems simplistic.
>>
>> Xavier
>>
>> 2010/7/5 Konrad Wilhelm Kleine <konrad at konradwilhelm.de>
>>>
>>> Hi all,
>>>
>>> since my development efforts lately went slightly into a wrong
direction
>>> I've listened to Matt's advice and have written this little document:
>>>
>>>
http://wiki.blender.org/index.php/User:Kwk/Gsoc2010/AutoSelectPaintImage
>>>
>>> If there are any developers here, that can help me understand how to
>>> write a hook that is called when another texture in the active
>>> material's texture slot is selected, I would really appreciate any
>>> review.
>>>
>>> Comments and critics in general are welcome!
>>>
>>> -Konrad
>>> _______________________________________________
>>> Bf-committers mailing list
>>> Bf-committers at blender.org
>>> http://lists.blender.org/mailman/listinfo/bf-committers
>> _______________________________________________
>> Bf-committers mailing list
>> Bf-committers at blender.org
>> http://lists.blender.org/mailman/listinfo/bf-committers
>>
> _______________________________________________
> Bf-committers mailing list
> Bf-committers at blender.org
> http://lists.blender.org/mailman/listinfo/bf-committers


More information about the Bf-committers mailing list