Changeset View
Changeset View
Standalone View
Standalone View
source/blender/windowmanager/intern/wm_files.c
| Show First 20 Lines • Show All 1,199 Lines • ▼ Show 20 Lines | |||||
| static ImBuf *blend_file_thumb(const bContext *C, | static ImBuf *blend_file_thumb(const bContext *C, | ||||
| Scene *scene, | Scene *scene, | ||||
| bScreen *screen, | bScreen *screen, | ||||
| BlendThumbnail **thumb_pt) | BlendThumbnail **thumb_pt) | ||||
| { | { | ||||
| /* will be scaled down, but gives some nice oversampling */ | /* will be scaled down, but gives some nice oversampling */ | ||||
| ImBuf *ibuf; | ImBuf *ibuf; | ||||
| BlendThumbnail *thumb; | BlendThumbnail *thumb; | ||||
| wmWindowManager *wm = CTX_wm_manager(C); | |||||
| wmWindow *windrawable_old = wm->windrawable; | |||||
| char err_out[256] = "unknown"; | char err_out[256] = "unknown"; | ||||
| /* screen if no camera found */ | /* screen if no camera found */ | ||||
| ScrArea *sa = NULL; | ScrArea *sa = NULL; | ||||
| ARegion *ar = NULL; | ARegion *ar = NULL; | ||||
| View3D *v3d = NULL; | View3D *v3d = NULL; | ||||
| /* In case we are given a valid thumbnail data, just generate image from it. */ | /* In case we are given a valid thumbnail data, just generate image from it. */ | ||||
| Show All 17 Lines | static ImBuf *blend_file_thumb(const bContext *C, | ||||
| if (scene->camera == NULL && v3d == NULL) { | if (scene->camera == NULL && v3d == NULL) { | ||||
| return NULL; | return NULL; | ||||
| } | } | ||||
| /* gets scaled to BLEN_THUMB_SIZE */ | /* gets scaled to BLEN_THUMB_SIZE */ | ||||
| Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); | Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); | ||||
| /* Offscreen drawing requires a drawable window context. */ | |||||
| wm_window_make_drawable(wm, CTX_wm_window(C)); | |||||
| if (scene->camera) { | if (scene->camera) { | ||||
| ibuf = ED_view3d_draw_offscreen_imbuf_simple(depsgraph, | ibuf = ED_view3d_draw_offscreen_imbuf_simple(depsgraph, | ||||
| scene, | scene, | ||||
| NULL, | NULL, | ||||
| OB_SOLID, | OB_SOLID, | ||||
| scene->camera, | scene->camera, | ||||
| BLEN_THUMB_SIZE * 2, | BLEN_THUMB_SIZE * 2, | ||||
| BLEN_THUMB_SIZE * 2, | BLEN_THUMB_SIZE * 2, | ||||
| Show All 16 Lines | ibuf = ED_view3d_draw_offscreen_imbuf(depsgraph, | ||||
| IB_rect, | IB_rect, | ||||
| R_ALPHAPREMUL, | R_ALPHAPREMUL, | ||||
| 0, | 0, | ||||
| NULL, | NULL, | ||||
| NULL, | NULL, | ||||
| err_out); | err_out); | ||||
| } | } | ||||
| /* Reset to old drawable. */ | |||||
| if (windrawable_old) { | |||||
| wm_window_make_drawable(wm, windrawable_old); | |||||
| } | |||||
| else { | |||||
| wm_window_clear_drawable(wm); | |||||
| } | |||||
| if (ibuf) { | if (ibuf) { | ||||
| float aspect = (scene->r.xsch * scene->r.xasp) / (scene->r.ysch * scene->r.yasp); | float aspect = (scene->r.xsch * scene->r.xasp) / (scene->r.ysch * scene->r.yasp); | ||||
| /* dirty oversampling */ | /* dirty oversampling */ | ||||
| IMB_scaleImBuf(ibuf, BLEN_THUMB_SIZE, BLEN_THUMB_SIZE); | IMB_scaleImBuf(ibuf, BLEN_THUMB_SIZE, BLEN_THUMB_SIZE); | ||||
| /* add pretty overlay */ | /* add pretty overlay */ | ||||
| IMB_thumb_overlay_blend(ibuf->rect, ibuf->x, ibuf->y, aspect); | IMB_thumb_overlay_blend(ibuf->rect, ibuf->x, ibuf->y, aspect); | ||||
| ▲ Show 20 Lines • Show All 1,036 Lines • ▼ Show 20 Lines | else { | ||||
| autoexec_text = IFACE_("Trusted Source"); | autoexec_text = IFACE_("Trusted Source"); | ||||
| } | } | ||||
| uiItemR(col, op->ptr, "use_scripts", 0, autoexec_text, ICON_NONE); | uiItemR(col, op->ptr, "use_scripts", 0, autoexec_text, ICON_NONE); | ||||
| } | } | ||||
| void WM_OT_open_mainfile(wmOperatorType *ot) | void WM_OT_open_mainfile(wmOperatorType *ot) | ||||
| { | { | ||||
| ot->name = "Open Blender File"; | ot->name = "Open"; | ||||
| ot->idname = "WM_OT_open_mainfile"; | ot->idname = "WM_OT_open_mainfile"; | ||||
| ot->description = "Open a Blender file"; | ot->description = "Open a Blender file"; | ||||
| ot->invoke = wm_open_mainfile_invoke; | ot->invoke = wm_open_mainfile_invoke; | ||||
| ot->exec = wm_open_mainfile_exec; | ot->exec = wm_open_mainfile_exec; | ||||
| ot->check = wm_open_mainfile_check; | ot->check = wm_open_mainfile_check; | ||||
| ot->ui = wm_open_mainfile_ui; | ot->ui = wm_open_mainfile_ui; | ||||
| /* omit window poll so this can work in background mode */ | /* omit window poll so this can work in background mode */ | ||||
| ▲ Show 20 Lines • Show All 165 Lines • ▼ Show 20 Lines | void WM_OT_recover_auto_save(wmOperatorType *ot) | ||||
| ot->exec = wm_recover_auto_save_exec; | ot->exec = wm_recover_auto_save_exec; | ||||
| ot->invoke = wm_recover_auto_save_invoke; | ot->invoke = wm_recover_auto_save_invoke; | ||||
| WM_operator_properties_filesel(ot, | WM_operator_properties_filesel(ot, | ||||
| FILE_TYPE_BLENDER, | FILE_TYPE_BLENDER, | ||||
| FILE_BLENDER, | FILE_BLENDER, | ||||
| FILE_OPENFILE, | FILE_OPENFILE, | ||||
| WM_FILESEL_FILEPATH, | WM_FILESEL_FILEPATH, | ||||
| FILE_LONGDISPLAY, | FILE_HORIZONTALDISPLAY, | ||||
| FILE_SORT_TIME); | FILE_SORT_TIME); | ||||
| } | } | ||||
| /** \} */ | /** \} */ | ||||
| /* -------------------------------------------------------------------- */ | /* -------------------------------------------------------------------- */ | ||||
| /** \name Save Main .blend File Operator | /** \name Save Main .blend File Operator | ||||
| * \{ */ | * \{ */ | ||||
| ▲ Show 20 Lines • Show All 117 Lines • ▼ Show 20 Lines | static bool blend_save_check(bContext *UNUSED(C), wmOperator *op) | ||||
| } | } | ||||
| return false; | return false; | ||||
| } | } | ||||
| void WM_OT_save_as_mainfile(wmOperatorType *ot) | void WM_OT_save_as_mainfile(wmOperatorType *ot) | ||||
| { | { | ||||
| PropertyRNA *prop; | PropertyRNA *prop; | ||||
| ot->name = "Save As Blender File"; | ot->name = "Save As"; | ||||
| ot->idname = "WM_OT_save_as_mainfile"; | ot->idname = "WM_OT_save_as_mainfile"; | ||||
| ot->description = "Save the current file in the desired location"; | ot->description = "Save the current file in the desired location"; | ||||
| ot->invoke = wm_save_as_mainfile_invoke; | ot->invoke = wm_save_as_mainfile_invoke; | ||||
| ot->exec = wm_save_as_mainfile_exec; | ot->exec = wm_save_as_mainfile_exec; | ||||
| ot->check = blend_save_check; | ot->check = blend_save_check; | ||||
| /* omit window poll so this can work in background mode */ | /* omit window poll so this can work in background mode */ | ||||
| ▲ Show 20 Lines • Show All 542 Lines • Show Last 20 Lines | |||||