diff options
Diffstat (limited to 'source/blender/editors/space_image/image_buttons.c')
-rw-r--r-- | source/blender/editors/space_image/image_buttons.c | 239 |
1 files changed, 49 insertions, 190 deletions
diff --git a/source/blender/editors/space_image/image_buttons.c b/source/blender/editors/space_image/image_buttons.c index 52b48e1f9fd..c48078118a7 100644 --- a/source/blender/editors/space_image/image_buttons.c +++ b/source/blender/editors/space_image/image_buttons.c @@ -63,8 +63,6 @@ #include "ED_gpencil.h" #include "ED_image.h" #include "ED_screen.h" -#include "ED_uvedit.h" - #include "RNA_access.h" @@ -78,7 +76,6 @@ #define B_REDR 1 #define B_IMAGECHANGED 2 -#define B_TRANS_IMAGE 3 #define B_NOP 0 #define B_TWINANIM 5 #define B_SIMAGETILE 6 @@ -100,8 +97,6 @@ #define B_SIMACLONEDELETE 26 /* proto */ -static void image_editvertex_buts(const bContext *C, uiBlock *block); - static void do_image_panel_events(bContext *C, void *UNUSED(arg), int event) { @@ -110,62 +105,68 @@ static void do_image_panel_events(bContext *C, void *UNUSED(arg), int event) switch(event) { case B_REDR: break; - case B_TRANS_IMAGE: - image_editvertex_buts(C, NULL); - break; } /* all events now */ WM_event_add_notifier(C, NC_IMAGE, sima->image); } -static void image_info(Image *ima, ImBuf *ibuf, char *str) +static void image_info(Scene *scene, ImageUser *iuser, 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) { - ofs+= sprintf(str+ofs, "%d float channel(s)", ibuf->channels); - } - else if(ibuf->depth==32) - ofs+= sprintf(str+ofs, " RGBA float"); - else - ofs+= sprintf(str+ofs, " RGB float"); + ofs+= sprintf(str, "Can't Load Image"); } else { - if(ibuf->depth==32) - ofs+= sprintf(str+ofs, " RGBA byte"); + 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+ofs, " RGB byte"); + ofs+= sprintf(str, "Image"); + + ofs+= sprintf(str+ofs, ": size %d x %d,", ibuf->x, ibuf->y); + + if(ibuf->rect_float) { + if(ibuf->channels!=4) { + ofs+= sprintf(str+ofs, "%d float channel(s)", ibuf->channels); + } + else if(ibuf->depth==32) + ofs+= sprintf(str+ofs, " RGBA float"); + else + ofs+= sprintf(str+ofs, " RGB float"); + } + else { + if(ibuf->depth==32) + ofs+= sprintf(str+ofs, " RGBA byte"); + else + ofs+= sprintf(str+ofs, " RGB byte"); + } + if(ibuf->zbuf || ibuf->zbuf_float) + ofs+= sprintf(str+ofs, " + Z"); + + if(ima->source==IMA_SRC_SEQUENCE) { + char *file= BLI_last_slash(ibuf->name); + if(file==NULL) file= ibuf->name; + else file++; + ofs+= sprintf(str+ofs, ", %s", file); + } } - if(ibuf->zbuf || ibuf->zbuf_float) - ofs+= sprintf(str+ofs, " + Z"); + /* the frame number, even if we cant */ if(ima->source==IMA_SRC_SEQUENCE) { - char *file= BLI_last_slash(ibuf->name); - if(file==NULL) file= ibuf->name; - else file++; - sprintf(str+ofs, ", %s", file); + /* don't use iuser->framenr directly because it may not be updated if auto-refresh is off */ + const int framenr= BKE_image_user_get_frame(iuser, CFRA, 0); + ofs+= sprintf(str+ofs, ", Frame: %d", framenr); } - + + (void)ofs; } /* gets active viewer user */ @@ -184,127 +185,6 @@ struct ImageUser *ntree_get_active_iuser(bNodeTree *ntree) /* ************ panel stuff ************* */ -/* this function gets the values for cursor and vertex number buttons */ -static void image_transform_but_attr(SpaceImage *sima, int *imx, int *imy, int *step, int *digits) /*, float *xcoord, float *ycoord)*/ -{ - ED_space_image_size(sima, imx, imy); - - if (sima->flag & SI_COORDFLOATS) { - *step= 1; - *digits= 3; - } - else { - *step= 100; - *digits= 2; - } -} - - -/* is used for both read and write... */ -static void image_editvertex_buts(const bContext *C, uiBlock *block) -{ - Scene *scene= CTX_data_scene(C); - SpaceImage *sima= CTX_wm_space_image(C); - Image *ima= sima->image; - 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; - EditFace *efa; - MTFace *tf; - - image_transform_but_attr(sima, &imx, &imy, &step, &digits); - - em= BKE_mesh_get_editmesh((Mesh *)obedit->data); - for (efa= em->faces.first; efa; efa= efa->next) { - tf= CustomData_em_get(&em->fdata, efa->data, CD_MTFACE); - if (uvedit_face_visible(scene, ima, efa, tf)) { - - if (uvedit_uv_selected(scene, efa, tf, 0)) { - cent[0]+= tf->uv[0][0]; - cent[1]+= tf->uv[0][1]; - nactive++; - } - if (uvedit_uv_selected(scene, efa, tf, 1)) { - cent[0]+= tf->uv[1][0]; - cent[1]+= tf->uv[1][1]; - nactive++; - } - if (uvedit_uv_selected(scene, efa, tf, 2)) { - cent[0]+= tf->uv[2][0]; - cent[1]+= tf->uv[2][1]; - nactive++; - } - if (efa->v4 && uvedit_uv_selected(scene, efa, tf, 3)) { - cent[0]+= tf->uv[3][0]; - cent[1]+= tf->uv[3][1]; - nactive++; - } - } - } - - if(block) { // do the buttons - if (nactive) { - ocent[0]= cent[0]/nactive; - ocent[1]= cent[1]/nactive; - if (sima->flag & SI_COORDFLOATS) { - } else { - ocent[0] *= imx; - ocent[1] *= imy; - } - - uiBlockBeginAlign(block); - uiDefButF(block, NUM, B_TRANS_IMAGE, "X:", 10, 10, 145, 19, &ocent[0], -10*imx, 10.0*imx, step, digits, ""); - uiDefButF(block, NUM, B_TRANS_IMAGE, "Y:", 165, 10, 145, 19, &ocent[1], -10*imy, 10.0*imy, step, digits, ""); - uiBlockEndAlign(block); - } - } - else { // apply event - float delta[2]; - - cent[0]= cent[0]/nactive; - cent[1]= cent[1]/nactive; - - if (sima->flag & SI_COORDFLOATS) { - delta[0]= ocent[0]-cent[0]; - delta[1]= ocent[1]-cent[1]; - } - else { - delta[0]= ocent[0]/imx - cent[0]; - delta[1]= ocent[1]/imy - cent[1]; - } - - for (efa= em->faces.first; efa; efa= efa->next) { - tf= CustomData_em_get(&em->fdata, efa->data, CD_MTFACE); - if (uvedit_face_visible(scene, ima, efa, tf)) { - if (uvedit_uv_selected(scene, efa, tf, 0)) { - tf->uv[0][0]+= delta[0]; - tf->uv[0][1]+= delta[1]; - } - if (uvedit_uv_selected(scene, efa, tf, 1)) { - tf->uv[1][0]+= delta[0]; - tf->uv[1][1]+= delta[1]; - } - if (uvedit_uv_selected(scene, efa, tf, 2)) { - tf->uv[2][0]+= delta[0]; - tf->uv[2][1]+= delta[1]; - } - if (efa->v4 && uvedit_uv_selected(scene, efa, tf, 3)) { - tf->uv[3][0]+= delta[0]; - tf->uv[3][1]+= delta[1]; - } - } - } - - WM_event_add_notifier(C, NC_IMAGE, sima->image); - } - - BKE_mesh_end_editmesh(obedit->data, em); -} - - /* is used for both read and write... */ static int image_panel_poll(const bContext *C, PanelType *UNUSED(pt)) @@ -713,6 +593,7 @@ static void uiblock_layer_pass_arrow_buttons(uiLayout *layout, RenderResult *rr, uiBlock *block= uiLayoutGetBlock(layout); uiLayout *row; uiBut *but; + const float dpi_fac= UI_DPI_FAC; row= uiLayoutRow(layout, 1); @@ -729,7 +610,7 @@ static void uiblock_layer_pass_arrow_buttons(uiLayout *layout, RenderResult *rr, but= uiDefIconBut(block, BUT, 0, ICON_TRIA_RIGHT, 0,0,18,20, NULL, 0, 0, 0, 0, "Next Layer"); uiButSetFunc(but, image_multi_inclay_cb, rr, iuser); - uiblock_layer_pass_buttons(row, rr, iuser, 230, render_slot); + uiblock_layer_pass_buttons(row, rr, iuser, 230 * dpi_fac, render_slot); /* decrease, increase arrows */ but= uiDefIconBut(block, BUT, 0, ICON_TRIA_LEFT, 0,0,17,20, NULL, 0, 0, 0, 0, "Previous Pass"); @@ -816,7 +697,7 @@ void uiTemplateImage(uiLayout *layout, bContext *C, PointerRNA *ptr, const char if(ima->source == IMA_SRC_VIEWER) { ibuf= BKE_image_acquire_ibuf(ima, iuser, &lock); - image_info(ima, ibuf, str); + image_info(scene, iuser, ima, ibuf, str); BKE_image_release_ibuf(ima, lock); uiItemL(layout, ima->id.name+2, ICON_NONE); @@ -888,7 +769,7 @@ void uiTemplateImage(uiLayout *layout, bContext *C, PointerRNA *ptr, const char else if(ima->source != IMA_SRC_GENERATED) { if(compact == 0) { ibuf= BKE_image_acquire_ibuf(ima, iuser, &lock); - image_info(ima, ibuf, str); + image_info(scene, iuser, ima, ibuf, str); BKE_image_release_ibuf(ima, lock); uiItemL(layout, str, ICON_NONE); } @@ -961,28 +842,13 @@ void uiTemplateImageLayers(uiLayout *layout, bContext *C, Image *ima, ImageUser /* render layers and passes */ if(ima && iuser) { + const float dpi_fac= UI_DPI_FAC; rr= BKE_image_acquire_renderresult(scene, ima); - uiblock_layer_pass_buttons(layout, rr, iuser, 160, (ima->type==IMA_TYPE_R_RESULT)? &ima->render_slot: NULL); + uiblock_layer_pass_buttons(layout, rr, iuser, 160 * dpi_fac, (ima->type==IMA_TYPE_R_RESULT)? &ima->render_slot: NULL); BKE_image_release_renderresult(scene, ima); } } -static int image_panel_uv_poll(const bContext *C, PanelType *UNUSED(pt)) -{ - Object *obedit= CTX_data_edit_object(C); - return ED_uvedit_test(obedit); -} - -static void image_panel_uv(const bContext *C, Panel *pa) -{ - uiBlock *block; - - block= uiLayoutAbsoluteBlock(pa->layout); - uiBlockSetHandleFunc(block, do_image_panel_events, NULL); - - image_editvertex_buts(C, block); -} - void image_buttons_register(ARegionType *art) { PanelType *pt; @@ -1000,13 +866,6 @@ void image_buttons_register(ARegionType *art) strcpy(pt->label, "Grease Pencil"); pt->draw= gpencil_panel_standard; BLI_addtail(&art->paneltypes, pt); - - pt= MEM_callocN(sizeof(PanelType), "spacetype image panel uv"); - strcpy(pt->idname, "IMAGE_PT_uv"); - strcpy(pt->label, "UV Vertex"); - pt->draw= image_panel_uv; - pt->poll= image_panel_uv_poll; - BLI_addtail(&art->paneltypes, pt); } static int image_properties(bContext *C, wmOperator *UNUSED(op)) |