diff options
Diffstat (limited to 'source/blender/editors/space_image')
-rw-r--r-- | source/blender/editors/space_image/CMakeLists.txt | 1 | ||||
-rw-r--r-- | source/blender/editors/space_image/image_buttons.c | 239 | ||||
-rw-r--r-- | source/blender/editors/space_image/image_header.c | 91 | ||||
-rw-r--r-- | source/blender/editors/space_image/image_ops.c | 6 | ||||
-rw-r--r-- | source/blender/editors/space_image/space_image.c | 4 |
5 files changed, 56 insertions, 285 deletions
diff --git a/source/blender/editors/space_image/CMakeLists.txt b/source/blender/editors/space_image/CMakeLists.txt index e3ac30067a5..b23ab624faa 100644 --- a/source/blender/editors/space_image/CMakeLists.txt +++ b/source/blender/editors/space_image/CMakeLists.txt @@ -37,7 +37,6 @@ set(INC set(SRC image_buttons.c image_draw.c - image_header.c image_ops.c image_render.c space_image.c 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)) diff --git a/source/blender/editors/space_image/image_header.c b/source/blender/editors/space_image/image_header.c deleted file mode 100644 index cee532038f4..00000000000 --- a/source/blender/editors/space_image/image_header.c +++ /dev/null @@ -1,91 +0,0 @@ -/* - * $Id$ - * - * ***** BEGIN GPL LICENSE BLOCK ***** - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * The Original Code is Copyright (C) 2008 Blender Foundation. - * All rights reserved. - * - * - * Contributor(s): Blender Foundation - * - * ***** END GPL LICENSE BLOCK ***** - */ - -/** \file blender/editors/space_image/image_header.c - * \ingroup spimage - */ - - -#include <string.h> -#include <stdio.h> - -#include "DNA_object_types.h" -#include "DNA_space_types.h" -#include "DNA_windowmanager_types.h" - -#include "BLI_blenlib.h" -#include "BLI_editVert.h" -#include "BLI_utildefines.h" - -#include "BKE_context.h" - -#include "ED_image.h" - -#include "WM_types.h" - -#include "UI_interface.h" -#include "UI_resources.h" - -#include "image_intern.h" - -/********************** toolbox operator *********************/ - -static int toolbox_invoke(bContext *C, wmOperator *UNUSED(op), wmEvent *UNUSED(event)) -{ - SpaceImage *sima= CTX_wm_space_image(C); - Object *obedit= CTX_data_edit_object(C); - uiPopupMenu *pup; - uiLayout *layout; - int show_uvedit; - - show_uvedit= ED_space_image_show_uvedit(sima, obedit); - - pup= uiPupMenuBegin(C, "Toolbox", ICON_NONE); - layout= uiPupMenuLayout(pup); - - uiItemM(layout, C, "IMAGE_MT_view", NULL, ICON_NONE); - if(show_uvedit) uiItemM(layout, C, "IMAGE_MT_select", NULL, ICON_NONE); - uiItemM(layout, C, "IMAGE_MT_image", NULL, ICON_NONE); - if(show_uvedit) uiItemM(layout, C, "IMAGE_MT_uvs", NULL, ICON_NONE); - - uiPupMenuEnd(C, pup); - - return OPERATOR_CANCELLED; -} - -void IMAGE_OT_toolbox(wmOperatorType *ot) -{ - /* identifiers */ - ot->name= "Toolbox"; - ot->idname= "IMAGE_OT_toolbox"; - - /* api callbacks */ - ot->invoke= toolbox_invoke; - ot->poll= space_image_main_area_poll; -} - diff --git a/source/blender/editors/space_image/image_ops.c b/source/blender/editors/space_image/image_ops.c index 7d4aaf0c70e..17244a5251c 100644 --- a/source/blender/editors/space_image/image_ops.c +++ b/source/blender/editors/space_image/image_ops.c @@ -645,6 +645,9 @@ static const EnumPropertyItem image_file_type_items[] = { {R_TARGA, "TARGA", 0, "Targa", ""}, {R_RAWTGA, "TARGA RAW", 0, "Targa Raw", ""}, {R_PNG, "PNG", 0, "PNG", ""}, +#ifdef WITH_DDS + {R_DDS, "DDS", 0, "DirectDraw Surface", ""}, +#endif {R_BMP, "BMP", 0, "BMP", ""}, {R_JPEG90, "JPEG", 0, "Jpeg", ""}, #ifdef WITH_OPENJPEG @@ -1420,6 +1423,9 @@ static int image_invert_exec(bContext *C, wmOperator *op) } ibuf->userflags |= IB_BITMAPDIRTY; + if(ibuf->mipmap[0]) + ibuf->userflags |= IB_MIPMAP_INVALID; + WM_event_add_notifier(C, NC_IMAGE|NA_EDITED, ima); return OPERATOR_FINISHED; } diff --git a/source/blender/editors/space_image/space_image.c b/source/blender/editors/space_image/space_image.c index 451e0e6e89b..409ab4b2fc6 100644 --- a/source/blender/editors/space_image/space_image.c +++ b/source/blender/editors/space_image/space_image.c @@ -496,7 +496,6 @@ static void image_operatortypes(void) WM_operatortype_append(IMAGE_OT_record_composite); - WM_operatortype_append(IMAGE_OT_toolbox); WM_operatortype_append(IMAGE_OT_properties); WM_operatortype_append(IMAGE_OT_scopes); } @@ -544,8 +543,6 @@ static void image_keymap(struct wmKeyConfig *keyconf) RNA_enum_set(WM_keymap_add_item(keymap, "IMAGE_OT_curves_point_set", ACTIONMOUSE, KM_PRESS, KM_CTRL, 0)->ptr, "point", 0); RNA_enum_set(WM_keymap_add_item(keymap, "IMAGE_OT_curves_point_set", ACTIONMOUSE, KM_PRESS, KM_SHIFT, 0)->ptr, "point", 1); - WM_keymap_add_item(keymap, "IMAGE_OT_toolbox", SPACEKEY, KM_PRESS, 0, 0); - /* toggle editmode is handy to have while UV unwrapping */ kmi= WM_keymap_add_item(keymap, "OBJECT_OT_mode_set", TABKEY, KM_PRESS, 0, 0); RNA_enum_set(kmi->ptr, "mode", OB_MODE_EDIT); @@ -989,6 +986,7 @@ void ED_spacetype_image(void) BLI_addhead(&st->regiontypes, art); image_buttons_register(art); + ED_uvedit_buttons_register(art); /* regions: statistics/scope buttons */ art= MEM_callocN(sizeof(ARegionType), "spacetype image region"); |