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.
This commit is contained in:
2009-02-10 23:17:58 +00:00
parent 1195c22207
commit b77da4893d
15 changed files with 1084 additions and 632 deletions

View File

@@ -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);

View File

@@ -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);

View File

@@ -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);

View File

@@ -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 */

View File

@@ -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);

View File

@@ -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];

View File

@@ -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) {

View File

@@ -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)) {

View File

@@ -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);

File diff suppressed because it is too large Load Diff

View File

@@ -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)

View File

@@ -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);

View File

@@ -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++);

View File

@@ -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);
}

View File

@@ -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);