Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/space_file/file_draw.c
| Show First 20 Lines • Show All 69 Lines • ▼ Show 20 Lines | |||||
| #include "WM_types.h" | #include "WM_types.h" | ||||
| #include "fsmenu.h" | #include "fsmenu.h" | ||||
| #include "filelist.h" | #include "filelist.h" | ||||
| #include "file_intern.h" // own include | #include "file_intern.h" // own include | ||||
| /* button events */ | |||||
| enum { | |||||
| B_FS_DIRNAME, | |||||
| B_FS_FILENAME | |||||
| } /*eFile_ButEvents*/; | |||||
| static void do_file_buttons(bContext *C, void *UNUSED(arg), int event) | |||||
| { | |||||
| switch (event) { | |||||
| case B_FS_FILENAME: | |||||
| file_filename_exec(C, NULL); | |||||
| break; | |||||
| case B_FS_DIRNAME: | |||||
| file_directory_exec(C, NULL); | |||||
| break; | |||||
| } | |||||
| } | |||||
| /* Note: This function uses pixelspace (0, 0, winx, winy), not view2d. | /* Note: This function uses pixelspace (0, 0, winx, winy), not view2d. | ||||
| * The controls are laid out as follows: | * The controls are laid out as follows: | ||||
| * | * | ||||
| * ------------------------------------------- | * ------------------------------------------- | ||||
| * | Directory input | execute | | * | Directory input | execute | | ||||
| * ------------------------------------------- | * ------------------------------------------- | ||||
| * | Filename input | + | - | cancel | | * | Filename input | + | - | cancel | | ||||
| * ------------------------------------------- | * ------------------------------------------- | ||||
| Show All 29 Lines | void file_draw_buttons(const bContext *C, ARegion *ar) | ||||
| uiBlock *block; | uiBlock *block; | ||||
| SpaceFile *sfile = CTX_wm_space_file(C); | SpaceFile *sfile = CTX_wm_space_file(C); | ||||
| FileSelectParams *params = ED_fileselect_get_params(sfile); | FileSelectParams *params = ED_fileselect_get_params(sfile); | ||||
| ARegion *artmp; | ARegion *artmp; | ||||
| /* Initialize UI block. */ | /* Initialize UI block. */ | ||||
| BLI_snprintf(uiblockstr, sizeof(uiblockstr), "win %p", (void *)ar); | BLI_snprintf(uiblockstr, sizeof(uiblockstr), "win %p", (void *)ar); | ||||
| block = uiBeginBlock(C, ar, uiblockstr, UI_EMBOSS); | block = uiBeginBlock(C, ar, uiblockstr, UI_EMBOSS); | ||||
| uiBlockSetHandleFunc(block, do_file_buttons, NULL); | |||||
| /* exception to make space for collapsed region icon */ | /* exception to make space for collapsed region icon */ | ||||
| for (artmp = CTX_wm_area(C)->regionbase.first; artmp; artmp = artmp->next) { | for (artmp = CTX_wm_area(C)->regionbase.first; artmp; artmp = artmp->next) { | ||||
| if (artmp->regiontype == RGN_TYPE_CHANNELS && artmp->flag & RGN_FLAG_HIDDEN) { | if (artmp->regiontype == RGN_TYPE_CHANNELS && artmp->flag & RGN_FLAG_HIDDEN) { | ||||
| chan_offs = 16; | chan_offs = 16; | ||||
| min_x += chan_offs; | min_x += chan_offs; | ||||
| available_w -= chan_offs; | available_w -= chan_offs; | ||||
| } | } | ||||
| Show All 24 Lines | void file_draw_buttons(const bContext *C, ARegion *ar) | ||||
| } | } | ||||
| /* Text input fields for directory and file. */ | /* Text input fields for directory and file. */ | ||||
| if (available_w > 0) { | if (available_w > 0) { | ||||
| int overwrite_alert = file_draw_check_exists(sfile); | int overwrite_alert = file_draw_check_exists(sfile); | ||||
| /* callbacks for operator check functions */ | /* callbacks for operator check functions */ | ||||
| uiBlockSetFunc(block, file_draw_check_cb, NULL, NULL); | uiBlockSetFunc(block, file_draw_check_cb, NULL, NULL); | ||||
| but = uiDefButTextO(block, TEX, "FILE_OT_directory", 0, "", | but = uiDefBut(block, TEX, -1, "", | ||||
| min_x, line1_y, line1_w - chan_offs, btn_h, | min_x, line1_y, line1_w - chan_offs, btn_h, | ||||
| params->dir, 0.0, (float)FILE_MAX, 0, 0, | params->dir, 0.0, (float)FILE_MAX, 0, 0, | ||||
| TIP_("File path")); | TIP_("File path")); | ||||
| uiButSetCompleteFunc(but, autocomplete_directory, NULL); | uiButSetCompleteFunc(but, autocomplete_directory, NULL); | ||||
| uiButSetFlag(but, UI_BUT_NO_UTF8); | uiButSetFlag(but, UI_BUT_NO_UTF8); | ||||
| uiButClearFlag(but, UI_BUT_UNDO); | |||||
| uiButSetNFunc(but, file_directory_enter_handle, NULL, but); | |||||
| /* TODO, directory editing is non-functional while a library is loaded | |||||
| * until this is properly supported just disable it. */ | |||||
| if (sfile->files && filelist_lib(sfile->files)) | |||||
| uiButSetFlag(but, UI_BUT_DISABLED); | |||||
| if ((params->flag & FILE_DIRSEL_ONLY) == 0) { | if ((params->flag & FILE_DIRSEL_ONLY) == 0) { | ||||
| but = uiDefButTextO(block, TEX, "FILE_OT_filename", 0, "", | but = uiDefBut(block, TEX, -1, "", | ||||
| min_x, line2_y, line2_w - chan_offs, btn_h, | min_x, line2_y, line2_w - chan_offs, btn_h, | ||||
| params->file, 0.0, (float)FILE_MAXFILE, 0, 0, | params->file, 0.0, (float)FILE_MAXFILE, 0, 0, | ||||
| TIP_(overwrite_alert ? N_("File name, overwrite existing") : N_("File name"))); | TIP_(overwrite_alert ? N_("File name, overwrite existing") : N_("File name"))); | ||||
| uiButSetCompleteFunc(but, autocomplete_file, NULL); | uiButSetCompleteFunc(but, autocomplete_file, NULL); | ||||
| uiButSetFlag(but, UI_BUT_NO_UTF8); | uiButSetFlag(but, UI_BUT_NO_UTF8); | ||||
| uiButClearFlag(but, UI_BUT_UNDO); /* operator button above does this automatic */ | uiButClearFlag(but, UI_BUT_UNDO); | ||||
| /* silly workaround calling NFunc to ensure this does not get called | |||||
| * immediate ui_apply_but_func but only after button deactivates */ | |||||
| uiButSetNFunc(but, file_filename_enter_handle, NULL, but); | |||||
| /* check if this overrides a file and if the operator option is used */ | /* check if this overrides a file and if the operator option is used */ | ||||
| if (overwrite_alert) { | if (overwrite_alert) { | ||||
| uiButSetFlag(but, UI_BUT_REDALERT); | uiButSetFlag(but, UI_BUT_REDALERT); | ||||
| } | } | ||||
| } | } | ||||
| /* clear func */ | /* clear func */ | ||||
| ▲ Show 20 Lines • Show All 397 Lines • Show Last 20 Lines | |||||