Text: support "Text to 3D Object" for read-only data
Add poll function for read-only text data, for operators that don't require the text to be editable.
This commit is contained in:
parent
6250a8725e
commit
6ab8cbc68c
|
@ -635,7 +635,10 @@ void FONT_OT_text_paste_from_file(wmOperatorType *ot)
|
|||
/** \name Text To Object
|
||||
* \{ */
|
||||
|
||||
static void txt_add_object(bContext *C, TextLine *firstline, int totline, const float offset[3])
|
||||
static void txt_add_object(bContext *C,
|
||||
const TextLine *firstline,
|
||||
int totline,
|
||||
const float offset[3])
|
||||
{
|
||||
Main *bmain = CTX_data_main(C);
|
||||
Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C);
|
||||
|
@ -644,7 +647,7 @@ static void txt_add_object(bContext *C, TextLine *firstline, int totline, const
|
|||
Curve *cu;
|
||||
Object *obedit;
|
||||
Base *base;
|
||||
struct TextLine *tmp;
|
||||
const struct TextLine *tmp;
|
||||
int nchars = 0, nbytes = 0;
|
||||
char *s;
|
||||
int a;
|
||||
|
@ -709,10 +712,10 @@ static void txt_add_object(bContext *C, TextLine *firstline, int totline, const
|
|||
WM_event_add_notifier(C, NC_OBJECT | NA_ADDED, obedit);
|
||||
}
|
||||
|
||||
void ED_text_to_object(bContext *C, Text *text, const bool split_lines)
|
||||
void ED_text_to_object(bContext *C, const Text *text, const bool split_lines)
|
||||
{
|
||||
RegionView3D *rv3d = CTX_wm_region_view3d(C);
|
||||
TextLine *line;
|
||||
const TextLine *line;
|
||||
float offset[3];
|
||||
int linenum = 0;
|
||||
|
||||
|
|
|
@ -84,7 +84,7 @@ void ED_curve_editfont_load(struct Object *obedit);
|
|||
void ED_curve_editfont_make(struct Object *obedit);
|
||||
void ED_curve_editfont_free(struct Object *obedit);
|
||||
|
||||
void ED_text_to_object(struct bContext *C, struct Text *text, const bool split_lines);
|
||||
void ED_text_to_object(struct bContext *C, const struct Text *text, const bool split_lines);
|
||||
|
||||
void ED_curve_beztcpy(struct EditNurb *editnurb,
|
||||
struct BezTriple *dst,
|
||||
|
|
|
@ -159,6 +159,15 @@ static bool text_new_poll(bContext *UNUSED(C))
|
|||
return 1;
|
||||
}
|
||||
|
||||
static bool text_data_poll(bContext *C)
|
||||
{
|
||||
Text *text = CTX_data_edit_text(C);
|
||||
if (!text) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool text_edit_poll(bContext *C)
|
||||
{
|
||||
Text *text = CTX_data_edit_text(C);
|
||||
|
@ -751,11 +760,6 @@ void TEXT_OT_save_as(wmOperatorType *ot)
|
|||
/** \name Run Script Operator
|
||||
* \{ */
|
||||
|
||||
static bool text_run_script_poll(bContext *C)
|
||||
{
|
||||
return (CTX_data_edit_text(C) != NULL);
|
||||
}
|
||||
|
||||
static int text_run_script(bContext *C, ReportList *reports)
|
||||
{
|
||||
#ifdef WITH_PYTHON
|
||||
|
@ -817,7 +821,7 @@ void TEXT_OT_run_script(wmOperatorType *ot)
|
|||
ot->description = "Run active script";
|
||||
|
||||
/* api callbacks */
|
||||
ot->poll = text_run_script_poll;
|
||||
ot->poll = text_data_poll;
|
||||
ot->exec = text_run_script_exec;
|
||||
|
||||
/* flags */
|
||||
|
@ -3911,7 +3915,7 @@ void TEXT_OT_resolve_conflict(wmOperatorType *ot)
|
|||
|
||||
static int text_to_3d_object_exec(bContext *C, wmOperator *op)
|
||||
{
|
||||
Text *text = CTX_data_edit_text(C);
|
||||
const Text *text = CTX_data_edit_text(C);
|
||||
const bool split_lines = RNA_boolean_get(op->ptr, "split_lines");
|
||||
|
||||
ED_text_to_object(C, text, split_lines);
|
||||
|
@ -3928,7 +3932,7 @@ void TEXT_OT_to_3d_object(wmOperatorType *ot)
|
|||
|
||||
/* api callbacks */
|
||||
ot->exec = text_to_3d_object_exec;
|
||||
ot->poll = text_edit_poll;
|
||||
ot->poll = text_data_poll;
|
||||
|
||||
/* flags */
|
||||
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
|
||||
|
|
Loading…
Reference in New Issue