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

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'source/blender/editors/space_image/image_ops.c')
-rw-r--r--source/blender/editors/space_image/image_ops.c282
1 files changed, 143 insertions, 139 deletions
diff --git a/source/blender/editors/space_image/image_ops.c b/source/blender/editors/space_image/image_ops.c
index dba60586b29..c83baf24c1c 100644
--- a/source/blender/editors/space_image/image_ops.c
+++ b/source/blender/editors/space_image/image_ops.c
@@ -1,6 +1,4 @@
/*
- * $Id$
- *
* ***** BEGIN GPL LICENSE BLOCK *****
*
* This program is free software; you can redistribute it and/or
@@ -136,18 +134,27 @@ static int space_image_file_exists_poll(bContext *C)
SpaceImage *sima= CTX_wm_space_image(C);
ImBuf *ibuf;
void *lock;
- int poll= 0;
+ int ret= FALSE;
char name[FILE_MAX];
ibuf= ED_space_image_acquire_buffer(sima, &lock);
if(ibuf) {
BLI_strncpy(name, ibuf->name, FILE_MAX);
BLI_path_abs(name, bmain->name);
- poll= (BLI_exists(name) && BLI_file_is_writable(name));
+
+ if(BLI_exists(name) == FALSE) {
+ CTX_wm_operator_poll_msg_set(C, "image file not found");
+ }
+ else if (BLI_file_is_writable(name) == FALSE) {
+ CTX_wm_operator_poll_msg_set(C, "image path can't be written to");
+ }
+ else {
+ ret= TRUE;
+ }
}
ED_space_image_release_buffer(sima, lock);
- return poll;
+ return ret;
}
return 0;
}
@@ -179,7 +186,7 @@ typedef struct ViewPanData {
int event_type;
} ViewPanData;
-static void view_pan_init(bContext *C, wmOperator *op, wmEvent *event)
+static void image_view_pan_init(bContext *C, wmOperator *op, wmEvent *event)
{
SpaceImage *sima= CTX_wm_space_image(C);
ViewPanData *vpd;
@@ -196,7 +203,7 @@ static void view_pan_init(bContext *C, wmOperator *op, wmEvent *event)
WM_event_add_modal_handler(C, op);
}
-static void view_pan_exit(bContext *C, wmOperator *op, int cancel)
+static void image_view_pan_exit(bContext *C, wmOperator *op, int cancel)
{
SpaceImage *sima= CTX_wm_space_image(C);
ViewPanData *vpd= op->customdata;
@@ -211,7 +218,7 @@ static void view_pan_exit(bContext *C, wmOperator *op, int cancel)
MEM_freeN(op->customdata);
}
-static int view_pan_exec(bContext *C, wmOperator *op)
+static int image_view_pan_exec(bContext *C, wmOperator *op)
{
SpaceImage *sima= CTX_wm_space_image(C);
float offset[2];
@@ -234,7 +241,7 @@ static int view_pan_exec(bContext *C, wmOperator *op)
return OPERATOR_FINISHED;
}
-static int view_pan_invoke(bContext *C, wmOperator *op, wmEvent *event)
+static int image_view_pan_invoke(bContext *C, wmOperator *op, wmEvent *event)
{
if (event->type == MOUSEPAN) {
SpaceImage *sima= CTX_wm_space_image(C);
@@ -244,16 +251,16 @@ static int view_pan_invoke(bContext *C, wmOperator *op, wmEvent *event)
offset[1]= (event->y - event->prevy)/sima->zoom;
RNA_float_set_array(op->ptr, "offset", offset);
- view_pan_exec(C, op);
+ image_view_pan_exec(C, op);
return OPERATOR_FINISHED;
}
else {
- view_pan_init(C, op, event);
+ image_view_pan_init(C, op, event);
return OPERATOR_RUNNING_MODAL;
}
}
-static int view_pan_modal(bContext *C, wmOperator *op, wmEvent *event)
+static int image_view_pan_modal(bContext *C, wmOperator *op, wmEvent *event)
{
SpaceImage *sima= CTX_wm_space_image(C);
ViewPanData *vpd= op->customdata;
@@ -266,11 +273,11 @@ static int view_pan_modal(bContext *C, wmOperator *op, wmEvent *event)
offset[0]= (vpd->x - event->x)/sima->zoom;
offset[1]= (vpd->y - event->y)/sima->zoom;
RNA_float_set_array(op->ptr, "offset", offset);
- view_pan_exec(C, op);
+ image_view_pan_exec(C, op);
break;
default:
if(event->type==vpd->event_type && event->val==KM_RELEASE) {
- view_pan_exit(C, op, 0);
+ image_view_pan_exit(C, op, 0);
return OPERATOR_FINISHED;
}
break;
@@ -279,9 +286,9 @@ static int view_pan_modal(bContext *C, wmOperator *op, wmEvent *event)
return OPERATOR_RUNNING_MODAL;
}
-static int view_pan_cancel(bContext *C, wmOperator *op)
+static int image_view_pan_cancel(bContext *C, wmOperator *op)
{
- view_pan_exit(C, op, 1);
+ image_view_pan_exit(C, op, 1);
return OPERATOR_CANCELLED;
}
@@ -292,10 +299,10 @@ void IMAGE_OT_view_pan(wmOperatorType *ot)
ot->idname= "IMAGE_OT_view_pan";
/* api callbacks */
- ot->exec= view_pan_exec;
- ot->invoke= view_pan_invoke;
- ot->modal= view_pan_modal;
- ot->cancel= view_pan_cancel;
+ ot->exec= image_view_pan_exec;
+ ot->invoke= image_view_pan_invoke;
+ ot->modal= image_view_pan_modal;
+ ot->cancel= image_view_pan_cancel;
ot->poll= space_image_main_area_poll;
/* flags */
@@ -314,7 +321,7 @@ typedef struct ViewZoomData {
int event_type;
} ViewZoomData;
-static void view_zoom_init(bContext *C, wmOperator *op, wmEvent *event)
+static void image_view_zoom_init(bContext *C, wmOperator *op, wmEvent *event)
{
SpaceImage *sima= CTX_wm_space_image(C);
ViewZoomData *vpd;
@@ -330,7 +337,7 @@ static void view_zoom_init(bContext *C, wmOperator *op, wmEvent *event)
WM_event_add_modal_handler(C, op);
}
-static void view_zoom_exit(bContext *C, wmOperator *op, int cancel)
+static void image_view_zoom_exit(bContext *C, wmOperator *op, int cancel)
{
SpaceImage *sima= CTX_wm_space_image(C);
ViewZoomData *vpd= op->customdata;
@@ -344,7 +351,7 @@ static void view_zoom_exit(bContext *C, wmOperator *op, int cancel)
MEM_freeN(op->customdata);
}
-static int view_zoom_exec(bContext *C, wmOperator *op)
+static int image_view_zoom_exec(bContext *C, wmOperator *op)
{
SpaceImage *sima= CTX_wm_space_image(C);
ARegion *ar= CTX_wm_region(C);
@@ -365,7 +372,7 @@ static int view_zoom_exec(bContext *C, wmOperator *op)
return OPERATOR_FINISHED;
}
-static int view_zoom_invoke(bContext *C, wmOperator *op, wmEvent *event)
+static int image_view_zoom_invoke(bContext *C, wmOperator *op, wmEvent *event)
{
if (event->type == MOUSEZOOM) {
SpaceImage *sima= CTX_wm_space_image(C);
@@ -380,12 +387,12 @@ static int view_zoom_invoke(bContext *C, wmOperator *op, wmEvent *event)
return OPERATOR_FINISHED;
}
else {
- view_zoom_init(C, op, event);
+ image_view_zoom_init(C, op, event);
return OPERATOR_RUNNING_MODAL;
}
}
-static int view_zoom_modal(bContext *C, wmOperator *op, wmEvent *event)
+static int image_view_zoom_modal(bContext *C, wmOperator *op, wmEvent *event)
{
SpaceImage *sima= CTX_wm_space_image(C);
ARegion *ar= CTX_wm_region(C);
@@ -401,7 +408,7 @@ static int view_zoom_modal(bContext *C, wmOperator *op, wmEvent *event)
break;
default:
if(event->type==vpd->event_type && event->val==KM_RELEASE) {
- view_zoom_exit(C, op, 0);
+ image_view_zoom_exit(C, op, 0);
return OPERATOR_FINISHED;
}
break;
@@ -410,9 +417,9 @@ static int view_zoom_modal(bContext *C, wmOperator *op, wmEvent *event)
return OPERATOR_RUNNING_MODAL;
}
-static int view_zoom_cancel(bContext *C, wmOperator *op)
+static int image_view_zoom_cancel(bContext *C, wmOperator *op)
{
- view_zoom_exit(C, op, 1);
+ image_view_zoom_exit(C, op, 1);
return OPERATOR_CANCELLED;
}
@@ -423,10 +430,10 @@ void IMAGE_OT_view_zoom(wmOperatorType *ot)
ot->idname= "IMAGE_OT_view_zoom";
/* api callbacks */
- ot->exec= view_zoom_exec;
- ot->invoke= view_zoom_invoke;
- ot->modal= view_zoom_modal;
- ot->cancel= view_zoom_cancel;
+ ot->exec= image_view_zoom_exec;
+ ot->invoke= image_view_zoom_invoke;
+ ot->modal= image_view_zoom_modal;
+ ot->cancel= image_view_zoom_cancel;
ot->poll= space_image_main_area_poll;
/* flags */
@@ -445,7 +452,7 @@ void IMAGE_OT_view_zoom(wmOperatorType *ot)
* that explains the negative signs in the code below
*/
-static int view_ndof_invoke(bContext *C, wmOperator *UNUSED(op), wmEvent *event)
+static int image_view_ndof_invoke(bContext *C, wmOperator *UNUSED(op), wmEvent *event)
{
if (event->type != NDOF_MOTION)
return OPERATOR_CANCELLED;
@@ -491,7 +498,7 @@ void IMAGE_OT_view_ndof(wmOperatorType *ot)
ot->idname= "IMAGE_OT_view_ndof";
/* api callbacks */
- ot->invoke= view_ndof_invoke;
+ ot->invoke= image_view_ndof_invoke;
}
/********************** view all operator *********************/
@@ -500,7 +507,7 @@ void IMAGE_OT_view_ndof(wmOperatorType *ot)
* Default behavior is to reset the position of the image and set the zoom to 1
* If the image will not fit within the window rectangle, the zoom is adjusted */
-static int view_all_exec(bContext *C, wmOperator *UNUSED(op))
+static int image_view_all_exec(bContext *C, wmOperator *UNUSED(op))
{
SpaceImage *sima;
ARegion *ar;
@@ -544,13 +551,13 @@ void IMAGE_OT_view_all(wmOperatorType *ot)
ot->idname= "IMAGE_OT_view_all";
/* api callbacks */
- ot->exec= view_all_exec;
+ ot->exec= image_view_all_exec;
ot->poll= space_image_main_area_poll;
}
/********************** view selected operator *********************/
-static int view_selected_exec(bContext *C, wmOperator *UNUSED(op))
+static int image_view_selected_exec(bContext *C, wmOperator *UNUSED(op))
{
SpaceImage *sima;
ARegion *ar;
@@ -593,7 +600,7 @@ static int view_selected_exec(bContext *C, wmOperator *UNUSED(op))
return OPERATOR_FINISHED;
}
-static int view_selected_poll(bContext *C)
+static int image_view_selected_poll(bContext *C)
{
return (space_image_main_area_poll(C) && ED_operator_uvedit(C));
}
@@ -605,13 +612,13 @@ void IMAGE_OT_view_selected(wmOperatorType *ot)
ot->idname= "IMAGE_OT_view_selected";
/* api callbacks */
- ot->exec= view_selected_exec;
- ot->poll= view_selected_poll;
+ ot->exec= image_view_selected_exec;
+ ot->poll= image_view_selected_poll;
}
/********************** view zoom in/out operator *********************/
-static int view_zoom_in_exec(bContext *C, wmOperator *UNUSED(op))
+static int image_view_zoom_in_exec(bContext *C, wmOperator *UNUSED(op))
{
SpaceImage *sima= CTX_wm_space_image(C);
ARegion *ar= CTX_wm_region(C);
@@ -630,11 +637,11 @@ void IMAGE_OT_view_zoom_in(wmOperatorType *ot)
ot->idname= "IMAGE_OT_view_zoom_in";
/* api callbacks */
- ot->exec= view_zoom_in_exec;
+ ot->exec= image_view_zoom_in_exec;
ot->poll= space_image_main_area_poll;
}
-static int view_zoom_out_exec(bContext *C, wmOperator *UNUSED(op))
+static int image_view_zoom_out_exec(bContext *C, wmOperator *UNUSED(op))
{
SpaceImage *sima= CTX_wm_space_image(C);
ARegion *ar= CTX_wm_region(C);
@@ -653,13 +660,13 @@ void IMAGE_OT_view_zoom_out(wmOperatorType *ot)
ot->idname= "IMAGE_OT_view_zoom_out";
/* api callbacks */
- ot->exec= view_zoom_out_exec;
+ ot->exec= image_view_zoom_out_exec;
ot->poll= space_image_main_area_poll;
}
/********************** view zoom ratio operator *********************/
-static int view_zoom_ratio_exec(bContext *C, wmOperator *op)
+static int image_view_zoom_ratio_exec(bContext *C, wmOperator *op)
{
SpaceImage *sima= CTX_wm_space_image(C);
ARegion *ar= CTX_wm_region(C);
@@ -691,7 +698,7 @@ void IMAGE_OT_view_zoom_ratio(wmOperatorType *ot)
ot->idname= "IMAGE_OT_view_zoom_ratio";
/* api callbacks */
- ot->exec= view_zoom_ratio_exec;
+ ot->exec= image_view_zoom_ratio_exec;
ot->poll= space_image_main_area_poll;
/* properties */
@@ -742,7 +749,7 @@ static void image_filesel(bContext *C, wmOperator *op, const char *path)
/******************** open image operator ********************/
-static void open_init(bContext *C, wmOperator *op)
+static void image_open_init(bContext *C, wmOperator *op)
{
PropertyPointerRNA *pprop;
@@ -750,14 +757,14 @@ static void open_init(bContext *C, wmOperator *op)
uiIDContextProperty(C, &pprop->ptr, &pprop->prop);
}
-static int open_cancel(bContext *UNUSED(C), wmOperator *op)
+static int image_open_cancel(bContext *UNUSED(C), wmOperator *op)
{
MEM_freeN(op->customdata);
op->customdata= NULL;
return OPERATOR_CANCELLED;
}
-static int open_exec(bContext *C, wmOperator *op)
+static int image_open_exec(bContext *C, wmOperator *op)
{
SpaceImage *sima= CTX_wm_space_image(C); /* XXX other space types can call */
Scene *scene= CTX_data_scene(C);
@@ -782,7 +789,7 @@ static int open_exec(bContext *C, wmOperator *op)
}
if(!op->customdata)
- open_init(C, op);
+ image_open_init(C, op);
/* hook into UI */
pprop= op->customdata;
@@ -825,7 +832,7 @@ static int open_exec(bContext *C, wmOperator *op)
return OPERATOR_FINISHED;
}
-static int open_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(event))
+static int image_open_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(event))
{
SpaceImage *sima= CTX_wm_space_image(C); /* XXX other space types can call */
char *path=U.textudir;
@@ -845,9 +852,9 @@ static int open_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(event))
path= ima->name;
if(RNA_property_is_set(op->ptr, "filepath"))
- return open_exec(C, op);
+ return image_open_exec(C, op);
- open_init(C, op);
+ image_open_init(C, op);
image_filesel(C, op, path);
@@ -863,9 +870,9 @@ void IMAGE_OT_open(wmOperatorType *ot)
ot->idname= "IMAGE_OT_open";
/* api callbacks */
- ot->exec= open_exec;
- ot->invoke= open_invoke;
- ot->cancel= open_cancel;
+ ot->exec= image_open_exec;
+ ot->invoke= image_open_invoke;
+ ot->cancel= image_open_cancel;
/* flags */
ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
@@ -876,7 +883,7 @@ void IMAGE_OT_open(wmOperatorType *ot)
/******************** replace image operator ********************/
-static int replace_exec(bContext *C, wmOperator *op)
+static int image_replace_exec(bContext *C, wmOperator *op)
{
SpaceImage *sima= CTX_wm_space_image(C);
char str[FILE_MAX];
@@ -896,7 +903,7 @@ static int replace_exec(bContext *C, wmOperator *op)
return OPERATOR_FINISHED;
}
-static int replace_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(event))
+static int image_replace_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(event))
{
SpaceImage *sima= CTX_wm_space_image(C);
@@ -904,7 +911,7 @@ static int replace_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(event))
return OPERATOR_CANCELLED;
if(RNA_property_is_set(op->ptr, "filepath"))
- return replace_exec(C, op);
+ return image_replace_exec(C, op);
if(!RNA_property_is_set(op->ptr, "relative_path"))
RNA_boolean_set(op->ptr, "relative_path", (strncmp(sima->image->name, "//", 2))==0);
@@ -921,8 +928,8 @@ void IMAGE_OT_replace(wmOperatorType *ot)
ot->idname= "IMAGE_OT_replace";
/* api callbacks */
- ot->exec= replace_exec;
- ot->invoke= replace_invoke;
+ ot->exec= image_replace_exec;
+ ot->invoke= image_replace_invoke;
ot->poll= space_image_poll;
/* flags */
@@ -1034,7 +1041,7 @@ static void save_image_doit(bContext *C, SpaceImage *sima, wmOperator *op, SaveI
ImBuf *ibuf= ED_space_image_acquire_buffer(sima, &lock);
if (ibuf) {
- Main *bmain= CTX_data_main(C);
+ const char *relbase= ID_BLEND_PATH(CTX_data_main(C), &ima->id);
const short relative= (RNA_struct_find_property(op->ptr, "relative_path") && RNA_boolean_get(op->ptr, "relative_path"));
const short save_copy= (RNA_struct_find_property(op->ptr, "copy") && RNA_boolean_get(op->ptr, "copy"));
short ok= FALSE;
@@ -1077,19 +1084,11 @@ static void save_image_doit(bContext *C, SpaceImage *sima, wmOperator *op, SaveI
ok= TRUE;
}
- if(ok) {
- if(relative)
- BLI_path_rel(simopts->filepath, bmain->name); /* only after saving */
-
- if(ibuf->name[0]==0) {
- BLI_strncpy(ibuf->name, simopts->filepath, sizeof(ibuf->name));
- BLI_strncpy(ima->name, simopts->filepath, sizeof(ima->name));
- }
-
+ if (ok) {
if(!save_copy) {
if(do_newpath) {
- BLI_strncpy(ima->name, simopts->filepath, sizeof(ima->name));
BLI_strncpy(ibuf->name, simopts->filepath, sizeof(ibuf->name));
+ BLI_strncpy(ima->name, simopts->filepath, sizeof(ima->name));
}
ibuf->userflags &= ~IB_BITMAPDIRTY;
@@ -1114,6 +1113,11 @@ static void save_image_doit(bContext *C, SpaceImage *sima, wmOperator *op, SaveI
ima->source= IMA_SRC_FILE;
ima->type= IMA_TYPE_IMAGE;
}
+
+ /* only image path, never ibuf */
+ if(relative) {
+ BLI_path_rel(ima->name, relbase); /* only after saving */
+ }
}
}
else {
@@ -1129,7 +1133,7 @@ static void save_image_doit(bContext *C, SpaceImage *sima, wmOperator *op, SaveI
ED_space_image_release_buffer(sima, lock);
}
-static int save_as_exec(bContext *C, wmOperator *op)
+static int image_save_as_exec(bContext *C, wmOperator *op)
{
SpaceImage *sima= CTX_wm_space_image(C);
SaveImageOptions simopts;
@@ -1145,7 +1149,7 @@ static int save_as_exec(bContext *C, wmOperator *op)
}
-static int save_as_check(bContext *UNUSED(C), wmOperator *op)
+static int image_save_as_check(bContext *UNUSED(C), wmOperator *op)
{
char filepath[FILE_MAX];
RNA_string_get(op->ptr, "filepath", filepath);
@@ -1156,7 +1160,7 @@ static int save_as_check(bContext *UNUSED(C), wmOperator *op)
return FALSE;
}
-static int save_as_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(event))
+static int image_save_as_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(event))
{
SpaceImage *sima= CTX_wm_space_image(C);
Image *ima = ED_space_image(sima);
@@ -1164,7 +1168,7 @@ static int save_as_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(event))
SaveImageOptions simopts;
if(RNA_property_is_set(op->ptr, "filepath"))
- return save_as_exec(C, op);
+ return image_save_as_exec(C, op);
if (save_image_options_init(&simopts, sima, scene, TRUE) == 0)
return OPERATOR_CANCELLED;
@@ -1190,9 +1194,9 @@ void IMAGE_OT_save_as(wmOperatorType *ot)
ot->idname= "IMAGE_OT_save_as";
/* api callbacks */
- ot->exec= save_as_exec;
- ot->check= save_as_check;
- ot->invoke= save_as_invoke;
+ ot->exec= image_save_as_exec;
+ ot->check= image_save_as_check;
+ ot->invoke= image_save_as_invoke;
ot->poll= space_image_buffer_exists_poll;
/* flags */
@@ -1213,7 +1217,7 @@ void IMAGE_OT_save_as(wmOperatorType *ot)
/******************** save image operator ********************/
-static int save_exec(bContext *C, wmOperator *op)
+static int image_save_exec(bContext *C, wmOperator *op)
{
SpaceImage *sima= CTX_wm_space_image(C);
Scene *scene= CTX_data_scene(C);
@@ -1241,7 +1245,7 @@ void IMAGE_OT_save(wmOperatorType *ot)
ot->idname= "IMAGE_OT_save";
/* api callbacks */
- ot->exec= save_exec;
+ ot->exec= image_save_exec;
ot->poll= space_image_file_exists_poll;
/* flags */
@@ -1250,7 +1254,7 @@ void IMAGE_OT_save(wmOperatorType *ot)
/******************* save sequence operator ********************/
-static int save_sequence_exec(bContext *C, wmOperator *op)
+static int image_save_sequence_exec(bContext *C, wmOperator *op)
{
Main *bmain= CTX_data_main(C);
SpaceImage *sima= CTX_wm_space_image(C);
@@ -1318,7 +1322,7 @@ void IMAGE_OT_save_sequence(wmOperatorType *ot)
ot->idname= "IMAGE_OT_save_sequence";
/* api callbacks */
- ot->exec= save_sequence_exec;
+ ot->exec= image_save_sequence_exec;
ot->poll= space_image_buffer_exists_poll;
/* flags */
@@ -1327,7 +1331,7 @@ void IMAGE_OT_save_sequence(wmOperatorType *ot)
/******************** reload image operator ********************/
-static int reload_exec(bContext *C, wmOperator *UNUSED(op))
+static int image_reload_exec(bContext *C, wmOperator *UNUSED(op))
{
Image *ima= CTX_data_edit_image(C);
SpaceImage *sima= CTX_wm_space_image(C);
@@ -1353,7 +1357,7 @@ void IMAGE_OT_reload(wmOperatorType *ot)
ot->idname= "IMAGE_OT_reload";
/* api callbacks */
- ot->exec= reload_exec;
+ ot->exec= image_reload_exec;
/* flags */
ot->flag= OPTYPE_REGISTER; /* no undo, image buffer is not handled by undo */
@@ -1540,7 +1544,7 @@ void IMAGE_OT_invert(wmOperatorType *ot)
/********************* pack operator *********************/
-static int pack_test(bContext *C, wmOperator *op)
+static int image_pack_test(bContext *C, wmOperator *op)
{
Image *ima= CTX_data_edit_image(C);
int as_png= RNA_boolean_get(op->ptr, "as_png");
@@ -1558,14 +1562,14 @@ static int pack_test(bContext *C, wmOperator *op)
return 1;
}
-static int pack_exec(bContext *C, wmOperator *op)
+static int image_pack_exec(bContext *C, wmOperator *op)
{
struct Main *bmain= CTX_data_main(C);
Image *ima= CTX_data_edit_image(C);
ImBuf *ibuf= BKE_image_get_ibuf(ima, NULL);
int as_png= RNA_boolean_get(op->ptr, "as_png");
- if(!pack_test(C, op))
+ if(!image_pack_test(C, op))
return OPERATOR_CANCELLED;
if(!as_png && (ibuf && (ibuf->userflags & IB_BITMAPDIRTY))) {
@@ -1583,7 +1587,7 @@ static int pack_exec(bContext *C, wmOperator *op)
return OPERATOR_FINISHED;
}
-static int pack_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(event))
+static int image_pack_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(event))
{
Image *ima= CTX_data_edit_image(C);
ImBuf *ibuf= BKE_image_get_ibuf(ima, NULL);
@@ -1591,7 +1595,7 @@ static int pack_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(event))
uiLayout *layout;
int as_png= RNA_boolean_get(op->ptr, "as_png");
- if(!pack_test(C, op))
+ if(!image_pack_test(C, op))
return OPERATOR_CANCELLED;
if(!as_png && (ibuf && (ibuf->userflags & IB_BITMAPDIRTY))) {
@@ -1603,7 +1607,7 @@ static int pack_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(event))
return OPERATOR_CANCELLED;
}
- return pack_exec(C, op);
+ return image_pack_exec(C, op);
}
void IMAGE_OT_pack(wmOperatorType *ot)
@@ -1614,8 +1618,8 @@ void IMAGE_OT_pack(wmOperatorType *ot)
ot->idname= "IMAGE_OT_pack";
/* api callbacks */
- ot->exec= pack_exec;
- ot->invoke= pack_invoke;
+ ot->exec= image_pack_exec;
+ ot->invoke= image_pack_invoke;
/* flags */
ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
@@ -1723,7 +1727,7 @@ typedef struct ImageSampleInfo {
int draw;
} ImageSampleInfo;
-static void sample_draw(const bContext *UNUSED(C), ARegion *ar, void *arg_info)
+static void image_sample_draw(const bContext *UNUSED(C), ARegion *ar, void *arg_info)
{
ImageSampleInfo *info= arg_info;
if(info->draw) {
@@ -1732,7 +1736,7 @@ static void sample_draw(const bContext *UNUSED(C), ARegion *ar, void *arg_info)
}
}
-static void sample_apply(bContext *C, wmOperator *op, wmEvent *event)
+static void image_sample_apply(bContext *C, wmOperator *op, wmEvent *event)
{
SpaceImage *sima= CTX_wm_space_image(C);
ARegion *ar= CTX_wm_region(C);
@@ -1842,7 +1846,7 @@ static void sample_apply(bContext *C, wmOperator *op, wmEvent *event)
ED_area_tag_redraw(CTX_wm_area(C));
}
-static void sample_exit(bContext *C, wmOperator *op)
+static void image_sample_exit(bContext *C, wmOperator *op)
{
ImageSampleInfo *info= op->customdata;
@@ -1851,7 +1855,7 @@ static void sample_exit(bContext *C, wmOperator *op)
MEM_freeN(info);
}
-static int sample_invoke(bContext *C, wmOperator *op, wmEvent *event)
+static int image_sample_invoke(bContext *C, wmOperator *op, wmEvent *event)
{
SpaceImage *sima= CTX_wm_space_image(C);
ARegion *ar= CTX_wm_region(C);
@@ -1862,34 +1866,34 @@ static int sample_invoke(bContext *C, wmOperator *op, wmEvent *event)
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_PIXEL);
+ info->draw_handle = ED_region_draw_cb_activate(ar->type, image_sample_draw, info, REGION_DRAW_POST_PIXEL);
op->customdata= info;
- sample_apply(C, op, event);
+ image_sample_apply(C, op, event);
WM_event_add_modal_handler(C, op);
return OPERATOR_RUNNING_MODAL;
}
-static int sample_modal(bContext *C, wmOperator *op, wmEvent *event)
+static int image_sample_modal(bContext *C, wmOperator *op, wmEvent *event)
{
switch(event->type) {
case LEFTMOUSE:
case RIGHTMOUSE: // XXX hardcoded
- sample_exit(C, op);
+ image_sample_exit(C, op);
return OPERATOR_CANCELLED;
case MOUSEMOVE:
- sample_apply(C, op, event);
+ image_sample_apply(C, op, event);
break;
}
return OPERATOR_RUNNING_MODAL;
}
-static int sample_cancel(bContext *C, wmOperator *op)
+static int image_sample_cancel(bContext *C, wmOperator *op)
{
- sample_exit(C, op);
+ image_sample_exit(C, op);
return OPERATOR_CANCELLED;
}
@@ -1900,9 +1904,9 @@ void IMAGE_OT_sample(wmOperatorType *ot)
ot->idname= "IMAGE_OT_sample";
/* api callbacks */
- ot->invoke= sample_invoke;
- ot->modal= sample_modal;
- ot->cancel= sample_cancel;
+ ot->invoke= image_sample_invoke;
+ ot->modal= image_sample_modal;
+ ot->cancel= image_sample_cancel;
ot->poll= space_image_main_area_poll;
/* flags */
@@ -1910,7 +1914,7 @@ void IMAGE_OT_sample(wmOperatorType *ot)
}
/******************** sample line operator ********************/
-static int sample_line_exec(bContext *C, wmOperator *op)
+static int image_sample_line_exec(bContext *C, wmOperator *op)
{
SpaceImage *sima= CTX_wm_space_image(C);
ARegion *ar= CTX_wm_region(C);
@@ -1991,7 +1995,7 @@ static int sample_line_exec(bContext *C, wmOperator *op)
return OPERATOR_FINISHED;
}
-static int sample_line_invoke(bContext *C, wmOperator *op, wmEvent *event)
+static int image_sample_line_invoke(bContext *C, wmOperator *op, wmEvent *event)
{
SpaceImage *sima= CTX_wm_space_image(C);
@@ -2008,9 +2012,9 @@ void IMAGE_OT_sample_line(wmOperatorType *ot)
ot->idname= "IMAGE_OT_sample_line";
/* api callbacks */
- ot->invoke= sample_line_invoke;
+ ot->invoke= image_sample_line_invoke;
ot->modal= WM_gesture_straightline_modal;
- ot->exec= sample_line_exec;
+ ot->exec= image_sample_line_exec;
ot->poll= space_image_main_area_poll;
ot->cancel= WM_gesture_straightline_cancel;
@@ -2037,9 +2041,9 @@ void IMAGE_OT_curves_point_set(wmOperatorType *ot)
ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
/* api callbacks */
- ot->invoke= sample_invoke;
- ot->modal= sample_modal;
- ot->cancel= sample_cancel;
+ ot->invoke= image_sample_invoke;
+ ot->modal= image_sample_modal;
+ ot->cancel= image_sample_cancel;
ot->poll= space_image_main_area_poll;
/* properties */
@@ -2054,7 +2058,7 @@ typedef struct RecordCompositeData {
int sfra, efra;
} RecordCompositeData;
-static int record_composite_apply(bContext *C, wmOperator *op)
+static int image_record_composite_apply(bContext *C, wmOperator *op)
{
SpaceImage *sima= CTX_wm_space_image(C);
RecordCompositeData *rcd= op->customdata;
@@ -2082,7 +2086,7 @@ static int record_composite_apply(bContext *C, wmOperator *op)
return (scene->r.cfra <= rcd->efra);
}
-static int record_composite_init(bContext *C, wmOperator *op)
+static int image_record_composite_init(bContext *C, wmOperator *op)
{
SpaceImage *sima= CTX_wm_space_image(C);
Scene *scene= CTX_data_scene(C);
@@ -2103,7 +2107,7 @@ static int record_composite_init(bContext *C, wmOperator *op)
return 1;
}
-static void record_composite_exit(bContext *C, wmOperator *op)
+static void image_record_composite_exit(bContext *C, wmOperator *op)
{
Scene *scene= CTX_data_scene(C);
SpaceImage *sima= CTX_wm_space_image(C);
@@ -2124,60 +2128,60 @@ static void record_composite_exit(bContext *C, wmOperator *op)
MEM_freeN(rcd);
}
-static int record_composite_exec(bContext *C, wmOperator *op)
+static int image_record_composite_exec(bContext *C, wmOperator *op)
{
- if(!record_composite_init(C, op))
+ if(!image_record_composite_init(C, op))
return OPERATOR_CANCELLED;
- while(record_composite_apply(C, op))
+ while(image_record_composite_apply(C, op))
;
- record_composite_exit(C, op);
+ image_record_composite_exit(C, op);
return OPERATOR_FINISHED;
}
-static int record_composite_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(event))
+static int image_record_composite_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(event))
{
RecordCompositeData *rcd;
- if(!record_composite_init(C, op))
+ if(!image_record_composite_init(C, op))
return OPERATOR_CANCELLED;
rcd= op->customdata;
rcd->timer= WM_event_add_timer(CTX_wm_manager(C), CTX_wm_window(C), TIMER, 0.0f);
WM_event_add_modal_handler(C, op);
- if(!record_composite_apply(C, op))
+ if(!image_record_composite_apply(C, op))
return OPERATOR_FINISHED;
return OPERATOR_RUNNING_MODAL;
}
-static int record_composite_modal(bContext *C, wmOperator *op, wmEvent *event)
+static int image_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);
+ if(!image_record_composite_apply(C, op)) {
+ image_record_composite_exit(C, op);
return OPERATOR_FINISHED;
}
}
break;
case ESCKEY:
- record_composite_exit(C, op);
+ image_record_composite_exit(C, op);
return OPERATOR_FINISHED;
}
return OPERATOR_RUNNING_MODAL;
}
-static int record_composite_cancel(bContext *C, wmOperator *op)
+static int image_record_composite_cancel(bContext *C, wmOperator *op)
{
- record_composite_exit(C, op);
+ image_record_composite_exit(C, op);
return OPERATOR_CANCELLED;
}
@@ -2188,23 +2192,23 @@ void IMAGE_OT_record_composite(wmOperatorType *ot)
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->exec= image_record_composite_exec;
+ ot->invoke= image_record_composite_invoke;
+ ot->modal= image_record_composite_modal;
+ ot->cancel= image_record_composite_cancel;
ot->poll= space_image_buffer_exists_poll;
}
/********************* cycle render slot operator *********************/
-static int cycle_render_slot_poll(bContext *C)
+static int image_cycle_render_slot_poll(bContext *C)
{
Image *ima= CTX_data_edit_image(C);
return (ima && ima->type == IMA_TYPE_R_RESULT);
}
-static int cycle_render_slot_exec(bContext *C, wmOperator *op)
+static int image_cycle_render_slot_exec(bContext *C, wmOperator *op)
{
Image *ima= CTX_data_edit_image(C);
int a, slot, cur= ima->render_slot;
@@ -2243,8 +2247,8 @@ void IMAGE_OT_cycle_render_slot(wmOperatorType *ot)
ot->idname= "IMAGE_OT_cycle_render_slot";
/* api callbacks */
- ot->exec= cycle_render_slot_exec;
- ot->poll= cycle_render_slot_poll;
+ ot->exec= image_cycle_render_slot_exec;
+ ot->poll= image_cycle_render_slot_poll;
/* flags */
ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;