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
path: root/source
diff options
context:
space:
mode:
authorBrecht Van Lommel <brechtvanlommel@pandora.be>2009-02-11 02:17:58 +0300
committerBrecht Van Lommel <brechtvanlommel@pandora.be>2009-02-11 02:17:58 +0300
commitb77da4893dc18adf981f158d52842f0c6d81498e (patch)
tree1b0215c79dc833403d036249acd0b5b170b1f3bd /source
parent1195c22207c452f1d6d974c8043d533ab8f41402 (diff)
2.5: Image window operators, quite a few of these still have
missing parts and are work in progress. Set 3D Cursor Set Tile Sample Color New Open Replace Reload Save (As) Save Sequence Pack Unpack Record Composite The file select operators have context issues still. They need to get the image space in the context on exec() but it's not there currently, not sure how to solve that yet. Also added name parameter to uiMenuItemEnumO, and fixed "mute" argument in ED_update_for_newframe calls in fluidsim bake.
Diffstat (limited to 'source')
-rw-r--r--source/blender/editors/armature/editarmature.c4
-rw-r--r--source/blender/editors/include/ED_image.h2
-rw-r--r--source/blender/editors/include/UI_interface.h2
-rw-r--r--source/blender/editors/interface/interface_regions.c10
-rw-r--r--source/blender/editors/object/object_edit.c28
-rw-r--r--source/blender/editors/physics/ed_fluidsim.c10
-rw-r--r--source/blender/editors/space_image/image_draw.c38
-rw-r--r--source/blender/editors/space_image/image_header.c139
-rw-r--r--source/blender/editors/space_image/image_intern.h14
-rw-r--r--source/blender/editors/space_image/image_ops.c1204
-rw-r--r--source/blender/editors/space_image/space_image.c37
-rw-r--r--source/blender/editors/space_view3d/view3d_header.c14
-rw-r--r--source/blender/editors/transform/transform_orientations.c8
-rw-r--r--source/blender/editors/uvedit/uvedit_ops.c121
-rw-r--r--source/blender/makesrna/intern/rna_space.c15
15 files changed, 1049 insertions, 597 deletions
diff --git a/source/blender/editors/armature/editarmature.c b/source/blender/editors/armature/editarmature.c
index b45390683b5..6262642f7f9 100644
--- a/source/blender/editors/armature/editarmature.c
+++ b/source/blender/editors/armature/editarmature.c
@@ -3429,11 +3429,11 @@ static int armature_parent_set_invoke(bContext *C, wmOperator *op, wmEvent *even
}
CTX_DATA_END;
- uiMenuItemEnumO(head, 0, "ARMATURE_OT_set_parent", "type", ARM_PAR_CONNECT);
+ uiMenuItemEnumO(head, "", 0, "ARMATURE_OT_set_parent", "type", ARM_PAR_CONNECT);
/* ob becomes parent, make the associated menus */
if (allchildbones)
- uiMenuItemEnumO(head, 0, "ARMATURE_OT_set_parent", "type", ARM_PAR_OFFSET);
+ uiMenuItemEnumO(head, "", 0, "ARMATURE_OT_set_parent", "type", ARM_PAR_OFFSET);
uiPupMenuEnd(C, head);
diff --git a/source/blender/editors/include/ED_image.h b/source/blender/editors/include/ED_image.h
index f015001c0d5..99a8a02e7cf 100644
--- a/source/blender/editors/include/ED_image.h
+++ b/source/blender/editors/include/ED_image.h
@@ -33,7 +33,7 @@ struct bContext;
/* space_image.c, exported for transform */
struct Image *ED_space_image(struct SpaceImage *sima);
-void ED_space_image_set(struct SpaceImage *sima, struct Scene *scene, struct Object *obedit, struct Image *ima);
+void ED_space_image_set(struct bContext *C, struct SpaceImage *sima, struct Scene *scene, struct Object *obedit, struct Image *ima);
struct ImBuf *ED_space_image_buffer(struct SpaceImage *sima);
void ED_space_image_size(struct SpaceImage *sima, int *width, int *height);
diff --git a/source/blender/editors/include/UI_interface.h b/source/blender/editors/include/UI_interface.h
index f516d953bc5..ab35089549b 100644
--- a/source/blender/editors/include/UI_interface.h
+++ b/source/blender/editors/include/UI_interface.h
@@ -212,7 +212,7 @@ void uiMenuContext(uiMenuItem *head, int opcontext);
void uiMenuItemVal(uiMenuItem *head, const char *name, int icon, int argval);
-void uiMenuItemEnumO(uiMenuItem *head, int icon, char *opname, char *propname, int value);
+void uiMenuItemEnumO(uiMenuItem *head, const char *name, int icon, char *opname, char *propname, int value);
void uiMenuItemBooleanO(uiMenuItem *head, const char *name, int icon, char *opname, char *propname, int value);
void uiMenuItemsEnumO(uiMenuItem *head, char *opname, char *propname);
void uiMenuItemIntO(uiMenuItem *head, const char *name, int icon, char *opname, char *propname, int value);
diff --git a/source/blender/editors/interface/interface_regions.c b/source/blender/editors/interface/interface_regions.c
index 1eb4588ac0b..7830ec0e707 100644
--- a/source/blender/editors/interface/interface_regions.c
+++ b/source/blender/editors/interface/interface_regions.c
@@ -2009,9 +2009,9 @@ void uiMenuItemO(uiMenuItem *head, int icon, char *opname)
}
/* single operator item with property */
-void uiMenuItemEnumO(uiMenuItem *head, int icon, char *opname, char *propname, int value)
+void uiMenuItemEnumO(uiMenuItem *head, const char *name, int icon, char *opname, char *propname, int value)
{
- uiMenuItem *item= ui_menu_add_item(head, "", icon, 0);
+ uiMenuItem *item= ui_menu_add_item(head, name, icon, 0);
item->opname= opname; // static!
item->propname= propname; // static!
@@ -2072,7 +2072,7 @@ void uiMenuItemsEnumO(uiMenuItem *head, char *opname, char *propname)
RNA_property_enum_items(&ptr, prop, &item, &totitem);
for (i=0; i<totitem; i++)
- uiMenuItemEnumO(head, 0, opname, propname, item[i].value);
+ uiMenuItemEnumO(head, "", 0, opname, propname, item[i].value);
}
}
@@ -2136,8 +2136,6 @@ void uiMenuLevelEnumO(uiMenuItem *head, char *opname, char *propname)
item->opname= opname; // static!
item->propname= propname; // static!
-
- BLI_addtail(&head->items, item);
}
/* make a new level from enum properties */
@@ -2153,8 +2151,6 @@ void uiMenuLevelEnumR(uiMenuItem *head, PointerRNA *ptr, char *propname)
item->rnapoin= *ptr;
item->propname= propname; // static!
-
- BLI_addtail(&head->items, item);
}
/* separator */
diff --git a/source/blender/editors/object/object_edit.c b/source/blender/editors/object/object_edit.c
index 42a4dc0e0de..56281a288d0 100644
--- a/source/blender/editors/object/object_edit.c
+++ b/source/blender/editors/object/object_edit.c
@@ -526,13 +526,13 @@ static int object_add_primitive_invoke(bContext *C, wmOperator *op, wmEvent *eve
uiMenuLevelEnumO(head, "OBJECT_OT_mesh_add", "type");
uiMenuLevelEnumO(head, "OBJECT_OT_curve_add", "type");
- uiMenuItemEnumO(head, 0, "OBJECT_OT_object_add", "type", OB_SURF);
- uiMenuItemEnumO(head, 0, "OBJECT_OT_object_add", "type", OB_MBALL);
- uiMenuItemEnumO(head, 0, "OBJECT_OT_object_add", "type", OB_CAMERA);
- uiMenuItemEnumO(head, 0, "OBJECT_OT_object_add", "type", OB_LAMP);
- uiMenuItemEnumO(head, 0, "OBJECT_OT_object_add", "type", OB_EMPTY);
- uiMenuItemEnumO(head, 0, "OBJECT_OT_armature_add", "type", OB_ARMATURE);
- uiMenuItemEnumO(head, 0, "OBJECT_OT_object_add", "type", OB_LATTICE);
+ uiMenuItemEnumO(head, "", 0, "OBJECT_OT_object_add", "type", OB_SURF);
+ uiMenuItemEnumO(head, "", 0, "OBJECT_OT_object_add", "type", OB_MBALL);
+ uiMenuItemEnumO(head, "", 0, "OBJECT_OT_object_add", "type", OB_CAMERA);
+ uiMenuItemEnumO(head, "", 0, "OBJECT_OT_object_add", "type", OB_LAMP);
+ uiMenuItemEnumO(head, "", 0, "OBJECT_OT_object_add", "type", OB_EMPTY);
+ uiMenuItemEnumO(head, "", 0, "OBJECT_OT_armature_add", "type", OB_ARMATURE);
+ uiMenuItemEnumO(head, "", 0, "OBJECT_OT_object_add", "type", OB_LATTICE);
uiPupMenuEnd(C, head);
@@ -2448,20 +2448,20 @@ static int make_parent_invoke(bContext *C, wmOperator *op, wmEvent *event)
uiMenuItem *head= uiPupMenuBegin("Make Parent To", 0);
uiMenuContext(head, WM_OP_EXEC_DEFAULT);
- uiMenuItemEnumO(head, 0, "OBJECT_OT_make_parent", "type", PAR_OBJECT);
+ uiMenuItemEnumO(head, "", 0, "OBJECT_OT_make_parent", "type", PAR_OBJECT);
/* ob becomes parent, make the associated menus */
if(ob->type==OB_ARMATURE) {
- uiMenuItemEnumO(head, 0, "OBJECT_OT_make_parent", "type", PAR_ARMATURE);
- uiMenuItemEnumO(head, 0, "OBJECT_OT_make_parent", "type", PAR_BONE);
+ uiMenuItemEnumO(head, "", 0, "OBJECT_OT_make_parent", "type", PAR_ARMATURE);
+ uiMenuItemEnumO(head, "", 0, "OBJECT_OT_make_parent", "type", PAR_BONE);
}
else if(ob->type==OB_CURVE) {
- uiMenuItemEnumO(head, 0, "OBJECT_OT_make_parent", "type", PAR_CURVE);
- uiMenuItemEnumO(head, 0, "OBJECT_OT_make_parent", "type", PAR_FOLLOW);
- uiMenuItemEnumO(head, 0, "OBJECT_OT_make_parent", "type", PAR_PATH_CONST);
+ uiMenuItemEnumO(head, "", 0, "OBJECT_OT_make_parent", "type", PAR_CURVE);
+ uiMenuItemEnumO(head, "", 0, "OBJECT_OT_make_parent", "type", PAR_FOLLOW);
+ uiMenuItemEnumO(head, "", 0, "OBJECT_OT_make_parent", "type", PAR_PATH_CONST);
}
else if(ob->type == OB_LATTICE) {
- uiMenuItemEnumO(head, 0, "OBJECT_OT_make_parent", "type", PAR_LATTICE);
+ uiMenuItemEnumO(head, "", 0, "OBJECT_OT_make_parent", "type", PAR_LATTICE);
}
uiPupMenuEnd(C, head);
diff --git a/source/blender/editors/physics/ed_fluidsim.c b/source/blender/editors/physics/ed_fluidsim.c
index 1675313205b..5f84989be54 100644
--- a/source/blender/editors/physics/ed_fluidsim.c
+++ b/source/blender/editors/physics/ed_fluidsim.c
@@ -262,7 +262,7 @@ static void fluidsimInitMeshChannel(bContext *C, float **setchannel, int size, O
float *verts=NULL;
int *tris=NULL;
scene->r.cfra = frame;
- ED_update_for_newframe(C, 0);
+ ED_update_for_newframe(C, 1);
initElbeemMesh(scene, obm, &numVerts, &verts, &numTris, &tris, 1, modifierIndex);
//fprintf(stderr,"\nfluidsimInitMeshChannel frame%d verts%d/%d \n\n",frame,vertices,numVerts);
@@ -596,7 +596,7 @@ void fluidsimBake(bContext *C, struct Object *ob)
// CHECK more reasonable to number frames according to blender?
// dump data for frame 0
scene->r.cfra = startFrame;
- ED_update_for_newframe(C, 0);
+ ED_update_for_newframe(C, 1);
// init common export vars for both file export and run
for(i=0; i<256; i++) {
@@ -985,7 +985,7 @@ void fluidsimBake(bContext *C, struct Object *ob)
fsmesh.channelSizeVertices = allchannelSize;
fluidsimInitMeshChannel(C, &fsmesh.channelVertices, allchannelSize, obit, numVerts, timeAtFrame, modifierIndex);
scene->r.cfra = startFrame;
- ED_update_for_newframe(C, 0);
+ ED_update_for_newframe(C, 1);
// remove channels
fsmesh.channelTranslation =
fsmesh.channelRotation =
@@ -1063,7 +1063,7 @@ void fluidsimBake(bContext *C, struct Object *ob)
ScrArea *sa;
scene->r.cfra = startFrame+globalBakeFrame;
lastRedraw = globalBakeFrame;
- ED_update_for_newframe(C, 0);
+ ED_update_for_newframe(C, 1);
sa= G.curscreen->areabase.first;
while(sa) {
if(sa->spacetype == SPACE_VIEW3D) { scrarea_do_windraw(sa); }
@@ -1096,7 +1096,7 @@ void fluidsimBake(bContext *C, struct Object *ob)
}
scene->r.cfra = origFrame;
- ED_update_for_newframe(C, 0);
+ ED_update_for_newframe(C, 1);
if(!simAborted) {
char fsmessage[512];
diff --git a/source/blender/editors/space_image/image_draw.c b/source/blender/editors/space_image/image_draw.c
index 42c91d7ea1b..7311821a5ef 100644
--- a/source/blender/editors/space_image/image_draw.c
+++ b/source/blender/editors/space_image/image_draw.c
@@ -158,10 +158,12 @@ static void sima_draw_render_info(SpaceImage *sima, ARegion *ar)
UI_DrawString(G.fonts, str, 0);
}
-/*static void sima_draw_image_info(ARegion *ar, int channels, int x, int y, char *cp, float *fp, int *zp, float *zpf)
+void draw_image_info(ARegion *ar, int channels, int x, int y, char *cp, float *fp, int *zp, float *zpf)
{
char str[256];
int ofs;
+
+ ED_region_pixelspace(ar);
ofs= sprintf(str, "X: %d Y: %d ", x, y);
if(cp)
@@ -193,7 +195,7 @@ static void sima_draw_render_info(SpaceImage *sima, ARegion *ar)
UI_RasterPos(10, 10);
UI_DrawString(G.fonts, str, 0);
-}*/
+}
/* image drawing */
@@ -493,36 +495,6 @@ static void draw_image_buffer_repeated(SpaceImage *sima, ARegion *ar, Scene *sce
/* draw uv edit */
-/* XXX this becomes draw extra? */
-#if 0
- glPixelZoom(zoomx, zoomy);
-
- if(sima->flag & SI_EDITTILE) {
- /* create char buffer from float if needed */
- image_verify_buffer_float(sima, ibuf);
-
- glaDrawPixelsSafe(x1, y1, ibuf->x, ibuf->y, ibuf->x, GL_RGBA, GL_UNSIGNED_BYTE, ibuf->rect);
-
- glPixelZoom(1.0, 1.0);
-
- dx= ibuf->x/sima->image->xrep;
- dy= ibuf->y/sima->image->yrep;
- sy= (sima->curtile / sima->image->xrep);
- sx= sima->curtile - sy*sima->image->xrep;
-
- sx*= dx;
- sy*= dy;
-
- calc_image_view(sima, 'p'); /* pixel */
- myortho2(G.v2d->cur.xmin, G.v2d->cur.xmax, G.v2d->cur.ymin, G.v2d->cur.ymax);
-
- cpack(0x0);
- glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); glRects(sx, sy, sx+dx-1, sy+dy-1); glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
- cpack(0xFFFFFF);
- glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); glRects(sx+1, sy+1, sx+dx, sy+dy); glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
- }
-#endif
-
/* draw grease pencil */
static void draw_image_grease_pencil(SpaceImage *sima, ImBuf *ibuf)
@@ -653,7 +625,7 @@ void draw_image_main(SpaceImage *sima, ARegion *ar, Scene *scene)
what_image(sima);
if(sima->image) {
- image_pixel_aspect(sima->image, &xuser_asp, &yuser_asp);
+ ED_image_aspect(sima->image, &xuser_asp, &yuser_asp);
/* UGLY hack? until now iusers worked fine... but for flipbook viewer we need this */
if(sima->image->type==IMA_TYPE_COMPOSITE) {
diff --git a/source/blender/editors/space_image/image_header.c b/source/blender/editors/space_image/image_header.c
index 9a6bab08238..997ba867121 100644
--- a/source/blender/editors/space_image/image_header.c
+++ b/source/blender/editors/space_image/image_header.c
@@ -197,12 +197,6 @@ static void do_image_imagemenu(void *arg, int event)
case 2:
pack_image_sima();
break;
- case 4: /* Texture Painting */
- brush_check_exists(&G.scene->toolsettings->imapaint.brush);
- if(sima->flag & SI_DRAWTOOL) sima->flag &= ~SI_DRAWTOOL;
- else sima->flag |= SI_DRAWTOOL;
- allqueue(REDRAWBUTSSHADING, 0);
- break;
case 5:
save_as_image_sima();
break;
@@ -226,28 +220,11 @@ static void do_image_imagemenu(void *arg, int event)
}
#endif
-/* move to realtime properties panel */
-#if 0
-static void do_image_image_rtmappingmenu(void *arg, int event)
-{
- switch(event) {
- case 0: /* UV Co-ordinates */
- sima->image->flag &= ~IMA_REFLECT;
- break;
- case 1: /* Reflection */
- sima->image->flag |= IMA_REFLECT;
- break;
- }
-
- allqueue(REDRAWVIEW3D, 0);
-}
-#endif
-
static void image_imagemenu(bContext *C, uiMenuItem *head, void *arg_unused)
{
bScreen *sc= CTX_wm_screen(C);
SpaceImage *sima= (SpaceImage*)CTX_wm_space_data(C);
- PointerRNA spaceptr;
+ PointerRNA spaceptr, imaptr;
Image *ima;
ImBuf *ibuf;
int show_render;
@@ -261,13 +238,13 @@ static void image_imagemenu(bContext *C, uiMenuItem *head, void *arg_unused)
RNA_pointer_create(&sc->id, &RNA_SpaceImageEditor, sima, &spaceptr);
/* create menu */
- uiMenuItemO(head, 0, "IMAGE_OT_new"); // New...|Alt N
- uiMenuItemO(head, 0, "IMAGE_OT_open"); // Open...|Alt O
+ uiMenuItemO(head, 0, "IMAGE_OT_new"); // New...
+ uiMenuItemO(head, 0, "IMAGE_OT_open"); // Open...
if(ima) {
uiMenuItemO(head, 0, "IMAGE_OT_replace"); // Replace...
- uiMenuItemO(head, 0, "IMAGE_OT_reload"); // Reload...|Alt R
- uiMenuItemO(head, 0, "IMAGE_OT_save"); // Save|Alt S
+ uiMenuItemO(head, 0, "IMAGE_OT_reload"); // Reload...
+ uiMenuItemO(head, 0, "IMAGE_OT_save"); // Save
uiMenuItemO(head, 0, "IMAGE_OT_save_as"); // Save As...
if(ima->source == IMA_SRC_SEQUENCE)
uiMenuItemO(head, 0, "IMAGE_OT_save_changed"); // Save Changed Images
@@ -281,12 +258,15 @@ static void image_imagemenu(bContext *C, uiMenuItem *head, void *arg_unused)
/* only for dirty && specific image types : XXX poll? */
if(ibuf && (ibuf->userflags & IB_BITMAPDIRTY))
if(ELEM(ima->source, IMA_SRC_FILE, IMA_SRC_GENERATED) && ima->type != IMA_TYPE_MULTILAYER)
- uiMenuItemO(head, 0, "IMAGE_OT_pack_as_png"); // Pack Image As PNG
+ uiMenuItemBooleanO(head, "Pack As PNG", 0, "IMAGE_OT_pack", "as_png", 1); // Pack Image As PNG
uiMenuSeparator(head);
- /* XXX check state better */
uiMenuItemBooleanR(head, &spaceptr, "image_painting");
+
+ /* move to realtime properties panel */
+ RNA_id_pointer_create(&ima->id, &imaptr);
+ uiMenuLevelEnumR(head, &imaptr, "mapping");
}
}
@@ -317,15 +297,15 @@ static void image_uvs_showhidemenu(bContext *C, uiMenuItem *head, void *arg_unus
static void image_uvs_transformmenu(bContext *C, uiMenuItem *head, void *arg_unused)
{
- uiMenuItemEnumO(head, 0, "TFM_OT_transform", "mode", TFM_TRANSLATION);
- uiMenuItemEnumO(head, 0, "TFM_OT_transform", "mode", TFM_ROTATION);
- uiMenuItemEnumO(head, 0, "TFM_OT_transform", "mode", TFM_RESIZE);
+ uiMenuItemEnumO(head, "", 0, "TFM_OT_transform", "mode", TFM_TRANSLATION);
+ uiMenuItemEnumO(head, "", 0, "TFM_OT_transform", "mode", TFM_ROTATION);
+ uiMenuItemEnumO(head, "", 0, "TFM_OT_transform", "mode", TFM_RESIZE);
}
static void image_uvs_mirrormenu(bContext *C, uiMenuItem *head, void *arg_unused)
{
- uiMenuItemEnumO(head, 0, "UV_OT_mirror", "axis", 'x'); // "X Axis", M, 1
- uiMenuItemEnumO(head, 0, "UV_OT_mirror", "axis", 'y'); // "Y Axis", M, 2
+ uiMenuItemEnumO(head, "", 0, "UV_OT_mirror", "axis", 'x'); // "X Axis", M, 1
+ uiMenuItemEnumO(head, "", 0, "UV_OT_mirror", "axis", 'y'); // "Y Axis", M, 2
}
static void image_uvs_weldalignmenu(bContext *C, uiMenuItem *head, void *arg_unused)
@@ -369,26 +349,6 @@ static void image_uvs_scriptsmenu (void *args_unused)
#endif /* DISABLE_PYTHON */
#endif
-#if 0
-static void do_uvsmenu(bContext *C, void *arg, int event)
-{
- switch(event) {
- case 10:
- unwrap_lscm(0);
- break;
- case 12:
- minimize_stretch_tface_uv();
- break;
- case 13:
- pack_charts_tface_uv();
- break;
- case 14:
- average_charts_tface_uv();
- break;
- }
-}
-#endif
-
static void image_uvsmenu(bContext *C, uiMenuItem *head, void *arg_unused)
{
bScreen *sc= CTX_wm_screen(C);
@@ -490,13 +450,6 @@ static void do_image_buttons(bContext *C, void *arg, int event)
}
switch(event) {
- case B_SIMAPIN:
- allqueue (REDRAWIMAGE, 0);
- break;
- case B_SIMAGEHOME:
- image_home();
- break;
-
case B_SIMABROWSE:
if(sima->imanr== -2) {
if(G.qual & LR_CTRLKEY) {
@@ -541,14 +494,6 @@ static void do_image_buttons(bContext *C, void *arg, int event)
allqueue(REDRAWVIEW3D, 0);
allqueue(REDRAWIMAGE, 0);
break;
- case B_SIMAGEPAINTTOOL:
- if(sima->flag & SI_DRAWTOOL)
- /* add new brush if none exists */
- brush_check_exists(&G.scene->toolsettings->imapaint.brush);
- allqueue(REDRAWBUTSSHADING, 0);
- allqueue(REDRAWIMAGE, 0);
- allqueue(REDRAWVIEW3D, 0);
- break;
case B_SIMAPACKIMA:
pack_image_sima();
@@ -770,29 +715,19 @@ static void sima_idpoin_handle(bContext *C, ID *id, int event)
switch(event) {
case UI_ID_BROWSE:
case UI_ID_DELETE:
- ED_space_image_set(sima, scene, obedit, sima->image);
-
- if(sima->image && sima->image->id.us==0)
- sima->image->id.us= 1;
-
- if(obedit)
- WM_event_add_notifier(C, NC_OBJECT|ND_GEOM_DATA, obedit);
-
- ED_area_tag_redraw(CTX_wm_area(C));
+ ED_space_image_set(C, sima, scene, obedit, sima->image);
ED_undo_push(C, "Assign Image UV");
break;
case UI_ID_RENAME:
break;
case UI_ID_ADD_NEW:
- /* XXX not implemented */
+ WM_operator_name_call(C, "IMAGE_OT_new", WM_OP_INVOKE_REGION_WIN, NULL);
break;
case UI_ID_OPEN:
- /* XXX not implemented */
- break;
- case UI_ID_ALONE:
- /* XXX not implemented */
+ WM_operator_name_call(C, "IMAGE_OT_open", WM_OP_INVOKE_REGION_WIN, NULL);
break;
case UI_ID_PIN:
+ ED_area_tag_refresh(CTX_wm_area(C));
break;
}
}
@@ -808,7 +743,7 @@ void image_header_buttons(const bContext *C, ARegion *ar)
uiBlock *block;
uiBut *but;
PointerRNA spaceptr, uvptr, sceneptr;
- int xco, yco= 3, show_uvedit, show_render, show_paint;
+ int xco, yco= 3, show_uvedit, show_render, show_paint, pinflag;
/* retrieve state */
ima= ED_space_image(sima);
@@ -861,35 +796,27 @@ void image_header_buttons(const bContext *C, ARegion *ar)
/* image select */
+ pinflag= (show_render)? 0: UI_ID_PIN;
xco= uiDefIDPoinButs(block, CTX_data_main(C), NULL, (ID**)&sima->image, ID_IM, &sima->pin, xco, yco,
- sima_idpoin_handle, UI_ID_BROWSE|UI_ID_BROWSE_RENDER|UI_ID_RENAME|UI_ID_ADD_NEW|UI_ID_OPEN|UI_ID_DELETE|UI_ID_ALONE|UI_ID_PIN);
+ sima_idpoin_handle, UI_ID_BROWSE|UI_ID_BROWSE_RENDER|UI_ID_RENAME|UI_ID_ADD_NEW|UI_ID_OPEN|UI_ID_DELETE|pinflag);
xco += 8;
-#if 0
- char naam[256];
-
- /* This should not be a static var */
- static int headerbuttons_packdummy;
-
- headerbuttons_packdummy = 0;
-
- int allow_pin= (show_render)? 0: B_SIMAPIN;
-
- xco= 8 + std_libbuttons(block, xco, yco, allow_pin, &sima->pin, B_SIMABROWSE, ID_IM, 0, (ID *)ima, 0, &(sima->imanr), 0, 0, B_IMAGEDELETE, 0, 0);
-
if(ima && !ELEM3(ima->source, IMA_SRC_SEQUENCE, IMA_SRC_MOVIE, IMA_SRC_VIEWER) && ima->ok) {
+ /* XXX this should not be a static var */
+ static int headerbuttons_packdummy;
+
+ headerbuttons_packdummy = 0;
if (ima->packedfile) {
headerbuttons_packdummy = 1;
}
if (ima->packedfile && ibuf && (ibuf->userflags & IB_BITMAPDIRTY))
- uiDefIconButBitI(block, TOG, 1, B_SIMA_REPACK, ICON_UGLYPACKAGE, xco,yco,XIC,YIC, &headerbuttons_packdummy, 0, 0, 0, 0, "Re-Pack this image as PNG");
+ uiDefIconButBitI(block, TOG, 1, 0 /* XXX B_SIMA_REPACK */, ICON_UGLYPACKAGE, xco,yco,XIC,YIC, &headerbuttons_packdummy, 0, 0, 0, 0, "Re-Pack this image as PNG");
else
- uiDefIconButBitI(block, TOG, 1, B_SIMAPACKIMA, ICON_PACKAGE, xco,yco,XIC,YIC, &headerbuttons_packdummy, 0, 0, 0, 0, "Pack/Unpack this image");
+ uiDefIconButBitI(block, TOG, 1, 0 /* XXX B_SIMAPACKIMA */, ICON_PACKAGE, xco,yco,XIC,YIC, &headerbuttons_packdummy, 0, 0, 0, 0, "Pack/Unpack this image");
xco+= XIC+8;
}
-#endif
/* uv editing */
if(show_uvedit) {
@@ -955,7 +882,7 @@ void image_header_buttons(const bContext *C, ARegion *ar)
}
uiBlockEndAlign(block);
- xco+= 10;
+ xco+= 8;
/* uv layers */
{
@@ -968,14 +895,14 @@ void image_header_buttons(const bContext *C, ARegion *ar)
but = uiDefButI(block, MENU, B_NOP, menustr ,xco,yco,85,YIC, &act, 0, 0, 0, 0, "Active UV Layer for editing.");
// uiButSetFunc(but, do_image_buttons_set_uvlayer_callback, &act, NULL);
- xco+= 90;
+ xco+= 85;
}
+
+ xco+= 8;
}
if(ima) {
RenderResult *rr;
-
- xco+= 8;
/* render layers and passes */
rr= BKE_image_get_renderresult(scene, ima);
@@ -1013,7 +940,7 @@ void image_header_buttons(const bContext *C, ARegion *ar)
/* record & play */
uiBlockBeginAlign(block);
if(ima->type==IMA_TYPE_COMPOSITE) {
-//XXX uiDefIconButO(block, BUT, "IMAGE_OT_record_composite", WM_OP_INVOKE_REGION_WIN, ICON_REC, xco, yco, XIC, YIC, NULL); // Record Composite
+ uiDefIconButO(block, BUT, "IMAGE_OT_record_composite", WM_OP_INVOKE_REGION_WIN, ICON_REC, xco, yco, XIC, YIC, NULL); // Record Composite
xco+= XIC;
}
if((ima->type==IMA_TYPE_COMPOSITE) || ELEM(ima->source, IMA_SRC_MOVIE, IMA_SRC_SEQUENCE)) {
diff --git a/source/blender/editors/space_image/image_intern.h b/source/blender/editors/space_image/image_intern.h
index bbf0ed792c0..384689bb000 100644
--- a/source/blender/editors/space_image/image_intern.h
+++ b/source/blender/editors/space_image/image_intern.h
@@ -46,6 +46,7 @@ void IMAGE_OT_toolbox(struct wmOperatorType *ot);
/* image_draw.c */
void draw_image_main(struct SpaceImage *sima, struct ARegion *ar, struct Scene *scene);
+void draw_image_info(struct ARegion *ar, int channels, int x, int y, char *cp, float *fp, int *zp, float *zpf);
/* image_ops.c */
int space_image_main_area_poll(struct bContext *C);
@@ -58,6 +59,19 @@ void IMAGE_OT_view_zoom_in(struct wmOperatorType *ot);
void IMAGE_OT_view_zoom_out(struct wmOperatorType *ot);
void IMAGE_OT_view_zoom_ratio(struct wmOperatorType *ot);
+void IMAGE_OT_new(struct wmOperatorType *ot);
+void IMAGE_OT_open(struct wmOperatorType *ot);
+void IMAGE_OT_replace(struct wmOperatorType *ot);
+void IMAGE_OT_reload(struct wmOperatorType *ot);
+void IMAGE_OT_save(struct wmOperatorType *ot);
+void IMAGE_OT_save_as(struct wmOperatorType *ot);
+void IMAGE_OT_save_sequence(struct wmOperatorType *ot);
+void IMAGE_OT_pack(struct wmOperatorType *ot);
+void IMAGE_OT_unpack(struct wmOperatorType *ot);
+void IMAGE_OT_sample(struct wmOperatorType *ot);
+
+void IMAGE_OT_record_composite(struct wmOperatorType *ot);
+
/* uvedit_draw.c */
void draw_uvedit_main(struct SpaceImage *sima, struct ARegion *ar, struct Scene *scene, struct Object *obedit);
diff --git a/source/blender/editors/space_image/image_ops.c b/source/blender/editors/space_image/image_ops.c
index afda954b074..6ad1207f7cd 100644
--- a/source/blender/editors/space_image/image_ops.c
+++ b/source/blender/editors/space_image/image_ops.c
@@ -47,6 +47,7 @@
#include "BKE_library.h"
#include "BKE_node.h"
#include "BKE_packedFile.h"
+#include "BKE_report.h"
#include "BKE_screen.h"
#include "BLI_arithb.h"
@@ -62,58 +63,18 @@
#include "RNA_types.h"
#include "ED_image.h"
+#include "ED_fileselect.h"
#include "ED_screen.h"
+#include "ED_space_api.h"
#include "ED_uvedit.h"
+#include "UI_view2d.h"
+
#include "WM_api.h"
#include "WM_types.h"
#include "image_intern.h"
-void imagespace_composite_flipbook(SpaceImage *sima, Scene *scene)
-{
- ImBuf *ibuf;
- int cfrao= scene->r.cfra;
- int sfra, efra;
-
- if(sima->iuser.frames<2)
- return;
- if(scene->nodetree==NULL)
- return;
-
- sfra= sima->iuser.sfra;
- efra= sima->iuser.sfra + sima->iuser.frames-1;
- scene->nodetree->test_break= NULL; // XXX blender_test_break;
-
- for(scene->r.cfra=sfra; scene->r.cfra<=efra; scene->r.cfra++) {
-
- // XXX set_timecursor(CFRA);
-
- BKE_image_all_free_anim_ibufs(CFRA);
- ntreeCompositTagAnimated(scene->nodetree);
- ntreeCompositExecTree(scene->nodetree, &scene->r, scene->r.cfra!=cfrao); /* 1 is no previews */
-
- // XXX force_draw(0);
-
- ibuf= BKE_image_get_ibuf(sima->image, &sima->iuser);
- /* save memory in flipbooks */
- if(ibuf)
- imb_freerectfloatImBuf(ibuf);
-
- // XXX if(blender_test_break())
- // XXX break;
- }
- scene->nodetree->test_break= NULL;
- // XXX waitcursor(0);
-
- // XXX play_anim(0);
-
- // XXX allqueue(REDRAWNODE, 1);
- // XXX allqueue(REDRAWIMAGE, 1);
-
- scene->r.cfra= cfrao;
-}
-
/******************** view navigation utilities *********************/
static void sima_zoom_set(SpaceImage *sima, ARegion *ar, float zoom)
@@ -145,6 +106,13 @@ static void sima_zoom_set_factor(SpaceImage *sima, ARegion *ar, float zoomfac)
sima_zoom_set(sima, ar, sima->zoom*zoomfac);
}
+int space_image_poll(bContext *C)
+{
+ SpaceLink *slink= CTX_wm_space_data(C);
+
+ return (slink && (slink->spacetype == SPACE_IMAGE));
+}
+
int space_image_main_area_poll(bContext *C)
{
SpaceLink *slink= CTX_wm_space_data(C);
@@ -268,9 +236,6 @@ void IMAGE_OT_view_pan(wmOperatorType *ot)
ot->cancel= view_pan_cancel;
ot->poll= space_image_main_area_poll;
- /* flags */
- ot->flag= OPTYPE_REGISTER;
-
/* properties */
RNA_def_float_vector(ot->srna, "offset", 2, NULL, -FLT_MAX, FLT_MAX,
"Offset", "Offset in floating point units, 1.0 is the width and height of the image.", -FLT_MAX, FLT_MAX);
@@ -383,9 +348,6 @@ void IMAGE_OT_view_zoom(wmOperatorType *ot)
ot->cancel= view_zoom_cancel;
ot->poll= space_image_main_area_poll;
- /* flags */
- ot->flag= OPTYPE_REGISTER;
-
/* properties */
RNA_def_float(ot->srna, "factor", 0.0f, 0.0f, FLT_MAX,
"Factor", "Zoom factor, values higher than 1.0 zoom in, lower values zoom out.", -FLT_MAX, FLT_MAX);
@@ -451,9 +413,6 @@ void IMAGE_OT_view_all(wmOperatorType *ot)
/* api callbacks */
ot->exec= view_all_exec;
ot->poll= space_image_main_area_poll;
-
- /* flags */
- ot->flag= OPTYPE_REGISTER;
}
/********************** view selected operator *********************/
@@ -508,9 +467,6 @@ void IMAGE_OT_view_selected(wmOperatorType *ot)
/* api callbacks */
ot->exec= view_selected_exec;
ot->poll= ED_operator_uvedit;
-
- /* flags */
- ot->flag= OPTYPE_REGISTER;
}
/********************** view zoom in/out operator *********************/
@@ -536,9 +492,6 @@ void IMAGE_OT_view_zoom_in(wmOperatorType *ot)
/* api callbacks */
ot->exec= view_zoom_in_exec;
ot->poll= space_image_main_area_poll;
-
- /* flags */
- ot->flag= OPTYPE_REGISTER;
}
static int view_zoom_out_exec(bContext *C, wmOperator *op)
@@ -562,9 +515,6 @@ void IMAGE_OT_view_zoom_out(wmOperatorType *ot)
/* api callbacks */
ot->exec= view_zoom_out_exec;
ot->poll= space_image_main_area_poll;
-
- /* flags */
- ot->flag= OPTYPE_REGISTER;
}
/********************** view zoom ratio operator *********************/
@@ -604,42 +554,165 @@ void IMAGE_OT_view_zoom_ratio(wmOperatorType *ot)
ot->exec= view_zoom_ratio_exec;
ot->poll= space_image_main_area_poll;
- /* flags */
- ot->flag= OPTYPE_REGISTER;
-
/* properties */
RNA_def_float(ot->srna, "ratio", 0.0f, 0.0f, FLT_MAX,
"Ratio", "Zoom ratio, 1.0 is 1:1, higher is zoomed in, lower is zoomed out.", -FLT_MAX, FLT_MAX);
}
-/* Image functions */
+/**************** load/replace/save callbacks ******************/
-#if 0
-static void load_image_filesel(SpaceImage *sima, Scene *scene, Object *obedit, char *str) /* called from fileselect */
+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;
+}
+
+static void image_filesel(bContext *C, wmOperator *op, const char *path)
+{
+ SpaceFile *sfile;
+
+ ED_screen_full_newspace(C, CTX_wm_area(C), SPACE_FILE);
+
+ /* settings for filebrowser */
+ sfile= (SpaceFile*)CTX_wm_space_data(C);
+ sfile->op= op;
+
+ /* XXX right params for image filter browse, filters, .. */
+ ED_fileselect_set_params(sfile, FILE_SPECIAL, op->type->name, path, 0, 0, 0);
+}
+
+/******************** open image operator ********************/
+
+static int open_exec(bContext *C, wmOperator *op)
+{
+ SpaceImage *sima= (SpaceImage*)CTX_wm_space_data(C);
+ Scene *scene= CTX_data_scene(C);
+ Object *obedit= CTX_data_edit_object(C);
Image *ima= NULL;
+ char *str;
+ str= RNA_string_get_alloc(op->ptr, "filename", NULL, 0);
ima= BKE_add_image_file(str, scene->r.cfra);
- if(ima) {
- BKE_image_signal(ima, &sima->iuser, IMA_SIGNAL_RELOAD);
- ED_space_image_set(sima, scene, obedit, ima);
- }
- // XXX BIF_undo_push("Load image UV");
- // XXX allqueue(REDRAWIMAGE, 0);
+ MEM_freeN(str);
+
+ if(!ima)
+ return OPERATOR_CANCELLED;
+
+ return OPERATOR_FINISHED; // XXX context not correct!
+
+ BKE_image_signal(ima, &sima->iuser, IMA_SIGNAL_RELOAD);
+ ED_space_image_set(C, sima, scene, obedit, ima);
+
+ return OPERATOR_FINISHED;
}
-static void replace_image_filesel(SpaceImage *sima, char *str) /* called from fileselect */
+static int open_invoke(bContext *C, wmOperator *op, wmEvent *event)
{
- if (!sima->image)
- return;
+ SpaceImage *sima= (SpaceImage*)CTX_wm_space_data(C);
+ char *path= (sima->image)? sima->image->name: U.textudir;
+
+ if(RNA_property_is_set(op->ptr, "filename"))
+ return open_exec(C, op);
+
+ image_filesel(C, op, path);
+
+ return OPERATOR_RUNNING_MODAL;
+}
+
+void IMAGE_OT_open(wmOperatorType *ot)
+{
+ /* identifiers */
+ ot->name= "Open";
+ ot->idname= "IMAGE_OT_open";
+
+ /* api callbacks */
+ ot->exec= open_exec;
+ ot->invoke= open_invoke;
+ ot->poll= space_image_poll;
+
+ /* flags */
+ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
+
+ /* properties */
+ RNA_def_string_file_path(ot->srna, "filename", "", 0, "Filename", "File path of image to open.");
+}
+
+/******************** replace image operator ********************/
+
+static int replace_exec(bContext *C, wmOperator *op)
+{
+ SpaceImage *sima= (SpaceImage*)CTX_wm_space_data(C);
+ char *str;
+
+ return OPERATOR_CANCELLED; // XXX context not correct!
+
+ if(!sima->image)
+ return OPERATOR_CANCELLED;
+ str= RNA_string_get_alloc(op->ptr, "filename", NULL, 0);
BLI_strncpy(sima->image->name, str, sizeof(sima->image->name)-1); /* we cant do much if the str is longer then 240 :/ */
+ MEM_freeN(str);
+
BKE_image_signal(sima->image, &sima->iuser, IMA_SIGNAL_RELOAD);
- // XXX BIF_undo_push("Replace image UV");
- // XXX allqueue(REDRAWIMAGE, 0);
- // XXX allqueue(REDRAWVIEW3D, 0);
+
+ return OPERATOR_FINISHED;
}
-#endif
+
+static int replace_invoke(bContext *C, wmOperator *op, wmEvent *event)
+{
+ SpaceImage *sima= (SpaceImage*)CTX_wm_space_data(C);
+ char *path= (sima->image)? sima->image->name: U.textudir;
+
+ if(!sima->image)
+ return OPERATOR_CANCELLED;
+
+ if(RNA_property_is_set(op->ptr, "filename"))
+ return replace_exec(C, op);
+
+ image_filesel(C, op, path);
+
+ return OPERATOR_RUNNING_MODAL;
+}
+
+void IMAGE_OT_replace(wmOperatorType *ot)
+{
+ /* identifiers */
+ ot->name= "Replace";
+ ot->idname= "IMAGE_OT_replace";
+
+ /* api callbacks */
+ ot->exec= replace_exec;
+ ot->invoke= replace_invoke;
+ ot->poll= space_image_poll;
+
+ /* flags */
+ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
+
+ /* properties */
+ RNA_def_string_file_path(ot->srna, "filename", "", 0, "Filename", "File path of image to replace current image with.");
+}
+
+/******************** save image as operator ********************/
static void save_image_doit(SpaceImage *sima, Scene *scene, char *name)
{
@@ -660,7 +733,7 @@ static void save_image_doit(SpaceImage *sima, Scene *scene, char *name)
BKE_add_image_extension(scene, name, sima->imtypenr);
}
- if (1) { // XXX saveover(str)) {
+ if(1) { // XXX saveover(str)) {
/* enforce user setting for RGB or RGBA, but skip BW */
if(scene->r.planes==32)
@@ -668,7 +741,8 @@ static void save_image_doit(SpaceImage *sima, Scene *scene, char *name)
else if(scene->r.planes==24)
ibuf->depth= 24;
- // XXX waitcursor(1);
+ WM_cursor_wait(1);
+
if(sima->imtypenr==R_MULTILAYER) {
RenderResult *rr= BKE_image_get_renderresult(scene, ima);
if(rr) {
@@ -710,133 +784,152 @@ static void save_image_doit(SpaceImage *sima, Scene *scene, char *name)
// XXX allqueue(REDRAWHEADERS, 0);
// XXX allqueue(REDRAWBUTSSHADING, 0);
- // XXX waitcursor(0);
+ WM_cursor_wait(0);
}
}
}
-void open_image_sima(SpaceImage *sima, short imageselect)
+static int save_as_exec(bContext *C, wmOperator *op)
{
- char name[FILE_MAXDIR+FILE_MAXFILE];
+ SpaceImage *sima= (SpaceImage*)CTX_wm_space_data(C);
+ Scene *scene= CTX_data_scene(C);
+ //Image *ima = ED_space_image(sima);
+ char *str;
- if(sima->image)
- BLI_strncpy(name, sima->image->name, sizeof(name));
- else
- BLI_strncpy(name, U.textudir, sizeof(name));
+ return OPERATOR_CANCELLED; // XXX context not correct!
- if(imageselect)
- ; // XXX activate_imageselect(FILE_SPECIAL, "Open Image", name, load_image_filesel);
- else
- ; // XXX activate_fileselect(FILE_SPECIAL, "Open Image", name, load_image_filesel);
+ /*if(!ima)
+ return OPERATOR_CANCELLED;*/
+
+ str= RNA_string_get_alloc(op->ptr, "filename", NULL, 0);
+ save_image_doit(sima, scene, str);
+ MEM_freeN(str);
+
+ return OPERATOR_FINISHED;
}
-void replace_image_sima(SpaceImage *sima, short imageselect)
+static int save_as_invoke(bContext *C, wmOperator *op, wmEvent *event)
{
- char name[FILE_MAXDIR+FILE_MAXFILE];
+ SpaceImage *sima= (SpaceImage*)CTX_wm_space_data(C);
+ Image *ima = ED_space_image(sima);
+ ImBuf *ibuf= ED_space_image_buffer(sima);
+ Scene *scene= CTX_data_scene(C);
- if(sima->image)
- BLI_strncpy(name, sima->image->name, sizeof(name));
- else
- BLI_strncpy(name, U.textudir, sizeof(name));
+ if(RNA_property_is_set(op->ptr, "filename"))
+ return save_as_exec(C, op);
- if(imageselect)
- ; // XXX activate_imageselect(FILE_SPECIAL, "Replace Image", name, replace_image_filesel);
- else
- ; // XXX activate_fileselect(FILE_SPECIAL, "Replace Image", name, replace_image_filesel);
-}
+ if(!ima)
+ return OPERATOR_CANCELLED;
+
+ /* always opens fileselect */
+ if(ibuf) {
+ char *strp;
+
+ strp= filesel_imagetype_string(ima);
+
+ /* 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))
+ sima->imtypenr= R_MULTILAYER;
+ else if(ima->type==IMA_TYPE_R_RESULT)
+ sima->imtypenr= scene->r.imtype;
+ else
+ sima->imtypenr= BKE_ftype_to_imtype(ibuf->ftype);
+
+ // XXX activate_fileselect_menu(FILE_SPECIAL, "Save Image", name, strp, &sima->imtypenr, save_image_doit);
+
+ image_filesel(C, op, ima->name);
+ return OPERATOR_RUNNING_MODAL;
+ }
-static char *filesel_imagetype_string(Image *ima)
+ return OPERATOR_CANCELLED;
+}
+
+void IMAGE_OT_save_as(wmOperatorType *ot)
{
- char *strp, *str= MEM_callocN(14*32, "menu for filesel");
+ /* identifiers */
+ ot->name= "Save As";
+ ot->idname= "IMAGE_OT_save_as";
- 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;
+ /* api callbacks */
+ ot->exec= save_as_exec;
+ ot->invoke= save_as_invoke;
+ ot->poll= space_image_poll;
+
+ /* flags */
+ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
+
+ /* properties */
+ RNA_def_string_file_path(ot->srna, "filename", "", 0, "Filename", "File path to save image to.");
}
-/* always opens fileselect */
-void save_as_image_sima(SpaceImage *sima, Scene *scene)
+/******************** save image operator ********************/
+
+static int save_exec(bContext *C, wmOperator *op)
{
- Image *ima = sima->image;
+ SpaceImage *sima= (SpaceImage*)CTX_wm_space_data(C);
+ Image *ima = ED_space_image(sima);
ImBuf *ibuf= ED_space_image_buffer(sima);
+ Scene *scene= CTX_data_scene(C);
char name[FILE_MAXDIR+FILE_MAXFILE];
- if (ima) {
- strcpy(name, ima->name);
+ if(!ima)
+ return OPERATOR_CANCELLED;
- if (ibuf) {
- char *strp;
-
- strp= filesel_imagetype_string(ima);
-
- /* 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))
+ /* if exists, saves over without fileselect */
+
+ strcpy(name, ima->name);
+
+ if(ibuf) {
+ if(BLI_exists(ibuf->name)) {
+ if(BKE_image_get_renderresult(scene, ima))
sima->imtypenr= R_MULTILAYER;
- else if(ima->type==IMA_TYPE_R_RESULT)
- sima->imtypenr= scene->r.imtype;
- else sima->imtypenr= BKE_ftype_to_imtype(ibuf->ftype);
+ else
+ sima->imtypenr= BKE_ftype_to_imtype(ibuf->ftype);
- // XXX activate_fileselect_menu(FILE_SPECIAL, "Save Image", name, strp, &sima->imtypenr, save_image_doit);
+ save_image_doit(sima, scene, ibuf->name);
}
+ else
+ return save_as_exec(C, op);
}
+
+ return OPERATOR_FINISHED;
}
-/* if exists, saves over without fileselect */
-void save_image_sima(SpaceImage *sima, Scene *scene)
+void IMAGE_OT_save(wmOperatorType *ot)
{
- Image *ima = ED_space_image(sima);
- ImBuf *ibuf= ED_space_image_buffer(sima);
- char name[FILE_MAXDIR+FILE_MAXFILE];
-
- if (ima) {
- strcpy(name, ima->name);
+ /* identifiers */
+ ot->name= "Save";
+ ot->idname= "IMAGE_OT_save";
+
+ /* api callbacks */
+ ot->exec= save_exec;
+ ot->poll= space_image_poll;
- if (ibuf) {
- if (BLI_exists(ibuf->name)) {
- if(BKE_image_get_renderresult(scene, ima))
- sima->imtypenr= R_MULTILAYER;
- else
- sima->imtypenr= BKE_ftype_to_imtype(ibuf->ftype);
-
- save_image_doit(sima, scene, ibuf->name);
- }
- else
- save_as_image_sima(sima, scene);
- }
- }
+ /* flags */
+ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
}
-void save_image_sequence_sima(SpaceImage *sima)
+/******************* save sequence operator ********************/
+
+static int save_sequence_exec(bContext *C, wmOperator *op)
{
+ SpaceImage *sima= (SpaceImage*)CTX_wm_space_data(C);
ImBuf *ibuf;
int tot= 0;
char di[FILE_MAX], fi[FILE_MAX];
if(sima->image==NULL)
- return;
- if(sima->image->source!=IMA_SRC_SEQUENCE)
- return;
+ return OPERATOR_CANCELLED;
+
+ if(sima->image->source!=IMA_SRC_SEQUENCE) {
+ BKE_report(op->reports, RPT_ERROR, "Can only save sequence on image sequences.");
+ return OPERATOR_CANCELLED;
+ }
+
if(sima->image->type==IMA_TYPE_MULTILAYER) {
- // XXX error("Cannot save Multilayer Sequences");
- return;
+ BKE_report(op->reports, RPT_ERROR, "Can't save multilayer sequences.");
+ return OPERATOR_CANCELLED;
}
/* get total */
@@ -845,9 +938,10 @@ void save_image_sequence_sima(SpaceImage *sima)
tot++;
if(tot==0) {
- // XXX notice("No Images have been changed");
- return;
+ BKE_report(op->reports, RPT_WARNING, "No images have been changed.");
+ return OPERATOR_CANCELLED;
}
+
/* get a filename for menu */
for(ibuf= sima->image->ibufs.first; ibuf; ibuf= ibuf->next)
if(ibuf->userflags & IB_BITMAPDIRTY)
@@ -857,6 +951,7 @@ void save_image_sequence_sima(SpaceImage *sima)
BLI_splitdirstring(di, fi);
sprintf(fi, "%d Image(s) will be saved in %s", tot, di);
+
if(1) { // XXX okee(fi)) {
for(ibuf= sima->image->ibufs.first; ibuf; ibuf= ibuf->next) {
@@ -867,7 +962,7 @@ void save_image_sequence_sima(SpaceImage *sima)
BLI_convertstringcode(name, G.sce);
if(0 == IMB_saveiff(ibuf, name, IB_rect | IB_zbuf | IB_zbuffloat)) {
- // XXX error("Could not write image", name);
+ BKE_reportf(op->reports, RPT_ERROR, "Could not write image %s.", name);
break;
}
printf("Saved: %s\n", ibuf->name);
@@ -875,86 +970,555 @@ void save_image_sequence_sima(SpaceImage *sima)
}
}
}
+
+ return OPERATOR_FINISHED;
}
-void reload_image_sima(SpaceImage *sima)
+void IMAGE_OT_save_sequence(wmOperatorType *ot)
{
- if (sima ) {
- BKE_image_signal(sima->image, &sima->iuser, IMA_SIGNAL_RELOAD);
- /* ED_space_image_set(sima, scene, obedit, NULL); - do we really need this? */
- }
+ /* identifiers */
+ ot->name= "Save Sequence";
+ ot->idname= "IMAGE_OT_save_sequence";
+
+ /* api callbacks */
+ ot->exec= save_sequence_exec;
+ ot->poll= space_image_poll;
- // XXX allqueue(REDRAWIMAGE, 0);
- // XXX allqueue(REDRAWVIEW3D, 0);
+ /* flags */
+ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
+}
+
+/******************** reload image operator ********************/
+
+static int reload_exec(bContext *C, wmOperator *op)
+{
+ SpaceImage *sima;
+
+ /* retrieve state */
+ sima= (SpaceImage*)CTX_wm_space_data(C);
+
+ if(!sima->image)
+ return OPERATOR_CANCELLED;
+
+ BKE_image_signal(sima->image, &sima->iuser, IMA_SIGNAL_RELOAD);
+ /* ED_space_image_set(C, sima, scene, obedit, NULL); - do we really need this? */
+
+ // XXX notifier
// XXX BIF_preview_changed(ID_TE);
+ ED_area_tag_redraw(CTX_wm_area(C));
+
+ return OPERATOR_FINISHED;
}
-void new_image_sima(SpaceImage *sima, Scene *scene, Object *obedit)
+void IMAGE_OT_reload(wmOperatorType *ot)
{
- static int width= 1024, height= 1024;
- static short uvtestgrid= 0;
- static int floatbuf=0;
- static float color[] = {0, 0, 0, 1};
- char name[22];
- Image *ima;
+ /* identifiers */
+ ot->name= "Reload";
+ ot->idname= "IMAGE_OT_reload";
- strcpy(name, "Untitled");
+ /* api callbacks */
+ ot->exec= reload_exec;
+ ot->poll= space_image_poll;
-#if 0
- add_numbut(0, TEX, "Name:", 0, 21, name, NULL);
- add_numbut(1, NUM|INT, "Width:", 1, 16384, &width, NULL);
- add_numbut(2, NUM|INT, "Height:", 1, 16384, &height, NULL);
- add_numbut(3, COL, "", 0, 0, &color, NULL);
- add_numbut(4, NUM|FLO, "Alpha:", 0.0, 1.0, &color[3], NULL);
- add_numbut(5, TOG|SHO, "UV Test Grid", 0, 0, &uvtestgrid, NULL);
- add_numbut(6, TOG|INT, "32 bit Float", 0, 0, &floatbuf, NULL);
- if (!do_clever_numbuts("New Image", 7, REDRAW))
- return;
-#endif
+ /* flags */
+ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
+}
+
+/********************** new image operator *********************/
+
+static int new_exec(bContext *C, wmOperator *op)
+{
+ SpaceImage *sima;
+ Scene *scene;
+ Object *obedit;
+ Image *ima;
+ char name[22];
+ float color[4];
+ int width, height, floatbuf, uvtestgrid;
+
+ /* retrieve state */
+ sima= (SpaceImage*)CTX_wm_space_data(C);
+ scene= (Scene*)CTX_data_scene(C);
+ obedit= CTX_data_edit_object(C);
+
+ RNA_string_get(op->ptr, "name", name);
+ width= RNA_int_get(op->ptr, "width");
+ height= RNA_int_get(op->ptr, "height");
+ floatbuf= RNA_boolean_get(op->ptr, "float");
+ uvtestgrid= RNA_boolean_get(op->ptr, "uv_test_grid");
+ RNA_float_get_array(op->ptr, "color", color);
+ color[3]= RNA_float_get(op->ptr, "alpha");
ima = BKE_add_image_size(width, height, name, floatbuf, uvtestgrid, color);
- ED_space_image_set(sima, scene, obedit, ima);
BKE_image_signal(sima->image, &sima->iuser, IMA_SIGNAL_USER_NEW_IMAGE);
- // XXX BIF_undo_push("Add image");
+ ED_space_image_set(C, sima, scene, obedit, ima);
+
+ return OPERATOR_FINISHED;
+}
+
+void IMAGE_OT_new(wmOperatorType *ot)
+{
+ /* identifiers */
+ ot->name= "New";
+ ot->idname= "IMAGE_OT_new";
+
+ /* api callbacks */
+ ot->exec= new_exec;
+ ot->poll= space_image_poll;
+
+ /* flags */
+ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
+
+ /* properties */
+ RNA_def_string(ot->srna, "name", "Untitled", 21, "Name", "Image datablock name.");
+ RNA_def_int(ot->srna, "width", 1024, 1, INT_MAX, "Width", "Image width.", 1, 16384);
+ RNA_def_int(ot->srna, "height", 1024, 1, INT_MAX, "Height", "Image height.", 1, 16384);
+ RNA_def_float_color(ot->srna, "color", 3, NULL, 0.0f, FLT_MAX, "Color", "Default fill color.", 0.0f, 1.0f);
+ RNA_def_float(ot->srna, "alpha", 1.0f, 0.0f, 1.0f, "Alpha", "Default fill alpha.", 0.0f, 1.0f);
+ RNA_def_boolean(ot->srna, "uv_test_grid", 0, "UV Test Grid", "Fill the image with a grid for UV map testing.");
+ RNA_def_boolean(ot->srna, "float", 0, "32 bit Float", "Create image with 32 bit floating point bit depth.");
+}
- // XXX allqueue(REDRAWIMAGE, 0);
- // XXX allqueue(REDRAWVIEW3D, 0);
+/********************* pack operator *********************/
+
+static int pack_exec(bContext *C, wmOperator *op)
+{
+ SpaceImage *sima= (SpaceImage*)CTX_wm_space_data(C);
+ Image *ima= CTX_data_edit_image(C);
+ ImBuf *ibuf= ED_space_image_buffer(sima);
+ int as_png= RNA_boolean_get(op->ptr, "as_png");
+
+ if(!ima)
+ return OPERATOR_CANCELLED;
+ if(!as_png && ima->packedfile)
+ return OPERATOR_CANCELLED;
+
+ if(ima->source==IMA_SRC_SEQUENCE || ima->source==IMA_SRC_MOVIE) {
+ BKE_report(op->reports, RPT_ERROR, "Can't pack movie or image sequence.");
+ return OPERATOR_CANCELLED;
+ }
+
+ if(as_png || (ibuf && (ibuf->userflags & IB_BITMAPDIRTY))) {
+ if(1) // XXX okee("Can't pack painted image. Use Repack as PNG?"))
+ BKE_image_memorypack(ima);
+ }
+ else {
+ ima->packedfile = newPackedFile(ima->name);
+ // XXX BIF_undo_push("Pack image");
+ }
+
+ return OPERATOR_CANCELLED;
+}
+
+void IMAGE_OT_pack(wmOperatorType *ot)
+{
+ /* identifiers */
+ ot->name= "Pack";
+ ot->idname= "IMAGE_OT_pack";
+
+ /* api callbacks */
+ ot->exec= pack_exec;
+ ot->poll= space_image_poll;
+
+ /* flags */
+ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
+
+ /* properties */
+ RNA_def_boolean(ot->srna, "as_png", 0, "Pack As PNG", "Pack image as lossless PNG.");
}
-void pack_image_sima(SpaceImage *sima)
+/********************* unpack operator *********************/
+
+static int unpack_exec(bContext *C, wmOperator *op)
{
- Image *ima = sima->image;
+ Image *ima= CTX_data_edit_image(C);
- if (ima) {
- if(ima->source!=IMA_SRC_SEQUENCE && ima->source!=IMA_SRC_MOVIE) {
- if (ima->packedfile) {
- if (G.fileflags & G_AUTOPACK)
- if (1) // XXX okee("Disable AutoPack?"))
- G.fileflags &= ~G_AUTOPACK;
-
- if ((G.fileflags & G_AUTOPACK) == 0) {
- unpackImage(ima, PF_ASK);
- // XXX BIF_undo_push("Unpack image");
+ if(!ima)
+ return OPERATOR_CANCELLED;
+ if(!ima->packedfile)
+ return OPERATOR_CANCELLED;
+
+ if(ima->source==IMA_SRC_SEQUENCE || ima->source==IMA_SRC_MOVIE) {
+ BKE_report(op->reports, RPT_ERROR, "Can't unpack movie or image sequence.");
+ return OPERATOR_CANCELLED;
+ }
+
+ if(G.fileflags & G_AUTOPACK)
+ if(1) // XXX okee("Disable AutoPack?"))
+ G.fileflags &= ~G_AUTOPACK;
+
+ if((G.fileflags & G_AUTOPACK) == 0) {
+ unpackImage(ima, PF_ASK);
+ // XXX BIF_undo_push("Ununpack image");
+ }
+
+ return OPERATOR_CANCELLED;
+}
+
+void IMAGE_OT_unpack(wmOperatorType *ot)
+{
+ /* identifiers */
+ ot->name= "Unpack";
+ ot->idname= "IMAGE_OT_unpack";
+
+ /* api callbacks */
+ ot->exec= unpack_exec;
+ ot->poll= space_image_poll;
+
+ /* flags */
+ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
+}
+
+/******************** sample image operator ********************/
+
+typedef struct ImageSampleInfo {
+ ARegionType *art;
+ void *draw_handle;
+ int x, y;
+
+ char col[4];
+ float colf[4];
+ int z;
+ float zf;
+
+ char *colp;
+ float *colfp;
+ int *zp;
+ float *zfp;
+
+ int draw;
+} ImageSampleInfo;
+
+static void sample_draw(const bContext *C, ARegion *ar, void *arg_info)
+{
+ SpaceImage *sima= (SpaceImage*)CTX_wm_space_data(C);
+ ImBuf *ibuf= ED_space_image_buffer(sima);
+ ImageSampleInfo *info= arg_info;
+
+ draw_image_info(ar, ibuf->channels, info->x, info->y, info->colp,
+ info->colfp, info->zp, info->zfp);
+}
+
+static void sample_apply(bContext *C, wmOperator *op, wmEvent *event)
+{
+ SpaceImage *sima= (SpaceImage*)CTX_wm_space_data(C);
+ ARegion *ar= CTX_wm_region(C);
+ ImBuf *ibuf= ED_space_image_buffer(sima);
+ ImageSampleInfo *info= op->customdata;
+ float fx, fy;
+ int x, y;
+
+ if(ibuf == NULL)
+ return;
+
+ x= event->x - ar->winrct.xmin;
+ y= event->y - ar->winrct.ymin;
+ UI_view2d_region_to_view(&ar->v2d, x, y, &fx, &fy);
+
+ if(fx>=0.0 && fy>=0.0 && fx<1.0 && fy<1.0) {
+ float *fp;
+ char *cp;
+ int x= (int)(fx*ibuf->x), y= (int)(fy*ibuf->y);
+
+ CLAMP(x, 0, ibuf->x-1);
+ CLAMP(y, 0, ibuf->y-1);
+
+ info->x= x;
+ info->y= y;
+ info->draw= 1;
+
+ info->colp= NULL;
+ info->colfp= NULL;
+ info->zp= NULL;
+ info->zfp= NULL;
+
+ if(ibuf->rect) {
+ cp= (char *)(ibuf->rect + y*ibuf->x + x);
+
+ info->col[0]= cp[0];
+ info->col[1]= cp[1];
+ info->col[2]= cp[2];
+ info->col[3]= cp[3];
+ info->colp= info->col;
+
+ info->colf[0]= (float)cp[0]/255.0f;
+ info->colf[1]= (float)cp[1]/255.0f;
+ info->colf[2]= (float)cp[2]/255.0f;
+ info->colf[3]= (float)cp[3]/255.0f;
+ info->colfp= info->colf;
+ }
+ if(ibuf->rect_float) {
+ fp= (ibuf->rect_float + (ibuf->channels)*(y*ibuf->x + x));
+
+ info->colf[0]= fp[0];
+ info->colf[1]= fp[1];
+ info->colf[2]= fp[2];
+ info->colf[3]= fp[4];
+ info->colfp= info->colf;
+ }
+
+ if(ibuf->zbuf) {
+ info->z= ibuf->zbuf[y*ibuf->x + x];
+ info->zp= &info->z;
+ }
+ if(ibuf->zbuf_float) {
+ info->zf= ibuf->zbuf_float[y*ibuf->x + x];
+ info->zfp= &info->zf;
+ }
+
+ // XXX set white/black point
+ if(sima->cumap) {
+ if(ibuf->channels==4) {
+ if(0) { // XXX G.qual & LR_CTRLKEY) {
+ curvemapping_set_black_white(sima->cumap, NULL, fp);
+ curvemapping_do_ibuf(sima->cumap, ibuf);
}
- }
- else {
- ImBuf *ibuf= ED_space_image_buffer(sima);
- if (ibuf && (ibuf->userflags & IB_BITMAPDIRTY)) {
- if(1) // XXX okee("Can't pack painted image. Use Repack as PNG?"))
- BKE_image_memorypack(ima);
+ else if(0) { // XXX G.qual & LR_SHIFTKEY) {
+ curvemapping_set_black_white(sima->cumap, fp, NULL);
+ curvemapping_do_ibuf(sima->cumap, ibuf);
}
- else {
- ima->packedfile = newPackedFile(ima->name);
- // XXX BIF_undo_push("Pack image");
+ }
+ }
+
+ // XXX node curve integration ..
+#if 0
+ {
+ ScrArea *sa, *cur= curarea;
+
+ node_curvemap_sample(fp); /* sends global to node editor */
+ for(sa= G.curscreen->areabase.first; sa; sa= sa->next) {
+ if(sa->spacetype==SPACE_NODE) {
+ areawinset(sa->win);
+ scrarea_do_windraw(sa);
}
}
-
- // XXX allqueue(REDRAWBUTSSHADING, 0);
- // XXX allqueue(REDRAWHEADERS, 0);
+ node_curvemap_sample(NULL); /* clears global in node editor */
+ curarea= cur;
}
+#endif
+ }
+ else
+ info->draw= 0;
+
+ ED_area_tag_redraw(CTX_wm_area(C));
+}
+
+static void sample_exit(bContext *C, wmOperator *op)
+{
+ ImageSampleInfo *info= op->customdata;
+
+ ED_region_draw_cb_exit(info->art, info->draw_handle);
+ ED_area_tag_redraw(CTX_wm_area(C));
+ MEM_freeN(info);
+}
+
+static int sample_invoke(bContext *C, wmOperator *op, wmEvent *event)
+{
+ SpaceImage *sima= (SpaceImage*)CTX_wm_space_data(C);
+ ARegion *ar= CTX_wm_region(C);
+ ImBuf *ibuf= ED_space_image_buffer(sima);
+ ImageSampleInfo *info;
+
+ if(ibuf == NULL)
+ return OPERATOR_CANCELLED;
+
+ info= MEM_callocN(sizeof(ImageSampleInfo), "ImageSampleInfo");
+ info->art= ar->type;
+ info->draw_handle = ED_region_draw_cb_activate(ar->type, sample_draw, info, REGION_DRAW_POST);
+ op->customdata= info;
+
+ sample_apply(C, op, event);
+
+ WM_event_add_modal_handler(C, &CTX_wm_window(C)->handlers, op);
+
+ return OPERATOR_RUNNING_MODAL;
+}
+
+static int sample_modal(bContext *C, wmOperator *op, wmEvent *event)
+{
+ switch(event->type) {
+ case LEFTMOUSE:
+ case RIGHTMOUSE: // XXX hardcoded
+ sample_exit(C, op);
+ return OPERATOR_CANCELLED;
+ case MOUSEMOVE:
+ sample_apply(C, op, event);
+ break;
}
+
+ return OPERATOR_RUNNING_MODAL;
}
+static int sample_cancel(bContext *C, wmOperator *op)
+{
+ sample_exit(C, op);
+ return OPERATOR_CANCELLED;
+}
+
+void IMAGE_OT_sample(wmOperatorType *ot)
+{
+ /* identifiers */
+ ot->name= "Sample";
+ ot->idname= "IMAGE_OT_sample";
+
+ /* api callbacks */
+ ot->invoke= sample_invoke;
+ ot->modal= sample_modal;
+ ot->cancel= sample_cancel;
+ ot->poll= space_image_main_area_poll;
+}
+
+/******************** record composite operator *********************/
+
+typedef struct RecordCompositeData {
+ wmTimer *timer;
+ int old_cfra;
+ int sfra, efra;
+} RecordCompositeData;
+
+int record_composite_apply(bContext *C, wmOperator *op)
+{
+ SpaceImage *sima= (SpaceImage*)CTX_wm_space_data(C);
+ RecordCompositeData *rcd= op->customdata;
+ Scene *scene= CTX_data_scene(C);
+ ImBuf *ibuf;
+
+ // XXX scene->nodetree->test_break= blender_test_break;
+ // XXX scene->nodetree->test_break= NULL;
+ // XXX set_timecursor(CFRA);
+
+ BKE_image_all_free_anim_ibufs(CFRA);
+ ntreeCompositTagAnimated(scene->nodetree);
+ ntreeCompositExecTree(scene->nodetree, &scene->r, scene->r.cfra != rcd->old_cfra); /* 1 is no previews */
+
+ ED_area_tag_redraw(CTX_wm_area(C));
+
+ ibuf= BKE_image_get_ibuf(sima->image, &sima->iuser);
+ /* save memory in flipbooks */
+ if(ibuf)
+ imb_freerectfloatImBuf(ibuf);
+
+ scene->r.cfra++;
+
+ return (scene->r.cfra <= rcd->efra);
+}
+
+static int record_composite_init(bContext *C, wmOperator *op)
+{
+ SpaceImage *sima= (SpaceImage*)CTX_wm_space_data(C);
+ Scene *scene= CTX_data_scene(C);
+ RecordCompositeData *rcd;
+
+ if(sima->iuser.frames < 2)
+ return 0;
+ if(scene->nodetree == NULL)
+ return 0;
+
+ op->customdata= rcd= MEM_callocN(sizeof(RecordCompositeData), "ImageRecordCompositeData");
+
+ rcd->old_cfra= scene->r.cfra;
+ rcd->sfra= sima->iuser.sfra;
+ rcd->efra= sima->iuser.sfra + sima->iuser.frames-1;
+ scene->r.cfra= rcd->sfra;
+
+ WM_cursor_wait(1);
+
+ return 1;
+}
+
+static void record_composite_exit(bContext *C, wmOperator *op)
+{
+ Scene *scene= CTX_data_scene(C);
+ RecordCompositeData *rcd= op->customdata;
+
+ scene->r.cfra= rcd->old_cfra;
+
+ WM_cursor_wait(0);
+
+ if(rcd->timer)
+ WM_event_remove_window_timer(CTX_wm_window(C), rcd->timer);
+
+ // XXX play_anim(0);
+
+ // XXX allqueue(REDRAWNODE, 1);
+ // XXX allqueue(REDRAWIMAGE, 1);
+
+ MEM_freeN(rcd);
+}
+
+static int record_composite_exec(bContext *C, wmOperator *op)
+{
+ if(!record_composite_init(C, op))
+ return OPERATOR_CANCELLED;
+
+ while(record_composite_apply(C, op))
+ ;
+
+ record_composite_exit(C, op);
+
+ return OPERATOR_FINISHED;
+}
+
+static int record_composite_invoke(bContext *C, wmOperator *op, wmEvent *event)
+{
+ RecordCompositeData *rcd= op->customdata;
+
+ if(!record_composite_init(C, op))
+ return OPERATOR_CANCELLED;
+
+ rcd= op->customdata;
+ rcd->timer= WM_event_add_window_timer(CTX_wm_window(C), TIMER, 0.0f);
+ WM_event_add_modal_handler(C, &CTX_wm_window(C)->handlers, op);
+
+ if(!record_composite_apply(C, op))
+ return OPERATOR_FINISHED;
+
+ return OPERATOR_RUNNING_MODAL;
+}
+
+static int record_composite_modal(bContext *C, wmOperator *op, wmEvent *event)
+{
+ RecordCompositeData *rcd= op->customdata;
+
+ switch(event->type) {
+ case TIMER:
+ if(rcd->timer == event->customdata) {
+ if(!record_composite_apply(C, op)) {
+ record_composite_exit(C, op);
+ return OPERATOR_FINISHED;
+ }
+ }
+ break;
+ case ESCKEY:
+ record_composite_exit(C, op);
+ return OPERATOR_FINISHED;
+ }
+
+ return OPERATOR_RUNNING_MODAL;
+}
+
+static int record_composite_cancel(bContext *C, wmOperator *op)
+{
+ record_composite_exit(C, op);
+ return OPERATOR_CANCELLED;
+}
+
+void IMAGE_OT_record_composite(wmOperatorType *ot)
+{
+ /* identifiers */
+ ot->name= "Record Composite";
+ ot->idname= "IMAGE_OT_record_composite";
+
+ /* api callbacks */
+ ot->exec= record_composite_exec;
+ ot->invoke= record_composite_invoke;
+ ot->modal= record_composite_modal;
+ ot->cancel= record_composite_cancel;
+ ot->poll= space_image_poll;
+}
+
+/******************** TODO ********************/
+
/* XXX notifier? */
#if 0
/* goes over all ImageUsers, and sets frame numbers if auto-refresh is set */
@@ -1005,189 +1569,3 @@ void BIF_image_update_frame(void)
}
#endif
-void image_pixel_aspect(Image *image, float *x, float *y)
-{
- *x = *y = 1.0;
-
- if( (image == NULL) ||
- (image->type == IMA_TYPE_R_RESULT) ||
- (image->type == IMA_TYPE_COMPOSITE) ||
- (image->tpageflag & IMA_TILES) ||
- (image->aspx==0.0 || image->aspy==0.0)
- ) {
- return;
- }
-
- /* x is always 1 */
- *y = image->aspy / image->aspx;
-}
-
-void image_final_aspect(Image *image, float *x, float *y)
-{
- *x = *y = 1.0;
-
- if( (image == NULL) ||
- (image->type == IMA_TYPE_R_RESULT) ||
- (image->type == IMA_TYPE_COMPOSITE) ||
- (image->tpageflag & IMA_TILES) ||
- (image->aspx==0.0 || image->aspy==0.0)
- ) {
- return;
- } else {
- ImBuf *ibuf= BKE_image_get_ibuf(image, NULL);
- if (ibuf && ibuf->x && ibuf->y) {
- *y = (image->aspy * ibuf->y) / (image->aspx * ibuf->x);
- } else {
- /* x is always 1 */
- *y = image->aspy / image->aspx;
- }
- }
-}
-
-void sima_sample_color(SpaceImage *sima)
-{
- ImBuf *ibuf= ED_space_image_buffer(sima);
- float fx, fy;
- short mval[2], mvalo[2], firsttime=1;
-
- if(ibuf==NULL)
- return;
-
- // XXX calc_image_view(sima, 'f');
- // XXX getmouseco_areawin(mvalo);
-
- while(0) { // XXX get_mbut() & L_MOUSE) {
-
- // XXX getmouseco_areawin(mval);
- if(mval[0]!=mvalo[0] || mval[1]!=mvalo[1] || firsttime) {
- firsttime= 0;
- // XXX areamouseco_to_ipoco(G.v2d, mval, &fx, &fy);
-
- if(fx>=0.0 && fy>=0.0 && fx<1.0 && fy<1.0) {
- float *fp= NULL, *zpf= NULL;
- float vec[3];
- int *zp= NULL;
- char *cp= NULL;
-
- int x= (int) (fx*ibuf->x);
- int y= (int) (fy*ibuf->y);
-
- if(x>=ibuf->x) x= ibuf->x-1;
- if(y>=ibuf->y) y= ibuf->y-1;
-
- if(ibuf->rect)
- cp= (char *)(ibuf->rect + y*ibuf->x + x);
- if(ibuf->zbuf)
- zp= ibuf->zbuf + y*ibuf->x + x;
- if(ibuf->zbuf_float)
- zpf= ibuf->zbuf_float + y*ibuf->x + x;
- if(ibuf->rect_float)
- fp= (ibuf->rect_float + (ibuf->channels)*(y*ibuf->x + x));
-
- if(fp==NULL) {
- fp= vec;
- vec[0]= (float)cp[0]/255.0f;
- vec[1]= (float)cp[1]/255.0f;
- vec[2]= (float)cp[2]/255.0f;
- }
-
- if(sima->cumap) {
-
- if(ibuf->channels==4) {
- if(0) { // XXX G.qual & LR_CTRLKEY) {
- curvemapping_set_black_white(sima->cumap, NULL, fp);
- curvemapping_do_ibuf(sima->cumap, ibuf);
- }
- else if(0) { // XXX G.qual & LR_SHIFTKEY) {
- curvemapping_set_black_white(sima->cumap, fp, NULL);
- curvemapping_do_ibuf(sima->cumap, ibuf);
- }
- }
- }
-
-#if 0
- {
- ScrArea *sa, *cur= curarea;
-
- node_curvemap_sample(fp); /* sends global to node editor */
- for(sa= G.curscreen->areabase.first; sa; sa= sa->next) {
- if(sa->spacetype==SPACE_NODE) {
- areawinset(sa->win);
- scrarea_do_windraw(sa);
- }
- }
- node_curvemap_sample(NULL); /* clears global in node editor */
- curarea= cur;
- }
-
- areawinset(curarea->win);
- scrarea_do_windraw(curarea);
- myortho2(-0.375, curarea->winx-0.375, -0.375, curarea->winy-0.375);
- glLoadIdentity();
-
- sima_show_info(ibuf->channels, x, y, cp, (ibuf->rect_float)?fp:NULL, zp, zpf);
-
- screen_swapbuffers();
-#endif
-
- }
- }
- // XXX BIF_wait_for_statechange();
- }
-
- // XXX scrarea_queue_winredraw(curarea);
-}
-
-void mouseco_to_curtile(SpaceImage *sima, struct Object *obedit)
-{
- float fx, fy;
- short mval[2];
- int show_uvedit;
-
- show_uvedit= ED_space_image_show_uvedit(sima, obedit);
- if(!show_uvedit) return;
-
- if(sima->image && sima->image->tpageflag & IMA_TILES) {
-
- sima->flag |= SI_EDITTILE;
-
- while(0) { // XXX get_mbut()&L_MOUSE) {
-
- // XXX calc_image_view(sima, 'f');
-
- // XXX getmouseco_areawin(mval);
- // XXX areamouseco_to_ipoco(G.v2d, mval, &fx, &fy);
-
- if(fx>=0.0 && fy>=0.0 && fx<1.0 && fy<1.0) {
-
- fx= (fx)*sima->image->xrep;
- fy= (fy)*sima->image->yrep;
-
- mval[0]= fx;
- mval[1]= fy;
-
- sima->curtile= mval[1]*sima->image->xrep + mval[0];
- }
-
- // XXX scrarea_do_windraw(curarea);
- // XXX screen_swapbuffers();
- }
-
- sima->flag &= ~SI_EDITTILE;
-
- // XXX image_set_tile(sima, 2);
-
- // XXX allqueue(REDRAWVIEW3D, 0);
- // XXX scrarea_queue_winredraw(curarea);
- }
-}
-
-/* Could be used for other 2D views also */
-void mouseco_to_cursor_sima(void)
-{
- // XXX short mval[2];
- // XXX getmouseco_areawin(mval);
- // XXX areamouseco_to_ipoco(G.v2d, mval, &G.v2d->cursor[0], &G.v2d->cursor[1]);
- // XXX scrarea_queue_winredraw(curarea);
-}
-
diff --git a/source/blender/editors/space_image/space_image.c b/source/blender/editors/space_image/space_image.c
index 4f40dff378b..a3208331a3f 100644
--- a/source/blender/editors/space_image/space_image.c
+++ b/source/blender/editors/space_image/space_image.c
@@ -147,6 +147,19 @@ void image_operatortypes(void)
WM_operatortype_append(IMAGE_OT_view_zoom_out);
WM_operatortype_append(IMAGE_OT_view_zoom_ratio);
+ WM_operatortype_append(IMAGE_OT_new);
+ WM_operatortype_append(IMAGE_OT_open);
+ WM_operatortype_append(IMAGE_OT_replace);
+ WM_operatortype_append(IMAGE_OT_reload);
+ WM_operatortype_append(IMAGE_OT_save);
+ WM_operatortype_append(IMAGE_OT_save_as);
+ WM_operatortype_append(IMAGE_OT_save_sequence);
+ WM_operatortype_append(IMAGE_OT_pack);
+ WM_operatortype_append(IMAGE_OT_unpack);
+ WM_operatortype_append(IMAGE_OT_sample);
+
+ WM_operatortype_append(IMAGE_OT_record_composite);
+
WM_operatortype_append(IMAGE_OT_toolbox);
}
@@ -172,6 +185,12 @@ void image_keymap(struct wmWindowManager *wm)
RNA_float_set(WM_keymap_add_item(keymap, "IMAGE_OT_view_zoom_ratio", PAD4, KM_PRESS, 0, 0)->ptr, "ratio", 0.25f);
RNA_float_set(WM_keymap_add_item(keymap, "IMAGE_OT_view_zoom_ratio", PAD8, KM_PRESS, 0, 0)->ptr, "ratio", 0.125f);
+ WM_keymap_add_item(keymap, "IMAGE_OT_new", NKEY, KM_PRESS, KM_ALT, 0);
+ WM_keymap_add_item(keymap, "IMAGE_OT_open", OKEY, KM_PRESS, KM_ALT, 0);
+ WM_keymap_add_item(keymap, "IMAGE_OT_reload", RKEY, KM_PRESS, KM_ALT, 0);
+ WM_keymap_add_item(keymap, "IMAGE_OT_save", SKEY, KM_PRESS, KM_ALT, 0);
+ WM_keymap_add_item(keymap, "IMAGE_OT_sample", ACTIONMOUSE, KM_PRESS, 0, 0);
+
WM_keymap_add_item(keymap, "IMAGE_OT_toolbox", SPACEKEY, KM_PRESS, 0, 0);
}
@@ -190,7 +209,7 @@ static void image_refresh(const bContext *C, ScrArea *sa)
EditMesh *em= me->edit_mesh;
MTFace *tf;
- if(EM_texFaceCheck(em)) {
+ if(em && EM_texFaceCheck(em)) {
sima->image= ima= NULL;
tf = EM_get_active_mtface(em, NULL, NULL, 1); /* partially selected face is ok */
@@ -261,7 +280,7 @@ static void image_main_area_set_view2d(SpaceImage *sima, ARegion *ar)
ImBuf *ibuf= imagewindow_get_ibuf(sima);
float xuser_asp, yuser_asp;
- image_pixel_aspect(sima->image, &xuser_asp, &yuser_asp);
+ ED_image_aspect(sima->image, &xuser_asp, &yuser_asp);
if(ibuf) {
xim= ibuf->x * xuser_asp;
yim= ibuf->y * yuser_asp;
@@ -368,6 +387,7 @@ static void image_modal_keymaps(wmWindowManager *wm, ARegion *ar, int stype)
ListBase *keymap;
keymap= WM_keymap_listbase(wm, "UVEdit", 0, 0);
+
if(stype==NS_EDITMODE_MESH)
WM_event_add_keymap_handler(&ar->handlers, keymap);
else
@@ -479,7 +499,7 @@ Image *ED_space_image(SpaceImage *sima)
}
/* called to assign images to UV faces */
-void ED_space_image_set(SpaceImage *sima, Scene *scene, Object *obedit, Image *ima)
+void ED_space_image_set(bContext *C, SpaceImage *sima, Scene *scene, Object *obedit, Image *ima)
{
ED_uvedit_assign_image(scene, obedit, ima, sima->image);
@@ -487,11 +507,22 @@ void ED_space_image_set(SpaceImage *sima, Scene *scene, Object *obedit, Image *i
* to check if the face is displayed in UV-localview */
sima->image= ima;
+ if(ima)
+ printf("assign %s\n", ima->id.name);
+
if(ima == NULL || ima->type==IMA_TYPE_R_RESULT || ima->type==IMA_TYPE_COMPOSITE)
sima->flag &= ~SI_DRAWTOOL;
if(sima->image)
BKE_image_signal(sima->image, &sima->iuser, IMA_SIGNAL_USER_NEW_IMAGE);
+
+ if(sima->image && sima->image->id.us==0)
+ sima->image->id.us= 1;
+
+ if(obedit)
+ WM_event_add_notifier(C, NC_OBJECT|ND_GEOM_DATA, obedit);
+
+ ED_area_tag_redraw(CTX_wm_area(C));
}
ImBuf *ED_space_image_buffer(SpaceImage *sima)
diff --git a/source/blender/editors/space_view3d/view3d_header.c b/source/blender/editors/space_view3d/view3d_header.c
index 157be64e6e6..20a6f15e057 100644
--- a/source/blender/editors/space_view3d/view3d_header.c
+++ b/source/blender/editors/space_view3d/view3d_header.c
@@ -593,10 +593,10 @@ static void view3d_viewmenu(bContext *C, uiMenuItem *head, void *arg_unused)
// uiMenuSeparator(head);
- uiMenuItemEnumO(head, 0, "VIEW3D_OT_viewnumpad", "type", V3D_VIEW_CAMERA);
- uiMenuItemEnumO(head, 0, "VIEW3D_OT_viewnumpad", "type", V3D_VIEW_TOP);
- uiMenuItemEnumO(head, 0, "VIEW3D_OT_viewnumpad", "type", V3D_VIEW_FRONT);
- uiMenuItemEnumO(head, 0, "VIEW3D_OT_viewnumpad", "type", V3D_VIEW_RIGHT);
+ uiMenuItemEnumO(head, "", 0, "VIEW3D_OT_viewnumpad", "type", V3D_VIEW_CAMERA);
+ uiMenuItemEnumO(head, "", 0, "VIEW3D_OT_viewnumpad", "type", V3D_VIEW_TOP);
+ uiMenuItemEnumO(head, "", 0, "VIEW3D_OT_viewnumpad", "type", V3D_VIEW_FRONT);
+ uiMenuItemEnumO(head, "", 0, "VIEW3D_OT_viewnumpad", "type", V3D_VIEW_RIGHT);
//uiMenuLevel(head, "Cameras", view3d_view_camerasmenu);
@@ -4898,9 +4898,9 @@ static void view3d_sculpt_menu(bContext *C, uiMenuItem *head, void *arg_unused)
/* Curve */
uiMenuSeparator(head);
- uiMenuItemEnumO(head, 0, "SCULPT_OT_brush_curve_preset", "mode", BRUSH_PRESET_SHARP);
- uiMenuItemEnumO(head, 0, "SCULPT_OT_brush_curve_preset", "mode", BRUSH_PRESET_SMOOTH);
- uiMenuItemEnumO(head, 0, "SCULPT_OT_brush_curve_preset", "mode", BRUSH_PRESET_MAX);
+ uiMenuItemEnumO(head, "", 0, "SCULPT_OT_brush_curve_preset", "mode", BRUSH_PRESET_SHARP);
+ uiMenuItemEnumO(head, "", 0, "SCULPT_OT_brush_curve_preset", "mode", BRUSH_PRESET_SMOOTH);
+ uiMenuItemEnumO(head, "", 0, "SCULPT_OT_brush_curve_preset", "mode", BRUSH_PRESET_MAX);
uiMenuSeparator(head);
diff --git a/source/blender/editors/transform/transform_orientations.c b/source/blender/editors/transform/transform_orientations.c
index ec64d1483a1..fd1db9e1984 100644
--- a/source/blender/editors/transform/transform_orientations.c
+++ b/source/blender/editors/transform/transform_orientations.c
@@ -360,10 +360,10 @@ void BIF_menuTransformOrientation(bContext *C, uiMenuItem *head, void *arg)
TransformOrientation *ts;
int i= V3D_MANIP_CUSTOM;
- uiMenuItemEnumO(head, 0, "TFM_OT_select_orientation", "orientation", V3D_MANIP_GLOBAL);
- uiMenuItemEnumO(head, 0, "TFM_OT_select_orientation", "orientation", V3D_MANIP_LOCAL);
- uiMenuItemEnumO(head, 0, "TFM_OT_select_orientation", "orientation", V3D_MANIP_NORMAL);
- uiMenuItemEnumO(head, 0, "TFM_OT_select_orientation", "orientation", V3D_MANIP_VIEW);
+ uiMenuItemEnumO(head, "", 0, "TFM_OT_select_orientation", "orientation", V3D_MANIP_GLOBAL);
+ uiMenuItemEnumO(head, "", 0, "TFM_OT_select_orientation", "orientation", V3D_MANIP_LOCAL);
+ uiMenuItemEnumO(head, "", 0, "TFM_OT_select_orientation", "orientation", V3D_MANIP_NORMAL);
+ uiMenuItemEnumO(head, "", 0, "TFM_OT_select_orientation", "orientation", V3D_MANIP_VIEW);
for(ts = transform_spaces->first; ts; ts = ts->next)
uiMenuItemIntO(head, ts->name, 0, "TFM_OT_select_orientation", "custom_index", i++);
diff --git a/source/blender/editors/uvedit/uvedit_ops.c b/source/blender/editors/uvedit/uvedit_ops.c
index 4c27151acef..6697cc83845 100644
--- a/source/blender/editors/uvedit/uvedit_ops.c
+++ b/source/blender/editors/uvedit/uvedit_ops.c
@@ -2897,6 +2897,120 @@ void UV_OT_show_hidden(wmOperatorType *ot)
ot->poll= ED_operator_uvedit;
}
+
+/******************** set 3d cursor operator ********************/
+
+static int set_3d_cursor_exec(bContext *C, wmOperator *op)
+{
+ ARegion *ar= CTX_wm_region(C);
+ float location[2];
+
+ RNA_float_get_array(op->ptr, "location", location);
+ ar->v2d.cursor[0]= location[0];
+ ar->v2d.cursor[1]= location[1];
+
+ ED_area_tag_redraw(CTX_wm_area(C));
+
+ return OPERATOR_FINISHED;
+}
+
+static int set_3d_cursor_invoke(bContext *C, wmOperator *op, wmEvent *event)
+{
+ ARegion *ar= CTX_wm_region(C);
+ int x, y;
+ float location[2];
+
+ x= event->x - ar->winrct.xmin;
+ y= event->y - ar->winrct.ymin;
+ UI_view2d_region_to_view(&ar->v2d, x, y, &location[0], &location[1]);
+ RNA_float_set_array(op->ptr, "location", location);
+
+ return set_3d_cursor_exec(C, op);
+}
+
+void UV_OT_set_3d_cursor(wmOperatorType *ot)
+{
+ /* identifiers */
+ ot->name= "Set 3D Cursor";
+ ot->idname= "UV_OT_set_3d_cursor";
+
+ /* api callbacks */
+ ot->exec= set_3d_cursor_exec;
+ ot->invoke= set_3d_cursor_invoke;
+ ot->poll= ED_operator_uvedit;
+
+ /* flags */
+ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
+
+ /* properties */
+ RNA_def_float_vector(ot->srna, "location", 2, NULL, -FLT_MAX, FLT_MAX, "Location", "Cursor location in 0.0-1.0 coordinates.", -10.0f, 10.0f);
+}
+
+/********************** set tile operator **********************/
+
+static int set_tile_exec(bContext *C, wmOperator *op)
+{
+ Image *ima= CTX_data_edit_image(C);
+ int tile[2];
+
+ if(!ima || !(ima->tpageflag & IMA_TILES))
+ return OPERATOR_CANCELLED;
+
+ RNA_int_get_array(op->ptr, "tile", tile);
+ ED_uvedit_set_tile(C, CTX_data_scene(C), CTX_data_edit_object(C), ima, tile[0] + ima->xrep*tile[1], 1);
+
+ ED_area_tag_redraw(CTX_wm_area(C));
+
+ return OPERATOR_FINISHED;
+}
+
+static int set_tile_invoke(bContext *C, wmOperator *op, wmEvent *event)
+{
+ SpaceImage *sima= (SpaceImage*)CTX_wm_space_data(C);
+ Image *ima= CTX_data_edit_image(C);
+ ARegion *ar= CTX_wm_region(C);
+ float fx, fy;
+ int x, y, tile[2];
+
+ if(!ima || !(ima->tpageflag & IMA_TILES))
+ return OPERATOR_CANCELLED;
+
+ x= event->x - ar->winrct.xmin;
+ y= event->y - ar->winrct.ymin;
+ UI_view2d_region_to_view(&ar->v2d, x, y, &fx, &fy);
+
+ if(fx>=0.0 && fy>=0.0 && fx<1.0 && fy<1.0) {
+ fx= fx*ima->xrep;
+ fy= fy*ima->yrep;
+
+ tile[0]= fx;
+ tile[1]= fy;
+
+ sima->curtile= tile[1]*ima->xrep + tile[0];
+ RNA_int_set_array(op->ptr, "tile", tile);
+ }
+
+ return set_tile_exec(C, op);
+}
+
+void UV_OT_set_tile(wmOperatorType *ot)
+{
+ /* identifiers */
+ ot->name= "Set Tile";
+ ot->idname= "UV_OT_set_tile";
+
+ /* api callbacks */
+ ot->exec= set_tile_exec;
+ ot->invoke= set_tile_invoke;
+ ot->poll= ED_operator_uvedit;
+
+ /* flags */
+ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
+
+ /* properties */
+ RNA_def_int_vector(ot->srna, "tile", 2, NULL, 0, INT_MAX, "Tile", "Tile coordinate.", 0, 10);
+}
+
/* ************************** registration **********************************/
void ED_operatortypes_uvedit(void)
@@ -2934,6 +3048,9 @@ void ED_operatortypes_uvedit(void)
WM_operatortype_append(UV_OT_show_hidden);
WM_operatortype_append(UV_OT_hide_selected);
WM_operatortype_append(UV_OT_hide_deselected);
+
+ WM_operatortype_append(UV_OT_set_3d_cursor);
+ WM_operatortype_append(UV_OT_set_tile);
}
void ED_keymap_uvedit(wmWindowManager *wm)
@@ -2974,6 +3091,10 @@ void ED_keymap_uvedit(wmWindowManager *wm)
WM_keymap_add_item(keymap, "UV_OT_hide_deselected", HKEY, KM_PRESS, KM_SHIFT, 0);
WM_keymap_add_item(keymap, "UV_OT_show_hidden", HKEY, KM_PRESS, KM_ALT, 0);
+ /* cursor */
+ WM_keymap_add_item(keymap, "UV_OT_set_3d_cursor", ACTIONMOUSE, KM_PRESS, 0, 0);
+ WM_keymap_add_item(keymap, "UV_OT_set_tile", ACTIONMOUSE, KM_PRESS, KM_SHIFT, 0);
+
transform_keymap_for_space(wm, keymap, SPACE_IMAGE);
}
diff --git a/source/blender/makesrna/intern/rna_space.c b/source/blender/makesrna/intern/rna_space.c
index 33f386fd35a..793727d4d7b 100644
--- a/source/blender/makesrna/intern/rna_space.c
+++ b/source/blender/makesrna/intern/rna_space.c
@@ -33,6 +33,11 @@
#ifdef RNA_RUNTIME
+#include "DNA_scene_types.h"
+
+#include "BKE_brush.h"
+#include "BKE_context.h"
+
static StructRNA* rna_Space_refine(struct PointerRNA *ptr)
{
SpaceLink *space= (SpaceLink*)ptr->data;
@@ -80,6 +85,14 @@ static PointerRNA rna_SpaceImage_uvedit_get(PointerRNA *ptr)
return rna_pointer_inherit_refine(ptr, &RNA_SpaceUVEditor, ptr->data);
}
+static void rna_SpaceImage_paint_update(bContext *C, PointerRNA *ptr)
+{
+ Scene *scene= CTX_data_scene(C);
+
+ if(scene)
+ brush_check_exists(&scene->toolsettings->imapaint.brush);
+}
+
#else
static void rna_def_space(BlenderRNA *brna)
@@ -270,8 +283,8 @@ static void rna_def_space_image(BlenderRNA *brna)
/* paint */
prop= RNA_def_property(srna, "image_painting", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", SI_DRAWTOOL);
- RNA_def_property_flag(prop, PROP_NOT_EDITABLE); // brush check
RNA_def_property_ui_text(prop, "Image Painting", "Enable image painting mode.");
+ RNA_def_property_update(prop, 0, "rna_SpaceImage_paint_update");
/* grease pencil */
prop= RNA_def_property(srna, "grease_pencil", PROP_POINTER, PROP_NONE);