diff options
-rw-r--r-- | source/blender/editors/interface/interface_panel.c | 2 | ||||
-rw-r--r-- | source/blender/editors/space_graph/space_graph.c | 4 | ||||
-rw-r--r-- | source/blender/editors/space_image/image_intern.h | 2 | ||||
-rw-r--r-- | source/blender/editors/space_image/image_ops.c | 1 | ||||
-rw-r--r-- | source/blender/editors/space_image/image_panels.c | 1109 | ||||
-rw-r--r-- | source/blender/editors/space_image/space_image.c | 3 | ||||
-rw-r--r-- | source/blender/editors/space_node/node_edit.c | 14 | ||||
-rw-r--r-- | source/blender/windowmanager/WM_api.h | 2 | ||||
-rw-r--r-- | source/blender/windowmanager/intern/wm_event_system.c | 2 |
9 files changed, 937 insertions, 202 deletions
diff --git a/source/blender/editors/interface/interface_panel.c b/source/blender/editors/interface/interface_panel.c index 4ee5de85675..6775f6362b8 100644 --- a/source/blender/editors/interface/interface_panel.c +++ b/source/blender/editors/interface/interface_panel.c @@ -243,7 +243,7 @@ void uiFreePanels(ListBase *lb) void uiNewPanelHeight(uiBlock *block, int sizey) { - if(sizey<64) sizey= 64; + if(sizey<0) sizey= 0; if(block->panel) { block->panel->ofsy+= (block->panel->sizey - sizey); diff --git a/source/blender/editors/space_graph/space_graph.c b/source/blender/editors/space_graph/space_graph.c index 11922a2b383..a43f8ee3502 100644 --- a/source/blender/editors/space_graph/space_graph.c +++ b/source/blender/editors/space_graph/space_graph.c @@ -337,6 +337,8 @@ static void graph_buttons_area_init(wmWindowManager *wm, ARegion *ar) UI_view2d_region_reinit(&ar->v2d, V2D_COMMONVIEW_LIST_UI, ar->winx, ar->winy); + keymap= WM_keymap_listbase(wm, "View2D Buttons List", 0, 0); + WM_event_add_keymap_handler(&ar->handlers, keymap); keymap= WM_keymap_listbase(wm, "GraphEdit Generic", SPACE_IPO, 0); WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct); } @@ -567,7 +569,7 @@ void ED_spacetype_ipo(void) art= MEM_callocN(sizeof(ARegionType), "spacetype graphedit region"); art->regionid = RGN_TYPE_UI; art->minsizey= 160; - art->keymapflag= ED_KEYMAP_UI|ED_KEYMAP_VIEW2D|ED_KEYMAP_FRAMES; + art->keymapflag= ED_KEYMAP_UI|ED_KEYMAP_FRAMES; art->listener= NULL; // graph_region_listener; art->init= graph_buttons_area_init; art->draw= graph_buttons_area_draw; diff --git a/source/blender/editors/space_image/image_intern.h b/source/blender/editors/space_image/image_intern.h index cfd58d13495..20f12fecaf5 100644 --- a/source/blender/editors/space_image/image_intern.h +++ b/source/blender/editors/space_image/image_intern.h @@ -39,6 +39,7 @@ struct Image; struct ImBuf; struct wmOperatorType; struct Scene; +struct bNodeTree; /* space_image.c */ struct ARegion *image_has_buttons_region(struct ScrArea *sa); @@ -82,6 +83,7 @@ void IMAGE_OT_record_composite(struct wmOperatorType *ot); void draw_uvedit_main(struct SpaceImage *sima, struct ARegion *ar, struct Scene *scene, struct Object *obedit); /* image_panels.c */ +struct ImageUser *ntree_get_active_iuser(struct bNodeTree *ntree); void image_buttons_area_defbuts(const struct bContext *C, struct ARegion *ar); void IMAGE_OT_properties(struct wmOperatorType *ot); diff --git a/source/blender/editors/space_image/image_ops.c b/source/blender/editors/space_image/image_ops.c index 0652196842c..8038e6a00ff 100644 --- a/source/blender/editors/space_image/image_ops.c +++ b/source/blender/editors/space_image/image_ops.c @@ -621,7 +621,6 @@ static int open_exec(bContext *C, wmOperator *op) RNA_string_get(op->ptr, "filename", str); ima= BKE_add_image_file(str, scene->r.cfra); - MEM_freeN(str); if(!ima) return OPERATOR_CANCELLED; diff --git a/source/blender/editors/space_image/image_panels.c b/source/blender/editors/space_image/image_panels.c index a9ddc855fdf..188d3c13a1a 100644 --- a/source/blender/editors/space_image/image_panels.c +++ b/source/blender/editors/space_image/image_panels.c @@ -29,13 +29,17 @@ #include <string.h> #include <stdio.h> +#include "DNA_color_types.h" #include "DNA_image_types.h" #include "DNA_mesh_types.h" #include "DNA_meshdata_types.h" #include "DNA_object_types.h" +#include "DNA_packedFile_types.h" +#include "DNA_node_types.h" #include "DNA_space_types.h" #include "DNA_scene_types.h" #include "DNA_screen_types.h" +#include "DNA_userdef_types.h" #include "MEM_guardedalloc.h" @@ -46,10 +50,18 @@ #include "BKE_colortools.h" #include "BKE_context.h" +#include "BKE_customdata.h" #include "BKE_image.h" +#include "BKE_global.h" +#include "BKE_library.h" +#include "BKE_main.h" +#include "BKE_node.h" +#include "BKE_packedfile.h" #include "BKE_screen.h" #include "BKE_utildefines.h" +#include "RE_pipeline.h" + #include "IMB_imbuf.h" #include "IMB_imbuf_types.h" @@ -58,6 +70,7 @@ #include "ED_space_api.h" #include "ED_screen.h" #include "ED_uvedit.h" +#include "ED_util.h" #include "BIF_gl.h" #include "BIF_glutil.h" @@ -73,21 +86,140 @@ #include "image_intern.h" +#define B_REDR 1 +#define B_IMAGECHANGED 2 +#define B_TRANS_IMAGE 3 +#define B_CURSOR_IMAGE 4 +#define B_NOP 0 +#define B_TWINANIM 5 +#define B_SIMAGETILE 6 +#define B_IDNAME 10 +#define B_FACESEL_PAINT_TEST 11 +#define B_SIMA_RECORD 12 +#define B_SIMA_PLAY 13 +#define B_SIMARANGE 14 +#define B_SIMACURVES 15 + +#define B_SIMANOTHING 16 +#define B_SIMABRUSHCHANGE 17 +#define B_SIMABRUSHBROWSE 18 +#define B_SIMABRUSHLOCAL 19 +#define B_SIMABRUSHDELETE 20 +#define B_KEEPDATA 21 +#define B_SIMABTEXBROWSE 22 +#define B_SIMABTEXDELETE 23 +#define B_VPCOLSLI 24 +#define B_SIMACLONEBROWSE 25 +#define B_SIMACLONEDELETE 26 + +/* XXX */ +static int okee() {return 0;} +static int simaFaceDraw_Check() {return 0;} +static int simaUVSel_Check() {return 0;} +static int is_uv_tface_editing_allowed_silent() {return 0;} +/* XXX */ + +/* proto */ +static void image_editvertex_buts(const bContext *C, uiBlock *block); +static void image_editcursor_buts(const bContext *C, View2D *v2d, uiBlock *block); + + +static void do_image_panel_events(bContext *C, void *arg, int event) +{ + SpaceImage *sima= (SpaceImage*)CTX_wm_space_data(C); + ARegion *ar= CTX_wm_region(C); + + switch(event) { + case B_REDR: + break; + case B_SIMACURVES: + curvemapping_do_ibuf(sima->cumap, ED_space_image_buffer(sima)); + break; + case B_SIMARANGE: + curvemapping_set_black_white(sima->cumap, NULL, NULL); + curvemapping_do_ibuf(sima->cumap, ED_space_image_buffer(sima)); + break; + case B_TRANS_IMAGE: + image_editvertex_buts(C, NULL); + break; + case B_CURSOR_IMAGE: + image_editcursor_buts(C, &ar->v2d, NULL); + break; + } + /* all events now */ + WM_event_add_notifier(C, NC_IMAGE, sima->image); +} + + + +static void image_info(Image *ima, ImBuf *ibuf, char *str) +{ + int ofs= 0; + + str[0]= 0; + + if(ima==NULL) return; + if(ibuf==NULL) { + sprintf(str, "Can not get an image"); + return; + } + + if(ima->source==IMA_SRC_MOVIE) { + ofs= sprintf(str, "Movie "); + if(ima->anim) + ofs+= sprintf(str+ofs, "%d frs", IMB_anim_get_duration(ima->anim)); + } + else + ofs= sprintf(str, "Image "); + + ofs+= sprintf(str+ofs, ": size %d x %d,", ibuf->x, ibuf->y); + + if(ibuf->rect_float) { + if(ibuf->channels!=4) { + sprintf(str+ofs, "%d float channel(s)", ibuf->channels); + } + else if(ibuf->depth==32) + strcat(str, " RGBA float"); + else + strcat(str, " RGB float"); + } + else { + if(ibuf->depth==32) + strcat(str, " RGBA byte"); + else + strcat(str, " RGB byte"); + } + if(ibuf->zbuf || ibuf->zbuf_float) + strcat(str, " + Z"); + +} + +/* gets active viewer user */ +struct ImageUser *ntree_get_active_iuser(bNodeTree *ntree) +{ + bNode *node; + + if(ntree) + for(node= ntree->nodes.first; node; node= node->next) + if( ELEM(node->type, CMP_NODE_VIEWER, CMP_NODE_SPLITVIEWER)) + if(node->flag & NODE_DO_OUTPUT) + return node->storage; + return NULL; +} -#if 0 /* ************ panel stuff ************* */ /* this function gets the values for cursor and vertex number buttons */ -static void image_transform_but_attr(int *imx, int *imy, int *step, int *digits) /*, float *xcoord, float *ycoord)*/ +static void image_transform_but_attr(SpaceImage *sima, int *imx, int *imy, int *step, int *digits) /*, float *xcoord, float *ycoord)*/ { - ImBuf *ibuf= imagewindow_get_ibuf(G.sima); + ImBuf *ibuf= ED_space_image_buffer(sima); if(ibuf) { *imx= ibuf->x; *imy= ibuf->y; } - if (G.sima->flag & SI_COORDFLOATS) { + if (sima->flag & SI_COORDFLOATS) { *step= 1; *digits= 3; } @@ -99,20 +231,25 @@ static void image_transform_but_attr(int *imx, int *imy, int *step, int *digits) /* is used for both read and write... */ -void image_editvertex_buts(uiBlock *block) +static void image_editvertex_buts(const bContext *C, uiBlock *block) { + SpaceImage *sima= (SpaceImage*)CTX_wm_space_data(C); + Object *obedit= CTX_data_edit_object(C); static float ocent[2]; float cent[2]= {0.0, 0.0}; int imx= 256, imy= 256; int nactive= 0, step, digits; - EditMesh *em = G.editMesh; + EditMesh *em; EditFace *efa; MTFace *tf; + if(obedit==NULL || obedit->type!=OB_MESH) return; + if( is_uv_tface_editing_allowed_silent()==0 ) return; - image_transform_but_attr(&imx, &imy, &step, &digits); + image_transform_but_attr(sima, &imx, &imy, &step, &digits); + em= ((Mesh *)obedit->data)->edit_mesh; for (efa= em->faces.first; efa; efa= efa->next) { tf= CustomData_em_get(&em->fdata, efa->data, CD_MTFACE); if (simaFaceDraw_Check(efa, tf)) { @@ -144,7 +281,7 @@ void image_editvertex_buts(uiBlock *block) if (nactive) { ocent[0]= cent[0]/nactive; ocent[1]= cent[1]/nactive; - if (G.sima->flag & SI_COORDFLOATS) { + if (sima->flag & SI_COORDFLOATS) { } else { ocent[0] *= imx; ocent[1] *= imy; @@ -168,7 +305,7 @@ void image_editvertex_buts(uiBlock *block) cent[0]= cent[0]/nactive; cent[1]= cent[1]/nactive; - if (G.sima->flag & SI_COORDFLOATS) { + if (sima->flag & SI_COORDFLOATS) { delta[0]= ocent[0]-cent[0]; delta[1]= ocent[1]-cent[1]; } @@ -198,28 +335,28 @@ void image_editvertex_buts(uiBlock *block) } } } - - allqueue(REDRAWVIEW3D, 0); - allqueue(REDRAWIMAGE, 0); + + WM_event_add_notifier(C, NC_IMAGE, sima->image); } } /* is used for both read and write... */ -void image_editcursor_buts(uiBlock *block) +static void image_editcursor_buts(const bContext *C, View2D *v2d, uiBlock *block) { + SpaceImage *sima= (SpaceImage*)CTX_wm_space_data(C); static float ocent[2]; int imx= 256, imy= 256; int step, digits; if( is_uv_tface_editing_allowed_silent()==0 ) return; - image_transform_but_attr(&imx, &imy, &step, &digits); + image_transform_but_attr(sima, &imx, &imy, &step, &digits); if(block) { // do the buttons - ocent[0]= G.v2d->cursor[0]; - ocent[1]= G.v2d->cursor[1]; - if (G.sima->flag & SI_COORDFLOATS) { + ocent[0]= v2d->cursor[0]; + ocent[1]= v2d->cursor[1]; + if (sima->flag & SI_COORDFLOATS) { } else { ocent[0] *= imx; ocent[1] *= imy; @@ -231,169 +368,285 @@ void image_editcursor_buts(uiBlock *block) uiBlockEndAlign(block); } else { // apply event - if (G.sima->flag & SI_COORDFLOATS) { - G.v2d->cursor[0]= ocent[0]; - G.v2d->cursor[1]= ocent[1]; + if (sima->flag & SI_COORDFLOATS) { + v2d->cursor[0]= ocent[0]; + v2d->cursor[1]= ocent[1]; } else { - G.v2d->cursor[0]= ocent[0]/imx; - G.v2d->cursor[1]= ocent[1]/imy; + v2d->cursor[0]= ocent[0]/imx; + v2d->cursor[1]= ocent[1]/imy; } - allqueue(REDRAWIMAGE, 0); + WM_event_add_notifier(C, NC_IMAGE, sima->image); } } - -void image_info(Image *ima, ImBuf *ibuf, char *str) +static void image_panel_game_properties(const bContext *C, ARegion *ar) { - int ofs= 0; - - str[0]= 0; - - if(ima==NULL) return; - if(ibuf==NULL) { - sprintf(str, "Can not get an image"); - return; - } - - if(ima->source==IMA_SRC_MOVIE) { - ofs= sprintf(str, "Movie "); - if(ima->anim) - ofs+= sprintf(str+ofs, "%d frs", IMB_anim_get_duration(ima->anim)); - } - else - ofs= sprintf(str, "Image "); - - ofs+= sprintf(str+ofs, ": size %d x %d,", ibuf->x, ibuf->y); - - if(ibuf->rect_float) { - if(ibuf->channels!=4) { - sprintf(str+ofs, "%d float channel(s)", ibuf->channels); - } - else if(ibuf->depth==32) - strcat(str, " RGBA float"); - else - strcat(str, " RGB float"); - } - else { - if(ibuf->depth==32) - strcat(str, " RGBA byte"); - else - strcat(str, " RGB byte"); - } - if(ibuf->zbuf || ibuf->zbuf_float) - strcat(str, " + Z"); - -} - -static void image_panel_game_properties(short cntrl) // IMAGE_HANDLER_GAME_PROPERTIES -{ - ImBuf *ibuf= BKE_image_get_ibuf(G.sima->image, &G.sima->iuser); + SpaceImage *sima= (SpaceImage*)CTX_wm_space_data(C); + ImBuf *ibuf= BKE_image_get_ibuf(sima->image, &sima->iuser); uiBlock *block; - block= uiNewBlock(&curarea->uiblocks, "image_panel_game_properties", UI_EMBOSS, UI_HELV, curarea->win); - uiPanelControl(UI_PNL_SOLID | UI_PNL_CLOSE | cntrl); - uiSetPanelHandler(IMAGE_HANDLER_GAME_PROPERTIES); // for close and esc - if(uiNewPanel(curarea, block, "Real-time Properties", "Image", 10, 10, 318, 204)==0) + block= uiBeginBlock(C, ar, "image_panel_game_properties", UI_EMBOSS, UI_HELV); + if(uiNewPanel(C, ar, block, "Real-time Properties", "Image", 10, 10, 318, 204)==0) return; + uiBlockSetHandleFunc(block, do_image_panel_events, NULL); if (ibuf) { char str[128]; - image_info(G.sima->image, ibuf, str); + image_info(sima->image, ibuf, str); uiDefBut(block, LABEL, B_NOP, str, 10,180,300,19, 0, 0, 0, 0, 0, ""); uiBlockBeginAlign(block); - uiDefButBitS(block, TOG, IMA_TWINANIM, B_TWINANIM, "Anim", 10,150,140,19, &G.sima->image->tpageflag, 0, 0, 0, 0, "Toggles use of animated texture"); - uiDefButS(block, NUM, B_TWINANIM, "Start:", 10,130,140,19, &G.sima->image->twsta, 0.0, 128.0, 0, 0, "Displays the start frame of an animated texture"); - uiDefButS(block, NUM, B_TWINANIM, "End:", 10,110,140,19, &G.sima->image->twend, 0.0, 128.0, 0, 0, "Displays the end frame of an animated texture"); - uiDefButS(block, NUM, B_NOP, "Speed", 10,90,140,19, &G.sima->image->animspeed, 1.0, 100.0, 0, 0, "Displays Speed of the animation in frames per second"); + uiDefButBitS(block, TOG, IMA_TWINANIM, B_TWINANIM, "Anim", 10,150,140,19, &sima->image->tpageflag, 0, 0, 0, 0, "Toggles use of animated texture"); + uiDefButS(block, NUM, B_TWINANIM, "Start:", 10,130,140,19, &sima->image->twsta, 0.0, 128.0, 0, 0, "Displays the start frame of an animated texture"); + uiDefButS(block, NUM, B_TWINANIM, "End:", 10,110,140,19, &sima->image->twend, 0.0, 128.0, 0, 0, "Displays the end frame of an animated texture"); + uiDefButS(block, NUM, B_NOP, "Speed", 10,90,140,19, &sima->image->animspeed, 1.0, 100.0, 0, 0, "Displays Speed of the animation in frames per second"); uiBlockEndAlign(block); uiBlockBeginAlign(block); - uiDefButBitS(block, TOG, IMA_TILES, B_SIMAGETILE, "Tiles", 160,150,140,19, &G.sima->image->tpageflag, 0, 0, 0, 0, "Toggles use of tilemode for faces (Shift LMB to pick the tile for selected faces)"); - uiDefButS(block, NUM, B_SIMA_REDR_IMA_3D, "X:", 160,130,70,19, &G.sima->image->xrep, 1.0, 16.0, 0, 0, "Sets the degree of repetition in the X direction"); - uiDefButS(block, NUM, B_SIMA_REDR_IMA_3D, "Y:", 230,130,70,19, &G.sima->image->yrep, 1.0, 16.0, 0, 0, "Sets the degree of repetition in the Y direction"); + uiDefButBitS(block, TOG, IMA_TILES, B_SIMAGETILE, "Tiles", 160,150,140,19, &sima->image->tpageflag, 0, 0, 0, 0, "Toggles use of tilemode for faces (Shift LMB to pick the tile for selected faces)"); + uiDefButS(block, NUM, B_REDR, "X:", 160,130,70,19, &sima->image->xrep, 1.0, 16.0, 0, 0, "Sets the degree of repetition in the X direction"); + uiDefButS(block, NUM, B_REDR, "Y:", 230,130,70,19, &sima->image->yrep, 1.0, 16.0, 0, 0, "Sets the degree of repetition in the Y direction"); uiBlockBeginAlign(block); uiBlockBeginAlign(block); - uiDefButBitS(block, TOG, IMA_CLAMP_U, B_SIMA3DVIEWDRAW, "ClampX", 160,100,70,19, &G.sima->image->tpageflag, 0, 0, 0, 0, "Disable texture repeating horizontaly"); - uiDefButBitS(block, TOG, IMA_CLAMP_V, B_SIMA3DVIEWDRAW, "ClampY", 230,100,70,19, &G.sima->image->tpageflag, 0, 0, 0, 0, "Disable texture repeating vertically"); + uiDefButBitS(block, TOG, IMA_CLAMP_U, B_REDR, "ClampX", 160,100,70,19, &sima->image->tpageflag, 0, 0, 0, 0, "Disable texture repeating horizontaly"); + uiDefButBitS(block, TOG, IMA_CLAMP_V, B_REDR, "ClampY", 230,100,70,19, &sima->image->tpageflag, 0, 0, 0, 0, "Disable texture repeating vertically"); uiBlockEndAlign(block); } } -static void image_panel_view_properties(short cntrl) // IMAGE_HANDLER_VIEW_PROPERTIES +static void image_panel_view_properties(const bContext *C, ARegion *ar) { + SpaceImage *sima= (SpaceImage*)CTX_wm_space_data(C); + Object *obedit= CTX_data_edit_object(C); uiBlock *block; - block= uiNewBlock(&curarea->uiblocks, "image_view_properties", UI_EMBOSS, UI_HELV, curarea->win); - uiPanelControl(UI_PNL_SOLID | UI_PNL_CLOSE | cntrl); - uiSetPanelHandler(IMAGE_HANDLER_VIEW_PROPERTIES); // for close and esc - if(uiNewPanel(curarea, block, "View Properties", "Image", 10, 10, 318, 204)==0) + block= uiBeginBlock(C, ar, "image_view_properties", UI_EMBOSS, UI_HELV); + if(uiNewPanel(C, ar, block, "View Properties", "Image", 10, 30, 318, 204)==0) return; + uiBlockSetHandleFunc(block, do_image_panel_events, NULL); + uiDefButBitI(block, TOG, SI_DRAW_TILE, B_REDR, "Repeat Image", 10,160,140,19, &sima->flag, 0, 0, 0, 0, "Repeat/Tile the image display"); + uiDefButBitI(block, TOG, SI_COORDFLOATS, B_REDR, "Normalized Coords", 165,160,145,19, &sima->flag, 0, 0, 0, 0, "Display coords from 0.0 to 1.0 rather then in pixels"); - uiDefButBitI(block, TOG, SI_DRAW_TILE, B_REDR, "Repeat Image", 10,160,140,19, &G.sima->flag, 0, 0, 0, 0, "Repeat/Tile the image display"); - uiDefButBitI(block, TOG, SI_COORDFLOATS, B_REDR, "Normalized Coords", 165,160,145,19, &G.sima->flag, 0, 0, 0, 0, "Display coords from 0.0 to 1.0 rather then in pixels"); - - - if (G.sima->image) { + if (sima->image) { uiDefBut(block, LABEL, B_NOP, "Image Display:", 10,140,140,19, 0, 0, 0, 0, 0, ""); uiBlockBeginAlign(block); - uiDefButF(block, NUM, B_REDR, "AspX:", 10,120,140,19, &G.sima->image->aspx, 0.1, 5000.0, 100, 0, "X Display Aspect for this image, does not affect renderingm 0 disables."); - uiDefButF(block, NUM, B_REDR, "AspY:", 10,100,140,19, &G.sima->image->aspy, 0.1, 5000.0, 100, 0, "X Display Aspect for this image, does not affect rendering 0 disables."); + uiDefButF(block, NUM, B_REDR, "AspX:", 10,120,140,19, &sima->image->aspx, 0.1, 5000.0, 100, 0, "X Display Aspect for this image, does not affect renderingm 0 disables."); + uiDefButF(block, NUM, B_REDR, "AspY:", 10,100,140,19, &sima->image->aspy, 0.1, 5000.0, 100, 0, "X Display Aspect for this image, does not affect rendering 0 disables."); uiBlockEndAlign(block); } - - if (EM_texFaceCheck()) { - uiDefBut(block, LABEL, B_NOP, "Draw Type:", 10, 80,120,19, 0, 0, 0, 0, 0, ""); - uiBlockBeginAlign(block); - uiDefButC(block, ROW, B_REDR, "Outline", 10,60,58,19, &G.sima->dt_uv, 0.0, SI_UVDT_OUTLINE, 0, 0, "Outline Wire UV drawtype"); - uiDefButC(block, ROW, B_REDR, "Dash", 68, 60,58,19, &G.sima->dt_uv, 0.0, SI_UVDT_DASH, 0, 0, "Dashed Wire UV drawtype"); - uiDefButC(block, ROW, B_REDR, "Black", 126, 60,58,19, &G.sima->dt_uv, 0.0, SI_UVDT_BLACK, 0, 0, "Black Wire UV drawtype"); - uiDefButC(block, ROW, B_REDR, "White", 184,60,58,19, &G.sima->dt_uv, 0.0, SI_UVDT_WHITE, 0, 0, "White Wire UV drawtype"); + if (obedit && obedit->type==OB_MESH) { + Mesh *me= obedit->data; + EditMesh *em= me->edit_mesh; - uiBlockEndAlign(block); - uiDefButBitI(block, TOG, SI_SMOOTH_UV, B_REDR, "Smooth", 250,60,60,19, &G.sima->flag, 0, 0, 0, 0, "Display smooth lines in the UV view"); + if(EM_texFaceCheck(em)) { + uiDefBut(block, LABEL, B_NOP, "Draw Type:", 10, 80,120,19, 0, 0, 0, 0, 0, ""); + uiBlockBeginAlign(block); + uiDefButC(block, ROW, B_REDR, "Outline", 10,60,58,19, &sima->dt_uv, 0.0, SI_UVDT_OUTLINE, 0, 0, "Outline Wire UV drawtype"); + uiDefButC(block, ROW, B_REDR, "Dash", 68, 60,58,19, &sima->dt_uv, 0.0, SI_UVDT_DASH, 0, 0, "Dashed Wire UV drawtype"); + uiDefButC(block, ROW, B_REDR, "Black", 126, 60,58,19, &sima->dt_uv, 0.0, SI_UVDT_BLACK, 0, 0, "Black Wire UV drawtype"); + uiDefButC(block, ROW, B_REDR, "White", 184,60,58,19, &sima->dt_uv, 0.0, SI_UVDT_WHITE, 0, 0, "White Wire UV drawtype"); + + uiBlockEndAlign(block); + uiDefButBitI(block, TOG, SI_SMOOTH_UV, B_REDR, "Smooth", 250,60,60,19, &sima->flag, 0, 0, 0, 0, "Display smooth lines in the UV view"); + + + uiDefButBitI(block, TOG, ME_DRAWFACES, B_REDR, "Faces", 10,30,60,19, &me->drawflag, 0, 0, 0, 0, "Displays all faces as shades in the 3d view and UV editor"); + uiDefButBitI(block, TOG, ME_DRAWEDGES, B_REDR, "Edges", 70, 30,60,19, &me->drawflag, 0, 0, 0, 0, "Displays selected edges using hilights in the 3d view and UV editor"); + + uiDefButBitI(block, TOG, SI_DRAWSHADOW, B_REDR, "Final Shadow", 130, 30,110,19, &sima->flag, 0, 0, 0, 0, "Draw the final result from the objects modifiers"); + + uiDefButBitI(block, TOG, SI_DRAW_STRETCH, B_REDR, "UV Stretch", 10,0,100,19, &sima->flag, 0, 0, 0, 0, "Difference between UV's and the 3D coords (blue for low distortion, red is high)"); + if (sima->flag & SI_DRAW_STRETCH) { + uiBlockBeginAlign(block); + uiDefButC(block, ROW, B_REDR, "Area", 120,0,60,19, &sima->dt_uvstretch, 0.0, SI_UVDT_STRETCH_AREA, 0, 0, "Area distortion between UV's and 3D coords"); + uiDefButC(block, ROW, B_REDR, "Angle", 180,0,60,19, &sima->dt_uvstretch, 0.0, SI_UVDT_STRETCH_ANGLE, 0, 0, "Angle distortion between UV's and 3D coords"); + uiBlockEndAlign(block); + } + } + + } + image_editcursor_buts(C, &ar->v2d, block); +} + +void brush_buttons(const bContext *C, uiBlock *block, short fromsima, + int evt_nop, int evt_change, + int evt_browse, int evt_local, + int evt_del, int evt_keepdata, + int evt_texbrowse, int evt_texdel) +{ +// SpaceImage *sima= (SpaceImage*)CTX_wm_space_data(C); + ToolSettings *settings= CTX_data_tool_settings(C); + Brush *brush= settings->imapaint.brush; + ID *id; + int yco, xco, butw, but_idx; +// short *menupoin = &(sima->menunr); // XXX : &(G.buts->menunr); + short do_project = settings->imapaint.flag & IMAGEPAINT_PROJECT_DISABLE ? 0:1; + + yco= 160; + + butw = fromsima ? 80 : 106; + + uiBlockBeginAlign(block); + but_idx = 0; + uiDefButS(block, ROW, evt_change, "Draw", butw*(but_idx++),yco,butw,19, &settings->imapaint.tool, 7.0, PAINT_TOOL_DRAW, 0, 0, "Draw brush"); + if (fromsima || do_project==0) + uiDefButS(block, ROW, evt_change, "Soften", butw*(but_idx++), yco,butw,19, &settings->imapaint.tool, 7.0, PAINT_TOOL_SOFTEN, 0, 0, "Soften brush"); + uiDefButS(block, ROW, evt_change, "Smear", butw*(but_idx++), yco,butw,19, &settings->imapaint.tool, 7.0, PAINT_TOOL_SMEAR, 0, 0, "Smear brush"); + if (fromsima || do_project) + uiDefButS(block, ROW, evt_change, "Clone", butw*(but_idx++), yco,butw,19, &settings->imapaint.tool, 7.0, PAINT_TOOL_CLONE, 0, 0, "Clone brush, use RMB to drag source image"); + + uiBlockEndAlign(block); + yco -= 30; + + uiBlockSetCol(block, TH_BUT_SETTING2); + id= (ID*)settings->imapaint.brush; + xco= 200; // std_libbuttons(block, 0, yco, 0, NULL, evt_browse, ID_BR, 0, id, NULL, menupoin, 0, evt_local, evt_del, 0, evt_keepdata); + uiBlockSetCol(block, TH_AUTO); + + if(brush && !brush->id.lib) { + butw= 320-(xco+10); - uiDefButBitI(block, TOG, G_DRAWFACES, B_REDR, "Faces", 10,30,60,19, &G.f, 0, 0, 0, 0, "Displays all faces as shades in the 3d view and UV editor"); - uiDefButBitI(block, TOG, G_DRAWEDGES, B_REDR, "Edges", 70, 30,60,19, &G.f, 0, 0, 0, 0, "Displays selected edges using hilights in the 3d view and UV editor"); + uiDefButS(block, MENU, evt_nop, "Mix %x0|Add %x1|Subtract %x2|Multiply %x3|Lighten %x4|Darken %x5|Erase Alpha %x6|Add Alpha %x7", xco+10,yco,butw,19, &brush->blend, 0, 0, 0, 0, "Blending method for applying brushes"); - uiDefButBitI(block, TOG, SI_DRAWSHADOW, B_REDR, "Final Shadow", 130, 30,110,19, &G.sima->flag, 0, 0, 0, 0, "Draw the final result from the objects modifiers"); + uiBlockBeginAlign(block); + uiDefButBitS(block, TOG|BIT, BRUSH_AIRBRUSH, evt_change, "Airbrush", xco+10,yco-25,butw/2,19, &brush->flag, 0, 0, 0, 0, "Keep applying paint effect while holding mouse (spray)"); + uiDefButF(block, NUM, evt_nop, "", xco+10 + butw/2,yco-25,butw/2,19, &brush->rate, 0.01, 1.0, 0, 0, "Number of paints per second for Airbrush"); + uiBlockEndAlign(block); - uiDefButBitI(block, TOG, SI_DRAW_STRETCH, B_REDR, "UV Stretch", 10,0,100,19, &G.sima->flag, 0, 0, 0, 0, "Difference between UV's and the 3D coords (blue for low distortion, red is high)"); - if (G.sima->flag & SI_DRAW_STRETCH) { + if (fromsima) { + uiDefButBitS(block, TOG|BIT, BRUSH_TORUS, evt_change, "Wrap", xco+10,yco-45,butw,19, &brush->flag, 0, 0, 0, 0, "Enables torus wrapping"); + yco -= 25; + } + else { + yco -= 25; uiBlockBeginAlign(block); - uiDefButC(block, ROW, B_REDR, "Area", 120,0,60,19, &G.sima->dt_uvstretch, 0.0, SI_UVDT_STRETCH_AREA, 0, 0, "Area distortion between UV's and 3D coords"); - uiDefButC(block, ROW, B_REDR, "Angle", 180,0,60,19, &G.sima->dt_uvstretch, 0.0, SI_UVDT_STRETCH_ANGLE, 0, 0, "Angle distortion between UV's and 3D coords"); + uiDefButBitS(block, TOGN|BIT, IMAGEPAINT_PROJECT_DISABLE, B_REDR, "Project Paint", xco+10,yco-25,butw,19, &settings->imapaint.flag, 0, 0, 0, 0, "Use projection painting for improved consistency in the brush strokes"); + + if ((settings->imapaint.flag & IMAGEPAINT_PROJECT_DISABLE)==0) { + /* Projection Painting */ + + uiDefButBitS(block, TOGN|BIT, IMAGEPAINT_PROJECT_XRAY, B_NOP, "Occlude", xco+10,yco-45,butw/2,19, &settings->imapaint.flag, 0, 0, 0, 0, "Only paint onto the faces directly under the brush (slower)"); + uiDefButBitS(block, TOGN|BIT, IMAGEPAINT_PROJECT_BACKFACE, B_NOP, "Cull", xco+10+butw/2,yco-45,butw/2,19, &settings->imapaint.flag, 0, 0, 0, 0, "Ignore faces pointing away from the view (faster)"); + + uiDefButBitS(block, TOGN|BIT, IMAGEPAINT_PROJECT_FLAT, B_NOP, "Normal", xco+10,yco-65,butw/2,19, &settings->imapaint.flag, 0, 0, 0, 0, "Paint most on faces pointing towards the view"); + uiDefButS(block, NUM, B_NOP, "", xco+10 +(butw/2),yco-65,butw/2,19, &settings->imapaint.normal_angle, 10.0, 90.0, 0, 0, "Paint most on faces pointing towards the view acording to this angle"); + + uiDefButS(block, NUM, B_NOP, "Bleed: ", xco+10,yco-85,butw,19, &settings->imapaint.seam_bleed, 0.0, 8.0, 0, 0, "Extend paint beyond the faces UVs to reduce seams (in pixels, slower)"); + uiBlockEndAlign(block); + + uiBlockBeginAlign(block); + uiDefButBitS(block, TOG|BIT, IMAGEPAINT_PROJECT_LAYER_MASK, B_NOP, "Stencil Layer", xco+10,yco-110,butw-30,19, &settings->imapaint.flag, 0, 0, 0, 0, "Set the mask layer from the UV layer buttons"); + uiDefButBitS(block, TOG|BIT, IMAGEPAINT_PROJECT_LAYER_MASK_INV, B_NOP, "Inv", xco+10 + butw-30,yco-110,30,19, &settings->imapaint.flag, 0, 0, 0, 0, "Invert the mask"); + uiBlockEndAlign(block); + + } uiBlockEndAlign(block); } + uiBlockBeginAlign(block); + uiDefButF(block, COL, B_VPCOLSLI, "", 0,yco,200,19, brush->rgb, 0, 0, 0, 0, ""); + uiDefButF(block, NUMSLI, evt_nop, "Opacity ", 0,yco-20,180,19, &brush->alpha, 0.0, 1.0, 0, 0, "The amount of pressure on the brush"); + uiDefButBitS(block, TOG|BIT, BRUSH_ALPHA_PRESSURE, evt_nop, "P", 180,yco-20,20,19, &brush->flag, 0, 0, 0, 0, "Enables pressure sensitivity for tablets"); + uiDefButI(block, NUMSLI, evt_nop, "Size ", 0,yco-40,180,19, &brush->size, 1, 200, 0, 0, "The size of the brush"); + uiDefButBitS(block, TOG|BIT, BRUSH_SIZE_PRESSURE, evt_nop, "P", 180,yco-40,20,19, &brush->flag, 0, 0, 0, 0, "Enables pressure sensitivity for tablets"); + uiDefButF(block, NUMSLI, evt_nop, "Falloff ", 0,yco-60,180,19, &brush->innerradius, 0.0, 1.0, 0, 0, "The fall off radius of the brush"); + uiDefButBitS(block, TOG|BIT, BRUSH_RAD_PRESSURE, evt_nop, "P", 180,yco-60,20,19, &brush->flag, 0, 0, 0, 0, "Enables pressure sensitivity for tablets"); + uiDefButF(block, NUMSLI, evt_nop, "Spacing ",0,yco-80,180,19, &brush->spacing, 1.0, 100.0, 0, 0, "Repeating paint on %% of brush diameter"); + uiDefButBitS(block, TOG|BIT, BRUSH_SPACING_PRESSURE, evt_nop, "P", 180,yco-80,20,19, &brush->flag, 0, 0, 0, 0, "Enables pressure sensitivity for tablets"); + uiBlockEndAlign(block); + + yco -= 110; + + if(fromsima && settings->imapaint.tool == PAINT_TOOL_CLONE) { + id= (ID*)brush->clone.image; + uiBlockSetCol(block, TH_BUT_SETTING2); + xco= 200; // std_libbuttons(block, 0, yco, 0, NULL, B_SIMACLONEBROWSE, ID_IM, 0, id, 0, menupoin, 0, 0, B_SIMACLONEDELETE, 0, 0); + uiBlockSetCol(block, TH_AUTO); + if(id) { + butw= 320-(xco+5); + uiDefButF(block, NUMSLI, evt_change, "B ",xco+5,yco,butw,19, &brush->clone.alpha , 0.0, 1.0, 0, 0, "Opacity of clone image display"); + } + } + else { + if ( + (fromsima==0) && /* 3D View */ + (settings->imapaint.flag & IMAGEPAINT_PROJECT_DISABLE)==0 && /* Projection Painting */ + (settings->imapaint.tool == PAINT_TOOL_CLONE) + ) { + butw = 130; + uiDefButBitS(block, TOG|BIT, IMAGEPAINT_PROJECT_LAYER_CLONE, B_REDR, "Clone Layer", 0,yco,butw,20, &settings->imapaint.flag, 0, 0, 0, 0, "Use another UV layer as clone source, otherwise use 3D the cursor as the source"); + } + else { + MTex *mtex= brush->mtex[brush->texact]; + + uiBlockSetCol(block, TH_BUT_SETTING2); + id= (mtex)? (ID*)mtex->tex: NULL; + xco= 200; // std_libbuttons(block, 0, yco, 0, NULL, evt_texbrowse, ID_TE, 0, id, NULL, menupoin, 0, 0, evt_texdel, 0, 0); + /*uiDefButBitS(block, TOG|BIT, BRUSH_FIXED_TEX, evt_change, "Fixed", xco+5,yco,butw,19, &brush->flag, 0, 0, 0, 0, "Keep texture origin in fixed position");*/ + uiBlockSetCol(block, TH_AUTO); + } + } } - image_editcursor_buts(block); + +#if 0 + uiDefButBitS(block, TOG|BIT, IMAGEPAINT_DRAW_TOOL_DRAWING, B_SIMABRUSHCHANGE, "TD", 0,1,50,19, &settings->imapaint.flag.flag, 0, 0, 0, 0, "Enables brush shape while drawing"); + uiDefButBitS(block, TOG|BIT, IMAGEPAINT_DRAW_TOOL, B_SIMABRUSHCHANGE, "TP", 50,1,50,19, &settings->imapaint.flag.flag, 0, 0, 0, 0, "Enables brush shape while not drawing"); +#endif } -static void image_panel_paint(short cntrl) // IMAGE_HANDLER_PAINT +static void image_panel_paintcolor(const bContext *C, ARegion *ar) { + SpaceImage *sima= (SpaceImage*)CTX_wm_space_data(C); + ToolSettings *settings= CTX_data_tool_settings(C); + Brush *brush= settings->imapaint.brush; uiBlock *block; - if ((G.sima->image && (G.sima->flag & SI_DRAWTOOL))==0) { + static float hsv[3], old[3]; // used as temp mem for picker + static char hexcol[128]; + + block= uiBeginBlock(C, ar, "image_panel_paintcolor", UI_EMBOSS, UI_HELV); + uiBlockSetHandleFunc(block, do_image_panel_events, NULL); + if(uiNewPanel(C, ar, block, "Paint Color", "Image", 10, 22, 318, 204)==0) + return; + + if ( (brush && sima->image && (sima->flag & SI_DRAWTOOL))==0) { + uiNewPanelHeight(block, 0); return; } + uiNewPanelHeight(block, 204); - block= uiNewBlock(&curarea->uiblocks, "image_panel_paint", UI_EMBOSS, UI_HELV, curarea->win); - uiPanelControl(UI_PNL_SOLID | UI_PNL_CLOSE | cntrl); - uiSetPanelHandler(IMAGE_HANDLER_PAINT); // for close and esc - if(uiNewPanel(curarea, block, "Image Paint", "Image", 10, 230, 318, 204)==0) + uiBlockPickerButtons(block, brush->rgb, hsv, old, hexcol, 'f', B_REDR); +} + + + +static void image_panel_paint(const bContext *C, ARegion *ar) +{ + SpaceImage *sima= (SpaceImage*)CTX_wm_space_data(C); + uiBlock *block; + + block= uiBeginBlock(C, ar, "image_panel_paint", UI_EMBOSS, UI_HELV); + uiBlockSetHandleFunc(block, do_image_panel_events, NULL); + if(uiNewPanel(C, ar, block, "Image Paint", "Image", 10, 20, 318, 204)==0) return; - brush_buttons(block, 1, B_SIMANOTHING, B_SIMABRUSHCHANGE, B_SIMABRUSHBROWSE, B_SIMABRUSHLOCAL, B_SIMABRUSHDELETE, B_KEEPDATA, B_SIMABTEXBROWSE, B_SIMABTEXDELETE); + if ((sima->image && (sima->flag & SI_DRAWTOOL))==0) { + uiNewPanelHeight(block, 0); + return; + } + uiNewPanelHeight(block, 204); + + brush_buttons(C, block, 1, B_SIMANOTHING, B_SIMABRUSHCHANGE, B_SIMABRUSHBROWSE, B_SIMABRUSHLOCAL, B_SIMABRUSHDELETE, B_KEEPDATA, B_SIMABTEXBROWSE, B_SIMABTEXDELETE); } -static void image_panel_curves_reset(void *cumap_v, void *ibuf_v) +static void image_panel_curves_reset(bContext *C, void *cumap_v, void *ibuf_v) { + SpaceImage *sima= (SpaceImage*)CTX_wm_space_data(C); CurveMapping *cumap = cumap_v; int a; @@ -407,52 +660,54 @@ static void image_panel_curves_reset(void *cumap_v, void *ibuf_v) curvemapping_changed(cumap, 0); curvemapping_do_ibuf(cumap, ibuf_v); - allqueue(REDRAWIMAGE, 0); + WM_event_add_notifier(C, NC_IMAGE, sima->image); } -static void image_panel_curves(short cntrl) // IMAGE_HANDLER_CURVES +static void image_panel_curves(const bContext *C, ARegion *ar) { + SpaceImage *sima= (SpaceImage*)CTX_wm_space_data(C); ImBuf *ibuf; uiBlock *block; uiBut *bt; /* and we check for spare */ - ibuf= imagewindow_get_ibuf(G.sima); + ibuf= ED_space_image_buffer(sima); - block= uiNewBlock(&curarea->uiblocks, "image_panel_curves", UI_EMBOSS, UI_HELV, curarea->win); - uiPanelControl(UI_PNL_SOLID | UI_PNL_CLOSE | cntrl); - uiSetPanelHandler(IMAGE_HANDLER_CURVES); // for close and esc - if(uiNewPanel(curarea, block, "Curves", "Image", 10, 450, 318, 204)==0) + block= uiBeginBlock(C, ar, "image_panel_curves", UI_EMBOSS, UI_HELV); + if(uiNewPanel(C, ar, block, "Curves", "Image", 10, 40, 318, 204)==0) return; + uiBlockSetHandleFunc(block, do_image_panel_events, NULL); if (ibuf) { rctf rect; - if(G.sima->cumap==NULL) - G.sima->cumap= curvemapping_add(4, 0.0f, 0.0f, 1.0f, 1.0f); + if(sima->cumap==NULL) + sima->cumap= curvemapping_add(4, 0.0f, 0.0f, 1.0f, 1.0f); rect.xmin= 110; rect.xmax= 310; rect.ymin= 10; rect.ymax= 200; - curvemap_buttons(block, G.sima->cumap, 'c', B_SIMACURVES, B_REDR, &rect); + curvemap_buttons(block, sima->cumap, 'c', B_SIMACURVES, B_REDR, &rect); /* curvemap min/max only works for RGBA */ if(ibuf->channels==4) { bt=uiDefBut(block, BUT, B_SIMARANGE, "Reset", 10, 160, 90, 19, NULL, 0.0f, 0.0f, 0, 0, "Reset Black/White point and curves"); - uiButSetFunc(bt, image_panel_curves_reset, G.sima->cumap, ibuf); + uiButSetFunc(bt, image_panel_curves_reset, sima->cumap, ibuf); uiBlockBeginAlign(block); - uiDefButF(block, NUM, B_SIMARANGE, "Min R:", 10, 120, 90, 19, G.sima->cumap->black, -1000.0f, 1000.0f, 10, 2, "Black level"); - uiDefButF(block, NUM, B_SIMARANGE, "Min G:", 10, 100, 90, 19, G.sima->cumap->black+1, -1000.0f, 1000.0f, 10, 2, "Black level"); - uiDefButF(block, NUM, B_SIMARANGE, "Min B:", 10, 80, 90, 19, G.sima->cumap->black+2, -1000.0f, 1000.0f, 10, 2, "Black level"); + uiDefButF(block, NUM, B_SIMARANGE, "Min R:", 10, 120, 90, 19, sima->cumap->black, -1000.0f, 1000.0f, 10, 2, "Black level"); + uiDefButF(block, NUM, B_SIMARANGE, "Min G:", 10, 100, 90, 19, sima->cumap->black+1, -1000.0f, 1000.0f, 10, 2, "Black level"); + uiDefButF(block, NUM, B_SIMARANGE, "Min B:", 10, 80, 90, 19, sima->cumap->black+2, -1000.0f, 1000.0f, 10, 2, "Black level"); uiBlockBeginAlign(block); - uiDefButF(block, NUM, B_SIMARANGE, "Max R:", 10, 50, 90, 19, G.sima->cumap->white, -1000.0f, 1000.0f, 10, 2, "White level"); - uiDefButF(block, NUM, B_SIMARANGE, "Max G:", 10, 30, 90, 19, G.sima->cumap->white+1, -1000.0f, 1000.0f, 10, 2, "White level"); - uiDefButF(block, NUM, B_SIMARANGE, "Max B:", 10, 10, 90, 19, G.sima->cumap->white+2, -1000.0f, 1000.0f, 10, 2, "White level"); + uiDefButF(block, NUM, B_SIMARANGE, "Max R:", 10, 50, 90, 19, sima->cumap->white, -1000.0f, 1000.0f, 10, 2, "White level"); + uiDefButF(block, NUM, B_SIMARANGE, "Max G:", 10, 30, 90, 19, sima->cumap->white+1, -1000.0f, 1000.0f, 10, 2, "White level"); + uiDefButF(block, NUM, B_SIMARANGE, "Max B:", 10, 10, 90, 19, sima->cumap->white+2, -1000.0f, 1000.0f, 10, 2, "White level"); } } } + +#if 0 /* 0: disable preview otherwise refresh preview */ @@ -460,7 +715,6 @@ void image_preview_event(int event) { int exec= 0; - if(event==0) { G.scene->r.scemode &= ~R_COMP_CROP; exec= 1; @@ -493,7 +747,7 @@ void image_preview_event(int event) scrarea_do_windraw(curarea); waitcursor(0); - allqueue(REDRAWNODE, 1); + WM_event_add_notifier(C, NC_IMAGE, ima_v); } } @@ -501,6 +755,7 @@ void image_preview_event(int event) /* nothing drawn here, we use it to store values */ static void preview_cb(struct ScrArea *sa, struct uiBlock *block) { + SpaceImage *sima= sa->spacedata.first; rctf dispf; rcti *disprect= &G.scene->r.disprect; int winx= (G.scene->r.size*G.scene->r.xsch)/100; @@ -520,13 +775,13 @@ static void preview_cb(struct ScrArea *sa, struct uiBlock *block) /* correction for gla draw */ BLI_translate_rcti(disprect, -curarea->winrct.xmin, -curarea->winrct.ymin); - calc_image_view(G.sima, 'p'); + calc_image_view(sima, 'p'); // printf("winrct %d %d %d %d\n", disprect->xmin, disprect->ymin,disprect->xmax, disprect->ymax); /* map to image space coordinates */ mval[0]= disprect->xmin; mval[1]= disprect->ymin; - areamouseco_to_ipoco(G.v2d, mval, &dispf.xmin, &dispf.ymin); + areamouseco_to_ipoco(v2d, mval, &dispf.xmin, &dispf.ymin); mval[0]= disprect->xmax; mval[1]= disprect->ymax; - areamouseco_to_ipoco(G.v2d, mval, &dispf.xmax, &dispf.ymax); + areamouseco_to_ipoco(v2d, mval, &dispf.xmax, &dispf.ymax); /* map to render coordinates */ disprect->xmin= dispf.xmin; @@ -561,6 +816,7 @@ static int is_preview_allowed(ScrArea *cur) return 1; } + static void image_panel_preview(ScrArea *sa, short cntrl) // IMAGE_HANDLER_PREVIEW { uiBlock *block; @@ -573,13 +829,13 @@ static void image_panel_preview(ScrArea *sa, short cntrl) // IMAGE_HANDLER_PREVI return; } - block= uiNewBlock(&sa->uiblocks, "image_panel_preview", UI_EMBOSS, UI_HELV, sa->win); + block= uiBeginBlock(C, ar, "image_panel_preview", UI_EMBOSS, UI_HELV); uiPanelControl(UI_PNL_SOLID | UI_PNL_CLOSE | UI_PNL_SCALE | cntrl); uiSetPanelHandler(IMAGE_HANDLER_PREVIEW); // for close and esc ofsx= -150+(sa->winx/2)/sima->blockscale; ofsy= -100+(sa->winy/2)/sima->blockscale; - if(uiNewPanel(sa, block, "Preview", "Image", ofsx, ofsy, 300, 200)==0) return; + if(uiNewPanel(C, ar, block, "Preview", "Image", ofsx, ofsy, 300, 200)==0) return; uiBlockSetDrawExtraFunc(block, preview_cb); @@ -592,10 +848,10 @@ static void image_panel_gpencil(short cntrl) // IMAGE_HANDLER_GREASEPENCIL sima= curarea->spacedata.first; - block= uiNewBlock(&curarea->uiblocks, "image_panel_gpencil", UI_EMBOSS, UI_HELV, curarea->win); + block= uiBeginBlock(C, ar, "image_panel_gpencil", UI_EMBOSS, UI_HELV); uiPanelControl(UI_PNL_SOLID | UI_PNL_CLOSE | cntrl); uiSetPanelHandler(IMAGE_HANDLER_GREASEPENCIL); // for close and esc - if (uiNewPanel(curarea, block, "Grease Pencil", "SpaceImage", 100, 30, 318, 204)==0) return; + if (uiNewPanel(C, ar, block, "Grease Pencil", "SpaceImage", 100, 30, 318, 204)==0) return; /* allocate memory for gpd if drawing enabled (this must be done first or else we crash) */ if (sima->flag & SI_DISPGP) { @@ -623,57 +879,539 @@ static void image_panel_gpencil(short cntrl) // IMAGE_HANDLER_GREASEPENCIL uiDefBut(block, LABEL, 1, " ", 160, 180, 150, 20, NULL, 0.0, 0.0, 0, 0, ""); } } +#endif + + +/* ********************* callbacks for standard image buttons *************** */ -static void image_blockhandlers(ScrArea *sa) +/* called from fileselect or button */ +static void load_image_cb(bContext *C, char *str, void *ima_pp_v, void *iuser_v) { - SpaceImage *sima= sa->spacedata.first; - short a; + Image **ima_pp= (Image **)ima_pp_v; + Image *ima= NULL; + + ima= BKE_add_image_file(str, 0); + if(ima) { + if(*ima_pp) { + (*ima_pp)->id.us--; + } + *ima_pp= ima; + + BKE_image_signal(ima, iuser_v, IMA_SIGNAL_RELOAD); + WM_event_add_notifier(C, NC_IMAGE, ima); + + /* button event gets lost when it goes via filewindow */ +// if(G.buts && G.buts->lockpoin) { +// Tex *tex= G.buts->lockpoin; +// if(GS(tex->id.name)==ID_TE) { +// BIF_preview_changed(ID_TE); +// allqueue(REDRAWBUTSSHADING, 0); +// allqueue(REDRAWVIEW3D, 0); +// allqueue(REDRAWOOPS, 0); +// } +// } + } + + ED_undo_push(C, "Load image"); +} - /* warning; blocks need to be freed each time, handlers dont remove */ - uiFreeBlocksWin(&sa->uiblocks, sa->win); +static char *layer_menu(RenderResult *rr, short *curlay) +{ + RenderLayer *rl; + int len= 64 + 32*BLI_countlist(&rr->layers); + short a, nr= 0; + char *str= MEM_callocN(len, "menu layers"); - for(a=0; a<SPACE_MAXHANDLER; a+=2) { - switch(sima->blockhandler[a]) { - case IMAGE_HANDLER_PROPERTIES: - image_panel_properties(sima->blockhandler[a+1]); - break; - case IMAGE_HANDLER_GAME_PROPERTIES: - image_panel_game_properties(sima->blockhandler[a+1]); - break; - case IMAGE_HANDLER_VIEW_PROPERTIES: - image_panel_view_properties(sima->blockhandler[a+1]); - break; - case IMAGE_HANDLER_PAINT: - image_panel_paint(sima->blockhandler[a+1]); - break; - case IMAGE_HANDLER_CURVES: - image_panel_curves(sima->blockhandler[a+1]); - break; - case IMAGE_HANDLER_PREVIEW: - image_panel_preview(sa, sima->blockhandler[a+1]); - break; - case IMAGE_HANDLER_GREASEPENCIL: - image_panel_gpencil(sima->blockhandler[a+1]); - break; + strcpy(str, "Layer %t"); + a= strlen(str); + + /* compo result */ + if(rr->rectf) { + a+= sprintf(str+a, "|Composite %%x0"); + nr= 1; + } + for(rl= rr->layers.first; rl; rl= rl->next, nr++) { + a+= sprintf(str+a, "|%s %%x%d", rl->name, nr); + } + + /* no curlay clip here, on render (redraws) the amount of layers can be 1 fir single-layer render */ + + return str; +} + +/* rl==NULL means composite result */ +static char *pass_menu(RenderLayer *rl, short *curpass) +{ + RenderPass *rpass; + int len= 64 + 32*(rl?BLI_countlist(&rl->passes):1); + short a, nr= 0; + char *str= MEM_callocN(len, "menu layers"); + + strcpy(str, "Pass %t"); + a= strlen(str); + + /* rendered results don't have a Combined pass */ + if(rl==NULL || rl->rectf) { + a+= sprintf(str+a, "|Combined %%x0"); + nr= 1; + } + + if(rl) + for(rpass= rl->passes.first; rpass; rpass= rpass->next, nr++) + a+= sprintf(str+a, "|%s %%x%d", rpass->name, nr); + + if(*curpass >= nr) + *curpass= 0; + + return str; +} + +static void set_frames_cb(bContext *C, void *ima_v, void *iuser_v) +{ + Scene *scene= CTX_data_scene(C); + Image *ima= ima_v; + ImageUser *iuser= iuser_v; + + if(ima->anim) { + iuser->frames = IMB_anim_get_duration(ima->anim); + BKE_image_user_calc_imanr(iuser, scene->r.cfra, 0); + } +} + +static void image_src_change_cb(bContext *C, void *ima_v, void *iuser_v) +{ + BKE_image_signal(ima_v, iuser_v, IMA_SIGNAL_SRC_CHANGE); +} + +/* buttons have 2 arg callbacks, filewindow has 3 args... so thats why the wrapper below */ +static void image_browse_cb1(bContext *C, void *ima_pp_v, void *iuser_v) +{ + Image **ima_pp= (Image **)ima_pp_v; + ImageUser *iuser= iuser_v; + + if(ima_pp) { + Image *ima= *ima_pp; + + if(iuser->menunr== -2) { + // XXX activate_databrowse_args(&ima->id, ID_IM, 0, &iuser->menunr, image_browse_cb1, ima_pp, iuser); + } + else if (iuser->menunr>0) { + Image *newima= (Image*) BLI_findlink(&CTX_data_main(C)->image, iuser->menunr-1); + + if (newima && newima!=ima) { + *ima_pp= newima; + id_us_plus(&newima->id); + if(ima) ima->id.us--; + + BKE_image_signal(newima, iuser, IMA_SIGNAL_USER_NEW_IMAGE); + + ED_undo_push(C, "Browse image"); + } } - /* clear action value for event */ - sima->blockhandler[a+1]= 0; } - uiDrawBlocksPanels(sa, 0); } -#endif + +static void image_browse_cb(bContext *C, void *ima_pp_v, void *iuser_v) +{ + image_browse_cb1(C, ima_pp_v, iuser_v); +} + +static void image_reload_cb(bContext *C, void *ima_v, void *iuser_v) +{ + if(ima_v) { + BKE_image_signal(ima_v, iuser_v, IMA_SIGNAL_RELOAD); + } +} + +static void image_field_test(bContext *C, void *ima_v, void *iuser_v) +{ + Image *ima= ima_v; + + if(ima) { + ImBuf *ibuf= BKE_image_get_ibuf(ima, iuser_v); + if(ibuf) { + short nr= 0; + if( !(ima->flag & IMA_FIELDS) && (ibuf->flags & IB_fields) ) nr= 1; + if( (ima->flag & IMA_FIELDS) && !(ibuf->flags & IB_fields) ) nr= 1; + if(nr) { + BKE_image_signal(ima, iuser_v, IMA_SIGNAL_FREE); + } + } + } +} + +static void image_unlink_cb(bContext *C, void *ima_pp_v, void *unused) +{ + Image **ima_pp= (Image **)ima_pp_v; + + if(ima_pp && *ima_pp) { + Image *ima= *ima_pp; + /* (for time being, texturefaces are no users, conflict in design...) */ + if(ima->id.us>1) + ima->id.us--; + *ima_pp= NULL; + } +} + +static void image_load_fs_cb(bContext *C, void *ima_pp_v, void *iuser_v) +{ + ScrArea *sa= CTX_wm_area(C); +// Image **ima_pp= (Image **)ima_pp_v; + + if(sa->spacetype==SPACE_IMAGE) + WM_operator_name_call(C, "IMAGE_OT_open", WM_OP_INVOKE_REGION_WIN, NULL); + else + printf("not supported yet\n"); +} + +/* 5 layer button callbacks... */ +static void image_multi_cb(bContext *C, void *rr_v, void *iuser_v) +{ + BKE_image_multilayer_index(rr_v, iuser_v); +} +static void image_multi_inclay_cb(bContext *C, void *rr_v, void *iuser_v) +{ + RenderResult *rr= rr_v; + ImageUser *iuser= iuser_v; + int tot= BLI_countlist(&rr->layers) + (rr->rectf?1:0); /* fake compo result layer */ + if(iuser->layer<tot-1) + iuser->layer++; + BKE_image_multilayer_index(rr, iuser); +} +static void image_multi_declay_cb(bContext *C, void *rr_v, void *iuser_v) +{ + ImageUser *iuser= iuser_v; + if(iuser->layer>0) + iuser->layer--; + BKE_image_multilayer_index(rr_v, iuser); +} +static void image_multi_incpass_cb(bContext *C, void *rr_v, void *iuser_v) +{ + RenderResult *rr= rr_v; + ImageUser *iuser= iuser_v; + RenderLayer *rl= BLI_findlink(&rr->layers, iuser->layer); + if(rl) { + int tot= BLI_countlist(&rl->passes) + (rl->rectf?1:0); /* builtin render result has no combined pass in list */ + if(iuser->pass<tot-1) { + iuser->pass++; + BKE_image_multilayer_index(rr, iuser); + } + } +} +static void image_multi_decpass_cb(bContext *C, void *rr_v, void *iuser_v) +{ + ImageUser *iuser= iuser_v; + if(iuser->pass>0) { + iuser->pass--; + BKE_image_multilayer_index(rr_v, iuser); + } +} + +static void image_pack_cb(bContext *C, void *ima_v, void *iuser_v) +{ + if(ima_v) { + Image *ima= ima_v; + if(ima->source!=IMA_SRC_SEQUENCE && ima->source!=IMA_SRC_MOVIE) { + if (ima->packedfile) { + if (G.fileflags & G_AUTOPACK) { + if (okee("Disable AutoPack ?")) { + G.fileflags &= ~G_AUTOPACK; + } + } + + if ((G.fileflags & G_AUTOPACK) == 0) { + unpackImage(ima, PF_ASK); + ED_undo_push(C, "Unpack image"); + } + } + else { + ImBuf *ibuf= BKE_image_get_ibuf(ima, iuser_v); + if (ibuf && (ibuf->userflags & IB_BITMAPDIRTY)) { + // XXX error("Can't pack painted image. Save image or use Repack as PNG."); + } else { + ima->packedfile = newPackedFile(ima->name); + ED_undo_push(C, "Pack image"); + } + } + } + } +} + +static void image_load_cb(bContext *C, void *ima_pp_v, void *iuser_v) +{ + if(ima_pp_v) { + Image *ima= *((Image **)ima_pp_v); + ImBuf *ibuf= BKE_image_get_ibuf(ima, iuser_v); + char str[FILE_MAX]; + + /* name in ima has been changed by button! */ + BLI_strncpy(str, ima->name, FILE_MAX); + if(ibuf) BLI_strncpy(ima->name, ibuf->name, FILE_MAX); + + load_image_cb(C, str, ima_pp_v, iuser_v); + } +} + +static void image_freecache_cb(bContext *C, void *ima_v, void *unused) +{ + Scene *scene= CTX_data_scene(C); + BKE_image_free_anim_ibufs(ima_v, scene->r.cfra); + WM_event_add_notifier(C, NC_IMAGE, ima_v); +} + +static void image_generated_change_cb(bContext *C, void *ima_v, void *iuser_v) +{ + BKE_image_signal(ima_v, iuser_v, IMA_SIGNAL_FREE); +} + +static void image_user_change(bContext *C, void *iuser_v, void *unused) +{ + Scene *scene= CTX_data_scene(C); + BKE_image_user_calc_imanr(iuser_v, scene->r.cfra, 0); +} + +static void uiblock_layer_pass_buttons(uiBlock *block, RenderResult *rr, ImageUser *iuser, int event, int x, int y, int w) +{ + uiBut *but; + RenderLayer *rl= NULL; + int wmenu1, wmenu2; + char *strp; + + /* layer menu is 1/3 larger than pass */ + wmenu1= (3*w)/5; + wmenu2= (2*w)/5; + + /* menu buts */ + strp= layer_menu(rr, &iuser->layer); + but= uiDefButS(block, MENU, event, strp, x, y, wmenu1, 20, &iuser->layer, 0,0,0,0, "Select Layer"); + uiButSetFunc(but, image_multi_cb, rr, iuser); + MEM_freeN(strp); + + rl= BLI_findlink(&rr->layers, iuser->layer - (rr->rectf?1:0)); /* fake compo layer, return NULL is meant to be */ + strp= pass_menu(rl, &iuser->pass); + but= uiDefButS(block, MENU, event, strp, x+wmenu1, y, wmenu2, 20, &iuser->pass, 0,0,0,0, "Select Pass"); + uiButSetFunc(but, image_multi_cb, rr, iuser); + MEM_freeN(strp); +} + +static void uiblock_layer_pass_arrow_buttons(uiBlock *block, RenderResult *rr, ImageUser *iuser, int imagechanged) +{ + uiBut *but; + + if(rr==NULL || iuser==NULL) + return; + if(rr->layers.first==NULL) { + uiDefBut(block, LABEL, 0, "No Layers in Render Result,", 10, 107, 300, 20, NULL, 1, 0, 0, 0, ""); + return; + } + + uiBlockBeginAlign(block); + + /* decrease, increase arrows */ + but= uiDefIconBut(block, BUT, imagechanged, ICON_TRIA_LEFT, 10,107,17,20, NULL, 0, 0, 0, 0, "Previous Layer"); + uiButSetFunc(but, image_multi_declay_cb, rr, iuser); + but= uiDefIconBut(block, BUT, imagechanged, ICON_TRIA_RIGHT, 27,107,18,20, NULL, 0, 0, 0, 0, "Next Layer"); + uiButSetFunc(but, image_multi_inclay_cb, rr, iuser); + + uiblock_layer_pass_buttons(block, rr, iuser, imagechanged, 45, 107, 230); + + /* decrease, increase arrows */ + but= uiDefIconBut(block, BUT, imagechanged, ICON_TRIA_LEFT, 275,107,17,20, NULL, 0, 0, 0, 0, "Previous Pass"); + uiButSetFunc(but, image_multi_decpass_cb, rr, iuser); + but= uiDefIconBut(block, BUT, imagechanged, ICON_TRIA_RIGHT, 292,107,18,20, NULL, 0, 0, 0, 0, "Next Pass"); + uiButSetFunc(but, image_multi_incpass_cb, rr, iuser); + + uiBlockEndAlign(block); + +} + +// XXX HACK! +static int packdummy=0; + +/* The general Image panel with the loadsa callbacks! */ +void uiblock_image_panel(const bContext *C, uiBlock *block, Image **ima_pp, ImageUser *iuser, + short redraw, short imagechanged) +{ + Scene *scene= CTX_data_scene(C); + SpaceImage *sima= (SpaceImage*)CTX_wm_space_data(C); + Image *ima= *ima_pp; + uiBut *but; + char str[128], *strp; + + /* different stuff when we show viewer */ + if(ima && ima->source==IMA_SRC_VIEWER) { + ImBuf *ibuf= BKE_image_get_ibuf(ima, iuser); + + image_info(ima, ibuf, str); + uiDefBut(block, LABEL, 0, ima->id.name+2, 10, 180, 300, 20, NULL, 1, 0, 0, 0, ""); + uiDefBut(block, LABEL, 0, str, 10, 160, 300, 20, NULL, 1, 0, 0, 0, ""); + + if(ima->type==IMA_TYPE_COMPOSITE) { + iuser= ntree_get_active_iuser(scene->nodetree); + if(iuser) { + uiBlockBeginAlign(block); + uiDefIconTextBut(block, BUT, B_SIMA_RECORD, ICON_REC, "Record", 10,120,100,20, 0, 0, 0, 0, 0, ""); + uiDefIconTextBut(block, BUT, B_SIMA_PLAY, ICON_PLAY, "Play", 110,120,100,20, 0, 0, 0, 0, 0, ""); + but= uiDefBut(block, BUT, B_NOP, "Free Cache", 210,120,100,20, 0, 0, 0, 0, 0, ""); + uiButSetFunc(but, image_freecache_cb, ima, NULL); + + if(iuser->frames) + sprintf(str, "(%d) Frames:", iuser->framenr); + else strcpy(str, "Frames:"); + uiBlockBeginAlign(block); + uiDefButI(block, NUM, imagechanged, str, 10, 90,150, 20, &iuser->frames, 0.0, MAXFRAMEF, 0, 0, "Sets the number of images of a movie to use"); + uiDefButI(block, NUM, imagechanged, "StartFr:", 160,90,150,20, &iuser->sfra, 1.0, MAXFRAMEF, 0, 0, "Sets the global starting frame of the movie"); + } + } + else if(ima->type==IMA_TYPE_R_RESULT) { + /* browse layer/passes */ + uiblock_layer_pass_arrow_buttons(block, RE_GetResult(RE_GetRender(scene->id.name)), iuser, imagechanged); + } + return; + } + + /* the main ima source types */ + if(ima) { +// XXX uiSetButLock(ima->id.lib!=NULL, ERROR_LIBDATA_MESSAGE); + uiBlockBeginAlign(block); + uiBlockSetFunc(block, image_src_change_cb, ima, iuser); + uiDefButS(block, ROW, imagechanged, "Still", 10, 180, 60, 20, &ima->source, 0.0, IMA_SRC_FILE, 0, 0, "Single Image file"); + uiDefButS(block, ROW, imagechanged, "Movie", 70, 180, 60, 20, &ima->source, 0.0, IMA_SRC_MOVIE, 0, 0, "Movie file"); + uiDefButS(block, ROW, imagechanged, "Sequence", 130, 180, 90, 20, &ima->source, 0.0, IMA_SRC_SEQUENCE, 0, 0, "Multiple Image files, as a sequence"); + uiDefButS(block, ROW, imagechanged, "Generated", 220, 180, 90, 20, &ima->source, 0.0, IMA_SRC_GENERATED, 0, 0, "Generated Image"); + uiBlockSetFunc(block, NULL, NULL, NULL); + } + else + uiDefBut(block, LABEL, 0, " ", 10, 180, 300, 20, 0, 0, 0, 0, 0, ""); /* for align in panel */ + + /* Browse */ + IMAnames_to_pupstring(&strp, NULL, NULL, &(CTX_data_main(C)->image), NULL, &iuser->menunr); + + uiBlockBeginAlign(block); + but= uiDefButS(block, MENU, imagechanged, strp, 10,155,23,20, &iuser->menunr, 0, 0, 0, 0, "Selects an existing Image or Movie"); + uiButSetFunc(but, image_browse_cb, ima_pp, iuser); + + MEM_freeN(strp); + + /* name + options, or only load */ + if(ima) { + int drawpack= (ima->source!=IMA_SRC_SEQUENCE && ima->source!=IMA_SRC_MOVIE && ima->ok); + + but= uiDefBut(block, TEX, B_IDNAME, "IM:", 33, 155, 177, 20, ima->id.name+2, 0.0, 21.0, 0, 0, "Current Image Datablock name."); + uiButSetFunc(but, test_idbutton_cb, ima->id.name, NULL); + but= uiDefBut(block, BUT, imagechanged, "Reload", 210, 155, 60, 20, NULL, 0, 0, 0, 0, "Reloads Image or Movie"); + uiButSetFunc(but, image_reload_cb, ima, iuser); + + but= uiDefIconBut(block, BUT, imagechanged, ICON_X, 270,155,20,20, 0, 0, 0, 0, 0, "Unlink Image block"); + uiButSetFunc(but, image_unlink_cb, ima_pp, NULL); + sprintf(str, "%d", ima->id.us); + uiDefBut(block, BUT, B_NOP, str, 290,155,20,20, 0, 0, 0, 0, 0, "Only displays number of users of Image block"); + + but= uiDefIconBut(block, BUT, imagechanged, ICON_FILESEL, 10, 135, 23, 20, 0, 0, 0, 0, 0, "Open Fileselect to load new Image"); + uiButSetFunc(but, image_load_fs_cb, ima_pp, iuser); + but= uiDefBut(block, TEX, imagechanged, "", 33,135,257+(drawpack?0:20),20, ima->name, 0.0, 239.0, 0, 0, "Image/Movie file name, change to load new"); + uiButSetFunc(but, image_load_cb, ima_pp, iuser); + + if(drawpack) { + if (ima->packedfile) packdummy = 1; + else packdummy = 0; + but= uiDefIconButBitI(block, TOG, 1, redraw, ICON_PACKAGE, 290,135,20,20, &packdummy, 0, 0, 0, 0, "Toggles Packed status of this Image"); + uiButSetFunc(but, image_pack_cb, ima, iuser); + } + + } + else { + but= uiDefBut(block, BUT, imagechanged, "Load", 33, 155, 100,20, NULL, 0, 0, 0, 0, "Load new Image of Movie"); + uiButSetFunc(but, image_load_fs_cb, ima_pp, iuser); + } + uiBlockEndAlign(block); + + if(ima) { + ImBuf *ibuf= BKE_image_get_ibuf(ima, iuser); + + /* check for re-render, only buttons */ + if(imagechanged==B_IMAGECHANGED) { + if(iuser->flag & IMA_ANIM_REFRESHED) { + iuser->flag &= ~IMA_ANIM_REFRESHED; + WM_event_add_notifier(C, NC_IMAGE, ima); + } + } + + /* multilayer? */ + if(ima->type==IMA_TYPE_MULTILAYER && ima->rr) { + uiblock_layer_pass_arrow_buttons(block, ima->rr, iuser, imagechanged); + } + else { + image_info(ima, ibuf, str); + uiDefBut(block, LABEL, 0, str, 10, 112, 300, 20, NULL, 1, 0, 0, 0, ""); + } + + /* exception, let's do because we only use this panel 3 times in blender... but not real good code! */ + if( (FACESEL_PAINT_TEST) && sima && &sima->iuser==iuser) + return; + /* left side default per-image options, right half the additional options */ + + /* fields */ + uiBlockBeginAlign(block); + but= uiDefButBitS(block, TOG, IMA_FIELDS, imagechanged, "Fields", 10, 70, 65, 20, &ima->flag, 0, 0, 0, 0, "Click to enable use of fields in Image"); + uiButSetFunc(but, image_field_test, ima, iuser); + uiDefButBitS(block, TOG, IMA_STD_FIELD, B_NOP, "Odd", 75, 70, 45, 20, &ima->flag, 0, 0, 0, 0, "Standard Field Toggle"); + + uiBlockSetFunc(block, image_reload_cb, ima, iuser); + uiDefButBitS(block, TOG, IMA_ANTIALI, B_NOP, "Anti", 10, 50, 45, 20, &ima->flag, 0, 0, 0, 0, "Toggles Image anti-aliasing, only works with solid colors"); + uiDefButBitS(block, TOG, IMA_DO_PREMUL, imagechanged, "Premul", 55, 50, 65, 20, &ima->flag, 0, 0, 0, 0, "Toggles premultiplying alpha"); + uiBlockEndAlign(block); + + if( ELEM(ima->source, IMA_SRC_MOVIE, IMA_SRC_SEQUENCE)) { + sprintf(str, "(%d) Frames:", iuser->framenr); + + uiBlockBeginAlign(block); + uiBlockSetFunc(block, image_user_change, iuser, NULL); + uiDefButBitS(block, TOG, IMA_ANIM_ALWAYS, B_NOP, "Auto Refresh", 120, 70, 190, 20, &iuser->flag, 0, 0, 0, 0, "Always refresh Image on frame changes"); + + if(ima->anim) { + uiDefButI(block, NUM, imagechanged, str, 120, 50,170, 20, &iuser->frames, 0.0, MAXFRAMEF, 0, 0, "Sets the number of images of a movie to use"); + but= uiDefBut(block, BUT, redraw, "<", 290, 50, 20, 20, 0, 0, 0, 0, 0, "Copies number of frames in movie file to Frames: button"); + uiButSetFunc(but, set_frames_cb, ima, iuser); + } + else + uiDefButI(block, NUM, imagechanged, str, 120, 50,190, 20, &iuser->frames, 0.0, MAXFRAMEF, 0, 0, "Sets the number of images of a movie to use"); + + uiDefButI(block, NUM, imagechanged, "Offs:", 120,30,100,20, &iuser->offset, -MAXFRAMEF, MAXFRAMEF, 0, 0, "Offsets the number of the frame to use in the animation"); + uiDefButS(block, NUM, imagechanged, "Fie/Ima:", 220,30,90,20, &iuser->fie_ima, 1.0, 200.0, 0, 0, "The number of fields per rendered frame (2 fields is 1 image)"); + + uiDefButI(block, NUM, imagechanged, "StartFr:", 120,10,100,20, &iuser->sfra, 1.0, MAXFRAMEF, 0, 0, "Sets the global starting frame of the movie"); + uiDefButS(block, TOG, imagechanged, "Cyclic", 220,10,90,20, &iuser->cycl, 0.0, 1.0, 0, 0, "Cycle the images in the movie"); + + uiBlockSetFunc(block, NULL, iuser, NULL); + } + else if(ima->source==IMA_SRC_GENERATED) { + + uiBlockBeginAlign(block); + uiBlockSetFunc(block, image_generated_change_cb, ima, iuser); + uiDefButS(block, NUM, imagechanged, "SizeX:", 120,70,100,20, &ima->gen_x, 1.0, 5000.0, 0, 0, "Image size x"); + uiDefButS(block, NUM, imagechanged, "SizeY:", 220,70,90,20, &ima->gen_y, 1.0, 5000.0, 0, 0, "Image size y"); + uiDefButS(block, TOG, imagechanged, "UV Test grid",120,50,190,20, &ima->gen_type, 0.0, 1.0, 0, 0, ""); + uiBlockSetFunc(block, NULL, NULL, NULL); + } + } + uiBlockEndAlign(block); +} + static void image_panel_properties(const bContext *C, ARegion *ar) { + SpaceImage *sima= (SpaceImage*)CTX_wm_space_data(C); uiBlock *block; block= uiBeginBlock(C, ar, "image_panel_properties", UI_EMBOSS, UI_HELV); - if(uiNewPanel(C, ar, block, "Image Properties", "Image", 10, 10, 318, 204)==0) + if(uiNewPanel(C, ar, block, "Image Properties", "Image", 10, 50, 318, 204)==0) return; - + uiBlockSetHandleFunc(block, do_image_panel_events, NULL); + /* note, it draws no bottom half in facemode, for vertex buttons */ -// uiblock_image_panel(block, &G.sima->image, &G.sima->iuser, B_REDR, B_REDR); -// image_editvertex_buts(block); + uiblock_image_panel(C, block, &sima->image, &sima->iuser, B_REDR, B_REDR); + image_editvertex_buts(C, block); uiEndBlock(C, block); } @@ -684,7 +1422,12 @@ void image_buttons_area_defbuts(const bContext *C, ARegion *ar) { image_panel_properties(C, ar); - + image_panel_game_properties(C, ar); + image_panel_view_properties(C, ar); + image_panel_paint(C, ar); + image_panel_paintcolor(C, ar); + image_panel_curves(C, ar); + uiDrawPanels(C, 1); /* 1 = align */ uiMatchPanelsView2d(ar); /* sets v2d->totrct */ diff --git a/source/blender/editors/space_image/space_image.c b/source/blender/editors/space_image/space_image.c index 703b309f2ab..896522e15de 100644 --- a/source/blender/editors/space_image/space_image.c +++ b/source/blender/editors/space_image/space_image.c @@ -483,6 +483,8 @@ static void image_buttons_area_init(wmWindowManager *wm, ARegion *ar) { ListBase *keymap; + keymap= WM_keymap_listbase(wm, "View2D Buttons List", 0, 0); + WM_event_add_keymap_handler(&ar->handlers, keymap); keymap= WM_keymap_listbase(wm, "Image Generic", SPACE_IMAGE, 0); WM_event_add_keymap_handler(&ar->handlers, keymap); @@ -603,6 +605,7 @@ void ED_spacetype_image(void) /**************************** common state *****************************/ +/* note; image_panel_properties() uses pointer to sima->image directly */ Image *ED_space_image(SpaceImage *sima) { return sima->image; diff --git a/source/blender/editors/space_node/node_edit.c b/source/blender/editors/space_node/node_edit.c index 85812438a2e..06487916d4d 100644 --- a/source/blender/editors/space_node/node_edit.c +++ b/source/blender/editors/space_node/node_edit.c @@ -2231,20 +2231,6 @@ void clear_scene_in_nodes(Scene *sce) } } - -/* gets active viewer user */ -struct ImageUser *ntree_get_active_iuser(bNodeTree *ntree) -{ - bNode *node; - - if(ntree) - for(node= ntree->nodes.first; node; node= node->next) - if( ELEM(node->type, CMP_NODE_VIEWER, CMP_NODE_SPLITVIEWER)) - if(node->flag & NODE_DO_OUTPUT) - return node->storage; - return NULL; -} - void imagepaint_composite_tags(bNodeTree *ntree, Image *image, ImageUser *iuser) { bNode *node; diff --git a/source/blender/windowmanager/WM_api.h b/source/blender/windowmanager/WM_api.h index 2dd1aa871c2..99e6e26d6a9 100644 --- a/source/blender/windowmanager/WM_api.h +++ b/source/blender/windowmanager/WM_api.h @@ -105,7 +105,7 @@ void WM_event_remove_handlers(struct bContext *C, ListBase *handlers); void WM_event_add_mousemove(struct bContext *C); int WM_modal_tweak_exit(struct wmEvent *evt, int tweak_event); -void WM_event_add_notifier(struct bContext *C, unsigned int type, void *data); +void WM_event_add_notifier(const struct bContext *C, unsigned int type, void *data); void wm_event_add (struct wmWindow *win, struct wmEvent *event_to_add); /* XXX only for warning */ diff --git a/source/blender/windowmanager/intern/wm_event_system.c b/source/blender/windowmanager/intern/wm_event_system.c index 6eb71d3d314..7bf5cddd1b9 100644 --- a/source/blender/windowmanager/intern/wm_event_system.c +++ b/source/blender/windowmanager/intern/wm_event_system.c @@ -96,7 +96,7 @@ void wm_event_free_all(wmWindow *win) /* ********************* notifiers, listeners *************** */ /* XXX: in future, which notifiers to send to other windows? */ -void WM_event_add_notifier(bContext *C, unsigned int type, void *reference) +void WM_event_add_notifier(const bContext *C, unsigned int type, void *reference) { wmNotifier *note= MEM_callocN(sizeof(wmNotifier), "notifier"); |