示例#1
0
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;
}
示例#2
0
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;
}
示例#3
0
static void file_deselect_all(SpaceFile *sfile, unsigned int flag)
{
	FileSelection sel;
	sel.first = 0;
	sel.last = filelist_numfiles(sfile->files) - 1;
	
	filelist_select(sfile->files, &sel, FILE_SEL_REMOVE, flag, CHECK_ALL);
}
示例#4
0
static int file_border_select_modal(bContext *C, wmOperator *op, wmEvent *event)
{
	ARegion *ar= CTX_wm_region(C);
	SpaceFile *sfile= CTX_wm_space_file(C);
	FileSelectParams *params = ED_fileselect_get_params(sfile);
	FileSelection sel;
	rcti rect;

	int result;

	result=	WM_border_select_modal(C, op, event);

	if(result==OPERATOR_RUNNING_MODAL)	{

		rect.xmin= RNA_int_get(op->ptr, "xmin");
		rect.ymin= RNA_int_get(op->ptr, "ymin");
		rect.xmax= RNA_int_get(op->ptr, "xmax");
		rect.ymax= RNA_int_get(op->ptr, "ymax");

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

		sel = file_selection_get(C, &rect, 0);
		if ( (sel.first != params->sel_first) || (sel.last != params->sel_last) ) {
			file_deselect_all(sfile, HILITED_FILE);
			filelist_select(sfile->files, &sel, FILE_SEL_ADD, HILITED_FILE, CHECK_ALL);
			WM_event_add_notifier(C, NC_SPACE|ND_SPACE_FILE_PARAMS, NULL);
		}
		params->sel_first = sel.first; params->sel_last = sel.last;

	}else {
		params->active_file = -1;
		params->sel_first = params->sel_last = -1;
		file_deselect_all(sfile, HILITED_FILE);
		WM_event_add_notifier(C, NC_SPACE|ND_SPACE_FILE_PARAMS, NULL);
	}

	return result;
}