当前位置: 首页>>代码示例>>C++>>正文


C++ CTX_wm_space_file函数代码示例

本文整理汇总了C++中CTX_wm_space_file函数的典型用法代码示例。如果您正苦于以下问题:C++ CTX_wm_space_file函数的具体用法?C++ CTX_wm_space_file怎么用?C++ CTX_wm_space_file使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了CTX_wm_space_file函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: file_select

static FileSelect file_select(bContext *C, const rcti *rect, FileSelType select, bool fill, bool do_diropen)
{
	SpaceFile *sfile = CTX_wm_space_file(C);
	FileSelect retval = FILE_SELECT_NOTHING;
	FileSelection sel = file_selection_get(C, rect, fill); /* get the selection */
	const FileCheckType check_type = (sfile->params->flag & FILE_DIRSEL_ONLY) ? CHECK_DIRS : CHECK_ALL;
	
	/* flag the files as selected in the filelist */
	filelist_select(sfile->files, &sel, select, SELECTED_FILE, check_type);
	
	/* Don't act on multiple selected files */
	if (sel.first != sel.last) select = 0;

	/* Do we have a valid selection and are we actually selecting */
	if ((sel.last >= 0) && ((select == FILE_SEL_ADD) || (select == FILE_SEL_TOGGLE))) {
		/* Check last selection, if selected, act on the file or dir */
		if (filelist_is_selected(sfile->files, sel.last, check_type)) {
			retval = file_select_do(C, sel.last, do_diropen);
		}
	}

	/* update operator for name change event */
	file_draw_check_cb(C, NULL, NULL);
	
	return retval;
}
开发者ID:manwapastorelli,项目名称:blender-git,代码行数:26,代码来源:file_ops.c

示例2: ED_file_change_dir

void ED_file_change_dir(bContext *C, const bool checkdir)
{
	wmWindowManager *wm = CTX_wm_manager(C);
	SpaceFile *sfile = CTX_wm_space_file(C);

	if (sfile->params) {
		ED_fileselect_clear(wm, sfile);

		/* Clear search string, it is very rare to want to keep that filter while changing dir,
		 * and usually very annoying to keep it actually! */
		sfile->params->filter_search[0] = '\0';

		if (checkdir && !BLI_is_dir(sfile->params->dir)) {
			BLI_strncpy(sfile->params->dir, filelist_dir(sfile->files), sizeof(sfile->params->dir));
			/* could return but just refresh the current dir */
		}
		filelist_setdir(sfile->files, sfile->params->dir);
		/* clear selected file to avoid trying to open it from the new dir with changed path */
		sfile->params->file[0] = '\0';
		sfile->params->active_file = -1;
		
		if (folderlist_clear_next(sfile))
			folderlist_free(sfile->folders_next);

		folderlist_pushdir(sfile->folders_prev, sfile->params->dir);

		file_draw_check(C);
	}
}
开发者ID:bitfusionio,项目名称:blender,代码行数:29,代码来源:filesel.c

示例3: file_expand_directory

static void file_expand_directory(bContext *C)
{
	SpaceFile *sfile= CTX_wm_space_file(C);
	
	if(sfile->params) {
		if ( sfile->params->dir[0] == '~' ) {
			char tmpstr[sizeof(sfile->params->dir)-1];
			BLI_strncpy(tmpstr, sfile->params->dir+1, sizeof(tmpstr));
			BLI_join_dirfile(sfile->params->dir, sizeof(sfile->params->dir), BLI_getDefaultDocumentFolder(), tmpstr);
		}

#ifdef WIN32
		if (sfile->params->dir[0] == '\0') {
			get_default_root(sfile->params->dir);
		}
		/* change "C:" --> "C:\", [#28102] */
		else if (   (isalpha(sfile->params->dir[0]) &&
		            (sfile->params->dir[1] == ':')) &&
		            (sfile->params->dir[2] == '\0')

		) {
			sfile->params->dir[2]= '\\';
			sfile->params->dir[3]= '\0';
		}
#endif
	}
}
开发者ID:OldBrunet,项目名称:BGERTPS,代码行数:27,代码来源:file_ops.c

示例4: file_directory_exec

int file_directory_exec(bContext *C, wmOperator *UNUSED(unused))
{
	SpaceFile *sfile= CTX_wm_space_file(C);
	
	if(sfile->params) {
		file_expand_directory(C);

		if (!BLI_exists(sfile->params->dir)) {
			BLI_recurdir_fileops(sfile->params->dir);
		}

		/* special case, user may have pasted a fulepath into the directory */
		if(BLI_exists(sfile->params->dir) && BLI_is_dir(sfile->params->dir) == 0) {
			char path[sizeof(sfile->params->dir)];
			BLI_strncpy(path, sfile->params->dir, sizeof(path));
			BLI_split_dirfile(path, sfile->params->dir, sfile->params->file);
		}

		BLI_cleanup_dir(G.main->name, sfile->params->dir);
		BLI_add_slash(sfile->params->dir);
		file_change_dir(C, 1);

		WM_event_add_notifier(C, NC_SPACE|ND_SPACE_FILE_LIST, NULL);
	}		
	

	return OPERATOR_FINISHED;
}
开发者ID:OldBrunet,项目名称:BGERTPS,代码行数:28,代码来源:file_ops.c

示例5: file_selection_get

static FileSelection file_selection_get(bContext *C, const rcti *rect, bool fill)
{
	ARegion *ar = CTX_wm_region(C);
	SpaceFile *sfile = CTX_wm_space_file(C);
	int numfiles = filelist_numfiles(sfile->files);
	FileSelection sel;

	sel = find_file_mouse_rect(sfile, ar, rect);
	if (!((sel.first == -1) && (sel.last == -1)) ) {
		clamp_to_filelist(numfiles, &sel);
	}


	/* if desired, fill the selection up from the last selected file to the current one */
	if (fill && (sel.last >= 0) && (sel.last < numfiles) ) {
		int f = sel.last;
		while (f >= 0) {
			if (filelist_is_selected(sfile->files, f, CHECK_ALL) )
				break;
			f--;
		}
		if (f >= 0) {
			sel.first = f + 1;
		}
	}
	return sel;
}
开发者ID:manwapastorelli,项目名称:blender-git,代码行数:27,代码来源:file_ops.c

示例6: file_panel_operator_header

static void file_panel_operator_header(const bContext *C, Panel *pa)
{
	SpaceFile *sfile= CTX_wm_space_file(C);
	wmOperator *op= sfile->op;

	BLI_strncpy(pa->drawname, op->type->name, sizeof(pa->drawname));
}
开发者ID:BHCLL,项目名称:blendocv,代码行数:7,代码来源:file_panels.c

示例7: file_panel_category

static void file_panel_category(const bContext *C, Panel *pa, FSMenuCategory category, short *nr, int icon, int allow_delete)
{
	SpaceFile *sfile = CTX_wm_space_file(C);
	uiBlock *block;
	uiBut *but;
	uiLayout *box, *col;
	struct FSMenu *fsmenu = fsmenu_get();
	int i, nentries = fsmenu_get_nentries(fsmenu, category);

	/* reset each time */
	*nr = -1;

	/* hide if no entries */
	if (nentries == 0)
		return;

	/* layout */
	uiLayoutSetAlignment(pa->layout, UI_LAYOUT_ALIGN_LEFT);
	block = uiLayoutGetBlock(pa->layout);
	box = uiLayoutBox(pa->layout);
	col = uiLayoutColumn(box, TRUE);

	for (i = 0; i < nentries; ++i) {
		char dir[FILE_MAX];
		char temp[FILE_MAX];
		uiLayout *layout = uiLayoutRow(col, FALSE);
		char *entry;
		
		entry = fsmenu_get_entry(fsmenu, category, i);
		
		/* set this list item as active if we have a match */
		if (sfile->params) {
			if (BLI_path_cmp(sfile->params->dir, entry) == 0) {
				*nr = i;
			}
		}

		/* create nice bookmark name, shows last directory in the full path currently */
		BLI_strncpy(temp, entry, FILE_MAX);
		BLI_add_slash(temp);
		BLI_getlastdir(temp, dir, FILE_MAX);
		BLI_del_slash(dir);

		if (dir[0] == 0)
			BLI_strncpy(dir, entry, FILE_MAX);

		/* create list item */
		but = uiDefIconTextButS(block, LISTROW, 0, icon, dir, 0, 0, UI_UNIT_X * 10, UI_UNIT_Y, nr, 0, i, 0, 0, entry);
		uiButSetFunc(but, file_panel_cb, entry, NULL);
		uiButClearFlag(but, UI_BUT_UNDO); /* skip undo on screen buttons */
		uiButSetFlag(but, UI_ICON_LEFT | UI_TEXT_LEFT);

		/* create delete button */
		if (allow_delete && fsmenu_can_save(fsmenu, category, i)) {
			uiBlockSetEmboss(block, UI_EMBOSSN);
			uiItemIntO(layout, "", ICON_X, "FILE_OT_delete_bookmark", "index", i);
			uiBlockSetEmboss(block, UI_EMBOSS);
		}
	}
}
开发者ID:diosney,项目名称:blender,代码行数:60,代码来源:file_panels.c

示例8: file_border_select_exec

static int file_border_select_exec(bContext *C, wmOperator *op)
{
	ARegion *ar = CTX_wm_region(C);
	rcti rect;
	FileSelect ret;
	const bool select = (RNA_int_get(op->ptr, "gesture_mode") == GESTURE_MODAL_SELECT);
	const bool extend = RNA_boolean_get(op->ptr, "extend");

	WM_operator_properties_border_to_rcti(op, &rect);

	if (!extend) {
		SpaceFile *sfile = CTX_wm_space_file(C);

		file_deselect_all(sfile, SELECTED_FILE);
	}

	BLI_rcti_isect(&(ar->v2d.mask), &rect, &rect);

	ret = file_select(C, &rect, select ? FILE_SEL_ADD : FILE_SEL_REMOVE, false, false);
	if (FILE_SELECT_DIR == ret) {
		WM_event_add_notifier(C, NC_SPACE | ND_SPACE_FILE_LIST, NULL);
	}
	else if (FILE_SELECT_FILE == ret) {
		WM_event_add_notifier(C, NC_SPACE | ND_SPACE_FILE_PARAMS, NULL);
	}
	return OPERATOR_FINISHED;
}
开发者ID:manwapastorelli,项目名称:blender-git,代码行数:27,代码来源:file_ops.c

示例9: file_parent_exec

int file_parent_exec(bContext *C, wmOperator *UNUSED(unused))
{
	SpaceFile *sfile = CTX_wm_space_file(C);
	
	if (sfile->params) {
		if (BLI_parent_dir(sfile->params->dir)) {
			BLI_cleanup_dir(G.main->name, sfile->params->dir);
			/* if not browsing in .blend file, we still want to check whether the path is a directory */
			if (sfile->params->type == FILE_LOADLIB) {
				char tdir[FILE_MAX], tgroup[FILE_MAX];
				if (BLO_is_a_library(sfile->params->dir, tdir, tgroup)) {
					file_change_dir(C, 0);
				}
				else {
					file_change_dir(C, 1);
				}
			}
			else {
				file_change_dir(C, 1);
			}
			WM_event_add_notifier(C, NC_SPACE | ND_SPACE_FILE_LIST, NULL);
		}
	}
	
	return OPERATOR_FINISHED;

}
开发者ID:manwapastorelli,项目名称:blender-git,代码行数:27,代码来源:file_ops.c

示例10: file_panel_system

static void file_panel_system(const bContext *C, Panel *pa)
{
	SpaceFile *sfile= CTX_wm_space_file(C);

	if(sfile)
		file_panel_category(C, pa, FS_CATEGORY_SYSTEM, &sfile->systemnr, ICON_DISK_DRIVE, 0, 0);
}
开发者ID:BHCLL,项目名称:blendocv,代码行数:7,代码来源:file_panels.c

示例11: autocomplete_directory

void autocomplete_directory(struct bContext *C, char *str, void *arg_v)
{
	char tmp[FILE_MAX];
	SpaceFile *sfile= CTX_wm_space_file(C);

	/* search if str matches the beginning of name */
	if(str[0] && sfile->files) {
		AutoComplete *autocpl= autocomplete_begin(str, FILE_MAX);
		int nentries = filelist_numfiles(sfile->files);
		int i;

		for(i= 0; i<nentries; ++i) {
			struct direntry* file = filelist_file(sfile->files, i);
			const char* dir = filelist_dir(sfile->files);
			if (file && S_ISDIR(file->type))	{
				// BLI_make_file_string(G.sce, tmp, dir, file->relname);
				BLI_join_dirfile(tmp, dir, file->relname);
				autocomplete_do_name(autocpl,tmp);
			}
		}
		autocomplete_end(autocpl, str);
		if (BLI_exists(str)) {
			BLI_add_slash(str);
		} else {
			BLI_make_exist(str);
		}
	}
}
开发者ID:jinjoh,项目名称:NOOR,代码行数:28,代码来源:filesel.c

示例12: file_panel_operator

static void file_panel_operator(const bContext *C, Panel *pa)
{
	SpaceFile *sfile = CTX_wm_space_file(C);
	wmOperator *op = sfile->op;

	UI_block_func_set(uiLayoutGetBlock(pa->layout), file_draw_check_cb, NULL, NULL);

	/* Hack: temporary hide.*/
	const char *hide[] = {"filepath", "directory", "filename", "files"};
	for (int i = 0; i < ARRAY_SIZE(hide); i++) {
		PropertyRNA *prop = RNA_struct_find_property(op->ptr, hide[i]);
		if (prop) {
			RNA_def_property_flag(prop, PROP_HIDDEN);
		}
	}

	uiTemplateOperatorPropertyButs(C, pa->layout, op, '\0', UI_TEMPLATE_OP_PROPS_SHOW_EMPTY);

	for (int i = 0; i < ARRAY_SIZE(hide); i++) {
		PropertyRNA *prop = RNA_struct_find_property(op->ptr, hide[i]);
		if (prop) {
			RNA_def_property_clear_flag(prop, PROP_HIDDEN);
		}
	}

	UI_block_func_set(uiLayoutGetBlock(pa->layout), NULL, NULL, NULL);
}
开发者ID:Ichthyostega,项目名称:blender,代码行数:27,代码来源:file_panels.c

示例13: file_select_all_exec

static int file_select_all_exec(bContext *C, wmOperator *UNUSED(op))
{
	ScrArea *sa = CTX_wm_area(C);
	SpaceFile *sfile = CTX_wm_space_file(C);
	FileSelection sel;
	int numfiles = filelist_numfiles(sfile->files);
	int i;
	bool is_selected = false;

	sel.first = 0; 
	sel.last = numfiles - 1;

	/* Is any file selected ? */
	for (i = 0; i < numfiles; ++i) {
		if (filelist_is_selected(sfile->files, i, CHECK_ALL)) {
			is_selected = true;
			break;
		}
	}
	/* select all only if previously no file was selected */
	if (is_selected) {
		filelist_select(sfile->files, &sel, FILE_SEL_REMOVE, SELECTED_FILE, CHECK_ALL);
	}
	else {
		const FileCheckType check_type = (sfile->params->flag & FILE_DIRSEL_ONLY) ? CHECK_DIRS : CHECK_FILES;
		filelist_select(sfile->files, &sel, FILE_SEL_ADD, SELECTED_FILE, check_type);
	}
	ED_area_tag_redraw(sa);
	return OPERATOR_FINISHED;
}
开发者ID:manwapastorelli,项目名称:blender-git,代码行数:30,代码来源:file_ops.c

示例14: file_select_invoke

static int file_select_invoke(bContext *C, wmOperator *op, const wmEvent *event)
{
	ARegion *ar = CTX_wm_region(C);
	SpaceFile *sfile = CTX_wm_space_file(C);
	FileSelect ret;
	rcti rect;
	const bool extend = RNA_boolean_get(op->ptr, "extend");
	const bool fill = RNA_boolean_get(op->ptr, "fill");
	const bool do_diropen = RNA_boolean_get(op->ptr, "open");

	if (ar->regiontype != RGN_TYPE_WINDOW)
		return OPERATOR_CANCELLED;

	rect.xmin = rect.xmax = event->mval[0];
	rect.ymin = rect.ymax = event->mval[1];

	if (!BLI_rcti_isect_pt(&ar->v2d.mask, rect.xmin, rect.ymin))
		return OPERATOR_CANCELLED;

	/* single select, deselect all selected first */
	if (!extend) file_deselect_all(sfile, SELECTED_FILE);

	ret = file_select(C, &rect, extend ? FILE_SEL_TOGGLE : FILE_SEL_ADD, fill, do_diropen);
	if (FILE_SELECT_DIR == ret)
		WM_event_add_notifier(C, NC_SPACE | ND_SPACE_FILE_LIST, NULL);
	else if (FILE_SELECT_FILE == ret)
		WM_event_add_notifier(C, NC_SPACE | ND_SPACE_FILE_PARAMS, NULL);

	WM_event_add_mousemove(C); /* for directory changes */
	WM_event_add_notifier(C, NC_SPACE | ND_SPACE_FILE_PARAMS, NULL);

	return OPERATOR_FINISHED;
}
开发者ID:manwapastorelli,项目名称:blender-git,代码行数:33,代码来源:file_ops.c

示例15: file_calc_previews

void file_calc_previews(const bContext *C, ARegion *ar)
{
	SpaceFile *sfile = CTX_wm_space_file(C);
	View2D *v2d = &ar->v2d;
	
	ED_fileselect_init_layout(sfile, ar);
	UI_view2d_totRect_set(v2d, sfile->layout->width, sfile->layout->height);
}
开发者ID:danielmarg,项目名称:blender-main,代码行数:8,代码来源:file_draw.c


注:本文中的CTX_wm_space_file函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。