Added ability to add and remove text boxes back from Blender 2.4x. One on those small things missing.
This commit is contained in:
@@ -367,21 +367,36 @@ class DATA_PT_textboxes(DataButtonsPanel):
|
||||
|
||||
text = context.curve
|
||||
wide_ui = context.region.width > narrowui
|
||||
|
||||
for box in text.textboxes:
|
||||
split = layout.box().split()
|
||||
|
||||
col = split.column(align=True)
|
||||
col.label(text="Dimensions:")
|
||||
col.prop(box, "width", text="Width")
|
||||
col.prop(box, "height", text="Height")
|
||||
|
||||
split = layout.split()
|
||||
col = split.column()
|
||||
col.operator("font.textbox_add", icon='ZOOMIN')
|
||||
if wide_ui:
|
||||
col = split.column()
|
||||
|
||||
for i, box in enumerate(text.textboxes):
|
||||
|
||||
boxy = layout.box()
|
||||
|
||||
split = boxy.split()
|
||||
|
||||
col = split.column()
|
||||
|
||||
col2 = col.column(align=True)
|
||||
col2.label(text="Dimensions:")
|
||||
col2.prop(box, "width", text="Width")
|
||||
col2.prop(box, "height", text="Height")
|
||||
|
||||
if wide_ui:
|
||||
col = split.column(align=True)
|
||||
col.label(text="Offset:")
|
||||
col.prop(box, "x", text="X")
|
||||
col.prop(box, "y", text="Y")
|
||||
|
||||
col = split.column()
|
||||
|
||||
row = col.row()
|
||||
row.label(text="Offset:")
|
||||
row.operator("font.textbox_remove", text='', icon='X').index = i
|
||||
|
||||
col2 = col.column(align=True)
|
||||
col2.prop(box, "x", text="X")
|
||||
col2.prop(box, "y", text="Y")
|
||||
|
||||
classes = [
|
||||
DATA_PT_context_curve,
|
||||
|
||||
@@ -66,6 +66,9 @@ void FONT_OT_change_spacing(struct wmOperatorType *ot);
|
||||
void FONT_OT_open(struct wmOperatorType *ot);
|
||||
void FONT_OT_unlink(struct wmOperatorType *ot);
|
||||
|
||||
void FONT_OT_textbox_add(struct wmOperatorType *ot);
|
||||
void FONT_OT_textbox_remove(struct wmOperatorType *ot);
|
||||
|
||||
/* editcurve.c */
|
||||
void CURVE_OT_hide(struct wmOperatorType *ot);
|
||||
void CURVE_OT_reveal(struct wmOperatorType *ot);
|
||||
|
||||
@@ -81,6 +81,9 @@ void ED_operatortypes_curve(void)
|
||||
|
||||
WM_operatortype_append(FONT_OT_open);
|
||||
WM_operatortype_append(FONT_OT_unlink);
|
||||
|
||||
WM_operatortype_append(FONT_OT_textbox_add);
|
||||
WM_operatortype_append(FONT_OT_textbox_remove);
|
||||
|
||||
WM_operatortype_append(CURVE_OT_hide);
|
||||
WM_operatortype_append(CURVE_OT_reveal);
|
||||
|
||||
@@ -1363,6 +1363,99 @@ void FONT_OT_text_insert(wmOperatorType *ot)
|
||||
RNA_def_string(ot->srna, "text", "", 0, "Text", "Text to insert at the cursor position.");
|
||||
}
|
||||
|
||||
|
||||
/*********************** textbox add operator *************************/
|
||||
static int textbox_poll(bContext *C)
|
||||
{
|
||||
Object *ob = CTX_data_active_object(C);
|
||||
|
||||
if (!ED_operator_object_active_editable(C) ) return 0;
|
||||
if (ob->type != OB_FONT) return 0;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int textbox_add_exec(bContext *C, wmOperator *op)
|
||||
{
|
||||
Object *obedit= CTX_data_active_object(C);
|
||||
Curve *cu= obedit->data;
|
||||
int i;
|
||||
|
||||
if (cu->totbox < 256) {
|
||||
for (i = cu->totbox; i>cu->actbox; i--) cu->tb[i]= cu->tb[i-1];
|
||||
cu->tb[cu->actbox]= cu->tb[cu->actbox-1];
|
||||
cu->actbox++;
|
||||
cu->totbox++;
|
||||
}
|
||||
|
||||
WM_event_add_notifier(C, NC_GEOM|ND_DATA, obedit->data);
|
||||
return OPERATOR_FINISHED;
|
||||
}
|
||||
|
||||
void FONT_OT_textbox_add(wmOperatorType *ot)
|
||||
{
|
||||
/* identifiers */
|
||||
ot->name= "Add Textbox";
|
||||
ot->description= "Add a new text box";
|
||||
ot->idname= "FONT_OT_textbox_add";
|
||||
|
||||
/* api callbacks */
|
||||
ot->exec= textbox_add_exec;
|
||||
ot->poll= textbox_poll;
|
||||
|
||||
/* flags */
|
||||
ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*********************** textbox remove operator *************************/
|
||||
|
||||
|
||||
|
||||
static int textbox_remove_exec(bContext *C, wmOperator *op)
|
||||
{
|
||||
Object *obedit= CTX_data_active_object(C);
|
||||
Curve *cu= obedit->data;
|
||||
int i;
|
||||
int index = RNA_int_get(op->ptr, "index");
|
||||
|
||||
|
||||
if (cu->totbox > 1) {
|
||||
for (i = index; i < cu->totbox; i++) cu->tb[i]= cu->tb[i+1];
|
||||
cu->totbox--;
|
||||
if (cu->actbox >= index)
|
||||
cu->actbox--;
|
||||
}
|
||||
|
||||
WM_event_add_notifier(C, NC_GEOM|ND_DATA, obedit->data);
|
||||
|
||||
return OPERATOR_FINISHED;
|
||||
}
|
||||
|
||||
void FONT_OT_textbox_remove(wmOperatorType *ot)
|
||||
{
|
||||
/* identifiers */
|
||||
ot->name= "Remove Textbox";
|
||||
ot->description= "Remove the textbox";
|
||||
ot->idname= "FONT_OT_textbox_remove";
|
||||
|
||||
/* api callbacks */
|
||||
ot->exec= textbox_remove_exec;
|
||||
ot->poll= textbox_poll;
|
||||
|
||||
/* flags */
|
||||
ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
|
||||
|
||||
RNA_def_int(ot->srna, "index", 0, 0, INT_MAX, "Index", "The current text box.", 0, INT_MAX);
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
/***************** editmode enter/exit ********************/
|
||||
|
||||
void make_editText(Object *obedit)
|
||||
|
||||
Reference in New Issue
Block a user