diff options
author | Brecht Van Lommel <brechtvanlommel@pandora.be> | 2009-02-06 19:40:14 +0300 |
---|---|---|
committer | Brecht Van Lommel <brechtvanlommel@pandora.be> | 2009-02-06 19:40:14 +0300 |
commit | 84e2de8ca7a86334c604e4476cf2938c8b444fcb (patch) | |
tree | ffc5051f2064d28259a81bea763b4e01cfaf9869 /source/blender/editors/space_image/image_header.c | |
parent | 14f180fa04bd9732d603f15e3acccbc803adb8f9 (diff) |
2.5: ID datablock button back, previously known as std_libbuttons. The
way this worked in 2.4x wasn't really clean, with events going all over
the place and using dubious variables such as G.but->lockpoin or
G.sima->menunr. It works as follows now, for example:
xco= uiDefIDPoinButs(block, CTX_data_main(C), NULL, (ID**)&sima->image, ID_IM, &sima->pin, xco, yco,
sima_idpoin_handle, UI_ID_BROWSE|UI_ID_RENAME|UI_ID_ADD_NEW|UI_ID_OPEN|UI_ID_DELETE|UI_ID_ALONE|UI_ID_PIN);
The last two parameters are a callback function, and a list of events
or functionalities that are supported. The callback function will then
get the ID pointer + event to handle.
Diffstat (limited to 'source/blender/editors/space_image/image_header.c')
-rw-r--r-- | source/blender/editors/space_image/image_header.c | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/source/blender/editors/space_image/image_header.c b/source/blender/editors/space_image/image_header.c index 38f9883bdc7..f1c80ed8531 100644 --- a/source/blender/editors/space_image/image_header.c +++ b/source/blender/editors/space_image/image_header.c @@ -885,6 +885,39 @@ static void do_image_buttons_set_uvlayer_callback(void *act, void *data) } #endif +static void sima_idpoin_handle(bContext *C, ID *id, int event) +{ + SpaceImage *sima= (SpaceImage*)CTX_wm_space_data(C); + Scene *scene= CTX_data_scene(C); + Object *obedit= CTX_data_edit_object(C); + + switch(event) { + case UI_ID_BROWSE: + case UI_ID_DELETE: + set_space_image(sima, scene, obedit, sima->image); + + if(sima->image && sima->image->id.us==0) + sima->image->id.us= 1; + + ED_area_tag_redraw(CTX_wm_area(C)); + ED_undo_push(C, "Assign Image UV"); + break; + case UI_ID_RENAME: + break; + case UI_ID_ADD_NEW: + /* XXX not implemented */ + break; + case UI_ID_OPEN: + /* XXX not implemented */ + break; + case UI_ID_ALONE: + /* XXX not implemented */ + break; + case UI_ID_PIN: + break; + } +} + void image_header_buttons(const bContext *C, ARegion *ar) { bScreen *sc= CTX_wm_screen(C); @@ -948,6 +981,11 @@ void image_header_buttons(const bContext *C, ARegion *ar) uiBlockSetEmboss(block, UI_EMBOSS); /* image select */ + + xco= uiDefIDPoinButs(block, CTX_data_main(C), NULL, (ID**)&sima->image, ID_IM, &sima->pin, xco, yco, + sima_idpoin_handle, UI_ID_BROWSE|UI_ID_BROWSE_RENDER|UI_ID_RENAME|UI_ID_ADD_NEW|UI_ID_OPEN|UI_ID_DELETE|UI_ID_ALONE|UI_ID_PIN); + xco += 8; + #if 0 char naam[256]; |