curve.textboxes collection access for the UI + minor UI tweaks for poly curves

This commit is contained in:
Campbell Barton 2009-09-09 00:10:12 +00:00
parent e6965c46fc
commit 850abb3580
3 changed files with 97 additions and 76 deletions

@ -15,7 +15,7 @@ class DataButtonsPanelCurve(DataButtonsPanel):
'''
def poll(self, context):
return (context.object and context.object.type == 'CURVE' and context.curve)
class DataButtonsPanelActive(DataButtonsPanel):
'''
Same as above but for curves only
@ -80,7 +80,7 @@ class DATA_PT_shape_curve(DataButtonsPanel):
sub = col.column(align=True)
sub.itemR(curve, "resolution_u", text="Preview U")
sub.itemR(curve, "render_resolution_u", text="Render U")
if is_surf:
sub = col.column(align=True)
sub.itemR(curve, "resolution_v", text="Preview V")
@ -150,59 +150,70 @@ class DATA_PT_active_spline(DataButtonsPanelActive):
curve = context.curve
act_spline = curve.active_spline
is_surf = (ob.type == 'SURFACE')
is_poly = (act_spline.type == 'POLY')
split = layout.split()
col = split.column()
col.itemL(text="Cyclic:")
if act_spline.type == 'NURBS':
col.itemL(text="Bezier:")
col.itemL(text="Endpoint:")
col.itemL(text="Order:")
col.itemL(text="Resolution:")
col = split.column()
col.itemR(act_spline, "cyclic_u", text="U")
if act_spline.type == 'NURBS':
sub = col.column()
sub.active = (not act_spline.cyclic_u)
sub.itemR(act_spline, "bezier_u", text="U")
sub.itemR(act_spline, "endpoint_u", text="U")
sub = col.column()
sub.itemR(act_spline, "order_u", text="U")
col.itemR(act_spline, "resolution_u", text="U")
if is_surf:
if is_poly:
# These settings are below but its easier to have
# poly's set aside since they use so few settings
col = split.column()
col.itemR(act_spline, "cyclic_v", text="V")
# its a surface, assume its a nurb.
sub = col.column()
sub.active = (not act_spline.cyclic_v)
sub.itemR(act_spline, "bezier_v", text="V")
sub.itemR(act_spline, "endpoint_v", text="V")
sub = col.column()
sub.itemR(act_spline, "order_v", text="V")
sub.itemR(act_spline, "resolution_v", text="V")
col.itemL(text="Cyclic:")
col.itemR(act_spline, "smooth")
col = split.column()
col.itemR(act_spline, "cyclic_u", text="U")
if not is_surf:
else:
col = split.column()
col.itemL(text="Cyclic:")
if act_spline.type == 'NURBS':
col.itemL(text="Bezier:")
col.itemL(text="Endpoint:")
col.itemL(text="Order:")
col.itemL(text="Resolution:")
col = split.column()
col.itemR(act_spline, "cyclic_u", text="U")
if act_spline.type == 'NURBS':
sub = col.column()
# sub.active = (not act_spline.cyclic_u)
sub.itemR(act_spline, "bezier_u", text="U")
sub.itemR(act_spline, "endpoint_u", text="U")
sub = col.column()
sub.itemR(act_spline, "order_u", text="U")
col.itemR(act_spline, "resolution_u", text="U")
if is_surf:
col = split.column()
col.itemR(act_spline, "cyclic_v", text="V")
# its a surface, assume its a nurb.
sub = col.column()
sub.active = (not act_spline.cyclic_v)
sub.itemR(act_spline, "bezier_v", text="V")
sub.itemR(act_spline, "endpoint_v", text="V")
sub = col.column()
sub.itemR(act_spline, "order_v", text="V")
sub.itemR(act_spline, "resolution_v", text="V")
if not is_surf:
split = layout.split()
col = split.column()
col.active = (not curve.curve_2d)
col.itemL(text="Interpolation:")
col.itemR(act_spline, "tilt_interpolation", text="Tilt")
col.itemR(act_spline, "radius_interpolation", text="Radius")
split = layout.split()
col = split.column()
col.active = (not curve.curve_2d)
col.itemL(text="Interpolation:")
col.itemR(act_spline, "tilt_interpolation", text="Tilt")
col.itemR(act_spline, "radius_interpolation", text="Radius")
split = layout.split()
col = split.column()
col.itemR(act_spline, "smooth")
col.itemR(act_spline, "smooth")
bpy.types.register(DATA_PT_context_curve)
bpy.types.register(DATA_PT_shape_curve)
bpy.types.register(DATA_PT_geometry_curve)

@ -44,8 +44,10 @@ class DATA_PT_shape_text(DataButtonsPanel):
col = split.column()
col.itemL(text="Caps:")
col.itemR(curve, "front")
col.itemR(curve, "back")
row = col.row()
row .itemR(curve, "front")
row .itemR(curve, "back")
# col = split.column()
col.itemL(text="Textures:")
col.itemR(curve, "uv_orco")
col.itemR(curve, "auto_texspace")
@ -55,11 +57,12 @@ class DATA_PT_shape_text(DataButtonsPanel):
sub = col.column(align=True)
sub.itemR(curve, "resolution_u", text="Preview U")
sub.itemR(curve, "render_resolution_u", text="Render U")
# resolution_v is not used for text
sub = col.column(align=True)
sub.itemR(curve, "resolution_v", text="Preview V")
sub.itemR(curve, "render_resolution_v", text="Render V")
col.itemL(text="Display:")
col.itemR(curve, "fast")
col.itemR(curve, "fast", text="Fast Editing")
class DATA_PT_geometry_text(DataButtonsPanel):
__label__ = "Geometry"
@ -93,19 +96,19 @@ class DATA_PT_font(DataButtonsPanel):
text = context.curve
char = context.curve.edit_format
layout.itemR(text, "font")
row = layout.row()
row.itemR(text, "text_size", text="Size")
row.itemR(text, "shear")
split = layout.split()
col = split.column()
col = split.column()
col.itemL(text="Object Font:")
col.itemR(text, "family", text="")
col = split.column()
col.itemL(text="Text on Curve:")
col.itemR(text, "text_on_curve", text="")
@ -158,19 +161,19 @@ class DATA_PT_textboxes(DataButtonsPanel):
layout = self.layout
text = context.curve
box = context.curve.textbox
split = layout.box().split()
for box in text.textboxes:
split = layout.box().split()
col = split.column(align=True)
col.itemL(text="Dimensions:")
col.itemR(box, "width", text="Width")
col.itemR(box, "height", text="Height")
col = split.column(align=True)
col.itemL(text="Dimensions:")
col.itemR(box, "width", text="Width")
col.itemR(box, "height", text="Height")
col = split.column(align=True)
col.itemL(text="Offset:")
col.itemR(box, "x", text="X")
col.itemR(box, "y", text="Y")
col = split.column(align=True)
col.itemL(text="Offset:")
col.itemR(box, "x", text="X")
col.itemR(box, "y", text="Y")
bpy.types.register(DATA_PT_context_text)
bpy.types.register(DATA_PT_shape_text)

@ -159,6 +159,14 @@ static void rna_Curve_material_index_range(PointerRNA *ptr, int *min, int *max)
*max= cu->totcol-1;
}
static void rna_Curve_active_textbox_index_range(PointerRNA *ptr, int *min, int *max)
{
Curve *cu= (Curve*)ptr->id.data;
*min= 0;
*max= cu->totbox-1;
}
static void rna_Curve_2d_set(PointerRNA *ptr, int value)
{
Curve *cu= (Curve*)ptr->id.data;
@ -509,11 +517,15 @@ static void rna_def_font(BlenderRNA *brna, StructRNA *srna)
RNA_def_property_ui_text(prop, "Underline Thickness", "");
RNA_def_property_update(prop, 0, "rna_Curve_update_data");
prop= RNA_def_property(srna, "textboxes", PROP_COLLECTION, PROP_NONE);
RNA_def_property_collection_sdna(prop, NULL, "tb", "totbox");
RNA_def_property_struct_type(prop, "TextBox");
RNA_def_property_ui_text(prop, "Textboxes", "");
prop= RNA_def_property(srna, "active_textbox", PROP_INT, PROP_NONE);
RNA_def_property_int_sdna(prop, NULL, "actbox");
RNA_def_property_range(prop, 0, 100);
RNA_def_property_ui_text(prop, "The active text box", "");
RNA_def_property_update(prop, 0, "rna_Curve_update_data");
RNA_def_property_int_funcs(prop, NULL, NULL, "rna_Curve_active_textbox_index_range");
/* strings */
prop= RNA_def_property(srna, "family", PROP_STRING, PROP_NONE);
@ -539,12 +551,7 @@ static void rna_def_font(BlenderRNA *brna, StructRNA *srna)
RNA_def_property_pointer_sdna(prop, NULL, "vfont");
RNA_def_property_ui_text(prop, "Font", "");
RNA_def_property_update(prop, 0, "rna_Curve_update_data");
prop= RNA_def_property(srna, "textbox", PROP_POINTER, PROP_NONE);
RNA_def_property_pointer_sdna(prop, NULL, "tb");
RNA_def_property_ui_text(prop, "Textbox", "");
RNA_def_property_update(prop, 0, "rna_Curve_update_data");
prop= RNA_def_property(srna, "edit_format", PROP_POINTER, PROP_NONE);
RNA_def_property_pointer_sdna(prop, NULL, "curinfo");
RNA_def_property_ui_text(prop, "Edit Format", "Editing settings character formatting.");