[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [29602] trunk/blender: Added ability to add and remove text boxes back from Blender 2.4x.
William Reynish
william at reynish.com
Tue Jun 22 01:20:44 CEST 2010
Revision: 29602
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=29602
Author: billrey
Date: 2010-06-22 01:20:44 +0200 (Tue, 22 Jun 2010)
Log Message:
-----------
Added ability to add and remove text boxes back from Blender 2.4x. One on those small things missing.
Modified Paths:
--------------
trunk/blender/release/scripts/ui/properties_data_curve.py
trunk/blender/source/blender/editors/curve/curve_intern.h
trunk/blender/source/blender/editors/curve/curve_ops.c
trunk/blender/source/blender/editors/curve/editfont.c
Modified: trunk/blender/release/scripts/ui/properties_data_curve.py
===================================================================
--- trunk/blender/release/scripts/ui/properties_data_curve.py 2010-06-21 22:16:13 UTC (rev 29601)
+++ trunk/blender/release/scripts/ui/properties_data_curve.py 2010-06-21 23:20:44 UTC (rev 29602)
@@ -367,22 +367,37 @@
text = context.curve
wide_ui = context.region.width > narrowui
+
+ 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")
- 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")
-
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,
DATA_PT_shape_curve,
Modified: trunk/blender/source/blender/editors/curve/curve_intern.h
===================================================================
--- trunk/blender/source/blender/editors/curve/curve_intern.h 2010-06-21 22:16:13 UTC (rev 29601)
+++ trunk/blender/source/blender/editors/curve/curve_intern.h 2010-06-21 23:20:44 UTC (rev 29602)
@@ -66,6 +66,9 @@
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);
Modified: trunk/blender/source/blender/editors/curve/curve_ops.c
===================================================================
--- trunk/blender/source/blender/editors/curve/curve_ops.c 2010-06-21 22:16:13 UTC (rev 29601)
+++ trunk/blender/source/blender/editors/curve/curve_ops.c 2010-06-21 23:20:44 UTC (rev 29602)
@@ -81,6 +81,9 @@
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);
Modified: trunk/blender/source/blender/editors/curve/editfont.c
===================================================================
--- trunk/blender/source/blender/editors/curve/editfont.c 2010-06-21 22:16:13 UTC (rev 29601)
+++ trunk/blender/source/blender/editors/curve/editfont.c 2010-06-21 23:20:44 UTC (rev 29602)
@@ -1363,6 +1363,99 @@
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)
More information about the Bf-blender-cvs
mailing list