Ejemplo n.º 1
0
static int report_copy_exec(bContext *C, wmOperator *UNUSED(op))
{
	SpaceInfo *sinfo = CTX_wm_space_info(C);
	ReportList *reports = CTX_wm_reports(C);
	int report_mask = info_report_mask(sinfo);

	Report *report;

	DynStr *buf_dyn = BLI_dynstr_new();
	char *buf_str;

	for (report = reports->list.first; report; report = report->next) {
		if ((report->type & report_mask) && (report->flag & SELECT)) {
			BLI_dynstr_append(buf_dyn, report->message);
			BLI_dynstr_append(buf_dyn, "\n");
		}
	}

	buf_str = BLI_dynstr_get_cstring(buf_dyn);
	BLI_dynstr_free(buf_dyn);

	WM_clipboard_text_set(buf_str, 0);

	MEM_freeN(buf_str);
	return OPERATOR_FINISHED;
}
Ejemplo n.º 2
0
static int report_delete_exec(bContext *C, wmOperator *UNUSED(op))
{
	SpaceInfo *sinfo = CTX_wm_space_info(C);
	ReportList *reports = CTX_wm_reports(C);
	int report_mask = info_report_mask(sinfo);


	Report *report, *report_next;

	for (report = reports->list.first; report; ) {

		report_next = report->next;

		if ((report->type & report_mask) && (report->flag & SELECT)) {
			BLI_remlink(&reports->list, report);
			MEM_freeN((void *)report->message);
			MEM_freeN(report);
		}

		report = report_next;
	}

	ED_area_tag_redraw(CTX_wm_area(C));

	return OPERATOR_FINISHED;
}
Ejemplo n.º 3
0
static int report_select_all_toggle_exec(bContext *C, wmOperator *UNUSED(op))
{
	SpaceInfo *sinfo = CTX_wm_space_info(C);
	ReportList *reports = CTX_wm_reports(C);
	int report_mask = info_report_mask(sinfo);
	int deselect = 0;

	Report *report;

	for (report = reports->list.last; report; report = report->prev) {
		if ((report->type & report_mask) && (report->flag & SELECT)) {
			deselect = 1;
			break;
		}
	}


	if (deselect) {
		for (report = reports->list.last; report; report = report->prev)
			if (report->type & report_mask)
				report->flag &= ~SELECT;
	}
	else {
		for (report = reports->list.last; report; report = report->prev)
			if (report->type & report_mask)
				report->flag |= SELECT;
	}

	ED_area_tag_redraw(CTX_wm_area(C));

	return OPERATOR_FINISHED;
}
Ejemplo n.º 4
0
static int report_textview_skip__internal(TextViewContext *tvc)
{
	SpaceInfo *sinfo = (SpaceInfo *)tvc->arg1;
	const int report_mask = info_report_mask(sinfo);
	while (tvc->iter && (((Report *)tvc->iter)->type & report_mask) == 0) {
		tvc->iter = (void *)((Link *)tvc->iter)->prev;
	}
	return (tvc->iter != NULL);
}
Ejemplo n.º 5
0
/* borderselect operator */
static int borderselect_exec(bContext *C, wmOperator *op)
{
	SpaceInfo *sinfo = CTX_wm_space_info(C);
	ARegion *ar = CTX_wm_region(C);
	ReportList *reports = CTX_wm_reports(C);
	int report_mask = info_report_mask(sinfo);
	int extend = RNA_boolean_get(op->ptr, "extend");
	Report *report_min, *report_max, *report;

	//View2D *v2d = UI_view2d_fromcontext(C);


	rcti rect;
	//rctf rectf, rq;
	short selecting = (RNA_int_get(op->ptr, "gesture_mode") == GESTURE_MODAL_SELECT);
	//int mval[2];

	WM_operator_properties_border_to_rcti(op, &rect);

#if 0
	mval[0] = rect.xmin;
	mval[1] = rect.ymin;
	UI_view2d_region_to_view(v2d, mval[0], mval[1], &rectf.xmin, &rectf.ymin);
	mval[0] = rect.xmax;
	mval[1] = rect.ymax;
	UI_view2d_region_to_view(v2d, mval[0], mval[1], &rectf.xmax, &rectf.ymax);
#endif

	if (!extend) {
		for (report = reports->list.first; report; report = report->next) {

			if ((report->type & report_mask) == 0)
				continue;

			report->flag &= ~SELECT;
		}
	}

	report_min = info_text_pick(sinfo, ar, reports, rect.ymax);
	report_max = info_text_pick(sinfo, ar, reports, rect.ymin);

	/* get the first report if none found */
	if (report_min == NULL) {
		// printf("find_min\n");
		for (report = reports->list.first; report; report = report->next) {
			if (report->type & report_mask) {
				report_min = report;
				break;
			}
		}
	}

	if (report_max == NULL) {
		// printf("find_max\n");
		for (report = reports->list.last; report; report = report->prev) {
			if (report->type & report_mask) {
				report_max = report;
				break;
			}
		}
	}

	if (report_min == NULL || report_max == NULL)
		return OPERATOR_CANCELLED;

	for (report = report_min; (report != report_max->next); report = report->next) {

		if ((report->type & report_mask) == 0)
			continue;

		if (selecting)
			report->flag |= SELECT;
		else
			report->flag &= ~SELECT;
	}

	ED_area_tag_redraw(CTX_wm_area(C));

	return OPERATOR_FINISHED;
}