From 127f19cac4378142dfcf1edd18e0e014f248270c Mon Sep 17 00:00:00 2001 From: Joshua Leung Date: Thu, 13 Aug 2009 07:28:51 +0000 Subject: 2.5 - Assorted cleanups * Silencing some compiler warnings * Set paths for Scene rendering settings so that they can be animated (or at least won't produce error warnings) --- source/blender/blenkernel/BKE_pointcache.h | 1 + .../blender/editors/animation/anim_channels_edit.c | 40 ++++------------------ source/blender/editors/space_outliner/outliner.c | 2 +- source/blender/makesrna/intern/rna_scene.c | 6 ++++ 4 files changed, 14 insertions(+), 35 deletions(-) (limited to 'source') diff --git a/source/blender/blenkernel/BKE_pointcache.h b/source/blender/blenkernel/BKE_pointcache.h index 011cde9f297..b83afb6b28f 100644 --- a/source/blender/blenkernel/BKE_pointcache.h +++ b/source/blender/blenkernel/BKE_pointcache.h @@ -71,6 +71,7 @@ struct Object; struct Scene; struct SoftBody; struct ParticleSystem; +struct ParticleKey; struct ClothModifierData; struct PointCache; struct ListBase; diff --git a/source/blender/editors/animation/anim_channels_edit.c b/source/blender/editors/animation/anim_channels_edit.c index d74c9fbf48b..4f463d3daed 100644 --- a/source/blender/editors/animation/anim_channels_edit.c +++ b/source/blender/editors/animation/anim_channels_edit.c @@ -1193,47 +1193,19 @@ static void borderselect_anim_channels (bAnimContext *ac, rcti *rect, short sele /* if channel is within border-select region, alter it */ if (!((ymax < rectf.ymin) || (ymin > rectf.ymax))) { - /* only the following types can be selected */ + /* set selection flags only */ + ANIM_channel_setting_set(ac, ale, ACHANNEL_SETTING_SELECT, selectmode); + + /* type specific actions */ switch (ale->type) { - case ANIMTYPE_OBJECT: /* object */ - { - Base *base= (Base *)ale->data; - Object *ob= base->object; - - ACHANNEL_SET_FLAG(base, selectmode, SELECT); - ACHANNEL_SET_FLAG(ob, selectmode, SELECT); - } - break; - case ANIMTYPE_GROUP: /* action group */ + case ANIMTYPE_GROUP: { bActionGroup *agrp= (bActionGroup *)ale->data; - ACHANNEL_SET_FLAG(agrp, selectmode, AGRP_SELECTED); + /* always clear active flag after doing this */ agrp->flag &= ~AGRP_ACTIVE; } break; - case ANIMTYPE_FCURVE: /* F-Curve channel */ - { - FCurve *fcu = (FCurve *)ale->data; - - ACHANNEL_SET_FLAG(fcu, selectmode, FCURVE_SELECTED); - } - break; - case ANIMTYPE_GPLAYER: /* grease-pencil layer */ - { - bGPDlayer *gpl = (bGPDlayer *)ale->data; - - ACHANNEL_SET_FLAG(gpl, selectmode, GP_LAYER_SELECT); - } - break; - - case ANIMTYPE_NLATRACK: /* nla-track */ - { - NlaTrack *nlt= (NlaTrack *)ale->data; - - ACHANNEL_SET_FLAG(nlt, selectmode, NLATRACK_SELECTED); - } - break; } } diff --git a/source/blender/editors/space_outliner/outliner.c b/source/blender/editors/space_outliner/outliner.c index 4f5d3f8f736..e4fa095e552 100644 --- a/source/blender/editors/space_outliner/outliner.c +++ b/source/blender/editors/space_outliner/outliner.c @@ -3663,7 +3663,7 @@ static void tree_element_to_path(SpaceOops *soops, TreeElement *te, TreeStoreEle } else if(RNA_property_type(prop) == PROP_COLLECTION) { char buf[128], *name; - + temnext= (TreeElement*)(ld->next->data); tsenext= TREESTORE(temnext); diff --git a/source/blender/makesrna/intern/rna_scene.c b/source/blender/makesrna/intern/rna_scene.c index 97320c0f9d4..f74687a3096 100644 --- a/source/blender/makesrna/intern/rna_scene.c +++ b/source/blender/makesrna/intern/rna_scene.c @@ -174,6 +174,11 @@ static void rna_Scene_frame_update(bContext *C, PointerRNA *ptr) //ED_update_for_newframe(C); } +static char *rna_SceneRenderData_path(PointerRNA *ptr) +{ + return BLI_sprintfN("render_data"); +} + static int rna_SceneRenderData_threads_get(PointerRNA *ptr) { RenderData *rd= (RenderData*)ptr->data; @@ -1081,6 +1086,7 @@ static void rna_def_scene_render_data(BlenderRNA *brna) srna= RNA_def_struct(brna, "SceneRenderData", NULL); RNA_def_struct_sdna(srna, "RenderData"); RNA_def_struct_nested(brna, srna, "Scene"); + RNA_def_struct_path_func(srna, "rna_SceneRenderData_path"); RNA_def_struct_ui_text(srna, "Render Data", "Rendering settings for a Scene datablock."); prop= RNA_def_property(srna, "color_mode", PROP_ENUM, PROP_NONE); -- cgit v1.2.3 From d916c25616b4f5038d9b17fb3eae9de377a2a9e5 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 13 Aug 2009 07:37:41 +0000 Subject: - moved unit settings from user prefs into the scene. - use the scene context for the unit settings since there isn't a better place for it currently. - added 'chain' to imperial units - set more rna props to be distances and angles. --- source/blender/blenkernel/intern/scene.c | 3 + source/blender/blenkernel/intern/unit.c | 1 + source/blender/editors/interface/interface.c | 26 ++++---- source/blender/editors/space_view3d/view3d_draw.c | 14 ++--- source/blender/editors/transform/transform.c | 10 ++-- source/blender/makesdna/DNA_scene_types.h | 19 ++++++ source/blender/makesdna/DNA_userdef_types.h | 11 +--- source/blender/makesrna/RNA_access.h | 1 + source/blender/makesrna/intern/rna_constraint.c | 72 +++++++++++------------ source/blender/makesrna/intern/rna_scene.c | 41 +++++++++++++ source/blender/makesrna/intern/rna_userdef.c | 23 -------- 11 files changed, 129 insertions(+), 92 deletions(-) (limited to 'source') diff --git a/source/blender/blenkernel/intern/scene.c b/source/blender/blenkernel/intern/scene.c index 0a93874f24e..0e987850acd 100644 --- a/source/blender/blenkernel/intern/scene.c +++ b/source/blender/blenkernel/intern/scene.c @@ -280,6 +280,9 @@ Scene *add_scene(char *name) sce->toolsettings->proportional_size = 1.0f; + + sce->unit.scale_length = 1.0f; + pset= &sce->toolsettings->particle; pset->flag= PE_KEEP_LENGTHS|PE_LOCK_FIRST|PE_DEFLECT_EMITTER; pset->emitterdist= 0.25f; diff --git a/source/blender/blenkernel/intern/unit.c b/source/blender/blenkernel/intern/unit.c index 8c63a8756a4..dfec54eb5ea 100644 --- a/source/blender/blenkernel/intern/unit.c +++ b/source/blender/blenkernel/intern/unit.c @@ -82,6 +82,7 @@ static struct bUnitCollection buMetricLenCollecton = {buMetricLenDef, 3, 0, size static struct bUnitDef buImperialLenDef[] = { {"mile", "Miles", "mi", "m", 1609.344, 0.0, B_UNIT_DEF_NONE}, {"furlong", "Furlongs", "fur", NULL,201.168, 0.0, B_UNIT_DEF_SUPPRESS}, + {"chain", "Chains", "ch", NULL, 0.9144*22.0, 0.0, B_UNIT_DEF_SUPPRESS}, {"yard", "Yards", "yd", NULL, 0.9144, 0.0, B_UNIT_DEF_NONE}, {"foot", "Feet", "'", "ft", 0.3048, 0.0, B_UNIT_DEF_NONE}, {"inch", "Inches", "\"", "in", 0.0254, 0.0, B_UNIT_DEF_NONE}, /* base unit */ diff --git a/source/blender/editors/interface/interface.c b/source/blender/editors/interface/interface.c index 2fe3ac720b6..a8703868ad1 100644 --- a/source/blender/editors/interface/interface.c +++ b/source/blender/editors/interface/interface.c @@ -1144,7 +1144,8 @@ int ui_is_but_float(uiBut *but) int ui_is_but_unit(uiBut *but) { - if(U.unit_system == USER_UNIT_NONE) + Scene *scene= CTX_data_scene((bContext *)but->block->evil_C); + if(scene->unit.system == USER_UNIT_NONE) return 0; if(but->rnaprop==NULL) @@ -1324,13 +1325,13 @@ int ui_get_but_string_max_length(uiBut *but) static double ui_get_but_scale_unit(uiBut *but, double value) { + Scene *scene= CTX_data_scene((bContext *)but->block->evil_C); int subtype= RNA_property_subtype(but->rnaprop); if(subtype & PROP_UNIT_LENGTH) { - return value * U.unit_scale_length; + return value * scene->unit.scale_length; } else if(subtype & PROP_UNIT_TIME) { /* WARNING - using evil_C :| */ - Scene *scene= CTX_data_scene((bContext *)but->block->evil_C); return FRA2TIME(value); } else { @@ -1340,23 +1341,27 @@ static double ui_get_but_scale_unit(uiBut *but, double value) static void ui_get_but_string_unit(uiBut *but, char *str, double value, int pad) { - int do_split= U.unit_flag & USER_UNIT_OPT_SPLIT ? 1:0; + Scene *scene= CTX_data_scene((bContext *)but->block->evil_C); + int do_split= scene->unit.flag & USER_UNIT_OPT_SPLIT; int unit_type= RNA_SUBTYPE_UNIT_VALUE(RNA_property_subtype(but->rnaprop)); int precission= but->a2; + if(scene->unit.scale_length<0.0001) scene->unit.scale_length= 1.0; // XXX do_versions + /* Sanity checks */ if(precission>4) precission= 4; else if(precission==0) precission= 2; - bUnit_AsString(str, ui_get_but_scale_unit(but, value), precission, U.unit_system, unit_type, do_split, pad); + bUnit_AsString(str, ui_get_but_scale_unit(but, value), precission, scene->unit.system, unit_type, do_split, pad); } static float ui_get_but_step_unit(uiBut *but, double value, float step_default) { + Scene *scene= CTX_data_scene((bContext *)but->block->evil_C); int unit_type= RNA_SUBTYPE_UNIT_VALUE(RNA_property_subtype(but->rnaprop)); float step; - step = bUnit_ClosestScalar(ui_get_but_scale_unit(but, value), U.unit_system, unit_type); + step = bUnit_ClosestScalar(ui_get_but_scale_unit(but, value), scene->unit.system, unit_type); if(step > 0.0) { /* -1 is an error value */ return (step/ui_get_but_scale_unit(but, 1.0))*100; @@ -1502,10 +1507,12 @@ int ui_set_but_string(bContext *C, uiBut *but, const char *str) { char str_unit_convert[256]; int unit_type= RNA_SUBTYPE_UNIT_VALUE(RNA_property_subtype(but->rnaprop)); + Scene *scene= CTX_data_scene((bContext *)but->block->evil_C); + - if(U.unit_system != USER_UNIT_NONE && unit_type) { + if(scene->unit.system != USER_UNIT_NONE && unit_type) { /* ugly, use the draw string to get the value, this could cause problems if it includes some text which resolves to a unit */ - bUnit_ReplaceString(str_unit_convert, str, but->drawstr, ui_get_but_scale_unit(but, 1.0), U.unit_system, unit_type); + bUnit_ReplaceString(str_unit_convert, str, but->drawstr, ui_get_but_scale_unit(but, 1.0), scene->unit.system, unit_type); } else { strcpy(str_unit_convert, str); @@ -1865,9 +1872,6 @@ void ui_check_but(uiBut *but) /* support length type buttons */ else if(ui_is_but_unit(but)) { char new_str[256]; - - if(U.unit_scale_length<0.0001) U.unit_scale_length= 1.0; // XXX do_versions - ui_get_but_string_unit(but, new_str, value, TRUE); sprintf(but->drawstr, "%s%s", but->str, new_str); } diff --git a/source/blender/editors/space_view3d/view3d_draw.c b/source/blender/editors/space_view3d/view3d_draw.c index fcc6692f621..0e5c1606066 100644 --- a/source/blender/editors/space_view3d/view3d_draw.c +++ b/source/blender/editors/space_view3d/view3d_draw.c @@ -237,7 +237,7 @@ static void drawgrid_draw(ARegion *ar, float wx, float wy, float x, float y, flo #define GRID_MIN_PX 6.0f -static void drawgrid(ARegion *ar, View3D *v3d, char **grid_unit) +static void drawgrid(UnitSettings *unit, ARegion *ar, View3D *v3d, char **grid_unit) { /* extern short bgpicmode; */ RegionView3D *rv3d= ar->regiondata; @@ -260,7 +260,7 @@ static void drawgrid(ARegion *ar, View3D *v3d, char **grid_unit) x= (wx)*fx/fw; y= (wy)*fy/fw; - vec4[0]=vec4[1]= (U.unit_system) ? 1.0 : v3d->grid; + vec4[0]=vec4[1]= (unit->system) ? 1.0 : v3d->grid; vec4[2]= 0.0; vec4[3]= 1.0; @@ -277,7 +277,7 @@ static void drawgrid(ARegion *ar, View3D *v3d, char **grid_unit) /* check zoom out */ UI_ThemeColor(TH_GRID); - if(U.unit_system) { + if(unit->system) { /* Use GRID_MIN_PX*2 for units because very very small grid * items are less useful when dealing with units */ void *usys; @@ -286,21 +286,21 @@ static void drawgrid(ARegion *ar, View3D *v3d, char **grid_unit) float dx_scalar; float blend_fac; - bUnit_GetSystem(&usys, &len, U.unit_system, B_UNIT_LENGTH); + bUnit_GetSystem(&usys, &len, unit->system, B_UNIT_LENGTH); if(usys) { i= len; while(i--) { scalar= bUnit_GetScaler(usys, i); - dx_scalar = dx * scalar * U.unit_scale_length; + dx_scalar = dx * scalar * unit->scale_length; if (dx_scalar < (GRID_MIN_PX*2)) continue; /* Store the smallest drawn grid size units name so users know how big each grid cell is */ if(*grid_unit==NULL) { *grid_unit= bUnit_GetNamePlural(usys, i); - v3d->gridview= (scalar * U.unit_scale_length); + v3d->gridview= (scalar * unit->scale_length); } blend_fac= 1-((GRID_MIN_PX*2)/dx_scalar); @@ -1978,7 +1978,7 @@ void view3d_main_area_draw(const bContext *C, ARegion *ar) } else { ED_region_pixelspace(ar); - drawgrid(ar, v3d, &grid_unit); + drawgrid(&scene->unit, ar, v3d, &grid_unit); /* XXX make function? replaces persp(1) */ glMatrixMode(GL_PROJECTION); wmLoadMatrix(rv3d->winmat); diff --git a/source/blender/editors/transform/transform.c b/source/blender/editors/transform/transform.c index 1d4882c2da2..042e4a1941a 100644 --- a/source/blender/editors/transform/transform.c +++ b/source/blender/editors/transform/transform.c @@ -3040,11 +3040,11 @@ static void headerTranslation(TransInfo *t, float vec[3], char *str) { applyAspectRatio(t, dvec); dist = VecLength(vec); - if(U.unit_system) { - int i, do_split= U.unit_flag & USER_UNIT_OPT_SPLIT ? 1:0; + if(t->scene->unit.system) { + int i, do_split= t->scene->unit.flag & USER_UNIT_OPT_SPLIT ? 1:0; for(i=0; i<3; i++) - bUnit_AsString(&tvec[i*20], dvec[i]*U.unit_scale_length, 4, U.unit_system, B_UNIT_LENGTH, do_split, 1); + bUnit_AsString(&tvec[i*20], dvec[i]*t->scene->unit.scale_length, 4, t->scene->unit.system, B_UNIT_LENGTH, do_split, 1); } else { sprintf(&tvec[0], "%.4f", dvec[0]); @@ -3053,8 +3053,8 @@ static void headerTranslation(TransInfo *t, float vec[3], char *str) { } } - if(U.unit_system) - bUnit_AsString(distvec, dist*U.unit_scale_length, 4, U.unit_system, B_UNIT_LENGTH, U.unit_flag & USER_UNIT_OPT_SPLIT, 0); + if(t->scene->unit.system) + bUnit_AsString(distvec, dist*t->scene->unit.scale_length, 4, t->scene->unit.system, B_UNIT_LENGTH, t->scene->unit.flag & USER_UNIT_OPT_SPLIT, 0); else if( dist > 1e10 || dist < -1e10 ) /* prevent string buffer overflow */ sprintf(distvec, "%.4e", dist); else diff --git a/source/blender/makesdna/DNA_scene_types.h b/source/blender/makesdna/DNA_scene_types.h index cf32e4e2980..0e0a851e71f 100644 --- a/source/blender/makesdna/DNA_scene_types.h +++ b/source/blender/makesdna/DNA_scene_types.h @@ -622,6 +622,12 @@ typedef struct bStats { int totvert, totface; } bStats; +typedef struct UnitSettings { + /* Display/Editing unit options for each scene */ + float scale_length; /* maybe have other unit conversions? */ + short system; + short flag; /* imperial, metric etc */ +} UnitSettings; typedef struct Scene { ID id; @@ -681,6 +687,10 @@ typedef struct Scene { /* Game Settings */ struct GameFraming framing; // XXX deprecated since 2.5 struct GameData gm; + + /* Units */ + struct UnitSettings unit; + } Scene; @@ -1072,6 +1082,15 @@ typedef enum SculptFlags { #define SK_RETARGET_ROLL_VIEW 1 #define SK_RETARGET_ROLL_JOINT 2 +/* UnitSettings */ + +/* UnitSettings->system */ +#define USER_UNIT_NONE 0 +#define USER_UNIT_METRIC 1 +#define USER_UNIT_IMPERIAL 2 +/* UnitSettings->flag */ +#define USER_UNIT_OPT_SPLIT 1 + #ifdef __cplusplus } diff --git a/source/blender/makesdna/DNA_userdef_types.h b/source/blender/makesdna/DNA_userdef_types.h index ae0ad6cc0be..019dad4eed5 100644 --- a/source/blender/makesdna/DNA_userdef_types.h +++ b/source/blender/makesdna/DNA_userdef_types.h @@ -299,9 +299,7 @@ typedef struct UserDef { int audiochannels; int scrollback; /* console scrollback limit */ - float unit_scale_length, pad1; /* maybe have other unit conversions? */ - char unit_system, unit_flag; /* imperial, metric etc */ - short dpi; /* range 48-128? */ + int dpi; /* range 48-128? */ short encoding; short transopts; short menuthreshold1, menuthreshold2; @@ -418,13 +416,6 @@ extern UserDef U; /* from blenkernel blender.c */ /* toolsettings->autokey_flag */ #define ANIMRECORD_FLAG_WITHNLA (1<<10) -/* unit_type */ -#define USER_UNIT_NONE 0 -#define USER_UNIT_METRIC 1 -#define USER_UNIT_IMPERIAL 2 -/* unit_flag */ -#define USER_UNIT_OPT_SPLIT 1 - /* transopts */ #define USER_TR_TOOLTIPS (1 << 0) #define USER_TR_BUTTONS (1 << 1) diff --git a/source/blender/makesrna/RNA_access.h b/source/blender/makesrna/RNA_access.h index 06752250bd0..8bbd5308e28 100644 --- a/source/blender/makesrna/RNA_access.h +++ b/source/blender/makesrna/RNA_access.h @@ -470,6 +470,7 @@ extern StructRNA RNA_TransformSequence; extern StructRNA RNA_UILayout; extern StructRNA RNA_UIListItem; extern StructRNA RNA_UVProjectModifier; +extern StructRNA RNA_UnitSettings; extern StructRNA RNA_UnknownType; extern StructRNA RNA_UserPreferences; extern StructRNA RNA_UserPreferencesAutosave; diff --git a/source/blender/makesrna/intern/rna_constraint.c b/source/blender/makesrna/intern/rna_constraint.c index 467b8f6e8e1..a8dc0454cef 100644 --- a/source/blender/makesrna/intern/rna_constraint.c +++ b/source/blender/makesrna/intern/rna_constraint.c @@ -416,7 +416,7 @@ static void rna_def_constraint_kinematic(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Pole Sub-Target", ""); RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_dependency_update"); - prop= RNA_def_property(srna, "pole_angle", PROP_FLOAT, PROP_NONE); + prop= RNA_def_property(srna, "pole_angle", PROP_FLOAT, PROP_ANGLE); // XXX - todo, convert to rad RNA_def_property_float_sdna(prop, NULL, "poleangle"); RNA_def_property_range(prop, 0.0, 180.f); RNA_def_property_ui_text(prop, "Pole Angle", "Pole rotation offset."); @@ -676,7 +676,7 @@ static void rna_def_constraint_minmax(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Use Rotation", "Use the target's rotation to determine floor."); RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_update"); - prop= RNA_def_property(srna, "offset", PROP_FLOAT, PROP_NONE); + prop= RNA_def_property(srna, "offset", PROP_FLOAT, PROP_DISTANCE); RNA_def_property_range(prop, 0.0, 100.f); RNA_def_property_ui_text(prop, "Offset", "Offset of floor from object center."); RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_update"); @@ -871,7 +871,7 @@ static void rna_def_constraint_follow_path(BlenderRNA *brna) RNA_def_property_flag(prop, PROP_EDITABLE); RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_dependency_update"); - prop= RNA_def_property(srna, "offset", PROP_INT, PROP_NONE); + prop= RNA_def_property(srna, "offset", PROP_INT, PROP_TIME); RNA_def_property_range(prop, -300000.0, 300000.f); RNA_def_property_ui_text(prop, "Offset", "Offset from the position corresponding to the time frame."); RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_update"); @@ -938,7 +938,7 @@ static void rna_def_constraint_stretch_to(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Keep Axis", "Axis to maintain during stretch."); RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_update"); - prop= RNA_def_property(srna, "original_length", PROP_FLOAT, PROP_NONE); + prop= RNA_def_property(srna, "original_length", PROP_FLOAT, PROP_DISTANCE); RNA_def_property_float_sdna(prop, NULL, "orglength"); RNA_def_property_range(prop, 0.0, 100.f); RNA_def_property_ui_text(prop, "Original Length", "Length at rest position."); @@ -983,37 +983,37 @@ static void rna_def_constraint_rigid_body_joint(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Pivot Type", ""); RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_update"); - prop= RNA_def_property(srna, "pivot_x", PROP_FLOAT, PROP_NONE); + prop= RNA_def_property(srna, "pivot_x", PROP_FLOAT, PROP_DISTANCE); RNA_def_property_float_sdna(prop, NULL, "pivX"); RNA_def_property_range(prop, -1000.0, 1000.f); RNA_def_property_ui_text(prop, "Pivot X", "Offset pivot on X."); RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_update"); - prop= RNA_def_property(srna, "pivot_y", PROP_FLOAT, PROP_NONE); + prop= RNA_def_property(srna, "pivot_y", PROP_FLOAT, PROP_DISTANCE); RNA_def_property_float_sdna(prop, NULL, "pivY"); RNA_def_property_range(prop, -1000.0, 1000.f); RNA_def_property_ui_text(prop, "Pivot Y", "Offset pivot on Y."); RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_update"); - prop= RNA_def_property(srna, "pivot_z", PROP_FLOAT, PROP_NONE); + prop= RNA_def_property(srna, "pivot_z", PROP_FLOAT, PROP_DISTANCE); RNA_def_property_float_sdna(prop, NULL, "pivZ"); RNA_def_property_range(prop, -1000.0, 1000.f); RNA_def_property_ui_text(prop, "Pivot Z", "Offset pivot on Z."); RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_update"); - prop= RNA_def_property(srna, "axis_x", PROP_FLOAT, PROP_NONE); + prop= RNA_def_property(srna, "axis_x", PROP_FLOAT, PROP_ANGLE); // XXX - convert to radians RNA_def_property_float_sdna(prop, NULL, "axX"); RNA_def_property_range(prop, -360.0, 360.f); RNA_def_property_ui_text(prop, "Axis X", "Rotate pivot on X axis in degrees."); RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_update"); - prop= RNA_def_property(srna, "axis_y", PROP_FLOAT, PROP_NONE); + prop= RNA_def_property(srna, "axis_y", PROP_FLOAT, PROP_ANGLE); // XXX - convert to radians RNA_def_property_float_sdna(prop, NULL, "axY"); RNA_def_property_range(prop, -360.0, 360.f); RNA_def_property_ui_text(prop, "Axis Y", "Rotate pivot on Y axis in degrees."); RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_update"); - prop= RNA_def_property(srna, "axis_z", PROP_FLOAT, PROP_NONE); + prop= RNA_def_property(srna, "axis_z", PROP_FLOAT, PROP_ANGLE); // XXX - convert to radians RNA_def_property_float_sdna(prop, NULL, "axZ"); RNA_def_property_range(prop, -360.0, 360.f); RNA_def_property_ui_text(prop, "Axis Z", "Rotate pivot on Z axis in degrees."); @@ -1135,73 +1135,73 @@ static void rna_def_constraint_transform(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Extrapolate Motion", "Extrapolate ranges."); RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_update"); - prop= RNA_def_property(srna, "from_min_x", PROP_FLOAT, PROP_NONE); + prop= RNA_def_property(srna, "from_min_x", PROP_FLOAT, PROP_DISTANCE); RNA_def_property_float_sdna(prop, NULL, "from_min[0]"); RNA_def_property_range(prop, 0.0, 1000.f); RNA_def_property_ui_text(prop, "From Minimum X", "Bottom range of X axis source motion."); RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_update"); - prop= RNA_def_property(srna, "from_min_y", PROP_FLOAT, PROP_NONE); + prop= RNA_def_property(srna, "from_min_y", PROP_FLOAT, PROP_DISTANCE); RNA_def_property_float_sdna(prop, NULL, "from_min[1]"); RNA_def_property_range(prop, 0.0, 1000.f); RNA_def_property_ui_text(prop, "From Minimum Y", "Bottom range of Y axis source motion."); RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_update"); - prop= RNA_def_property(srna, "from_min_z", PROP_FLOAT, PROP_NONE); + prop= RNA_def_property(srna, "from_min_z", PROP_FLOAT, PROP_DISTANCE); RNA_def_property_float_sdna(prop, NULL, "from_min[2]"); RNA_def_property_range(prop, 0.0, 1000.f); RNA_def_property_ui_text(prop, "From Minimum Z", "Bottom range of Z axis source motion."); RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_update"); - prop= RNA_def_property(srna, "from_max_x", PROP_FLOAT, PROP_NONE); + prop= RNA_def_property(srna, "from_max_x", PROP_FLOAT, PROP_DISTANCE); RNA_def_property_float_sdna(prop, NULL, "from_max[0]"); RNA_def_property_range(prop, 0.0, 1000.f); RNA_def_property_ui_text(prop, "From Maximum X", "Top range of X axis source motion."); RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_update"); - prop= RNA_def_property(srna, "from_max_y", PROP_FLOAT, PROP_NONE); + prop= RNA_def_property(srna, "from_max_y", PROP_FLOAT, PROP_DISTANCE); RNA_def_property_float_sdna(prop, NULL, "from_max[1]"); RNA_def_property_range(prop, 0.0, 1000.f); RNA_def_property_ui_text(prop, "From Maximum Y", "Top range of Y axis source motion."); RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_update"); - prop= RNA_def_property(srna, "from_max_z", PROP_FLOAT, PROP_NONE); + prop= RNA_def_property(srna, "from_max_z", PROP_FLOAT, PROP_DISTANCE); RNA_def_property_float_sdna(prop, NULL, "from_max[2]"); RNA_def_property_range(prop, 0.0, 1000.f); RNA_def_property_ui_text(prop, "From Maximum Z", "Top range of Z axis source motion."); RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_update"); - prop= RNA_def_property(srna, "to_min_x", PROP_FLOAT, PROP_NONE); + prop= RNA_def_property(srna, "to_min_x", PROP_FLOAT, PROP_DISTANCE); RNA_def_property_float_sdna(prop, NULL, "to_min[0]"); RNA_def_property_range(prop, 0.0, 1000.f); RNA_def_property_ui_text(prop, "To Minimum X", "Bottom range of X axis destination motion."); RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_update"); - prop= RNA_def_property(srna, "to_min_y", PROP_FLOAT, PROP_NONE); + prop= RNA_def_property(srna, "to_min_y", PROP_FLOAT, PROP_DISTANCE); RNA_def_property_float_sdna(prop, NULL, "to_min[1]"); RNA_def_property_range(prop, 0.0, 1000.f); RNA_def_property_ui_text(prop, "To Minimum Y", "Bottom range of Y axis destination motion."); RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_update"); - prop= RNA_def_property(srna, "to_min_z", PROP_FLOAT, PROP_NONE); + prop= RNA_def_property(srna, "to_min_z", PROP_FLOAT, PROP_DISTANCE); RNA_def_property_float_sdna(prop, NULL, "to_min[2]"); RNA_def_property_range(prop, 0.0, 1000.f); RNA_def_property_ui_text(prop, "To Minimum Z", "Bottom range of Z axis destination motion."); RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_update"); - prop= RNA_def_property(srna, "to_max_x", PROP_FLOAT, PROP_NONE); + prop= RNA_def_property(srna, "to_max_x", PROP_FLOAT, PROP_DISTANCE); RNA_def_property_float_sdna(prop, NULL, "to_max[0]"); RNA_def_property_range(prop, 0.0, 1000.f); RNA_def_property_ui_text(prop, "To Maximum X", "Top range of X axis destination motion."); RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_update"); - prop= RNA_def_property(srna, "to_max_y", PROP_FLOAT, PROP_NONE); + prop= RNA_def_property(srna, "to_max_y", PROP_FLOAT, PROP_DISTANCE); RNA_def_property_float_sdna(prop, NULL, "to_max[1]"); RNA_def_property_range(prop, 0.0, 1000.f); RNA_def_property_ui_text(prop, "To Maximum Y", "Top range of Y axis destination motion."); RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_update"); - prop= RNA_def_property(srna, "to_max_z", PROP_FLOAT, PROP_NONE); + prop= RNA_def_property(srna, "to_max_z", PROP_FLOAT, PROP_DISTANCE); RNA_def_property_float_sdna(prop, NULL, "to_max[2]"); RNA_def_property_range(prop, 0.0, 1000.f); RNA_def_property_ui_text(prop, "To Maximum Z", "Top range of Z axis destination motion."); @@ -1247,37 +1247,37 @@ static void rna_def_constraint_location_limit(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Maximum Z", "Use the maximum Z value."); RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_update"); - prop= RNA_def_property(srna, "minimum_x", PROP_FLOAT, PROP_NONE); + prop= RNA_def_property(srna, "minimum_x", PROP_FLOAT, PROP_DISTANCE); RNA_def_property_float_sdna(prop, NULL, "xmin"); RNA_def_property_range(prop, -1000.0, 1000.f); RNA_def_property_ui_text(prop, "Minimum X", "Lowest X value to allow."); RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_update"); - prop= RNA_def_property(srna, "minimum_y", PROP_FLOAT, PROP_NONE); + prop= RNA_def_property(srna, "minimum_y", PROP_FLOAT, PROP_DISTANCE); RNA_def_property_float_sdna(prop, NULL, "ymin"); RNA_def_property_range(prop, -1000.0, 1000.f); RNA_def_property_ui_text(prop, "Minimum Y", "Lowest Y value to allow."); RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_update"); - prop= RNA_def_property(srna, "minimum_z", PROP_FLOAT, PROP_NONE); + prop= RNA_def_property(srna, "minimum_z", PROP_FLOAT, PROP_DISTANCE); RNA_def_property_float_sdna(prop, NULL, "zmin"); RNA_def_property_range(prop, -1000.0, 1000.f); RNA_def_property_ui_text(prop, "Minimum Z", "Lowest Z value to allow."); RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_update"); - prop= RNA_def_property(srna, "maximum_x", PROP_FLOAT, PROP_NONE); + prop= RNA_def_property(srna, "maximum_x", PROP_FLOAT, PROP_DISTANCE); RNA_def_property_float_sdna(prop, NULL, "xmax"); RNA_def_property_range(prop, -1000.0, 1000.f); RNA_def_property_ui_text(prop, "Maximum X", "Highest X value to allow."); RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_update"); - prop= RNA_def_property(srna, "maximum_y", PROP_FLOAT, PROP_NONE); + prop= RNA_def_property(srna, "maximum_y", PROP_FLOAT, PROP_DISTANCE); RNA_def_property_float_sdna(prop, NULL, "ymax"); RNA_def_property_range(prop, -1000.0, 1000.f); RNA_def_property_ui_text(prop, "Maximum Y", "Highest Y value to allow."); RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_update"); - prop= RNA_def_property(srna, "maximum_z", PROP_FLOAT, PROP_NONE); + prop= RNA_def_property(srna, "maximum_z", PROP_FLOAT, PROP_DISTANCE); RNA_def_property_float_sdna(prop, NULL, "zmax"); RNA_def_property_range(prop, -1000.0, 1000.f); RNA_def_property_ui_text(prop, "Maximum Z", "Highest Z value to allow."); @@ -1313,37 +1313,37 @@ static void rna_def_constraint_rotation_limit(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Limit Z", "Use the minimum Z value."); RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_update"); - prop= RNA_def_property(srna, "minimum_x", PROP_FLOAT, PROP_NONE); + prop= RNA_def_property(srna, "minimum_x", PROP_FLOAT, PROP_ANGLE); RNA_def_property_float_sdna(prop, NULL, "xmin"); RNA_def_property_range(prop, -1000.0, 1000.f); RNA_def_property_ui_text(prop, "Minimum X", "Lowest X value to allow."); RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_update"); - prop= RNA_def_property(srna, "minimum_y", PROP_FLOAT, PROP_NONE); + prop= RNA_def_property(srna, "minimum_y", PROP_FLOAT, PROP_ANGLE); RNA_def_property_float_sdna(prop, NULL, "ymin"); RNA_def_property_range(prop, -1000.0, 1000.f); RNA_def_property_ui_text(prop, "Minimum Y", "Lowest Y value to allow."); RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_update"); - prop= RNA_def_property(srna, "minimum_z", PROP_FLOAT, PROP_NONE); + prop= RNA_def_property(srna, "minimum_z", PROP_FLOAT, PROP_ANGLE); RNA_def_property_float_sdna(prop, NULL, "zmin"); RNA_def_property_range(prop, -1000.0, 1000.f); RNA_def_property_ui_text(prop, "Minimum Z", "Lowest Z value to allow."); RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_update"); - prop= RNA_def_property(srna, "maximum_x", PROP_FLOAT, PROP_NONE); + prop= RNA_def_property(srna, "maximum_x", PROP_FLOAT, PROP_ANGLE); RNA_def_property_float_sdna(prop, NULL, "xmax"); RNA_def_property_range(prop, -1000.0, 1000.f); RNA_def_property_ui_text(prop, "Maximum X", "Highest X value to allow."); RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_update"); - prop= RNA_def_property(srna, "maximum_y", PROP_FLOAT, PROP_NONE); + prop= RNA_def_property(srna, "maximum_y", PROP_FLOAT, PROP_ANGLE); RNA_def_property_float_sdna(prop, NULL, "ymax"); RNA_def_property_range(prop, -1000.0, 1000.f); RNA_def_property_ui_text(prop, "Maximum Y", "Highest Y value to allow."); RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_update"); - prop= RNA_def_property(srna, "maximum_z", PROP_FLOAT, PROP_NONE); + prop= RNA_def_property(srna, "maximum_z", PROP_FLOAT, PROP_ANGLE); RNA_def_property_float_sdna(prop, NULL, "zmax"); RNA_def_property_range(prop, -1000.0, 1000.f); RNA_def_property_ui_text(prop, "Maximum Z", "Highest Z value to allow."); @@ -1462,7 +1462,7 @@ static void rna_def_constraint_distance_limit(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Sub-Target", ""); RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_dependency_update"); - prop= RNA_def_property(srna, "distance", PROP_FLOAT, PROP_NONE); + prop= RNA_def_property(srna, "distance", PROP_FLOAT, PROP_DISTANCE); RNA_def_property_float_sdna(prop, NULL, "dist"); RNA_def_property_range(prop, 0.0, 100.f); RNA_def_property_ui_text(prop, "Distance", "Radius of limiting sphere."); @@ -1502,7 +1502,7 @@ static void rna_def_constraint_shrinkwrap(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Shrinkwrap Type", "Selects type of shrinkwrap algorithm for target position"); RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_update"); - prop= RNA_def_property(srna, "distance", PROP_FLOAT, PROP_NONE); + prop= RNA_def_property(srna, "distance", PROP_FLOAT, PROP_DISTANCE); RNA_def_property_float_sdna(prop, NULL, "dist"); RNA_def_property_range(prop, 0.0, 100.f); RNA_def_property_ui_text(prop, "Distance", "Distance to Target."); diff --git a/source/blender/makesrna/intern/rna_scene.c b/source/blender/makesrna/intern/rna_scene.c index f74687a3096..fe982ced466 100644 --- a/source/blender/makesrna/intern/rna_scene.c +++ b/source/blender/makesrna/intern/rna_scene.c @@ -448,6 +448,40 @@ static void rna_def_tool_settings(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Vertex Group Weight", "Weight to assign in vertex groups."); } + +static void rna_def_unit_settings(BlenderRNA *brna) +{ + StructRNA *srna; + PropertyRNA *prop; + + static EnumPropertyItem unit_systems[] = { + {USER_UNIT_NONE, "NONE", 0, "None", ""}, + {USER_UNIT_METRIC, "METRIC", 0, "Metric", ""}, + {USER_UNIT_IMPERIAL, "IMPERIAL", 0, "Imperial", ""}, + {0, NULL, 0, NULL, NULL}}; + + srna= RNA_def_struct(brna, "UnitSettings", NULL); + RNA_def_struct_ui_text(srna, "Unit Settings", ""); + + /* Units */ + prop= RNA_def_property(srna, "system", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_items(prop, unit_systems); + RNA_def_property_ui_text(prop, "Unit System", "The unit system to use for button display."); + RNA_def_property_update(prop, NC_WINDOW, NULL); + + prop= RNA_def_property(srna, "scale_length", PROP_FLOAT, PROP_UNSIGNED); + RNA_def_property_ui_text(prop, "Unit Scale", "Scale to use when converting between blender units and dimensions."); + RNA_def_property_range(prop, 0.00001, 100000.0); + RNA_def_property_ui_range(prop, 0.001, 100.0, 0.1, 3); + RNA_def_property_update(prop, NC_WINDOW, NULL); + + prop= RNA_def_property(srna, "use_separate", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", USER_UNIT_OPT_SPLIT); + RNA_def_property_ui_text(prop, "Separate Units", "Display units in pairs."); + RNA_def_property_update(prop, NC_WINDOW, NULL); +} + + void rna_def_render_layer_common(StructRNA *srna, int scene) { PropertyRNA *prop; @@ -1749,6 +1783,12 @@ void RNA_def_scene(BlenderRNA *brna) RNA_def_property_pointer_sdna(prop, NULL, "toolsettings"); RNA_def_property_struct_type(prop, "ToolSettings"); RNA_def_property_ui_text(prop, "Tool Settings", ""); + + /* Unit Settings */ + prop= RNA_def_property(srna, "unit_settings", PROP_POINTER, PROP_NEVER_NULL); + RNA_def_property_pointer_sdna(prop, NULL, "unit"); + RNA_def_property_struct_type(prop, "UnitSettings"); + RNA_def_property_ui_text(prop, "Unit Settings", "Unit editing settings"); /* Render Data */ prop= RNA_def_property(srna, "render_data", PROP_POINTER, PROP_NEVER_NULL); @@ -1769,6 +1809,7 @@ void RNA_def_scene(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Game Data", ""); rna_def_tool_settings(brna); + rna_def_unit_settings(brna); rna_def_scene_render_data(brna); rna_def_scene_game_data(brna); rna_def_scene_render_layer(brna); diff --git a/source/blender/makesrna/intern/rna_userdef.c b/source/blender/makesrna/intern/rna_userdef.c index 165bd0ddd5b..19b2b5376f7 100644 --- a/source/blender/makesrna/intern/rna_userdef.c +++ b/source/blender/makesrna/intern/rna_userdef.c @@ -1733,12 +1733,6 @@ static void rna_def_userdef_edit(BlenderRNA *brna) {BEZT_IPO_BEZ, "BEZIER", 0, "Bezier", ""}, {0, NULL, 0, NULL, NULL}}; - static EnumPropertyItem unit_systems[] = { - {USER_UNIT_NONE, "NONE", 0, "None", ""}, - {USER_UNIT_METRIC, "METRIC", 0, "Metric", ""}, - {USER_UNIT_IMPERIAL, "IMPERIAL", 0, "Imperial", ""}, - {0, NULL, 0, NULL, NULL}}; - srna= RNA_def_struct(brna, "UserPreferencesEdit", NULL); RNA_def_struct_sdna(srna, "UserDef"); RNA_def_struct_nested(brna, srna, "UserPreferences"); @@ -1779,23 +1773,6 @@ static void rna_def_userdef_edit(BlenderRNA *brna) RNA_def_property_boolean_sdna(prop, NULL, "uiflag", USER_GLOBALUNDO); RNA_def_property_ui_text(prop, "Global Undo", "Global undo works by keeping a full copy of the file itself in memory, so takes extra memory."); - /* Units */ - prop= RNA_def_property(srna, "unit_system", PROP_ENUM, PROP_NONE); - RNA_def_property_enum_items(prop, unit_systems); - RNA_def_property_ui_text(prop, "Unit System", "The unit system to use for button display."); - RNA_def_property_update(prop, NC_WINDOW, NULL); - - prop= RNA_def_property(srna, "unit_scale_length", PROP_FLOAT, PROP_UNSIGNED); - RNA_def_property_ui_text(prop, "Unit Scale", "Scale to use when converting between blender units and dimensions."); - RNA_def_property_range(prop, 0.00001, 100000.0); - RNA_def_property_ui_range(prop, 0.001, 100.0, 0.1, 3); - RNA_def_property_update(prop, NC_WINDOW, NULL); - - prop= RNA_def_property(srna, "use_unit_split", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "unit_flag", USER_UNIT_OPT_SPLIT); - RNA_def_property_ui_text(prop, "Separate Units", "Display units in pairs."); - RNA_def_property_update(prop, NC_WINDOW, NULL); - /* snap to grid */ prop= RNA_def_property(srna, "snap_translate", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", USER_AUTOGRABGRID); -- cgit v1.2.3 From 79a928682c9ae8241f265f90148da1aeb73c1650 Mon Sep 17 00:00:00 2001 From: Joshua Leung Date: Thu, 13 Aug 2009 11:54:12 +0000 Subject: 2.5 - Fix for segfaults with entering text in normal number buttons (i.e. frame buttons in timeline header). --- source/blender/editors/interface/interface.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'source') diff --git a/source/blender/editors/interface/interface.c b/source/blender/editors/interface/interface.c index a8703868ad1..bbdaad5fd5d 100644 --- a/source/blender/editors/interface/interface.c +++ b/source/blender/editors/interface/interface.c @@ -1505,14 +1505,18 @@ int ui_set_but_string(bContext *C, uiBut *but, const char *str) #ifndef DISABLE_PYTHON { - char str_unit_convert[256]; - int unit_type= RNA_SUBTYPE_UNIT_VALUE(RNA_property_subtype(but->rnaprop)); Scene *scene= CTX_data_scene((bContext *)but->block->evil_C); - - + char str_unit_convert[256]; + int unit_type; + + if (but->rnaprop) + RNA_SUBTYPE_UNIT_VALUE(RNA_property_subtype(but->rnaprop)); + else + unit_type= 0; + if(scene->unit.system != USER_UNIT_NONE && unit_type) { /* ugly, use the draw string to get the value, this could cause problems if it includes some text which resolves to a unit */ - bUnit_ReplaceString(str_unit_convert, str, but->drawstr, ui_get_but_scale_unit(but, 1.0), scene->unit.system, unit_type); + bUnit_ReplaceString(str_unit_convert, (char *)str, but->drawstr, ui_get_but_scale_unit(but, 1.0), scene->unit.system, unit_type); } else { strcpy(str_unit_convert, str); -- cgit v1.2.3 From e8d9e0823ee73e3c3fdd596fd3945abec40d21c1 Mon Sep 17 00:00:00 2001 From: Thomas Dinges Date: Thu, 13 Aug 2009 16:59:52 +0000 Subject: 2.5 Timeline: WIP Commit, still uncommented. * Adeed some RNA properties for Playback. * Start of Python File. --- source/blender/editors/space_time/space_time.c | 12 ++++++- source/blender/makesrna/RNA_access.h | 1 + source/blender/makesrna/intern/rna_space.c | 47 ++++++++++++++++++++++++-- 3 files changed, 57 insertions(+), 3 deletions(-) (limited to 'source') diff --git a/source/blender/editors/space_time/space_time.c b/source/blender/editors/space_time/space_time.c index 8445f1b47e7..77ad832e4e9 100644 --- a/source/blender/editors/space_time/space_time.c +++ b/source/blender/editors/space_time/space_time.c @@ -270,14 +270,23 @@ static void time_main_area_listener(ARegion *ar, wmNotifier *wmn) /* ************************ header time area region *********************** */ +//#define PY_HEADER /* add handlers, stuff you only do once or on area/region changes */ static void time_header_area_init(wmWindowManager *wm, ARegion *ar) { +#ifdef PY_HEADER + ED_region_header_init(ar); +#else UI_view2d_region_reinit(&ar->v2d, V2D_COMMONVIEW_HEADER, ar->winx, ar->winy); +#endif } static void time_header_area_draw(const bContext *C, ARegion *ar) { +#ifdef PY_HEADER + ED_region_header(C, ar); +#else + float col[3]; /* clear */ @@ -293,7 +302,8 @@ static void time_header_area_draw(const bContext *C, ARegion *ar) UI_view2d_view_ortho(C, &ar->v2d); time_header_buttons(C, ar); - +#endif + /* restore view matrix? */ UI_view2d_view_restore(C); } diff --git a/source/blender/makesrna/RNA_access.h b/source/blender/makesrna/RNA_access.h index 8bbd5308e28..7dd7e3714a4 100644 --- a/source/blender/makesrna/RNA_access.h +++ b/source/blender/makesrna/RNA_access.h @@ -393,6 +393,7 @@ extern StructRNA RNA_SpaceFileBrowser; extern StructRNA RNA_SpaceGraphEditor; extern StructRNA RNA_SpaceImageEditor; extern StructRNA RNA_SpaceNLA; +extern StructRNA RNA_SpaceTimeline; extern StructRNA RNA_SpaceOutliner; extern StructRNA RNA_SpaceSequenceEditor; extern StructRNA RNA_SpaceTextEditor; diff --git a/source/blender/makesrna/intern/rna_space.c b/source/blender/makesrna/intern/rna_space.c index 1d9fac9cbb2..620816d3de6 100644 --- a/source/blender/makesrna/intern/rna_space.c +++ b/source/blender/makesrna/intern/rna_space.c @@ -118,10 +118,10 @@ static StructRNA* rna_Space_refine(struct PointerRNA *ptr) case SPACE_NLA: return &RNA_SpaceNLA; /*case SPACE_SCRIPT: - return &RNA_SpaceScriptsWindow; + return &RNA_SpaceScriptsWindow;*/ case SPACE_TIME: return &RNA_SpaceTimeline; - case SPACE_NODE: + /*case SPACE_NODE: return &RNA_SpaceNodeEditor; case SPACE_LOGIC: return &RNA_SpaceLogicEditor;*/ @@ -1104,6 +1104,48 @@ static void rna_def_space_nla(BlenderRNA *brna) // TODO... autosnap, dopesheet? } +static void rna_def_space_time(BlenderRNA *brna) +{ + StructRNA *srna; + PropertyRNA *prop; + + srna= RNA_def_struct(brna, "SpaceTimeline", "Space"); + RNA_def_struct_sdna(srna, "SpaceTime"); + RNA_def_struct_ui_text(srna, "Space Timeline Editor", "Timeline editor space data."); + + /* Define Anim Playback Areas */ + + prop= RNA_def_property(srna, "play_top_left", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", TIME_REGION); + RNA_def_property_ui_text(prop, "Top-Left 3D Window", ""); + + prop= RNA_def_property(srna, "play_all_3d", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", TIME_ALL_3D_WIN); + RNA_def_property_ui_text(prop, "All 3D Windows", ""); + + prop= RNA_def_property(srna, "play_anim", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", TIME_ALL_ANIM_WIN); + RNA_def_property_ui_text(prop, "Animation Windows", ""); + + prop= RNA_def_property(srna, "play_buttons", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", TIME_ALL_BUTS_WIN); + RNA_def_property_ui_text(prop, "Buttons Windows", ""); + + prop= RNA_def_property(srna, "play_image", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", TIME_ALL_IMAGE_WIN); + RNA_def_property_ui_text(prop, "Image Windows", ""); + + prop= RNA_def_property(srna, "play_sequencer", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", TIME_SEQ); + RNA_def_property_ui_text(prop, "Sequencer Windows", ""); + + /* Other options */ + + prop= RNA_def_property(srna, "continue_physics", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", TIME_CONTINUE_PHYSICS); + RNA_def_property_ui_text(prop, "Continue Physics", "During playblack, continue physics simulations regardless of the frame number"); +} + static void rna_def_console_line(BlenderRNA *brna) { StructRNA *srna; @@ -1332,6 +1374,7 @@ void RNA_def_space(BlenderRNA *brna) rna_def_space_dopesheet(brna); rna_def_space_graph(brna); rna_def_space_nla(brna); + rna_def_space_time(brna); rna_def_space_console(brna); rna_def_console_line(brna); } -- cgit v1.2.3 From 52a6a07d67f48c6c3465cbaf156bf8057755e1bc Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 13 Aug 2009 17:05:27 +0000 Subject: added string max length option for unit functions bUnit_AsString and bUnit_ReplaceString --- source/blender/blenkernel/BKE_unit.h | 4 +- source/blender/blenkernel/intern/unit.c | 189 +++++++++++++++++---------- source/blender/editors/interface/interface.c | 29 ++-- source/blender/editors/transform/transform.c | 4 +- 4 files changed, 141 insertions(+), 85 deletions(-) (limited to 'source') diff --git a/source/blender/blenkernel/BKE_unit.h b/source/blender/blenkernel/BKE_unit.h index df299718673..54d5bba057a 100644 --- a/source/blender/blenkernel/BKE_unit.h +++ b/source/blender/blenkernel/BKE_unit.h @@ -31,10 +31,10 @@ extern "C" { /* in all cases the value is assumed to be scaled by the user preference */ /* humanly readable representation of a value in units (used for button drawing) */ -void bUnit_AsString(char *str, double value, int prec, int system, int type, int split, int pad); +void bUnit_AsString(char *str, int len_max, double value, int prec, int system, int type, int split, int pad); /* replace units with values, used before python button evaluation */ -int bUnit_ReplaceString(char *str, char *str_orig, char *str_prev, double scale_pref, int system, int type); +int bUnit_ReplaceString(char *str, int len_max, char *str_prev, double scale_pref, int system, int type); /* the size of the unit used for this value (used for calculating the ckickstep) */ double bUnit_ClosestScalar(double value, int system, int type); diff --git a/source/blender/blenkernel/intern/unit.c b/source/blender/blenkernel/intern/unit.c index dfec54eb5ea..fde0ac5391d 100644 --- a/source/blender/blenkernel/intern/unit.c +++ b/source/blender/blenkernel/intern/unit.c @@ -27,6 +27,8 @@ #include #include +#define TEMP_STR_SIZE 256 + /* define a single unit */ typedef struct bUnitDef { char *name; @@ -89,7 +91,7 @@ static struct bUnitDef buImperialLenDef[] = { {"thou", "Thous", "mil", NULL,0.0000254, 0.0, B_UNIT_DEF_NONE}, {NULL, NULL, NULL, NULL, 0.0, 0.0} }; -static struct bUnitCollection buImperialLenCollecton = {buImperialLenDef, 3, 0, sizeof(buImperialLenDef)/sizeof(bUnitDef)}; +static struct bUnitCollection buImperialLenCollecton = {buImperialLenDef, 4, 0, sizeof(buImperialLenDef)/sizeof(bUnitDef)}; /* Time */ @@ -156,7 +158,7 @@ static void unit_dual_convert(double value, bUnitCollection *usys, *unit_b= unit_best_fit(*value_b, usys, *unit_a, 1); } -static int unit_as_string(char *str, double value, int prec, bUnitCollection *usys, +static int unit_as_string(char *str, int len_max, double value, int prec, bUnitCollection *usys, /* non exposed options */ bUnitDef *unit, char pad) { @@ -178,32 +180,33 @@ static int unit_as_string(char *str, double value, int prec, bUnitCollection *us /* Convert to a string */ { - char conv_str[5] = {'%', '.', '0'+prec, 'f', '\0'}; /* "%.2f" when prec is 2, must be under 10 */ - len= sprintf(str, conv_str, (float)value_conv); + char conv_str[6] = {'%', '.', '0'+prec, 'l', 'f', '\0'}; /* "%.2lf" when prec is 2, must be under 10 */ + len= snprintf(str, len_max, conv_str, (float)value_conv); + + if(len >= len_max) + len= len_max; } - /* Add unit prefix and strip zeros */ - { - /* replace trailing zero's with spaces - * so the number is less complicated but allignment in a button wont - * jump about while dragging */ - int j; - i= len-1; + /* replace trailing zero's with spaces + * so the number is less complicated but allignment in a button wont + * jump about while dragging */ + i= len-1; + + while(i>0 && str[i]=='0') { /* 4.300 -> 4.3 */ + str[i--]= pad; + } + + if(i>0 && str[i]=='.') { /* 10. -> 10 */ + str[i--]= pad; + } - while(i>0 && str[i]=='0') { /* 4.300 -> 4.3 */ - str[i--]= pad; - } - - if(i>0 && str[i]=='.') { /* 10. -> 10 */ - str[i--]= pad; - } - - /* Now add the suffix */ + /* Now add the suffix */ + if(iname_short[j]) { + while(unit->name_short[j] && (i < len_max)) { str[i++]= unit->name_short[j++]; } @@ -212,21 +215,23 @@ static int unit_as_string(char *str, double value, int prec, bUnitCollection *us * the unit name only used padded chars, * In that case add padding for the name. */ - while(i<=len+j) { + while(i<=len+j && (i < len_max)) { str[i++]= pad; } } - - /* terminate no matter whats done with padding above */ - str[i] = '\0'; } + /* terminate no matter whats done with padding above */ + if(i >= len_max) + i= len_max-1; + + str[i] = '\0'; return i; } /* Used for drawing number buttons, try keep fast */ -void bUnit_AsString(char *str, double value, int prec, int system, int type, int split, int pad) +void bUnit_AsString(char *str, int len_max, double value, int prec, int system, int type, int split, int pad) { bUnitCollection *usys = unit_get_system(system, type); @@ -242,56 +247,111 @@ void bUnit_AsString(char *str, double value, int prec, int system, int type, int /* check the 2 is a smaller unit */ if(unit_b > unit_a) { - i= unit_as_string(str, value_a, prec, usys, unit_a, '\0'); - str[i++]= ','; - str[i++]= ' '; + i= unit_as_string(str, len_max, value_a, prec, usys, unit_a, '\0'); - /* use low precision since this is a smaller unit */ - unit_as_string(str+i, value_b, prec?1:0, usys, unit_b, '\0'); + /* is there enough space for at least 1 char of the next unit? */ + if(i+3 < len_max) { + str[i++]= ','; + str[i++]= ' '; + + /* use low precision since this is a smaller unit */ + unit_as_string(str+i, len_max-i, value_b, prec?1:0, usys, unit_b, '\0'); + } return; } } - unit_as_string(str, value, prec, usys, NULL, pad?' ':'\0'); + unit_as_string(str, len_max, value, prec, usys, NULL, pad?' ':'\0'); } -static int unit_scale_str(char *str, char *str_tmp, double scale_pref, bUnitDef *unit, char *replace_str) +static char *unit_find_str(char *str, char *substr) { char *str_found; - int change= 0; - if(replace_str==NULL || replace_str[0] == '\0') - return 0; + if(substr && substr[0] != '\0') { + str_found= strstr(str, substr); + if(str_found) { + /* previous char cannot be a letter */ + if (str_found == str || isalpha(*(str_found-1))==0) { + /* next char cannot be alphanum */ + int len_name = strlen(substr); - if((str_found= strstr(str, replace_str))) { - /* previous char cannot be a letter */ - if (str_found == str || isalpha(*(str_found-1))==0) { - int len_name = strlen(replace_str); - - /* next char cannot be alphanum */ - if (!isalpha(*(str_found+len_name))) { - int len= strlen(str); - int len_num= sprintf(str_tmp, "*%g", unit->scalar/scale_pref); - memmove(str_found+len_num, str_found+len_name, (len+1)-(int)((str_found+len_name)-str)); /* may grow or shrink the string, 1+ to copy the string terminator */ - memcpy(str_found, str_tmp, len_num); /* without the string terminator */ - change= 1; + if (!isalpha(*(str_found+len_name))) { + return str_found; + } } } + } - return change; + return NULL; + +} + +static int unit_scale_str(char *str, int len_max, char *str_tmp, double scale_pref, bUnitDef *unit, char *replace_str) +{ + char *str_found= unit_find_str(str, replace_str); + + if(str_found) { /* XXX - investigate, does not respect len_max properly */ + int len, len_num, len_name, len_move, found_ofs; + + found_ofs = (int)(str_found-str); + + len= strlen(str); + + len_name = strlen(replace_str); + len_move= (len - (found_ofs+len_name)) + 1; /* 1+ to copy the string terminator */ + len_num= snprintf(str_tmp, TEMP_STR_SIZE, "*%lg", unit->scalar/scale_pref); + + if(len_num > len_max) + len_num= len_max; + + if(found_ofs+len_num+len_move > len_max) { + /* can't move the whole string, move just as much as will fit */ + len_move -= (found_ofs+len_num+len_move) - len_max; + } + + if(len_move>0) { + /* resize the last part of the string */ + memmove(str_found+len_num, str_found+len_name, len_move); /* may grow or shrink the string */ + } + + if(found_ofs+len_num > len_max) { + /* not even the number will fit into the string, only copy part of it */ + len_num -= (found_ofs+len_num) - len_max; + } + + if(len_num > 0) { + /* its possible none of the number could be copied in */ + memcpy(str_found, str_tmp, len_num); /* without the string terminator */ + } + + str[len_max-1]= '\0'; /* since the null terminator wont be moved */ + return 1; + } + return 0; } -static int unit_replace(char *str, char *str_tmp, double scale_pref, bUnitDef *unit) +static int unit_replace(char *str, int len_max, char *str_tmp, double scale_pref, bUnitDef *unit) { int change= 0; - change |= unit_scale_str(str, str_tmp, scale_pref, unit, unit->name_short); - change |= unit_scale_str(str, str_tmp, scale_pref, unit, unit->name_plural); - change |= unit_scale_str(str, str_tmp, scale_pref, unit, unit->name_alt); - change |= unit_scale_str(str, str_tmp, scale_pref, unit, unit->name); + change |= unit_scale_str(str, len_max, str_tmp, scale_pref, unit, unit->name_short); + change |= unit_scale_str(str, len_max, str_tmp, scale_pref, unit, unit->name_plural); + change |= unit_scale_str(str, len_max, str_tmp, scale_pref, unit, unit->name_alt); + change |= unit_scale_str(str, len_max, str_tmp, scale_pref, unit, unit->name); return change; } +static int unit_find(char *str, bUnitDef *unit) +{ + if (unit_find_str(str, unit->name_short)) return 1; + if (unit_find_str(str, unit->name_plural)) return 1; + if (unit_find_str(str, unit->name_alt)) return 1; + if (unit_find_str(str, unit->name)) return 1; + + return 0; +} + /* make a copy of the string that replaces the units with numbers * this is used before parsing * This is only used when evaluating user input and can afford to be a bit slower @@ -304,15 +364,13 @@ static int unit_replace(char *str, char *str_tmp, double scale_pref, bUnitDef *u * * return true of a change was made. */ -int bUnit_ReplaceString(char *str, char *str_orig, char *str_prev, double scale_pref, int system, int type) +int bUnit_ReplaceString(char *str, int len_max, char *str_prev, double scale_pref, int system, int type) { bUnitCollection *usys = unit_get_system(system, type); bUnitDef *unit; - char str_tmp[256]; + char str_tmp[TEMP_STR_SIZE]; int change= 0; - - strcpy(str, str_orig); if(usys==NULL || usys->units[0].name==NULL) { return 0; @@ -324,7 +382,7 @@ int bUnit_ReplaceString(char *str, char *str_orig, char *str_prev, double scale_ continue; /* incase there are multiple instances */ - while(unit_replace(str, str_tmp, scale_pref, unit)) + while(unit_replace(str, len_max, str_tmp, scale_pref, unit)) change= 1; } unit= NULL; @@ -343,7 +401,7 @@ int bUnit_ReplaceString(char *str, char *str_orig, char *str_prev, double scale_ continue; /* incase there are multiple instances */ - while(unit_replace(str, str_tmp, scale_pref, unit)) + while(unit_replace(str, len_max, str_tmp, scale_pref, unit)) change= 1; } } @@ -355,25 +413,24 @@ int bUnit_ReplaceString(char *str, char *str_orig, char *str_prev, double scale_ /* no units given so infer a unit from the previous string or default */ if(str_prev) { /* see which units the original value had */ - strcpy(str, str_prev); /* temp overwrite */ for(unit= usys->units; unit->name; unit++) { if(unit->flag & B_UNIT_DEF_SUPPRESS) continue; - if (unit_replace(str, str_tmp, scale_pref, unit)) + if (unit_find(str_prev, unit)) break; } - strcpy(str, str_orig); /* temp overwrite */ } if(unit==NULL) unit= unit_default(usys); /* add the unit prefic and re-run */ - sprintf(str_tmp, "%s %s", str, unit->name); + snprintf(str_tmp, sizeof(str_tmp), "%s %s", str, unit->name); + strncpy(str, str_tmp, len_max); - return bUnit_ReplaceString(str, str_tmp, NULL, scale_pref, system, type); + return bUnit_ReplaceString(str, len_max, NULL, scale_pref, system, type); } // printf("replace %s\n", str); diff --git a/source/blender/editors/interface/interface.c b/source/blender/editors/interface/interface.c index bbdaad5fd5d..ac26fe86364 100644 --- a/source/blender/editors/interface/interface.c +++ b/source/blender/editors/interface/interface.c @@ -1339,7 +1339,7 @@ static double ui_get_but_scale_unit(uiBut *but, double value) } } -static void ui_get_but_string_unit(uiBut *but, char *str, double value, int pad) +static void ui_get_but_string_unit(uiBut *but, char *str, int len_max, double value, int pad) { Scene *scene= CTX_data_scene((bContext *)but->block->evil_C); int do_split= scene->unit.flag & USER_UNIT_OPT_SPLIT; @@ -1352,7 +1352,7 @@ static void ui_get_but_string_unit(uiBut *but, char *str, double value, int pad) if(precission>4) precission= 4; else if(precission==0) precission= 2; - bUnit_AsString(str, ui_get_but_scale_unit(but, value), precission, scene->unit.system, unit_type, do_split, pad); + bUnit_AsString(str, len_max, ui_get_but_scale_unit(but, value), precission, scene->unit.system, unit_type, do_split, pad); } static float ui_get_but_step_unit(uiBut *but, double value, float step_default) @@ -1428,7 +1428,7 @@ void ui_get_but_string(uiBut *but, char *str, int maxlen) if(ui_is_but_float(but)) { if(ui_is_but_unit(but)) { - ui_get_but_string_unit(but, str, value, 0); + ui_get_but_string_unit(but, str, maxlen, value, 0); } else if(but->a2) { /* amount of digits defined */ if(but->a2==1) BLI_snprintf(str, maxlen, "%.1f", value); @@ -1505,21 +1505,20 @@ int ui_set_but_string(bContext *C, uiBut *but, const char *str) #ifndef DISABLE_PYTHON { - Scene *scene= CTX_data_scene((bContext *)but->block->evil_C); char str_unit_convert[256]; int unit_type; - - if (but->rnaprop) - RNA_SUBTYPE_UNIT_VALUE(RNA_property_subtype(but->rnaprop)); + Scene *scene= CTX_data_scene((bContext *)but->block->evil_C); + + if(but->rnaprop) + unit_type= RNA_SUBTYPE_UNIT_VALUE(RNA_property_subtype(but->rnaprop)); else unit_type= 0; - + + BLI_strncpy(str_unit_convert, str, sizeof(str_unit_convert)); + if(scene->unit.system != USER_UNIT_NONE && unit_type) { /* ugly, use the draw string to get the value, this could cause problems if it includes some text which resolves to a unit */ - bUnit_ReplaceString(str_unit_convert, (char *)str, but->drawstr, ui_get_but_scale_unit(but, 1.0), scene->unit.system, unit_type); - } - else { - strcpy(str_unit_convert, str); + bUnit_ReplaceString(str_unit_convert, sizeof(str_unit_convert), but->drawstr, ui_get_but_scale_unit(but, 1.0), scene->unit.system, unit_type); } if(BPY_button_eval(C, str_unit_convert, &value)) { @@ -1875,9 +1874,9 @@ void ui_check_but(uiBut *but) else if(value == -FLT_MAX) sprintf(but->drawstr, "%s-inf", but->str); /* support length type buttons */ else if(ui_is_but_unit(but)) { - char new_str[256]; - ui_get_but_string_unit(but, new_str, value, TRUE); - sprintf(but->drawstr, "%s%s", but->str, new_str); + char new_str[sizeof(but->drawstr)]; + ui_get_but_string_unit(but, new_str, sizeof(new_str), value, TRUE); + snprintf(but->drawstr, sizeof(but->drawstr), "%s%s", but->str, new_str); } else if(but->a2) { /* amount of digits defined */ if(but->a2==1) sprintf(but->drawstr, "%s%.1f", but->str, value); diff --git a/source/blender/editors/transform/transform.c b/source/blender/editors/transform/transform.c index 042e4a1941a..dd7cebdfe3f 100644 --- a/source/blender/editors/transform/transform.c +++ b/source/blender/editors/transform/transform.c @@ -3044,7 +3044,7 @@ static void headerTranslation(TransInfo *t, float vec[3], char *str) { int i, do_split= t->scene->unit.flag & USER_UNIT_OPT_SPLIT ? 1:0; for(i=0; i<3; i++) - bUnit_AsString(&tvec[i*20], dvec[i]*t->scene->unit.scale_length, 4, t->scene->unit.system, B_UNIT_LENGTH, do_split, 1); + bUnit_AsString(&tvec[i*20], 20, dvec[i]*t->scene->unit.scale_length, 4, t->scene->unit.system, B_UNIT_LENGTH, do_split, 1); } else { sprintf(&tvec[0], "%.4f", dvec[0]); @@ -3054,7 +3054,7 @@ static void headerTranslation(TransInfo *t, float vec[3], char *str) { } if(t->scene->unit.system) - bUnit_AsString(distvec, dist*t->scene->unit.scale_length, 4, t->scene->unit.system, B_UNIT_LENGTH, t->scene->unit.flag & USER_UNIT_OPT_SPLIT, 0); + bUnit_AsString(distvec, sizeof(distvec), dist*t->scene->unit.scale_length, 4, t->scene->unit.system, B_UNIT_LENGTH, t->scene->unit.flag & USER_UNIT_OPT_SPLIT, 0); else if( dist > 1e10 || dist < -1e10 ) /* prevent string buffer overflow */ sprintf(distvec, "%.4e", dist); else -- cgit v1.2.3 From 75af1a7f9eba4c761fea08995c5d529ed602a19a Mon Sep 17 00:00:00 2001 From: Andrea Weikert Date: Thu, 13 Aug 2009 18:26:15 +0000 Subject: MSVC compile fix. * replaced snprintf with BLI_snprintf * in unit.c used the #define hack used in several places already to avoid adding additional dependency. --- source/blender/blenkernel/intern/unit.c | 4 ++++ source/blender/editors/interface/interface.c | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) (limited to 'source') diff --git a/source/blender/blenkernel/intern/unit.c b/source/blender/blenkernel/intern/unit.c index fde0ac5391d..ba609fc5611 100644 --- a/source/blender/blenkernel/intern/unit.c +++ b/source/blender/blenkernel/intern/unit.c @@ -27,6 +27,10 @@ #include #include +#if defined(WIN32) && (!(defined snprintf)) +#define snprintf _snprintf +#endif + #define TEMP_STR_SIZE 256 /* define a single unit */ diff --git a/source/blender/editors/interface/interface.c b/source/blender/editors/interface/interface.c index ac26fe86364..4f6c6db3b16 100644 --- a/source/blender/editors/interface/interface.c +++ b/source/blender/editors/interface/interface.c @@ -1876,7 +1876,7 @@ void ui_check_but(uiBut *but) else if(ui_is_but_unit(but)) { char new_str[sizeof(but->drawstr)]; ui_get_but_string_unit(but, new_str, sizeof(new_str), value, TRUE); - snprintf(but->drawstr, sizeof(but->drawstr), "%s%s", but->str, new_str); + BLI_snprintf(but->drawstr, sizeof(but->drawstr), "%s%s", but->str, new_str); } else if(but->a2) { /* amount of digits defined */ if(but->a2==1) sprintf(but->drawstr, "%s%.1f", but->str, value); -- cgit v1.2.3 From 972224b9e1934002f0c2ace326facd706c1e0b32 Mon Sep 17 00:00:00 2001 From: Nicholas Bishop Date: Thu, 13 Aug 2009 20:05:36 +0000 Subject: 2.5/Sculpt: * Moved the brush texture settings to MTex/TextureSlot. The mapping settings now show up in the texture panel, pretty much like they do for textures used with materials. TODO: * Tiled mode should not show Z size setting * Add a locked mode so that texture size can be changed uniformly like in 2.4x --- source/blender/blenkernel/intern/brush.c | 21 ++++++++++++--- source/blender/editors/sculpt_paint/sculpt.c | 40 +++++++++++++--------------- source/blender/makesdna/DNA_brush_types.h | 10 +------ source/blender/makesdna/DNA_scene_types.h | 5 ++-- source/blender/makesdna/DNA_texture_types.h | 11 +++++--- source/blender/makesrna/intern/rna_brush.c | 31 --------------------- source/blender/makesrna/intern/rna_texture.c | 31 +++++++++++++++++++++ 7 files changed, 77 insertions(+), 72 deletions(-) (limited to 'source') diff --git a/source/blender/blenkernel/intern/brush.c b/source/blender/blenkernel/intern/brush.c index 30a35cbe91c..5dbef017f9d 100644 --- a/source/blender/blenkernel/intern/brush.c +++ b/source/blender/blenkernel/intern/brush.c @@ -300,6 +300,13 @@ void brush_curve_preset(Brush *b, BrushCurvePreset preset) curvemapping_changed(b->curve, 0); } +static MTex *brush_active_texture(Brush *brush) +{ + if(brush && brush->texact >= 0) + return brush->mtex[brush->texact]; + return NULL; +} + int brush_texture_set_nr(Brush *brush, int nr) { ID *idtest, *id=NULL; @@ -1077,8 +1084,11 @@ void brush_radial_control_invoke(wmOperator *op, Brush *br, float size_weight) original_value = br->size * size_weight; else if(mode == WM_RADIALCONTROL_STRENGTH) original_value = br->alpha; - else if(mode == WM_RADIALCONTROL_ANGLE) - original_value = br->rot; + else if(mode == WM_RADIALCONTROL_ANGLE) { + MTex *mtex = brush_active_texture(br); + if(mtex) + original_value = mtex->rot; + } RNA_float_set(op->ptr, "initial_value", original_value); op->customdata = brush_gen_radial_control_imbuf(br); @@ -1094,8 +1104,11 @@ int brush_radial_control_exec(wmOperator *op, Brush *br, float size_weight) br->size = new_value * size_weight; else if(mode == WM_RADIALCONTROL_STRENGTH) br->alpha = new_value; - else if(mode == WM_RADIALCONTROL_ANGLE) - br->rot = new_value * conv; + else if(mode == WM_RADIALCONTROL_ANGLE) { + MTex *mtex = brush_active_texture(br); + if(mtex) + mtex->rot = new_value * conv; + } return OPERATOR_FINISHED; } diff --git a/source/blender/editors/sculpt_paint/sculpt.c b/source/blender/editors/sculpt_paint/sculpt.c index 90d2eb31355..8fac4b83b13 100644 --- a/source/blender/editors/sculpt_paint/sculpt.c +++ b/source/blender/editors/sculpt_paint/sculpt.c @@ -655,31 +655,26 @@ static float tex_strength(Sculpt *sd, float *point, const float len) { SculptSession *ss= sd->session; Brush *br = sd->brush; + MTex *tex = NULL; float avg= 1; - if(br->texact==-1 || !br->mtex[br->texact]) + if(br->texact >= 0) + tex = br->mtex[br->texact]; + + if(!tex) { avg= 1; - else if(br->tex_mode==BRUSH_TEX_3D) { - /* Get strength by feeding the vertex location directly - into a texture */ + } + else if(tex->brush_map_mode == MTEX_MAP_MODE_3D) { float jnk; - const float factor= 0.01; - MTex mtex; - memset(&mtex,0,sizeof(MTex)); - mtex.tex= br->mtex[br->texact]->tex; - mtex.projx= 1; - mtex.projy= 2; - mtex.projz= 3; - VecCopyf(mtex.size, br->mtex[br->texact]->size); - VecMulf(mtex.size, factor); - if(!sd->texsep) - mtex.size[1]= mtex.size[2]= mtex.size[0]; - - externtex(&mtex,point,&avg,&jnk,&jnk,&jnk,&jnk); + + /* Get strength by feeding the vertex + location directly into a texture */ + externtex(tex, point, &avg, + &jnk, &jnk, &jnk, &jnk); } else if(ss->texcache) { const float bsize= ss->cache->pixel_radius * 2; - const float rot= sd->brush->rot + ss->cache->rotation; + const float rot= tex->rot + ss->cache->rotation; int px, py; float flip[3], point_2d[2]; @@ -692,9 +687,9 @@ static float tex_strength(Sculpt *sd, float *point, const float len) /* For Tile and Drag modes, get the 2D screen coordinates of the and scale them up or down to the texture size. */ - if(br->tex_mode==BRUSH_TEX_TILE) { - const int sx= (const int)br->mtex[br->texact]->size[0]; - const int sy= (const int)sd->texsep ? br->mtex[br->texact]->size[1] : sx; + if(tex->brush_map_mode == MTEX_MAP_MODE_TILED) { + const int sx= (const int)tex->size[0]; + const int sy= (const int)tex->size[1]; float fx= point_2d[0]; float fy= point_2d[1]; @@ -714,7 +709,8 @@ static float tex_strength(Sculpt *sd, float *point, const float len) if(sy != 1) py %= sy-1; avg= get_texcache_pixel_bilinear(ss, ss->texcache_side*px/sx, ss->texcache_side*py/sy); - } else { + } + else if(tex->brush_map_mode == MTEX_MAP_MODE_FIXED) { float fx= (point_2d[0] - ss->cache->mouse[0]) / bsize; float fy= (point_2d[1] - ss->cache->mouse[1]) / bsize; diff --git a/source/blender/makesdna/DNA_brush_types.h b/source/blender/makesdna/DNA_brush_types.h index adb7fa2303d..e8962d013f4 100644 --- a/source/blender/makesdna/DNA_brush_types.h +++ b/source/blender/makesdna/DNA_brush_types.h @@ -63,13 +63,10 @@ typedef struct Brush { float rgb[3]; /* color */ float alpha; /* opacity */ - float rot; /* rotation in radians */ - short texact; /* active texture */ char sculpt_tool; /* active tool */ - char tex_mode; - char pad[4]; + char pad; } Brush; /* Brush.flag */ @@ -97,11 +94,6 @@ typedef struct Brush { #define BRUSH_BLEND_ERASE_ALPHA 6 #define BRUSH_BLEND_ADD_ALPHA 7 -/* Brush.tex_mode */ -#define BRUSH_TEX_DRAG 0 -#define BRUSH_TEX_TILE 1 -#define BRUSH_TEX_3D 2 - /* Brush.sculpt_tool */ #define SCULPT_TOOL_DRAW 1 #define SCULPT_TOOL_SMOOTH 2 diff --git a/source/blender/makesdna/DNA_scene_types.h b/source/blender/makesdna/DNA_scene_types.h index 0e0a851e71f..7404072db47 100644 --- a/source/blender/makesdna/DNA_scene_types.h +++ b/source/blender/makesdna/DNA_scene_types.h @@ -476,11 +476,10 @@ typedef struct Sculpt /* For rotating around a pivot point */ float pivot[3]; int flags; - /* For the Brush Shape */ - char texsep; + /* Control tablet input */ char tablet_size, tablet_strength; - char pad[5]; + char pad[6]; } Sculpt; typedef struct VPaint { diff --git a/source/blender/makesdna/DNA_texture_types.h b/source/blender/makesdna/DNA_texture_types.h index 7367ee3cf71..0054e885a21 100644 --- a/source/blender/makesdna/DNA_texture_types.h +++ b/source/blender/makesdna/DNA_texture_types.h @@ -53,17 +53,17 @@ typedef struct MTex { char uvname[32]; char projx, projy, projz, mapping; - float ofs[3], size[3]; + float ofs[3], size[3], rot; short texflag, colormodel, pmapto, pmaptoneg; - short normapspace, which_output, pad[2]; + short normapspace, which_output; + char brush_map_mode, pad[7]; float r, g, b, k; float def_var, rt; float colfac, norfac, varfac; float dispfac; float warpfac; - } MTex; #ifndef DNA_USHORT_FIX @@ -396,6 +396,11 @@ typedef struct TexMapping { #define MTEX_BLEND_COLOR 13 #define MTEX_NUM_BLENDTYPES 14 +/* brush_map_mode */ +#define MTEX_MAP_MODE_FIXED 0 +#define MTEX_MAP_MODE_TILED 1 +#define MTEX_MAP_MODE_3D 2 + /* **************** EnvMap ********************* */ /* type */ diff --git a/source/blender/makesrna/intern/rna_brush.c b/source/blender/makesrna/intern/rna_brush.c index 3b8586e020d..b58df16dc62 100644 --- a/source/blender/makesrna/intern/rna_brush.c +++ b/source/blender/makesrna/intern/rna_brush.c @@ -74,20 +74,6 @@ static void rna_Brush_active_texture_set(PointerRNA *ptr, PointerRNA value) } } -static float rna_Brush_rotation_get(PointerRNA *ptr) -{ - Brush *brush= (Brush*)ptr->data; - const float conv = 57.295779506; - return brush->rot * conv; -} - -static void rna_Brush_rotation_set(PointerRNA *ptr, float v) -{ - Brush *brush= (Brush*)ptr->data; - const float conv = 0.017453293; - brush->rot = v * conv; -} - #else void rna_def_brush(BlenderRNA *brna) @@ -106,12 +92,6 @@ void rna_def_brush(BlenderRNA *brna) {BRUSH_BLEND_ADD_ALPHA, "ADD_ALPHA", 0, "Add Alpha", "Add alpha while painting."}, {0, NULL, 0, NULL, NULL}}; - static EnumPropertyItem prop_texture_mode_items[] = { - {BRUSH_TEX_DRAG, "TEX_DRAG", 0, "Drag", ""}, - {BRUSH_TEX_TILE, "TEX_TILE", 0, "Tile", ""}, - {BRUSH_TEX_3D, "TEX_3D", 0, "3D", ""}, - {0, NULL, 0, NULL, NULL}}; - static EnumPropertyItem prop_sculpt_tool_items[] = { {SCULPT_TOOL_DRAW, "DRAW", 0, "Draw", ""}, {SCULPT_TOOL_SMOOTH, "SMOOTH", 0, "Smooth", ""}, @@ -132,11 +112,6 @@ void rna_def_brush(BlenderRNA *brna) RNA_def_property_enum_items(prop, prop_blend_items); RNA_def_property_ui_text(prop, "Blending mode", "Brush blending mode."); - prop= RNA_def_property(srna, "texture_mode", PROP_ENUM, PROP_NONE); - RNA_def_property_enum_sdna(prop, NULL, "tex_mode"); - RNA_def_property_enum_items(prop, prop_texture_mode_items); - RNA_def_property_ui_text(prop, "Texture Mode", ""); - prop= RNA_def_property(srna, "sculpt_tool", PROP_ENUM, PROP_NONE); RNA_def_property_enum_items(prop, prop_sculpt_tool_items); RNA_def_property_ui_text(prop, "Sculpt Tool", ""); @@ -170,12 +145,6 @@ void rna_def_brush(BlenderRNA *brna) RNA_def_property_range(prop, 0.0f, 1.0f); RNA_def_property_ui_text(prop, "Strength", "The amount of pressure on the brush."); - prop= RNA_def_property(srna, "rotation", PROP_FLOAT, PROP_NONE); - RNA_def_property_float_sdna(prop, NULL, "rot"); - RNA_def_property_range(prop, 0, 360); - RNA_def_property_float_funcs(prop, "rna_Brush_rotation_get", "rna_Brush_rotation_set", NULL); - RNA_def_property_ui_text(prop, "Rotation", "Angle of the brush texture."); - /* flag */ prop= RNA_def_property(srna, "airbrush", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", BRUSH_AIRBRUSH); diff --git a/source/blender/makesrna/intern/rna_texture.c b/source/blender/makesrna/intern/rna_texture.c index 5c7fd5ece0e..ccb5e5b2f95 100644 --- a/source/blender/makesrna/intern/rna_texture.c +++ b/source/blender/makesrna/intern/rna_texture.c @@ -147,6 +147,20 @@ static EnumPropertyItem *rna_ImageTexture_filter_itemf(bContext *C, PointerRNA * return item; } +static float rna_TextureSlot_angle_get(PointerRNA *ptr) +{ + MTex *tex= (MTex*)ptr->data; + const float conv = 57.295779506; + return tex->rot * conv; +} + +static void rna_TextureSlot_angle_set(PointerRNA *ptr, float v) +{ + MTex *tex= (MTex*)ptr->data; + const float conv = 0.017453293; + tex->rot = v * conv; +} + #else static void rna_def_color_ramp_element(BlenderRNA *brna) @@ -267,6 +281,12 @@ static void rna_def_mtex(BlenderRNA *brna) {MTEX_BLEND_COLOR, "COLOR", 0, "Color", ""}, {0, NULL, 0, NULL, NULL}}; + static EnumPropertyItem prop_map_mode_items[] = { + {MTEX_MAP_MODE_FIXED, "FIXED", 0, "Fixed", ""}, + {MTEX_MAP_MODE_TILED, "TILED", 0, "Tiled", ""}, + {MTEX_MAP_MODE_3D, "3D", 0, "3D", ""}, + {0, NULL, 0, NULL, NULL}}; + srna= RNA_def_struct(brna, "TextureSlot", NULL); RNA_def_struct_sdna(srna, "MTex"); RNA_def_struct_ui_text(srna, "Texture Slot", "Texture slot defining the mapping and influence of a texture."); @@ -325,6 +345,17 @@ static void rna_def_mtex(BlenderRNA *brna) RNA_def_property_ui_text(prop, "RGB to Intensity", "Converts texture RGB values to intensity (gray) values."); RNA_def_property_update(prop, NC_TEXTURE, NULL); + prop= RNA_def_property(srna, "angle", PROP_FLOAT, PROP_ANGLE); + RNA_def_property_float_sdna(prop, NULL, "rot"); + RNA_def_property_range(prop, 0, 360); + RNA_def_property_float_funcs(prop, "rna_TextureSlot_angle_get", "rna_TextureSlot_angle_set", NULL); + RNA_def_property_ui_text(prop, "Angle", "Defines brush texture rotation."); + RNA_def_property_update(prop, NC_TEXTURE, NULL); + + prop= RNA_def_property(srna, "brush_map_mode", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_items(prop, prop_map_mode_items); + RNA_def_property_ui_text(prop, "Mode", ""); + prop= RNA_def_property(srna, "default_value", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "def_var"); RNA_def_property_ui_range(prop, 0, 1, 10, 3); -- cgit v1.2.3 From 4fb59f65651a58129f459e9c084c6ac759382b89 Mon Sep 17 00:00:00 2001 From: Daniel Genrich Date: Thu, 13 Aug 2009 21:29:05 +0000 Subject: Smoke: no lamp results in no shading (requested by nudelZ) --- source/blender/editors/space_view3d/drawobject.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'source') diff --git a/source/blender/editors/space_view3d/drawobject.c b/source/blender/editors/space_view3d/drawobject.c index 05336d29dc3..3641ff435dd 100644 --- a/source/blender/editors/space_view3d/drawobject.c +++ b/source/blender/editors/space_view3d/drawobject.c @@ -5351,6 +5351,7 @@ void draw_object(Scene *scene, ARegion *ar, View3D *v3d, Base *base, int flag) float bigfactor = 1.0; int big = (smd->domain->flags & MOD_SMOKE_HIGHRES) && (smd->domain->viewsettings & MOD_SMOKE_VIEW_USEBIG); int new = 0; + int have_lamp = 0; // GUI sent redraw event if(smd->domain->flags & MOD_SMOKE_VIEW_REDRAWNICE) @@ -5439,7 +5440,7 @@ void draw_object(Scene *scene, ARegion *ar, View3D *v3d, Base *base, int flag) if(new > 1) { - float light[3] = {0.0,0.0,2.0}; // TODO: take real LAMP coordinates - dg + float light[3] = {0.0,0.0,0.0}; // TODO: take real LAMP coordinates - dg Base *base_tmp = NULL; for(base_tmp = scene->base.first; base_tmp; base_tmp= base_tmp->next) @@ -5451,6 +5452,7 @@ void draw_object(Scene *scene, ARegion *ar, View3D *v3d, Base *base, int flag) if(la->type == LA_LOCAL) { VECCOPY(light, base_tmp->object->obmat[3]); + have_lamp = 1; break; } } @@ -5554,6 +5556,9 @@ void draw_object(Scene *scene, ARegion *ar, View3D *v3d, Base *base, int flag) tvox = smoke_get_bigtvox(smd, index); tray = smoke_get_bigtray(smd, index); } + + if(!have_lamp) + tvox = 1.0; // fill buffer with luminance and alpha // 1 - T_vox -- cgit v1.2.3 From 3671a420c6c9a7c0e2791ce2dfdf85b0fa2a4b3f Mon Sep 17 00:00:00 2001 From: Daniel Genrich Date: Thu, 13 Aug 2009 21:30:48 +0000 Subject: Smoke: bugfix - tray, not tvox --- source/blender/editors/space_view3d/drawobject.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source') diff --git a/source/blender/editors/space_view3d/drawobject.c b/source/blender/editors/space_view3d/drawobject.c index 3641ff435dd..0f2b43a260d 100644 --- a/source/blender/editors/space_view3d/drawobject.c +++ b/source/blender/editors/space_view3d/drawobject.c @@ -5558,7 +5558,7 @@ void draw_object(Scene *scene, ARegion *ar, View3D *v3d, Base *base, int flag) } if(!have_lamp) - tvox = 1.0; + tray = 1.0; // fill buffer with luminance and alpha // 1 - T_vox -- cgit v1.2.3 From f04da8e7f5d1c15a205a9e26afdb711dfc306c2a Mon Sep 17 00:00:00 2001 From: Joilnen Leite Date: Fri, 14 Aug 2009 00:14:20 +0000 Subject: Changed to able compile libsamplerate properly --- source/Makefile | 2 +- source/nan_definitions.mk | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) (limited to 'source') diff --git a/source/Makefile b/source/Makefile index aa226d27668..588ffe0bbb6 100644 --- a/source/Makefile +++ b/source/Makefile @@ -109,7 +109,7 @@ COMLIB += $(OCGDIR)/blender/blenfont/$(DEBUG_DIR)libblenfont.a COMLIB += $(NAN_AUDASPACE)/lib/$(DEBUG_DIR)libaudaspace.a COMLIB += $(NAN_AUDASPACE)/lib/$(DEBUG_DIR)libaud_src.a COMLIB += $(NAN_AUDASPACE)/lib/$(DEBUG_DIR)libaud_fx.a -COMLIB += $(LCGDIR)/samplerate/lib/libsamplerate.a +COMLIB += $(NAN_SAMPLERATE)/lib/libsamplerate.a ifneq ($(NAN_NO_KETSJI),true) COMLIB += $(OCGDIR)/gameengine/bloutines/$(DEBUG_DIR)libbloutines.a diff --git a/source/nan_definitions.mk b/source/nan_definitions.mk index 5c6f444ab0c..259796cf6fb 100644 --- a/source/nan_definitions.mk +++ b/source/nan_definitions.mk @@ -191,6 +191,9 @@ ifndef CONFIG_GUESS # enable l10n export INTERNATIONAL ?= true + export NAN_SAMPLERATE ?= $(LCGDIR)/samplerate + export NAN_SAMPLERATE_LIBS ?= $(NAN_SAMPLERATE)/lib/libsamplerate.a + else ifeq ($(OS),freebsd) @@ -309,6 +312,7 @@ ifndef CONFIG_GUESS export NAN_SDL ?= $(shell sdl-config --prefix) export NAN_SDLLIBS ?= $(shell sdl-config --libs) export NAN_SDLCFLAGS ?= $(shell sdl-config --cflags) + export NAN_SAMPLERATE ?= /usr ifneq ($(NAN_USE_FFMPEG_CONFIG), true) export NAN_FFMPEG ?= /usr -- cgit v1.2.3 From 9a654aa8de66da4bbf726e00720599f5aeb7d339 Mon Sep 17 00:00:00 2001 From: "Guillermo S. Romero" Date: Fri, 14 Aug 2009 00:32:29 +0000 Subject: Clean some whitespace. --- source/nan_definitions.mk | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'source') diff --git a/source/nan_definitions.mk b/source/nan_definitions.mk index 259796cf6fb..b3f36dd3b5c 100644 --- a/source/nan_definitions.mk +++ b/source/nan_definitions.mk @@ -131,7 +131,7 @@ ifndef CONFIG_GUESS ifeq ($(NAN_PYTHON_VERSION),3.1) export PY_FRAMEWORK ?= 0 - export NAN_PYTHON ?= $(LCGDIR)/python + export NAN_PYTHON ?= $(LCGDIR)/python export NAN_PYTHON_LIB ?= $(NAN_PYTHON)/lib/python$(NAN_PYTHON_VERSION)/libpython$(NAN_PYTHON_VERSION).a else export PY_FRAMEWORK ?= 1 @@ -192,7 +192,7 @@ ifndef CONFIG_GUESS export INTERNATIONAL ?= true export NAN_SAMPLERATE ?= $(LCGDIR)/samplerate - export NAN_SAMPLERATE_LIBS ?= $(NAN_SAMPLERATE)/lib/libsamplerate.a + export NAN_SAMPLERATE_LIBS ?= $(NAN_SAMPLERATE)/lib/libsamplerate.a else ifeq ($(OS),freebsd) @@ -327,7 +327,7 @@ endif endif # Uncomment the following line to use Mozilla inplace of netscape - + # Location of MOZILLA/Netscape header files... export NAN_MOZILLA_INC ?= /usr/include/mozilla export NAN_MOZILLA_LIB ?= $(LCGDIR)/mozilla/lib/ -- cgit v1.2.3 From d426676f79690dae2327eb237599b730c55a5947 Mon Sep 17 00:00:00 2001 From: Nicholas Bishop Date: Fri, 14 Aug 2009 01:48:05 +0000 Subject: 2.5/Multires: Bugfixes * Don't allow multires subdivision in editmode, this leads to corruption as noted by nudelZ. Reason is that editmode has its own copy of the MDisps customdata layer, gets written back out on exiting editmode, but the layer that was subdivided was the non-editmode original. * Missed clearing a couple variables, caught with valgrind. --- source/blender/blenkernel/intern/multires.c | 2 ++ source/blender/editors/object/object_modifier.c | 7 ++++++- 2 files changed, 8 insertions(+), 1 deletion(-) (limited to 'source') diff --git a/source/blender/blenkernel/intern/multires.c b/source/blender/blenkernel/intern/multires.c index 22a471f6521..e91f318adad 100644 --- a/source/blender/blenkernel/intern/multires.c +++ b/source/blender/blenkernel/intern/multires.c @@ -220,6 +220,7 @@ static void multires_subdisp(DerivedMesh *orig, Mesh *me, DerivedMesh *final, in int skip = multires_side_tot[totlvl - lvl] - 1; int i, j, k; + memset(&mmd_sub, 0, sizeof(MultiresModifierData)); mmd_sub.lvl = mmd_sub.totlvl = totlvl; mrdm = multires_dm_create_from_derived(&mmd_sub, orig, me, 0, 0); @@ -465,6 +466,7 @@ void multiresModifier_subdivide(MultiresModifierData *mmd, Object *ob, int dista MultiresModifierData mmd_sub; orig = CDDM_from_mesh(me, NULL); + memset(&mmd_sub, 0, sizeof(MultiresModifierData)); mmd_sub.lvl = mmd_sub.totlvl = mmd->lvl; mrdm = multires_dm_create_from_derived(&mmd_sub, orig, me, 0, 0); totsubvert = mrdm->getNumVerts(mrdm); diff --git a/source/blender/editors/object/object_modifier.c b/source/blender/editors/object/object_modifier.c index 6b9f2db0d96..1742e1d1279 100644 --- a/source/blender/editors/object/object_modifier.c +++ b/source/blender/editors/object/object_modifier.c @@ -640,14 +640,19 @@ static int multires_subdivide_exec(bContext *C, wmOperator *op) return OPERATOR_FINISHED; } +static int multires_subdivide_poll(bContext *C) +{ + return NULL != CTX_data_active_object(C) && NULL == CTX_data_edit_object(C); +} + void OBJECT_OT_multires_subdivide(wmOperatorType *ot) { ot->name= "Multires Subdivide"; ot->description= "Add a new level of subdivision."; ot->idname= "OBJECT_OT_multires_subdivide"; - ot->poll= ED_operator_object_active; ot->exec= multires_subdivide_exec; + ot->poll= multires_subdivide_poll; /* flags */ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; -- cgit v1.2.3 From c6e041f125008a59f9c77ffb4d6a017e20804eec Mon Sep 17 00:00:00 2001 From: Nicholas Bishop Date: Fri, 14 Aug 2009 04:45:29 +0000 Subject: 2.5/Paint modes: * Moved brush curve preset operator out of sculpt to paint_utils * Added a button to the curve panel to set the preset --- source/blender/editors/sculpt_paint/paint_intern.h | 1 + source/blender/editors/sculpt_paint/paint_ops.c | 3 ++ source/blender/editors/sculpt_paint/paint_utils.c | 41 ++++++++++++++++++++++ source/blender/editors/sculpt_paint/sculpt.c | 26 -------------- .../blender/editors/space_view3d/view3d_header.c | 6 ++-- 5 files changed, 48 insertions(+), 29 deletions(-) (limited to 'source') diff --git a/source/blender/editors/sculpt_paint/paint_intern.h b/source/blender/editors/sculpt_paint/paint_intern.h index b630975c934..40423e17fe4 100644 --- a/source/blender/editors/sculpt_paint/paint_intern.h +++ b/source/blender/editors/sculpt_paint/paint_intern.h @@ -59,6 +59,7 @@ int imapaint_pick_face(struct ViewContext *vc, struct Mesh *me, int *mval, unsig void imapaint_pick_uv(struct Scene *scene, struct Object *ob, struct Mesh *mesh, unsigned int faceindex, int *xy, float *uv); void paint_sample_color(struct Scene *scene, struct ARegion *ar, int x, int y); +void BRUSH_OT_curve_preset(struct wmOperatorType *ot); #endif /* ED_PAINT_INTERN_H */ diff --git a/source/blender/editors/sculpt_paint/paint_ops.c b/source/blender/editors/sculpt_paint/paint_ops.c index e9263ddabf0..e5500960a6e 100644 --- a/source/blender/editors/sculpt_paint/paint_ops.c +++ b/source/blender/editors/sculpt_paint/paint_ops.c @@ -10,6 +10,9 @@ void ED_operatortypes_paint(void) { + /* brush */ + WM_operatortype_append(BRUSH_OT_curve_preset); + /* image */ WM_operatortype_append(PAINT_OT_texture_paint_toggle); WM_operatortype_append(PAINT_OT_texture_paint_radial_control); diff --git a/source/blender/editors/sculpt_paint/paint_utils.c b/source/blender/editors/sculpt_paint/paint_utils.c index 85ea55331dc..8120e23f5f2 100644 --- a/source/blender/editors/sculpt_paint/paint_utils.c +++ b/source/blender/editors/sculpt_paint/paint_utils.c @@ -5,13 +5,18 @@ #include "DNA_mesh_types.h" #include "DNA_meshdata_types.h" #include "DNA_object_types.h" + #include "DNA_scene_types.h" #include "DNA_screen_types.h" #include "DNA_view3d_types.h" +#include "RNA_access.h" +#include "RNA_define.h" + #include "BLI_arithb.h" #include "BKE_brush.h" +#include "BKE_context.h" #include "BKE_DerivedMesh.h" #include "BKE_global.h" #include "BKE_utildefines.h" @@ -20,6 +25,9 @@ #include "ED_view3d.h" +#include "WM_api.h" +#include "WM_types.h" + #include "paint_intern.h" /* 3D Paint */ @@ -180,3 +188,36 @@ void paint_sample_color(Scene *scene, ARegion *ar, int x, int y) /* frontbuf */ } } +static int brush_curve_preset_exec(bContext *C, wmOperator *op) +{ + Brush *br = *current_brush_source(CTX_data_scene(C)); + brush_curve_preset(br, RNA_enum_get(op->ptr, "shape")); + + return OPERATOR_FINISHED; +} + +static int brush_curve_preset_poll(bContext *C) +{ + Brush **br = current_brush_source(CTX_data_scene(C)); + + return br && *br && (*br)->curve; +} + +void BRUSH_OT_curve_preset(wmOperatorType *ot) +{ + static EnumPropertyItem prop_shape_items[] = { + {BRUSH_PRESET_SHARP, "SHARP", 0, "Sharp", ""}, + {BRUSH_PRESET_SMOOTH, "SMOOTH", 0, "Smooth", ""}, + {BRUSH_PRESET_MAX, "MAX", 0, "Max", ""}, + {0, NULL, 0, NULL, NULL}}; + + ot->name= "Preset"; + ot->idname= "BRUSH_OT_curve_preset"; + + ot->exec= brush_curve_preset_exec; + ot->poll= brush_curve_preset_poll; + + ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; + + RNA_def_enum(ot->srna, "shape", prop_shape_items, BRUSH_PRESET_SHARP, "Mode", ""); +} diff --git a/source/blender/editors/sculpt_paint/sculpt.c b/source/blender/editors/sculpt_paint/sculpt.c index 8fac4b83b13..bf05490b631 100644 --- a/source/blender/editors/sculpt_paint/sculpt.c +++ b/source/blender/editors/sculpt_paint/sculpt.c @@ -1118,31 +1118,6 @@ static void sculpt_undo_push(bContext *C, Sculpt *sd) } } -static int sculpt_brush_curve_preset_exec(bContext *C, wmOperator *op) -{ - brush_curve_preset(CTX_data_scene(C)->toolsettings->sculpt->brush, RNA_enum_get(op->ptr, "mode")); - return OPERATOR_FINISHED; -} - -static void SCULPT_OT_brush_curve_preset(wmOperatorType *ot) -{ - static EnumPropertyItem prop_mode_items[] = { - {BRUSH_PRESET_SHARP, "SHARP", 0, "Sharp Curve", ""}, - {BRUSH_PRESET_SMOOTH, "SMOOTH", 0, "Smooth Curve", ""}, - {BRUSH_PRESET_MAX, "MAX", 0, "Max Curve", ""}, - {0, NULL, 0, NULL, NULL}}; - - ot->name= "Preset"; - ot->idname= "SCULPT_OT_brush_curve_preset"; - - ot->exec= sculpt_brush_curve_preset_exec; - ot->poll= sculpt_mode_poll; - - ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; - - RNA_def_enum(ot->srna, "mode", prop_mode_items, BRUSH_PRESET_SHARP, "Mode", ""); -} - /**** Radial control ****/ static int sculpt_radial_control_invoke(bContext *C, wmOperator *op, wmEvent *event) { @@ -1732,6 +1707,5 @@ void ED_operatortypes_sculpt() WM_operatortype_append(SCULPT_OT_radial_control); WM_operatortype_append(SCULPT_OT_brush_stroke); WM_operatortype_append(SCULPT_OT_sculptmode_toggle); - WM_operatortype_append(SCULPT_OT_brush_curve_preset); WM_operatortype_append(SCULPT_OT_set_persistent_base); } diff --git a/source/blender/editors/space_view3d/view3d_header.c b/source/blender/editors/space_view3d/view3d_header.c index 26ca5a07973..2e0172f4238 100644 --- a/source/blender/editors/space_view3d/view3d_header.c +++ b/source/blender/editors/space_view3d/view3d_header.c @@ -3173,9 +3173,9 @@ static void view3d_sculpt_menu(bContext *C, uiLayout *layout, void *arg_unused) /* Curve */ uiItemS(layout); - uiItemEnumO(layout, NULL, 0, "SCULPT_OT_brush_curve_preset", "mode", BRUSH_PRESET_SHARP); - uiItemEnumO(layout, NULL, 0, "SCULPT_OT_brush_curve_preset", "mode", BRUSH_PRESET_SMOOTH); - uiItemEnumO(layout, NULL, 0, "SCULPT_OT_brush_curve_preset", "mode", BRUSH_PRESET_MAX); + uiItemEnumO(layout, NULL, 0, "BRUSH_OT_curve_preset", "shape", BRUSH_PRESET_SHARP); + uiItemEnumO(layout, NULL, 0, "BRUSH_OT_curve_preset", "shape", BRUSH_PRESET_SMOOTH); + uiItemEnumO(layout, NULL, 0, "BRUSH_OT_curve_preset", "shape", BRUSH_PRESET_MAX); uiItemS(layout); -- cgit v1.2.3 From 4bbccd39bc827e5d794bdbe987b4d48164e8d950 Mon Sep 17 00:00:00 2001 From: Joshua Leung Date: Fri, 14 Aug 2009 11:09:19 +0000 Subject: 2.5 - Assorted Animation UI Tweaks * Fixed padding for Graph Editor visibility toggles * Reverted many of the tweaks to Timeline UI for now (for the reasons outlined in earlier mail) * NLA Editor now (mostly) uses the new channel-drawing API --- .../editors/animation/anim_channels_defines.c | 45 +- source/blender/editors/include/ED_anim_api.h | 6 +- source/blender/editors/space_graph/graph_buttons.c | 2 +- source/blender/editors/space_graph/graph_draw.c | 15 - source/blender/editors/space_nla/nla_draw.c | 549 +++++---------------- source/blender/editors/space_time/time_header.c | 39 +- 6 files changed, 170 insertions(+), 486 deletions(-) (limited to 'source') diff --git a/source/blender/editors/animation/anim_channels_defines.c b/source/blender/editors/animation/anim_channels_defines.c index 879296c58b8..32bda94f796 100644 --- a/source/blender/editors/animation/anim_channels_defines.c +++ b/source/blender/editors/animation/anim_channels_defines.c @@ -1874,10 +1874,10 @@ void ANIM_channel_draw (bAnimContext *ac, bAnimListElem *ale, float yminc, float glColor3fv(fcu->color); /* just a solid color rect - * hardcoded 18 pixels width is slightly wider than icon width, so that + * hardcoded 17 pixels width is slightly wider than icon width, so that * there's a slight border around it */ - glRectf(offset, yminc, offset+18, ymaxc); + glRectf(offset, yminc, offset+17, ymaxc); } /* finally the icon itself */ @@ -1913,34 +1913,35 @@ void ANIM_channel_draw (bAnimContext *ac, bAnimListElem *ale, float yminc, float UI_DrawString(offset, ytext, name); } - /* step 6) draw mute+protection toggles ............................. */ + /* step 6) draw mute+protection toggles + (sliders) ....................... */ /* reset offset - now goes from RHS of panel */ offset = 0; // TODO: we need a mechanism of drawing over (and hiding) stuff from here... + // TODO: when drawing sliders, make those draw instead of these toggles if not enough space - /* set blending again, as text drawing may clear it */ - glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - glEnable(GL_BLEND); - - /* protect... */ - // XXX v2d might not be valid - if (acf->has_setting(ac, ale, ACHANNEL_SETTING_PROTECT)) { - enabled= ANIM_channel_setting_get(ac, ale, ACHANNEL_SETTING_PROTECT); + if (v2d) { + /* set blending again, as text drawing may clear it */ + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + glEnable(GL_BLEND); - offset += ICON_WIDTH; - UI_icon_draw(v2d->cur.xmax-(float)offset, ymid, ((enabled)? ICON_LOCKED : ICON_UNLOCKED)); - } - /* mute... */ - // XXX v2d might not be valid - if (acf->has_setting(ac, ale, ACHANNEL_SETTING_MUTE)) { - enabled= ANIM_channel_setting_get(ac, ale, ACHANNEL_SETTING_MUTE); + /* protect... */ + if (acf->has_setting(ac, ale, ACHANNEL_SETTING_PROTECT)) { + enabled= ANIM_channel_setting_get(ac, ale, ACHANNEL_SETTING_PROTECT); + + offset += ICON_WIDTH; + UI_icon_draw(v2d->cur.xmax-(float)offset, ymid, ((enabled)? ICON_LOCKED : ICON_UNLOCKED)); + } + /* mute... */ + if (acf->has_setting(ac, ale, ACHANNEL_SETTING_MUTE)) { + enabled= ANIM_channel_setting_get(ac, ale, ACHANNEL_SETTING_MUTE); + + offset += ICON_WIDTH; + UI_icon_draw(v2d->cur.xmax-(float)offset, ymid, ((enabled)? ICON_MUTE_IPO_ON : ICON_MUTE_IPO_OFF)); + } - offset += ICON_WIDTH; - UI_icon_draw(v2d->cur.xmax-(float)offset, ymid, ((enabled)? ICON_MUTE_IPO_ON : ICON_MUTE_IPO_OFF)); + glDisable(GL_BLEND); /* End of blending with background */ } - - glDisable(GL_BLEND); /* End of blending with background */ } /* *********************************************** */ diff --git a/source/blender/editors/include/ED_anim_api.h b/source/blender/editors/include/ED_anim_api.h index d3d42deba21..21c5e6bbcf9 100644 --- a/source/blender/editors/include/ED_anim_api.h +++ b/source/blender/editors/include/ED_anim_api.h @@ -402,14 +402,16 @@ void ANIM_uiTemplate_fmodifier_draw(struct uiLayout *layout, struct ID *id, List /* ------------ Animation F-Curves <-> Icons/Names Mapping ------------ */ /* anim_ipo_utils.c */ +/* Get icon for type of setting F-Curve is for */ +// XXX include this in the getname() method via RNA? int geticon_anim_blocktype(short blocktype); +/* Get name for channel-list displays for F-Curve */ void getname_anim_fcurve(char *name, struct ID *id, struct FCurve *fcu); - +/* Automatically determine a color for the nth F-Curve */ void ipo_rainbow(int cur, int tot, float *out); - /* ------------- NLA-Mapping ----------------------- */ /* anim_draw.c */ diff --git a/source/blender/editors/space_graph/graph_buttons.c b/source/blender/editors/space_graph/graph_buttons.c index 82babb70c53..fb995285ab7 100644 --- a/source/blender/editors/space_graph/graph_buttons.c +++ b/source/blender/editors/space_graph/graph_buttons.c @@ -160,7 +160,7 @@ static void graph_panel_properties(const bContext *C, Panel *pa) } getname_anim_fcurve(name, ale->id, fcu); - uiDefBut(block, LABEL, 1, name, 30, 180, 300, 19, NULL, 0.0, 0.0, 0, 0, "Name of Active F-Curve"); + uiDefBut(block, LABEL, 1, name, 40, 180, 300, 19, NULL, 0.0, 0.0, 0, 0, "Name of Active F-Curve"); /* TODO: the following settings could be added here * - F-Curve coloring mode - mode selector + color selector diff --git a/source/blender/editors/space_graph/graph_draw.c b/source/blender/editors/space_graph/graph_draw.c index 07918646926..46d067d9dd2 100644 --- a/source/blender/editors/space_graph/graph_draw.c +++ b/source/blender/editors/space_graph/graph_draw.c @@ -877,10 +877,6 @@ void graph_draw_curves (bAnimContext *ac, SpaceIpo *sipo, ARegion *ar, View2DGri /* ************************************************************************* */ /* Channel List */ -// XXX quite a few of these need to be kept in sync with their counterparts in Action Editor -// as they're the same. We have 2 separate copies of this for now to make it easier to develop -// the diffences between the two editors, but one day these should be merged! - /* left hand part */ void graph_draw_channel_names(bAnimContext *ac, SpaceIpo *sipo, ARegion *ar) { @@ -903,17 +899,6 @@ void graph_draw_channel_names(bAnimContext *ac, SpaceIpo *sipo, ARegion *ar) * start of list offset, and the second is as a correction for the scrollers. */ height= (float)((items*ACHANNEL_STEP) + (ACHANNEL_HEIGHT*2)); - -#if 0 - if (height > (v2d->mask.ymax - v2d->mask.ymin)) { - /* don't use totrect set, as the width stays the same - * (NOTE: this is ok here, the configuration is pretty straightforward) - */ - v2d->tot.ymin= (float)(-height); - } - - /* XXX I would call the below line! (ton) */ -#endif UI_view2d_totRect_set(v2d, ar->winx, height); /* loop through channels, and set up drawing depending on their type */ diff --git a/source/blender/editors/space_nla/nla_draw.c b/source/blender/editors/space_nla/nla_draw.c index a7a854a7277..a4265af71d9 100644 --- a/source/blender/editors/space_nla/nla_draw.c +++ b/source/blender/editors/space_nla/nla_draw.c @@ -633,308 +633,10 @@ void draw_nla_channel_list (bAnimContext *ac, SpaceNla *snla, ARegion *ar) short indent= 0, offset= 0, sel= 0, group= 0; int expand= -1, protect = -1, special= -1, mute = -1; char name[128]; + short doDraw=0; /* determine what needs to be drawn */ switch (ale->type) { - case ANIMTYPE_SCENE: /* scene */ - { - Scene *sce= (Scene *)ale->data; - AnimData *adt= ale->adt; - - group= 4; - indent= 0; - - special= ICON_SCENE_DATA; - - /* only show expand if there are any channels */ - if (EXPANDED_SCEC(sce)) - expand= ICON_TRIA_DOWN; - else - expand= ICON_TRIA_RIGHT; - - /* NLA evaluation on/off button */ - if (adt) { - if (adt->flag & ADT_NLA_EVAL_OFF) - mute = ICON_MUTE_IPO_ON; - else - mute = ICON_MUTE_IPO_OFF; - } - - sel = SEL_SCEC(sce); - strcpy(name, sce->id.name+2); - } - break; - case ANIMTYPE_OBJECT: /* object */ - { - Base *base= (Base *)ale->data; - Object *ob= base->object; - AnimData *adt= ale->adt; - - group= 4; - indent= 0; - - /* icon depends on object-type */ - if (ob->type == OB_ARMATURE) - special= ICON_ARMATURE_DATA; - else - special= ICON_OBJECT_DATA; - - /* only show expand if there are any channels */ - if (EXPANDED_OBJC(ob)) - expand= ICON_TRIA_DOWN; - else - expand= ICON_TRIA_RIGHT; - - /* NLA evaluation on/off button */ - if (adt) { - if (adt->flag & ADT_NLA_EVAL_OFF) - mute = ICON_MUTE_IPO_ON; - else - mute = ICON_MUTE_IPO_OFF; - } - - sel = SEL_OBJC(base); - strcpy(name, ob->id.name+2); - } - break; - case ANIMTYPE_FILLMATD: /* object materials (dopesheet) expand widget */ - { - Object *ob = (Object *)ale->data; - - group = 4; - indent = 1; - special = ICON_MATERIAL_DATA; - - if (FILTER_MAT_OBJC(ob)) - expand = ICON_TRIA_DOWN; - else - expand = ICON_TRIA_RIGHT; - - strcpy(name, "Materials"); - } - break; - case ANIMTYPE_FILLPARTD: /* object particles (dopesheet) expand widget */ - { - Object *ob = (Object *)ale->data; - - group = 4; - indent = 1; - special = ICON_PARTICLE_DATA; - - if (FILTER_PART_OBJC(ob)) - expand = ICON_TRIA_DOWN; - else - expand = ICON_TRIA_RIGHT; - - strcpy(name, "Particles"); - } - break; - - - case ANIMTYPE_DSMAT: /* single material (dopesheet) expand widget */ - { - Material *ma = (Material *)ale->data; - AnimData *adt= ale->adt; - - group = 0; - indent = 0; - special = ICON_MATERIAL_DATA; - offset = 21; - - if (FILTER_MAT_OBJD(ma)) - expand = ICON_TRIA_DOWN; - else - expand = ICON_TRIA_RIGHT; - - /* NLA evaluation on/off button */ - if (adt) { - if (adt->flag & ADT_NLA_EVAL_OFF) - mute = ICON_MUTE_IPO_ON; - else - mute = ICON_MUTE_IPO_OFF; - } - - strcpy(name, ma->id.name+2); - } - break; - case ANIMTYPE_DSLAM: /* lamp (dopesheet) expand widget */ - { - Lamp *la = (Lamp *)ale->data; - AnimData *adt= ale->adt; - - group = 4; - indent = 1; - special = ICON_LAMP_DATA; - - if (FILTER_LAM_OBJD(la)) - expand = ICON_TRIA_DOWN; - else - expand = ICON_TRIA_RIGHT; - - /* NLA evaluation on/off button */ - if (adt) { - if (adt->flag & ADT_NLA_EVAL_OFF) - mute = ICON_MUTE_IPO_ON; - else - mute = ICON_MUTE_IPO_OFF; - } - - strcpy(name, la->id.name+2); - } - break; - case ANIMTYPE_DSCAM: /* camera (dopesheet) expand widget */ - { - Camera *ca = (Camera *)ale->data; - AnimData *adt= ale->adt; - - group = 4; - indent = 1; - special = ICON_CAMERA_DATA; - - if (FILTER_CAM_OBJD(ca)) - expand = ICON_TRIA_DOWN; - else - expand = ICON_TRIA_RIGHT; - - /* NLA evaluation on/off button */ - if (adt) { - if (adt->flag & ADT_NLA_EVAL_OFF) - mute = ICON_MUTE_IPO_ON; - else - mute = ICON_MUTE_IPO_OFF; - } - - strcpy(name, ca->id.name+2); - } - break; - case ANIMTYPE_DSCUR: /* curve (dopesheet) expand widget */ - { - Curve *cu = (Curve *)ale->data; - AnimData *adt= ale->adt; - - group = 4; - indent = 1; - special = ICON_CURVE_DATA; - - if (FILTER_CUR_OBJD(cu)) - expand = ICON_TRIA_DOWN; - else - expand = ICON_TRIA_RIGHT; - - /* NLA evaluation on/off button */ - if (adt) { - if (adt->flag & ADT_NLA_EVAL_OFF) - mute = ICON_MUTE_IPO_ON; - else - mute = ICON_MUTE_IPO_OFF; - } - - strcpy(name, cu->id.name+2); - } - break; - case ANIMTYPE_DSSKEY: /* shapekeys (dopesheet) expand widget */ - { - Key *key= (Key *)ale->data; - AnimData *adt= ale->adt; - - group = 4; - indent = 1; - special = ICON_SHAPEKEY_DATA; - - if (FILTER_SKE_OBJD(key)) - expand = ICON_TRIA_DOWN; - else - expand = ICON_TRIA_RIGHT; - - /* NLA evaluation on/off button */ - if (adt) { - if (adt->flag & ADT_NLA_EVAL_OFF) - mute = ICON_MUTE_IPO_ON; - else - mute = ICON_MUTE_IPO_OFF; - } - - //sel = SEL_OBJC(base); - strcpy(name, "Shape Keys"); - } - break; - case ANIMTYPE_DSWOR: /* world (dopesheet) expand widget */ - { - World *wo= (World *)ale->data; - AnimData *adt= ale->adt; - - group = 4; - indent = 1; - special = ICON_WORLD_DATA; - - if (FILTER_WOR_SCED(wo)) - expand = ICON_TRIA_DOWN; - else - expand = ICON_TRIA_RIGHT; - - /* NLA evaluation on/off button */ - if (adt) { - if (adt->flag & ADT_NLA_EVAL_OFF) - mute = ICON_MUTE_IPO_ON; - else - mute = ICON_MUTE_IPO_OFF; - } - - strcpy(name, wo->id.name+2); - } - break; - case ANIMTYPE_DSPART: /* particle (dopesheet) expand widget */ - { - ParticleSettings *part= (ParticleSettings*)ale->data; - AnimData *adt= ale->adt; - - group = 0; - indent = 0; - special = ICON_PARTICLE_DATA; - offset = 21; - - if (FILTER_PART_OBJD(part)) - expand = ICON_TRIA_DOWN; - else - expand = ICON_TRIA_RIGHT; - - /* NLA evaluation on/off button */ - if (adt) { - if (adt->flag & ADT_NLA_EVAL_OFF) - mute = ICON_MUTE_IPO_ON; - else - mute = ICON_MUTE_IPO_OFF; - } - - strcpy(name, part->id.name+2); - } - break; - case ANIMTYPE_DSMBALL: /* metaball (dopesheet) expand widget */ - { - MetaBall *mb = (MetaBall *)ale->data; - AnimData *adt= ale->adt; - - group = 4; - indent = 1; - special = ICON_META_DATA; - - if (FILTER_MBALL_OBJD(mb)) - expand = ICON_TRIA_DOWN; - else - expand = ICON_TRIA_RIGHT; - - /* NLA evaluation on/off button */ - if (adt) { - if (adt->flag & ADT_NLA_EVAL_OFF) - mute = ICON_MUTE_IPO_ON; - else - mute = ICON_MUTE_IPO_OFF; - } - - strcpy(name, mb->id.name+2); - } - break; - case ANIMTYPE_NLATRACK: /* NLA Track */ { NlaTrack *nlt= (NlaTrack *)ale->data; @@ -978,6 +680,9 @@ void draw_nla_channel_list (bAnimContext *ac, SpaceNla *snla, ARegion *ar) sel = SEL_NLT(nlt); strcpy(name, nlt->name); + + // draw manually still + doDraw= 1; } break; case ANIMTYPE_NLAACTION: /* NLA Action-Line */ @@ -1004,162 +709,148 @@ void draw_nla_channel_list (bAnimContext *ac, SpaceNla *snla, ARegion *ar) sprintf(name, "ActAction: <%s>", act->id.name+2); else sprintf(name, ""); + + // draw manually still + doDraw= 1; } break; + + default: /* handled by standard channel-drawing API */ + ANIM_channel_draw(ac, ale, yminc, ymaxc); + break; } - /* now, start drawing based on this information */ - glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - glEnable(GL_BLEND); - - /* draw backing strip behind channel name */ - if (group == 4) { - /* only used in dopesheet... */ - if (ELEM(ale->type, ANIMTYPE_SCENE, ANIMTYPE_OBJECT)) { - /* object channel - darker */ - UI_ThemeColor(TH_DOPESHEET_CHANNELOB); - uiSetRoundBox((expand == ICON_TRIA_DOWN)? (8):(1|8)); - gl_round_box(GL_POLYGON, x+offset, yminc, (float)NLACHANNEL_NAMEWIDTH, ymaxc, 10); + /* if special types, draw manually for now... */ + if (doDraw) { + /* now, start drawing based on this information */ + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + glEnable(GL_BLEND); + + /* draw backing strip behind channel name */ + if (group == 5) { + /* Action Line */ + AnimData *adt= ale->adt; + + // TODO: if tweaking some action, use the same color as for the tweaked track (quick hack done for now) + if (adt && (adt->flag & ADT_NLA_EDIT_ON)) { + // greenish color (same as tweaking strip) - hardcoded for now + glColor3f(0.3f, 0.95f, 0.1f); + } + else { + if (ale->data) + glColor3f(0.8f, 0.2f, 0.0f); // reddish color - hardcoded for now + else + glColor3f(0.6f, 0.5f, 0.5f); // greyish-red color - hardcoded for now + } + + offset += 7 * indent; + + /* only on top two corners, to show that this channel sits on top of the preceeding ones */ + uiSetRoundBox((1|2)); + + /* draw slightly shifted up vertically to look like it has more separtion from other channels, + * but we then need to slightly shorten it so that it doesn't look like it overlaps + */ + gl_round_box(GL_POLYGON, x+offset, yminc+NLACHANNEL_SKIP, (float)v2d->cur.xmax, ymaxc+NLACHANNEL_SKIP-1, 8); + + /* clear group value, otherwise we cause errors... */ + group = 0; } else { - /* sub-object folders - lighter */ - UI_ThemeColor(TH_DOPESHEET_CHANNELSUBOB); + /* for normal channels + * - use 3 shades of color group/standard color for 3 indention level + */ + UI_ThemeColorShade(TH_HEADER, ((indent==0)?20: (indent==1)?-20: -40)); + indent += group; offset += 7 * indent; glBegin(GL_QUADS); glVertex2f(x+offset, yminc); glVertex2f(x+offset, ymaxc); - glVertex2f((float)ACHANNEL_NAMEWIDTH, ymaxc); - glVertex2f((float)ACHANNEL_NAMEWIDTH, yminc); + glVertex2f((float)v2d->cur.xmax, ymaxc); + glVertex2f((float)v2d->cur.xmax, yminc); glEnd(); - - /* clear group value, otherwise we cause errors... */ - group = 0; } - } - else if (group == 5) { - /* Action Line */ - AnimData *adt= ale->adt; - // TODO: if tweaking some action, use the same color as for the tweaked track (quick hack done for now) - if (adt && (adt->flag & ADT_NLA_EDIT_ON)) { - // greenish color (same as tweaking strip) - hardcoded for now - glColor3f(0.3f, 0.95f, 0.1f); - } - else { - if (ale->data) - glColor3f(0.8f, 0.2f, 0.0f); // reddish color - hardcoded for now - else - glColor3f(0.6f, 0.5f, 0.5f); // greyish-red color - hardcoded for now + /* draw expand/collapse triangle */ + if (expand > 0) { + UI_icon_draw(x+offset, ydatac, expand); + offset += 17; } - offset += 7 * indent; + /* draw special icon indicating certain data-types */ + if (special > -1) { + /* for normal channels */ + UI_icon_draw(x+offset, ydatac, special); + offset += 17; + } + glDisable(GL_BLEND); - /* only on top two corners, to show that this channel sits on top of the preceeding ones */ - uiSetRoundBox((1|2)); + /* draw name */ + if (sel) + UI_ThemeColor(TH_TEXT_HI); + else + UI_ThemeColor(TH_TEXT); + offset += 3; + UI_DrawString(x+offset, y-4, name); - /* draw slightly shifted up vertically to look like it has more separtion from other channels, - * but we then need to slightly shorten it so that it doesn't look like it overlaps - */ - gl_round_box(GL_POLYGON, x+offset, yminc+NLACHANNEL_SKIP, (float)NLACHANNEL_NAMEWIDTH, ymaxc+NLACHANNEL_SKIP-1, 8); + /* reset offset - for RHS of panel */ + offset = 0; - /* clear group value, otherwise we cause errors... */ - group = 0; - } - else { - /* for normal channels - * - use 3 shades of color group/standard color for 3 indention level - */ - UI_ThemeColorShade(TH_HEADER, ((indent==0)?20: (indent==1)?-20: -40)); + /* set blending again, as text drawing may clear it */ + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + glEnable(GL_BLEND); - indent += group; - offset += 7 * indent; - glBegin(GL_QUADS); - glVertex2f(x+offset, yminc); - glVertex2f(x+offset, ymaxc); - glVertex2f((float)NLACHANNEL_NAMEWIDTH, ymaxc); - glVertex2f((float)NLACHANNEL_NAMEWIDTH, yminc); - glEnd(); - } - - /* draw expand/collapse triangle */ - if (expand > 0) { - UI_icon_draw(x+offset, ydatac, expand); - offset += 17; - } - - /* draw special icon indicating certain data-types */ - if (special > -1) { - /* for normal channels */ - UI_icon_draw(x+offset, ydatac, special); - offset += 17; - } - glDisable(GL_BLEND); - - /* draw name */ - if (sel) - UI_ThemeColor(TH_TEXT_HI); - else - UI_ThemeColor(TH_TEXT); - offset += 3; - UI_DrawString(x+offset, y-4, name); - - /* reset offset - for RHS of panel */ - offset = 0; - - /* set blending again, as text drawing may clear it */ - glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - glEnable(GL_BLEND); - - /* draw protect 'lock' */ - if (protect > -1) { - offset = 16; - UI_icon_draw((float)NLACHANNEL_NAMEWIDTH-offset, ydatac, protect); - } - - /* draw mute 'eye' */ - if (mute > -1) { - offset += 16; - UI_icon_draw((float)(NLACHANNEL_NAMEWIDTH-offset), ydatac, mute); - } - - /* draw NLA-action line 'status-icons' - only when there's an action */ - if ((ale->type == ANIMTYPE_NLAACTION) && (ale->data)) { - AnimData *adt= ale->adt; + /* draw protect 'lock' */ + if (protect > -1) { + offset = 16; + UI_icon_draw((float)(v2d->cur.xmax-offset), ydatac, protect); + } - offset += 16; + /* draw mute 'eye' */ + if (mute > -1) { + offset += 16; + UI_icon_draw((float)(v2d->cur.xmax-offset), ydatac, mute); + } - /* now draw some indicator icons */ - if ((adt) && (adt->flag & ADT_NLA_EDIT_ON)) { - /* toggle for tweaking with mapping/no-mapping (i.e. 'in place editing' toggle) */ - // for now, use pin icon to symbolise this - if (adt->flag & ADT_NLA_EDIT_NOMAP) - UI_icon_draw((float)(NLACHANNEL_NAMEWIDTH-offset), ydatac, ICON_PINNED); - else - UI_icon_draw((float)(NLACHANNEL_NAMEWIDTH-offset), ydatac, ICON_UNPINNED); + /* draw NLA-action line 'status-icons' - only when there's an action */ + if ((ale->type == ANIMTYPE_NLAACTION) && (ale->data)) { + AnimData *adt= ale->adt; - fdrawline((float)(NLACHANNEL_NAMEWIDTH-offset), yminc, - (float)(NLACHANNEL_NAMEWIDTH-offset), ymaxc); - offset += 16;; + offset += 16; - /* 'tweaking action' indicator - not a button */ - UI_icon_draw((float)NLACHANNEL_NAMEWIDTH-offset, ydatac, ICON_EDIT); - } - else { - /* XXX firstly draw a little rect to help identify that it's different from the toggles */ - glBegin(GL_LINE_LOOP); - glVertex2f((float)NLACHANNEL_NAMEWIDTH-offset-1, y-7); - glVertex2f((float)NLACHANNEL_NAMEWIDTH-offset-1, y+9); - glVertex2f((float)NLACHANNEL_NAMEWIDTH-1, y+9); - glVertex2f((float)NLACHANNEL_NAMEWIDTH-1, y-7); - glEnd(); // GL_LINES - - /* 'push down' icon for normal active-actions */ - UI_icon_draw((float)NLACHANNEL_NAMEWIDTH-offset, ydatac, ICON_FREEZE); + /* now draw some indicator icons */ + if ((adt) && (adt->flag & ADT_NLA_EDIT_ON)) { + /* toggle for tweaking with mapping/no-mapping (i.e. 'in place editing' toggle) */ + // for now, use pin icon to symbolise this + if (adt->flag & ADT_NLA_EDIT_NOMAP) + UI_icon_draw((float)(v2d->cur.xmax-offset), ydatac, ICON_PINNED); + else + UI_icon_draw((float)(v2d->cur.xmax-offset), ydatac, ICON_UNPINNED); + + fdrawline((float)(v2d->cur.xmax-offset), yminc, + (float)(v2d->cur.xmax-offset), ymaxc); + offset += 16;; + + /* 'tweaking action' indicator - not a button */ + UI_icon_draw((float)(v2d->cur.xmax-offset), ydatac, ICON_EDIT); + } + else { + /* XXX firstly draw a little rect to help identify that it's different from the toggles */ + glBegin(GL_LINE_LOOP); + glVertex2f((float)v2d->cur.xmax-offset-1, y-7); + glVertex2f((float)v2d->cur.xmax-offset-1, y+9); + glVertex2f((float)v2d->cur.xmax-1, y+9); + glVertex2f((float)v2d->cur.xmax-1, y-7); + glEnd(); // GL_LINES + + /* 'push down' icon for normal active-actions */ + UI_icon_draw((float)NLACHANNEL_NAMEWIDTH-offset, ydatac, ICON_FREEZE); + } } + + glDisable(GL_BLEND); } - - glDisable(GL_BLEND); } /* adjust y-position for next one */ diff --git a/source/blender/editors/space_time/time_header.c b/source/blender/editors/space_time/time_header.c index dd1130849b5..ea391e0cca7 100644 --- a/source/blender/editors/space_time/time_header.c +++ b/source/blender/editors/space_time/time_header.c @@ -437,7 +437,7 @@ void time_header_buttons(const bContext *C, ARegion *ar) &scene->r.psfra,0, 1, 0, 0, "Show settings for frame range of animation preview"); - xco += XIC*2.5; + xco += XIC*2; uiBlockBeginAlign(block); @@ -516,35 +516,37 @@ void time_header_buttons(const bContext *C, ARegion *ar) xco+= XIC; uiBlockEndAlign(block); - xco+= 0.5*XIC; + xco+= (short)(0.5*XIC); uiBlockBeginAlign(block); uiDefIconButBitS(block, TOG, AUTOKEY_ON, B_REDRAWALL, ICON_REC, xco, yco, XIC, YIC, &(scene->toolsettings->autokey_mode), 0, 0, 0, 0, "Automatic keyframe insertion for Objects and Bones"); xco+= 1*XIC; if (IS_AUTOKEY_ON(scene)) { -// uiDefButS(block, MENU, B_REDRAWALL, -// "Auto-Keying Mode %t|Add/Replace Keys%x3|Replace Keys %x5", -// xco, yco, (int)5.5*XIC, YIC, &(scene->toolsettings->autokey_mode), 0, 1, 0, 0, -// "Mode of automatic keyframe insertion for Objects and Bones"); + uiDefButS(block, MENU, B_REDRAWALL, + "Auto-Keying Mode %t|Add/Replace%x3|Replace%x5", + xco, yco, (int)(4.25*XIC), YIC, &(scene->toolsettings->autokey_mode), 0, 1, 0, 0, + "Mode of automatic keyframe insertion for Objects and Bones"); + xco+= (short)(4.25*XIC); if (animtimer) { uiDefButBitS(block, TOG, ANIMRECORD_FLAG_WITHNLA, B_REDRAWALL, "Layered", - xco,yco, 70, YIC, + xco,yco, (int)(3.5*XIC), YIC, &(scene->toolsettings->autokey_flag),0, 1, 0, 0, "Add a new NLA Track + Strip for every loop/pass made over the animation to allow non-destructive tweaking."); uiBlockEndAlign(block); + + xco+= (short)(3.5*XIC); } - + + xco += XIC; + + uiBlockEndAlign(block); + } + else { + xco+= (short)(5.25*XIC); uiBlockEndAlign(block); } - else - - - - uiBlockEndAlign(block); - - xco+= (4.5*XIC); menustr= ANIM_build_keyingsets_menu(&scene->keyingsets, 0); uiDefButI(block, MENU, B_DIFF, @@ -554,11 +556,14 @@ void time_header_buttons(const bContext *C, ARegion *ar) MEM_freeN(menustr); xco+= (5.5*XIC); + /* NOTE: order of these buttons needs to be kept in sync with other occurances + * (see Outliner header for instance, also +/- stuff for filebrowser) + */ uiBlockBeginAlign(block); - uiDefIconButO(block, BUT, "ANIM_OT_insert_keyframe", WM_OP_INVOKE_REGION_WIN, ICON_KEY_HLT, xco,yco,XIC,YIC, "Insert Keyframes for the Active Keying Set (I)"); - xco += XIC; uiDefIconButO(block, BUT, "ANIM_OT_delete_keyframe", WM_OP_INVOKE_REGION_WIN, ICON_KEY_DEHLT, xco,yco,XIC,YIC, "Delete Keyframes for the Active Keying Set (Alt-I)"); xco += XIC; + uiDefIconButO(block, BUT, "ANIM_OT_insert_keyframe", WM_OP_INVOKE_REGION_WIN, ICON_KEY_HLT, xco,yco,XIC,YIC, "Insert Keyframes for the Active Keying Set (I)"); + xco += XIC; uiBlockEndAlign(block); xco+= XIC; -- cgit v1.2.3