Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/space_image/image_ops.c
| Show First 20 Lines • Show All 2,151 Lines • ▼ Show 20 Lines | void IMAGE_OT_save_sequence(wmOperatorType *ot) | ||||
| /* api callbacks */ | /* api callbacks */ | ||||
| ot->exec = image_save_sequence_exec; | ot->exec = image_save_sequence_exec; | ||||
| ot->poll = space_image_buffer_exists_poll; | ot->poll = space_image_buffer_exists_poll; | ||||
| /* flags */ | /* flags */ | ||||
| ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; | ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; | ||||
| } | } | ||||
| /********************** save all operator **********************/ | |||||
| int ED_image_save_all_modified_count(const bContext *C) | |||||
| { | |||||
| Main *bmain = CTX_data_main(C); | |||||
| int num_files = 0; | |||||
| for (Image *ima = bmain->images.first; ima; ima = ima->id.next) { | |||||
| if (ELEM(ima->type, IMA_TYPE_R_RESULT, IMA_TYPE_COMPOSITE)) { | |||||
| continue; | |||||
| } | |||||
| else if (BKE_image_is_dirty(ima)) { | |||||
| if (ima->source == IMA_SRC_FILE && !BKE_image_has_packedfile(ima)) { | |||||
| num_files++; | |||||
| } | |||||
| } | |||||
| } | |||||
| return num_files; | |||||
| } | |||||
| bool ED_image_save_all_modified(const bContext *C, ReportList *reports) | |||||
| { | |||||
| Main *bmain = CTX_data_main(C); | |||||
| Scene *scene = CTX_data_scene(C); | |||||
| bool ok = true; | |||||
| for (Image *ima = bmain->images.first; ima; ima = ima->id.next) { | |||||
| if (ELEM(ima->type, IMA_TYPE_R_RESULT, IMA_TYPE_COMPOSITE)) { | |||||
| continue; | |||||
| } | |||||
| else if (BKE_image_is_dirty(ima)) { | |||||
| if (ima->source == IMA_SRC_FILE && !BKE_image_has_packedfile(ima)) { | |||||
| ImageSaveOptions simopts; | |||||
| BKE_image_save_options_init(&simopts, bmain, scene); | |||||
| if (image_save_options_init(bmain, &simopts, ima, NULL, false, false)) { | |||||
| ok = ok && BKE_image_save(reports, bmain, ima, NULL, &simopts); | |||||
| } | |||||
| } | |||||
| } | |||||
| } | |||||
| if (!ok) { | |||||
| BKE_report(reports, RPT_WARNING, "Failed to save one or more images"); | |||||
| } | |||||
| return ok; | |||||
| } | |||||
| static int image_save_all_modified_exec(bContext *C, wmOperator *op) | |||||
| { | |||||
| ED_image_save_all_modified(C, op->reports); | |||||
| return OPERATOR_FINISHED; | |||||
| } | |||||
| static bool image_save_all_modified_poll(bContext *C) | |||||
| { | |||||
| return (ED_image_save_all_modified_count(C) > 0); | |||||
| } | |||||
| void IMAGE_OT_save_all_modified(wmOperatorType *ot) | |||||
| { | |||||
| /* identifiers */ | |||||
| ot->name = "Save All Modified"; | |||||
| ot->idname = "IMAGE_OT_save_all_modified"; | |||||
| ot->description = "Save all modified images"; | |||||
| /* api callbacks */ | |||||
| ot->exec = image_save_all_modified_exec; | |||||
| ot->poll = image_save_all_modified_poll; | |||||
| /* flags */ | |||||
| ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; | |||||
| } | |||||
| /******************** reload image operator ********************/ | /******************** reload image operator ********************/ | ||||
| static int image_reload_exec(bContext *C, wmOperator *UNUSED(op)) | static int image_reload_exec(bContext *C, wmOperator *UNUSED(op)) | ||||
| { | { | ||||
| Main *bmain = CTX_data_main(C); | Main *bmain = CTX_data_main(C); | ||||
| Image *ima = CTX_data_edit_image(C); | Image *ima = CTX_data_edit_image(C); | ||||
| SpaceImage *sima = CTX_wm_space_image(C); | SpaceImage *sima = CTX_wm_space_image(C); | ||||
| ▲ Show 20 Lines • Show All 1,601 Lines • Show Last 20 Lines | |||||