Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTon Roosendaal <ton@blender.org>2006-12-20 20:57:56 +0300
committerTon Roosendaal <ton@blender.org>2006-12-20 20:57:56 +0300
commit253432bfc7c2a1dae224a03fb3055de19743ec67 (patch)
tree2cea30606f9f29be51d5366ddf0d3747b9649b90 /source/blender/src
parent0a0753b409221b66f5003d8c257426043ada227e (diff)
The Big Image refactor!
Please read: http://www.blender3d.org/cms/Imaging.834.0.html Or in short: - adding MultiLayer Image support - recoded entire Image API - better integration of movie/sequence Images Was a whole load of work... went down for a week to do this. So, will need a lot of testing! Will be in irc all evening.
Diffstat (limited to 'source/blender/src')
-rw-r--r--source/blender/src/butspace.c23
-rw-r--r--source/blender/src/buttons_scene.c22
-rw-r--r--source/blender/src/buttons_shading.c996
-rw-r--r--source/blender/src/drawimage.c516
-rw-r--r--source/blender/src/drawmesh.c81
-rw-r--r--source/blender/src/drawnode.c182
-rw-r--r--source/blender/src/drawview.c282
-rw-r--r--source/blender/src/editnode.c111
-rw-r--r--source/blender/src/editobject.c10
-rw-r--r--source/blender/src/editscreen.c28
-rw-r--r--source/blender/src/editsima.c403
-rw-r--r--source/blender/src/edittime.c3
-rw-r--r--source/blender/src/filesel.c161
-rw-r--r--source/blender/src/header_filesel.c4
-rw-r--r--source/blender/src/header_image.c270
-rw-r--r--source/blender/src/header_info.c17
-rw-r--r--source/blender/src/header_node.c7
-rw-r--r--source/blender/src/header_time.c4
-rw-r--r--source/blender/src/headerbuttons.c11
-rw-r--r--source/blender/src/imagepaint.c121
-rw-r--r--source/blender/src/interface.c30
-rw-r--r--source/blender/src/interface_icons.c6
-rw-r--r--source/blender/src/meshtools.c10
-rw-r--r--source/blender/src/previewrender.c2
-rw-r--r--source/blender/src/renderwin.c61
-rw-r--r--source/blender/src/space.c39
-rw-r--r--source/blender/src/toets.c7
-rw-r--r--source/blender/src/toolbox.c5
-rw-r--r--source/blender/src/verse_object.c2
-rw-r--r--source/blender/src/writeimage.c101
30 files changed, 2149 insertions, 1366 deletions
diff --git a/source/blender/src/butspace.c b/source/blender/src/butspace.c
index cdc99f13b82..d8b69e41255 100644
--- a/source/blender/src/butspace.c
+++ b/source/blender/src/butspace.c
@@ -100,29 +100,8 @@ char texstr[20][12]= {"None" , "Clouds" , "Wood", "Marble", "Magic" , "Blend",
void test_idbutton_cb(void *namev, void *arg2)
{
char *name= namev;
- test_idbutton(name+2);
- /* temporal! image rename for procedural Image has issues */
- if(arg2 && GS(name)==ID_IM) {
- /* when name changed */
- if(strcmp(name+2, (char *)arg2)) {
- ID *id= NULL;
- if(strcmp((char *)arg2, "Render Result")==0)
- id= find_id(name, name+2);
- else if(strcmp((char *)arg2, "Compositor")==0)
- id= find_id(name, name+2);
- if(id) {
- Image *ima= (Image *)id;
- if(ima->ibuf) {
- /* ibuf rect or rect_float is possibly not allocated but borrowed */
- ImBuf *ibuf= IMB_dupImBuf(ima->ibuf);
- IMB_freeImBuf(ima->ibuf);
- ima->ibuf= ibuf;
- printf("changed ima %s\n", name);
- }
- }
- }
- }
+ test_idbutton(name+2);
}
diff --git a/source/blender/src/buttons_scene.c b/source/blender/src/buttons_scene.c
index 2d76f4f5ca9..059afee3cf3 100644
--- a/source/blender/src/buttons_scene.c
+++ b/source/blender/src/buttons_scene.c
@@ -124,7 +124,7 @@ void playback_anim(void);
/* ************************ SOUND *************************** */
static void load_new_sample(char *str) /* called from fileselect */
{
- char name[FILE_MAXDIR+FILE_MAXFILE];
+ char name[FILE_MAX];
bSound *sound;
bSample *sample, *newsample;
@@ -164,7 +164,7 @@ static void load_new_sample(char *str) /* called from fileselect */
void do_soundbuts(unsigned short event)
{
- char name[FILE_MAXDIR+FILE_MAXFILE];
+ char name[FILE_MAX];
bSound *sound;
bSample *sample;
bSound* tempsound;
@@ -481,11 +481,10 @@ static void backbuf_pic(char *name)
strcpy(G.scene->r.backbuf, name);
allqueue(REDRAWBUTSSCENE, 0);
- ima= add_image(name);
- if(ima) {
- free_image_buffers(ima); /* force read again */
- ima->ok= 1;
- }
+ ima= BKE_add_image_file(name);
+ if(ima)
+ BKE_image_signal(ima, NULL, IMA_SIGNAL_RELOAD);
+
BIF_undo_push("Change background picture");
}
@@ -498,7 +497,7 @@ static void ftype_pic(char *name)
static void run_playanim(char *file)
{
extern char bprogname[]; /* usiblender.c */
- char str[FILE_MAXDIR+FILE_MAXFILE];
+ char str[FILE_MAX];
int pos[2], size[2];
/* use current settings for defining position of window. it actually should test image size */
@@ -511,7 +510,7 @@ static void run_playanim(char *file)
void playback_anim(void)
{
- char file[FILE_MAXDIR+FILE_MAXFILE];
+ char file[FILE_MAX];
if(BKE_imtype_is_movie(G.scene->r.imtype)) {
switch (G.scene->r.imtype) {
@@ -1115,6 +1114,8 @@ static char *imagetype_pup(void)
strcpy(formatstring, "|%s %%x%d");
sprintf(appendstring, formatstring, "OpenEXR", R_OPENEXR);
strcat(string, appendstring);
+ sprintf(appendstring, formatstring, "MultiLayer", R_MULTILAYER);
+ strcat(string, appendstring);
#endif
if (G.have_libtiff) {
@@ -1815,7 +1816,8 @@ static void render_panel_layers(void)
uiDefButS(block, MENU, B_ADD_RENDERLAYER, strp, 30,145,23,20, &(G.scene->r.actlay), 0, 0, 0, 0, "Choose Active Render Layer");
MEM_freeN(strp);
- bt= uiDefBut(block, TEX, REDRAWNODE, "", 53,145,172,20, srl->name, 0.0, 31.0, 0, 0, "");
+ /* name max 20, exr format limit... */
+ bt= uiDefBut(block, TEX, REDRAWNODE, "", 53,145,172,20, srl->name, 0.0, 20.0, 0, 0, "");
uiButSetFunc(bt, rename_scene_layer_func, srl, NULL);
uiDefButBitS(block, TOG, R_SINGLE_LAYER, B_NOP, "Single", 230,145,60,20, &G.scene->r.scemode, 0, 0, 0, 0, "Only render this layer");
diff --git a/source/blender/src/buttons_shading.c b/source/blender/src/buttons_shading.c
index 2dcf7b001da..8557cea5468 100644
--- a/source/blender/src/buttons_shading.c
+++ b/source/blender/src/buttons_shading.c
@@ -81,6 +81,7 @@
#include "BDR_drawmesh.h"
+#include "BIF_drawimage.h"
#include "BIF_gl.h"
#include "BIF_graphics.h"
#include "BIF_keyval.h"
@@ -102,15 +103,12 @@
#include "blendef.h"
#include "radio.h"
+#include "RE_pipeline.h"
+
/* -----includes for this file specific----- */
#include "butspace.h" // own module
-/* ---------function prototypes ------------- */
-void load_tex_image(char *);
-void load_plugin_tex(char *);
-
-void save_env(char *);
static MTex emptytex;
static int packdummy = 0;
@@ -178,40 +176,37 @@ void shade_buttons_change_3d(void)
/* *************************** TEXTURE ******************************** */
-Tex *cur_imatex=0;
-int prv_win= 0;
-
-void load_tex_image(char *str) /* called from fileselect */
+static void load_image_cb(char *str, void *ima_pp_v, void *iuser_v) /* called from fileselect or button */
{
- Image *ima=0;
- Tex *tex;
+ Image **ima_pp= (Image **)ima_pp_v;
+ Image *ima= NULL;
- tex= cur_imatex;
- if(tex->type==TEX_IMAGE || tex->type==TEX_ENVMAP) {
+ ima= BKE_add_image_file(str);
+ if(ima) {
+ if(*ima_pp) {
+ (*ima_pp)->id.us--;
+ }
+ *ima_pp= ima;
- ima= add_image(str);
- if(ima) {
- if(tex->ima) {
- tex->ima->id.us--;
+ BKE_image_signal(ima, iuser_v, IMA_SIGNAL_RELOAD);
+
+ /* 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);
}
- tex->ima= ima;
-
- free_image_buffers(ima); /* force reading again */
- ima->ok= 1;
}
-
- BIF_undo_push("Load image");
- allqueue(REDRAWBUTSSHADING, 0);
-
- BIF_preview_changed(ID_TE);
}
+
+ BIF_undo_push("Load image");
}
-void load_plugin_tex(char *str) /* called from fileselect */
+static void load_plugin_tex(char *str, void *tex_v, void *unused) /* called from fileselect */
{
- Tex *tex;
+ Tex *tex= tex_v;
- tex= cur_imatex;
if(tex->type!=TEX_PLUGIN) return;
if(tex->plugin) free_plugin_tex(tex->plugin);
@@ -223,10 +218,10 @@ void load_plugin_tex(char *str) /* called from fileselect */
BIF_preview_changed(ID_TE);
}
-void save_env(char *name)
+static void save_env(char *name)
{
Tex *tex;
- char str[FILE_MAXDIR+FILE_MAXFILE];
+ char str[FILE_MAX];
strcpy(str, name);
BLI_convertstringcode(str, G.sce, G.scene->r.cfra);
@@ -255,11 +250,8 @@ static int vergcband(const void *a1, const void *a2)
void do_texbuts(unsigned short event)
{
Tex *tex;
- ImBuf *ibuf;
ScrArea *sa;
- ID *id;
- int nr;
- char *name, str[FILE_MAXDIR+FILE_MAXFILE];
+ char str[FILE_MAX];
tex= G.buts->lockpoin;
@@ -279,7 +271,7 @@ void do_texbuts(unsigned short event)
allqueue(REDRAWBUTSSHADING, 0);
break;
case B_TEXTYPE:
- if(tex==0) return;
+ if(tex==NULL) return;
tex->stype= 0;
allqueue(REDRAWBUTSSHADING, 0);
BIF_preview_changed(ID_TE);
@@ -290,175 +282,41 @@ void do_texbuts(unsigned short event)
}
break;
case B_DEFTEXVAR:
- if(tex==0) return;
+ if(tex==NULL) return;
default_tex(tex);
BIF_undo_push("Default texture vars");
allqueue(REDRAWBUTSSHADING, 0);
BIF_preview_changed(ID_TE);
break;
- case B_LOADTEXIMA:
- if(tex==0) return;
- /* globals: temporal store them: we make another area a fileselect */
- cur_imatex= tex;
- prv_win= curarea->win;
- sa= closest_bigger_area();
- areawinset(sa->win);
- if(tex->ima) name= tex->ima->name;
-#ifdef _WIN32
- else {
- if (strcmp (U.textudir, "/") == 0)
- name= G.sce;
- else
- name= U.textudir;
- }
-#else
- else name = U.textudir;
-#endif
-
- if(G.qual==LR_CTRLKEY)
- activate_imageselect(FILE_SPECIAL, "SELECT IMAGE", name, load_tex_image);
- else
- activate_fileselect(FILE_SPECIAL, "SELECT IMAGE", name, load_tex_image);
-
- break;
- case B_NAMEIMA:
- if(tex==0) return;
- if(tex->ima) {
- cur_imatex= tex;
- prv_win= curarea->win;
-
- /* name in tex->ima has been changed by button! */
- strcpy(str, tex->ima->name);
- if(tex->ima->ibuf) strcpy(tex->ima->name, tex->ima->ibuf->name);
-
- load_tex_image(str);
- }
- break;
- case B_TEXREDR_PRV:
- allqueue(REDRAWBUTSSHADING, 0);
+ case B_IMAGECHANGED:
BIF_preview_changed(ID_TE);
- shade_buttons_change_3d();
- break;
- case B_TEXIMABROWSE:
+ allqueue(REDRAWBUTSSHADING, 0);
+
if(tex) {
- id= (ID*) tex->ima;
-
- if(G.buts->menunr== -2) {
- activate_databrowse(id, ID_IM, 0, B_TEXIMABROWSE, &G.buts->menunr, do_texbuts);
- } else if (G.buts->menunr>0) {
- Image *newima= (Image*) BLI_findlink(&G.main->image, G.buts->menunr-1);
-
- if (newima && newima!=(Image*) id) {
- tex->ima= newima;
- id_us_plus((ID*) newima);
- if(id) id->us--;
-
- BIF_undo_push("Browse image");
- allqueue(REDRAWBUTSSHADING, 0);
- BIF_preview_changed(ID_TE);
- }
+ if(G.scene->nodetree) {
+ NodeTagIDChanged(G.scene->nodetree, &tex->id);
+ allqueue(RECALC_COMPOSITE, 0);
}
- }
- break;
- case B_IMAPTEST:
- if(tex) {
- if( (tex->imaflag & (TEX_FIELDS+TEX_MIPMAP))== TEX_FIELDS+TEX_MIPMAP ) {
+ if(tex->ima && (tex->imaflag & TEX_MIPMAP) && (tex->ima->flag & IMA_FIELDS)) {
error("Cannot combine fields and mipmap");
tex->imaflag -= TEX_MIPMAP;
- allqueue(REDRAWBUTSSHADING, 0);
- }
-
- if(tex->ima && tex->ima->ibuf) {
- ibuf= tex->ima->ibuf;
- nr= 0;
- if( !(tex->imaflag & TEX_FIELDS) && (ibuf->flags & IB_fields) ) nr= 1;
- if( (tex->imaflag & TEX_FIELDS) && !(ibuf->flags & IB_fields) ) nr= 1;
- if(nr) {
- IMB_freeImBuf(ibuf);
- tex->ima->ibuf= 0;
- tex->ima->ok= 1;
- BIF_preview_changed(ID_TE);
- }
}
- }
- break;
- case B_RELOADIMA:
- if(tex && tex->ima) {
- // check if there is a newer packedfile
-
- if (tex->ima->packedfile) {
- PackedFile *pf;
- pf = newPackedFile(tex->ima->name);
- if (pf) {
- freePackedFile(tex->ima->packedfile);
- tex->ima->packedfile = pf;
- } else {
- error("Image not available. Keeping packed image.");
- }
- }
- if (tex->ima->preview) {
- free_image_preview(tex->ima);
- }
-
- IMB_freeImBuf(tex->ima->ibuf);
- tex->ima->ibuf= NULL;
- tex->ima->ok= 1;
-
if(tex->env)
BKE_free_envmapdata(tex->env);
-
- free_realtime_image(tex->ima);
-
- allqueue(REDRAWVIEW3D, 0);
- allqueue(REDRAWIMAGE, 0);
- BIF_preview_changed(ID_TE);
- }
- allqueue(REDRAWBUTSSHADING, 0); // redraw buttons
-
- break;
- case B_UNLINKIMA:
- if(tex && tex->ima) {
- tex->ima->id.us--;
- tex->ima= NULL;
- allqueue(REDRAWBUTSSHADING, 0); // redraw buttons
- BIF_preview_changed(ID_TE);
}
+
break;
- case B_TEXSETFRAMES:
- if(tex->ima->anim) tex->frames = IMB_anim_get_duration(tex->ima->anim);
+
+ case B_TEXREDR_PRV:
allqueue(REDRAWBUTSSHADING, 0);
+ BIF_preview_changed(ID_TE);
+ shade_buttons_change_3d();
break;
- case B_PACKIMA:
- if(tex && tex->ima) {
- if (tex->ima->packedfile) {
- if (G.fileflags & G_AUTOPACK) {
- if (okee("Disable AutoPack ?")) {
- G.fileflags &= ~G_AUTOPACK;
- }
- }
-
- if ((G.fileflags & G_AUTOPACK) == 0) {
- unpackImage(tex->ima, PF_ASK);
- }
- } else {
- if (tex->ima->ibuf && (tex->ima->ibuf->userflags & IB_BITMAPDIRTY)) {
- error("Can't pack painted image. Save image from Image window first.");
- } else {
- tex->ima->packedfile = newPackedFile(tex->ima->name);
- }
- }
- allqueue(REDRAWBUTSSHADING, 0);
- allqueue(REDRAWHEADERS, 0);
- }
- break;
- case B_LOADPLUGIN:
- if(tex==0) return;
- /* globals: store temporal: we make another area a fileselect */
- cur_imatex= tex;
- prv_win= curarea->win;
+ case B_LOADPLUGIN:
+ if(tex==NULL) return;
sa= closest_bigger_area();
areawinset(sa->win);
@@ -466,12 +324,12 @@ void do_texbuts(unsigned short event)
else {
strcpy(str, U.plugtexdir);
}
- activate_fileselect(FILE_SPECIAL, "SELECT PLUGIN", str, load_plugin_tex);
+ activate_fileselect_args(FILE_SPECIAL, "SELECT PLUGIN", str, load_plugin_tex, tex, NULL);
break;
case B_NAMEPLUGIN:
- if(tex==0 || tex->plugin==0) return;
+ if(tex==NULL || tex->plugin==NULL) return;
strcpy(str, tex->plugin->name);
free_plugin_tex(tex->plugin);
tex->stype= 0;
@@ -481,8 +339,8 @@ void do_texbuts(unsigned short event)
break;
case B_COLORBAND:
- if(tex==0) return;
- if(tex->coba==0) tex->coba= add_colorband(0);
+ if(tex==NULL) return;
+ if(tex->coba==NULL) tex->coba= add_colorband(0);
allqueue(REDRAWBUTSSHADING, 0);
BIF_preview_changed(ID_TE); // also ramps, so we do this
break;
@@ -854,11 +712,559 @@ static void texture_panel_voronoi(Tex *tex)
}
+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");
+
+ 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);
+ }
+
+ if(*curlay >= nr)
+ *curlay= 0;
+
+ 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(void *ima_v, void *iuser_v)
+{
+ 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, G.scene->r.cfra, 0);
+ }
+}
+
+static void image_src_change_cb(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(char *unused, 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) {
+ 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(&G.main->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);
+
+ BIF_undo_push("Browse image");
+ }
+ }
+ }
+}
+
+static void image_browse_cb(void *ima_pp_v, void *iuser_v)
+{
+ image_browse_cb1(NULL, ima_pp_v, iuser_v);
+}
+
+static void image_reload_cb(void *ima_v, void *iuser_v)
+{
+ if(ima_v) {
+ BKE_image_signal(ima_v, iuser_v, IMA_SIGNAL_RELOAD);
+ }
+}
+
+static void image_field_test(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(void *ima_pp_v, void *unused)
+{
+ Image **ima_pp= (Image **)ima_pp_v;
+
+ if(ima_pp && *ima_pp) {
+ Image *ima= *ima_pp;
+ ima->id.us--;
+ *ima_pp= NULL;
+ }
+}
+
+static void image_load_fs_cb(void *ima_pp_v, void *iuser_v)
+{
+ Image **ima_pp= (Image **)ima_pp_v;
+ ScrArea *sa;
+ char *name;
+
+ if(ima_pp==NULL) return;
+
+ sa= closest_bigger_area();
+ areawinset(sa->win);
+ if(*ima_pp) name= (*ima_pp)->name;
+#ifdef _WIN32
+ else {
+ if (strcmp (U.textudir, "/") == 0)
+ name= G.sce;
+ else
+ name= U.textudir;
+ }
+#else
+ else name = U.textudir;
+#endif
+ activate_fileselect_args(FILE_SPECIAL, "SELECT IMAGE", name, load_image_cb, ima_pp_v, iuser_v);
+}
+
+/* 5 layer button callbacks... */
+static void image_multi_cb(void *rr_v, void *iuser_v)
+{
+ BKE_image_multilayer_index(rr_v, iuser_v);
+}
+static void image_multi_inclay_cb(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(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(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(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(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);
+ BIF_undo_push("Unpack image");
+ }
+ }
+ else {
+ ImBuf *ibuf= BKE_image_get_ibuf(ima, iuser_v);
+ if (ibuf && (ibuf->userflags & IB_BITMAPDIRTY)) {
+ error("Can't pack painted image. Save image or use Repack as PNG.");
+ } else {
+ ima->packedfile = newPackedFile(ima->name);
+ BIF_undo_push("Pack image");
+ }
+ }
+ }
+ }
+}
+
+static void image_load_cb(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(str, ima_pp_v, iuser_v);
+ }
+}
+
+static void image_freecache_cb(void *ima_v, void *unused)
+{
+ BKE_image_free_anim_ibufs(ima_v, G.scene->r.cfra);
+ allqueue(REDRAWIMAGE, 0);
+}
+
+static void image_generated_change_cb(void *ima_v, void *iuser_v)
+{
+ BKE_image_signal(ima_v, iuser_v, IMA_SIGNAL_FREE);
+}
+
+static void image_user_change(void *iuser_v, void *unused)
+{
+ BKE_image_user_calc_imanr(iuser_v, G.scene->r.cfra, 0);
+}
+
+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);
+
+}
+
+/* The general Image panel with the loadsa callbacks! */
+void uiblock_image_panel(uiBlock *block, Image **ima_pp, ImageUser *iuser,
+ short redraw, short imagechanged)
+{
+ 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(G.scene->nodetree);
+
+ 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(G.scene->id.name)), iuser, imagechanged);
+ }
+ return;
+ }
+
+ /* the main ima source types */
+ if(ima) {
+ uiSetButLock(ima->id.lib!=NULL, "Can't edit library data");
+ 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, &(G.main->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, 19.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;
+ BIF_preview_changed(ID_TE);
+ }
+ }
+
+ /* 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, 107, 300, 20, NULL, 1, 0, 0, 0, "");
+ }
+
+ /* left side default per-image options, right half the additional options */
+
+ /* fields */
+ uiBlockBeginAlign(block);
+ but= uiDefButBitS(block, TOG, IMA_FIELDS, imagechanged, "Fields", 10, 70, 100, 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", 10, 50, 100, 20, &ima->flag, 0, 0, 0, 0, "Standard Field Toggle");
+ uiBlockEndAlign(block);
+
+ uiDefButBitS(block, TOG, IMA_ANTIALI, B_NOP, "Anti", 10, 10, 100, 20, &ima->flag, 0, 0, 0, 0, "Toggles Image anti-aliasing, only works with solid colors");
+
+ 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);
+ }
+ }
+
+}
+
+static void texture_panel_image(Image **ima, ImageUser *iuser)
+{
+ uiBlock *block;
+
+ block= uiNewBlock(&curarea->uiblocks, "texture_panel_image", UI_EMBOSS, UI_HELV, curarea->win);
+ if(uiNewPanel(curarea, block, "Image", "Texture", 960, 0, 318, 204)==0) return;
+
+ uiblock_image_panel(block, ima, iuser, B_REDR, B_IMAGECHANGED);
+}
+
+static void texture_panel_image_map(Tex *tex)
+{
+ uiBlock *block;
+
+ block= uiNewBlock(&curarea->uiblocks, "texture_panel_image_map", UI_EMBOSS, UI_HELV, curarea->win);
+ if(uiNewPanel(curarea, block, "Map Image", "Texture", 640, 0, 318, 204)==0) return;
+ uiSetButLock(tex->id.lib!=0, "Can't edit library data");
+
+ /* types */
+ uiBlockBeginAlign(block);
+ uiDefButBitS(block, TOG, TEX_MIPMAP, B_IMAGECHANGED, "MipMap", 10, 180, 75, 20, &tex->imaflag, 0, 0, 0, 0, "Generates and uses mipmaps");
+ uiDefButBitS(block, TOG, TEX_GAUSS_MIP, 0, "Gauss", 85, 180, 75, 20, &tex->imaflag, 0, 0, 0, 0, "Enable Gauss filter to sample down mipmaps");
+ uiDefButBitS(block, TOG, TEX_INTERPOL, 0, "Interpol", 160, 180, 75, 20, &tex->imaflag, 0, 0, 0, 0, "Interpolates pixels using Area filter");
+ uiDefButBitS(block, TOG, TEX_IMAROT, B_TEXPRV, "Rot90", 235, 180, 75, 20, &tex->imaflag, 0, 0, 0, 0, "Actually flips X and Y for rendering, rotates and mirrors");
+
+ uiDefButBitS(block, TOG, TEX_USEALPHA, B_TEXPRV, "UseAlpha", 10, 160, 100, 20, &tex->imaflag, 0, 0, 0, 0, "Click to use Image's alpha channel");
+ uiDefButBitS(block, TOG, TEX_CALCALPHA, B_TEXPRV, "CalcAlpha", 110, 160, 100, 20, &tex->imaflag, 0, 0, 0, 0, "Click to calculate an alpha channel based on Image RGB values");
+ uiDefButBitS(block, TOG, TEX_NEGALPHA, B_TEXPRV, "NegAlpha", 210, 160, 100, 20, &tex->flag, 0, 0, 0, 0, "Click to invert the alpha values");
+ uiBlockEndAlign(block);
+
+ uiDefButF(block, NUM, B_TEXPRV, "Filter :", 10,120,150,20, &tex->filtersize, 0.1, 25.0, 0, 3, "Sets the filter size used by mipmap and interpol");
+
+ uiDefButBitS(block, TOG, TEX_NORMALMAP, B_NOP, "Normal Map", 160,120,150,20, &tex->imaflag,
+ 0, 0, 0, 0, "Use image RGB values for normal mapping");
+
+ /* crop extend clip */
+
+ uiBlockBeginAlign(block);
+ uiDefButS(block, ROW, B_TEXREDR_PRV, "Extend", 10,90,63,19, &tex->extend, 4.0, 1.0, 0, 0, "Extends the colour of the edge pixels");
+ uiDefButS(block, ROW, B_TEXREDR_PRV, "Clip", 73,90,48,19, &tex->extend, 4.0, 2.0, 0, 0, "Sets alpha 0.0 outside Image edges");
+ uiDefButS(block, ROW, B_TEXREDR_PRV, "ClipCube", 121,90,63,19, &tex->extend, 4.0, 4.0, 0, 0, "Sets alpha to 0.0 outside cubeshaped area around Image");
+ uiDefButS(block, ROW, B_TEXREDR_PRV, "Repeat", 184,90,63,19, &tex->extend, 4.0, 3.0, 0, 0, "Causes Image to repeat horizontally and vertically");
+ uiDefButS(block, ROW, B_TEXREDR_PRV, "Checker", 247,90,63,19, &tex->extend, 4.0, 5.0, 0, 0, "Causes Image to repeat in checker pattern");
+
+ if(tex->extend==TEX_REPEAT) {
+ uiBlockBeginAlign(block);
+ uiDefButS(block, NUM, B_TEXPRV, "Xrepeat:", 10,60,150,19, &tex->xrepeat, 1.0, 512.0, 0, 0, "Sets a repetition multiplier in the X direction");
+ uiDefButS(block, NUM, B_TEXPRV, "Yrepeat:", 160,60,150,19, &tex->yrepeat, 1.0, 512.0, 0, 0, "Sets a repetition multiplier in the Y direction");
+ }
+ else if(tex->extend==TEX_CHECKER) {
+ uiBlockBeginAlign(block);
+ uiDefButBitS(block, TOG, TEX_CHECKER_ODD, B_TEXPRV, "Odd", 10,60,100,19, &tex->flag, 0.0, 0.0, 0, 0, "Sets odd checker tiles");
+ uiDefButBitS(block, TOG, TEX_CHECKER_EVEN, B_TEXPRV, "Even", 110,60,100,19, &tex->flag, 0.0, 0.0, 0, 0, "Sets even checker tiles");
+ uiDefButF(block, NUM, B_TEXPRV, "Mortar:", 210,60,100,19, &tex->checkerdist, 0.0, 0.99, 0, 0, "Set checkers distance (like mortar)");
+ }
+ uiBlockBeginAlign(block);
+ uiDefButF(block, NUM, B_TEXPRV, "MinX ", 10,30,150,19, &tex->cropxmin, -10.0, 10.0, 10, 0, "Sets minimum X value to crop Image");
+ uiDefButF(block, NUM, B_TEXPRV, "MinY ", 10,10,150,19, &tex->cropymin, -10.0, 10.0, 10, 0, "Sets minimum Y value to crop Image");
+
+ uiBlockBeginAlign(block);
+ uiDefButF(block, NUM, B_TEXPRV, "MaxX ", 160,30,150,19, &tex->cropxmax, -10.0, 10.0, 10, 0, "Sets maximum X value to crop Image");
+ uiDefButF(block, NUM, B_TEXPRV, "MaxY ", 160,10,150,19, &tex->cropymax, -10.0, 10.0, 10, 0, "Sets maximum Y value to crop Image");
+ uiBlockEndAlign(block);
+
+}
+
/***************************************/
static void texture_panel_envmap(Tex *tex)
{
uiBlock *block;
+ uiBut *but;
EnvMap *env;
ID *id;
short a, xco, yco, dx, dy;
@@ -867,7 +1273,7 @@ static void texture_panel_envmap(Tex *tex)
block= uiNewBlock(&curarea->uiblocks, "texture_panel_envmap", UI_EMBOSS, UI_HELV, curarea->win);
if(uiNewPanel(curarea, block, "Envmap", "Texture", 640, 0, 318, 204)==0) return;
uiSetButLock(tex->id.lib!=0, "Can't edit library data");
-
+
if(tex->env==NULL) {
tex->env= BKE_add_envmap();
tex->env->object= OBACT;
@@ -884,28 +1290,35 @@ static void texture_panel_envmap(Tex *tex)
if(env->stype==ENV_LOAD) {
/* file input */
id= (ID *)tex->ima;
- IDnames_to_pupstring(&strp, NULL, NULL, &(G.main->image), id, &(G.buts->menunr));
+ IMAnames_to_pupstring(&strp, NULL, NULL, &(G.main->image), id, &(G.buts->menunr));
if(strp[0]) {
uiBlockBeginAlign(block);
- uiDefButS(block, MENU, B_TEXIMABROWSE, strp, 10,145,23,20, &(G.buts->menunr), 0, 0, 0, 0, "Selects an existing environment map or creates new");
+
+ but= uiDefButS(block, MENU, B_TEXPRV, strp, 10,145,23,20, &tex->iuser.menunr, 0, 0, 0, 0, "Selects an existing environment map");
+ uiButSetFunc(but, image_browse_cb, &tex->ima, &tex->iuser);
if(tex->ima) {
- uiDefBut(block, TEX, B_NAMEIMA, "", 35,145,255,20, tex->ima->name, 0.0, 79.0, 0, 0, "Displays environment map name: click to change");
+ but= uiDefBut(block, TEX, B_NAMEIMA, "", 35,145,255,20, tex->ima->name, 0.0, 79.0, 0, 0, "Displays environment map name: click to change");
+ uiButSetFunc(but, image_load_cb, &tex->ima, &tex->iuser);
+
sprintf(str, "%d", tex->ima->id.us);
uiDefBut(block, BUT, 0, str, 290,145,20,20, 0, 0, 0, 0, 0, "Displays number of users of environment map: click to make single user");
uiBlockEndAlign(block);
- uiDefBut(block, BUT, B_RELOADIMA, "Reload", 230,125,80,20, 0, 0, 0, 0, 0, "Reloads saved environment map");
-
+ but= uiDefBut(block, BUT, B_IMAGECHANGED, "Reload", 230,125,80,20, 0, 0, 0, 0, 0, "Reloads saved environment map");
+ uiButSetFunc(but, image_reload_cb, tex->ima, NULL);
+
if (tex->ima->packedfile) packdummy = 1;
else packdummy = 0;
- uiDefIconButBitI(block, TOG, 1, B_PACKIMA, ICON_PACKAGE, 205,125,24,20, &packdummy, 0, 0, 0, 0, "Toggles Packed status of this environment map");
+ but= uiDefIconButBitI(block, TOG, 1, B_REDR, ICON_PACKAGE, 205,125,24,20, &packdummy, 0, 0, 0, 0, "Toggles Packed status of this environment map");
+ uiButSetFunc(but, image_pack_cb, tex->ima, &tex->iuser);
}
else uiBlockEndAlign(block);
}
MEM_freeN(strp);
-
- uiDefBut(block, BUT, B_LOADTEXIMA, "Load Image", 10,125,150,20, 0, 0, 0, 0, 0, "Loads saved environment map - file select");
+
+ but= uiDefBut(block, BUT, B_IMAGECHANGED, "Load Image", 10,125,150,20, 0, 0, 0, 0, 0, "Loads saved environment map - file select");
+ uiButSetFunc(but, image_load_fs_cb, &tex->ima, &tex->iuser);
}
else {
uiBlockBeginAlign(block);
@@ -919,15 +1332,15 @@ static void texture_panel_envmap(Tex *tex)
uiDefButF(block, NUM, B_NOP, "Zoom: ", 210,120,100,20, &env->viewscale, 0.5f, 5.0f, 100, 2, "Zoom factor for planar environment map");
uiBlockEndAlign(block);
}
-
+
uiDefIDPoinBut(block, test_obpoin_but, ID_OB, B_ENV_OB, "Ob:", 10,90,150,20, &(env->object), "Displays object to use as viewpoint for environment map: click to change");
if(env->stype!=ENV_LOAD)
uiDefButS(block, NUM, B_ENV_FREE, "CubeRes", 160,90,150,20, &env->cuberes, 50, 4096.0, 0, 0, "Sets the pixel resolution of the rendered environment map");
-
+
uiBlockBeginAlign(block);
uiDefButF(block, NUM, B_TEXPRV, "Filter :", 10,65,150,20, &tex->filtersize, 0.1, 25.0, 0, 3, "Adjusts sharpness or blurriness of the reflection"),
- uiDefButS(block, NUM, B_ENV_FREE, "Depth:", 160,65,150,20, &env->depth, 0, 5.0, 0, 0, "Sets the number of times a map will be rendered recursively mirror effects"),
- uiDefButF(block, NUM, REDRAWVIEW3D, "ClipSta", 10,40,150,20, &env->clipsta, 0.01, 50.0, 100, 0, "Sets start value for clipping: objects nearer than this are not visible to map");
+ uiDefButS(block, NUM, B_ENV_FREE, "Depth:", 160,65,150,20, &env->depth, 0, 5.0, 0, 0, "Sets the number of times a map will be rendered recursively mirror effects"),
+ uiDefButF(block, NUM, REDRAWVIEW3D, "ClipSta", 10,40,150,20, &env->clipsta, 0.01, 50.0, 100, 0, "Sets start value for clipping: objects nearer than this are not visible to map");
uiDefButF(block, NUM, B_NOP, "ClipEnd", 160,40,150,20, &env->clipend, 0.1, 5000.0, 1000, 0, "Sets end value for clipping beyond which objects are not visible to map");
uiBlockEndAlign(block);
@@ -942,146 +1355,15 @@ static void texture_panel_envmap(Tex *tex)
uiDefButBitI(block, TOG, 1<<a, 0, "", (xco+a*(dx/2)), (yco+dy/2), (dx/2), (1+dy/2), &env->notlay, 0, 0, 0, 0, "Toggles layer visibility to environment map");
for(a=0; a<5; a++)
uiDefButBitI(block, TOG, 1<<(a+10), 0, "",(xco+a*(dx/2)), yco, (dx/2), (dy/2), &env->notlay, 0, 0, 0, 0, "Toggles layer visibility to environment map");
-
+
uiBlockBeginAlign(block);
xco+= 5;
for(a=5; a<10; a++)
uiDefButBitI(block, TOG, 1<<a, 0, "", (xco+a*(dx/2)), (yco+dy/2), (dx/2), (1+dy/2), &env->notlay, 0, 0, 0, 0, "Toggles layer visibility to environment map");
for(a=5; a<10; a++)
uiDefButBitI(block, TOG, 1<<(a+10), 0, "",(xco+a*(dx/2)), yco, (dx/2), (dy/2), &env->notlay, 0, 0, 0, 0, "Toggles layer visibility to environment map");
-
- }
-}
-
-
-static void texture_panel_image1(Tex *tex)
-{
- uiBlock *block;
- char str[32];
-
- block= uiNewBlock(&curarea->uiblocks, "texture_panel1", UI_EMBOSS, UI_HELV, curarea->win);
- if(uiNewPanel(curarea, block, "Anim and Movie", "Texture", 960, 0, 318, 204)==0) return;
- uiSetButLock(tex->id.lib!=0, "Can't edit library data");
-
- /* print amount of frames anim */
- if(tex->ima && tex->ima->anim) {
- uiDefBut(block, BUT, B_TEXSETFRAMES, "<", 802, 110, 20, 18, 0, 0, 0, 0, 0, "Copies number of frames in movie file to Frames: button");
- sprintf(str, "%d frs ", IMB_anim_get_duration(tex->ima->anim));
- uiDefBut(block, LABEL, 0, str, 834, 110, 90, 18, 0, 0, 0, 0, 0, "Number of frames in movie file");
- sprintf(str, "%d cur ", tex->ima->lastframe);
- uiDefBut(block, LABEL, 0, str, 834, 90, 90, 18, 0, 0, 0, 0, 0, "");
- }
- else uiDefBut(block, LABEL, 0, "<", 802, 110, 20, 18, 0, 0, 0, 0, 0, "");
-
- uiDefButI(block, NUM, B_TEXPRV, "Frames :", 642,110,150,19, &tex->frames, 0.0, MAXFRAMEF, 0, 0, "Sets the number of frames of a movie to use and activates animation options");
- uiDefButI(block, NUM, B_TEXPRV, "Offset :", 642,90,150,19, &tex->offset, -MAXFRAMEF, MAXFRAMEF, 0, 0, "Offsets the number of the first movie frame to use in the animation");
- uiDefButS(block, NUM, B_TEXPRV, "Fie/Ima:", 642,60,98,19, &tex->fie_ima, 1.0, 200.0, 0, 0, "Sets the number of fields per rendered frame");
- uiDefButI(block, NUM, B_TEXPRV, "StartFr:", 642,30,150,19, &tex->sfra, 1.0, MAXFRAMEF, 0, 0, "Sets the starting frame of the movie to use in animation");
- uiDefButI(block, NUM, B_TEXPRV, "Len:", 642,10,150,19, &tex->len, 0.0, MAXFRAMEF, 0, 0, "Sets the number of movie frames to use in animation: 0=all");
-
- uiBlockBeginAlign(block);
- uiDefButI(block, NUM, B_TEXPRV, "Fra:", 802,70,73,19, &(tex->fradur[0][0]), 0.0, MAXFRAMEF, 0, 0, "Montage mode: frame start");
- uiDefButI(block, NUM, B_TEXPRV, "Fra:", 802,50,73,19, &(tex->fradur[1][0]), 0.0, MAXFRAMEF, 0, 0, "Montage mode: frame start");
- uiDefButI(block, NUM, B_TEXPRV, "Fra:", 802,30,73,19, &(tex->fradur[2][0]), 0.0, MAXFRAMEF, 0, 0, "Montage mode: frame start");
- uiDefButI(block, NUM, B_TEXPRV, "Fra:", 802,10,73,19, &(tex->fradur[3][0]), 0.0, MAXFRAMEF, 0, 0, "Montage mode: frame start");
- uiBlockBeginAlign(block);
- uiDefButI(block, NUM, B_TEXPRV, "", 879,70,37,19, &(tex->fradur[0][1]), 0.0, 250.0, 0, 0, "Montage mode: amount of displayed frames");
- uiDefButI(block, NUM, B_TEXPRV, "", 879,50,37,19, &(tex->fradur[1][1]), 0.0, 250.0, 0, 0, "Montage mode: amount of displayed frames");
- uiDefButI(block, NUM, B_TEXPRV, "", 879,30,37,19, &(tex->fradur[2][1]), 0.0, 250.0, 0, 0, "Montage mode: amount of displayed frames");
- uiDefButI(block, NUM, B_TEXPRV, "", 879,10,37,19, &(tex->fradur[3][1]), 0.0, 250.0, 0, 0, "Montage mode: amount of displayed frames");
- uiBlockEndAlign(block);
- uiDefButBitS(block, TOG, TEX_ANIMCYCLIC, B_TEXPRV, "Cyclic", 743,60,48,19, &tex->imaflag, 0, 0, 0, 0, "Toggles looping of animated frames");
-}
-
-
-static void texture_panel_image(Tex *tex)
-{
- uiBlock *block;
- ID *id;
- char *strp, str[32];
-
- block= uiNewBlock(&curarea->uiblocks, "texture_panel_image", UI_EMBOSS, UI_HELV, curarea->win);
- if(uiNewPanel(curarea, block, "Image", "Texture", 640, 0, 318, 204)==0) return;
- uiSetButLock(tex->id.lib!=0, "Can't edit library data");
-
- /* types */
- uiBlockBeginAlign(block);
- uiDefButBitS(block, TOG, TEX_MIPMAP, B_IMAPTEST, "MipMap", 10, 180, 60, 18, &tex->imaflag, 0, 0, 0, 0, "Generates and uses mipmaps");
- uiDefButBitS(block, TOG, TEX_GAUSS_MIP, 0, "Gauss", 70, 180, 50, 18, &tex->imaflag, 0, 0, 0, 0, "Enable Gauss filter to sample down mipmaps");
- uiDefButBitS(block, TOG, TEX_INTERPOL, 0, "Interpol", 120, 180, 60, 18, &tex->imaflag, 0, 0, 0, 0, "Interpolates pixels using Area filter");
- uiDefButBitS(block, TOG, TEX_IMAROT, B_TEXPRV, "Rot90", 180, 180, 40, 18, &tex->imaflag, 0, 0, 0, 0, "Actually flips X and Y for rendering, rotates and mirrors");
- uiDefButBitS(block, TOG, TEX_ANTIALI, 0, "Anti", 220, 180, 40, 18, &tex->imaflag, 0, 0, 0, 0, "Toggles Image anti-aliasing");
- uiDefButBitS(block, TOG, TEX_ANIM5, B_RELOADIMA, "Movie", 260, 180, 50, 18, &tex->imaflag, 0, 0, 0, 0, "Click to enable movie frames as Images");
-
- uiDefButBitS(block, TOG, TEX_USEALPHA, B_TEXPRV, "UseAlpha", 10, 160, 70, 18, &tex->imaflag, 0, 0, 0, 0, "Click to use Image's alpha channel");
- uiDefButBitS(block, TOG, TEX_CALCALPHA, B_TEXPRV, "CalcAlpha", 80, 160, 70, 18, &tex->imaflag, 0, 0, 0, 0, "Click to calculate an alpha channel based on Image RGB values");
- uiDefButBitS(block, TOG, TEX_NEGALPHA, B_TEXPRV, "NegAlpha", 150, 160, 60, 18, &tex->flag, 0, 0, 0, 0, "Click to invert the alpha values");
- uiDefButBitS(block, TOG, TEX_FIELDS, B_IMAPTEST, "Fields", 210, 160, 60, 18, &tex->imaflag, 0, 0, 0, 0, "Click to enable use of fields in Image");
- uiDefButBitS(block, TOG, TEX_STD_FIELD, 0, "Odd", 270, 160, 40, 18, &tex->imaflag, 0, 0, 0, 0, "Standard Field Toggle");
- uiBlockEndAlign(block);
-
- /* file input */
- id= (ID *)tex->ima;
- IDnames_to_pupstring(&strp, NULL, NULL, &(G.main->image), id, &(G.buts->menunr));
- if(strp[0]) {
- uiBlockBeginAlign(block);
- uiDefButS(block, MENU, B_TEXIMABROWSE, strp, 10,135,23,20, &(G.buts->menunr), 0, 0, 0, 0, "Selects an existing texture or creates new");
- if(tex->ima) {
- uiDefBut(block, TEX, B_NAMEIMA, "", 35,135,235,20, tex->ima->name, 0.0, 79.0, 0, 0, "Displays name of the Image file: click to change");
- uiDefIconBut(block, BUT, B_UNLINKIMA, ICON_X, 270,135,20,20, 0, 0, 0, 0, 0, "Unlink Image block from Texture");
-
- sprintf(str, "%d", tex->ima->id.us);
- uiDefBut(block, BUT, 0, str, 290,135,20,20, 0, 0, 0, 0, 0, "Displays number of users of texture");
- uiBlockEndAlign(block);
-
- uiDefBut(block, BUT, B_RELOADIMA, "Reload", 230,115,80,19, 0, 0, 0, 0, 0, "Reloads Image");
-
- if (tex->ima->packedfile) packdummy = 1;
- else packdummy = 0;
-
- uiDefIconButBitI(block, TOG, 1, B_PACKIMA, ICON_PACKAGE, 205,115,24,19, &packdummy, 0, 0, 0, 0, "Toggles Packed status of this Image");
- }
- else uiBlockEndAlign(block);
}
- MEM_freeN(strp);
-
- uiDefBut(block, BUT, B_LOADTEXIMA, "Load Image", 10,115,150,19, 0, 0, 0, 0, 0, "Click to load an Image");
-
- /* crop extend clip */
-
- uiDefButF(block, NUM, B_TEXPRV, "Filter :", 10,92,150,19, &tex->filtersize, 0.1, 25.0, 0, 3, "Sets the filter size used by mipmap and interpol");
-
- uiDefButBitS(block, TOG, TEX_NORMALMAP, B_NOP, "Normal Map", 160,92,150,19, &tex->imaflag,
- 0, 0, 0, 0, "Use image RGB values for normal mapping");
-
- uiBlockBeginAlign(block);
- uiDefButS(block, ROW, B_TEXREDR_PRV, "Extend", 10,70,63,19, &tex->extend, 4.0, 1.0, 0, 0, "Extends the colour of the edge pixels");
- uiDefButS(block, ROW, B_TEXREDR_PRV, "Clip", 73,70,48,19, &tex->extend, 4.0, 2.0, 0, 0, "Sets alpha 0.0 outside Image edges");
- uiDefButS(block, ROW, B_TEXREDR_PRV, "ClipCube", 121,70,63,19, &tex->extend, 4.0, 4.0, 0, 0, "Sets alpha to 0.0 outside cubeshaped area around Image");
- uiDefButS(block, ROW, B_TEXREDR_PRV, "Repeat", 184,70,63,19, &tex->extend, 4.0, 3.0, 0, 0, "Causes Image to repeat horizontally and vertically");
- uiDefButS(block, ROW, B_TEXREDR_PRV, "Checker", 247,70,63,19, &tex->extend, 4.0, 5.0, 0, 0, "Causes Image to repeat in checker pattern");
-
- if(tex->extend==TEX_REPEAT) {
- uiBlockBeginAlign(block);
- uiDefButS(block, NUM, B_TEXPRV, "Xrepeat:", 10,50,150,19, &tex->xrepeat, 1.0, 512.0, 0, 0, "Sets a repetition multiplier in the X direction");
- uiDefButS(block, NUM, B_TEXPRV, "Yrepeat:", 160,50,150,19, &tex->yrepeat, 1.0, 512.0, 0, 0, "Sets a repetition multiplier in the Y direction");
- }
- else if(tex->extend==TEX_CHECKER) {
- uiBlockBeginAlign(block);
- uiDefButBitS(block, TOG, TEX_CHECKER_ODD, B_TEXPRV, "Odd", 10,50,100,19, &tex->flag, 0.0, 0.0, 0, 0, "Sets odd checker tiles");
- uiDefButBitS(block, TOG, TEX_CHECKER_EVEN, B_TEXPRV, "Even", 110,50,100,19, &tex->flag, 0.0, 0.0, 0, 0, "Sets even checker tiles");
- uiDefButF(block, NUM, B_TEXPRV, "Mortar:", 210,50,100,19, &tex->checkerdist, 0.0, 0.99, 0, 0, "Set checkers distance (like mortar)");
- }
- uiBlockBeginAlign(block);
- uiDefButF(block, NUM, B_TEXPRV, "MinX ", 10,28,150,19, &tex->cropxmin, -10.0, 10.0, 10, 0, "Sets minimum X value to crop Image");
- uiDefButF(block, NUM, B_TEXPRV, "MinY ", 10,8,150,19, &tex->cropymin, -10.0, 10.0, 10, 0, "Sets minimum Y value to crop Image");
-
- uiBlockBeginAlign(block);
- uiDefButF(block, NUM, B_TEXPRV, "MaxX ", 160,28,150,19, &tex->cropxmax, -10.0, 10.0, 10, 0, "Sets maximum X value to crop Image");
- uiDefButF(block, NUM, B_TEXPRV, "MaxY ", 160,8,150,19, &tex->cropymax, -10.0, 10.0, 10, 0, "Sets maximum Y value to crop Image");
- uiBlockEndAlign(block);
-
}
static void colorband_pos_cb(void *coba_v, void *unused_v)
@@ -1594,7 +1876,7 @@ void do_worldbuts(unsigned short event)
wrld= G.buts->lockpoin;
if(wrld && wrld->mtex[(int)wrld->texact] ) {
mtex= wrld->mtex[(int)wrld->texact];
- if(mtex->tex==0) {
+ if(mtex->tex==NULL) {
error("No texture available");
}
else {
@@ -1606,7 +1888,7 @@ void do_worldbuts(unsigned short event)
case B_WMTEXPASTE:
wrld= G.buts->lockpoin;
if(wrld && mtexcopied && mtexcopybuf.tex) {
- if(wrld->mtex[(int)wrld->texact]==0 )
+ if(wrld->mtex[(int)wrld->texact]==NULL )
wrld->mtex[(int)wrld->texact]= MEM_mallocN(sizeof(MTex), "mtex");
else if(wrld->mtex[(int)wrld->texact]->tex)
wrld->mtex[(int)wrld->texact]->tex->id.us--;
@@ -1641,7 +1923,7 @@ static void world_panel_mapto(World *wrld)
uiSetButLock(wrld->id.lib!=0, "Can't edit library data");
mtex= wrld->mtex[ wrld->texact ];
- if(mtex==0) {
+ if(mtex==NULL) {
mtex= &emptytex;
default_mtex(mtex);
mtex->texco= TEXCO_VIEW;
@@ -1707,7 +1989,7 @@ static void world_panel_texture(World *wrld)
uiBlockEndAlign(block);
mtex= wrld->mtex[ wrld->texact ];
- if(mtex==0) {
+ if(mtex==NULL) {
mtex= &emptytex;
default_mtex(mtex);
mtex->texco= TEXCO_VIEW;
@@ -1984,7 +2266,7 @@ void do_lampbuts(unsigned short event)
la= G.buts->lockpoin;
if(la && la->mtex[(int)la->texact] ) {
mtex= la->mtex[(int)la->texact];
- if(mtex->tex==0) {
+ if(mtex->tex==NULL) {
error("No texture available");
}
else {
@@ -1996,7 +2278,7 @@ void do_lampbuts(unsigned short event)
case B_LMTEXPASTE:
la= G.buts->lockpoin;
if(la && mtexcopied && mtexcopybuf.tex) {
- if(la->mtex[(int)la->texact]==0 )
+ if(la->mtex[(int)la->texact]==NULL )
la->mtex[(int)la->texact]= MEM_mallocN(sizeof(MTex), "mtex");
else if(la->mtex[(int)la->texact]->tex)
la->mtex[(int)la->texact]->tex->id.us--;
@@ -2026,7 +2308,7 @@ static void lamp_panel_mapto(Object *ob, Lamp *la)
uiSetButLock(la->id.lib!=0, "Can't edit library data");
mtex= la->mtex[ la->texact ];
- if(mtex==0) {
+ if(mtex==NULL) {
mtex= &emptytex;
default_mtex(mtex);
mtex->texco= TEXCO_VIEW;
@@ -2085,7 +2367,7 @@ static void lamp_panel_texture(Object *ob, Lamp *la)
uiBlockEndAlign(block);
mtex= la->mtex[ la->texact ];
- if(mtex==0) {
+ if(mtex==NULL) {
mtex= &emptytex;
default_mtex(mtex);
mtex->texco= TEXCO_VIEW;
@@ -2233,7 +2515,7 @@ static void lamp_panel_spot(Object *ob, Lamp *la)
if(la->area_shape==LA_AREA_CUBE)
uiDefButS(block, NUM,0,"Samples:", 100,160,200,19, &la->ray_samp, 1.0, 16.0, 100, 0, "Sets the amount of samples taken extra (samp x samp x samp)");
- if ELEM(la->area_shape, LA_AREA_RECT, LA_AREA_BOX) {
+ if (ELEM(la->area_shape, LA_AREA_RECT, LA_AREA_BOX)) {
uiDefButS(block, NUM,0,"SamplesX:", 100,180,200,19, &la->ray_samp, 1.0, 16.0, 100, 0, "Sets the amount of X samples taken extra");
uiDefButS(block, NUM,0,"SamplesY:", 100,160,200,19, &la->ray_sampy, 1.0, 16.0, 100, 0, "Sets the amount of Y samples taken extra");
if(la->area_shape==LA_AREA_BOX)
@@ -2361,16 +2643,16 @@ static void lamp_panel_lamp(Object *ob, Lamp *la)
//uiDefButS(block, MENU, B_LAMPREDRAW, "Shape %t|Square %x0|Rect %x1|Cube %x2|Box %x3",
uiDefButS(block, MENU, B_LAMPREDRAW, "Shape %t|Square %x0|Rect %x1",
10, 150, 100, 19, &la->area_shape, 0,0,0,0, "Sets area light shape");
- if ELEM(la->area_shape, LA_AREA_RECT, LA_AREA_BOX){
+ if (ELEM(la->area_shape, LA_AREA_RECT, LA_AREA_BOX)){
uiDefButF(block, NUM,B_LAMPREDRAW,"SizeX ", 10,130,100,19, &la->area_size, 0.01, 100.0, 10, 0, "Area light size X, doesn't affect energy amount");
uiDefButF(block, NUM,B_LAMPREDRAW,"SizeY ", 10,110,100,19, &la->area_sizey, 0.01, 100.0, 10, 0, "Area light size Y, doesn't affect energy amount");
}
if(la->area_shape==LA_AREA_BOX)
uiDefButF(block, NUM,B_LAMPREDRAW,"SizeZ ", 10,90,100,19, &la->area_sizez, 0.01, 100.0, 10, 0, "Area light size Z, doesn't affect energy amount");
- if ELEM(la->area_shape, LA_AREA_SQUARE, LA_AREA_CUBE)
+ if (ELEM(la->area_shape, LA_AREA_SQUARE, LA_AREA_CUBE))
uiDefButF(block, NUM,B_LAMPREDRAW,"Size ", 10,130,100,19, &la->area_size, 0.01, 100.0, 10, 0, "Area light size, doesn't affect energy amount");
}
- else if ELEM(la->type, LA_LOCAL, LA_SPOT) {
+ else if( ELEM(la->type, LA_LOCAL, LA_SPOT)) {
uiBlockSetCol(block, TH_BUT_SETTING1);
uiDefButBitS(block, TOG, LA_QUAD, B_LAMPPRV,"Quad", 10,150,100,19,&la->mode, 0, 0, 0, 0, "Uses inverse quadratic proportion for light attenuation");
uiDefButBitS(block, TOG, LA_SPHERE, REDRAWVIEW3D,"Sphere", 10,130,100,19,&la->mode, 0, 0, 0, 0, "Sets light intensity to zero for objects beyond the distance value");
@@ -2396,7 +2678,7 @@ static void lamp_panel_lamp(Object *ob, Lamp *la)
uiDefButF(block, COL, B_LAMPPRV, "", 120,52,180,24, &la->r, 0, 0, 0, B_COLLAMP, "");
uiBlockBeginAlign(block);
- if ELEM(la->type, LA_LOCAL, LA_SPOT) {
+ if (ELEM(la->type, LA_LOCAL, LA_SPOT)) {
uiDefButF(block, NUMSLI,B_LAMPPRV,"Quad1 ", 120,30,180,19,&la->att1, 0.0, 1.0, 0, 0, "Set the linear distance attenuatation for a quad lamp");
uiDefButF(block, NUMSLI,B_LAMPPRV,"Quad2 ", 120,10,180,19,&la->att2, 0.0, 1.0, 0, 0, "Set the quadratic distance attenuatation for a quad lamp");
}
@@ -2561,7 +2843,7 @@ void do_matbuts(unsigned short event)
case B_MTEXCOPY:
if(ma && ma->mtex[(int)ma->texact] ) {
mtex= ma->mtex[(int)ma->texact];
- if(mtex->tex==0) {
+ if(mtex->tex==NULL) {
error("No texture available");
}
else {
@@ -2572,7 +2854,7 @@ void do_matbuts(unsigned short event)
break;
case B_MTEXPASTE:
if(ma && mtexcopied && mtexcopybuf.tex) {
- if(ma->mtex[(int)ma->texact]==0 )
+ if(ma->mtex[(int)ma->texact]==NULL )
ma->mtex[(int)ma->texact]= MEM_mallocN(sizeof(MTex), "mtex");
else if(ma->mtex[(int)ma->texact]->tex)
ma->mtex[(int)ma->texact]->tex->id.us--;
@@ -2657,7 +2939,7 @@ static void material_panel_map_to(Material *ma)
if(uiNewPanel(curarea, block, "Map To", "Material", 1600, 0, 318, 204)==0) return;
mtex= ma->mtex[ ma->texact ];
- if(mtex==0) {
+ if(mtex==NULL) {
mtex= &emptytex;
default_mtex(mtex);
}
@@ -2734,7 +3016,7 @@ static void material_panel_map_input(Object *ob, Material *ma)
if(uiNewPanel(curarea, block, "Map Input", "Material", 1280, 0, 318, 204)==0) return;
mtex= ma->mtex[ ma->texact ];
- if(mtex==0) {
+ if(mtex==NULL) {
mtex= &emptytex;
default_mtex(mtex);
}
@@ -2835,14 +3117,14 @@ static void material_panel_texture(Material *ma)
uiBlockSetCol(block, TH_AUTO);
mtex= ma->mtex[ ma->texact ];
- if(mtex==0) {
+ if(mtex==NULL) {
mtex= &emptytex;
default_mtex(mtex);
}
/* TEXTUREBLOK SELECT */
uiBlockSetCol(block, TH_BUT_SETTING2);
- if(G.main->tex.first==0)
+ if(G.main->tex.first==NULL)
id= NULL;
else
id= (ID*) mtex->tex;
@@ -3388,7 +3670,7 @@ void material_panels()
MTex *mtex;
Object *ob= OBACT;
- if(ob==0) return;
+ if(ob==NULL) return;
// type numbers are ordered
if((ob->type<OB_LAMP) && ob->type) {
@@ -3537,8 +3819,8 @@ void texture_panels()
switch(tex->type) {
case TEX_IMAGE:
- texture_panel_image(tex);
- texture_panel_image1(tex);
+ texture_panel_image(&tex->ima, &tex->iuser);
+ texture_panel_image_map(tex);
break;
case TEX_ENVMAP:
texture_panel_envmap(tex);
@@ -3589,7 +3871,7 @@ void radio_panels()
int flag;
rad= G.scene->radio;
- if(rad==0) {
+ if(rad==NULL) {
add_radio();
rad= G.scene->radio;
}
diff --git a/source/blender/src/drawimage.c b/source/blender/src/drawimage.c
index 7e77432158e..48a99168923 100644
--- a/source/blender/src/drawimage.c
+++ b/source/blender/src/drawimage.c
@@ -1,15 +1,12 @@
/**
* $Id$
*
- * ***** BEGIN GPL/BL DUAL LICENSE BLOCK *****
+ * ***** 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. The Blender
- * Foundation also sells licenses for use in proprietary software under
- * the Blender License. See http://www.blender.org/BL/ for information
- * about this.
+ * 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
@@ -25,9 +22,9 @@
*
* The Original Code is: all of this file.
*
- * Contributor(s): none yet.
+ * Contributor(s): Blender Foundation, 2002-2006
*
- * ***** END GPL/BL DUAL LICENSE BLOCK *****
+ * ***** END GPL LICENSE BLOCK *****
*/
#include <math.h>
@@ -56,6 +53,7 @@
#include "DNA_image_types.h"
#include "DNA_mesh_types.h"
#include "DNA_meshdata_types.h"
+#include "DNA_node_types.h"
#include "DNA_object_types.h"
#include "DNA_packedFile_types.h"
#include "DNA_scene_types.h"
@@ -99,8 +97,10 @@
#include "BIF_transform.h"
#include "BSE_drawipo.h"
+#include "BSE_drawview.h"
#include "BSE_filesel.h"
#include "BSE_headerbuttons.h"
+#include "BSE_node.h"
#include "BSE_trans_types.h"
#include "BSE_view.h"
@@ -118,26 +118,24 @@
static unsigned char *alloc_alpha_clone_image(int *width, int *height)
{
Brush *brush = G.scene->toolsettings->imapaint.brush;
- Image *image;
+ ImBuf *ibuf;
unsigned int size, alpha;
unsigned char *rect, *cp;
if(!brush || !brush->clone.image)
return NULL;
- image= brush->clone.image;
- if(!image->ibuf)
- load_image(image, IB_rect, G.sce, G.scene->r.cfra);
+ ibuf= BKE_image_get_ibuf(brush->clone.image, NULL);
- if(!image->ibuf || !image->ibuf->rect)
+ if(!ibuf || !ibuf->rect)
return NULL;
- rect= MEM_dupallocN(image->ibuf->rect);
+ rect= MEM_dupallocN(ibuf->rect);
if(!rect)
return NULL;
- *width= image->ibuf->x;
- *height= image->ibuf->y;
+ *width= ibuf->x;
+ *height= ibuf->y;
size= (*width)*(*height);
alpha= (unsigned char)255*brush->clone.alpha;
@@ -190,11 +188,13 @@ void calc_image_view(SpaceImage *sima, char mode)
if(image_preview_active(curarea, &xim, &yim));
else if(sima->image) {
- if(sima->image->ibuf) {
- xim= sima->image->ibuf->x;
- yim= sima->image->ibuf->y;
+ ImBuf *ibuf= BKE_image_get_ibuf(sima->image, &sima->iuser);
+
+ if(ibuf) {
+ xim= ibuf->x;
+ yim= ibuf->y;
}
- else if( BLI_streq(sima->image->id.name+2, "Render Result") ) {
+ else if( sima->image->type==IMA_TYPE_R_RESULT ) {
/* not very important, just nice */
xim= (G.scene->r.xsch*G.scene->r.size)/100;
yim= (G.scene->r.ysch*G.scene->r.size)/100;
@@ -246,24 +246,8 @@ void what_image(SpaceImage *sima)
if(sima->mode==SI_TEXTURE) {
- if(sima->image && BLI_streq(sima->image->id.name+2, "Render Result")) {
- if(sima->image->ibuf==NULL) {
- RenderResult rres;
-
- /* make ibuf if needed, and initialize it */
- RE_GetResultImage(RE_GetRender(G.scene->id.name), &rres);
- if(rres.rectf || rres.rect32) {
- ImBuf *ibuf= sima->image->ibuf= IMB_allocImBuf(rres.rectx, rres.recty, 32, 0, 0);
-
- ibuf->x= rres.rectx;
- ibuf->y= rres.recty;
- ibuf->rect= rres.rect32;
- ibuf->rect_float= rres.rectf;
-
- sima->image->ok= 1;
- }
- }
- }
+ /* viewer overrides faceselect */
+ if(sima->image && sima->image->source==IMA_SRC_VIEWER);
else if((G.f & G_FACESELECT)) {
sima->image= NULL;
@@ -301,11 +285,11 @@ void image_changed(SpaceImage *sima, int dotile)
if(G.f & G_FACESELECT) {
- /* exception images, name rules are actually weak... */
+ /* skip assigning these procedural images... */
if(sima->image) {
- if(BLI_streq(sima->image->id.name+2, "Render Result"))
+ if(sima->image->type==IMA_TYPE_R_RESULT)
return;
- if(BLI_streq(sima->image->id.name+2, "Composite"))
+ if(sima->image->type==IMA_TYPE_COMPOSITE)
return;
}
@@ -740,26 +724,25 @@ static void draw_image_view_tool(void)
/* ************ panel stuff ************* */
-// button define is local, only events defined here possible
-#define B_TRANS_IMAGE 1
-
/* is used for both read and write... */
-static void image_editvertex_buts(uiBlock *block)
+void image_editvertex_buts(uiBlock *block)
{
static float ocent[2];
float cent[2]= {0.0, 0.0};
- int imx, imy;
+ int imx= 256, imy= 256;
int i, nactive= 0, step, digits;
Mesh *me;
if( is_uv_tface_editing_allowed_silent()==0 ) return;
me= get_mesh(OBACT);
- if (G.sima->image && G.sima->image->ibuf) {
- imx= G.sima->image->ibuf->x;
- imy= G.sima->image->ibuf->y;
- } else
- imx= imy= 256;
+ if (G.sima->image) {
+ ImBuf *ibuf= BKE_image_get_ibuf(G.sima->image, &G.sima->iuser);
+ if(ibuf) {
+ imx= ibuf->x;
+ imy= ibuf->y;
+ }
+ }
for (i=0; i<me->totface; i++) {
MFace *mf= &((MFace*) me->mface)[i];
@@ -863,174 +846,77 @@ static void image_editvertex_buts(uiBlock *block)
}
}
-
-void do_imagebuts(unsigned short event)
+void image_info(Image *ima, ImBuf *ibuf, char *str)
{
- ToolSettings *settings= G.scene->toolsettings;
-
- switch(event) {
- case B_TRANS_IMAGE:
- image_editvertex_buts(NULL);
- break;
-
- case B_SIMAGEDRAW:
- if(G.f & G_FACESELECT) {
- make_repbind(G.sima->image);
- image_changed(G.sima, 1);
- }
- allqueue(REDRAWVIEW3D, 0);
- allqueue(REDRAWIMAGE, 0);
- break;
-
- case B_SIMAGEDRAW1:
- image_changed(G.sima, 2); /* 2: only tileflag */
- allqueue(REDRAWVIEW3D, 0);
- allqueue(REDRAWIMAGE, 0);
- break;
-
- case B_TWINANIM:
- {
- Image *ima;
- int nr;
-
- ima = G.sima->image;
- if (ima) {
- if(ima->flag & IMA_TWINANIM) {
- nr= ima->xrep*ima->yrep;
- if(ima->twsta>=nr) ima->twsta= 1;
- if(ima->twend>=nr) ima->twend= nr-1;
- if(ima->twsta>ima->twend) ima->twsta= 1;
- allqueue(REDRAWIMAGE, 0);
- }
- }
- }
- break;
-
- case B_SIMACLONEBROWSE:
- if (settings->imapaint.brush)
- if (brush_clone_image_set_nr(settings->imapaint.brush, G.sima->menunr))
- allqueue(REDRAWIMAGE, 0);
- break;
-
- case B_SIMACLONEDELETE:
- if (settings->imapaint.brush)
- if (brush_clone_image_delete(settings->imapaint.brush))
- allqueue(REDRAWIMAGE, 0);
- break;
+ 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 ");
- case B_SIMABRUSHCHANGE:
- allqueue(REDRAWIMAGE, 0);
- allqueue(REDRAWBUTSEDIT, 0);
- break;
-
- case B_SIMACURVES:
- curvemapping_do_image(G.sima->cumap, G.sima->image);
- allqueue(REDRAWIMAGE, 0);
- break;
-
- case B_SIMARANGE:
- curvemapping_set_black_white(G.sima->cumap, NULL, NULL);
- curvemapping_do_image(G.sima->cumap, G.sima->image);
- allqueue(REDRAWIMAGE, 0);
- break;
+ ofs+= sprintf(str+ofs, ": size %d x %d,", ibuf->x, ibuf->y);
- case B_SIMABRUSHBROWSE:
- if(G.sima->menunr==-2) {
- activate_databrowse((ID*)settings->imapaint.brush, ID_BR, 0, B_SIMABRUSHBROWSE, &G.sima->menunr, do_global_buttons);
- break;
- }
- else if(G.sima->menunr < 0) break;
-
- if(brush_set_nr(&settings->imapaint.brush, G.sima->menunr)) {
- BIF_undo_push("Browse Brush");
- allqueue(REDRAWBUTSEDIT, 0);
- allqueue(REDRAWIMAGE, 0);
- }
- break;
- case B_SIMABRUSHDELETE:
- if(brush_delete(&settings->imapaint.brush)) {
- BIF_undo_push("Unlink Brush");
- allqueue(REDRAWIMAGE, 0);
- allqueue(REDRAWBUTSEDIT, 0);
- }
- break;
- case B_KEEPDATA:
- brush_toggle_fake_user(settings->imapaint.brush);
- allqueue(REDRAWIMAGE, 0);
- allqueue(REDRAWBUTSEDIT, 0);
- break;
- case B_SIMABRUSHLOCAL:
- if(settings->imapaint.brush && settings->imapaint.brush->id.lib) {
- if(okee("Make local")) {
- make_local_brush(settings->imapaint.brush);
- allqueue(REDRAWIMAGE, 0);
- allqueue(REDRAWBUTSEDIT, 0);
- }
- }
- break;
- case B_SIMABTEXBROWSE:
- if(settings->imapaint.brush) {
- Brush *brush= settings->imapaint.brush;
-
- if(G.sima->menunr==-2) {
- MTex *mtex= brush->mtex[brush->texact];
- ID *id= (ID*)((mtex)? mtex->tex: NULL);
- activate_databrowse(id, ID_TE, 0, B_SIMABTEXBROWSE, &G.sima->menunr, do_global_buttons);
- break;
- }
- else if(G.sima->menunr < 0) break;
-
- if(brush_texture_set_nr(brush, G.sima->menunr)) {
- BIF_undo_push("Browse Brush Texture");
- allqueue(REDRAWBUTSSHADING, 0);
- allqueue(REDRAWBUTSEDIT, 0);
- allqueue(REDRAWIMAGE, 0);
- }
+ if(ibuf->rect_float) {
+ if(ibuf->channels!=4) {
+ sprintf(str+ofs, "%d float channel(s)", ibuf->channels);
}
- break;
- case B_SIMABTEXDELETE:
- if(settings->imapaint.brush) {
- if (brush_texture_delete(settings->imapaint.brush)) {
- BIF_undo_push("Unlink Brush Texture");
- allqueue(REDRAWBUTSSHADING, 0);
- allqueue(REDRAWBUTSEDIT, 0);
- allqueue(REDRAWIMAGE, 0);
- }
- }
- break;
+ 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_properties(short cntrl) // IMAGE_HANDLER_PROPERTIES
{
uiBlock *block;
-
+
block= uiNewBlock(&curarea->uiblocks, "image_panel_properties", UI_EMBOSS, UI_HELV, curarea->win);
uiPanelControl(UI_PNL_SOLID | UI_PNL_CLOSE | cntrl);
uiSetPanelHandler(IMAGE_HANDLER_PROPERTIES); // for close and esc
if(uiNewPanel(curarea, block, "Properties", "Image", 10, 10, 318, 204)==0)
return;
+
+ uiblock_image_panel(block, &G.sima->image, &G.sima->iuser, B_REDR, B_REDR);
- if (G.sima->image && G.sima->image->ibuf) {
- ImBuf *ibuf= G.sima->image->ibuf;
- char str[64];
+}
- sprintf(str, "Image: size %d x %d", ibuf->x, ibuf->y);
- if(ibuf->rect_float) {
- 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);
+ 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, "Game Properties", "Image", 10, 10, 318, 204)==0)
+ return;
+
+ if (ibuf) {
+ char str[128];
+ image_info(G.sima->image, ibuf, str);
uiDefBut(block, LABEL, B_NOP, str, 10,180,300,19, 0, 0, 0, 0, 0, "");
uiBlockBeginAlign(block);
@@ -1050,7 +936,7 @@ static void image_panel_properties(short cntrl) // IMAGE_HANDLER_PROPERTIES
image_editvertex_buts(block);
}
-static void image_panel_paint(short cntrl) // IMAGE_HANDLER_PROPERTIES
+static void image_panel_paint(short cntrl) // IMAGE_HANDLER_PAINT
{
/* B_SIMABRUSHCHANGE only redraws and eats the mouse messages */
/* so that LEFTMOUSE does not 'punch' through the floating panel */
@@ -1135,7 +1021,7 @@ static void image_panel_paint(short cntrl) // IMAGE_HANDLER_PROPERTIES
#endif
}
-static void image_panel_curves_reset(void *cumap_v, void *unused)
+static void image_panel_curves_reset(void *cumap_v, void *ibuf_v)
{
CurveMapping *cumap = cumap_v;
int a;
@@ -1148,14 +1034,15 @@ static void image_panel_curves_reset(void *cumap_v, void *unused)
curvemapping_set_black_white(cumap, NULL, NULL);
curvemapping_changed(cumap, 0);
- curvemapping_do_image(cumap, G.sima->image);
+ curvemapping_do_ibuf(cumap, ibuf_v);
allqueue(REDRAWIMAGE, 0);
}
-static void image_panel_curves(short cntrl) // IMAGE_HANDLER_PROPERTIES
+static void image_panel_curves(short cntrl) // IMAGE_HANDLER_CURVES
{
+ ImBuf *ibuf= BKE_image_get_ibuf(G.sima->image, &G.sima->iuser);
uiBlock *block;
uiBut *bt;
@@ -1165,7 +1052,7 @@ static void image_panel_curves(short cntrl) // IMAGE_HANDLER_PROPERTIES
if(uiNewPanel(curarea, block, "Curves", "Image", 10, 450, 318, 204)==0)
return;
- if (G.sima->image && G.sima->image->ibuf) {
+ if (ibuf) {
rctf rect;
if(G.sima->cumap==NULL)
@@ -1176,7 +1063,7 @@ static void image_panel_curves(short cntrl) // IMAGE_HANDLER_PROPERTIES
curvemap_buttons(block, G.sima->cumap, 'c', B_SIMACURVES, B_SIMAGEDRAW, &rect);
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, NULL);
+ uiButSetFunc(bt, image_panel_curves_reset, G.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");
@@ -1339,6 +1226,9 @@ static void image_blockhandlers(ScrArea *sa)
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_PAINT:
image_panel_paint(sima->blockhandler[a+1]);
break;
@@ -1355,6 +1245,53 @@ static void image_blockhandlers(ScrArea *sa)
uiDrawBlocksPanels(sa, 0);
}
+void imagespace_composite_flipbook(ScrArea *sa)
+{
+ SpaceImage *sima= sa->spacedata.first;
+ ImBuf *ibuf;
+ int cfrao= G.scene->r.cfra;
+ int sfra, efra;
+
+ if(sa->spacetype!=SPACE_IMAGE)
+ return;
+ if(sima->iuser.frames<2)
+ return;
+ if(G.scene->nodetree==NULL)
+ return;
+
+ sfra= sima->iuser.sfra;
+ efra= sima->iuser.sfra + sima->iuser.frames-1;
+ G.scene->nodetree->test_break= blender_test_break;
+
+ for(G.scene->r.cfra=sfra; G.scene->r.cfra<=efra; G.scene->r.cfra++) {
+
+ set_timecursor(CFRA);
+
+ BKE_image_all_free_anim_ibufs(CFRA);
+ ntreeCompositTagAnimated(G.scene->nodetree);
+ ntreeCompositExecTree(G.scene->nodetree, &G.scene->r, G.scene->r.cfra!=cfrao); /* 1 is no previews */
+
+ force_draw(0);
+
+ ibuf= BKE_image_get_ibuf(sima->image, &sima->iuser);
+ /* save memory in flipbooks */
+ if(ibuf)
+ imb_freerectfloatImBuf(ibuf);
+
+ if(blender_test_break())
+ break;
+ }
+ G.scene->nodetree->test_break= NULL;
+ waitcursor(0);
+
+ play_anim(0);
+
+ allqueue(REDRAWNODE, 1);
+ allqueue(REDRAWIMAGE, 1);
+
+ G.scene->r.cfra= cfrao;
+}
+
static void imagespace_grid(SpaceImage *sima)
{
float gridsize, gridstep= 1.0f/32.0f;
@@ -1548,8 +1485,9 @@ static void imagewindow_draw_renderinfo(ScrArea *sa)
SpaceImage *sima= sa->spacedata.first;
rcti rect;
float colf[3];
+ char *str= sima->showspare?sima->info_spare:sima->info_str;
- if(sima->info_str==NULL)
+ if(str==NULL)
return;
rect= sa->winrct;
@@ -1564,7 +1502,11 @@ static void imagewindow_draw_renderinfo(ScrArea *sa)
BIF_ThemeColor(TH_TEXT_HI);
glRasterPos2i(12, 5);
- BMF_DrawString(G.fonts, sima->info_str);
+ if(sima->showspare) {
+ BMF_DrawString(G.fonts, "(Previous)");
+ glRasterPos2i(72, 5);
+ }
+ BMF_DrawString(G.fonts, str);
}
void drawimagespace(ScrArea *sa, void *spacedata)
@@ -1575,7 +1517,7 @@ void drawimagespace(ScrArea *sa, void *spacedata)
float col[3];
unsigned int *rect;
float x1, y1;
- short sx, sy, dx, dy, show_render= 0;
+ short sx, sy, dx, dy, show_render= 0, show_viewer= 0;
/* If derived data is used then make sure that object
* is up-to-date... might not be the case because updates
@@ -1593,24 +1535,33 @@ void drawimagespace(ScrArea *sa, void *spacedata)
bwin_clear_viewmat(sa->win); /* clear buttons view */
glLoadIdentity();
- if(sima->image && BLI_streq(sima->image->id.name+2, "Render Result") )
- show_render= 1;
-
+ if(sima->image && sima->image->source==IMA_SRC_VIEWER) {
+ show_viewer= 1;
+ if(sima->image->type==IMA_TYPE_R_RESULT)
+ show_render= 1;
+ }
what_image(sima);
if(sima->image) {
- if(sima->image->ibuf==NULL && show_render==0) {
- load_image(sima->image, IB_rect, G.sce, G.scene->r.cfra);
- scrarea_queue_headredraw(sa); /* update header for image options */
- }
- tag_image_time(sima->image);
- ibuf= sima->image->ibuf;
+ /* UGLY hack? until now iusers worked fine... but for flipbook viewer we need this */
+ if(sima->image->type==IMA_TYPE_COMPOSITE) {
+ ImageUser *iuser= ntree_get_active_iuser(G.scene->nodetree);
+ if(iuser) {
+ BKE_image_user_calc_imanr(iuser, G.scene->r.cfra, 0);
+ G.sima->iuser= *iuser;
+ }
+ }
+ /* and we check for spare */
+ if(sima->image->type==IMA_TYPE_R_RESULT && sima->showspare)
+ ibuf= sima->spare;
+ else
+ ibuf= BKE_image_get_ibuf(sima->image, &sima->iuser);
}
if(ibuf==NULL || (ibuf->rect==NULL && ibuf->rect_float==NULL)) {
imagespace_grid(sima);
- if(show_render==0)
+ if(show_viewer==0)
draw_tfaces();
}
else {
@@ -1706,14 +1657,16 @@ void drawimagespace(ScrArea *sa, void *spacedata)
if(sima->flag & SI_SHOW_ALPHA) {
if(ibuf->rect)
sima_draw_alpha_pixels(x1, y1, ibuf->x, ibuf->y, ibuf->rect);
- else if(ibuf->rect_float)
+ else if(ibuf->rect_float && ibuf->channels==4)
sima_draw_alpha_pixelsf(x1, y1, ibuf->x, ibuf->y, ibuf->rect_float);
}
else if(sima->flag & SI_SHOW_ZBUF) {
if(ibuf->zbuf)
sima_draw_zbuf_pixels(x1, y1, ibuf->x, ibuf->y, ibuf->zbuf);
- else
+ else if(ibuf->zbuf_float)
sima_draw_zbuffloat_pixels(x1, y1, ibuf->x, ibuf->y, ibuf->zbuf_float);
+ else if(ibuf->channels==1)
+ sima_draw_zbuffloat_pixels(x1, y1, ibuf->x, ibuf->y, ibuf->rect_float);
}
else {
if(sima->flag & SI_USE_ALPHA) {
@@ -1725,11 +1678,14 @@ void drawimagespace(ScrArea *sa, void *spacedata)
/* detect if we need to redo the curve map.
ibuf->rect is zero for compositor and render results after change
convert to 32 bits always... drawing float rects isnt supported well (atis)
+
+ NOTE: if float buffer changes, we have to manually remove the rect
*/
+
if(ibuf->rect_float) {
if(ibuf->rect==NULL) {
if(image_curves_active(sa))
- curvemapping_do_image(G.sima->cumap, G.sima->image);
+ curvemapping_do_ibuf(G.sima->cumap, ibuf);
else
IMB_rect_from_float(ibuf);
}
@@ -1770,7 +1726,7 @@ void drawimagespace(ScrArea *sa, void *spacedata)
glPixelZoom(1.0, 1.0);
- if(show_render==0)
+ if(show_viewer==0)
draw_tfaces();
}
@@ -1828,7 +1784,9 @@ static void image_zoom_set_factor(float zoomfac)
width= 256;
height= 256;
if (sima->image) {
- if (sima->image->ibuf) {
+ ImBuf *ibuf= BKE_image_get_ibuf(sima->image, &sima->iuser);
+
+ if (ibuf) {
float xim, yim;
/* I know a bit weak... but preview uses not actual image size */
if(image_preview_active(curarea, &xim, &yim)) {
@@ -1836,8 +1794,8 @@ static void image_zoom_set_factor(float zoomfac)
height= (int) yim;
}
else {
- width= sima->image->ibuf->x;
- height= sima->image->ibuf->y;
+ width= ibuf->x;
+ height= ibuf->y;
}
}
}
@@ -1938,18 +1896,19 @@ void image_viewzoom(unsigned short event, int invert)
*/
void image_home(void)
{
+ ImBuf *ibuf= BKE_image_get_ibuf(G.sima->image, &G.sima->iuser);
int width, height, imgwidth, imgheight;
float zoomX, zoomY;
if (curarea->spacetype != SPACE_IMAGE) return;
- if ((G.sima->image == NULL) || (G.sima->image->ibuf == NULL)) {
+ if (ibuf == NULL) {
imgwidth = 256;
imgheight = 256;
}
else {
- imgwidth = G.sima->image->ibuf->x;
- imgheight = G.sima->image->ibuf->y;
+ imgwidth = ibuf->x;
+ imgheight = ibuf->y;
}
/* Check if the image will fit in the image with zoom==1 */
@@ -1977,15 +1936,16 @@ void image_home(void)
void image_viewcentre(void)
{
+ ImBuf *ibuf= BKE_image_get_ibuf(G.sima->image, &G.sima->iuser);
float size, min[2], max[2], d[2], xim=256.0f, yim=256.0f;
if( is_uv_tface_editing_allowed()==0 ) return;
if (!minmax_tface_uv(min, max)) return;
- if(G.sima->image && G.sima->image->ibuf) {
- xim= G.sima->image->ibuf->x;
- yim= G.sima->image->ibuf->y;
+ if(ibuf) {
+ xim= ibuf->x;
+ yim= ibuf->y;
}
G.sima->xof= (int) (((min[0] + max[0])*0.5f - 0.5f)*xim);
@@ -2090,14 +2050,6 @@ static void imagewindow_progress_display_cb(RenderResult *rr, volatile rcti *rec
if (image_area) {
- if(rect==NULL) {
- SpaceImage *sima= image_area->spacedata.first;
-
- /* this enforces reading correct buffer in what_image(), renderlayers/scenes/compo/sequences... */
- IMB_freeImBuf(sima->image->ibuf);
- sima->image->ibuf= NULL;
- }
-
imagewindow_progress(image_area, rr, rect);
/* no screen_swapbuffers, prevent any other window to draw */
@@ -2153,7 +2105,7 @@ static ScrArea *biggest_area(void)
make a new temp fullscreen area with Image Window
*/
-static ScrArea *imagewindow_set_render_display(void)
+static ScrArea *find_area_showing_r_result(void)
{
ScrArea *sa;
SpaceImage *sima;
@@ -2162,11 +2114,20 @@ static ScrArea *imagewindow_set_render_display(void)
for(sa=G.curscreen->areabase.first; sa; sa= sa->next) {
if(sa->spacetype==SPACE_IMAGE) {
sima= sa->spacedata.first;
-
- if(sima->image && BLI_streq(sima->image->id.name+2, "Render Result") )
+ if(sima->image && sima->image->type==IMA_TYPE_R_RESULT)
break;
}
}
+ return sa;
+}
+
+static ScrArea *imagewindow_set_render_display(void)
+{
+ ScrArea *sa;
+ SpaceImage *sima;
+
+ sa= find_area_showing_r_result();
+
if(sa==NULL) {
/* find largest open non-image area */
sa= biggest_non_image_area();
@@ -2193,21 +2154,7 @@ static ScrArea *imagewindow_set_render_display(void)
sima= sa->spacedata.first;
/* get the correct image, and scale it */
- sima->image = (Image *)find_id("IM", "Render Result");
-
- if(sima->image==NULL) {
- Image *ima= alloc_libblock(&G.main->image, ID_IM, "Render Result");
- strcpy(ima->name, "Render Result");
- ima->ok= 1;
- ima->xrep= ima->yrep= 1;
- sima->image= ima;
- }
- else if(sima->image->id.us==0) /* well... happens on reload, dunno yet what todo, imagewindow cannot be user when hidden*/
- id_us_plus(&sima->image->id);
-
- /* this enforces reading empty buffer in what_image(), so display is cleared */
- IMB_freeImBuf(sima->image->ibuf);
- sima->image->ibuf= NULL;
+ sima->image= BKE_image_verify_viewer(IMA_TYPE_R_RESULT, "Render Result");
if(G.displaymode==R_DISPLAYSCREEN) {
if(sa->full==0) {
@@ -2260,7 +2207,7 @@ void imagewindow_toggle_render(void)
if(sa->spacetype==SPACE_IMAGE) {
SpaceImage *sima= sa->spacedata.first;
- if(sima->image && BLI_streq(sima->image->id.name+2, "Render Result") )
+ if(sima->image && sima->image->type==IMA_TYPE_R_RESULT)
if(sima->flag & (SI_PREVSPACE|SI_FULLWINDOW))
break;
}
@@ -2292,7 +2239,6 @@ static void imagewindow_renderinfo_cb(RenderStats *rs)
}
}
-
void imagewindow_render_callbacks(Render *re)
{
RE_display_init_cb(re, imagewindow_init_display_cb);
@@ -2301,3 +2247,53 @@ void imagewindow_render_callbacks(Render *re)
RE_stats_draw_cb(re, imagewindow_renderinfo_cb);
}
+void imagewin_store_spare(void)
+{
+ ScrArea *sa= find_area_showing_r_result();
+
+ if(sa) {
+ ImBuf *ibuf;
+ SpaceImage *sima= sa->spacedata.first;
+
+ if(sima->spare==NULL)
+ return;
+
+ /* only store when it does not show spare */
+ if(sima->showspare==0)
+ return;
+ sima->showspare= 0;
+
+ /* free spare */
+ IMB_freeImBuf(sima->spare);
+
+ /* make a copy of render result */
+ ibuf= BKE_image_get_ibuf(sima->image, &sima->iuser);
+ sima->spare= IMB_dupImBuf(ibuf);
+
+ BLI_strncpy(sima->info_spare, sima->info_str, RW_MAXTEXT);
+
+ }
+}
+
+/* context: in current image window? */
+void imagewindow_swap_render_rects(void)
+{
+ ScrArea *sa= find_area_showing_r_result();
+
+ if(sa) {
+ SpaceImage *sima= sa->spacedata.first;
+ ImBuf *ibuf= BKE_image_get_ibuf(sima->image, &sima->iuser);
+ if(ibuf) {
+
+ sima->showspare ^= 1;
+
+ if(sima->spare==NULL)
+ sima->spare= IMB_allocImBuf(ibuf->x, ibuf->y, 32, 0, 0);
+ if(sima->info_spare==NULL)
+ sima->info_spare= MEM_callocN(RW_MAXTEXT, "info str imagewin");
+
+ allqueue(REDRAWIMAGE, 0);
+ }
+ }
+}
+
diff --git a/source/blender/src/drawmesh.c b/source/blender/src/drawmesh.c
index c6b0a874ff4..94255384108 100644
--- a/source/blender/src/drawmesh.c
+++ b/source/blender/src/drawmesh.c
@@ -183,6 +183,7 @@ int set_tpage(MTFace *tface)
static int alphamode= -1;
static MTFace *lasttface= 0;
Image *ima;
+ ImBuf *ibuf;
unsigned int *rect=NULL, *bind;
int tpx=0, tpy=0, tilemode, tileXRep,tileYRep;
@@ -256,8 +257,7 @@ int set_tpage(MTFace *tface)
tilemode= tface->mode & TF_TILES;
tileXRep = 0;
tileYRep = 0;
- if (ima)
- {
+ if (ima) {
tileXRep = ima->xrep;
tileYRep = ima->yrep;
}
@@ -265,18 +265,17 @@ int set_tpage(MTFace *tface)
if(ima==fCurpage && fCurtile==tface->tile && tilemode==fCurmode && fCurtileXRep==tileXRep && fCurtileYRep == tileYRep) return ima!=0;
- if(tilemode!=fCurmode || fCurtileXRep!=tileXRep || fCurtileYRep != tileYRep)
- {
+ if(tilemode!=fCurmode || fCurtileXRep!=tileXRep || fCurtileYRep != tileYRep) {
glMatrixMode(GL_TEXTURE);
glLoadIdentity();
- if(tilemode && ima!=0)
+ if(tilemode && ima!=NULL)
glScalef(ima->xrep, ima->yrep, 1.0);
glMatrixMode(GL_MODELVIEW);
}
- if(ima==0 || ima->ok==0) {
+ if(ima==NULL || ima->ok==0) {
glDisable(GL_TEXTURE_2D);
fCurtile= tface->tile;
@@ -288,25 +287,21 @@ int set_tpage(MTFace *tface)
return 0;
}
- if(ima->ibuf==0) {
- load_image(ima, IB_rect, G.sce, G.scene->r.cfra);
+ ibuf= BKE_image_get_ibuf(ima, NULL);
+ if(ibuf==NULL) {
- if(ima->ibuf==0) {
- ima->ok= 0;
-
- fCurtile= tface->tile;
- fCurpage= 0;
- fCurmode= tilemode;
- fCurtileXRep = tileXRep;
- fCurtileYRep = tileYRep;
-
- glDisable(GL_TEXTURE_2D);
- return 0;
- }
+ fCurtile= tface->tile;
+ fCurpage= 0;
+ fCurmode= tilemode;
+ fCurtileXRep = tileXRep;
+ fCurtileYRep = tileYRep;
+
+ glDisable(GL_TEXTURE_2D);
+ return 0;
}
- if ((ima->ibuf->rect==NULL) && ima->ibuf->rect_float)
- IMB_rect_from_float(ima->ibuf);
+ if ((ibuf->rect==NULL) && ibuf->rect_float)
+ IMB_rect_from_float(ibuf);
if(ima->tpageflag & IMA_TWINANIM) fCurtile= ima->lastframe;
else fCurtile= tface->tile;
@@ -323,8 +318,8 @@ int set_tpage(MTFace *tface)
if(*bind==0) {
- fTexwindx= ima->ibuf->x/ima->xrep;
- fTexwindy= ima->ibuf->y/ima->yrep;
+ fTexwindx= ibuf->x/ima->xrep;
+ fTexwindy= ibuf->y/ima->yrep;
if(fCurtile>=ima->xrep*ima->yrep) fCurtile= ima->xrep*ima->yrep-1;
@@ -337,16 +332,16 @@ int set_tpage(MTFace *tface)
tpx= fTexwindx;
tpy= fTexwindy;
- rect= ima->ibuf->rect + fTexwinsy*ima->ibuf->x + fTexwinsx;
+ rect= ibuf->rect + fTexwinsy*ibuf->x + fTexwinsx;
}
}
else {
bind= &ima->bindcode;
if(*bind==0) {
- tpx= ima->ibuf->x;
- tpy= ima->ibuf->y;
- rect= ima->ibuf->rect;
+ tpx= ibuf->x;
+ tpy= ibuf->y;
+ rect= ibuf->rect;
}
}
@@ -367,7 +362,7 @@ int set_tpage(MTFace *tface)
tilerect= MEM_mallocN(rectw*recth*sizeof(*tilerect), "tilerect");
for (y=0; y<recth; y++) {
- unsigned int *rectrow= &rect[y*ima->ibuf->x];
+ unsigned int *rectrow= &rect[y*ibuf->x];
unsigned int *tilerectrow= &tilerect[y*rectw];
memcpy(tilerectrow, rectrow, tpx*sizeof(*rectrow));
@@ -422,8 +417,6 @@ int set_tpage(MTFace *tface)
}
else glBindTexture( GL_TEXTURE_2D, *bind);
- tag_image_time(ima);
-
glEnable(GL_TEXTURE_2D);
fCurpage= ima;
@@ -436,8 +429,10 @@ int set_tpage(MTFace *tface)
void update_realtime_image(Image *ima, int x, int y, int w, int h)
{
- if (ima->repbind || get_mipmap() || !ima->bindcode || !ima->ibuf ||
- (!is_pow2(ima->ibuf->x) || !is_pow2(ima->ibuf->y)) ||
+ ImBuf *ibuf= BKE_image_get_ibuf(ima, NULL);
+
+ if (ima->repbind || get_mipmap() || !ima->bindcode || !ibuf ||
+ (!is_pow2(ibuf->x) || !is_pow2(ibuf->y)) ||
(w == 0) || (h == 0)) {
/* these special cases require full reload still */
free_realtime_image(ima);
@@ -447,17 +442,17 @@ void update_realtime_image(Image *ima, int x, int y, int w, int h)
int skip_pixels = glaGetOneInteger(GL_UNPACK_SKIP_PIXELS);
int skip_rows = glaGetOneInteger(GL_UNPACK_SKIP_ROWS);
- if ((ima->ibuf->rect==NULL) && ima->ibuf->rect_float)
- IMB_rect_from_float(ima->ibuf);
+ if ((ibuf->rect==NULL) && ibuf->rect_float)
+ IMB_rect_from_float(ibuf);
glBindTexture(GL_TEXTURE_2D, ima->bindcode);
- glPixelStorei(GL_UNPACK_ROW_LENGTH, ima->ibuf->x);
+ glPixelStorei(GL_UNPACK_ROW_LENGTH, ibuf->x);
glPixelStorei(GL_UNPACK_SKIP_PIXELS, x);
glPixelStorei(GL_UNPACK_SKIP_ROWS, y);
glTexSubImage2D(GL_TEXTURE_2D, 0, x, y, w, h, GL_RGBA,
- GL_UNSIGNED_BYTE, ima->ibuf->rect);
+ GL_UNSIGNED_BYTE, ibuf->rect);
glPixelStorei(GL_UNPACK_ROW_LENGTH, row_length);
glPixelStorei(GL_UNPACK_SKIP_PIXELS, skip_pixels);
@@ -536,7 +531,9 @@ void texpaint_enable_mipmap(void)
void make_repbind(Image *ima)
{
- if(ima==0 || ima->ibuf==0) return;
+ ImBuf *ibuf= BKE_image_get_ibuf(ima, NULL);
+
+ if(ibuf==NULL) return;
if(ima->repbind) {
glDeleteTextures(ima->totbind, (GLuint *)ima->repbind);
@@ -1050,7 +1047,7 @@ void draw_tface_mesh(Object *ob, Mesh *me, int dt)
float v1[3], v2[3], v3[3], v4[3];
char string[MAX_PROPSTRING];
int characters, index;
- Image *ima;
+ ImBuf *ibuf;
float curpos;
if (badtex)
@@ -1068,8 +1065,8 @@ void draw_tface_mesh(Object *ob, Mesh *me, int dt)
set_property_valstr(prop, string);
characters = strlen(string);
- ima = tface->tpage;
- if (ima == NULL) {
+ ibuf= BKE_image_get_ibuf(tface->tpage, NULL);
+ if (ibuf == NULL) {
characters = 0;
}
@@ -1092,7 +1089,7 @@ void draw_tface_mesh(Object *ob, Mesh *me, int dt)
// space starts at offset 1
// character = character - ' ' + 1;
- matrixGlyph(ima->ibuf, character, & centerx, &centery, &sizex, &sizey, &transx, &transy, &movex, &movey, &advance);
+ matrixGlyph(ibuf, character, & centerx, &centery, &sizex, &sizey, &transx, &transy, &movex, &movey, &advance);
movex+= curpos;
if (tface->mode & TF_OBCOL) glColor3ubv(obcol);
diff --git a/source/blender/src/drawnode.c b/source/blender/src/drawnode.c
index d23f86ce4df..831387de931 100644
--- a/source/blender/src/drawnode.c
+++ b/source/blender/src/drawnode.c
@@ -647,7 +647,7 @@ static void node_shader_set_butfunc(bNodeType *ntype)
}
}
-/* ****************** BUTTON CALLBACKS FOR COMPOSIT NODES ***************** */
+/* ****************** BUTTON CALLBACKS FOR COMPOSITE NODES ***************** */
@@ -670,6 +670,7 @@ static void node_browse_image_cb(void *ntree_v, void *node_v)
BLI_strncpy(node->name, node->id->name+2, 21);
NodeTagChanged(ntree, node);
+ BKE_image_signal((Image *)node->id, node->storage, IMA_SIGNAL_USER_NEW_IMAGE);
addqueue(curarea->win, UI_BUT_EVENT, B_NODE_EXEC+node->nr);
}
node->menunr= 0;
@@ -679,24 +680,57 @@ static void node_active_cb(void *ntree_v, void *node_v)
{
nodeSetActive(ntree_v, node_v);
}
-static void node_image_anim_cb(void *node_v, void *unused)
+static void node_image_type_cb(void *node_v, void *unused)
{
- bNode *node= node_v;
- NodeImageAnim *nia;
- if(node->storage) {
- MEM_freeN(node->storage);
- node->storage= NULL;
- }
- else {
- nia= node->storage= MEM_callocN(sizeof(NodeImageAnim), "node image anim");
- nia->sfra= nia->nr= 1;
- }
allqueue(REDRAWNODE, 1);
}
+static char *node_image_type_pup(void)
+{
+ char *str= MEM_mallocN(256, "image type pup");
+ int a;
+
+ str[0]= 0;
+
+ a= sprintf(str, "Image Type %%t|");
+ a+= sprintf(str+a, " Image %%x%d %%i%d|", IMA_SRC_FILE, ICON_IMAGE_DEHLT);
+ a+= sprintf(str+a, " Movie %%x%d %%i%d|", IMA_SRC_MOVIE, ICON_SEQUENCE);
+ a+= sprintf(str+a, " Sequence %%x%d %%i%d|", IMA_SRC_SEQUENCE, ICON_IMAGE_COL);
+ a+= sprintf(str+a, " Generated %%x%d %%i%d", IMA_SRC_GENERATED, ICON_BLANK1);
+
+ return str;
+}
+
+/* copy from buttons_shading.c */
+static char *layer_menu(RenderResult *rr)
+{
+ RenderLayer *rl;
+ int len= 40 + 40*BLI_countlist(&rr->layers);
+ short a, nr;
+ char *str= MEM_callocN(len, "menu layers");
+
+ strcpy(str, "Layer %t");
+ a= strlen(str);
+ for(nr=0, rl= rr->layers.first; rl; rl= rl->next, nr++) {
+ a+= sprintf(str+a, "|%s %%x%d", rl->name, nr);
+ }
+
+ return str;
+}
+
+static void image_layer_cb(void *ima_v, void *iuser_v)
+{
+
+ ntreeCompositForceHidden(G.scene->nodetree);
+ BKE_image_multilayer_index(ima_v, iuser_v);
+ allqueue(REDRAWNODE, 0);
+}
+
static int node_composit_buts_image(uiBlock *block, bNodeTree *ntree, bNode *node, rctf *butr)
{
+ ImageUser *iuser= node->storage;
+
if(block) {
uiBut *bt;
short dy= (short)butr->ymax-19;
@@ -706,7 +740,7 @@ static int node_composit_buts_image(uiBlock *block, bNodeTree *ntree, bNode *nod
uiBlockSetCol(block, TH_BUT_SETTING2);
/* browse button */
- IDnames_to_pupstring(&strp, NULL, "LOAD NEW %x32767", &(G.main->image), NULL, NULL);
+ IMAnames_to_pupstring(&strp, NULL, "LOAD NEW %x32767", &(G.main->image), NULL, NULL);
node->menunr= 0;
bt= uiDefButS(block, MENU, B_NOP, strp,
butr->xmin, dy, 19, 19,
@@ -723,44 +757,82 @@ static int node_composit_buts_image(uiBlock *block, bNodeTree *ntree, bNode *nod
uiBlockSetCol(block, TH_AUTO);
}
else {
- /* name button */
- short width= (short)(butr->xmax-butr->xmin-38.0f);
- bt= uiDefBut(block, TEX, B_NOP, "IMA:",
- butr->xmin+19, dy, width, 19,
+ /* name button + type */
+ Image *ima= (Image *)node->id;
+ short xmin= (short)butr->xmin, xmax= (short)butr->xmax;
+ short width= xmax - xmin - 45;
+ short icon= ICON_IMAGE_DEHLT;
+
+ if(ima->source==IMA_SRC_MOVIE) icon= ICON_SEQUENCE;
+ else if(ima->source==IMA_SRC_SEQUENCE) icon= ICON_IMAGE_COL;
+ else if(ima->source==IMA_SRC_GENERATED) icon= ICON_BLANK1;
+
+ bt= uiDefBut(block, TEX, B_NOP, "IM:",
+ xmin+19, dy, width, 19,
node->id->name+2, 0.0, 19.0, 0, 0, "Image name");
uiButSetFunc(bt, node_ID_title_cb, node, NULL);
- bt= uiDefIconBut(block, BUT, B_NOP, ICON_SEQUENCE,
- butr->xmax-19, dy, 19, 19,
- node->id->name+2, 0.0, 19.0, 0, 0, "Enable/Disable Image animation");
- uiButSetFunc(bt, node_image_anim_cb, node, NULL);
- }
- if(node->storage) {
- NodeImageAnim *nia= node->storage;
- short width= (short)(butr->xmax-butr->xmin)/2;
- dy-= 19;
- uiDefButI(block, NUM, B_NODE_EXEC+node->nr, "Frs:",
- butr->xmin, dy, width, 19,
- &nia->frames, 0.0, 10000.0, 0, 0, "Amount of images used in animation");
- uiDefButI(block, NUM, B_NODE_EXEC+node->nr, "SFra:",
- butr->xmin+width, dy, width, 19,
- &nia->sfra, 1.0, 10000.0, 0, 0, "Start frame of animation");
- dy-= 19;
- uiDefButI(block, NUM, B_NODE_EXEC+node->nr, "First:",
- butr->xmin, dy, width, 19,
- &nia->nr, 0.0, 10000.0, 0, 0, "Number in image name, used as first in animation");
- uiDefButC(block, TOG, B_NODE_EXEC+node->nr, "Cycl",
- butr->xmin+width, dy, width-19, 19,
- &nia->cyclic, 0.0, 0.0, 0, 0, "Make animation go cyclic");
- bt= uiDefIconButC(block, TOG, B_NODE_EXEC+node->nr, ICON_SEQUENCE,
- butr->xmax-19, dy, 19, 19,
- &nia->movie, 0.0, 19.0, 0, 0, "Enable/Disable reading Image from Movie file");
+ /* buffer type option */
+ strp= node_image_type_pup();
+ bt= uiDefIconTextButS(block, MENU, B_NOP, icon, strp,
+ xmax-26, dy, 26, 19,
+ &ima->source, 0.0, 19.0, 0, 0, "Image type");
+ uiButSetFunc(bt, node_image_type_cb, node, ima);
+ MEM_freeN(strp);
+ if( ELEM(ima->source, IMA_SRC_MOVIE, IMA_SRC_SEQUENCE) ) {
+ width= (xmax-xmin)/2;
+
+ dy-= 19;
+ uiDefButI(block, NUM, B_NODE_EXEC+node->nr, "Frs:",
+ xmin, dy, width, 19,
+ &iuser->frames, 0.0, 10000.0, 0, 0, "Amount of images used in animation");
+ uiDefButI(block, NUM, B_NODE_EXEC+node->nr, "SFra:",
+ xmin+width, dy, width, 19,
+ &iuser->sfra, 1.0, 10000.0, 0, 0, "Start frame of animation");
+ dy-= 19;
+ uiDefButI(block, NUM, B_NODE_EXEC+node->nr, "Offs:",
+ xmin, dy, width, 19,
+ &iuser->offset, 0.0, 10000.0, 0, 0, "Offsets the number of the frame to use in the animation");
+ uiDefButS(block, TOG, B_NODE_EXEC+node->nr, "Cycl",
+ xmin+width, dy, width-20, 19,
+ &iuser->cycl, 0.0, 0.0, 0, 0, "Make animation go cyclic");
+ uiDefIconButBitS(block, TOG, IMA_ANIM_ALWAYS, B_NODE_EXEC+node->nr, ICON_AUTO,
+ xmax-20, dy, 20, 19,
+ &iuser->flag, 0.0, 0.0, 0, 0, "Always refresh Image on frame changes");
+ }
+ if( ima->type==IMA_TYPE_MULTILAYER && ima->rr) {
+ RenderLayer *rl= BLI_findlink(&ima->rr->layers, iuser->layer);
+ if(rl) {
+ width= (xmax-xmin);
+ dy-= 19;
+ strp= layer_menu(ima->rr);
+ bt= uiDefButS(block, MENU, B_NODE_EXEC+node->nr, strp,
+ xmin, dy, width, 19,
+ &iuser->layer, 0.0, 10000.0, 0, 0, "Layer");
+ uiButSetFunc(bt, image_layer_cb, ima, node->storage);
+ MEM_freeN(strp);
+ }
+ }
}
}
- if(node->storage)
- return 57;
+ if(node->id) {
+ Image *ima= (Image *)node->id;
+ int retval= 19;
+
+ /* for each draw we test for anim refresh event */
+ if(iuser->flag & IMA_ANIM_REFRESHED) {
+ iuser->flag &= ~IMA_ANIM_REFRESHED;
+ addqueue(curarea->win, UI_BUT_EVENT, B_NODE_EXEC+node->nr);
+ }
+
+ if( ELEM(ima->source, IMA_SRC_MOVIE, IMA_SRC_SEQUENCE) )
+ retval+= 38;
+ if( ima->type==IMA_TYPE_MULTILAYER)
+ retval+= 19;
+ return retval;
+ }
else
return 19;
}
@@ -1445,27 +1517,27 @@ static void draw_nodespace_grid(SpaceNode *snode)
static void draw_nodespace_back(ScrArea *sa, SpaceNode *snode)
{
- Image *ima;
- int x, y;
-
+
draw_nodespace_grid(snode);
if(snode->flag & SNODE_BACKDRAW) {
- ima= (Image *)find_id("IM", "Viewer Node");
- if(ima && ima->ibuf) {
+ Image *ima= BKE_image_verify_viewer(IMA_TYPE_COMPOSITE, "Viewer Node");
+ ImBuf *ibuf= BKE_image_get_ibuf(ima, NULL);
+ if(ibuf) {
+ int x, y;
/* somehow the offset has to be calculated inverse */
glaDefine2DArea(&sa->winrct);
/* ortho at pixel level curarea */
myortho2(-0.375, sa->winx-0.375, -0.375, sa->winy-0.375);
- x = (sa->winx-ima->ibuf->x)/2 + snode->xof;
- y = (sa->winx-ima->ibuf->y)/2 + snode->yof;
+ x = (sa->winx-ibuf->x)/2 + snode->xof;
+ y = (sa->winx-ibuf->y)/2 + snode->yof;
- if(ima->ibuf->rect)
- glaDrawPixelsSafe(x, y, ima->ibuf->x, ima->ibuf->y, ima->ibuf->x, GL_RGBA, GL_UNSIGNED_BYTE, ima->ibuf->rect);
- else
- glaDrawPixelsSafe(x, y, ima->ibuf->x, ima->ibuf->y, ima->ibuf->x, GL_RGBA, GL_FLOAT, ima->ibuf->rect_float);
+ if(ibuf->rect)
+ glaDrawPixelsSafe(x, y, ibuf->x, ibuf->y, ibuf->x, GL_RGBA, GL_UNSIGNED_BYTE, ibuf->rect);
+ else if(ibuf->channels==4)
+ glaDrawPixelsSafe(x, y, ibuf->x, ibuf->y, ibuf->x, GL_RGBA, GL_FLOAT, ibuf->rect_float);
/* sort this out, this should not be needed */
myortho2(snode->v2d.cur.xmin, snode->v2d.cur.xmax, snode->v2d.cur.ymin, snode->v2d.cur.ymax);
diff --git a/source/blender/src/drawview.c b/source/blender/src/drawview.c
index d22408f02e3..4706dcff9d0 100644
--- a/source/blender/src/drawview.c
+++ b/source/blender/src/drawview.c
@@ -168,22 +168,6 @@ static void star_stuff_term_func(void)
glEnd();
}
-static void setalpha_bgpic(BGpic *bgpic)
-{
- int x, y, alph;
- char *rect;
-
- alph= (int)(255.0*(1.0-bgpic->blend));
-
- rect= (char *)bgpic->rect;
- for(y=0; y< bgpic->yim; y++) {
- for(x= bgpic->xim; x>0; x--, rect+=4) {
- rect[3]= alph;
- }
- }
-}
-
-
void default_gl_light(void)
{
int a;
@@ -349,63 +333,24 @@ static void draw_bgpic(void)
{
BGpic *bgpic;
Image *ima;
+ ImBuf *ibuf= NULL;
float vec[4], fac, asp, zoomx, zoomy;
float x1, y1, x2, y2, cx, cy;
bgpic= G.vd->bgpic;
if(bgpic==NULL) return;
- if(bgpic->tex) {
- extern void init_render_texture(struct Render *re, Tex *tex);
- /* note; bad call, this has to be recoded to move to blenkernel */
- init_render_texture(NULL, bgpic->tex);
- free_unused_animimages();
- ima= bgpic->tex->ima;
- }
- else {
- ima= bgpic->ima;
- }
-
- if(ima==NULL) return;
- if(ima->ok==0) return;
-
- tag_image_time(ima);
-
- /* test for image */
- if(ima->ibuf==NULL) {
+ ima= bgpic->ima;
- if(bgpic->rect) MEM_freeN(bgpic->rect);
- bgpic->rect= NULL;
-
- if(bgpic->tex) {
- ima_ibuf_is_nul(bgpic->tex, bgpic->tex->ima);
- }
- else {
- waitcursor(1);
- load_image(ima, IB_rect, G.sce, G.scene->r.cfra);
- waitcursor(0);
- }
- if(ima->ibuf==NULL) {
- ima->ok= 0;
- return;
- }
- }
-
- /* this ensures that when ibuf changed (reloaded) the backbuf changes too */
- if(bgpic->ibuf!=ima->ibuf) {
- if(bgpic->rect) MEM_freeN(bgpic->rect);
- bgpic->rect= NULL;
- }
- bgpic->ibuf= ima->ibuf;
+ if(ima)
+ ibuf= BKE_image_get_ibuf(ima, &bgpic->iuser);
+ if(ibuf==NULL || (ibuf->rect==NULL && ibuf->rect_float==NULL) )
+ return;
+ if(ibuf->channels!=4)
+ return;
+ if(ibuf->rect==NULL)
+ IMB_rect_from_float(ibuf);
- if(bgpic->rect==NULL) {
-
- bgpic->rect= MEM_dupallocN(ima->ibuf->rect);
- bgpic->xim= ima->ibuf->x;
- bgpic->yim= ima->ibuf->y;
- setalpha_bgpic(bgpic);
- }
-
if(G.vd->persp==2) {
rctf vb;
@@ -425,7 +370,7 @@ static void draw_bgpic(void)
fac= MAX3( fabs(vec[0]), fabs(vec[1]), fabs(vec[1]) );
fac= 1.0/fac;
- asp= ( (float)ima->ibuf->y)/(float)ima->ibuf->x;
+ asp= ( (float)ibuf->y)/(float)ibuf->x;
vec[0] = vec[1] = vec[2] = 0.0;
view3d_project_float(curarea, vec, sco, G.vd->persmat);
@@ -445,10 +390,27 @@ static void draw_bgpic(void)
if(x1 > curarea->winx ) return;
if(y1 > curarea->winy ) return;
- zoomx= (x2-x1)/ima->ibuf->x;
- zoomy= (y2-y1)/ima->ibuf->y;
-
- glEnable(GL_BLEND);
+ zoomx= (x2-x1)/ibuf->x;
+ zoomy= (y2-y1)/ibuf->y;
+
+ /* for some reason; zoomlevels down refuses to use GL_ALPHA_SCALE */
+ if(zoomx < 1.0f || zoomy < 1.0f) {
+ float tzoom= MIN2(zoomx, zoomy);
+ int mip= 0;
+
+ if(ibuf->mipmap[0]==NULL)
+ IMB_makemipmap(ibuf, 0);
+
+ while(tzoom < 1.0f && mip<8 && ibuf->mipmap[mip]) {
+ tzoom*= 2.0f;
+ zoomx*= 2.0f;
+ zoomy*= 2.0f;
+ mip++;
+ }
+ if(mip>0)
+ ibuf= ibuf->mipmap[mip-1];
+ }
+
if(G.vd->zbuf) glDisable(GL_DEPTH_TEST);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
@@ -459,16 +421,18 @@ static void draw_bgpic(void)
glPushMatrix();
glaDefine2DArea(&curarea->winrct);
+ glEnable(GL_BLEND);
+ glPixelTransferf(GL_ALPHA_SCALE, (1.0f-bgpic->blend));
glPixelZoom(zoomx, zoomy);
- glaDrawPixelsSafe(x1, y1, ima->ibuf->x, ima->ibuf->y, ima->ibuf->x, GL_RGBA, GL_UNSIGNED_BYTE, bgpic->rect);
+ glaDrawPixelsSafe(x1, y1, ibuf->x, ibuf->y, ibuf->x, GL_RGBA, GL_UNSIGNED_BYTE, ibuf->rect);
glPixelZoom(1.0, 1.0);
+ glPixelTransferf(GL_ALPHA_SCALE, 1.0f);
glMatrixMode(GL_PROJECTION);
glPopMatrix();
glMatrixMode(GL_MODELVIEW);
glPopMatrix();
- glBlendFunc(GL_ONE, GL_ZERO);
glDisable(GL_BLEND);
if(G.vd->zbuf) glEnable(GL_DEPTH_TEST);
@@ -1213,9 +1177,6 @@ ImBuf *read_backbuf(short xmin, short ymin, short xmax, short ymax)
dr++;
}
- ibuf->ftype= PNG;
- IMB_saveiff(ibuf, "/tmp/rt.png", IB_rect);
-
/* put clipped result back, if needed */
if(xminc==xmin && xmaxc==xmax && yminc==ymin && ymaxc==ymax)
return ibuf;
@@ -1444,7 +1405,6 @@ static void draw_view_icon(void)
BIF_icon_draw(5.0, 5.0, icon);
- glBlendFunc(GL_ONE, GL_ZERO);
glDisable(GL_BLEND);
}
@@ -1475,54 +1435,6 @@ static void draw_viewport_name(ScrArea *sa)
/* ******************* view3d space & buttons ************** */
-static void view3d_change_bgpic_ima(View3D *v3d, Image *newima) {
- if (v3d->bgpic && v3d->bgpic->ima!=newima) {
- if (newima)
- id_us_plus((ID*) newima);
- if (v3d->bgpic->ima)
- v3d->bgpic->ima->id.us--;
- v3d->bgpic->ima= newima;
-
- if(v3d->bgpic->rect) MEM_freeN(v3d->bgpic->rect);
- v3d->bgpic->rect= NULL;
-
- allqueue(REDRAWVIEW3D, 0);
- }
-}
-static void view3d_change_bgpic_tex(View3D *v3d, Tex *newtex) {
- if (v3d->bgpic && v3d->bgpic->tex!=newtex) {
- if (newtex)
- id_us_plus((ID*) newtex);
- if (v3d->bgpic->tex)
- v3d->bgpic->tex->id.us--;
- v3d->bgpic->tex= newtex;
-
- allqueue(REDRAWVIEW3D, 0);
- }
-}
-
-static void load_bgpic_image(char *name)
-{
- Image *ima;
- View3D *vd;
-
- areawinset(curarea->win);
- vd= G.vd;
- if(vd==0 || vd->bgpic==0) return;
-
- ima= add_image(name);
- if(ima) {
- if(vd->bgpic->ima) {
- vd->bgpic->ima->id.us--;
- }
- vd->bgpic->ima= ima;
-
- free_image_buffers(ima); /* force read again */
- ima->ok= 1;
- }
- allqueue(REDRAWVIEW3D, 0);
-
-}
/* temporal struct for storing transform properties */
typedef struct {
@@ -1975,63 +1887,12 @@ void do_viewbuts(unsigned short event)
View3D *vd;
Object *ob= OBACT;
TransformProperties *tfp= G.vd->properties_storage;
- char *name;
vd= G.vd;
- if(vd==0) return;
+ if(vd==NULL) return;
switch(event) {
- case B_LOADBGPIC:
- if(vd->bgpic && vd->bgpic->ima) name= vd->bgpic->ima->name;
- else name= G.ima;
-
- if(G.qual==LR_CTRLKEY)
- activate_imageselect(FILE_SPECIAL, "Select Image", name, load_bgpic_image);
- else
- activate_fileselect(FILE_SPECIAL, "Select Image", name, load_bgpic_image);
- break;
-
- case B_BLENDBGPIC:
- if(vd->bgpic && vd->bgpic->rect) setalpha_bgpic(vd->bgpic);
- addqueue(curarea->win, REDRAW, 1);
- break;
-
- case B_BGPICBROWSE:
- if(vd->bgpic) {
- if (vd->menunr==-2) {
- activate_databrowse((ID*) vd->bgpic->ima, ID_IM, 0, B_BGPICBROWSE, &vd->menunr, do_viewbuts);
- } else if (vd->menunr>0) {
- Image *newima= (Image*) BLI_findlink(&G.main->image, vd->menunr-1);
-
- if (newima)
- view3d_change_bgpic_ima(vd, newima);
- }
- }
- break;
-
- case B_BGPICCLEAR:
- if (vd->bgpic)
- view3d_change_bgpic_ima(vd, NULL);
- break;
- case B_BGPICTEX:
- if (vd->bgpic) {
- if (vd->texnr==-2) {
- activate_databrowse((ID*) vd->bgpic->tex, ID_TE, 0, B_BGPICTEX, &vd->texnr, do_viewbuts);
- } else if (vd->texnr>0) {
- Tex *newtex= (Tex*) BLI_findlink(&G.main->tex, vd->texnr-1);
-
- if (newtex)
- view3d_change_bgpic_tex(vd, newtex);
- }
- }
- break;
-
- case B_BGPICTEXCLEAR:
- if (vd->bgpic)
- view3d_change_bgpic_tex(vd, NULL);
- break;
-
case B_OBJECTPANEL:
DAG_object_flush_update(G.scene, ob, OB_RECALC_OB);
allqueue(REDRAWVIEW3D, 1);
@@ -2371,8 +2232,6 @@ static void view3d_panel_background(short cntrl) // VIEW3D_HANDLER_BACKGROUND
{
uiBlock *block;
View3D *vd;
- ID *id;
- char *strp;
vd= G.vd;
@@ -2386,68 +2245,29 @@ static void view3d_panel_background(short cntrl) // VIEW3D_HANDLER_BACKGROUND
}
if(vd->flag & V3D_DISPBGPIC) {
- if(vd->bgpic==0) {
+ if(vd->bgpic==NULL) {
vd->bgpic= MEM_callocN(sizeof(BGpic), "bgpic");
vd->bgpic->size= 5.0;
vd->bgpic->blend= 0.5;
+ vd->bgpic->iuser.fie_ima= 2;
+ vd->bgpic->iuser.ok= 1;
}
}
- uiDefButBitS(block, TOG, V3D_DISPBGPIC, REDRAWVIEW3D, "Use Background Image", 0, 162, 200, 20, &vd->flag, 0, 0, 0, 0, "Display an image in the background of the 3D View");
-
- uiDefBut(block, LABEL, 1, " ", 206, 162, 84, 20, NULL, 0.0, 0.0, 0, 0, "");
-
-
- if(vd->flag & V3D_DISPBGPIC) {
-
- /* Background Image */
- uiDefBut(block, LABEL, 1, "Image:", 0, 128, 76, 19, NULL, 0.0, 0.0, 0, 0, "");
-
+ if(!(vd->flag & V3D_DISPBGPIC)) {
+ uiDefButBitS(block, TOG, V3D_DISPBGPIC, B_REDR, "Use Background Image", 10, 180, 150, 20, &vd->flag, 0, 0, 0, 0, "Display an image in the background of the 3D View");
+ uiDefBut(block, LABEL, 1, " ", 160, 180, 150, 20, NULL, 0.0, 0.0, 0, 0, "");
+ }
+ else {
uiBlockBeginAlign(block);
- uiDefIconBut(block, BUT, B_LOADBGPIC, ICON_FILESEL, 90, 128, 20, 20, 0, 0, 0, 0, 0, "Open a new background image");
+ uiDefButBitS(block, TOG, V3D_DISPBGPIC, B_REDR, "Use", 10, 225, 50, 20, &vd->flag, 0, 0, 0, 0, "Display an image in the background of the 3D View");
+ uiDefButF(block, NUMSLI, B_REDR, "Blend:", 60, 225, 150, 20, &vd->bgpic->blend, 0.0,1.0, 0, 0, "Set the transparency of the background image");
+ uiDefButF(block, NUM, B_REDR, "Size:", 210, 225, 100, 20, &vd->bgpic->size, 0.1, 250.0*vd->grid, 100, 0, "Set the size (width) of the background image");
- id= (ID *)vd->bgpic->ima;
- IDnames_to_pupstring(&strp, NULL, NULL, &(G.main->image), id, &(vd->menunr));
- if(strp[0]) {
-
- uiDefButS(block, MENU, B_BGPICBROWSE, strp, 110, 128, 20, 20, &(vd->menunr), 0, 0, 0, 0, "Select a background image");
+ uiDefButF(block, NUM, B_REDR, "X Offset:", 10, 205, 150, 20, &vd->bgpic->xof, -250.0*vd->grid,250.0*vd->grid, 10, 2, "Set the horizontal offset of the background image");
+ uiDefButF(block, NUM, B_REDR, "Y Offset:", 160, 205, 150, 20, &vd->bgpic->yof, -250.0*vd->grid,250.0*vd->grid, 10, 2, "Set the vertical offset of the background image");
- if(vd->bgpic->ima) {
- uiDefBut(block, TEX, 0,"BG: ", 130, 128, 140, 20, &vd->bgpic->ima->name,0.0,100.0, 0, 0, "The currently selected background image");
- uiDefIconBut(block, BUT, B_BGPICCLEAR, ICON_X, 270, 128, 20, 20, 0, 0, 0, 0, 0, "Remove background image link");
- }
- uiBlockEndAlign(block);
- } else {
- uiBlockEndAlign(block);
- }
- MEM_freeN(strp);
-
-
- /* Background texture */
- uiDefBut(block, LABEL, 1, "Texture:", 0, 100, 76, 19, NULL, 0.0, 0.0, 0, 0, "");
-
- id= (ID *)vd->bgpic->tex;
- IDnames_to_pupstring(&strp, NULL, NULL, &(G.main->tex), id, &(vd->texnr));
- if (strp[0])
- uiBlockBeginAlign(block);
- uiDefButS(block, MENU, B_BGPICTEX, strp, 90, 100, 20,20, &(vd->texnr), 0, 0, 0, 0, "Select a texture to use as an animated background image");
- MEM_freeN(strp);
-
- if (id) {
- uiDefBut(block, TEX, B_IDNAME, "TE:", 110, 100, 160, 20, id->name+2, 0.0, 18.0, 0, 0, "");
- uiDefIconBut(block, BUT, B_BGPICTEXCLEAR, ICON_X, 270, 100, 20, 20, 0, 0, 0, 0, 0, "Remove background texture link");
- uiBlockEndAlign(block);
- } else {
- uiBlockEndAlign(block);
- }
-
- uiDefButF(block, NUMSLI, B_BLENDBGPIC, "Blend:", 0, 60 , 290, 19, &vd->bgpic->blend, 0.0,1.0, 0, 0, "Set the transparency of the background image");
-
- uiDefButF(block, NUM, REDRAWVIEW3D, "Size:", 0, 28, 140, 19, &vd->bgpic->size, 0.1, 250.0*vd->grid, 100, 0, "Set the size (width) of the background image");
-
- uiDefButF(block, NUM, REDRAWVIEW3D, "X Offset:", 0, 6, 140, 19, &vd->bgpic->xof, -250.0*vd->grid,250.0*vd->grid, 10, 2, "Set the horizontal offset of the background image");
- uiDefButF(block, NUM, REDRAWVIEW3D, "Y Offset:", 150, 6, 140, 19, &vd->bgpic->yof, -250.0*vd->grid,250.0*vd->grid, 10, 2, "Set the vertical offset of the background image");
-
+ uiblock_image_panel(block, &vd->bgpic->ima, &vd->bgpic->iuser, B_REDR, B_REDR);
}
}
diff --git a/source/blender/src/editnode.c b/source/blender/src/editnode.c
index 9eb3f8794e4..e2faa3649eb 100644
--- a/source/blender/src/editnode.c
+++ b/source/blender/src/editnode.c
@@ -154,7 +154,9 @@ static void snode_handle_recalc(SpaceNode *snode)
snode->nodetree->timecursor= set_timecursor;
G.afbreek= 0;
snode->nodetree->test_break= blender_test_break;
-
+
+ BIF_store_spare();
+
ntreeCompositExecTree(snode->nodetree, &G.scene->r, 1); /* 1 is do_previews */
snode->nodetree->timecursor= NULL;
@@ -191,7 +193,7 @@ static void load_node_image(char *str) /* called from fileselect */
bNode *node= nodeGetActive(snode->edittree);
Image *ima= NULL;
- ima= add_image(str);
+ ima= BKE_add_image_file(str);
if(ima) {
if(node->id)
node->id->us--;
@@ -201,8 +203,7 @@ static void load_node_image(char *str) /* called from fileselect */
BLI_strncpy(node->name, node->id->name+2, 21);
- free_image_buffers(ima); /* force read again */
- ima->ok= 1;
+ BKE_image_signal(ima, node->storage, IMA_SIGNAL_RELOAD);
NodeTagChanged(snode->edittree, node);
snode_handle_recalc(snode);
@@ -417,6 +418,28 @@ void snode_set_context(SpaceNode *snode)
snode->edittree= snode->nodetree;
}
+/* on activate image viewer, check if we show it */
+static void node_active_image(Image *ima)
+{
+ ScrArea *sa;
+ SpaceImage *sima= NULL;
+
+ /* find an imagewindow showing render result */
+ for(sa=G.curscreen->areabase.first; sa; sa= sa->next) {
+ if(sa->spacetype==SPACE_IMAGE) {
+ sima= sa->spacedata.first;
+ if(sima->image && sima->image->source!=IMA_SRC_VIEWER)
+ break;
+ }
+ }
+ if(sa && sima) {
+ sima->image= ima;
+ scrarea_queue_winredraw(sa);
+ scrarea_queue_headredraw(sa);
+ }
+}
+
+
static void node_set_active(SpaceNode *snode, bNode *node)
{
@@ -460,18 +483,17 @@ static void node_set_active(SpaceNode *snode, bNode *node)
snode_handle_recalc(snode);
}
- /* add node doesnt link this yet... */
- if(node->id==NULL) {
- node->id= find_id("IM", "Viewer Node");
- if(node->id==NULL) {
- Image *ima= alloc_libblock(&G.main->image, ID_IM, "Viewer Node");
- strcpy(ima->name, "Viewer Node");
- ima->ok= 1;
- ima->xrep= ima->yrep= 1;
- node->id= &ima->id;
- }
- else
- node->id->us++;
+ /* addnode() doesnt link this yet... */
+ node->id= (ID *)BKE_image_verify_viewer(IMA_TYPE_COMPOSITE, "Viewer Node");
+ }
+ else if(node->type==CMP_NODE_IMAGE) {
+ if(node->id)
+ node_active_image((Image *)node->id);
+ }
+ else if(node->type==CMP_NODE_R_LAYERS) {
+ if(node->id==NULL || node->id==(ID *)G.scene) {
+ G.scene->r.actlay= node->custom1;
+ allqueue(REDRAWBUTSSCENE, 0);
}
}
}
@@ -746,19 +768,21 @@ void snode_zoom_in(ScrArea *sa)
static void snode_bg_viewmove(SpaceNode *snode)
{
ScrArea *sa;
+ Image *ima;
+ ImBuf *ibuf;
+ Window *win;
short mval[2], mvalo[2];
short rectx, recty, xmin, xmax, ymin, ymax, pad;
- Window *win;
int oldcursor;
- Image *ima;
- ima= (Image *)find_id("IM", "Viewer Node");
+ ima= BKE_image_verify_viewer(IMA_TYPE_COMPOSITE, "Viewer Node");
+ ibuf= BKE_image_get_ibuf(ima, NULL);
sa = snode->area;
- if(ima && ima->ibuf) {
- rectx = ima->ibuf->x;
- recty = ima->ibuf->y;
+ if(ibuf) {
+ rectx = ibuf->x;
+ recty = ibuf->y;
} else {
rectx = recty = 1;
}
@@ -1472,8 +1496,9 @@ bNode *node_add_node(SpaceNode *snode, int type, float locx, float locy)
id_us_plus(node->id);
if(snode->nodetree->type==NTREE_COMPOSIT)
- ntreeCompositForceHidden(G.scene->nodetree);
+ ntreeCompositForceHidden(snode->edittree);
+ NodeTagChanged(snode->edittree, node);
}
return node;
}
@@ -1884,6 +1909,43 @@ void node_read_renderlayers(SpaceNode *snode)
snode_handle_recalc(snode);
}
+/* 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;
+
+ if(ntree==NULL)
+ return;
+
+ /* search for renderresults */
+ if(image->type==IMA_TYPE_R_RESULT) {
+ for(node= ntree->nodes.first; node; node= node->next) {
+ if(node->type==CMP_NODE_R_LAYERS && node->id==NULL) {
+ /* imageuser comes from ImageWin, so indexes are offset 1 */
+ if(node->custom1==iuser->layer-1)
+ NodeTagChanged(ntree, node);
+ }
+ }
+ }
+ else {
+ for(node= ntree->nodes.first; node; node= node->next) {
+ if(node->id== &image->id)
+ NodeTagChanged(ntree, node);
+ }
+ }
+}
/* ********************** */
@@ -2085,6 +2147,9 @@ void winqreadnodespace(ScrArea *sa, void *spacedata, BWinEvent *evt)
else node_adduplicate(snode);
}
break;
+ case EKEY:
+ snode_handle_recalc(snode);
+ break;
case GKEY:
if(fromlib) fromlib= -1;
else {
diff --git a/source/blender/src/editobject.c b/source/blender/src/editobject.c
index 861306a62cb..913a49c28e2 100644
--- a/source/blender/src/editobject.c
+++ b/source/blender/src/editobject.c
@@ -107,6 +107,7 @@
#include "BKE_global.h"
#include "BKE_group.h"
#include "BKE_ipo.h"
+#include "BKE_image.h"
#include "BKE_key.h"
#include "BKE_lattice.h"
#include "BKE_library.h"
@@ -5049,8 +5050,9 @@ void image_aspect(void)
for(b=0; b<MAX_MTEX; b++) {
if(ma->mtex[b] && ma->mtex[b]->tex) {
tex= ma->mtex[b]->tex;
- if(tex->type==TEX_IMAGE && tex->ima && tex->ima->ibuf) {
-
+ if(tex->type==TEX_IMAGE && tex->ima) {
+ ImBuf *ibuf= BKE_image_get_ibuf(tex->ima, NULL);
+
/* texturespace */
space= 1.0;
if(ob->type==OB_MESH) {
@@ -5063,8 +5065,8 @@ void image_aspect(void)
space= cu->size[0]/cu->size[1];
}
- x= tex->ima->ibuf->x/space;
- y= tex->ima->ibuf->y;
+ x= ibuf->x/space;
+ y= ibuf->y;
if(x>y) ob->size[0]= ob->size[1]*x/y;
else ob->size[1]= ob->size[0]*y/x;
diff --git a/source/blender/src/editscreen.c b/source/blender/src/editscreen.c
index d69b1db1365..a8551656343 100644
--- a/source/blender/src/editscreen.c
+++ b/source/blender/src/editscreen.c
@@ -480,8 +480,7 @@ static void headmenu(ScrArea *sa)
static void addqueue_ext(short win, unsigned short event, short val, char ascii)
{
if (win<4 || !areawinar[win]) {
- if(win==0 && !G.background) /* other win ids are for mainwin & renderwin */
- printf("bad call to addqueue: %d (%d, %d)\n", win, event, val);
+ /* other win ids are for mainwin & renderwin */
}
else {
BWinEvent evt;
@@ -1842,8 +1841,8 @@ static void del_area(ScrArea *sa)
if(sa==g_activearea) g_activearea= NULL;
}
-/* sa2 to sa1 */
-static void copy_areadata(ScrArea *sa1, ScrArea *sa2)
+/* sa2 to sa1, we swap spaces for fullscreen to keep all allocated data */
+static void copy_areadata(ScrArea *sa1, ScrArea *sa2, int swap_space)
{
Panel *pa1, *pa2, *patab;
ScriptLink *slink1 = &sa1->scriptlink, *slink2 = &sa2->scriptlink;
@@ -1852,8 +1851,13 @@ static void copy_areadata(ScrArea *sa1, ScrArea *sa2)
sa1->spacetype= sa2->spacetype;
Mat4CpyMat4(sa1->winmat, sa2->winmat);
- freespacelist(sa1);
- duplicatespacelist(sa1, &sa1->spacedata, &sa2->spacedata);
+ if(swap_space) {
+ SWAP(ListBase, sa1->spacedata, sa2->spacedata);
+ }
+ else {
+ freespacelist(sa1);
+ duplicatespacelist(sa1, &sa1->spacedata, &sa2->spacedata);
+ }
BLI_freelistN(&sa1->panels);
duplicatelist(&sa1->panels, &sa2->panels);
@@ -2332,7 +2336,7 @@ void area_fullscreen(void) /* with curarea */
headertype = curarea->headertype;
}
- copy_areadata(old, curarea);
+ copy_areadata(old, curarea, 1); /* 1 = swap spacelist */
old->headertype = headertype;
old->full= 0;
@@ -2364,7 +2368,7 @@ void area_fullscreen(void) /* with curarea */
G.curscreen= oldscreen; /* needed because of setscreen */
/* copy area */
- copy_areadata(newa, curarea);
+ copy_areadata(newa, curarea, 1); /* 1 = swap spacelist */
curarea->full= oldscreen;
newa->full= oldscreen;
@@ -2416,7 +2420,7 @@ static void area_autoplayscreen(void)
G.curscreen= oldscreen; /* because of setscreen */
/* copy area settings */
- copy_areadata(newa, curarea);
+ copy_areadata(newa, curarea, 1); /* swap spacedata */
newa->headertype= 0;
curarea->full= oldscreen;
@@ -2470,7 +2474,7 @@ static void copy_screen(bScreen *to, bScreen *from)
sa->spacedata.first= sa->spacedata.last= NULL;
sa->uiblocks.first= sa->uiblocks.last= NULL;
sa->panels.first= sa->panels.last= NULL;
- copy_areadata(sa, saf);
+ copy_areadata(sa, saf, 0);
sa= sa->next;
saf= saf->next;
@@ -2939,7 +2943,7 @@ static void splitarea(ScrArea *sa, char dir, float fac)
/* new areas: top */
newa= screen_addarea(sc, sv1, sa->v2, sa->v3, sv2, sa->headertype, sa->spacetype);
- copy_areadata(newa, sa);
+ copy_areadata(newa, sa, 0);
/* area below */
sa->v2= sv1;
@@ -2960,7 +2964,7 @@ static void splitarea(ScrArea *sa, char dir, float fac)
/* new areas: left */
newa= screen_addarea(sc, sa->v1, sa->v2, sv2, sv1, sa->headertype, sa->spacetype);
- copy_areadata(newa, sa);
+ copy_areadata(newa, sa, 0);
/* area right */
sa->v1= sv1;
diff --git a/source/blender/src/editsima.c b/source/blender/src/editsima.c
index 3e25340048f..d7b025c53f3 100644
--- a/source/blender/src/editsima.c
+++ b/source/blender/src/editsima.c
@@ -49,17 +49,20 @@
#include "BLI_arithb.h"
#include "IMB_imbuf_types.h"
+#include "IMB_imbuf.h"
+#include "DNA_image_types.h"
#include "DNA_mesh_types.h"
#include "DNA_meshdata_types.h"
+#include "DNA_node_types.h"
+#include "DNA_object_types.h" // only for uvedit_selectionCB() (struct Object)
#include "DNA_packedFile_types.h"
#include "DNA_scene_types.h"
#include "DNA_space_types.h"
#include "DNA_screen_types.h"
+#include "DNA_texture_types.h"
#include "DNA_userdef_types.h"
-#include "DNA_space_types.h"
-#include "DNA_image_types.h"
-#include "DNA_object_types.h" // only for uvedit_selectionCB() (struct Object)
+#include "DNA_view3d_types.h"
#include "BKE_colortools.h"
#include "BKE_depsgraph.h"
@@ -69,6 +72,7 @@
#include "BKE_library.h"
#include "BKE_main.h"
#include "BKE_mesh.h"
+#include "BKE_node.h"
#include "BKE_object.h"
#include "BKE_packedFile.h"
#include "BKE_utildefines.h"
@@ -97,6 +101,8 @@
#include "BMF_Api.h"
+#include "RE_pipeline.h"
+
#include "blendef.h"
#include "mydevice.h"
@@ -142,10 +148,10 @@ int is_uv_tface_editing_allowed(void)
void get_connected_limit_tface_uv(float *limit)
{
- if(G.sima->image && G.sima->image->ibuf && G.sima->image->ibuf->x > 0 &&
- G.sima->image->ibuf->y > 0) {
- limit[0]= 0.05/(float)G.sima->image->ibuf->x;
- limit[1]= 0.05/(float)G.sima->image->ibuf->y;
+ ImBuf *ibuf= BKE_image_get_ibuf(G.sima->image, &G.sima->iuser);
+ if(ibuf && ibuf->x > 0 && ibuf->y > 0) {
+ limit[0]= 0.05/(float)ibuf->x;
+ limit[1]= 0.05/(float)ibuf->y;
}
else
limit[0]= limit[1]= 0.05/256.0;
@@ -154,18 +160,20 @@ void get_connected_limit_tface_uv(float *limit)
void clever_numbuts_sima(void)
{
float ocent[2], cent[2]= {0.0, 0.0};
- int imx, imy;
+ int imx= 256, imy= 256;
int i, nactive= 0;
Mesh *me;
if( is_uv_tface_editing_allowed()==0 ) return;
me= get_mesh(OBACT);
- if (G.sima->image && G.sima->image->ibuf) {
- imx= G.sima->image->ibuf->x;
- imy= G.sima->image->ibuf->y;
- } else
- imx= imy= 256;
+ if (G.sima->image) {
+ ImBuf *ibuf= BKE_image_get_ibuf(G.sima->image, &G.sima->iuser);
+ if(ibuf) {
+ imx= ibuf->x;
+ imy= ibuf->y;
+ }
+ }
for (i=0; i<me->totface; i++) {
MFace *mf= &((MFace*) me->mface)[i];
@@ -312,9 +320,11 @@ void transform_aspect_ratio_tface_uv(float *aspx, float *aspy)
void transform_width_height_tface_uv(int *width, int *height)
{
- if(G.sima->image && G.sima->image->ibuf) {
- *width= G.sima->image->ibuf->x;
- *height= G.sima->image->ibuf->y;
+ ImBuf *ibuf= BKE_image_get_ibuf(G.sima->image, &G.sima->iuser);
+
+ if(ibuf) {
+ *width= ibuf->x;
+ *height= ibuf->y;
}
else {
*width= 256;
@@ -861,14 +871,14 @@ void sel_uvco_inside_radius(short sel, MTFace *tface, int index, float *offset,
/** gets image dimensions of the 2D view 'v' */
static void getSpaceImageDimension(SpaceImage *sima, float *xy)
{
- Image *img = sima->image;
+ ImBuf *ibuf= BKE_image_get_ibuf(sima->image, &sima->iuser);
float z;
z = sima->zoom;
- if (img && img->ibuf) {
- xy[0] = img->ibuf->x * z;
- xy[1] = img->ibuf->y * z;
+ if (ibuf) {
+ xy[0] = ibuf->x * z;
+ xy[1] = ibuf->y * z;
} else {
xy[0] = 256 * z;
xy[1] = 256 * z;
@@ -1049,13 +1059,15 @@ void stitch_uv_tface(int mode)
return;
}
- if(G.sima->image && G.sima->image->ibuf && G.sima->image->ibuf->x > 0 &&
- G.sima->image->ibuf->y > 0) {
- limit[1]= limit[0]/(float)G.sima->image->ibuf->y;
- limit[0]= limit[0]/(float)G.sima->image->ibuf->x;
+ limit[0]= limit[1]= limit[0]/256.0;
+ if(G.sima->image) {
+ ImBuf *ibuf= BKE_image_get_ibuf(G.sima->image, &G.sima->iuser);
+
+ if(ibuf && ibuf->x > 0 && ibuf->y > 0) {
+ limit[1]= limit[0]/(float)ibuf->y;
+ limit[0]= limit[0]/(float)ibuf->x;
+ }
}
- else
- limit[0]= limit[1]= limit[0]/256.0;
me= get_mesh(OBACT);
tf= me->mtface;
@@ -1418,7 +1430,7 @@ int minmax_tface_uv(float *min, float *max)
return sel;
}
-static void sima_show_info(int x, int y, char *cp, float *fp, int *zp, float *zpf)
+static void sima_show_info(int channels, int x, int y, char *cp, float *fp, int *zp, float *zpf)
{
short ofs;
char str[256];
@@ -1426,8 +1438,14 @@ static void sima_show_info(int x, int y, char *cp, float *fp, int *zp, float *zp
ofs= sprintf(str, "X: %d Y: %d ", x, y);
if(cp)
ofs+= sprintf(str+ofs, "| R: %d G: %d B: %d A: %d ", cp[0], cp[1], cp[2], cp[3]);
- if(fp)
- ofs+= sprintf(str+ofs, "| R: %.3f G: %.3f B: %.3f A: %.3f ", fp[0], fp[1], fp[2], fp[3]);
+ if(fp) {
+ if(channels==4)
+ ofs+= sprintf(str+ofs, "| R: %.3f G: %.3f B: %.3f A: %.3f ", fp[0], fp[1], fp[2], fp[3]);
+ else if(channels==1)
+ ofs+= sprintf(str+ofs, "| Val: %.3f ", fp[0]);
+ else if(channels==3)
+ ofs+= sprintf(str+ofs, "| R: %.3f G: %.3f B: %.3f ", fp[0], fp[1], fp[2]);
+ }
if(zp)
ofs+= sprintf(str+ofs, "| Z: %.4f ", 0.5+0.5*( ((float)*zp)/(float)0x7fffffff));
if(zpf)
@@ -1449,13 +1467,12 @@ static void sima_show_info(int x, int y, char *cp, float *fp, int *zp, float *zp
void sima_sample_color(void)
{
- ImBuf *ibuf;
+ ImBuf *ibuf= BKE_image_get_ibuf(G.sima->image, &G.sima->iuser);
float fx, fy;
short mval[2], mvalo[2], firsttime=1;
- if(G.sima->image==NULL) return;
- if(G.sima->image->ibuf==NULL) return;
- ibuf= G.sima->image->ibuf;
+ if(ibuf==NULL)
+ return;
calc_image_view(G.sima, 'f');
getmouseco_areawin(mvalo);
@@ -1485,7 +1502,7 @@ void sima_sample_color(void)
if(ibuf->zbuf_float)
zpf= ibuf->zbuf_float + y*ibuf->x + x;
if(ibuf->rect_float)
- fp= (ibuf->rect_float + 4*(y*ibuf->x + x));
+ fp= (ibuf->rect_float + (ibuf->channels)*(y*ibuf->x + x));
if(G.sima->cumap) {
float vec[3];
@@ -1496,20 +1513,22 @@ void sima_sample_color(void)
vec[2]= (float)cp[2]/255.0f;
}
- if(G.qual & LR_CTRLKEY) {
- curvemapping_set_black_white(G.sima->cumap, NULL, fp);
- curvemapping_do_image(G.sima->cumap, G.sima->image);
- }
- else if(G.qual & LR_SHIFTKEY) {
- curvemapping_set_black_white(G.sima->cumap, fp, NULL);
- curvemapping_do_image(G.sima->cumap, G.sima->image);
+ if(ibuf->channels==4) {
+ if(G.qual & LR_CTRLKEY) {
+ curvemapping_set_black_white(G.sima->cumap, NULL, fp);
+ curvemapping_do_ibuf(G.sima->cumap, ibuf);
+ }
+ else if(G.qual & LR_SHIFTKEY) {
+ curvemapping_set_black_white(G.sima->cumap, fp, NULL);
+ curvemapping_do_ibuf(G.sima->cumap, ibuf);
+ }
}
}
scrarea_do_windraw(curarea);
myortho2(-0.375, curarea->winx-0.375, -0.375, curarea->winy-0.375);
glLoadIdentity();
- sima_show_info(x, y, cp, fp, zp, zpf);
+ sima_show_info(ibuf->channels, x, y, cp, fp, zp, zpf);
screen_swapbuffers();
}
@@ -1524,20 +1543,19 @@ void sima_sample_color(void)
static void load_image_filesel(char *str) /* called from fileselect */
{
- Image *ima=0;
+ Image *ima= NULL;
if(G.obedit) {
error("Can't perfom this in editmode");
return;
}
- ima= add_image(str);
+ ima= BKE_add_image_file(str);
if(ima) {
G.sima->image= ima;
- free_image_buffers(ima); /* force read again */
- ima->ok= 1;
+ BKE_image_signal(ima, &G.sima->iuser, IMA_SIGNAL_RELOAD);
image_changed(G.sima, 0);
}
@@ -1591,7 +1609,7 @@ static void replace_image_filesel(char *str) /* called from fileselect */
return;
}
- ima= add_image(str);
+ ima= BKE_add_image_file(str);
if(ima) {
if(G.sima->image && G.sima->image != ima) {
@@ -1600,8 +1618,8 @@ static void replace_image_filesel(char *str) /* called from fileselect */
G.sima->image= ima;
- free_image_buffers(ima); /* force read again */
- ima->ok= 1;
+ BKE_image_signal(ima, &G.sima->iuser, IMA_SIGNAL_RELOAD);
+
/* replace also assigns: */
image_changed(G.sima, 0);
@@ -1610,42 +1628,69 @@ static void replace_image_filesel(char *str) /* called from fileselect */
allqueue(REDRAWIMAGE, 0);
}
-static void save_image_filesel(char *name)
+
+static void save_image_doit(char *name)
{
- Image *ima = G.sima->image;
+ Image *ima= G.sima->image;
+ ImBuf *ibuf= BKE_image_get_ibuf(ima, &G.sima->iuser);
int len;
char str[FILE_MAXDIR+FILE_MAXFILE];
- if (ima && ima->ibuf) {
+ if (ibuf) {
BLI_strncpy(str, name, sizeof(str));
BLI_convertstringcode(str, G.sce, G.scene->r.cfra);
if(G.scene->r.scemode & R_EXTENSION)
- BKE_add_image_extension(str, G.scene->r.imtype);
-
+ BKE_add_image_extension(str, G.sima->imtypenr);
+
if (saveover(str)) {
+
/* enforce user setting for RGB or RGBA, but skip BW */
if(G.scene->r.planes==32)
- ima->ibuf->depth= 32;
+ ibuf->depth= 32;
else if(G.scene->r.planes==24)
- ima->ibuf->depth= 24;
+ ibuf->depth= 24;
waitcursor(1);
- if (BKE_write_ibuf(ima->ibuf, str, G.scene->r.imtype, G.scene->r.subimtype, G.scene->r.quality)) {
+ if(G.sima->imtypenr==R_MULTILAYER) {
+ RenderResult *rr= BKE_image_get_renderresult(ima);
+ if(rr) {
+ RE_WriteRenderResult(rr, str);
+
+ BLI_strncpy(ima->name, name, sizeof(ima->name));
+ BLI_strncpy(ibuf->name, str, sizeof(ibuf->name));
+
+ /* should be function? nevertheless, saving only happens here */
+ for(ibuf= ima->ibufs.first; ibuf; ibuf= ibuf->next)
+ ibuf->userflags &= ~IB_BITMAPDIRTY;
+
+ }
+ else error("Did not write, no Multilayer Image");
+ }
+ else if (BKE_write_ibuf(ibuf, str, G.sima->imtypenr, G.scene->r.subimtype, G.scene->r.quality)) {
BLI_strncpy(ima->name, name, sizeof(ima->name));
- BLI_strncpy(ima->ibuf->name, str, sizeof(ima->ibuf->name));
- ima->ibuf->userflags &= ~IB_BITMAPDIRTY;
- allqueue(REDRAWHEADERS, 0);
- allqueue(REDRAWBUTSSHADING, 0);
- } else {
+ BLI_strncpy(ibuf->name, str, sizeof(ibuf->name));
+
+ ibuf->userflags &= ~IB_BITMAPDIRTY;
+
+ /* change type? */
+ if( ELEM(ima->source, IMA_SRC_GENERATED, IMA_SRC_VIEWER))
+ ima->source= IMA_SRC_FILE;
+ if(ima->type==IMA_TYPE_R_RESULT)
+ ima->type= IMA_TYPE_IMAGE;
+
+ /* name image as how we saved it */
+ len= strlen(str);
+ while (len > 0 && str[len - 1] != '/' && str[len - 1] != '\\') len--;
+ rename_id(&ima->id, str+len);
+ }
+ else {
error("Couldn't write image: %s", str);
}
-
- /* name image as how we saved it */
- len= strlen(str);
- while (len > 0 && str[len - 1] != '/' && str[len - 1] != '\\') len--;
- rename_id(&ima->id, str+len);
+
+ allqueue(REDRAWHEADERS, 0);
+ allqueue(REDRAWBUTSSHADING, 0);
waitcursor(0);
}
@@ -1682,64 +1727,138 @@ void replace_image_sima(short imageselect)
activate_fileselect(FILE_SPECIAL, "Replace Image", name, replace_image_filesel);
}
-void save_as_image_sima()
+
+static char *filesel_imagetype_string(Image *ima)
+{
+ char *strp, *str= MEM_callocN(14*32, "menu for filesel");
+
+ strp= str;
+ str += sprintf(str, "Save Image as: %%t|");
+ str += sprintf(str, "Targa %%x%d|", R_TARGA);
+ str += sprintf(str, "Targa Raw %%x%d|", R_RAWTGA);
+ str += sprintf(str, "PNG %%x%d|", R_PNG);
+ str += sprintf(str, "BMP %%x%d|", R_BMP);
+ str += sprintf(str, "Jpeg %%x%d|", R_JPEG90);
+ str += sprintf(str, "Iris %%x%d|", R_IRIS);
+ if(G.have_libtiff)
+ str += sprintf(str, "Tiff %%x%d|", R_TIFF);
+ str += sprintf(str, "Radiance HDR %%x%d|", R_RADHDR);
+ str += sprintf(str, "Cineon %%x%d|", R_CINEON);
+ str += sprintf(str, "DPX %%x%d|", R_DPX);
+#ifdef WITH_OPENEXR
+ str += sprintf(str, "OpenEXR %%x%d|", R_OPENEXR);
+ /* saving sequences of multilayer won't work, they copy buffers */
+ if(ima->source==IMA_SRC_SEQUENCE && ima->type==IMA_TYPE_MULTILAYER);
+ else str += sprintf(str, "MultiLayer %%x%d|", R_MULTILAYER);
+#endif
+ return strp;
+}
+
+/* always opens fileselect */
+void save_as_image_sima(void)
{
Image *ima = G.sima->image;
+ ImBuf *ibuf= BKE_image_get_ibuf(ima, &G.sima->iuser);
char name[FILE_MAXDIR+FILE_MAXFILE];
if (ima) {
strcpy(name, ima->name);
- if (ima->ibuf) {
- char str[64];
- save_image_filesel_str(str);
+ if (ibuf) {
+ char *strp;
- /* so it shows an extension in filewindow */
- if(G.scene->r.scemode & R_EXTENSION)
- BKE_add_image_extension(name, G.scene->r.imtype);
+ strp= filesel_imagetype_string(ima);
- activate_fileselect(FILE_SPECIAL, str, name, save_image_filesel);
+ /* cant save multilayer sequence, ima->rr isn't valid for a specific frame */
+ if(ima->rr && !(ima->source==IMA_SRC_SEQUENCE && ima->type==IMA_TYPE_MULTILAYER))
+ G.sima->imtypenr= R_MULTILAYER;
+ else if(ima->type==IMA_TYPE_R_RESULT)
+ G.sima->imtypenr= R_MULTILAYER;
+ else G.sima->imtypenr= BKE_ftype_to_imtype(ibuf->ftype);
+
+ activate_fileselect_menu(FILE_SPECIAL, "Save Image", name, strp, &G.sima->imtypenr, save_image_doit);
}
}
}
-void save_image_sima()
+/* if exists, saves over without fileselect */
+void save_image_sima(void)
{
Image *ima = G.sima->image;
+ ImBuf *ibuf= BKE_image_get_ibuf(ima, &G.sima->iuser);
char name[FILE_MAXDIR+FILE_MAXFILE];
if (ima) {
strcpy(name, ima->name);
- if (ima->ibuf) {
- if (BLI_exists(ima->ibuf->name))
- save_image_filesel(ima->ibuf->name);
+ if (ibuf) {
+ if (BLI_exists(ibuf->name)) {
+ if(BKE_image_get_renderresult(ima))
+ G.sima->imtypenr= R_MULTILAYER;
+ else
+ G.sima->imtypenr= BKE_ftype_to_imtype(ibuf->ftype);
+
+ save_image_doit(ibuf->name);
+ }
else
save_as_image_sima();
}
}
}
-void reload_image_sima()
+void save_image_sequence_sima(void)
{
- Image *ima = G.sima->image;
-
- if (ima && ima->ibuf && BLI_exists(ima->ibuf->name)) {
- if (ima->packedfile) {
- PackedFile *pf;
- pf = newPackedFile(ima->name);
- if (pf) {
- freePackedFile(ima->packedfile);
- ima->packedfile = pf;
+ ImBuf *ibuf;
+ int tot= 0;
+ char di[FILE_MAX], fi[FILE_MAX];
+
+ if(G.sima->image==NULL)
+ return;
+ if(G.sima->image->source!=IMA_SRC_SEQUENCE)
+ return;
+ if(G.sima->image->type==IMA_TYPE_MULTILAYER) {
+ error("Cannot save Multilayer Sequences");
+ return;
+ }
+
+ /* get total */
+ for(ibuf= G.sima->image->ibufs.first; ibuf; ibuf= ibuf->next)
+ if(ibuf->userflags & IB_BITMAPDIRTY)
+ tot++;
+
+ if(tot==0) {
+ notice("No Images have been changed");
+ return;
+ }
+ /* get a filename for menu */
+ for(ibuf= G.sima->image->ibufs.first; ibuf; ibuf= ibuf->next)
+ if(ibuf->userflags & IB_BITMAPDIRTY)
+ break;
+
+ BLI_strncpy(di, ibuf->name, FILE_MAX);
+ BLI_splitdirstring(di, fi);
+
+ sprintf(fi, "%d Image(s) will be saved in %s", tot, di);
+ if(okee(fi)) {
+
+ for(ibuf= G.sima->image->ibufs.first; ibuf; ibuf= ibuf->next) {
+ if(ibuf->userflags & IB_BITMAPDIRTY) {
+ if(0 == IMB_saveiff(ibuf, ibuf->name, IB_rect | IB_zbuf | IB_zbuffloat)) {
+ error("Could not write image", ibuf->name);
+ break;
+ }
+ printf("Saved: %s\n", ibuf->name);
+ ibuf->userflags &= ~IB_BITMAPDIRTY;
}
- else
- error("Image not available. Keeping packed image.");
- }
- if (ima->preview) {
- free_image_preview(ima);
}
- free_image_buffers(ima); /* force read again */
- ima->ok= 1;
+ }
+}
+
+void reload_image_sima(void)
+{
+
+ if (G.sima ) {
+ BKE_image_signal(G.sima->image, &G.sima->iuser, IMA_SIGNAL_RELOAD);
image_changed(G.sima, 0);
}
@@ -1748,13 +1867,13 @@ void reload_image_sima()
BIF_preview_changed(ID_TE);
}
-void new_image_sima()
+void new_image_sima(void)
{
static int width= 256, height= 256;
static short uvtestgrid=0;
char name[256];
- strcpy(name, "Image");
+ strcpy(name, "Untitled");
add_numbut(0, TEX, "Name:", 0, 255, name, NULL);
add_numbut(1, NUM|INT, "Width:", 1, 5000, &width, NULL);
@@ -1763,7 +1882,7 @@ void new_image_sima()
if (!do_clever_numbuts("New Image", 4, REDRAW))
return;
- G.sima->image= new_image(width, height, name, uvtestgrid);
+ G.sima->image= BKE_add_image_size(width, height, name, uvtestgrid);
image_changed(G.sima, 0);
BIF_undo_push("Add image");
@@ -1777,28 +1896,80 @@ void pack_image_sima()
Image *ima = G.sima->image;
if (ima) {
- 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);
- BIF_undo_push("Unpack image");
- }
- }
- else {
- if (ima->ibuf && (ima->ibuf->userflags & IB_BITMAPDIRTY)) {
- error("Can't pack painted image. Save the painted image first.");
+ 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);
+ BIF_undo_push("Unpack image");
+ }
}
else {
- ima->packedfile = newPackedFile(ima->name);
- BIF_undo_push("Pack image");
+ ImBuf *ibuf= BKE_image_get_ibuf(ima, &G.sima->iuser);
+ if (ibuf && (ibuf->userflags & IB_BITMAPDIRTY)) {
+ error("Can't pack painted image. Save image or use Repack as PNG.");
+ }
+ else {
+ ima->packedfile = newPackedFile(ima->name);
+ BIF_undo_push("Pack image");
+ }
}
+
+ allqueue(REDRAWBUTSSHADING, 0);
+ allqueue(REDRAWHEADERS, 0);
}
+ }
+}
+
+
- allqueue(REDRAWBUTSSHADING, 0);
- allqueue(REDRAWHEADERS, 0);
+/* goes over all ImageUsers, and sets frame numbers if auto-refresh is set */
+void BIF_image_update_frame(void)
+{
+ Tex *tex;
+
+ /* texture users */
+ for(tex= G.main->tex.first; tex; tex= tex->id.next) {
+ if(tex->type==TEX_IMAGE && tex->ima)
+ if(ELEM(tex->ima->source, IMA_SRC_MOVIE, IMA_SRC_SEQUENCE))
+ if(tex->iuser.flag & IMA_ANIM_ALWAYS)
+ BKE_image_user_calc_imanr(&tex->iuser, G.scene->r.cfra, 0);
+
+ }
+ /* image window, compo node users */
+ if(G.curscreen) {
+ ScrArea *sa;
+ for(sa= G.curscreen->areabase.first; sa; sa= sa->next) {
+ if(sa->spacetype==SPACE_VIEW3D) {
+ View3D *v3d= sa->spacedata.first;
+ if(v3d->bgpic)
+ if(v3d->bgpic->iuser.flag & IMA_ANIM_ALWAYS)
+ BKE_image_user_calc_imanr(&v3d->bgpic->iuser, G.scene->r.cfra, 0);
+ }
+ else if(sa->spacetype==SPACE_IMAGE) {
+ SpaceImage *sima= sa->spacedata.first;
+ if(sima->iuser.flag & IMA_ANIM_ALWAYS)
+ BKE_image_user_calc_imanr(&sima->iuser, G.scene->r.cfra, 0);
+ }
+ else if(sa->spacetype==SPACE_NODE) {
+ SpaceNode *snode= sa->spacedata.first;
+ if(snode->treetype==NTREE_COMPOSIT) {
+ bNode *node;
+ for(node= snode->nodetree->nodes.first; node; node= node->next) {
+ if(node->id && node->type==CMP_NODE_IMAGE) {
+ Image *ima= (Image *)node->id;
+ ImageUser *iuser= node->storage;
+ if(ELEM(ima->source, IMA_SRC_MOVIE, IMA_SRC_SEQUENCE))
+ if(iuser->flag & IMA_ANIM_ALWAYS)
+ BKE_image_user_calc_imanr(iuser, G.scene->r.cfra, 0);
+ }
+ }
+ }
+ }
+ }
}
}
diff --git a/source/blender/src/edittime.c b/source/blender/src/edittime.c
index 0a000d65419..990bcd72ecf 100644
--- a/source/blender/src/edittime.c
+++ b/source/blender/src/edittime.c
@@ -718,6 +718,9 @@ static void timeline_force_draw(short val)
else if(sa->spacetype==SPACE_BUTS) {
if(val & TIME_ALL_BUTS_WIN) dodraw= 1;
}
+ else if(sa->spacetype==SPACE_IMAGE) {
+ if (val & TIME_ALL_IMAGE_WIN) dodraw = 1;
+ }
else if(sa->spacetype==SPACE_SEQ) {
if (val & TIME_SEQ) dodraw = 1;
}
diff --git a/source/blender/src/filesel.c b/source/blender/src/filesel.c
index bcee676ae90..19c35580ff0 100644
--- a/source/blender/src/filesel.c
+++ b/source/blender/src/filesel.c
@@ -164,7 +164,7 @@ static rcti scrollrct, textrct, bar;
static int filebuty1, filebuty2, page_ofs, collumwidth, selecting=0;
static int filetoname= 0;
static float pixels_to_ofs;
-static char otherdir[FILE_MAXDIR+FILE_MAXFILE];
+static char otherdir[FILE_MAX];
static ScrArea *otherarea;
/* FSMENU HANDLING */
@@ -441,13 +441,13 @@ static int compare_extension(const void *a1, const void *a2) {
}
/* **************************************** */
-
-void clear_global_filesel_vars()
+static int filesel_has_func(SpaceFile *sfile)
{
- selecting= 0;
+ if(sfile->returnfunc || sfile->returnfunc_event || sfile->returnfunc_args)
+ return 1;
+ return 0;
}
-
void filesel_statistics(SpaceFile *sfile, int *totfile, int *selfile, float *totlen, float *sellen)
{
double len;
@@ -497,7 +497,7 @@ void test_flags_file(SpaceFile *sfile)
file->flags |= BLENDERFILE;
if(sfile->type==FILE_LOADLIB) {
- char name[FILE_MAXDIR+FILE_MAXFILE];
+ char name[FILE_MAX];
BLI_strncpy(name, sfile->dir, sizeof(name));
strcat(name, file->relname);
@@ -614,7 +614,7 @@ void sort_filelist(SpaceFile *sfile)
void read_dir(SpaceFile *sfile)
{
int num, len;
- char wdir[FILE_MAXDIR+FILE_MAXFILE];
+ char wdir[FILE_MAX];
/* sfile->act is used for example in databrowse: double names of library objects */
sfile->act= -1;
@@ -675,7 +675,7 @@ void freefilelist(SpaceFile *sfile)
static void split_sfile(SpaceFile *sfile, char *s1)
{
- char string[FILE_MAXDIR+FILE_MAXFILE], dir[FILE_MAXDIR+FILE_MAXFILE], file[FILE_MAXDIR+FILE_MAXFILE];
+ char string[FILE_MAX], dir[FILE_MAX], file[FILE_MAX];
BLI_strncpy(string, s1, sizeof(string));
@@ -699,7 +699,7 @@ void parent(SpaceFile *sfile)
char *dir;
/* if databrowse: no parent */
- if(sfile->type==FILE_MAIN && sfile->returnfunc) return;
+ if(sfile->type==FILE_MAIN && filesel_has_func(sfile)) return;
dir= sfile->dir;
@@ -1135,7 +1135,7 @@ static char *library_string(void)
int nr=0, tot= BLI_countlist(&G.main->library);
if(tot==0) return NULL;
- str= MEM_callocN(tot*(FILE_MAXDIR+FILE_MAXFILE), "filesel lib menu");
+ str= MEM_callocN(tot*(FILE_MAX), "filesel lib menu");
for(tot=0, lib= G.main->library.first; lib; lib= lib->id.next, nr++) {
tot+= sprintf(str+tot, "%s %%x%d|", lib->name+2, nr);
@@ -1181,7 +1181,8 @@ void drawfilespace(ScrArea *sa, void *spacedata)
sprintf(name, "win %d", sa->win);
block= uiNewBlock(&sa->uiblocks, name, UI_EMBOSS, UI_HELV, sa->win);
- uiSetButLock( sfile->type==FILE_MAIN && sfile->returnfunc, NULL);
+ /* browse 1 datablock */
+ uiSetButLock( sfile->type==FILE_MAIN && filesel_has_func(sfile), NULL);
/* space available for load/save buttons? */
loadbutton= MAX2(80, 20+BMF_GetStringWidth(G.font, sfile->title));
@@ -1300,10 +1301,15 @@ static void do_filescrollwheel(SpaceFile *sfile, int move)
}
}
-void activate_fileselect(int type, char *title, char *file, void (*func)(char *))
+/* the complete call; pulldown menu, and three callback types */
+static void activate_fileselect_(int type, char *title, char *file, short *menup, char *pupmenu,
+ void (*func)(char *),
+ void (*func_event)(unsigned short),
+ void (*func_args)(char *, void *arg1, void *arg2),
+ void *arg1, void *arg2)
{
SpaceFile *sfile;
- char group[24], name[FILE_MAXDIR+FILE_MAXFILE], temp[FILE_MAXDIR+FILE_MAXFILE];
+ char group[24], name[FILE_MAX], temp[FILE_MAX];
if(curarea==0) return;
if(curarea->win==0) return;
@@ -1318,10 +1324,21 @@ void activate_fileselect(int type, char *title, char *file, void (*func)(char *)
BLI_strncpy(name, file, sizeof(name));
sfile= curarea->spacedata.first;
- /* sfile wants a (*)(short), but get (*)(char*) */
+
sfile->returnfunc= func;
+ sfile->returnfunc_event= func_event;
+ sfile->returnfunc_args= func_args;
+ sfile->arg1= arg1;
+ sfile->arg2= arg2;
+
sfile->type= type;
sfile->ofs= 0;
+
+ if(sfile->pupmenu)
+ MEM_freeN(sfile->pupmenu);
+ sfile->pupmenu= pupmenu;
+ sfile->menup= menup;
+
/* sfile->act is used for databrowse: double names of library objects */
sfile->act= -1;
@@ -1372,12 +1389,28 @@ void activate_fileselect(int type, char *title, char *file, void (*func)(char *)
filetoname= 1;
}
+void activate_fileselect(int type, char *title, char *file, void (*func)(char *))
+{
+ activate_fileselect_(type, title, file, NULL, NULL, func, NULL, NULL, NULL, NULL);
+}
+
+void activate_fileselect_menu(int type, char *title, char *file, char *pupmenu, short *menup, void (*func)(char *))
+{
+ activate_fileselect_(type, title, file, menup, pupmenu, func, NULL, NULL, NULL, NULL);
+}
+
+void activate_fileselect_args(int type, char *title, char *file, void (*func)(char *, void *, void *), void *arg1, void *arg2)
+{
+ activate_fileselect_(type, title, file, NULL, NULL, NULL, NULL, func, arg1, arg2);
+}
+
+
void activate_imageselect(int type, char *title, char *file, void (*func)(char *))
{
SpaceImaSel *simasel;
- char dir[FILE_MAXDIR+FILE_MAXFILE], name[FILE_MAXDIR+FILE_MAXFILE];
+ char dir[FILE_MAX], name[FILE_MAX];
- if(curarea==0) return;
+ if(curarea==NULL) return;
if(curarea->win==0) return;
newspace(curarea, SPACE_IMASEL);
@@ -1420,19 +1453,47 @@ void activate_databrowse(ID *id, int idcode, int fromcode, int retval, short *me
if(id) BLI_strncpy(str, id->name, sizeof(str));
else return;
- activate_fileselect(FILE_MAIN, "SELECT DATABLOCK", str, (void (*) (char*))func);
+ activate_fileselect_(FILE_MAIN, "SELECT DATABLOCK", str, menup, NULL, NULL, func, NULL, NULL, NULL);
sfile= curarea->spacedata.first;
sfile->retval= retval;
sfile->ipotype= fromcode;
- sfile->menup= menup;
}
-void filesel_prevspace()
+void activate_databrowse_args(struct ID *id, int idcode, int fromcode, short *menup, void (*func)(char *, void *, void *), void *arg1, void *arg2)
{
+ ListBase *lb;
SpaceFile *sfile;
+ char str[32];
+
+ if(id==NULL) {
+ lb= wich_libbase(G.main, idcode);
+ id= lb->first;
+ }
+
+ if(id) BLI_strncpy(str, id->name, sizeof(str));
+ else return;
+
+ activate_fileselect_(FILE_MAIN, "SELECT DATABLOCK", str, menup, NULL, NULL, NULL, func, arg1, arg2);
sfile= curarea->spacedata.first;
+ sfile->ipotype= fromcode;
+}
+
+void filesel_prevspace()
+{
+ SpaceFile *sfile= curarea->spacedata.first;
+
+ /* cleanup */
+ if(sfile->spacetype==SPACE_FILE) {
+ if(sfile->menup)
+ sfile->menup= NULL;
+ if(sfile->pupmenu) {
+ MEM_freeN(sfile->pupmenu);
+ sfile->pupmenu= NULL;
+ }
+ }
+
if(sfile->next) {
BLI_remlink(&curarea->spacedata, sfile);
@@ -1527,11 +1588,11 @@ void free_filesel_spec(char *dir)
}
}
-
+/* NOTE: this is called for file read, after the execfunc no UI memory is valid! */
static void filesel_execute(SpaceFile *sfile)
{
struct direntry *files;
- char name[FILE_MAXDIR+FILE_MAXFILE];
+ char name[FILE_MAX];
int a;
filesel_prevspace();
@@ -1548,7 +1609,7 @@ static void filesel_execute(SpaceFile *sfile)
BIF_undo_push("Append from file");
allqueue(REDRAWALL, 1);
}
- else if(sfile->returnfunc) {
+ else if(filesel_has_func(sfile)) {
fsmenu_insert_entry(sfile->dir, 1);
if(sfile->type==FILE_MAIN) { /* DATABROWSE */
@@ -1593,7 +1654,10 @@ static void filesel_execute(SpaceFile *sfile)
}
}
}
- sfile->returnfunc((char*) (long)sfile->retval);
+ if(sfile->returnfunc_event)
+ sfile->returnfunc_event(sfile->retval);
+ else if(sfile->returnfunc_args)
+ sfile->returnfunc_args(NULL, sfile->arg1, sfile->arg2);
}
else {
if(strncmp(sfile->title, "Save", 4)==0) free_filesel_spec(sfile->dir);
@@ -1604,22 +1668,27 @@ static void filesel_execute(SpaceFile *sfile)
if(sfile->flag & FILE_STRINGCODE) {
if (!G.relbase_valid) {
- okee("You have to save the .blend file before using relative paths! Using absolute path instead.");
- sfile->flag &= ~FILE_STRINGCODE;
+ /* skip save */
+ if(strncmp(sfile->title, "Save", 4)) {
+ okee("You have to save the .blend file before using relative paths! Using absolute path instead.");
+ sfile->flag &= ~FILE_STRINGCODE;
+ }
}
else {
BLI_makestringcode(G.sce, name);
}
}
-
- sfile->returnfunc(name);
+ if(sfile->returnfunc)
+ sfile->returnfunc(name);
+ else if(sfile->returnfunc_args)
+ sfile->returnfunc_args(name, sfile->arg1, sfile->arg2);
}
}
}
static void do_filesel_buttons(short event, SpaceFile *sfile)
{
- char butname[FILE_MAXDIR+FILE_MAXFILE];
+ char butname[FILE_MAX];
if (event == B_FS_FILENAME) {
if (strchr(sfile->file, '*') || strchr(sfile->file, '?') || strchr(sfile->file, '[')) {
@@ -1864,7 +1933,7 @@ static void fs_fake_users(SpaceFile *sfile)
int a;
/* only for F4 DATABROWSE */
- if(sfile->returnfunc) return;
+ if(filesel_has_func(sfile)) return;
for(a=0; a<sfile->totfile; a++) {
if(sfile->filelist[a].flags & ACTIVE) {
@@ -1907,7 +1976,7 @@ void winqreadfilespace(ScrArea *sa, void *spacedata, BWinEvent *evt)
SpaceFile *sfile;
int act, do_draw= 0, i, test, ret = 0;
short qual, mval[2];
- char str[FILE_MAXDIR+FILE_MAXFILE+12];
+ char str[FILE_MAX+12];
sfile= curarea->spacedata.first;
if(sfile==0) return;
@@ -2297,7 +2366,7 @@ static int is_a_library(SpaceFile *sfile, char *dir, char *group)
static void do_library_append(SpaceFile *sfile)
{
Library *lib;
- char dir[FILE_MAXDIR+FILE_MAXFILE], group[32];
+ char dir[FILE_MAX], group[32];
if ( is_a_library(sfile, dir, group)==0 ) {
error("Not a library");
@@ -2344,8 +2413,8 @@ static void library_to_filelist(SpaceFile *sfile)
{
LinkNode *l, *names;
int ok, i, nnames, idcode;
- char filename[FILE_MAXDIR+FILE_MAXFILE];
- char dir[FILE_MAXDIR+FILE_MAXFILE], group[24];
+ char filename[FILE_MAX];
+ char dir[FILE_MAX], group[24];
/* name test */
ok= is_a_library(sfile, dir, group);
@@ -2420,7 +2489,7 @@ static void filesel_select_objects(SpaceFile *sfile)
int a;
/* only when F4 DATABROWSE */
- if(sfile->returnfunc) return;
+ if(filesel_has_func(sfile)) return;
if( strcmp(sfile->dir, "Object/")==0 ) {
for(a=0; a<sfile->totfile; a++) {
@@ -2462,7 +2531,7 @@ static void active_file_object(SpaceFile *sfile)
Object *ob;
/* only when F4 DATABROWSE */
- if(sfile->returnfunc) return;
+ if(filesel_has_func(sfile)) return;
if( strcmp(sfile->dir, "Object/")==0 ) {
if(sfile->act >= 0) {
@@ -2551,7 +2620,7 @@ void main_to_filelist(SpaceFile *sfile)
id= lb->first;
sfile->totfile= 0;
while(id) {
- if(sfile->returnfunc && idcode==ID_IP) {
+ if(filesel_has_func(sfile) && idcode==ID_IP) {
if(sfile->ipotype== ((Ipo *)id)->blocktype) sfile->totfile++;
}
else if (hide==0 || id->name[2] != '.')
@@ -2560,12 +2629,12 @@ void main_to_filelist(SpaceFile *sfile)
id= id->next;
}
- if(sfile->returnfunc==0) sfile->totfile+= 2;
+ if(!filesel_has_func(sfile)) sfile->totfile+= 2;
sfile->filelist= (struct direntry *)malloc(sfile->totfile * sizeof(struct direntry));
files= sfile->filelist;
- if(sfile->returnfunc==0) {
+ if(!filesel_has_func(sfile)) {
memset( &(sfile->filelist[0]), 0 , sizeof(struct direntry));
sfile->filelist[0].relname= BLI_strdup(".");
sfile->filelist[0].type |= S_IFDIR;
@@ -2582,7 +2651,7 @@ void main_to_filelist(SpaceFile *sfile)
while(id) {
ok= 0;
- if(sfile->returnfunc && idcode==ID_IP) {
+ if(filesel_has_func(sfile) && idcode==ID_IP) {
if(sfile->ipotype== ((Ipo *)id)->blocktype) ok= 1;
}
else ok= 1;
@@ -2594,14 +2663,14 @@ void main_to_filelist(SpaceFile *sfile)
if(id->lib==NULL)
files->relname= BLI_strdup(id->name+2);
else {
- char tmp[FILE_MAXDIR+FILE_MAXFILE], fi[FILE_MAXFILE];
- BLI_strncpy(tmp, id->lib->name, FILE_MAXDIR+FILE_MAXFILE);
+ char tmp[FILE_MAX], fi[FILE_MAXFILE];
+ BLI_strncpy(tmp, id->lib->name, FILE_MAX);
BLI_splitdirstring(tmp, fi);
files->relname= MEM_mallocN(FILE_MAXFILE+32, "filename for lib");
sprintf(files->relname, "%s / %s", fi, id->name+2);
}
- if(sfile->returnfunc==0) { /* F4 DATA BROWSE */
+ if(!filesel_has_func(sfile)) { /* F4 DATA BROWSE */
if(idcode==ID_OB) {
if( ((Object *)id)->flag & SELECT) files->flags |= ACTIVE;
}
@@ -2646,7 +2715,7 @@ void main_to_filelist(SpaceFile *sfile)
if( strcmp(sfile->file, sfile->filelist[a].relname)==0) {
sfile->ofs= a-( sfile->collums*(curarea->winy-FILESELHEAD-10)/(2*FILESEL_DY));
filetoname= 0;
- if(sfile->returnfunc) sfile->filelist[a].flags |= ACTIVE;
+ if(filesel_has_func(sfile)) sfile->filelist[a].flags |= ACTIVE;
}
}
}
@@ -2656,9 +2725,9 @@ void main_to_filelist(SpaceFile *sfile)
void clever_numbuts_filesel()
{
SpaceFile *sfile;
- char orgname[FILE_MAXDIR+FILE_MAXFILE+12];
- char filename[FILE_MAXDIR+FILE_MAXFILE+12];
- char newname[FILE_MAXDIR+FILE_MAXFILE+12];
+ char orgname[FILE_MAX+12];
+ char filename[FILE_MAX+12];
+ char newname[FILE_MAX+12];
int test;
int len;
diff --git a/source/blender/src/header_filesel.c b/source/blender/src/header_filesel.c
index 4e7c94e7181..189cf8dab17 100644
--- a/source/blender/src/header_filesel.c
+++ b/source/blender/src/header_filesel.c
@@ -127,6 +127,10 @@ void file_buttons(void)
xcotitle= xco;
xco+= BIF_GetStringWidth(G.font, sfile->title, (U.transopts & USER_TR_BUTTONS));
+ if(sfile->pupmenu && sfile->menup) {
+ uiDefButS(block, MENU, B_NOP, sfile->pupmenu, xco+10,0,90,20, sfile->menup, 0, 0, 0, 0, "");
+ xco+= 100;
+ }
uiBlockBeginAlign(block);
uiDefIconButBitS(block, ICONTOG, FILE_SHOWSHORT, B_SORTFILELIST, ICON_LONGDISPLAY,xco+=XIC,0,XIC,YIC, &sfile->flag, 0, 0, 0, 0, "Toggles long info");
uiDefIconButBitS(block, TOG, FILE_HIDE_DOT, B_RELOADDIR, ICON_GHOST,xco+=XIC,0,XIC,YIC, &sfile->flag, 0, 0, 0, 0, "Hides dot files");
diff --git a/source/blender/src/header_image.c b/source/blender/src/header_image.c
index 5e162b9a22e..d1bfcdbe125 100644
--- a/source/blender/src/header_image.c
+++ b/source/blender/src/header_image.c
@@ -42,21 +42,28 @@
#include <config.h>
#endif
+#include "DNA_brush_types.h"
#include "DNA_ID.h"
#include "DNA_image_types.h"
#include "DNA_scene_types.h"
#include "DNA_screen_types.h"
#include "DNA_space_types.h"
+#include "DNA_texture_types.h"
#include "DNA_userdef_types.h"
+#include "BLI_blenlib.h"
+
#include "BDR_drawmesh.h"
#include "BDR_unwrapper.h"
#include "BKE_brush.h"
+#include "BKE_colortools.h"
#include "BKE_global.h"
#include "BKE_image.h"
#include "BKE_main.h"
+#include "BKE_utildefines.h"
+#include "BIF_butspace.h"
#include "BIF_drawimage.h"
#include "BIF_editsima.h"
#include "BIF_interface.h"
@@ -64,26 +71,38 @@
#include "BIF_screen.h"
#include "BIF_space.h"
#include "BIF_transform.h"
+#include "BIF_toolbox.h"
+#include "BSE_drawview.h"
#include "BSE_filesel.h"
#include "BSE_headerbuttons.h"
+#include "BSE_trans_types.h"
#include "BPY_extern.h"
#include "BPY_menus.h"
#include "IMB_imbuf_types.h"
-#include "BSE_trans_types.h"
+
+#include "RE_pipeline.h"
#include "blendef.h"
+#include "butspace.h"
#include "mydevice.h"
void do_image_buttons(unsigned short event)
{
+ ToolSettings *settings= G.scene->toolsettings;
ID *id, *idtest;
int nr;
if(curarea->win==0) return;
+ if(event<=100) {
+ if(event<=50) do_global_buttons2(event);
+ else do_global_buttons(event);
+ return;
+ }
+
switch(event) {
case B_SIMAGEHOME:
image_home();
@@ -100,21 +119,15 @@ void do_image_buttons(unsigned short event)
nr= 1;
id= (ID *)G.sima->image;
- idtest= G.main->image.first;
- while(idtest) {
- if(nr==G.sima->imanr) {
- break;
- }
- nr++;
- idtest= idtest->next;
- }
- if(idtest==0) { /* no new */
+ idtest= BLI_findlink(&G.main->image, G.sima->imanr-1);
+ if(idtest==NULL) { /* no new */
return;
}
if(idtest!=id) {
G.sima->image= (Image *)idtest;
if(idtest->us==0) idtest->us= 1;
+ BKE_image_signal(G.sima->image, &G.sima->iuser, IMA_SIGNAL_USER_NEW_IMAGE);
allqueue(REDRAWIMAGE, 0);
}
/* also when image is the same: assign! 0==no tileflag: */
@@ -128,10 +141,15 @@ void do_image_buttons(unsigned short event)
make_repbind(G.sima->image);
image_changed(G.sima, 1);
}
+ /* XXX might be another event needed for this? */
+ if(G.sima->image)
+ if(ELEM(G.sima->image->source, IMA_SRC_MOVIE, IMA_SRC_SEQUENCE))
+ if(G.sima->iuser.flag & IMA_ANIM_ALWAYS)
+ BKE_image_user_calc_imanr(&G.sima->iuser, G.scene->r.cfra, 0);
allqueue(REDRAWVIEW3D, 0);
allqueue(REDRAWIMAGE, 0);
break;
-
+
case B_SIMAGEDRAW1:
image_changed(G.sima, 2); /* 2: only tileflag */
allqueue(REDRAWVIEW3D, 0);
@@ -150,6 +168,11 @@ void do_image_buttons(unsigned short event)
pack_image_sima();
break;
+ case B_SIMA_REPACK:
+ BKE_image_memorypack(G.sima->image);
+ allqueue(REDRAWIMAGE, 0);
+ break;
+
case B_SIMA_USE_ALPHA:
G.sima->flag &= ~(SI_SHOW_ALPHA|SI_SHOW_ZBUF);
scrarea_queue_winredraw(curarea);
@@ -165,6 +188,157 @@ void do_image_buttons(unsigned short event)
scrarea_queue_winredraw(curarea);
scrarea_queue_headredraw(curarea);
break;
+ case B_SIMARELOAD:
+ reload_image_sima();
+ break;
+ case B_SIMAGELOAD:
+ open_image_sima(0);
+ break;
+ case B_SIMANAME:
+ if(G.sima->image) {
+ Image *ima;
+ char str[FILE_MAXDIR+FILE_MAXFILE];
+
+ /* name in ima has been changed by button! */
+ BLI_strncpy(str, G.sima->image->name, sizeof(str));
+ ima= BKE_add_image_file(str);
+ if(ima) {
+
+ G.sima->image= ima;
+
+ BKE_image_signal(ima, &G.sima->iuser, IMA_SIGNAL_RELOAD);
+ image_changed(G.sima, 0);
+
+ }
+ BIF_undo_push("Load image");
+ allqueue(REDRAWIMAGE, 0);
+ }
+ break;
+ case B_SIMAMULTI:
+ if(G.sima && G.sima->image) {
+ BKE_image_multilayer_index(G.sima->image->rr, &G.sima->iuser);
+ allqueue(REDRAWIMAGE, 0);
+ }
+ break;
+ case B_TRANS_IMAGE:
+ image_editvertex_buts(NULL);
+ break;
+
+ case B_TWINANIM:
+ {
+ Image *ima;
+ int nr;
+
+ ima = G.sima->image;
+ if (ima) {
+ if(ima->flag & IMA_TWINANIM) {
+ nr= ima->xrep*ima->yrep;
+ if(ima->twsta>=nr) ima->twsta= 1;
+ if(ima->twend>=nr) ima->twend= nr-1;
+ if(ima->twsta>ima->twend) ima->twsta= 1;
+ allqueue(REDRAWIMAGE, 0);
+ }
+ }
+ break;
+ }
+ case B_SIMACLONEBROWSE:
+ if (settings->imapaint.brush)
+ if (brush_clone_image_set_nr(settings->imapaint.brush, G.sima->menunr))
+ allqueue(REDRAWIMAGE, 0);
+ break;
+
+ case B_SIMACLONEDELETE:
+ if (settings->imapaint.brush)
+ if (brush_clone_image_delete(settings->imapaint.brush))
+ allqueue(REDRAWIMAGE, 0);
+ break;
+
+ case B_SIMABRUSHCHANGE:
+ allqueue(REDRAWIMAGE, 0);
+ allqueue(REDRAWBUTSEDIT, 0);
+ break;
+
+ case B_SIMACURVES:
+ curvemapping_do_ibuf(G.sima->cumap, BKE_image_get_ibuf(G.sima->image, &G.sima->iuser));
+ allqueue(REDRAWIMAGE, 0);
+ break;
+
+ case B_SIMARANGE:
+ curvemapping_set_black_white(G.sima->cumap, NULL, NULL);
+ curvemapping_do_ibuf(G.sima->cumap, BKE_image_get_ibuf(G.sima->image, &G.sima->iuser));
+ allqueue(REDRAWIMAGE, 0);
+ break;
+
+ case B_SIMABRUSHBROWSE:
+ if(G.sima->menunr==-2) {
+ activate_databrowse((ID*)settings->imapaint.brush, ID_BR, 0, B_SIMABRUSHBROWSE, &G.sima->menunr, do_global_buttons);
+ break;
+ }
+ else if(G.sima->menunr < 0) break;
+
+ if(brush_set_nr(&settings->imapaint.brush, G.sima->menunr)) {
+ BIF_undo_push("Browse Brush");
+ allqueue(REDRAWBUTSEDIT, 0);
+ allqueue(REDRAWIMAGE, 0);
+ }
+ break;
+ case B_SIMABRUSHDELETE:
+ if(brush_delete(&settings->imapaint.brush)) {
+ BIF_undo_push("Unlink Brush");
+ allqueue(REDRAWIMAGE, 0);
+ allqueue(REDRAWBUTSEDIT, 0);
+ }
+ break;
+ case B_KEEPDATA:
+ brush_toggle_fake_user(settings->imapaint.brush);
+ allqueue(REDRAWIMAGE, 0);
+ allqueue(REDRAWBUTSEDIT, 0);
+ break;
+ case B_SIMABRUSHLOCAL:
+ if(settings->imapaint.brush && settings->imapaint.brush->id.lib) {
+ if(okee("Make local")) {
+ make_local_brush(settings->imapaint.brush);
+ allqueue(REDRAWIMAGE, 0);
+ allqueue(REDRAWBUTSEDIT, 0);
+ }
+ }
+ break;
+ case B_SIMABTEXBROWSE:
+ if(settings->imapaint.brush) {
+ Brush *brush= settings->imapaint.brush;
+
+ if(G.sima->menunr==-2) {
+ MTex *mtex= brush->mtex[brush->texact];
+ ID *id= (ID*)((mtex)? mtex->tex: NULL);
+ activate_databrowse(id, ID_TE, 0, B_SIMABTEXBROWSE, &G.sima->menunr, do_global_buttons);
+ break;
+ }
+ else if(G.sima->menunr < 0) break;
+
+ if(brush_texture_set_nr(brush, G.sima->menunr)) {
+ BIF_undo_push("Browse Brush Texture");
+ allqueue(REDRAWBUTSSHADING, 0);
+ allqueue(REDRAWBUTSEDIT, 0);
+ allqueue(REDRAWIMAGE, 0);
+ }
+ }
+ break;
+ case B_SIMABTEXDELETE:
+ if(settings->imapaint.brush) {
+ if (brush_texture_delete(settings->imapaint.brush)) {
+ BIF_undo_push("Unlink Brush Texture");
+ allqueue(REDRAWBUTSSHADING, 0);
+ allqueue(REDRAWBUTSEDIT, 0);
+ allqueue(REDRAWIMAGE, 0);
+ }
+ }
+ break;
+ case B_SIMA_PLAY:
+ play_anim(0);
+ break;
+ case B_SIMA_RECORD:
+ imagespace_composite_flipbook(curarea);
+ break;
}
}
@@ -498,11 +672,19 @@ static void do_image_imagemenu(void *arg, int event)
case 8:
save_image_sima();
break;
+ case 9:
+ save_image_sequence_sima();
+ break;
+ case 10:
+ BKE_image_memorypack(G.sima->image);
+ allqueue(REDRAWIMAGE, 0);
+ break;
}
}
static uiBlock *image_imagemenu(void *arg_unused)
{
+ ImBuf *ibuf= BKE_image_get_ibuf(G.sima->image, &G.sima->iuser);
uiBlock *block;
short yco= 0, menuwidth=150;
BPyMenu *pym;
@@ -519,8 +701,10 @@ static uiBlock *image_imagemenu(void *arg_unused)
uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Reload|Alt R", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 6, "");
uiDefBut(block, SEPR, 0, "", 0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, "");
- uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Save|Alt S", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 5, "");
+ uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Save|Alt S", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 8, "");
uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Save As...", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 5, "");
+ if(G.sima->image->source==IMA_SRC_SEQUENCE)
+ uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Save Changed Images", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 9, "");
uiDefBut(block, SEPR, 0, "", 0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, "");
if (G.sima->image->packedfile) {
@@ -528,7 +712,13 @@ static uiBlock *image_imagemenu(void *arg_unused)
} else {
uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Pack Image", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 2, "");
}
-
+
+ /* only for dirty && specific image types */
+ if(ibuf && (ibuf->userflags & IB_BITMAPDIRTY))
+ if( ELEM(G.sima->image->source, IMA_SRC_FILE, IMA_SRC_GENERATED))
+ if(G.sima->image->type!=IMA_TYPE_MULTILAYER)
+ uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Pack Image as PNG", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 10, "");
+
uiDefBut(block, SEPR, 0, "", 0, yco-=7, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, "");
if(G.sima->flag & SI_DRAWTOOL) {
@@ -877,12 +1067,13 @@ static uiBlock *image_uvsmenu(void *arg_unused)
void image_buttons(void)
{
+ Image *ima= G.sima->image;
+ ImBuf *ibuf= BKE_image_get_ibuf(ima, &G.sima->iuser);
uiBlock *block;
short xco, xmax;
char naam[256], *menuname;
/* This should not be a static var */
static int headerbuttons_packdummy;
- Image *ima= G.sima->image;
headerbuttons_packdummy = 0;
@@ -914,6 +1105,7 @@ void image_buttons(void)
xco+=XIC;
if((curarea->flag & HEADER_NO_PULLDOWN)==0) {
+
/* pull down menus */
uiBlockSetEmboss(block, UI_EMBOSSP);
@@ -927,7 +1119,7 @@ void image_buttons(void)
xco+= xmax;
}
- if (ima && ima->ibuf && (ima->ibuf->userflags & IB_BITMAPDIRTY))
+ if (ibuf && (ibuf->userflags & IB_BITMAPDIRTY))
menuname= "Image*";
else
menuname= "Image";
@@ -948,29 +1140,57 @@ void image_buttons(void)
xco= std_libbuttons(block, xco, 0, 0, NULL, B_SIMABROWSE, ID_IM, 0, (ID *)ima, 0, &(G.sima->imanr), 0, 0, B_IMAGEDELETE, 0, 0);
if (ima) {
+ RenderResult *rr= BKE_image_get_renderresult(ima);
+
xco+= 8;
- if (ima->packedfile) {
- headerbuttons_packdummy = 1;
+ if(rr) {
+ uiBlockBeginAlign(block);
+ uiblock_layer_pass_buttons(block, rr, &G.sima->iuser, B_REDR, xco, 0, 160);
+ uiBlockEndAlign(block);
+ xco+= 166;
}
- uiDefIconButBitI(block, TOG, 1, B_SIMAPACKIMA, ICON_PACKAGE, xco,0,XIC,YIC, &headerbuttons_packdummy, 0, 0, 0, 0, "Pack/Unpack this image");
- xco+= XIC+8;
+ if( !ELEM3(ima->source, IMA_SRC_SEQUENCE, IMA_SRC_MOVIE, IMA_SRC_VIEWER) && ima->ok) {
+ if (ima->packedfile) {
+ headerbuttons_packdummy = 1;
+ }
+ if (ima->packedfile && (ibuf->userflags & IB_BITMAPDIRTY))
+ uiDefIconButBitI(block, TOG, 1, B_SIMA_REPACK, ICON_UGLYPACKAGE, xco,0,XIC,YIC, &headerbuttons_packdummy, 0, 0, 0, 0, "Re-Pack this image as PNG");
+ else
+ uiDefIconButBitI(block, TOG, 1, B_SIMAPACKIMA, ICON_PACKAGE, xco,0,XIC,YIC, &headerbuttons_packdummy, 0, 0, 0, 0, "Pack/Unpack this image");
+
+ xco+= XIC+8;
+ }
+
uiDefIconButBitI(block, TOG, SI_DRAWTOOL, B_SIMAGEPAINTTOOL, ICON_TPAINT_HLT, xco,0,XIC,YIC, &G.sima->flag, 0, 0, 0, 0, "Enables painting textures on the image with left mouse button");
xco+= XIC+8;
uiBlockBeginAlign(block);
- uiDefIconButBitI(block, TOG, SI_USE_ALPHA, B_SIMA_USE_ALPHA, ICON_TRANSP_HLT, xco,0,XIC,YIC, &G.sima->flag, 0, 0, 0, 0, "Draws image with alpha");
- xco+= XIC;
- uiDefIconButBitI(block, TOG, SI_SHOW_ALPHA, B_SIMA_SHOW_ALPHA, ICON_DOT, xco,0,XIC,YIC, &G.sima->flag, 0, 0, 0, 0, "Draws only alpha");
- xco+= XIC;
- if(ima->ibuf) {
- if(ima->ibuf->zbuf || ima->ibuf->zbuf_float) {
+ if(ibuf==NULL || ibuf->channels==4) {
+ uiDefIconButBitI(block, TOG, SI_USE_ALPHA, B_SIMA_USE_ALPHA, ICON_TRANSP_HLT, xco,0,XIC,YIC, &G.sima->flag, 0, 0, 0, 0, "Draws image with alpha");
+ xco+= XIC;
+ uiDefIconButBitI(block, TOG, SI_SHOW_ALPHA, B_SIMA_SHOW_ALPHA, ICON_DOT, xco,0,XIC,YIC, &G.sima->flag, 0, 0, 0, 0, "Draws only alpha");
+ xco+= XIC;
+ }
+ if(ibuf) {
+ if(ibuf->zbuf || ibuf->zbuf_float || (ibuf->channels==1)) {
uiDefIconButBitI(block, TOG, SI_SHOW_ZBUF, B_SIMA_SHOW_ZBUF, ICON_SOLID, xco,0,XIC,YIC, &G.sima->flag, 0, 0, 0, 0, "Draws zbuffer values");
xco+= XIC;
}
else G.sima->flag &= ~SI_SHOW_ZBUF; /* no confusing display for non-zbuf images */
}
+ xco+= 8;
+
+ uiBlockBeginAlign(block);
+ if(ima->type==IMA_TYPE_COMPOSITE) {
+ uiDefIconBut(block, BUT, B_SIMA_RECORD, ICON_REC, xco, 0, XIC, YIC, 0, 0, 0, 0, 0, "Record Composite");
+ xco+= XIC;
+ }
+ if((ima->type==IMA_TYPE_COMPOSITE) || ELEM(G.sima->image->source, IMA_SRC_MOVIE, IMA_SRC_SEQUENCE)) {
+ uiDefIconBut(block, BUT, B_SIMA_PLAY, ICON_PLAY, xco, 0, XIC, YIC, 0, 0, 0, 0, 0, "Play");
+ xco+= XIC;
+ }
uiBlockEndAlign(block);
xco+= 8;
}
diff --git a/source/blender/src/header_info.c b/source/blender/src/header_info.c
index d6c217534bb..03eed300520 100644
--- a/source/blender/src/header_info.c
+++ b/source/blender/src/header_info.c
@@ -529,15 +529,16 @@ static void check_packAll()
// first check for dirty images
Image *ima;
- ima = G.main->image.first;
- while (ima) {
- if (ima->ibuf && (ima->ibuf->userflags &= IB_BITMAPDIRTY)) {
- break;
- }
- ima= ima->id.next;
+ for(ima = G.main->image.first; ima; ima= ima->id.next) {
+ if (ima->ibufs.first) { /* XXX FIX */
+ ImBuf *ibuf= BKE_image_get_ibuf(ima, NULL);
+
+ if (ibuf && (ibuf->userflags &= IB_BITMAPDIRTY))
+ break;
}
+ }
- if (ima == 0 || okee("Some images are painted on. These changes will be lost. Continue ?")) {
+ if (ima == NULL || okee("Some images are painted on. These changes will be lost. Continue ?")) {
packAll();
G.fileflags |= G_AUTOPACK;
}
@@ -852,7 +853,7 @@ static void do_info_filemenu(void *arg, int event)
}
break;
case 6: /* save image */
- BIF_save_rendered_image_fs(0);
+ BIF_save_rendered_image_fs();
break;
case 22: /* save runtime */
activate_fileselect(FILE_SPECIAL, "Save Runtime", "", write_runtime_check);
diff --git a/source/blender/src/header_node.c b/source/blender/src/header_node.c
index a873f779b34..f32dbf0e760 100644
--- a/source/blender/src/header_node.c
+++ b/source/blender/src/header_node.c
@@ -490,6 +490,9 @@ static void do_node_nodemenu(void *arg, int event)
case 9: /* show cyclic */
ntreeSolveOrder(snode->edittree);
break;
+ case 10: /* execute */
+ addqueue(curarea->win, UI_BUT_EVENT, B_NODE_TREE_EXEC);
+ break;
}
if(fromlib==-1) error("Can't edit Library Data");
@@ -525,8 +528,10 @@ static uiBlock *node_nodemenu(void *arg_unused)
uiDefBut(block, SEPR, 0, "", 0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, "");
- if(snode->treetype==NTREE_COMPOSIT)
+ if(snode->treetype==NTREE_COMPOSIT) {
+ uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Execute Composite|E", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 10, "");
uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Read Saved Render Results|R", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 8, "");
+ }
uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Show Cyclic Dependencies|C", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 9, "");
if(curarea->headertype==HEADERTOP) {
diff --git a/source/blender/src/header_time.c b/source/blender/src/header_time.c
index c018812e38b..968a34d1dbc 100644
--- a/source/blender/src/header_time.c
+++ b/source/blender/src/header_time.c
@@ -154,6 +154,10 @@ static uiBlock *time_redrawmenu(void *arg_unused)
else icon= ICON_CHECKBOX_DEHLT;
uiDefIconTextBut(block, BUTM, 1, icon, "Buttons Windows", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, TIME_ALL_BUTS_WIN, "");
+ if(stime->redraws & TIME_ALL_IMAGE_WIN) icon= ICON_CHECKBOX_HLT;
+ else icon= ICON_CHECKBOX_DEHLT;
+ uiDefIconTextBut(block, BUTM, 1, icon, "Image Windows", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, TIME_ALL_IMAGE_WIN, "");
+
/* Add sequencer only redraw*/
if(stime->redraws & TIME_SEQ) icon= ICON_CHECKBOX_HLT;
else icon= ICON_CHECKBOX_DEHLT;
diff --git a/source/blender/src/headerbuttons.c b/source/blender/src/headerbuttons.c
index 1837ae2e384..7b283427492 100644
--- a/source/blender/src/headerbuttons.c
+++ b/source/blender/src/headerbuttons.c
@@ -279,6 +279,8 @@ int std_libbuttons(uiBlock *block, short xco, short yco,
if (lb) {
if( id_code==ID_IP)
IPOnames_to_pupstring(&str, NULL, extrastr, lb, id, menupoin, G.sipo->blocktype);
+ else if(browse!=B_SIMABROWSE && id_code==ID_IM )
+ IMAnames_to_pupstring(&str, NULL, extrastr, lb, id, menupoin);
else
IDnames_to_pupstring(&str, NULL, extrastr, lb, id, menupoin);
}
@@ -411,9 +413,12 @@ static void do_update_for_newframe(int mute, int events)
/* this function applies the changes too */
scene_update_for_newframe(G.scene, screen_view3d_layers()); /* BKE_scene.h */
- if ( (CFRA>1) && (!mute) && (G.scene->audio.flag & AUDIO_SCRUB)) audiostream_scrub( CFRA );
+ if ( (CFRA>1) && (!mute) && (G.scene->audio.flag & AUDIO_SCRUB))
+ audiostream_scrub( CFRA );
+
BIF_view3d_previewrender_signal(curarea, PR_DBASE|PR_DISPRECT);
+ BIF_image_update_frame();
}
void update_for_newframe(void)
@@ -573,7 +578,7 @@ void do_global_buttons(unsigned short event)
ScrArea *sa;
Brush *br;
int nr= 1;
- char buf[FILE_MAXDIR+FILE_MAXFILE];
+ char buf[FILE_MAX];
ob= OBACT;
@@ -1518,8 +1523,8 @@ void do_global_buttons(unsigned short event)
allqueue(REDRAWNLA, 1);
/* name scene also in set PUPmenu */
allqueue(REDRAWBUTSALL, 0);
+ allqueue(REDRAWIMAGE, 0);
allqueue(REDRAWHEADERS, 0);
-
break;
case B_KEEPDATA:
diff --git a/source/blender/src/imagepaint.c b/source/blender/src/imagepaint.c
index 21573ba0a11..3724aaf43a0 100644
--- a/source/blender/src/imagepaint.c
+++ b/source/blender/src/imagepaint.c
@@ -56,6 +56,7 @@
#include "DNA_image_types.h"
#include "DNA_mesh_types.h"
#include "DNA_meshdata_types.h"
+#include "DNA_node_types.h"
#include "DNA_object_types.h"
#include "DNA_scene_types.h"
#include "DNA_screen_types.h"
@@ -65,7 +66,9 @@
#include "BKE_brush.h"
#include "BKE_global.h"
+#include "BKE_image.h"
#include "BKE_mesh.h"
+#include "BKE_node.h"
#include "BKE_utildefines.h"
#include "BIF_mywindow.h"
@@ -74,6 +77,7 @@
#include "BIF_toolbox.h"
#include "BSE_drawipo.h"
+#include "BSE_node.h"
#include "BSE_trans_types.h"
#include "BSE_view.h"
@@ -84,6 +88,7 @@
#include "GHOST_Types.h"
#include "blendef.h"
+#include "butspace.h"
#include "mydevice.h"
/* Defines and Structs */
@@ -109,6 +114,7 @@ typedef struct ImagePaintState {
ImBuf *clonecanvas;
short clonefreefloat;
char *warnpackedfile;
+ char *warnmultifile;
/* texture paint only */
Object *ob;
@@ -132,21 +138,21 @@ typedef struct ImagePaintPartialRedraw {
static ImagePaintUndo imapaintundo = {NULL, NULL, NULL, 0, 0};
static ImagePaintPartialRedraw imapaintpartial = {0, 0, 0, 0, 0};
-static void init_imagapaint_undo(Image *ima)
+static void init_imagapaint_undo(Image *ima, ImBuf *ibuf)
{
int xt, yt;
imapaintundo.image = ima;
- imapaintundo.xtiles = xt = IMAPAINT_TILE_NUMBER(ima->ibuf->x);
- imapaintundo.ytiles = yt = IMAPAINT_TILE_NUMBER(ima->ibuf->y);
+ imapaintundo.xtiles = xt = IMAPAINT_TILE_NUMBER(ibuf->x);
+ imapaintundo.ytiles = yt = IMAPAINT_TILE_NUMBER(ibuf->y);
imapaintundo.tiles = MEM_callocN(sizeof(void*)*xt*yt, "ImagePaintUndoTiles");
imapaintundo.tilebuf = IMB_allocImBuf(IMAPAINT_TILE_SIZE, IMAPAINT_TILE_SIZE,
- ima->ibuf->depth, (ima->ibuf->rect_float)? IB_rectfloat: IB_rect, 0);
+ ibuf->depth, (ibuf->rect_float)? IB_rectfloat: IB_rect, 0);
}
-static void imapaint_copy_tile(Image *ima, int tile, int x, int y, int swapundo)
+static void imapaint_copy_tile(ImBuf *ibuf, int tile, int x, int y, int swapundo)
{
- IMB_rectcpy(imapaintundo.tilebuf, ima->ibuf, 0, 0, x*IMAPAINT_TILE_SIZE,
+ IMB_rectcpy(imapaintundo.tilebuf, ibuf, 0, 0, x*IMAPAINT_TILE_SIZE,
y*IMAPAINT_TILE_SIZE, IMAPAINT_TILE_SIZE, IMAPAINT_TILE_SIZE);
if (imapaintundo.tilebuf->rect_float)
@@ -155,7 +161,7 @@ static void imapaint_copy_tile(Image *ima, int tile, int x, int y, int swapundo)
SWAP(void*, imapaintundo.tilebuf->rect, imapaintundo.tiles[tile])
if (swapundo)
- IMB_rectcpy(ima->ibuf, imapaintundo.tilebuf, x*IMAPAINT_TILE_SIZE,
+ IMB_rectcpy(ibuf, imapaintundo.tilebuf, x*IMAPAINT_TILE_SIZE,
y*IMAPAINT_TILE_SIZE, 0, 0, IMAPAINT_TILE_SIZE, IMAPAINT_TILE_SIZE);
}
@@ -164,11 +170,11 @@ static void imapaint_clear_partial_redraw()
memset(&imapaintpartial, 0, sizeof(imapaintpartial));
}
-static void imapaint_dirty_region(Image *ima, int x, int y, int w, int h)
+static void imapaint_dirty_region(Image *ima, ImBuf *ibuf, int x, int y, int w, int h)
{
int srcx= 0, srcy= 0, origx, tile, allocsize;
- IMB_rectclip(ima->ibuf, NULL, &x, &y, &srcx, &srcy, &w, &h);
+ IMB_rectclip(ibuf, NULL, &x, &y, &srcx, &srcy, &w, &h);
if (w == 0 || h == 0)
return;
@@ -196,27 +202,29 @@ static void imapaint_dirty_region(Image *ima, int x, int y, int w, int h)
for (x=origx; x <= w; x++) {
if (ima != imapaintundo.image) {
free_imagepaint();
- init_imagapaint_undo(ima);
+ init_imagapaint_undo(ima, ibuf);
}
tile = y*imapaintundo.xtiles + x;
if (!imapaintundo.tiles[tile]) {
- allocsize= (ima->ibuf->rect_float)? sizeof(float): sizeof(char);
+ allocsize= (ibuf->rect_float)? sizeof(float): sizeof(char);
imapaintundo.tiles[tile]= MEM_mapallocN(allocsize*4*
IMAPAINT_TILE_SIZE*IMAPAINT_TILE_SIZE, "ImagePaintUndoTile");
- imapaint_copy_tile(ima, tile, x, y, 0);
+ imapaint_copy_tile(ibuf, tile, x, y, 0);
}
}
}
- ima->ibuf->userflags |= IB_BITMAPDIRTY;
+ ibuf->userflags |= IB_BITMAPDIRTY;
}
-static void imapaint_image_update(Image *image, short texpaint)
+static void imapaint_image_update(Image *image, ImBuf *ibuf, short texpaint)
{
- if(image->ibuf->rect_float)
- imb_freerectImBuf(image->ibuf); /* force recreate of char rect */
-
+ if(ibuf->rect_float)
+ imb_freerectImBuf(ibuf); /* force recreate of char rect */
+ if(ibuf->mipmap[0])
+ imb_freemipmapImBuf(ibuf);
+
/* todo: should set_tpage create ->rect? */
if(texpaint || G.sima->lock) {
int w = imapaintpartial.x2 - imapaintpartial.x1;
@@ -236,6 +244,24 @@ static void imapaint_redraw(int final, int texpaint, Image *image)
allqueue(REDRAWVIEW3D, 0);
}
allqueue(REDRAWHEADERS, 0);
+
+ /* after paint, tag Image or RenderResult nodes changed */
+ if(G.scene->nodetree) {
+ imagepaint_composite_tags(G.scene->nodetree, image, &G.sima->iuser);
+ }
+ /* signal composite (hurmf, need an allqueue?) */
+ if(G.sima->lock) {
+ ScrArea *sa;
+ for(sa=G.curscreen->areabase.first; sa; sa= sa->next) {
+ if(sa->spacetype==SPACE_NODE) {
+ if(((SpaceNode *)sa->spacedata.first)->treetype==NTREE_COMPOSIT) {
+ addqueue(sa->win, UI_BUT_EVENT, B_NODE_TREE_EXEC);
+ break;
+ }
+ }
+ }
+ }
+
}
else if(!texpaint && G.sima->lock)
force_draw_plus(SPACE_VIEW3D, 0);
@@ -245,20 +271,21 @@ static void imapaint_redraw(int final, int texpaint, Image *image)
void imagepaint_undo()
{
- int x, y, tile;
Image *ima= imapaintundo.image;
+ ImBuf *ibuf= BKE_image_get_ibuf(ima, &G.sima->iuser);
+ int x, y, tile;
- if (!ima || !ima->ibuf || !(ima->ibuf->rect || ima->ibuf->rect_float))
+ if (!ima || !ibuf || !(ibuf->rect || ibuf->rect_float))
return;
for (tile = 0, y = 0; y < imapaintundo.ytiles; y++)
for (x = 0; x < imapaintundo.xtiles; x++, tile++)
if (imapaintundo.tiles[tile])
- imapaint_copy_tile(ima, tile, x, y, 1);
+ imapaint_copy_tile(ibuf, tile, x, y, 1);
free_realtime_image(ima); /* force OpenGL reload */
- if(ima->ibuf->rect_float)
- imb_freerectImBuf(ima->ibuf); /* force recreate of char rect */
+ if(ibuf->rect_float)
+ imb_freerectImBuf(ibuf); /* force recreate of char rect */
allqueue(REDRAWIMAGE, 0);
allqueue(REDRAWVIEW3D, 0);
@@ -435,7 +462,7 @@ static int imapaint_paint_op(void *state, ImBuf *ibufb, float *lastpos, float *p
clonebuf= imapaint_lift_clone(s->clonecanvas, ibufb, bliftpos);
}
- imapaint_dirty_region(s->image, bpos[0], bpos[1], ibufb->x, ibufb->y);
+ imapaint_dirty_region(s->image, s->canvas, bpos[0], bpos[1], ibufb->x, ibufb->y);
/* blend into canvas */
if(torus)
@@ -479,26 +506,32 @@ static int texpaint_break_stroke(float *prevuv, float *fwuv, float *bkuv, float
static int imapaint_canvas_set(ImagePaintState *s, Image *ima)
{
+ ImBuf *ibuf= BKE_image_get_ibuf(ima, &G.sima->iuser);
+
/* verify that we can paint and set canvas */
- if(ima->packedfile) {
+ if(ima->packedfile && ima->rr) {
s->warnpackedfile = ima->id.name + 2;
return 0;
- }
- else if(!ima || !ima->ibuf || !(ima->ibuf->rect || ima->ibuf->rect_float))
+ }
+ else if(ibuf && ibuf->channels!=4) {
+ s->warnmultifile = ima->id.name + 2;
return 0;
- else if(ima->packedfile)
+ }
+ else if(!ima || !ibuf || !(ibuf->rect || ibuf->rect_float))
return 0;
s->image= ima;
- s->canvas= ima->ibuf;
+ s->canvas= ibuf;
/* set clone canvas */
if(s->tool == PAINT_TOOL_CLONE) {
ima= s->brush->clone.image;
- if(!ima || !ima->ibuf || !(ima->ibuf->rect || ima->ibuf->rect_float))
+ ibuf= BKE_image_get_ibuf(ima, &G.sima->iuser);
+
+ if(!ima || !ibuf || !(ibuf->rect || ibuf->rect_float))
return 0;
- s->clonecanvas= ima->ibuf;
+ s->clonecanvas= ibuf;
if(s->canvas->rect_float && !s->clonecanvas->rect_float) {
/* temporarily add float rect for cloning */
@@ -520,16 +553,17 @@ static void imapaint_canvas_free(ImagePaintState *s)
static int imapaint_paint_sub_stroke(ImagePaintState *s, BrushPainter *painter, Image *image, short texpaint, float *uv, double time, int update, float pressure)
{
+ ImBuf *ibuf= BKE_image_get_ibuf(image, &G.sima->iuser);
float pos[2];
- pos[0] = uv[0]*image->ibuf->x;
- pos[1] = uv[1]*image->ibuf->y;
+ pos[0] = uv[0]*ibuf->x;
+ pos[1] = uv[1]*ibuf->y;
- brush_painter_require_imbuf(painter, ((image->ibuf->rect_float)? 1: 0), 0, 0);
+ brush_painter_require_imbuf(painter, ((ibuf->rect_float)? 1: 0), 0, 0);
if (brush_painter_paint(painter, imapaint_paint_op, pos, time, pressure, s)) {
if (update)
- imapaint_image_update(image, texpaint);
+ imapaint_image_update(image, ibuf, texpaint);
return 1;
}
else return 0;
@@ -546,8 +580,12 @@ static void imapaint_paint_stroke(ImagePaintState *s, BrushPainter *painter, sho
/* pick new face and image */
if (facesel_face_pick(s->me, mval, &newfaceindex, 0)) {
+ ImBuf *ibuf;
+
newimage = (Image*)((s->me->mtface+newfaceindex)->tpage);
- if(newimage && newimage->ibuf && newimage->ibuf->rect)
+ ibuf= BKE_image_get_ibuf(newimage, &G.sima->iuser);
+
+ if(ibuf && ibuf->rect)
texpaint_pick_uv(s->ob, s->me, newfaceindex, mval, newuv);
else
newimage = NULL;
@@ -641,8 +679,10 @@ void imagepaint_paint(short mousebutton, short texpaint)
s.image = G.sima->image;
if(!imapaint_canvas_set(&s, G.sima->image)) {
+ if(s.warnmultifile)
+ error("Image requires 4 color channels to paint");
if(s.warnpackedfile)
- error("Painting in packed images not supported");
+ error("Packed MultiLayer files cannot be painted");
return;
}
}
@@ -694,9 +734,12 @@ void imagepaint_paint(short mousebutton, short texpaint)
imapaint_redraw(1, texpaint, s.image);
+
if (texpaint) {
- if (s.warnpackedfile)
- error("Painting in packed images is not supported: %s", s.warnpackedfile);
+ if (s.warnmultifile)
+ error("Image requires 4 color channels to paint: %s", s.warnmultifile);
+ if(s.warnpackedfile)
+ error("Packed MultiLayer files cannot be painted %s", s.warnpackedfile);
persp(PERSP_WIN);
}
@@ -708,7 +751,7 @@ void imagepaint_pick(short mousebutton)
Brush *brush= settings->imapaint.brush;
if(brush && (settings->imapaint.tool == PAINT_TOOL_CLONE)) {
- if(brush->clone.image && brush->clone.image->ibuf) {
+ if(brush->clone.image) {
short prevmval[2], mval[2];
float lastmousepos[2], mousepos[2];
diff --git a/source/blender/src/interface.c b/source/blender/src/interface.c
index 13b72739d0d..9eb68578968 100644
--- a/source/blender/src/interface.c
+++ b/source/blender/src/interface.c
@@ -118,8 +118,10 @@
float UIwinmat[4][4];
static int UIlock= 0, UIafterval;
static char *UIlockstr=NULL;
-static void (*UIafterfunc)(void *arg, int event);
-static void *UIafterfunc_arg;
+
+static void (*UIafterfunc_butm)(void *arg, int event);
+static void (*UIafterfunc_but)(void *arg1, void *arg2);
+static void *UIafterfunc_arg1, *UIafterfunc_arg2;
static uiFont UIfont[UI_ARRAY]; // no init needed
uiBut *UIbuttip;
@@ -1481,7 +1483,10 @@ static int ui_do_but_BUT(uiBut *but)
activated= (but->flag & UI_SELECT);
if(activated) {
- uibut_do_func(but);
+ UIafterfunc_but= but->func;
+ UIafterfunc_arg1= but->func_arg1;
+ UIafterfunc_arg2= but->func_arg2;
+ /* no more uibut_do_func(but); this button calls fileselecting windows */
}
but->flag &= ~UI_SELECT;
@@ -2649,8 +2654,8 @@ static int ui_do_but_BUTM(uiBut *but)
{
ui_set_but_val(but, but->min);
- UIafterfunc= but->butm_func;
- UIafterfunc_arg= but->butm_func_arg;
+ UIafterfunc_butm= but->butm_func;
+ UIafterfunc_arg1= but->butm_func_arg;
UIafterval= but->a2;
return but->retval;
@@ -4899,7 +4904,9 @@ int uiDoBlocks(ListBase *lb, int event)
if(event==MOUSEX) return UI_NOTHING;
UIbuttip= NULL;
- UIafterfunc= NULL; /* to prevent infinite loops, this shouldnt be a global! */
+ UIafterfunc_butm= NULL; /* to prevent infinite loops, this shouldnt be a global! */
+ UIafterfunc_but= NULL; /* to prevent infinite loops, this shouldnt be a global! */
+ UIafterfunc_arg1= UIafterfunc_arg2= NULL;
uevent.qual= G.qual;
uevent.event= event;
@@ -5016,11 +5023,16 @@ int uiDoBlocks(ListBase *lb, int event)
/* afterfunc is used for fileloading too, so after this call, the blocks pointers are invalid */
if(retval & UI_RETURN_OK) {
- if(UIafterfunc) {
+ if(UIafterfunc_butm) {
+ mywinset(curarea->win);
+ UIafterfunc_butm(UIafterfunc_arg1, UIafterval);
+ UIafterfunc_butm= NULL;
+ }
+ if(UIafterfunc_but) {
mywinset(curarea->win);
- UIafterfunc(UIafterfunc_arg, UIafterval);
+ UIafterfunc_but(UIafterfunc_arg1, UIafterfunc_arg2);
+ UIafterfunc_but= NULL;
}
- UIafterfunc= NULL;
}
/* tooltip */
diff --git a/source/blender/src/interface_icons.c b/source/blender/src/interface_icons.c
index 3fb6caf15b5..568907c77e7 100644
--- a/source/blender/src/interface_icons.c
+++ b/source/blender/src/interface_icons.c
@@ -699,10 +699,12 @@ static void icon_from_image(Image *img, RenderInfo *ri)
/* new rule: never read images, so icons get created while user works,
not always on first use of a menu */
if(!img->preview) {
- if(img->ibuf==NULL || img->ibuf->rect==NULL) {
+ ImBuf *ibuf;
+ if(img->ok!=IMA_OK_LOADED) {
return;
}
- icon_copy_rect(img->ibuf, ri);
+ ibuf= BKE_image_get_ibuf(img, NULL);
+ icon_copy_rect(ibuf, ri);
/* now copy the created preview to the DNA struct to be saved in file */
img->preview = MEM_callocN(sizeof(PreviewImage), "img_prv");
diff --git a/source/blender/src/meshtools.c b/source/blender/src/meshtools.c
index 1a97a3d594f..2d2ea2c8e0c 100644
--- a/source/blender/src/meshtools.c
+++ b/source/blender/src/meshtools.c
@@ -70,6 +70,7 @@ void sort_faces(void);
#include "BKE_depsgraph.h"
#include "BKE_customdata.h"
#include "BKE_global.h"
+#include "BKE_image.h"
#include "BKE_library.h"
#include "BKE_main.h"
#include "BKE_mesh.h"
@@ -850,10 +851,13 @@ void objects_bake_render(void)
else {
Image *ima;
/* force OpenGL reload */
- for(ima= G.main->image.first; ima; ima= ima->id.next)
- if(ima->ibuf)
- if(ima->ibuf->userflags & IB_BITMAPDIRTY)
+ for(ima= G.main->image.first; ima; ima= ima->id.next) {
+ if(ima->ok==IMA_OK_LOADED) {
+ ImBuf *ibuf= BKE_image_get_ibuf(ima, NULL);
+ if(ibuf && (ibuf->userflags & IB_BITMAPDIRTY))
free_realtime_image(ima);
+ }
+ }
}
allqueue(REDRAWIMAGE, 0);
diff --git a/source/blender/src/previewrender.c b/source/blender/src/previewrender.c
index a6e0d2ef27e..5113e261fa5 100644
--- a/source/blender/src/previewrender.c
+++ b/source/blender/src/previewrender.c
@@ -269,6 +269,8 @@ static Scene *preview_prepare_scene(RenderInfo *ri, int id_type, ID *id, int pr_
/* set world always back, is used now */
sce->world= pr_main->world.first;
+ sce->r.cfra= G.scene->r.cfra;
+
if(id_type==ID_MA) {
Material *mat= (Material *)id;
diff --git a/source/blender/src/renderwin.c b/source/blender/src/renderwin.c
index f6bd1d76524..bba8a9ebb45 100644
--- a/source/blender/src/renderwin.c
+++ b/source/blender/src/renderwin.c
@@ -599,7 +599,7 @@ static void renderwin_handler(Window *win, void *user_data, short evt, short val
mainwindow_make_active();
rw->active= 0;
areawinset(find_biggest_area()->win);
- BIF_save_rendered_image_fs(0);
+ BIF_save_rendered_image_fs();
}
}
else if (evt==F11KEY) {
@@ -1115,17 +1115,20 @@ static void do_render(int anim)
waitcursor(0);
}
+/* called before render, store old render in spare buffer */
static void renderwin_store_spare(void)
{
RenderResult rres;
if(render_win==0 || render_win->storespare==0)
return;
-
- if(render_win->showspare) {
- render_win->showspare= 0;
- window_set_title(render_win->win, renderwin_get_title(1));
- }
+
+ /* only store when it does not show spare */
+ if(render_win->showspare==0)
+ return;
+
+ render_win->showspare= 0;
+ window_set_title(render_win->win, renderwin_get_title(1));
BLI_strncpy(render_win->render_text_spare, render_win->render_text, RW_MAXTEXT);
@@ -1197,6 +1200,14 @@ void BIF_end_render_callbacks(void)
}
}
+void BIF_store_spare(void)
+{
+ if(render_win)
+ renderwin_store_spare();
+ else
+ imagewin_store_spare();
+}
+
/* set up display, render an image or scene */
void BIF_do_render(int anim)
{
@@ -1210,8 +1221,7 @@ void BIF_do_render(int anim)
}
}
- if(render_win && render_win->showspare)
- renderwin_store_spare();
+ BIF_store_spare();
do_render(anim);
@@ -1327,12 +1337,7 @@ void BIF_redraw_render_rect(void)
renderwin_queue_redraw(render_win);
}
else {
- Image *ima = (Image *)find_id("IM", "Render Result");
- if(ima && ima->ibuf) {
- IMB_freeImBuf(ima->ibuf);
- ima->ibuf= NULL;
- allqueue(REDRAWIMAGE, 0);
- }
+ allqueue(REDRAWIMAGE, 0);
}
}
@@ -1340,22 +1345,26 @@ void BIF_swap_render_rects(void)
{
RenderResult rres;
- if (render_win==NULL) return;
-
- render_win->storespare= 1;
- render_win->showspare ^= 1;
+ if(G.displaymode!=R_DISPLAYWIN) {
+ imagewindow_swap_render_rects();
+ }
+ else {
- RE_GetResultImage(RE_GetRender(G.scene->id.name), &rres);
+ render_win->storespare= 1;
+ render_win->showspare ^= 1;
+
+ RE_GetResultImage(RE_GetRender(G.scene->id.name), &rres);
+
+ if(render_win->sparex!=rres.rectx || render_win->sparey!=rres.recty) {
+ if(render_win->rectspare) MEM_freeN(render_win->rectspare);
+ render_win->rectspare= NULL;
+ if(render_win->rectsparef) MEM_freeN(render_win->rectsparef);
+ render_win->rectsparef= NULL;
+ }
- if(render_win->sparex!=rres.rectx || render_win->sparey!=rres.recty) {
- if(render_win->rectspare) MEM_freeN(render_win->rectspare);
- render_win->rectspare= NULL;
- if(render_win->rectsparef) MEM_freeN(render_win->rectsparef);
- render_win->rectsparef= NULL;
+ window_set_title(render_win->win, renderwin_get_title(1));
}
- window_set_title(render_win->win, renderwin_get_title(1));
-
/* redraw */
BIF_redraw_render_rect();
diff --git a/source/blender/src/space.c b/source/blender/src/space.c
index af6a5043244..a9de9e01ea8 100644
--- a/source/blender/src/space.c
+++ b/source/blender/src/space.c
@@ -4347,7 +4347,7 @@ static void init_imaselspace(ScrArea *sa)
simasel->firstdir = 0;
simasel->firstfile = 0;
simasel->cmap = 0;
- simasel->returnfunc = 0;
+ simasel->returnfunc = NULL;
simasel->title[0] = 0;
@@ -4589,7 +4589,7 @@ static void winqreadimagespace(ScrArea *sa, void *spacedata, BWinEvent *evt)
/* Events handled always (whether the draw tool is active or not) */
switch (event) {
case UI_BUT_EVENT:
- do_imagebuts(val); /* drawimage.c */
+ do_image_buttons(val); /* header_image.c */
break;
case MIDDLEMOUSE:
if((G.qual==LR_CTRLKEY) || ((U.flag & USER_TWOBUTTONMOUSE) && (G.qual==(LR_ALTKEY|LR_CTRLKEY))))
@@ -4665,6 +4665,10 @@ static void init_imagespace(ScrArea *sa)
sima->zoom= 1;
sima->blockscale= 0.7;
sima->flag = SI_LOCALSTICKY;
+
+ sima->iuser.ok= 1;
+ sima->iuser.fie_ima= 2;
+ sima->iuser.frames= 100;
}
@@ -5216,14 +5220,14 @@ void newspace(ScrArea *sa, int type)
sfile->type= FILE_UNIX;
}
- sfile->returnfunc= 0;
+ sfile->returnfunc= NULL;
sfile->title[0]= 0;
if(sfile->filelist) test_flags_file(sfile);
}
/* exception: imasel space */
else if(sa->spacetype==SPACE_IMASEL) {
SpaceImaSel *simasel= sa->spacedata.first;
- simasel->returnfunc= 0;
+ simasel->returnfunc= NULL;
simasel->title[0]= 0;
}
else if(sa->spacetype==SPACE_OOPS) {
@@ -5248,6 +5252,8 @@ void freespacelist(ScrArea *sa)
BLO_blendhandle_close(sfile->libfiledata);
if(sfile->filelist)
freefilelist(sfile);
+ if(sfile->pupmenu)
+ MEM_freeN(sfile->pupmenu);
}
else if(sl->spacetype==SPACE_BUTS) {
SpaceButs *buts= (SpaceButs*) sl;
@@ -5266,7 +5272,6 @@ void freespacelist(ScrArea *sa)
else if(sl->spacetype==SPACE_VIEW3D) {
View3D *vd= (View3D*) sl;
if(vd->bgpic) {
- if(vd->bgpic->rect) MEM_freeN(vd->bgpic->rect);
if(vd->bgpic->ima) vd->bgpic->ima->id.us--;
MEM_freeN(vd->bgpic);
}
@@ -5312,6 +5317,10 @@ void freespacelist(ScrArea *sa)
curvemapping_free(sima->cumap);
if(sima->info_str)
MEM_freeN(sima->info_str);
+ if(sima->info_spare)
+ MEM_freeN(sima->info_spare);
+ if(sima->spare)
+ IMB_freeImBuf(sima->spare);
}
else if(sl->spacetype==SPACE_NODE) {
/* SpaceNode *snode= (SpaceNode *)sl; */
@@ -5321,6 +5330,7 @@ void freespacelist(ScrArea *sa)
BLI_freelistN(&sa->spacedata);
}
+/* can be called for area-full, so it should keep interesting stuff */
void duplicatespacelist(ScrArea *newarea, ListBase *lb1, ListBase *lb2)
{
SpaceLink *sl;
@@ -5333,8 +5343,10 @@ void duplicatespacelist(ScrArea *newarea, ListBase *lb1, ListBase *lb2)
while(sl) {
if(sl->spacetype==SPACE_FILE) {
SpaceFile *sfile= (SpaceFile*) sl;
- sfile->libfiledata= 0;
- sfile->filelist= 0;
+ sfile->libfiledata= NULL;
+ sfile->filelist= NULL;
+ sfile->pupmenu= NULL;
+ sfile->menup= NULL;
}
else if(sl->spacetype==SPACE_VIEW3D) {
View3D *v3d= (View3D*)sl;
@@ -5351,6 +5363,10 @@ void duplicatespacelist(ScrArea *newarea, ListBase *lb1, ListBase *lb2)
else if(sl->spacetype==SPACE_IMASEL) {
check_imasel_copy((SpaceImaSel *) sl);
}
+ else if(sl->spacetype==SPACE_IMAGE) {
+ SpaceImage *sima= (SpaceImage *)sl;
+ sima->spare= NULL;
+ }
else if(sl->spacetype==SPACE_NODE) {
SpaceNode *snode= (SpaceNode *)sl;
snode->nodetree= NULL;
@@ -5359,6 +5375,8 @@ void duplicatespacelist(ScrArea *newarea, ListBase *lb1, ListBase *lb2)
sl= sl->next;
}
+ /* but some things we copy */
+
sl= lb1->first;
while(sl) {
sl->area= newarea;
@@ -5367,6 +5385,10 @@ void duplicatespacelist(ScrArea *newarea, ListBase *lb1, ListBase *lb2)
SpaceButs *buts= (SpaceButs *)sl;
buts->ri= NULL;
}
+ else if(sl->spacetype==SPACE_FILE) {
+ SpaceFile *sfile= (SpaceFile*) sl;
+ sfile->menup= NULL;
+ }
else if(sl->spacetype==SPACE_IPO) {
SpaceIpo *si= (SpaceIpo *)sl;
si->editipo= NULL;
@@ -5376,7 +5398,6 @@ void duplicatespacelist(ScrArea *newarea, ListBase *lb1, ListBase *lb2)
View3D *vd= (View3D *)sl;
if(vd->bgpic) {
vd->bgpic= MEM_dupallocN(vd->bgpic);
- vd->bgpic->rect= NULL;
if(vd->bgpic->ima) vd->bgpic->ima->id.us++;
}
vd->clipbb= MEM_dupallocN(vd->clipbb);
@@ -5389,6 +5410,8 @@ void duplicatespacelist(ScrArea *newarea, ListBase *lb1, ListBase *lb2)
sima->cumap= curvemapping_copy(sima->cumap);
if(sima->info_str)
sima->info_str= MEM_dupallocN(sima->info_str);
+ if(sima->info_spare)
+ sima->info_spare= MEM_dupallocN(sima->info_spare);
}
sl= sl->next;
}
diff --git a/source/blender/src/toets.c b/source/blender/src/toets.c
index f5b9ccf3f81..51c54cf6661 100644
--- a/source/blender/src/toets.c
+++ b/source/blender/src/toets.c
@@ -456,15 +456,12 @@ int blenderqread(unsigned short event, short val)
break;
case F3KEY:
if(G.qual==0) {
- BIF_save_rendered_image_fs(0);
+ BIF_save_rendered_image_fs();
return 0;
}
else if(G.qual & LR_CTRLKEY) {
BIF_screendump(0);
}
- else if(G.qual & LR_SHIFTKEY) {
- BIF_save_rendered_image_fs(1);
- }
break;
case F4KEY:
if(G.qual==LR_SHIFTKEY) {
@@ -473,7 +470,7 @@ int blenderqread(unsigned short event, short val)
ob= OBACT;
if(ob) strcpy(str, ob->id.name);
- activate_fileselect(FILE_MAIN, "Data Select", str, 0);
+ activate_fileselect(FILE_MAIN, "Data Select", str, NULL);
return 0;
}
else if(G.qual==0) {
diff --git a/source/blender/src/toolbox.c b/source/blender/src/toolbox.c
index 4601fa77b3a..c9fced04a00 100644
--- a/source/blender/src/toolbox.c
+++ b/source/blender/src/toolbox.c
@@ -74,6 +74,7 @@
#include "BKE_displist.h"
#include "BKE_depsgraph.h"
#include "BKE_global.h"
+#include "BKE_image.h"
#include "BKE_library.h"
#include "BKE_mesh.h"
#include "BKE_node.h"
@@ -709,9 +710,7 @@ void replace_names_but(void)
strcat(temp, ima->name+len);
BLI_strncpy(ima->name, temp, sizeof(ima->name));
- if(ima->ibuf) IMB_freeImBuf(ima->ibuf);
- ima->ibuf= 0;
- ima->ok= 1;
+ BKE_image_signal(ima, NULL, IMA_SIGNAL_FREE);
tot++;
}
diff --git a/source/blender/src/verse_object.c b/source/blender/src/verse_object.c
index 2a285d828b9..572849b5a92 100644
--- a/source/blender/src/verse_object.c
+++ b/source/blender/src/verse_object.c
@@ -289,7 +289,7 @@ void b_verse_pop_node(VNode *vnode)
return;
}
- vbitmap->image = (void*)new_image(
+ vbitmap->image = (void*)BKE_add_image_size(
vbitmap->width,
vbitmap->height,
vnode->name,
diff --git a/source/blender/src/writeimage.c b/source/blender/src/writeimage.c
index 6d167d858ff..530d0535baa 100644
--- a/source/blender/src/writeimage.c
+++ b/source/blender/src/writeimage.c
@@ -66,17 +66,17 @@ void BIF_save_envmap(EnvMap *env, char *str)
int dx;
/* all interactive stuff is handled in buttons.c */
- if(env->cube[0]==NULL || env->cube[0]->ibuf==NULL) return;
+ if(env->cube[0]==NULL) return;
- dx= env->cube[0]->ibuf->x;
+ dx= env->cube[0]->x;
ibuf= IMB_allocImBuf(3*dx, 2*dx, 24, IB_rect, 0);
- IMB_rectcpy(ibuf, env->cube[0]->ibuf, 0, 0, 0, 0, dx, dx);
- IMB_rectcpy(ibuf, env->cube[1]->ibuf, dx, 0, 0, 0, dx, dx);
- IMB_rectcpy(ibuf, env->cube[2]->ibuf, 2*dx, 0, 0, 0, dx, dx);
- IMB_rectcpy(ibuf, env->cube[3]->ibuf, 0, dx, 0, 0, dx, dx);
- IMB_rectcpy(ibuf, env->cube[4]->ibuf, dx, dx, 0, 0, dx, dx);
- IMB_rectcpy(ibuf, env->cube[5]->ibuf, 2*dx, dx, 0, 0, dx, dx);
+ IMB_rectcpy(ibuf, env->cube[0], 0, 0, 0, 0, dx, dx);
+ IMB_rectcpy(ibuf, env->cube[1], dx, 0, 0, 0, dx, dx);
+ IMB_rectcpy(ibuf, env->cube[2], 2*dx, 0, 0, 0, dx, dx);
+ IMB_rectcpy(ibuf, env->cube[3], 0, dx, 0, 0, dx, dx);
+ IMB_rectcpy(ibuf, env->cube[4], dx, dx, 0, 0, dx, dx);
+ IMB_rectcpy(ibuf, env->cube[5], 2*dx, dx, 0, 0, dx, dx);
BKE_write_ibuf(ibuf, str, G.scene->r.imtype, G.scene->r.subimtype, G.scene->r.quality);
IMB_freeImBuf(ibuf);
@@ -86,12 +86,10 @@ void BIF_save_envmap(EnvMap *env, char *str)
#define FTOCHAR(val) val<=0.0f?255: 255-(val>=255.0f?255: (char)(val))
/* callback for fileselect to save rendered image, renderresult was checked to exist */
-void save_rendered_image_cb_real(char *name, int zbuf, int confirm)
+static void save_rendered_image_cb_real(char *name, int confirm)
{
char str[FILE_MAXDIR+FILE_MAXFILE];
- int pixel, end, overwrite;
- float *pixf = 0;
- char *pixc = 0;
+ int overwrite;
if(BLI_testextensie(name,".blend")) {
error("Wrong filename");
@@ -112,54 +110,37 @@ void save_rendered_image_cb_real(char *name, int zbuf, int confirm)
overwrite = 1;
if(overwrite) {
- RenderResult rres;
- ImBuf *ibuf;
-
- RE_GetResultImage(RE_GetRender(G.scene->id.name), &rres);
-
- waitcursor(1); /* from screen.c */
-
- ibuf= IMB_allocImBuf(rres.rectx, rres.recty, G.scene->r.planes, 0, 0);
- if (zbuf == 1) {
- if (ibuf->rect ==NULL) imb_addrectImBuf(ibuf);
- if (ibuf->rect_float==NULL) imb_addrectfloatImBuf(ibuf);
-
- ibuf->zbuf_float= rres.rectz;
+ if(G.scene->r.imtype==R_MULTILAYER) {
+ RenderResult *rr= RE_GetResult(RE_GetRender(G.scene->id.name));
+ if(rr)
+ RE_WriteRenderResult(rr, str);
+ }
+ else {
+ RenderResult rres;
+ ImBuf *ibuf;
+
+ RE_GetResultImage(RE_GetRender(G.scene->id.name), &rres);
- pixc = (char *)ibuf->rect;
- pixf = (float *)ibuf->rect_float;
+ waitcursor(1); /* from screen.c */
- end = ibuf->x * ibuf->y;
- for(pixel = 0; pixel < end; pixel++, pixf+=4, pixc+=4) {
- pixf[0] = pixf[1] = pixf[2] = pixf[3] = 1-rres.rectz[pixel]/100000000000.0;
- pixc[0] = pixc[1] = pixc[2] = pixc[3] = FTOCHAR(rres.rectz[pixel]);
- }
- ibuf->zbuf_float= rres.rectz;
- } else {
+ ibuf= IMB_allocImBuf(rres.rectx, rres.recty, G.scene->r.planes, 0, 0);
ibuf->rect= rres.rect32;
ibuf->rect_float= rres.rectf;
ibuf->zbuf_float= rres.rectz;
+
+ /* float factor for random dither, imbuf takes care of it */
+ ibuf->dither= G.scene->r.dither_intensity;
+
+ BKE_write_ibuf(ibuf, str, G.scene->r.imtype, G.scene->r.subimtype, G.scene->r.quality);
+ IMB_freeImBuf(ibuf); /* imbuf knows rects are not part of ibuf */
}
- /* float factor for random dither, imbuf takes care of it */
- ibuf->dither= G.scene->r.dither_intensity;
-
- BKE_write_ibuf(ibuf, str, G.scene->r.imtype, G.scene->r.subimtype, G.scene->r.quality);
- IMB_freeImBuf(ibuf); /* imbuf knows rects are not part of ibuf */
-
strcpy(G.ima, name);
waitcursor(0);
}
}
-static void save_rendered_image_cb(char *name) {
- save_rendered_image_cb_real(name,0,1);
-}
-
-static void save_rendered_image_zbuf_cb(char *name) {
- save_rendered_image_cb_real(name,1,1);
-}
void save_image_filesel_str(char *str)
{
@@ -203,7 +184,9 @@ void save_image_filesel_str(char *str)
case R_TARGA:
strcpy(str, "Save Targa");
break;
-
+ case R_MULTILAYER:
+ strcpy(str, "Save Multi Layer EXR");
+ break;
/* default we save jpeg, also for all movie formats */
case R_JPEG90:
case R_MOVIE:
@@ -216,8 +199,19 @@ void save_image_filesel_str(char *str)
}
}
-/* calls fileselect if zbuf is set we are rendering the zbuffer */
-void BIF_save_rendered_image_fs(int zbuf)
+static void save_rendered_image_cb(char *name)
+{
+ save_rendered_image_cb_real(name, 1);
+}
+
+/* no fileselect, no confirm */
+void BIF_save_rendered_image(char *name)
+{
+ save_rendered_image_cb_real(name, 0);
+}
+
+/* calls fileselect */
+void BIF_save_rendered_image_fs(void)
{
RenderResult rres;
@@ -225,7 +219,8 @@ void BIF_save_rendered_image_fs(int zbuf)
if(!rres.rectf && !rres.rect32) {
error("No image rendered");
- } else {
+ }
+ else {
char dir[FILE_MAXDIR * 2], str[FILE_MAXFILE * 2];
if(G.ima[0]==0) {
@@ -235,10 +230,6 @@ void BIF_save_rendered_image_fs(int zbuf)
}
save_image_filesel_str(str);
- if (zbuf) {
- activate_fileselect(FILE_SPECIAL, str, G.ima, save_rendered_image_zbuf_cb);
- return;
- }
activate_fileselect(FILE_SPECIAL, str, G.ima, save_rendered_image_cb);
}
}