From ad545fd9f6d0b6d8fd8aa3ba1e0a6f29a5a284cc Mon Sep 17 00:00:00 2001 From: Matt Ebb Date: Tue, 2 Jun 2009 08:08:41 +0000 Subject: [PATCH 01/35] Wrapped buttons window in RNA --- .../editors/space_buttons/buttons_intern.h | 13 ------ source/blender/makesdna/DNA_space_types.h | 16 +++++++ source/blender/makesrna/RNA_access.h | 1 + source/blender/makesrna/intern/rna_space.c | 44 ++++++++++++++++++- 4 files changed, 59 insertions(+), 15 deletions(-) diff --git a/source/blender/editors/space_buttons/buttons_intern.h b/source/blender/editors/space_buttons/buttons_intern.h index 6050b4f0562..9d49a1eeaab 100644 --- a/source/blender/editors/space_buttons/buttons_intern.h +++ b/source/blender/editors/space_buttons/buttons_intern.h @@ -32,19 +32,6 @@ struct ARegion; struct ARegionType; struct bContext; -/* warning: the values of these defines are used in sbuts->tabs[8] */ -/* buts->mainb new */ -#define BCONTEXT_SCENE 0 -#define BCONTEXT_WORLD 1 -#define BCONTEXT_OBJECT 2 -#define BCONTEXT_DATA 3 -#define BCONTEXT_MATERIAL 4 -#define BCONTEXT_TEXTURE 5 -#define BCONTEXT_PARTICLE 6 -#define BCONTEXT_PHYSICS 7 -#define BCONTEXT_GAME 8 -#define BCONTEXT_BONE 9 -#define BCONTEXT_MODIFIER 10 /* buts->scaflag */ #define BUTS_SENS_SEL 1 diff --git a/source/blender/makesdna/DNA_space_types.h b/source/blender/makesdna/DNA_space_types.h index 8cdb51bcab0..ad07237fdc5 100644 --- a/source/blender/makesdna/DNA_space_types.h +++ b/source/blender/makesdna/DNA_space_types.h @@ -463,6 +463,22 @@ typedef struct SpaceImaSel { #define TAB_SCENE_SOUND 3 #define TAB_SCENE_SEQUENCER 4 + +/* warning: the values of these defines are used in sbuts->tabs[8] */ +/* buts->mainb new */ +#define BCONTEXT_SCENE 0 +#define BCONTEXT_WORLD 1 +#define BCONTEXT_OBJECT 2 +#define BCONTEXT_DATA 3 +#define BCONTEXT_MATERIAL 4 +#define BCONTEXT_TEXTURE 5 +#define BCONTEXT_PARTICLE 6 +#define BCONTEXT_PHYSICS 7 +#define BCONTEXT_GAME 8 +#define BCONTEXT_BONE 9 +#define BCONTEXT_MODIFIER 10 + + /* sbuts->flag */ #define SB_PRV_OSA 1 diff --git a/source/blender/makesrna/RNA_access.h b/source/blender/makesrna/RNA_access.h index 523faee79bf..ccc94fd35d5 100644 --- a/source/blender/makesrna/RNA_access.h +++ b/source/blender/makesrna/RNA_access.h @@ -245,6 +245,7 @@ extern StructRNA RNA_Sound; extern StructRNA RNA_SoundSequence; extern StructRNA RNA_Space; extern StructRNA RNA_Space3DView; +extern StructRNA RNA_SpaceButtonsWindow; extern StructRNA RNA_SpaceImageEditor; extern StructRNA RNA_SpaceUVEditor; extern StructRNA RNA_SpaceTextEditor; diff --git a/source/blender/makesrna/intern/rna_space.c b/source/blender/makesrna/intern/rna_space.c index 56967a84903..55c56beea7c 100644 --- a/source/blender/makesrna/intern/rna_space.c +++ b/source/blender/makesrna/intern/rna_space.c @@ -74,9 +74,9 @@ static StructRNA* rna_Space_refine(struct PointerRNA *ptr) */ case SPACE_OUTLINER: return &RNA_SpaceOutliner; - /* case SPACE_BUTS: + case SPACE_BUTS: return &RNA_SpaceButtonsWindow; - case SPACE_FILE: + /* case SPACE_FILE: return &RNA_SpaceFileBrowser;*/ case SPACE_IMAGE: return &RNA_SpaceImageEditor; @@ -471,6 +471,45 @@ static void rna_def_space_3dview(BlenderRNA *brna) } +static void rna_def_space_buttons(BlenderRNA *brna) +{ + StructRNA *srna; + PropertyRNA *prop; + + static EnumPropertyItem buttons_context_items[] = { + {BCONTEXT_SCENE, "SCENE", "Scene", ""}, + {BCONTEXT_WORLD, "WORLD", "World", ""}, + {BCONTEXT_OBJECT, "OBJECT", "Object", ""}, + {BCONTEXT_DATA, "DATA", "Data", ""}, + {BCONTEXT_MATERIAL, "MATERIAL", "Material", ""}, + {BCONTEXT_TEXTURE, "TEXTURE", "Texture", ""}, + {BCONTEXT_PARTICLE, "PARTICLE", "Particle", ""}, + {BCONTEXT_PHYSICS, "PHYSICS", "Physics", ""}, + {BCONTEXT_GAME, "GAME", "Game", ""}, + {BCONTEXT_BONE, "BONE", "Bone", ""}, + {BCONTEXT_MODIFIER, "MODIFIER", "Modifier", ""}, + {0, NULL, NULL, NULL}}; + + static EnumPropertyItem panel_alignment_items[] = { + {1, "HORIZONTAL", "Horizontal", ""}, + {2, "VERTICAL", "Vertical", ""}, + {0, NULL, NULL, NULL}}; + + srna= RNA_def_struct(brna, "SpaceButtonsWindow", "Space"); + RNA_def_struct_sdna(srna, "SpaceButs"); + RNA_def_struct_ui_text(srna, "Buttons Space", "Buttons Window space data"); + + prop= RNA_def_property(srna, "buttons_context", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_sdna(prop, NULL, "mainb"); + RNA_def_property_enum_items(prop, buttons_context_items); + RNA_def_property_ui_text(prop, "Buttons Context", "The type of active data to display and edit in the buttons window"); + + prop= RNA_def_property(srna, "panel_alignment", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_sdna(prop, NULL, "align"); + RNA_def_property_enum_items(prop, panel_alignment_items); + RNA_def_property_ui_text(prop, "Panel Alignment", "Arrangement of the panels within the buttons window"); +} + static void rna_def_space_image(BlenderRNA *brna) { StructRNA *srna; @@ -624,6 +663,7 @@ void RNA_def_space(BlenderRNA *brna) rna_def_space_outliner(brna); rna_def_background_image(brna); rna_def_space_3dview(brna); + rna_def_space_buttons(brna); } #endif From bfbb7d5d73b228c6eff7b94190ee30a0da6e526f Mon Sep 17 00:00:00 2001 From: Thomas Dinges Date: Tue, 2 Jun 2009 09:40:24 +0000 Subject: [PATCH 02/35] 2.5 Constraints: Wrapped IK and Rigid Body Joint constraint to Python. Note: Couldn't test Rigid constraint due to crash. --- release/ui/buttons_object_constraint.py | 53 ++++++++-- .../editors/interface/interface_templates.c | 99 +------------------ 2 files changed, 51 insertions(+), 101 deletions(-) diff --git a/release/ui/buttons_object_constraint.py b/release/ui/buttons_object_constraint.py index a4ac6dfff86..593010128a2 100644 --- a/release/ui/buttons_object_constraint.py +++ b/release/ui/buttons_object_constraint.py @@ -15,8 +15,8 @@ class ConstraintButtonsPanel(bpy.types.Panel): self.child_of(box, con) elif con.type == "TRACK_TO": self.track_to(box, con) - #elif con.type == "IK": - # self.ik(box, con) + elif con.type == "IK": + self.ik(box, con) elif con.type == "FOLLOW_PATH": self.follow_path(box, con) elif con.type == "LIMIT_ROTATION": @@ -43,7 +43,7 @@ class ConstraintButtonsPanel(bpy.types.Panel): self.stretch_to(box, con) elif con.type == "FLOOR": self.floor(box, con) - #elif con.type == "RIGID_BODY_JOINT" + #elif con.type == "RIGID_BODY_JOINT": # self.rigid_body(box, con) elif con.type == "CLAMP_TO": self.clamp_to(box, con) @@ -126,13 +126,30 @@ class ConstraintButtonsPanel(bpy.types.Panel): self.space_template(layout, con) - #def ik(self, layout, con): - + def ik(self, layout, con): + self.target_template(layout, con) + + layout.itemR(con, "pole_target") + layout.itemR(con, "pole_subtarget") + + col = layout.column_flow() + col.itemR(con, "iterations") + col.itemR(con, "pole_angle") + col.itemR(con, "weight") + col.itemR(con, "orient_weight") + col.itemR(con, "chain_length") + + col = layout.column_flow() + col.itemR(con, "tail") + col.itemR(con, "rotation") + col.itemR(con, "targetless") + col.itemR(con, "stretch") + def follow_path(self, layout, con): self.target_template(layout, con) row = layout.row() - row.itemR(con, "curve_follow", toggle=True) + row.itemR(con, "curve_follow") row.itemR(con, "offset") row = layout.row() @@ -394,7 +411,29 @@ class ConstraintButtonsPanel(bpy.types.Panel): row.itemL(text="Min/Max:") row.itemR(con, "floor_location", expand=True) - #def rigid_body(self, layout, con): + def rigid_body(self, layout, con): + self.target_template(layout, con) + + layout.itemR(con, "pivot_type") + layout.itemR(con, "child") + + row = layout.row() + row.itemR(con, "disable_linked_collision", text="No Collision") + row.itemR(con, "draw_pivot") + + split = layout.split() + + col = split.column() + col.itemR(con, "pivot_x") + col.itemR(con, "pivot_y") + col.itemR(con, "pivot_z") + + col = split.column() + col.itemR(con, "axis_x") + col.itemR(con, "axis_y") + col.itemR(con, "axis_z") + + #Missing: Limit arrays (not wrapped in RNA yet) def clamp_to(self, layout, con): self.target_template(layout, con) diff --git a/source/blender/editors/interface/interface_templates.c b/source/blender/editors/interface/interface_templates.c index 987b7eef4d6..cd905a9657b 100644 --- a/source/blender/editors/interface/interface_templates.c +++ b/source/blender/editors/interface/interface_templates.c @@ -1141,101 +1141,11 @@ static uiLayout *draw_constraint(uiLayout *layout, Object *ob, bConstraint *con) } break; */ - case CONSTRAINT_TYPE_KINEMATIC: + + /*case CONSTRAINT_TYPE_RIGIDBODYJOINT: { - bKinematicConstraint *data = con->data; - - /* IK Target */ - uiDefBut(block, LABEL, B_CONSTRAINT_TEST, "Target:", xco, yco-24, 80, 18, NULL, 0.0, 0.0, 0.0, 0.0, ""); - - /* Draw target parameters */ - uiBlockBeginAlign(block); - uiDefIDPoinBut(block, test_obpoin_but, ID_OB, B_CONSTRAINT_CHANGETARGET, "OB:", xco, yco-44, 137, 19, &data->tar, "Target Object"); - - if (is_armature_target(data->tar)) { - but=uiDefBut(block, TEX, B_CONSTRAINT_CHANGETARGET, "BO:", xco, yco-62,137,19, &data->subtarget, 0, 24, 0, 0, "Subtarget Bone"); - uiButSetCompleteFunc(but, autocomplete_bone, (void *)data->tar); - } - else if (is_geom_target(data->tar)) { - but= uiDefBut(block, TEX, B_CONSTRAINT_CHANGETARGET, "VG:", xco, yco-62,137,18, &data->subtarget, 0, 24, 0, 0, "Name of Vertex Group defining 'target' points"); - uiButSetCompleteFunc(but, autocomplete_vgroup, (void *)data->tar); - } - else { - strcpy (data->subtarget, ""); - } - - uiBlockEndAlign(block); - - /* Settings */ - uiBlockBeginAlign(block); - uiDefButBitS(block, TOG, CONSTRAINT_IK_TIP, B_CONSTRAINT_TEST, "Use Tail", xco, yco-92, 137, 19, &data->flag, 0, 0, 0, 0, "Include Bone's tail also last element in Chain"); - uiDefButS(block, NUM, B_CONSTRAINT_TEST, "ChainLen:", xco, yco-112,137,19, &data->rootbone, 0, 255, 0, 0, "If not zero, the amount of bones in this chain"); - - uiBlockBeginAlign(block); - uiDefButF(block, NUMSLI, B_CONSTRAINT_TEST, "PosW ", xco+147, yco-92, 137, 19, &data->weight, 0.01, 1.0, 2, 2, "For Tree-IK: weight of position control for this target"); - uiDefButBitS(block, TOG, CONSTRAINT_IK_ROT, B_CONSTRAINT_TEST, "Rot", xco+147, yco-112, 40,19, &data->flag, 0, 0, 0, 0, "Chain follows rotation of target"); - uiDefButF(block, NUMSLI, B_CONSTRAINT_TEST, "W ", xco+187, yco-112, 97, 19, &data->orientweight, 0.01, 1.0, 2, 2, "For Tree-IK: Weight of orientation control for this target"); - - uiBlockBeginAlign(block); - - uiDefButBitS(block, TOG, CONSTRAINT_IK_STRETCH, B_CONSTRAINT_TEST, "Stretch", xco, yco-137,137,19, &data->flag, 0, 0, 0, 0, "Enable IK stretching"); - uiBlockBeginAlign(block); - uiDefButS(block, NUM, B_CONSTRAINT_TEST, "Iterations:", xco+147, yco-137, 137, 19, &data->iterations, 1, 10000, 0, 0, "Maximum number of solving iterations"); - uiBlockEndAlign(block); - - /* Pole Vector */ - uiDefBut(block, LABEL, B_CONSTRAINT_TEST, "Pole Target:", xco+147, yco-24, 100, 18, NULL, 0.0, 0.0, 0.0, 0.0, ""); - - uiBlockBeginAlign(block); - uiDefIDPoinBut(block, test_obpoin_but, ID_OB, B_CONSTRAINT_CHANGETARGET, "OB:", xco+147, yco-44, 137, 19, &data->poletar, "Pole Target Object"); - if (is_armature_target(data->poletar)) { - but=uiDefBut(block, TEX, B_CONSTRAINT_CHANGETARGET, "BO:", xco+147, yco-62,137,19, &data->polesubtarget, 0, 24, 0, 0, "Pole Subtarget Bone"); - uiButSetCompleteFunc(but, autocomplete_bone, (void *)data->poletar); - } - else if (is_geom_target(data->poletar)) { - but= uiDefBut(block, TEX, B_CONSTRAINT_CHANGETARGET, "VG:", xco+147, yco-62,137,18, &data->polesubtarget, 0, 24, 0, 0, "Name of Vertex Group defining pole 'target' points"); - uiButSetCompleteFunc(but, autocomplete_vgroup, (void *)data->poletar); - } - else { - strcpy(data->polesubtarget, ""); - } - - if (data->poletar) { - uiDefButF(block, NUM, B_CONSTRAINT_TEST, "Pole Offset ", xco, yco-167, 137, 19, &data->poleangle, -180.0, 180.0, 0, 0, "Pole rotation offset"); - } - } - break; - case CONSTRAINT_TYPE_RIGIDBODYJOINT: - { - bRigidBodyJointConstraint *data = con->data; - float extremeLin = 999.f; - float extremeAngX = 180.f; - float extremeAngY = 45.f; - float extremeAngZ = 45.f; - int togButWidth = 70; - int offsetY = 150; - int textButWidth = ((width/2)-togButWidth); - - uiDefButI(block, MENU, B_CONSTRAINT_TEST, "Joint Types%t|Ball%x1|Hinge%x2|Generic 6DOF%x12",//|Extra Force%x6", - //uiDefButI(block, MENU, B_CONSTRAINT_TEST, "Joint Types%t|Ball%x1|Hinge%x2|Cone Twist%x4|Generic 6DOF%x12",//|Extra Force%x6", - xco, yco-25, 150, 18, &data->type, 0, 0, 0, 0, "Choose the joint type"); - - uiDefButBitS(block, TOG, CONSTRAINT_DISABLE_LINKED_COLLISION, B_CONSTRAINT_TEST, "No Collision", xco+155, yco-25, 111, 18, &data->flag, 0, 24, 0, 0, "Disable Collision Between Linked Bodies"); - - - uiDefIDPoinBut(block, test_obpoin_but, ID_OB, B_CONSTRAINT_CHANGETARGET, "toObject:", xco, yco-50, 130, 18, &data->tar, "Child Object"); - uiDefButBitS(block, TOG, CONSTRAINT_DRAW_PIVOT, B_CONSTRAINT_TEST, "ShowPivot", xco+135, yco-50, 130, 18, &data->flag, 0, 24, 0, 0, "Show pivot position and rotation"); - - uiDefButF(block, NUM, B_CONSTRAINT_TEST, "Pivot X:", xco, yco-75, 130, 18, &data->pivX, -1000, 1000, 100, 0.0, "Offset pivot on X"); - uiDefButF(block, NUM, B_CONSTRAINT_TEST, "Pivot Y:", xco, yco-100, 130, 18, &data->pivY, -1000, 1000, 100, 0.0, "Offset pivot on Y"); - uiDefButF(block, NUM, B_CONSTRAINT_TEST, "Pivot Z:", xco, yco-125, 130, 18, &data->pivZ, -1000, 1000, 100, 0.0, "Offset pivot on z"); - - uiDefButF(block, NUM, B_CONSTRAINT_TEST, "Ax X:", xco+135, yco-75, 130, 18, &data->axX, -360, 360, 1500, 0.0, "Rotate pivot on X Axis (in degrees)"); - uiDefButF(block, NUM, B_CONSTRAINT_TEST, "Ax Y:", xco+135, yco-100, 130, 18, &data->axY, -360, 360, 1500, 0.0, "Rotate pivot on Y Axis (in degrees)"); - uiDefButF(block, NUM, B_CONSTRAINT_TEST, "Ax Z:", xco+135, yco-125, 130, 18, &data->axZ, -360, 360, 1500, 0.0, "Rotate pivot on Z Axis (in degrees)"); - if (data->type==CONSTRAINT_RB_GENERIC6DOF) { - /* Draw Pairs of LimitToggle+LimitValue */ + // Draw Pairs of LimitToggle+LimitValue uiBlockBeginAlign(block); uiDefButBitS(block, TOG, 1, B_CONSTRAINT_TEST, "LinMinX", xco, yco-offsetY, togButWidth, 18, &data->flag, 0, 24, 0, 0, "Use minimum x limit"); uiDefButF(block, NUM, B_CONSTRAINT_TEST, "", xco+togButWidth, yco-offsetY, (textButWidth-5), 18, &(data->minLimit[0]), -extremeLin, extremeLin, 0.1,0.5,"min x limit"); @@ -1270,7 +1180,7 @@ static uiLayout *draw_constraint(uiLayout *layout, Object *ob, bConstraint *con) offsetY += 20; } if ((data->type==CONSTRAINT_RB_GENERIC6DOF) || (data->type==CONSTRAINT_RB_CONETWIST)) { - /* Draw Pairs of LimitToggle+LimitValue */ + // Draw Pairs of LimitToggle+LimitValue / uiBlockBeginAlign(block); uiDefButBitS(block, TOG, 8, B_CONSTRAINT_TEST, "AngMinX", xco, yco-offsetY, togButWidth, 18, &data->flag, 0, 24, 0, 0, "Use minimum x limit"); uiDefButF(block, NUM, B_CONSTRAINT_TEST, "", xco+togButWidth, yco-offsetY, (textButWidth-5), 18, &(data->minLimit[3]), -extremeAngX, extremeAngX, 0.1,0.5,"min x limit"); @@ -1305,6 +1215,7 @@ static uiLayout *draw_constraint(uiLayout *layout, Object *ob, bConstraint *con) } break; + */ case CONSTRAINT_TYPE_NULL: { From 67494dcad3330b1c056cef4b9aa21030c856cf5d Mon Sep 17 00:00:00 2001 From: Ton Roosendaal Date: Tue, 2 Jun 2009 16:40:15 +0000 Subject: [PATCH 03/35] 2.5 Crash; reading NULL pointer in poll() callback for UV edit. Note: poll() is ONLY for checking context, not for changing things. --- source/blender/editors/screen/screen_ops.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/source/blender/editors/screen/screen_ops.c b/source/blender/editors/screen/screen_ops.c index be952558b6c..bec3cde7935 100644 --- a/source/blender/editors/screen/screen_ops.c +++ b/source/blender/editors/screen/screen_ops.c @@ -242,7 +242,8 @@ int ED_operator_uvmap(bContext *C) return 1; } - BKE_mesh_end_editmesh(obedit->data, em); + if(obedit) + BKE_mesh_end_editmesh(obedit->data, em); return 0; } From ca24322413e78b60ece51902da1b8a9ac22d13ba Mon Sep 17 00:00:00 2001 From: Ton Roosendaal Date: Tue, 2 Jun 2009 18:10:06 +0000 Subject: [PATCH 04/35] 2.5 Part one of new text button type: SEARCH_MENU This opens a popup showing all matches for a typed string, nice for object names, materials, operators, and so on. Warning: Currently menu doesn't function yet! Only draws choices. As test I've added an operator search button in top bar. It only shows operators that can be used in this context now. Also that is part of the WIP, tomorrow more fun :) --- source/blender/editors/include/UI_interface.h | 41 ++-- source/blender/editors/interface/interface.c | 42 ++++- .../editors/interface/interface_handlers.c | 26 ++- .../editors/interface/interface_intern.h | 9 + .../editors/interface/interface_regions.c | 176 ++++++++++++++++++ .../editors/interface/interface_style.c | 2 +- .../editors/interface/interface_widgets.c | 69 +++++-- source/blender/editors/screen/screen_ops.c | 37 +--- .../blender/editors/space_info/info_header.c | 36 ++++ 9 files changed, 363 insertions(+), 75 deletions(-) diff --git a/source/blender/editors/include/UI_interface.h b/source/blender/editors/include/UI_interface.h index 97c2da5297f..e66c4ef827b 100644 --- a/source/blender/editors/include/UI_interface.h +++ b/source/blender/editors/include/UI_interface.h @@ -177,20 +177,21 @@ typedef struct uiLayout uiLayout; #define INLINK (23<<9) #define KEYEVT (24<<9) #define ICONTEXTROW (25<<9) -#define HSVCUBE (26<<9) -#define PULLDOWN (27<<9) -#define ROUNDBOX (28<<9) -#define CHARTAB (29<<9) +#define HSVCUBE (26<<9) +#define PULLDOWN (27<<9) +#define ROUNDBOX (28<<9) +#define CHARTAB (29<<9) #define BUT_COLORBAND (30<<9) -#define BUT_NORMAL (31<<9) -#define BUT_CURVE (32<<9) +#define BUT_NORMAL (31<<9) +#define BUT_CURVE (32<<9) #define BUT_TOGDUAL (33<<9) -#define ICONTOGN (34<<9) -#define FTPREVIEW (35<<9) -#define NUMABS (36<<9) -#define TOGBUT (37<<9) -#define OPTION (38<<9) -#define OPTIONN (39<<9) +#define ICONTOGN (34<<9) +#define FTPREVIEW (35<<9) +#define NUMABS (36<<9) +#define TOGBUT (37<<9) +#define OPTION (38<<9) +#define OPTIONN (39<<9) +#define SEARCH_MENU (40<<9) #define BUTTYPE (63<<9) /* Drawing @@ -401,6 +402,8 @@ uiBut *uiDefIconTextBlockBut(uiBlock *block, uiBlockCreateFunc func, void *arg, void uiDefKeyevtButS(uiBlock *block, int retval, char *str, short x1, short y1, short x2, short y2, short *spoin, char *tip); +uiBut *uiDefSearchBut(uiBlock *block, void *arg, int retval, int icon, int maxlen, short x1, short y1, short x2, short y2, char *tip); + void uiBlockPickerButtons(struct uiBlock *block, float *col, float *hsv, float *old, char *hexcol, char mode, short retval); void uiBlockColorbandButtons(struct uiBlock *block, struct ColorBand *coba, struct rctf *butr, int event); @@ -425,16 +428,29 @@ uiBut *uiFindInlink(uiBlock *block, void *poin); * * uiButSetCompleteFunc is for tab completion. * + * uiButSearchFunc is for name buttons, showing a popup with matches + * * uiBlockSetFunc and uiButSetFunc are callbacks run when a button is used, * in case events, operators or RNA are not sufficient to handle the button. * * uiButSetNFunc will free the argument with MEM_freeN. */ +typedef struct uiSearchItems { + int maxitem, totitem, maxstrlen; + + char **names; + void **pointers; + +} uiSearchItems; + + typedef void (*uiButHandleFunc)(struct bContext *C, void *arg1, void *arg2); typedef void (*uiButHandleNFunc)(struct bContext *C, void *argN, void *arg2); typedef void (*uiButCompleteFunc)(struct bContext *C, char *str, void *arg); +typedef void (*uiButSearchFunc)(const struct bContext *C, void *arg, char *str, uiSearchItems *items); typedef void (*uiBlockHandleFunc)(struct bContext *C, void *arg, int event); + void uiBlockSetHandleFunc(uiBlock *block, uiBlockHandleFunc func, void *arg); void uiBlockSetButmFunc (uiBlock *block, uiMenuHandleFunc func, void *arg); @@ -443,6 +459,7 @@ void uiButSetFunc (uiBut *but, uiButHandleFunc func, void *arg1, void *arg2); void uiButSetNFunc (uiBut *but, uiButHandleNFunc func, void *argN, void *arg2); void uiButSetCompleteFunc(uiBut *but, uiButCompleteFunc func, void *arg); +void uiButSetSearchFunc (uiBut *but, uiButSearchFunc func, void *arg); void uiBlockSetDrawExtraFunc(uiBlock *block, void (*func)(struct bContext *C, uiBlock *block)); diff --git a/source/blender/editors/interface/interface.c b/source/blender/editors/interface/interface.c index e9a886375c3..4fb2f27a618 100644 --- a/source/blender/editors/interface/interface.c +++ b/source/blender/editors/interface/interface.c @@ -1359,7 +1359,7 @@ int ui_get_but_string_max_length(uiBut *but) void ui_get_but_string(uiBut *but, char *str, int maxlen) { - if(but->rnaprop && ELEM(but->type, TEX, IDPOIN)) { + if(but->rnaprop && ELEM3(but->type, TEX, IDPOIN, SEARCH_MENU)) { PropertyType type; char *buf= NULL; @@ -1402,6 +1402,11 @@ void ui_get_but_string(uiBut *but, char *str, int maxlen) BLI_strncpy(str, but->poin, maxlen); return; } + else if(but->type == SEARCH_MENU) { + /* string */ + BLI_strncpy(str, but->poin, maxlen); + return; + } else { /* number */ double value; @@ -1491,7 +1496,7 @@ static void ui_rna_ID_autocomplete(bContext *C, char *str, void *arg_but) int ui_set_but_string(bContext *C, uiBut *but, const char *str) { - if(but->rnaprop && ELEM(but->type, TEX, IDPOIN)) { + if(but->rnaprop && ELEM3(but->type, TEX, IDPOIN, SEARCH_MENU)) { if(RNA_property_editable(&but->rnapoin, but->rnaprop)) { PropertyType type; @@ -1535,6 +1540,11 @@ int ui_set_but_string(bContext *C, uiBut *but, const char *str) BLI_strncpy(but->poin, str, but->hardmax); return 1; } + else if(but->type == SEARCH_MENU) { + /* string */ + BLI_strncpy(but->poin, str, but->hardmax); + return 1; + } else { double value; @@ -1817,11 +1827,11 @@ void ui_check_but(uiBut *but) /* if something changed in the button */ double value; float okwidth; - int transopts= ui_translate_buttons(); +// int transopts= ui_translate_buttons(); ui_is_but_sel(but); - if(but->type==TEX || but->type==IDPOIN) transopts= 0; +// if(but->type==TEX || but->type==IDPOIN) transopts= 0; /* test for min and max, icon sliders, etc */ switch( but->type ) { @@ -1926,6 +1936,7 @@ void ui_check_but(uiBut *but) case IDPOIN: case TEX: + case SEARCH_MENU: if(!but->editstr) { char str[UI_MAX_DRAW_STR]; @@ -3065,6 +3076,29 @@ void uiDefKeyevtButS(uiBlock *block, int retval, char *str, short x1, short y1, ui_check_but(but); } +/* arg is pointer to string/name, use callbacks below to make this work */ +uiBut *uiDefSearchBut(uiBlock *block, void *arg, int retval, int icon, int maxlen, short x1, short y1, short x2, short y2, char *tip) +{ + uiBut *but= ui_def_but(block, SEARCH_MENU, retval, "", x1, y1, x2, y2, arg, 0.0, maxlen, 0.0, 0.0, tip); + + but->icon= (BIFIconID) icon; + but->flag|= UI_HAS_ICON; + + but->flag|= UI_ICON_LEFT|UI_TEXT_LEFT; + but->flag|= UI_ICON_SUBMENU; + + ui_check_but(but); + + return but; +} + +void uiButSetSearchFunc(uiBut *but, uiButSearchFunc func, void *arg) +{ + but->search_func= func; + but->search_arg= arg; +} + + /* Program Init/Exit */ void UI_init(void) diff --git a/source/blender/editors/interface/interface_handlers.c b/source/blender/editors/interface/interface_handlers.c index ec2f960dd14..e0e58e61752 100644 --- a/source/blender/editors/interface/interface_handlers.c +++ b/source/blender/editors/interface/interface_handlers.c @@ -127,6 +127,9 @@ typedef struct uiHandleButtonData { /* menu open */ uiPopupBlockHandle *menu; int menuretval; + + /* search box */ + ARegion *searchbox; /* post activate */ uiButtonActivateType posttype; @@ -557,6 +560,7 @@ static void ui_apply_button(bContext *C, uiBlock *block, uiBut *but, uiHandleBut ui_apply_but_BUT(C, but, data); break; case TEX: + case SEARCH_MENU: ui_apply_but_TEX(C, but, data); break; case TOGBUT: @@ -1124,7 +1128,7 @@ static int ui_textedit_copypaste(uiBut *but, uiHandleButtonData *data, int paste return changed; } -static void ui_textedit_begin(uiBut *but, uiHandleButtonData *data) +static void ui_textedit_begin(bContext *C, uiBut *but, uiHandleButtonData *data) { if(data->str) { MEM_freeN(data->str); @@ -1146,14 +1150,24 @@ static void ui_textedit_begin(uiBut *but, uiHandleButtonData *data) but->selsta= 0; but->selend= strlen(but->drawstr) - strlen(but->str); + /* optional searchbox */ + if(but->type==SEARCH_MENU) { + data->searchbox= ui_searchbox_create(C, data->region, but); + ui_searchbox_update(C, data->searchbox, but); + } + ui_check_but(but); } -static void ui_textedit_end(uiBut *but, uiHandleButtonData *data) +static void ui_textedit_end(bContext *C, uiBut *but, uiHandleButtonData *data) { if(but) { but->editstr= 0; but->pos= -1; + + if(data->searchbox) + ui_searchbox_free(C, data->searchbox); + data->searchbox= NULL; } } @@ -1316,6 +1330,9 @@ static void ui_do_but_textedit(bContext *C, uiBlock *block, uiBut *but, uiHandle if(changed) { if(data->interactive) ui_apply_button(C, block, but, data, 1); else ui_check_but(but); + + if(data->searchbox) + ui_searchbox_update(C, data->searchbox, but); } if(changed || (retval == WM_UI_HANDLER_BREAK)) @@ -2702,6 +2719,7 @@ static int ui_do_button(bContext *C, uiBlock *block, uiBut *but, wmEvent *event) break; case TEX: case IDPOIN: + case SEARCH_MENU: retval= ui_do_but_TEX(C, block, but, data, event); break; case MENU: @@ -2928,9 +2946,9 @@ static void button_activate_state(bContext *C, uiBut *but, uiHandleButtonState s /* text editing */ if(state == BUTTON_STATE_TEXT_EDITING && data->state != BUTTON_STATE_TEXT_SELECTING) - ui_textedit_begin(but, data); + ui_textedit_begin(C, but, data); else if(data->state == BUTTON_STATE_TEXT_EDITING && state != BUTTON_STATE_TEXT_SELECTING) - ui_textedit_end(but, data); + ui_textedit_end(C, but, data); /* number editing */ if(state == BUTTON_STATE_NUM_EDITING) diff --git a/source/blender/editors/interface/interface_intern.h b/source/blender/editors/interface/interface_intern.h index 25a1dbe3d62..f4483a0540d 100644 --- a/source/blender/editors/interface/interface_intern.h +++ b/source/blender/editors/interface/interface_intern.h @@ -176,6 +176,9 @@ struct uiBut { uiButCompleteFunc autocomplete_func; void *autofunc_arg; + uiButSearchFunc search_func; + void *search_arg; + uiLink *link; char *tip, *lockstr; @@ -351,6 +354,10 @@ uiBlock *ui_block_func_COL(struct bContext *C, uiPopupBlockHandle *handle, void struct ARegion *ui_tooltip_create(struct bContext *C, struct ARegion *butregion, uiBut *but); void ui_tooltip_free(struct bContext *C, struct ARegion *ar); +ARegion *ui_searchbox_create(struct bContext *C, struct ARegion *butregion, uiBut *but); +void ui_searchbox_update(struct bContext *C, struct ARegion *ar, uiBut *but); +void ui_searchbox_free(struct bContext *C, struct ARegion *ar); + typedef uiBlock* (*uiBlockHandleCreateFunc)(struct bContext *C, struct uiPopupBlockHandle *handle, void *arg1); uiPopupBlockHandle *ui_popup_block_create(struct bContext *C, struct ARegion *butregion, uiBut *but, @@ -394,6 +401,8 @@ extern void ui_draw_but(ARegion *ar, struct uiStyle *style, uiBut *but, rcti *re struct ThemeUI; void ui_widget_color_init(struct ThemeUI *tui); +void ui_draw_menu_item(struct uiFontStyle *fstyle, rcti *rect, char *name, int state); + /* interface_style.c */ void uiStyleInit(void); diff --git a/source/blender/editors/interface/interface_regions.c b/source/blender/editors/interface/interface_regions.c index 0109612fdc0..3441abc94bd 100644 --- a/source/blender/editors/interface/interface_regions.c +++ b/source/blender/editors/interface/interface_regions.c @@ -383,6 +383,182 @@ void ui_tooltip_free(bContext *C, ARegion *ar) ui_remove_temporary_region(C, CTX_wm_screen(C), ar); } + +/************************* Creating Search Box **********************/ + + +typedef struct uiSearchboxData { + rcti bbox; + uiFontStyle fstyle; + uiSearchItems items; +} uiSearchboxData; + +#define SEARCH_ITEMS 10 + +/* ar is the search box itself */ +void ui_searchbox_update(bContext *C, ARegion *ar, uiBut *but) +{ + uiSearchboxData *data= ar->regiondata; + + /* callback */ + data->items.totitem= 0; + but->search_func(C, but->search_arg, but->editstr, &data->items); + + ED_region_tag_redraw(ar); +} + +static void ui_searchbox_region_draw(const bContext *C, ARegion *ar) +{ + uiSearchboxData *data= ar->regiondata; + + ui_draw_menu_back(U.uistyles.first, NULL, &data->bbox); + + /* draw text */ + if(data->items.totitem) { + rcti rect; + int a, buth; + + /* draw items */ + buth= (data->bbox.ymax-data->bbox.ymin - 2*MENU_SEPR_HEIGHT)/SEARCH_ITEMS; + rect= data->bbox; + rect.xmin= data->bbox.xmin + 3.0f; + rect.xmax= data->bbox.xmax - 3.0f; + rect.ymax= data->bbox.ymax - MENU_SEPR_HEIGHT; + rect.ymin= rect.ymax - buth; + + for(a=0; aitems.totitem; a++) { + ui_draw_menu_item(&data->fstyle, &rect, data->items.names[a], a==0?UI_ACTIVE:0); + rect.ymax -= buth; + rect.ymin -= buth; + } + } +} + +static void ui_searchbox_region_free(ARegion *ar) +{ + uiSearchboxData *data= ar->regiondata; + int a; + + /* free search data */ + for(a=0; aitems.names[a]); + MEM_freeN(data->items.names); + MEM_freeN(data->items.pointers); + + MEM_freeN(data); + ar->regiondata= NULL; +} + +ARegion *ui_searchbox_create(bContext *C, ARegion *butregion, uiBut *but) +{ + uiStyle *style= U.uistyles.first; // XXX pass on as arg + static ARegionType type; + ARegion *ar; + uiSearchboxData *data; + float aspect= but->block->aspect; + float x1f, x2f, y1f, y2f; + int x1, x2, y1, y2, winx, winy, ofsx, ofsy; + + /* create area region */ + ar= ui_add_temporary_region(CTX_wm_screen(C)); + + memset(&type, 0, sizeof(ARegionType)); + type.draw= ui_searchbox_region_draw; + type.free= ui_searchbox_region_free; + ar->type= &type; + + /* create searchbox data */ + data= MEM_callocN(sizeof(uiSearchboxData), "uiSearchboxData"); + + /* set font, get bb */ + data->fstyle= style->widget; /* copy struct */ + data->fstyle.align= UI_STYLE_TEXT_CENTER; + ui_fontscale(&data->fstyle.points, aspect); + uiStyleFontSet(&data->fstyle); + + ar->regiondata= data; + + /* compute position */ + ofsx= (but->block->panel)? but->block->panel->ofsx: 0; + ofsy= (but->block->panel)? but->block->panel->ofsy: 0; + + x1f= but->x1; + x2f= but->x2; + y2f= but->y1; + y1f= y2f - SEARCH_ITEMS*MENU_BUTTON_HEIGHT - 2*MENU_SEPR_HEIGHT; + + /* minimal width */ + if(x2f - x1f < 180) x2f= x1f+180; // XXX arbitrary + + /* copy to int, gets projected if possible too */ + x1= x1f; y1= y1f; x2= x2f; y2= y2f; + + if(butregion) { + if(butregion->v2d.cur.xmin != butregion->v2d.cur.xmax) { + UI_view2d_to_region_no_clip(&butregion->v2d, x1f, y1f, &x1, &y1); + UI_view2d_to_region_no_clip(&butregion->v2d, x2f, y2f, &x2, &y2); + } + + x1 += butregion->winrct.xmin; + x2 += butregion->winrct.xmin; + y1 += butregion->winrct.ymin; + y2 += butregion->winrct.ymin; + } + + wm_window_get_size(CTX_wm_window(C), &winx, &winy); + + if(x2 > winx) { + /* super size */ + if(x2 > winx + x1) { + x2= winx; + x1= 0; + } + else { + x1 -= x2-winx; + x2= winx; + } + } + if(y1 < 0) { + y1 += 36; + y2 += 36; + } + + /* widget rect, in region coords */ + data->bbox.xmin= MENU_SHADOW_SIDE; + data->bbox.xmax= x2-x1 + MENU_SHADOW_SIDE; + data->bbox.ymin= MENU_SHADOW_BOTTOM; + data->bbox.ymax= y2-y1 + MENU_SHADOW_BOTTOM; + + /* region bigger for shadow */ + ar->winrct.xmin= x1 - MENU_SHADOW_SIDE; + ar->winrct.xmax= x2 + MENU_SHADOW_SIDE; + ar->winrct.ymin= y1 - MENU_SHADOW_BOTTOM; + ar->winrct.ymax= y2 + MENU_TOP; + + /* adds subwindow */ + ED_region_init(C, ar); + + /* notify change and redraw */ + ED_region_tag_redraw(ar); + + /* prepare search data */ + data->items.maxitem= SEARCH_ITEMS; + data->items.maxstrlen= but->hardmax; + data->items.totitem= 0; + data->items.names= MEM_callocN(SEARCH_ITEMS*sizeof(void *), "search names"); + data->items.pointers= MEM_callocN(SEARCH_ITEMS*sizeof(void *), "search pointers"); + for(x1=0; x1items.names[x1]= MEM_callocN(but->hardmax+1, "search pointers"); + + return ar; +} + +void ui_searchbox_free(bContext *C, ARegion *ar) +{ + ui_remove_temporary_region(C, CTX_wm_screen(C), ar); +} + + /************************* Creating Menu Blocks **********************/ /* position block relative to but, result is in window space */ diff --git a/source/blender/editors/interface/interface_style.c b/source/blender/editors/interface/interface_style.c index fca88132771..62a4c01bc6c 100644 --- a/source/blender/editors/interface/interface_style.c +++ b/source/blender/editors/interface/interface_style.c @@ -170,7 +170,7 @@ void uiStyleFontDraw(uiFontStyle *fs, rcti *rect, char *str) if(fs->align==UI_STYLE_TEXT_CENTER) xofs= floor( 0.5f*(rect->xmax - rect->xmin - BLF_width(str))); else if(fs->align==UI_STYLE_TEXT_RIGHT) - xofs= rect->xmax - rect->xmin - BLF_width(str); + xofs= rect->xmax - rect->xmin - BLF_width(str) - 1; /* clip is very strict, so we give it some space */ BLF_clipping(rect->xmin-1, rect->ymin-4, rect->xmax+1, rect->ymax+4); diff --git a/source/blender/editors/interface/interface_widgets.c b/source/blender/editors/interface/interface_widgets.c index f4e3a7f2899..82bfb898f99 100644 --- a/source/blender/editors/interface/interface_widgets.c +++ b/source/blender/editors/interface/interface_widgets.c @@ -844,29 +844,23 @@ static void widget_draw_text_icon(uiFontStyle *fstyle, uiWidgetColors *wcol, uiB widget_draw_icon(but, ICON_DOT, dualset?0:-100, rect); } - if(but->drawstr[0]!=0) { + /* If there's an icon too (made with uiDefIconTextBut) then draw the icon + and offset the text label to accomodate it */ + + if (but->flag & UI_HAS_ICON) { + widget_draw_icon(but, but->icon, 0, rect); - /* If there's an icon too (made with uiDefIconTextBut) then draw the icon - and offset the text label to accomodate it */ + rect->xmin += UI_icon_get_width(but->icon); - if (but->flag & UI_HAS_ICON) { - widget_draw_icon(but, but->icon, 0, rect); - - rect->xmin += UI_icon_get_width(but->icon); - - if(but->editstr || (but->flag & UI_TEXT_LEFT)) - rect->xmin += 5; - } - else if(but->flag & UI_TEXT_LEFT) + if(but->editstr || (but->flag & UI_TEXT_LEFT)) rect->xmin += 5; - - widget_draw_text(fstyle, wcol, but, rect); - - } - /* if there's no text label, then check to see if there's an icon only and draw it */ - else if( but->flag & UI_HAS_ICON ) { - widget_draw_icon(but, (BIFIconID) (but->icon+but->iconadd), 0, rect); } + else if(but->flag & UI_TEXT_LEFT) + rect->xmin += 5; + + /* always draw text for textbutton cursor */ + widget_draw_text(fstyle, wcol, but, rect); + } } @@ -1827,6 +1821,7 @@ void ui_draw_but(ARegion *ar, uiStyle *style, uiBut *but, rcti *rect) wt= widget_type(UI_WTYPE_RADIO); break; case TEX: + case SEARCH_MENU: wt= widget_type(UI_WTYPE_NAME); break; case TOGBUT: @@ -1918,4 +1913,40 @@ void ui_draw_menu_back(uiStyle *style, uiBlock *block, rcti *rect) } +/* helper call to draw a menu item without button */ +/* state: UI_ACTIVE or 0 */ +void ui_draw_menu_item(uiFontStyle *fstyle, rcti *rect, char *name, int state) +{ + uiWidgetType *wt= widget_type(UI_WTYPE_MENU_ITEM); + rcti _rect= *rect; + char *cpoin; + + wt->state(wt, state); + wt->draw(&wt->wcol, rect, 0, 0); + + uiStyleFontSet(fstyle); + fstyle->align= UI_STYLE_TEXT_LEFT; + + /* text location offset */ + rect->xmin+=5; + + /* cut string in 2 parts? */ + cpoin= strchr(name, '|'); + if(cpoin) *cpoin= 0; + + glColor3ubv(wt->wcol.text); + uiStyleFontDraw(fstyle, rect, name); + + /* part text right aligned */ + if(cpoin) { + fstyle->align= UI_STYLE_TEXT_RIGHT; + rect->xmax-=5; + uiStyleFontDraw(fstyle, rect, cpoin+1); + *cpoin= '|'; + } + + /* restore rect, was messed with */ + *rect= _rect; + +} diff --git a/source/blender/editors/screen/screen_ops.c b/source/blender/editors/screen/screen_ops.c index bec3cde7935..e8314deeae9 100644 --- a/source/blender/editors/screen/screen_ops.c +++ b/source/blender/editors/screen/screen_ops.c @@ -225,7 +225,8 @@ int ED_operator_uvedit(bContext *C) return 1; } - BKE_mesh_end_editmesh(obedit->data, em); + if(obedit) + BKE_mesh_end_editmesh(obedit->data, em); return 0; } @@ -1971,37 +1972,6 @@ static int region_flip_exec(bContext *C, wmOperator *op) return OPERATOR_FINISHED; } -static void testfunc(bContext *C, void *argv, int arg) -{ - printf("arg %d\n", arg); -} - -static void newlevel1(bContext *C, uiLayout *layout, void *arg) -{ - uiLayoutSetFunc(layout, testfunc, NULL); - - uiItemV(layout, "First", ICON_PROP_ON, 1); - uiItemV(layout, "Second", ICON_PROP_CON, 2); - uiItemV(layout, "Third", ICON_SMOOTHCURVE, 3); - uiItemV(layout, "Fourth", ICON_SHARPCURVE, 4); -} - -static int testing123(bContext *C, wmOperator *op, wmEvent *event) -{ - uiPopupMenu *pup= uiPupMenuBegin(C, "Hello world", 0); - uiLayout *layout= uiPupMenuLayout(pup); - - uiLayoutSetOperatorContext(layout, WM_OP_EXEC_DEFAULT); - uiItemO(layout, NULL, ICON_PROP_ON, "SCREEN_OT_region_flip"); - uiItemO(layout, NULL, ICON_PROP_CON, "SCREEN_OT_screen_full_area"); - uiItemO(layout, NULL, ICON_SMOOTHCURVE, "SCREEN_OT_region_foursplit"); - uiItemMenuF(layout, "Submenu", 0, newlevel1); - - uiPupMenuEnd(C, pup); - - /* this operator is only for a menu, not used further */ - return OPERATOR_CANCELLED; -} void SCREEN_OT_region_flip(wmOperatorType *ot) { @@ -2010,13 +1980,10 @@ void SCREEN_OT_region_flip(wmOperatorType *ot) ot->idname= "SCREEN_OT_region_flip"; /* api callbacks */ - ot->invoke= testing123; // XXX WM_operator_confirm; ot->exec= region_flip_exec; ot->poll= ED_operator_areaactive; ot->flag= OPTYPE_REGISTER; - - RNA_def_int(ot->srna, "test", 0, INT_MIN, INT_MAX, "test", "", INT_MIN, INT_MAX); } diff --git a/source/blender/editors/space_info/info_header.c b/source/blender/editors/space_info/info_header.c index fd5d851b0c2..38e778848b9 100644 --- a/source/blender/editors/space_info/info_header.c +++ b/source/blender/editors/space_info/info_header.c @@ -387,6 +387,32 @@ static void scene_idpoin_handle(bContext *C, ID *id, int event) } } +static void operator_search_cb(const struct bContext *C, void *arg, char *str, uiSearchItems *items) +{ + wmOperatorType *ot = WM_operatortype_first(); + + for(; ot; ot= ot->next) { + + if(BLI_strcasestr(ot->name, str)) { + if(ot->poll==NULL || ot->poll((bContext *)C)) { + int len= strlen(ot->name); + + BLI_strncpy(items->names[items->totitem], ot->name, items->maxstrlen); + + /* check for hotkey */ + if(len < items->maxstrlen-6) { + if(WM_key_event_operator_string(C, ot->idname, WM_OP_EXEC_DEFAULT, NULL, items->names[items->totitem]+len+1, items->maxstrlen-len-1)) { + items->names[items->totitem][len]= '|'; + } + } + + items->totitem++; + if(items->totitem>=items->maxitem) + break; + } + } + } +} void info_header_buttons(const bContext *C, ARegion *ar) { @@ -453,6 +479,16 @@ void info_header_buttons(const bContext *C, ARegion *ar) xco+= 90; } + { + static char search[256]= ""; + uiBut *but= uiDefSearchBut(block, search, 0, ICON_PROP_ON, 256, xco+5, yco, 120, 19, ""); + + uiButSetSearchFunc(but, operator_search_cb, NULL); + + xco+= 125; + } + + /* always as last */ UI_view2d_totRect_set(&ar->v2d, xco+XIC+80, ar->v2d.tot.ymax-ar->v2d.tot.ymin); From c2d2b1c57d50a3f0a902532646811616502386c3 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Tue, 2 Jun 2009 23:53:40 +0000 Subject: [PATCH 05/35] RNA * Fix an issue where the pointer types wasn't always refine to the most specific type, now RNA_pointer_create also does this for convenience. * Make lamp fallof type editable. --- source/blender/makesrna/intern/rna_access.c | 11 +++++++++++ source/blender/makesrna/intern/rna_constraint.c | 3 ++- source/blender/makesrna/intern/rna_lamp.c | 4 ++-- source/blender/makesrna/intern/rna_ui.c | 6 +++--- source/blender/makesrna/intern/rna_wm.c | 2 +- 5 files changed, 19 insertions(+), 7 deletions(-) diff --git a/source/blender/makesrna/intern/rna_access.c b/source/blender/makesrna/intern/rna_access.c index cc952528302..41e1f4753f0 100644 --- a/source/blender/makesrna/intern/rna_access.c +++ b/source/blender/makesrna/intern/rna_access.c @@ -99,6 +99,17 @@ void RNA_pointer_create(ID *id, StructRNA *type, void *data, PointerRNA *r_ptr) r_ptr->id.data= id; r_ptr->type= type; r_ptr->data= data; + + if(data) { + while(r_ptr->type && r_ptr->type->refine) { + StructRNA *rtype= r_ptr->type->refine(r_ptr); + + if(rtype == r_ptr->type) + break; + else + r_ptr->type= rtype; + } + } } static void rna_pointer_inherit_id(StructRNA *type, PointerRNA *parent, PointerRNA *ptr) diff --git a/source/blender/makesrna/intern/rna_constraint.c b/source/blender/makesrna/intern/rna_constraint.c index 02429ffa4bf..d0730cd7bb0 100644 --- a/source/blender/makesrna/intern/rna_constraint.c +++ b/source/blender/makesrna/intern/rna_constraint.c @@ -1558,4 +1558,5 @@ void RNA_def_constraint(BlenderRNA *brna) rna_def_constraint_shrinkwrap(brna); } -#endif \ No newline at end of file +#endif + diff --git a/source/blender/makesrna/intern/rna_lamp.c b/source/blender/makesrna/intern/rna_lamp.c index 1c4aa7b4eee..d7f9c8728e8 100644 --- a/source/blender/makesrna/intern/rna_lamp.c +++ b/source/blender/makesrna/intern/rna_lamp.c @@ -329,7 +329,6 @@ static void rna_def_lamp_falloff(StructRNA *srna) {0, NULL, NULL, NULL}}; prop= RNA_def_property(srna, "falloff_type", PROP_ENUM, PROP_NONE); - RNA_def_property_clear_flag(prop, PROP_EDITABLE); /* needs to be able to create curve mapping */ RNA_def_property_enum_items(prop, prop_fallofftype_items); RNA_def_property_ui_text(prop, "Falloff Type", "Intensity Decay with distance."); RNA_def_property_update(prop, NC_LAMP|ND_LIGHTING, NULL); @@ -653,6 +652,8 @@ static void rna_def_sun_lamp(BlenderRNA *brna) RNA_def_property_struct_type(prop, "LampSkySettings"); RNA_def_property_pointer_funcs(prop, "rna_Lamp_sky_settings_get", NULL); RNA_def_property_ui_text(prop, "Sky Settings", "Sky related settings for sun lamps."); + + rna_def_lamp_sky_settings(brna); } static void rna_def_hemi_lamp(BlenderRNA *brna) @@ -672,7 +673,6 @@ void RNA_def_lamp(BlenderRNA *brna) rna_def_spot_lamp(brna); rna_def_sun_lamp(brna); rna_def_hemi_lamp(brna); - rna_def_lamp_sky_settings(brna); rna_def_lamp_mtex(brna); } diff --git a/source/blender/makesrna/intern/rna_ui.c b/source/blender/makesrna/intern/rna_ui.c index 9d3d961c18f..7ca0c586d47 100644 --- a/source/blender/makesrna/intern/rna_ui.c +++ b/source/blender/makesrna/intern/rna_ui.c @@ -199,7 +199,7 @@ static StructRNA *rna_Panel_register(const bContext *C, ReportList *reports, voi static StructRNA* rna_Panel_refine(struct PointerRNA *ptr) { Panel *hdr= (Panel*)ptr->data; - return (hdr->type)? hdr->type->py_srna: &RNA_Panel; + return (hdr->type && hdr->type->py_srna)? hdr->type->py_srna: &RNA_Panel; } /* Header */ @@ -290,7 +290,7 @@ static StructRNA *rna_Header_register(const bContext *C, ReportList *reports, vo static StructRNA* rna_Header_refine(struct PointerRNA *htr) { Header *hdr= (Header*)htr->data; - return (hdr->type)? hdr->type->py_srna: &RNA_Header; + return (hdr->type && hdr->type->py_srna)? hdr->type->py_srna: &RNA_Header; } /* Menu */ @@ -405,7 +405,7 @@ static StructRNA *rna_Menu_register(const bContext *C, ReportList *reports, void static StructRNA* rna_Menu_refine(struct PointerRNA *mtr) { Menu *hdr= (Menu*)mtr->data; - return (hdr->type)? hdr->type->py_srna: &RNA_Menu; + return (hdr->type && hdr->type->py_srna)? hdr->type->py_srna: &RNA_Menu; } static int rna_UILayout_active_get(struct PointerRNA *ptr) diff --git a/source/blender/makesrna/intern/rna_wm.c b/source/blender/makesrna/intern/rna_wm.c index c1bccad4ffa..a8f63566349 100644 --- a/source/blender/makesrna/intern/rna_wm.c +++ b/source/blender/makesrna/intern/rna_wm.c @@ -56,7 +56,7 @@ static StructRNA *rna_OperatorProperties_refine(PointerRNA *ptr) if(op) return op->type->srna; else - return &RNA_OperatorProperties; + return ptr->type; } IDProperty *rna_OperatorProperties_idproperties(PointerRNA *ptr, int create) From 5b2737a73523560bf195279a6b1b922d0b415182 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Tue, 2 Jun 2009 23:56:33 +0000 Subject: [PATCH 06/35] 2.5: * Fix crash adding rigid body constraint. * Give new nodetrees NT in ID name to make them recognizned by RNA, even if the nodetrees aren't actual ID datablock. --- source/blender/blenkernel/intern/node.c | 8 ++++++++ source/blender/editors/object/editconstraint.c | 6 +++--- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/source/blender/blenkernel/intern/node.c b/source/blender/blenkernel/intern/node.c index 941e73982a5..43df11335fe 100644 --- a/source/blender/blenkernel/intern/node.c +++ b/source/blender/blenkernel/intern/node.c @@ -1055,6 +1055,14 @@ bNodeTree *ntreeAddTree(int type) ntree->type= type; ntree->alltypes.first = NULL; ntree->alltypes.last = NULL; + + /* this helps RNA identify ID pointers as nodetree */ + if(ntree->type==NTREE_SHADER) + BLI_strncpy(ntree->id.name, "NTShader Nodetree", sizeof(ntree->id.name)); + else if(ntree->type==NTREE_COMPOSIT) + BLI_strncpy(ntree->id.name, "NTComposit Nodetree", sizeof(ntree->id.name)); + else if(ntree->type==NTREE_TEXTURE) + BLI_strncpy(ntree->id.name, "NTTexture Nodetree", sizeof(ntree->id.name)); ntreeInitTypes(ntree); return ntree; diff --git a/source/blender/editors/object/editconstraint.c b/source/blender/editors/object/editconstraint.c index b2cf3be6229..485dd890ac1 100644 --- a/source/blender/editors/object/editconstraint.c +++ b/source/blender/editors/object/editconstraint.c @@ -1000,7 +1000,7 @@ static int constraint_add_exec(bContext *C, wmOperator *op) { Scene *scene= CTX_data_scene(C); Object *ob = CTX_data_active_object(C); - bConstraint *con; + bConstraint *con, *coniter; ListBase *list= get_active_constraints(ob); bPoseChannel *pchan= get_active_posechannel(ob); int type= RNA_enum_get(op->ptr, "type"); @@ -1015,8 +1015,8 @@ static int constraint_add_exec(bContext *C, wmOperator *op) con->flag |= CONSTRAINT_PROXY_LOCAL; con->flag |= CONSTRAINT_ACTIVE; - for(con= con->prev; con; con= con->prev) - con->flag &= ~CONSTRAINT_ACTIVE; + for(coniter= coniter->prev; coniter; coniter= coniter->prev) + coniter->flag &= ~CONSTRAINT_ACTIVE; } switch(type) { From 7498561cfb27166569ae6f0b154bf8391a0cdd9f Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Wed, 3 Jun 2009 00:01:22 +0000 Subject: [PATCH 07/35] 2.5: * Button space context now includes most data so python code doesn't have to look it up manually, and to plug-in context browsing later. --- .../editors/space_buttons/buttons_context.c | 185 ++++++++++++++++++ .../editors/space_buttons/buttons_intern.h | 7 +- .../editors/space_buttons/space_buttons.c | 1 + 3 files changed, 191 insertions(+), 2 deletions(-) create mode 100644 source/blender/editors/space_buttons/buttons_context.c diff --git a/source/blender/editors/space_buttons/buttons_context.c b/source/blender/editors/space_buttons/buttons_context.c new file mode 100644 index 00000000000..642aab52e9d --- /dev/null +++ b/source/blender/editors/space_buttons/buttons_context.c @@ -0,0 +1,185 @@ +/** + * $Id: + * + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * + * The Original Code is Copyright (C) 2009 Blender Foundation. + * All rights reserved. + * + * Contributor(s): Blender Foundation + * + * ***** END GPL LICENSE BLOCK ***** + */ + +#include + +#include "DNA_armature_types.h" +#include "DNA_object_types.h" +#include "DNA_material_types.h" +#include "DNA_modifier_types.h" +#include "DNA_scene_types.h" +#include "DNA_particle_types.h" +#include "DNA_texture_types.h" +#include "DNA_world_types.h" + +#include "BKE_context.h" +#include "BKE_material.h" +#include "BKE_modifier.h" +#include "BKE_particle.h" + +#include "RNA_access.h" + +#include "buttons_intern.h" // own include + +int buttons_context(const bContext *C, const char *member, bContextDataResult *result) +{ + Scene *scene= CTX_data_scene(C); + Object *ob= (scene->basact)? scene->basact->object: NULL; + + if(CTX_data_equals(member, "scene")) { + CTX_data_pointer_set(result, &scene->id, &RNA_Scene, scene); + return 1; + } + else if(CTX_data_equals(member, "world")) { + CTX_data_pointer_set(result, &scene->world->id, &RNA_World, scene->world); + return 1; + } + else if(CTX_data_equals(member, "object")) { + CTX_data_pointer_set(result, &ob->id, &RNA_Object, ob); + return 1; + } + else if(CTX_data_equals(member, "mesh")) { + if(ob && ob->type == OB_MESH) { + CTX_data_pointer_set(result, ob->data, &RNA_Mesh, ob->data); + return 1; + } + } + else if(CTX_data_equals(member, "armature")) { + if(ob && ob->type == OB_ARMATURE) { + CTX_data_pointer_set(result, ob->data, &RNA_Armature, ob->data); + return 1; + } + } + else if(CTX_data_equals(member, "lattice")) { + if(ob && ob->type == OB_LATTICE) { + CTX_data_pointer_set(result, ob->data, &RNA_Lattice, ob->data); + return 1; + } + } + else if(CTX_data_equals(member, "curve")) { + if(ob && ob->type == OB_CURVE) { + CTX_data_pointer_set(result, ob->data, &RNA_Curve, ob->data); + return 1; + } + } + else if(CTX_data_equals(member, "meta_ball")) { + if(ob && ob->type == OB_MBALL) { + CTX_data_pointer_set(result, ob->data, &RNA_MetaBall, ob->data); + return 1; + } + } + else if(CTX_data_equals(member, "lamp")) { + if(ob && ob->type == OB_LAMP) { + CTX_data_pointer_set(result, ob->data, &RNA_Lamp, ob->data); + return 1; + } + } + else if(CTX_data_equals(member, "camera")) { + if(ob && ob->type == OB_CAMERA) { + CTX_data_pointer_set(result, ob->data, &RNA_Camera, ob->data); + return 1; + } + } + else if(CTX_data_equals(member, "material")) { + if(ob && ob->type && (ob->typeactcol); + CTX_data_pointer_set(result, &ma->id, &RNA_Material, ma); + return 1; + } + } + else if(CTX_data_equals(member, "texture")) { + if(ob && ob->type && (ob->typeactcol); + + if(ma) { + MTex *mtex= ma->mtex[(int)ma->texact]; + + if(mtex->tex) { + CTX_data_pointer_set(result, &mtex->tex->id, &RNA_Texture, mtex->tex); + return 1; + } + } + } + } + else if(CTX_data_equals(member, "material_slot")) { + } + else if(CTX_data_equals(member, "texture_slot")) { + if(ob && ob->type && (ob->typeactcol); + + if(ma) { + MTex *mtex= ma->mtex[(int)ma->texact]; + + CTX_data_pointer_set(result, &ma->id, &RNA_TextureSlot, mtex); + return 1; + } + } + } + else if(CTX_data_equals(member, "bone")) { + if(ob && ob->type == OB_ARMATURE) { + bArmature *arm= ob->data; + Bone *bone; + + for(bone=arm->bonebase.first; bone; bone=bone->next) { + if(bone->flag & BONE_ACTIVE) { + CTX_data_pointer_set(result, &arm->id, &RNA_Bone, bone); + return 1; + } + } + } + } + else if(CTX_data_equals(member, "particle_system")) { + if(ob) { + ParticleSystem *psys= psys_get_current(ob); + CTX_data_pointer_set(result, &ob->id, &RNA_ParticleSystem, psys); + return 1; + } + } + else if(CTX_data_equals(member, "cloth")) { + if(ob) { + ModifierData *md= modifiers_findByType(ob, eModifierType_Cloth); + CTX_data_pointer_set(result, &ob->id, &RNA_ClothModifier, md); + return 1; + } + } + else if(CTX_data_equals(member, "soft_body")) { + if(ob) { + CTX_data_pointer_set(result, &ob->id, &RNA_SoftBodySettings, ob->soft); + return 1; + } + } + else if(CTX_data_equals(member, "fluid")) { + if(ob) { + ModifierData *md= modifiers_findByType(ob, eModifierType_Fluidsim); + CTX_data_pointer_set(result, &ob->id, &RNA_FluidSimulationModifier, md); + return 1; + } + } + + return 0; +} + diff --git a/source/blender/editors/space_buttons/buttons_intern.h b/source/blender/editors/space_buttons/buttons_intern.h index 9d49a1eeaab..ea1fe7db29e 100644 --- a/source/blender/editors/space_buttons/buttons_intern.h +++ b/source/blender/editors/space_buttons/buttons_intern.h @@ -31,7 +31,7 @@ struct ARegion; struct ARegionType; struct bContext; - +struct bContextDataResult; /* buts->scaflag */ #define BUTS_SENS_SEL 1 @@ -48,8 +48,11 @@ struct bContext; /* internal exports only */ -/* image_header.c */ +/* buttons_header.c */ void buttons_header_buttons(const struct bContext *C, struct ARegion *ar); +/* buttons_context.c */ +int buttons_context(const struct bContext *C, const char *member, struct bContextDataResult *result); + #endif /* ED_BUTTONS_INTERN_H */ diff --git a/source/blender/editors/space_buttons/space_buttons.c b/source/blender/editors/space_buttons/space_buttons.c index 9f5e0f5974a..838316fd4af 100644 --- a/source/blender/editors/space_buttons/space_buttons.c +++ b/source/blender/editors/space_buttons/space_buttons.c @@ -272,6 +272,7 @@ void ED_spacetype_buttons(void) st->duplicate= buttons_duplicate; st->operatortypes= buttons_operatortypes; st->keymap= buttons_keymap; + st->context= buttons_context; /* regions: main window */ art= MEM_callocN(sizeof(ARegionType), "spacetype buttons region"); From 9ed9acaf9a5a64a3471b4eca6a9e91bb8f0bc23e Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Wed, 3 Jun 2009 00:04:48 +0000 Subject: [PATCH 08/35] UI: * Implemented scale_x/scale_y for layouts. * Implemented left/right/center/expand alignment for row layouts. --- source/blender/editors/include/UI_interface.h | 13 +- .../editors/interface/interface_layout.c | 172 +++++++++++++----- source/blender/makesrna/intern/rna_ui.c | 26 ++- 3 files changed, 157 insertions(+), 54 deletions(-) diff --git a/source/blender/editors/include/UI_interface.h b/source/blender/editors/include/UI_interface.h index e66c4ef827b..45f26ecdcab 100644 --- a/source/blender/editors/include/UI_interface.h +++ b/source/blender/editors/include/UI_interface.h @@ -556,9 +556,10 @@ uiBut *uiDefMenuTogR(uiBlock *block, struct PointerRNA *ptr, char *propname, cha #define UI_UNIT_X 20 #define UI_UNIT_Y 20 -#define UI_LAYOUT_ALIGN_LEFT 0 -#define UI_LAYOUT_ALIGN_CENTER 1 -#define UI_LAYOUT_ALIGN_RIGHT 2 +#define UI_LAYOUT_ALIGN_EXPAND 0 +#define UI_LAYOUT_ALIGN_LEFT 1 +#define UI_LAYOUT_ALIGN_CENTER 2 +#define UI_LAYOUT_ALIGN_RIGHT 3 uiLayout *uiBlockLayout(uiBlock *block, int dir, int type, int x, int y, int size, int em, struct uiStyle *style); void uiBlockSetCurLayout(uiBlock *block, uiLayout *layout); @@ -575,14 +576,16 @@ void uiLayoutSetEnabled(uiLayout *layout, int enabled); void uiLayoutSetRedAlert(uiLayout *layout, int redalert); void uiLayoutSetAlignment(uiLayout *layout, int alignment); void uiLayoutSetKeepAspect(uiLayout *layout, int keepaspect); -void uiLayoutSetScale(uiLayout *layout, float scale); +void uiLayoutSetScaleX(uiLayout *layout, float scale); +void uiLayoutSetScaleY(uiLayout *layout, float scale); int uiLayoutGetActive(uiLayout *layout); int uiLayoutGetEnabled(uiLayout *layout); int uiLayoutGetRedAlert(uiLayout *layout); int uiLayoutGetAlignment(uiLayout *layout); int uiLayoutGetKeepAspect(uiLayout *layout); -float uiLayoutGetScale(uiLayout *layout); +float uiLayoutGetScaleX(uiLayout *layout); +float uiLayoutGetScaleY(uiLayout *layout); /* layout specifiers */ uiLayout *uiLayoutRow(uiLayout *layout, int align); diff --git a/source/blender/editors/interface/interface_layout.c b/source/blender/editors/interface/interface_layout.c index 2e123c28339..bb2be0da874 100644 --- a/source/blender/editors/interface/interface_layout.c +++ b/source/blender/editors/interface/interface_layout.c @@ -115,6 +115,7 @@ typedef enum uiItemType { typedef struct uiItem { void *next, *prev; uiItemType type; + int flag; } uiItem; typedef struct uiButtonItem { @@ -130,7 +131,7 @@ struct uiLayout { ListBase items; int x, y, w, h; - float scale; + float scale[2]; short space; char align; char active; @@ -177,26 +178,29 @@ static char *ui_item_name_add_colon(char *name, char namestr[UI_MAX_NAME_STR]) return name; } -#define UI_FIT_EXPAND 1 - -static int ui_item_fit(int item, int pos, int all, int available, int spacing, int last, int flag) +static int ui_item_fit(int item, int pos, int all, int available, int last, int alignment, int *offset) { /* available == 0 is unlimited */ - - if(available != 0 && all > available-spacing) { + if(available == 0) + return item; + + if(offset) + *offset= 0; + + if(all > available) { /* contents is bigger than available space */ if(last) return available-pos; else - return (item*(available-spacing))/all; + return (item*available)/all; } else { /* contents is smaller or equal to available space */ - if(available != 0 && (flag & UI_FIT_EXPAND)) { + if(alignment == UI_LAYOUT_ALIGN_EXPAND) { if(last) return available-pos; else - return (item*(available-spacing))/all; + return (item*available)/all; } else return item; @@ -655,9 +659,6 @@ static void ui_item_rna_size(uiLayout *layout, char *name, int icon, PropertyRNA subtype= RNA_property_subtype(prop); len= RNA_property_array_length(prop); - if(ELEM(type, PROP_STRING, PROP_ENUM)) - w += 10*UI_UNIT_X; - /* increase height for arrays */ if(index == RNA_NO_INDEX && len > 0) { if(strcmp(name, "") == 0 && icon == 0) @@ -1033,14 +1034,22 @@ static void ui_litem_estimate_row(uiLayout *litem) } } +static int ui_litem_min_width(int itemw) +{ + return MIN2(UI_UNIT_X, itemw); +} + static void ui_litem_layout_row(uiLayout *litem) { uiItem *item; - int neww, itemw, itemh, x, y, w, tot= 0, totw= 0, extra=0, available=0; + int x, y, w, tot, totw, neww, itemw, minw, itemh, offset; + int fixedw, freew, fixedx, freex, flag= 0, lastw= 0; x= litem->x; y= litem->y; w= litem->w; + totw= 0; + tot= 0; for(item=litem->items.first; item; item=item->next) { ui_item_size(item, &itemw, &itemh); @@ -1051,40 +1060,81 @@ static void ui_litem_layout_row(uiLayout *litem) if(totw == 0) return; - /* two step to enforce minimum button with .. could be better */ - for(item=litem->items.first; item; item=item->next) { - ui_item_size(item, &itemw, &itemh); + if(w != 0) + w -= (tot-1)*litem->space; + fixedw= 0; - itemw= ui_item_fit(itemw, x-litem->x, totw, w, (tot-1)*litem->space, !item->next, UI_FIT_EXPAND); - x += itemw; + /* keep clamping items to fixed minimum size until all are done */ + do { + freew= 0; + x= 0; + flag= 0; - if(itemw < UI_UNIT_X) - extra += UI_UNIT_X - itemw; - else - available += itemw - UI_UNIT_X; + for(item=litem->items.first; item; item=item->next) { + if(item->flag) + continue; - if(item->next) - x += litem->space; - } + ui_item_size(item, &itemw, &itemh); + minw= ui_litem_min_width(itemw); + if(w - lastw > 0) + neww= ui_item_fit(itemw, x, totw, w-lastw, !item->next, litem->alignment, NULL); + else + neww= 0; /* no space left, all will need clamping to minimum size */ + + x += neww; + + if(neww < minw && w != 0) { + /* fixed size */ + item->flag= 1; + fixedw += minw; + flag= 1; + totw -= itemw; + } + else { + /* keep free size */ + item->flag= 0; + freew += itemw; + } + } + + lastw= fixedw; + } while(flag); + + freex= 0; + fixedx= 0; x= litem->x; for(item=litem->items.first; item; item=item->next) { ui_item_size(item, &itemw, &itemh); + minw= ui_litem_min_width(itemw); - neww= ui_item_fit(itemw, x-litem->x, totw, w, (tot-1)*litem->space, !item->next, UI_FIT_EXPAND); - if(neww < UI_UNIT_X) { - if(item->next) - itemw= UI_UNIT_X; - else - itemw= litem->w - (x-litem->x); + if(item->flag) { + /* fixed minimum size items */ + itemw= ui_item_fit(minw, fixedx, fixedw, MIN2(w, fixedw), !item->next, litem->alignment, NULL); + fixedx += itemw; + } + else { + /* free size item */ + itemw= ui_item_fit(itemw, freex, freew, w-fixedw, !item->next, litem->alignment, NULL); + freex += itemw; } - else - itemw= ui_item_fit(itemw, x-litem->x, totw, w-extra, (tot-1)*litem->space, !item->next, UI_FIT_EXPAND); - ui_item_position(item, x, y-itemh, itemw, itemh); + /* align right/center */ + offset= 0; + if(litem->alignment == UI_LAYOUT_ALIGN_RIGHT) { + if(fixedw == 0 && freew < w-fixedw) + offset= (w - fixedw) - freew; + } + else if(litem->alignment == UI_LAYOUT_ALIGN_CENTER) { + if(fixedw == 0 && freew < w-fixedw) + offset= ((w - fixedw) - freew)/2; + } + + /* position item */ + ui_item_position(item, x+offset, y-itemh, itemw, itemh); + x += itemw; - if(item->next) x += litem->space; } @@ -1263,7 +1313,7 @@ static void ui_litem_layout_column_flow(uiLayout *litem) uiLayoutItemFlow *flow= (uiLayoutItemFlow*)litem; uiItem *item; int col, x, y, w, emh, emy, miny, itemw, itemh; - int toth, totitem; + int toth, totitem, offset; /* compute max needed width and total height */ toth= 0; @@ -1280,18 +1330,18 @@ static void ui_litem_layout_column_flow(uiLayout *litem) emy= 0; miny= 0; - w= litem->w; + w= litem->w - (flow->totcol-1)*style->columnspace; emh= toth/flow->totcol; /* create column per column */ col= 0; for(item=litem->items.first; item; item=item->next) { ui_item_size(item, NULL, &itemh); - itemw= ui_item_fit(1, x-litem->x, flow->totcol, w, (flow->totcol-1)*style->columnspace, col == flow->totcol-1, UI_FIT_EXPAND); + itemw= ui_item_fit(1, x-litem->x, flow->totcol, w, col == flow->totcol-1, litem->alignment, &offset); y -= itemh; emy -= itemh; - ui_item_position(item, x, y, itemw, itemh); + ui_item_position(item, x+offset, y, itemw, itemh); y -= style->buttonspacey; miny= MIN2(miny, y); @@ -1578,9 +1628,14 @@ void uiLayoutSetAlignment(uiLayout *layout, int alignment) layout->alignment= alignment; } -void uiLayoutSetScale(uiLayout *layout, float scale) +void uiLayoutSetScaleX(uiLayout *layout, float scale) { - layout->scale= scale; + layout->scale[0]= scale; +} + +void uiLayoutSetScaleY(uiLayout *layout, float scale) +{ + layout->scale[1]= scale; } int uiLayoutGetActive(uiLayout *layout) @@ -1608,13 +1663,41 @@ int uiLayoutGetAlignment(uiLayout *layout) return layout->alignment; } -float uiLayoutGetScale(uiLayout *layout) +float uiLayoutGetScaleX(uiLayout *layout) { - return layout->scale; + return layout->scale[0]; +} + +float uiLayoutGetScaleY(uiLayout *layout) +{ + return layout->scale[0]; } /********************** Layout *******************/ +static void ui_item_scale(uiLayout *litem, float scale[2]) +{ + uiItem *item; + int x, y, w, h; + + for(item=litem->items.last; item; item=item->prev) { + ui_item_size(item, &w, &h); + ui_item_offset(item, &x, &y); + + if(scale[0] != 0.0f) { + x *= scale[0]; + w *= scale[0]; + } + + if(scale[1] != 0.0f) { + y *= scale[1]; + h *= scale[1]; + } + + ui_item_position(item, x, y, w, h); + } +} + static void ui_item_estimate(uiItem *item) { uiItem *subitem; @@ -1628,6 +1711,9 @@ static void ui_item_estimate(uiItem *item) if(litem->items.first == NULL) return; + if(litem->scale[0] != 0.0f || litem->scale[1] != 0.0f) + ui_item_scale(litem, litem->scale); + switch(litem->item.type) { case ITEM_LAYOUT_COLUMN: ui_litem_estimate_column(litem); diff --git a/source/blender/makesrna/intern/rna_ui.c b/source/blender/makesrna/intern/rna_ui.c index 7ca0c586d47..796817e1018 100644 --- a/source/blender/makesrna/intern/rna_ui.c +++ b/source/blender/makesrna/intern/rna_ui.c @@ -458,14 +458,24 @@ static void rna_UILayout_alignment_set(struct PointerRNA *ptr, int value) return uiLayoutSetAlignment(ptr->data, value); } -static float rna_UILayout_scale_get(struct PointerRNA *ptr) +static float rna_UILayout_scale_x_get(struct PointerRNA *ptr) { - return uiLayoutGetScale(ptr->data); + return uiLayoutGetScaleX(ptr->data); } -static void rna_UILayout_scale_set(struct PointerRNA *ptr, float value) +static void rna_UILayout_scale_x_set(struct PointerRNA *ptr, float value) { - return uiLayoutSetScale(ptr->data, value); + return uiLayoutSetScaleX(ptr->data, value); +} + +static float rna_UILayout_scale_y_get(struct PointerRNA *ptr) +{ + return uiLayoutGetScaleY(ptr->data); +} + +static void rna_UILayout_scale_y_set(struct PointerRNA *ptr, float value) +{ + return uiLayoutSetScaleY(ptr->data, value); } #else @@ -476,6 +486,7 @@ static void rna_def_ui_layout(BlenderRNA *brna) PropertyRNA *prop; static EnumPropertyItem alignment_items[] = { + {UI_LAYOUT_ALIGN_EXPAND, "EXPAND", "Expand", ""}, {UI_LAYOUT_ALIGN_LEFT, "LEFT", "Left", ""}, {UI_LAYOUT_ALIGN_CENTER, "CENTER", "Center", ""}, {UI_LAYOUT_ALIGN_RIGHT, "RIGHT", "RIght", ""}, @@ -501,8 +512,11 @@ static void rna_def_ui_layout(BlenderRNA *brna) prop= RNA_def_property(srna, "keep_aspect", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_funcs(prop, "rna_UILayout_keep_aspect_get", "rna_UILayout_keep_aspect_set"); - prop= RNA_def_property(srna, "scale", PROP_FLOAT, PROP_UNSIGNED); - RNA_def_property_float_funcs(prop, "rna_UILayout_scale_get", "rna_UILayout_scale_set", NULL); + prop= RNA_def_property(srna, "scale_x", PROP_FLOAT, PROP_UNSIGNED); + RNA_def_property_float_funcs(prop, "rna_UILayout_scale_x_get", "rna_UILayout_scale_x_set", NULL); + + prop= RNA_def_property(srna, "scale_y", PROP_FLOAT, PROP_UNSIGNED); + RNA_def_property_float_funcs(prop, "rna_UILayout_scale_y_get", "rna_UILayout_scale_y_set", NULL); RNA_api_ui_layout(srna); } From 084be86ea99673eb0f570ed723b235c70b98c7bc Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Wed, 3 Jun 2009 00:09:30 +0000 Subject: [PATCH 09/35] UI: * Make modifier and constraint templates use left/right alignment for buttons in the header. * Added mdef bind operator as an example of how to use local context for a modifier, and add some code I forgot to commit last time to make this system actually work. --- source/blender/editors/include/ED_object.h | 2 +- source/blender/editors/interface/interface.c | 7 + .../editors/interface/interface_handlers.c | 13 + .../editors/interface/interface_templates.c | 325 ++++++------------ source/blender/editors/object/object_intern.h | 1 + .../blender/editors/object/object_modifier.c | 162 +++++++++ source/blender/editors/object/object_ops.c | 1 + 7 files changed, 296 insertions(+), 215 deletions(-) diff --git a/source/blender/editors/include/ED_object.h b/source/blender/editors/include/ED_object.h index 3d0de795778..bfa819632c9 100644 --- a/source/blender/editors/include/ED_object.h +++ b/source/blender/editors/include/ED_object.h @@ -56,7 +56,7 @@ void ED_base_object_free_and_unlink(struct Scene *scene, struct Base *base); void ED_object_apply_obmat(struct Object *ob); /* single object duplicate, if dupflag==0, fully linked, else it uses U.dupflag */ -Base *ED_object_add_duplicate(struct Scene *scene, struct Base *base, int usedupflag); +struct Base *ED_object_add_duplicate(struct Scene *scene, struct Base *base, int usedupflag); /* bitflags for enter/exit editmode */ diff --git a/source/blender/editors/interface/interface.c b/source/blender/editors/interface/interface.c index 4fb2f27a618..69ee0d470d0 100644 --- a/source/blender/editors/interface/interface.c +++ b/source/blender/editors/interface/interface.c @@ -537,10 +537,17 @@ void uiEndBlock(const bContext *C, uiBlock *block) /* temp? Proper check for greying out */ if(but->optype) { wmOperatorType *ot= but->optype; + + if(but->context) + CTX_store_set((bContext*)C, but->context); + if(ot==NULL || (ot->poll && ot->poll((bContext *)C)==0)) { but->flag |= UI_BUT_DISABLED; but->lock = 1; } + + if(but->context) + CTX_store_set((bContext*)C, NULL); } /* only update soft range while not editing */ diff --git a/source/blender/editors/interface/interface_handlers.c b/source/blender/editors/interface/interface_handlers.c index e0e58e61752..5617874ab0e 100644 --- a/source/blender/editors/interface/interface_handlers.c +++ b/source/blender/editors/interface/interface_handlers.c @@ -160,6 +160,8 @@ typedef struct uiAfterFunc { PointerRNA rnapoin; PropertyRNA *rnaprop; + + bContextStore *context; } uiAfterFunc; static void button_activate_state(bContext *C, uiBut *but, uiHandleButtonState state); @@ -252,6 +254,9 @@ static void ui_apply_but_func(bContext *C, uiBut *but) after->rnapoin= but->rnapoin; after->rnaprop= but->rnaprop; + if(but->context) + after->context= CTX_store_copy(but->context); + but->optype= NULL; but->opcontext= 0; but->opptr= NULL; @@ -273,6 +278,9 @@ static void ui_apply_but_funcs_after(bContext *C) after= *afterf; /* copy to avoid memleak on exit() */ BLI_freelinkN(&funcs, afterf); + if(after.context) + CTX_store_set(C, after.context); + if(after.func) after.func(C, after.func_arg1, after.func_arg2); if(after.funcN) @@ -292,6 +300,11 @@ static void ui_apply_but_funcs_after(bContext *C) if(after.rnapoin.data) RNA_property_update(C, &after.rnapoin, after.rnaprop); + + if(after.context) { + CTX_store_set(C, NULL); + CTX_store_free(after.context); + } } } diff --git a/source/blender/editors/interface/interface_templates.c b/source/blender/editors/interface/interface_templates.c index cd905a9657b..4df5f99f224 100644 --- a/source/blender/editors/interface/interface_templates.c +++ b/source/blender/editors/interface/interface_templates.c @@ -240,33 +240,16 @@ void uiTemplateHeaderID(uiLayout *layout, bContext *C, PointerRNA *ptr, char *pr #define ERROR_LIBDATA_MESSAGE "Can't edit external libdata" -#define B_NOP 0 -#define B_MODIFIER_RECALC 1 -#define B_MODIFIER_REDRAW 2 -#define B_CHANGEDEP 3 -#define B_ARM_RECALCDATA 4 - #include -#include "DNA_armature_types.h" -#include "DNA_curve_types.h" #include "DNA_object_force.h" #include "DNA_object_types.h" -#include "DNA_mesh_types.h" -#include "DNA_meshdata_types.h" #include "DNA_modifier_types.h" -#include "DNA_particle_types.h" #include "DNA_scene_types.h" -#include "BKE_bmesh.h" -#include "BKE_curve.h" #include "BKE_depsgraph.h" #include "BKE_DerivedMesh.h" -#include "BKE_displist.h" #include "BKE_global.h" -#include "BKE_lattice.h" -#include "BKE_main.h" -#include "BKE_mesh.h" #include "BKE_modifier.h" #include "BKE_object.h" #include "BKE_particle.h" @@ -280,33 +263,20 @@ void uiTemplateHeaderID(uiLayout *layout, bContext *C, PointerRNA *ptr, char *pr #include "ED_object.h" -void do_modifier_panels(bContext *C, void *arg, int event) -{ - Scene *scene= CTX_data_scene(C); - Object *ob = CTX_data_active_object(C); - - switch(event) { - case B_MODIFIER_REDRAW: - WM_event_add_notifier(C, NC_OBJECT|ND_MODIFIER, ob); - break; - - case B_MODIFIER_RECALC: - WM_event_add_notifier(C, NC_OBJECT|ND_MODIFIER, ob); - DAG_object_flush_update(scene, ob, OB_RECALC_DATA); - object_handle_update(scene, ob); - // XXX countall(); - break; - } -} - static void modifiers_del(bContext *C, void *ob_v, void *md_v) { + Scene *scene= CTX_data_scene(C); + Object *ob= ob_v; ReportList reports; BKE_reports_init(&reports, RPT_STORE); - if(ED_object_modifier_delete(&reports, ob_v, md_v)) + if(ED_object_modifier_delete(&reports, ob_v, md_v)) { + WM_event_add_notifier(C, NC_OBJECT|ND_MODIFIER, ob); + DAG_object_flush_update(scene, ob, OB_RECALC_DATA); + ED_undo_push(C, "Delete modifier"); + } else uiPupMenuReports(C, &reports); @@ -315,12 +285,18 @@ static void modifiers_del(bContext *C, void *ob_v, void *md_v) static void modifiers_moveUp(bContext *C, void *ob_v, void *md_v) { + Scene *scene= CTX_data_scene(C); + Object *ob= ob_v; ReportList reports; BKE_reports_init(&reports, RPT_STORE); - if(ED_object_modifier_move_up(&reports, ob_v, md_v)) + if(ED_object_modifier_move_up(&reports, ob_v, md_v)) { + WM_event_add_notifier(C, NC_OBJECT|ND_MODIFIER, ob); + DAG_object_flush_update(scene, ob, OB_RECALC_DATA); + ED_undo_push(C, "Move modifier"); + } else uiPupMenuReports(C, &reports); @@ -329,12 +305,18 @@ static void modifiers_moveUp(bContext *C, void *ob_v, void *md_v) static void modifiers_moveDown(bContext *C, void *ob_v, void *md_v) { + Scene *scene= CTX_data_scene(C); + Object *ob= ob_v; ReportList reports; BKE_reports_init(&reports, RPT_STORE); - if(ED_object_modifier_move_down(&reports, ob_v, md_v)) + if(ED_object_modifier_move_down(&reports, ob_v, md_v)) { + WM_event_add_notifier(C, NC_OBJECT|ND_MODIFIER, ob); + DAG_object_flush_update(scene, ob, OB_RECALC_DATA); + ED_undo_push(C, "Move modifier"); + } else uiPupMenuReports(C, &reports); @@ -344,12 +326,17 @@ static void modifiers_moveDown(bContext *C, void *ob_v, void *md_v) static void modifiers_convertParticles(bContext *C, void *obv, void *mdv) { Scene *scene= CTX_data_scene(C); + Object *ob= obv; ReportList reports; BKE_reports_init(&reports, RPT_STORE); - if(ED_object_modifier_convert(&reports, scene, obv, mdv)) + if(ED_object_modifier_convert(&reports, scene, obv, mdv)) { + WM_event_add_notifier(C, NC_OBJECT|ND_MODIFIER, ob); + DAG_object_flush_update(scene, ob, OB_RECALC_DATA); + ED_undo_push(C, "Convert particles to mesh object(s)."); + } else uiPupMenuReports(C, &reports); @@ -359,12 +346,17 @@ static void modifiers_convertParticles(bContext *C, void *obv, void *mdv) static void modifiers_applyModifier(bContext *C, void *obv, void *mdv) { Scene *scene= CTX_data_scene(C); + Object *ob= obv; ReportList reports; BKE_reports_init(&reports, RPT_STORE); - if(ED_object_modifier_apply(&reports, scene, obv, mdv)) + if(ED_object_modifier_apply(&reports, scene, obv, mdv)) { + WM_event_add_notifier(C, NC_OBJECT|ND_MODIFIER, ob); + DAG_object_flush_update(scene, ob, OB_RECALC_DATA); + ED_undo_push(C, "Apply modifier"); + } else uiPupMenuReports(C, &reports); @@ -373,12 +365,17 @@ static void modifiers_applyModifier(bContext *C, void *obv, void *mdv) static void modifiers_copyModifier(bContext *C, void *ob_v, void *md_v) { + Scene *scene= CTX_data_scene(C); + Object *ob= ob_v; ReportList reports; BKE_reports_init(&reports, RPT_STORE); - if(ED_object_modifier_copy(&reports, ob_v, md_v)) + if(ED_object_modifier_copy(&reports, ob_v, md_v)) { + WM_event_add_notifier(C, NC_OBJECT|ND_MODIFIER, ob); + DAG_object_flush_update(scene, ob, OB_RECALC_DATA); ED_undo_push(C, "Copy modifier"); + } else uiPupMenuReports(C, &reports); @@ -387,21 +384,27 @@ static void modifiers_copyModifier(bContext *C, void *ob_v, void *md_v) static void modifiers_setOnCage(bContext *C, void *ob_v, void *md_v) { + Scene *scene= CTX_data_scene(C); Object *ob = ob_v; ModifierData *md; int i, cageIndex = modifiers_getCageIndex(ob, NULL ); - for( i = 0, md=ob->modifiers.first; md; ++i, md=md->next ) - if( md == md_v ) { - if( i >= cageIndex ) + for(i = 0, md=ob->modifiers.first; md; ++i, md=md->next) { + if(md == md_v) { + if(i >= cageIndex) md->mode ^= eModifierMode_OnCage; break; } + } + + WM_event_add_notifier(C, NC_OBJECT|ND_MODIFIER, ob); + DAG_object_flush_update(scene, ob, OB_RECALC_DATA); } static void modifiers_convertToReal(bContext *C, void *ob_v, void *md_v) { + Scene *scene= CTX_data_scene(C); Object *ob = ob_v; ModifierData *md = md_v; ModifierData *nmd = modifier_new(md->type); @@ -413,169 +416,56 @@ static void modifiers_convertToReal(bContext *C, void *ob_v, void *md_v) ob->partype = PAROBJECT; + WM_event_add_notifier(C, NC_OBJECT|ND_MODIFIER, ob); + DAG_object_flush_update(scene, ob, OB_RECALC_DATA); + ED_undo_push(C, "Modifier convert to real"); } -#if 0 -static void modifiers_clearHookOffset(bContext *C, void *ob_v, void *md_v) +static int modifier_can_delete(ModifierData *md) { - Object *ob = ob_v; - ModifierData *md = md_v; - HookModifierData *hmd = (HookModifierData*) md; - - if (hmd->object) { - Mat4Invert(hmd->object->imat, hmd->object->obmat); - Mat4MulSerie(hmd->parentinv, hmd->object->imat, ob->obmat, NULL, NULL, NULL, NULL, NULL, NULL); - ED_undo_push(C, "Clear hook offset"); - } -} + // deletion over the deflection panel + // fluid particle modifier can't be deleted here -static void modifiers_cursorHookCenter(bContext *C, void *ob_v, void *md_v) -{ - /* XXX - Object *ob = ob_v; - ModifierData *md = md_v; - HookModifierData *hmd = (HookModifierData*) md; - - if(G.vd) { - float *curs = give_cursor(); - float bmat[3][3], imat[3][3]; - - where_is_object(ob); - - Mat3CpyMat4(bmat, ob->obmat); - Mat3Inv(imat, bmat); - - curs= give_cursor(); - hmd->cent[0]= curs[0]-ob->obmat[3][0]; - hmd->cent[1]= curs[1]-ob->obmat[3][1]; - hmd->cent[2]= curs[2]-ob->obmat[3][2]; - Mat3MulVecfl(imat, hmd->cent); - - ED_undo_push(C, "Hook cursor center"); - }*/ -} - -static void modifiers_selectHook(bContext *C, void *ob_v, void *md_v) -{ - /* XXX ModifierData *md = md_v; - HookModifierData *hmd = (HookModifierData*) md; - - hook_select(hmd);*/ -} - -static void modifiers_reassignHook(bContext *C, void *ob_v, void *md_v) -{ - /* XXX ModifierData *md = md_v; - HookModifierData *hmd = (HookModifierData*) md; - float cent[3]; - int *indexar, tot, ok; - char name[32]; - - ok= hook_getIndexArray(&tot, &indexar, name, cent); - - if (!ok) { - uiPupMenuError(C, "Requires selected vertices or active Vertex Group"); - } else { - if (hmd->indexar) { - MEM_freeN(hmd->indexar); - } - - VECCOPY(hmd->cent, cent); - hmd->indexar = indexar; - hmd->totindex = tot; - }*/ -} - -static void modifiers_bindMeshDeform(bContext *C, void *ob_v, void *md_v) -{ - Scene *scene= CTX_data_scene(C); - MeshDeformModifierData *mmd = (MeshDeformModifierData*) md_v; - Object *ob = (Object*)ob_v; - - if(mmd->bindcos) { - if(mmd->bindweights) MEM_freeN(mmd->bindweights); - if(mmd->bindcos) MEM_freeN(mmd->bindcos); - if(mmd->dyngrid) MEM_freeN(mmd->dyngrid); - if(mmd->dyninfluences) MEM_freeN(mmd->dyninfluences); - if(mmd->dynverts) MEM_freeN(mmd->dynverts); - mmd->bindweights= NULL; - mmd->bindcos= NULL; - mmd->dyngrid= NULL; - mmd->dyninfluences= NULL; - mmd->dynverts= NULL; - mmd->totvert= 0; - mmd->totcagevert= 0; - mmd->totinfluence= 0; - } - else { - DerivedMesh *dm; - int mode= mmd->modifier.mode; - - /* force modifier to run, it will call binding routine */ - mmd->needbind= 1; - mmd->modifier.mode |= eModifierMode_Realtime; - - if(ob->type == OB_MESH) { - dm= mesh_create_derived_view(scene, ob, 0); - dm->release(dm); - } - else if(ob->type == OB_LATTICE) { - lattice_calc_modifiers(scene, ob); - } - else if(ob->type==OB_MBALL) { - makeDispListMBall(scene, ob); - } - else if(ELEM3(ob->type, OB_CURVE, OB_SURF, OB_FONT)) { - makeDispListCurveTypes(scene, ob, 0); - } - - mmd->needbind= 0; - mmd->modifier.mode= mode; - } -} - -void modifiers_explodeFacepa(bContext *C, void *arg1, void *arg2) -{ - ExplodeModifierData *emd=arg1; - - emd->flag |= eExplodeFlag_CalcFaces; -} - -void modifiers_explodeDelVg(bContext *C, void *arg1, void *arg2) -{ - ExplodeModifierData *emd=arg1; - emd->vgroup = 0; -} -#endif - -static int modifier_is_fluid_particles(ModifierData *md) -{ - if(md->type == eModifierType_ParticleSystem) { + if(md->type==eModifierType_Fluidsim) + return 0; + if(md->type==eModifierType_Collision) + return 0; + if(md->type==eModifierType_Surface) + return 0; + if(md->type == eModifierType_ParticleSystem) if(((ParticleSystemModifierData *)md)->psys->part->type == PART_FLUID) - return 1; - } - return 0; + return 0; + + return 1; } static uiLayout *draw_modifier(uiLayout *layout, Object *ob, ModifierData *md, int index, int cageIndex, int lastCageIndex) { ModifierTypeInfo *mti = modifierType_getInfo(md->type); + PointerRNA ptr; uiBut *but; uiBlock *block; - uiLayout *column, *row, *result= NULL; + uiLayout *column, *row, *subrow, *result= NULL; int isVirtual = md->mode&eModifierMode_Virtual; - int x = 0, y = 0; // XXX , color = md->error?TH_REDALERT:TH_BUT_NEUTRAL; + // XXX short color = md->error?TH_REDALERT:TH_BUT_NEUTRAL; short width = 295, buttonWidth = width-120-10; char str[128]; + RNA_pointer_create(&ob->id, &RNA_Modifier, md, &ptr); + column= uiLayoutColumn(layout, 1); + uiLayoutSetContextPointer(column, "modifier", &ptr); /* rounded header */ /* XXX uiBlockSetCol(block, color); */ /* roundbox 4 free variables: corner-rounding, nop, roundbox type, shade */ - block= uiLayoutFreeBlock(uiLayoutBox(column)); - uiBlockSetHandleFunc(block, do_modifier_panels, NULL); + + row= uiLayoutRow(uiLayoutBox(column), 0); + block= uiLayoutGetBlock(row); + + subrow= uiLayoutRow(row, 0); + uiLayoutSetAlignment(subrow, UI_LAYOUT_ALIGN_LEFT); //uiDefBut(block, ROUNDBOX, 0, "", x-10, y-4, width, 25, NULL, 7.0, 0.0, // (!isVirtual && (md->mode&eModifierMode_Expanded))?3:15, 20, ""); @@ -584,27 +474,27 @@ static uiLayout *draw_modifier(uiLayout *layout, Object *ob, ModifierData *md, i /* open/close icon */ if (!isVirtual) { uiBlockSetEmboss(block, UI_EMBOSSN); - uiDefIconButBitI(block, ICONTOG, eModifierMode_Expanded, B_MODIFIER_REDRAW, ICON_TRIA_RIGHT, x-10, y-2, 20, 20, &md->mode, 0.0, 0.0, 0.0, 0.0, "Collapse/Expand Modifier"); + uiDefIconButBitI(block, ICONTOG, eModifierMode_Expanded, 0, ICON_TRIA_RIGHT, 0, 0, UI_UNIT_X, UI_UNIT_Y, &md->mode, 0.0, 0.0, 0.0, 0.0, "Collapse/Expand Modifier"); } uiBlockSetEmboss(block, UI_EMBOSS); if (isVirtual) { sprintf(str, "%s parent deform", md->name); - uiDefBut(block, LABEL, 0, str, x+10, y-1, width-110, 19, NULL, 0.0, 0.0, 0.0, 0.0, "Modifier name"); + uiDefBut(block, LABEL, 0, str, 0, 0, 185, UI_UNIT_Y, NULL, 0.0, 0.0, 0.0, 0.0, "Modifier name"); - but = uiDefBut(block, BUT, B_MODIFIER_RECALC, "Make Real", x+width-100, y, 80, 16, NULL, 0.0, 0.0, 0.0, 0.0, "Convert virtual modifier to a real modifier"); + but = uiDefBut(block, BUT, 0, "Make Real", 0, 0, 80, 16, NULL, 0.0, 0.0, 0.0, 0.0, "Convert virtual modifier to a real modifier"); uiButSetFunc(but, modifiers_convertToReal, ob, md); } else { uiBlockBeginAlign(block); - uiDefBut(block, TEX, B_MODIFIER_REDRAW, "", x+10, y-1, buttonWidth-60, 19, md->name, 0.0, sizeof(md->name)-1, 0.0, 0.0, "Modifier name"); + uiDefBut(block, TEX, 0, "", 0, 0, buttonWidth-60, UI_UNIT_Y, md->name, 0.0, sizeof(md->name)-1, 0.0, 0.0, "Modifier name"); /* Softbody not allowed in this situation, enforce! */ if (((md->type!=eModifierType_Softbody && md->type!=eModifierType_Collision) || !(ob->pd && ob->pd->deflect)) && (md->type!=eModifierType_Surface)) { - uiDefIconButBitI(block, TOG, eModifierMode_Render, B_MODIFIER_RECALC, ICON_SCENE, x+10+buttonWidth-60, y-1, 19, 19,&md->mode, 0, 0, 1, 0, "Enable modifier during rendering"); - but= uiDefIconButBitI(block, TOG, eModifierMode_Realtime, B_MODIFIER_RECALC, ICON_VIEW3D, x+10+buttonWidth-40, y-1, 19, 19,&md->mode, 0, 0, 1, 0, "Enable modifier during interactive display"); + uiDefIconButBitI(block, TOG, eModifierMode_Render, 0, ICON_SCENE, 0, 0, 19, UI_UNIT_Y,&md->mode, 0, 0, 1, 0, "Enable modifier during rendering"); + but= uiDefIconButBitI(block, TOG, eModifierMode_Realtime, 0, ICON_VIEW3D, 0, 0, 19, UI_UNIT_Y,&md->mode, 0, 0, 1, 0, "Enable modifier during interactive display"); if (mti->flags&eModifierTypeFlag_SupportsEditmode) { - uiDefIconButBitI(block, TOG, eModifierMode_Editmode, B_MODIFIER_RECALC, ICON_EDITMODE_HLT, x+10+buttonWidth-20, y-1, 19, 19,&md->mode, 0, 0, 1, 0, "Enable modifier during Editmode (only if enabled for display)"); + uiDefIconButBitI(block, TOG, eModifierMode_Editmode, 0, ICON_EDITMODE_HLT, 0, 0, 19, UI_UNIT_Y,&md->mode, 0, 0, 1, 0, "Enable modifier during Editmode (only if enabled for display)"); } } uiBlockEndAlign(block); @@ -625,26 +515,28 @@ static uiLayout *draw_modifier(uiLayout *layout, Object *ob, ModifierData *md, i icon = ICON_BLANK1; } /* XXX uiBlockSetCol(block, color); */ - but = uiDefIconBut(block, BUT, B_MODIFIER_RECALC, icon, x+width-105, y, 16, 16, NULL, 0.0, 0.0, 0.0, 0.0, "Apply modifier to editing cage during Editmode"); + but = uiDefIconBut(block, BUT, 0, icon, 0, 0, 16, 16, NULL, 0.0, 0.0, 0.0, 0.0, "Apply modifier to editing cage during Editmode"); uiButSetFunc(but, modifiers_setOnCage, ob, md); /* XXX uiBlockSetCol(block, TH_AUTO); */ } + } + subrow= uiLayoutRow(row, 0); + uiLayoutSetAlignment(subrow, UI_LAYOUT_ALIGN_RIGHT); + + if(!isVirtual) { /* XXX uiBlockSetCol(block, TH_BUT_ACTION); */ - but = uiDefIconBut(block, BUT, B_MODIFIER_RECALC, VICON_MOVE_UP, x+width-75, y, 16, 16, NULL, 0.0, 0.0, 0.0, 0.0, "Move modifier up in stack"); + but = uiDefIconBut(block, BUT, 0, VICON_MOVE_UP, 0, 0, 16, 16, NULL, 0.0, 0.0, 0.0, 0.0, "Move modifier up in stack"); uiButSetFunc(but, modifiers_moveUp, ob, md); - but = uiDefIconBut(block, BUT, B_MODIFIER_RECALC, VICON_MOVE_DOWN, x+width-75+20, y, 16, 16, NULL, 0.0, 0.0, 0.0, 0.0, "Move modifier down in stack"); + but = uiDefIconBut(block, BUT, 0, VICON_MOVE_DOWN, 0, 0, 16, 16, NULL, 0.0, 0.0, 0.0, 0.0, "Move modifier down in stack"); uiButSetFunc(but, modifiers_moveDown, ob, md); uiBlockSetEmboss(block, UI_EMBOSSN); - // deletion over the deflection panel - // fluid particle modifier can't be deleted here - if(md->type!=eModifierType_Fluidsim && md->type!=eModifierType_Collision && md->type!=eModifierType_Surface && !modifier_is_fluid_particles(md)) - { - but = uiDefIconBut(block, BUT, B_MODIFIER_RECALC, VICON_X, x+width-70+40, y, 16, 16, NULL, 0.0, 0.0, 0.0, 0.0, "Delete modifier"); + if(modifier_can_delete(md)) { + but = uiDefIconBut(block, BUT, 0, VICON_X, 0, 0, 16, 16, NULL, 0.0, 0.0, 0.0, 0.0, "Delete modifier"); uiButSetFunc(but, modifiers_del, ob, md); } /* XXX uiBlockSetCol(block, TH_AUTO); */ @@ -653,15 +545,11 @@ static uiLayout *draw_modifier(uiLayout *layout, Object *ob, ModifierData *md, i uiBlockSetEmboss(block, UI_EMBOSS); if(!isVirtual && (md->mode&eModifierMode_Expanded)) { - int cy = y - 8; - int lx = x + width - 60 - 15; uiLayout *box; box= uiLayoutBox(column); row= uiLayoutRow(box, 1); - y -= 18; - if (!isVirtual && (md->type!=eModifierType_Collision) && (md->type!=eModifierType_Surface)) { uiBlockSetButLock(block, object_data_is_libdata(ob), ERROR_LIBDATA_MESSAGE); /* only here obdata, the rest of modifiers is ob level */ @@ -670,13 +558,13 @@ static uiLayout *draw_modifier(uiLayout *layout, Object *ob, ModifierData *md, i if(!(G.f & G_PARTICLEEDIT)) { if(ELEM3(psys->part->draw_as, PART_DRAW_PATH, PART_DRAW_GR, PART_DRAW_OB) && psys->pathcache) { - but = uiDefBut(block, BUT, B_MODIFIER_RECALC, "Convert", lx,(cy-=19),60,19, 0, 0, 0, 0, 0, "Convert the current particles to a mesh object"); + but = uiDefBut(block, BUT, 0, "Convert", 0,0,60,19, 0, 0, 0, 0, 0, "Convert the current particles to a mesh object"); uiButSetFunc(but, modifiers_convertParticles, ob, md); } } } else{ - but = uiDefBut(block, BUT, B_MODIFIER_RECALC, "Apply", lx,(cy-=19),60,19, 0, 0, 0, 0, 0, "Apply the current modifier and remove from the stack"); + but = uiDefBut(block, BUT, 0, "Apply", 0,0,60,19, 0, 0, 0, 0, 0, "Apply the current modifier and remove from the stack"); uiButSetFunc(but, modifiers_applyModifier, ob, md); } @@ -684,16 +572,13 @@ static uiLayout *draw_modifier(uiLayout *layout, Object *ob, ModifierData *md, i uiBlockSetButLock(block, ob && ob->id.lib, ERROR_LIBDATA_MESSAGE); if (md->type!=eModifierType_Fluidsim && md->type!=eModifierType_Softbody && md->type!=eModifierType_ParticleSystem && (md->type!=eModifierType_Cloth)) { - but = uiDefBut(block, BUT, B_MODIFIER_RECALC, "Copy", lx,(cy-=19),60,19, 0, 0, 0, 0, 0, "Duplicate the current modifier at the same position in the stack"); + but = uiDefBut(block, BUT, 0, "Copy", 0,0,60,19, 0, 0, 0, 0, 0, "Duplicate the current modifier at the same position in the stack"); uiButSetFunc(but, modifiers_copyModifier, ob, md); } } result= uiLayoutColumn(box, 0); block= uiLayoutFreeBlock(box); - - lx = x + 10; - cy = y + 10 - 1; } if (md->error) { @@ -886,7 +771,7 @@ static void draw_constraint_spaceselect (uiBlock *block, bConstraint *con, short } if ((target != -1) && (owner != -1)) - uiDefIconBut(block, LABEL, B_NOP, ICON_ARROW_LEFTRIGHT, + uiDefIconBut(block, LABEL, 0, ICON_ARROW_LEFTRIGHT, iconx, yco, 20, 20, NULL, 0.0, 0.0, 0.0, 0.0, ""); /* Owner-Space */ @@ -906,8 +791,9 @@ static uiLayout *draw_constraint(uiLayout *layout, Object *ob, bConstraint *con) bPoseChannel *pchan= get_active_posechannel(ob); bConstraintTypeInfo *cti; uiBlock *block; - uiLayout *result= NULL, *col, *box; + uiLayout *result= NULL, *col, *box, *row, *subrow; uiBut *but; + PointerRNA ptr; char typestr[32]; short width = 265; short proxy_protected, xco=0, yco=0; @@ -936,11 +822,19 @@ static uiLayout *draw_constraint(uiLayout *layout, Object *ob, bConstraint *con) uiBlockSetHandleFunc(block, do_constraint_panels, NULL); uiBlockSetFunc(block, constraint_active_func, ob, con); + RNA_pointer_create(&ob->id, &RNA_Constraint, con, &ptr); + col= uiLayoutColumn(layout, 1); + uiLayoutSetContextPointer(col, "constraint", &ptr); + box= uiLayoutBox(col); + row= uiLayoutRow(box, 0); block= uiLayoutFreeBlock(box); - + + subrow= uiLayoutRow(row, 0); + uiLayoutSetAlignment(subrow, UI_LAYOUT_ALIGN_LEFT); + /* Draw constraint header */ uiBlockSetEmboss(block, UI_EMBOSSN); @@ -974,6 +868,9 @@ static uiLayout *draw_constraint(uiLayout *layout, Object *ob, bConstraint *con) } // XXX uiBlockSetCol(block, TH_AUTO); + + subrow= uiLayoutRow(row, 0); + uiLayoutSetAlignment(subrow, UI_LAYOUT_ALIGN_RIGHT); /* proxy-protected constraints cannot be edited, so hide up/down + close buttons */ if (proxy_protected) { diff --git a/source/blender/editors/object/object_intern.h b/source/blender/editors/object/object_intern.h index ce8bd7287f7..1eb867e19a0 100644 --- a/source/blender/editors/object/object_intern.h +++ b/source/blender/editors/object/object_intern.h @@ -87,6 +87,7 @@ void GROUP_OT_objects_remove_active(struct wmOperatorType *ot); /* object_modifier.c */ void OBJECT_OT_modifier_add(struct wmOperatorType *ot); void OBJECT_OT_multires_subdivide(struct wmOperatorType *ot); +void OBJECT_OT_modifier_mdef_bind(struct wmOperatorType *ot); /* editconstraint.c */ void OBJECT_OT_constraint_add(struct wmOperatorType *ot); diff --git a/source/blender/editors/object/object_modifier.c b/source/blender/editors/object/object_modifier.c index 2e2c16ee6d6..e6b00fa7155 100644 --- a/source/blender/editors/object/object_modifier.c +++ b/source/blender/editors/object/object_modifier.c @@ -42,8 +42,10 @@ #include "BKE_curve.h" #include "BKE_context.h" #include "BKE_depsgraph.h" +#include "BKE_displist.h" #include "BKE_DerivedMesh.h" #include "BKE_global.h" +#include "BKE_lattice.h" #include "BKE_mesh.h" #include "BKE_modifier.h" #include "BKE_multires.h" @@ -396,6 +398,80 @@ void OBJECT_OT_multires_subdivide(wmOperatorType *ot) ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; } +/************************ mdef bind operator *********************/ + +static int modifier_mdef_bind_poll(bContext *C) +{ + PointerRNA ptr= CTX_data_pointer_get(C, "modifier"); + return RNA_struct_is_a(ptr.type, &RNA_MeshDeformModifier); +} + +static int modifier_mdef_bind_exec(bContext *C, wmOperator *op) +{ + Scene *scene= CTX_data_scene(C); + PointerRNA ptr= CTX_data_pointer_get(C, "modifier"); + Object *ob= ptr.id.data; + MeshDeformModifierData *mmd= ptr.data; + + if(mmd->bindcos) { + if(mmd->bindweights) MEM_freeN(mmd->bindweights); + if(mmd->bindcos) MEM_freeN(mmd->bindcos); + if(mmd->dyngrid) MEM_freeN(mmd->dyngrid); + if(mmd->dyninfluences) MEM_freeN(mmd->dyninfluences); + if(mmd->dynverts) MEM_freeN(mmd->dynverts); + mmd->bindweights= NULL; + mmd->bindcos= NULL; + mmd->dyngrid= NULL; + mmd->dyninfluences= NULL; + mmd->dynverts= NULL; + mmd->totvert= 0; + mmd->totcagevert= 0; + mmd->totinfluence= 0; + } + else { + DerivedMesh *dm; + int mode= mmd->modifier.mode; + + /* force modifier to run, it will call binding routine */ + mmd->needbind= 1; + mmd->modifier.mode |= eModifierMode_Realtime; + + if(ob->type == OB_MESH) { + dm= mesh_create_derived_view(scene, ob, 0); + dm->release(dm); + } + else if(ob->type == OB_LATTICE) { + lattice_calc_modifiers(scene, ob); + } + else if(ob->type==OB_MBALL) { + makeDispListMBall(scene, ob); + } + else if(ELEM3(ob->type, OB_CURVE, OB_SURF, OB_FONT)) { + makeDispListCurveTypes(scene, ob, 0); + } + + mmd->needbind= 0; + mmd->modifier.mode= mode; + } + + return OPERATOR_FINISHED; +} + +void OBJECT_OT_modifier_mdef_bind(wmOperatorType *ot) +{ + /* identifiers */ + ot->name= "Mesh Deform Bind"; + ot->description = "Bind mesh to cage in mesh deform modifier."; + ot->idname= "OBJECT_OT_modifier_mdef_bind"; + + /* api callbacks */ + ot->poll= modifier_mdef_bind_poll; + ot->exec= modifier_mdef_bind_exec; + + /* flags */ + ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; +} + #if 0 static void modifiers_add(void *ob_v, int type) { @@ -469,3 +545,89 @@ static uiBlock *modifiers_add_menu(void *ob_v) } #endif +#if 0 +static void modifiers_clearHookOffset(bContext *C, void *ob_v, void *md_v) +{ + Object *ob = ob_v; + ModifierData *md = md_v; + HookModifierData *hmd = (HookModifierData*) md; + + if (hmd->object) { + Mat4Invert(hmd->object->imat, hmd->object->obmat); + Mat4MulSerie(hmd->parentinv, hmd->object->imat, ob->obmat, NULL, NULL, NULL, NULL, NULL, NULL); + ED_undo_push(C, "Clear hook offset"); + } +} + +static void modifiers_cursorHookCenter(bContext *C, void *ob_v, void *md_v) +{ + /* XXX + Object *ob = ob_v; + ModifierData *md = md_v; + HookModifierData *hmd = (HookModifierData*) md; + + if(G.vd) { + float *curs = give_cursor(); + float bmat[3][3], imat[3][3]; + + where_is_object(ob); + + Mat3CpyMat4(bmat, ob->obmat); + Mat3Inv(imat, bmat); + + curs= give_cursor(); + hmd->cent[0]= curs[0]-ob->obmat[3][0]; + hmd->cent[1]= curs[1]-ob->obmat[3][1]; + hmd->cent[2]= curs[2]-ob->obmat[3][2]; + Mat3MulVecfl(imat, hmd->cent); + + ED_undo_push(C, "Hook cursor center"); + }*/ +} + +static void modifiers_selectHook(bContext *C, void *ob_v, void *md_v) +{ + /* XXX ModifierData *md = md_v; + HookModifierData *hmd = (HookModifierData*) md; + + hook_select(hmd);*/ +} + +static void modifiers_reassignHook(bContext *C, void *ob_v, void *md_v) +{ + /* XXX ModifierData *md = md_v; + HookModifierData *hmd = (HookModifierData*) md; + float cent[3]; + int *indexar, tot, ok; + char name[32]; + + ok= hook_getIndexArray(&tot, &indexar, name, cent); + + if (!ok) { + uiPupMenuError(C, "Requires selected vertices or active Vertex Group"); + } else { + if (hmd->indexar) { + MEM_freeN(hmd->indexar); + } + + VECCOPY(hmd->cent, cent); + hmd->indexar = indexar; + hmd->totindex = tot; + }*/ +} + +void modifiers_explodeFacepa(bContext *C, void *arg1, void *arg2) +{ + ExplodeModifierData *emd=arg1; + + emd->flag |= eExplodeFlag_CalcFaces; +} + +void modifiers_explodeDelVg(bContext *C, void *arg1, void *arg2) +{ + ExplodeModifierData *emd=arg1; + emd->vgroup = 0; +} +#endif + + diff --git a/source/blender/editors/object/object_ops.c b/source/blender/editors/object/object_ops.c index 9d8247522e1..cfee6a55152 100644 --- a/source/blender/editors/object/object_ops.c +++ b/source/blender/editors/object/object_ops.c @@ -101,6 +101,7 @@ void ED_operatortypes_object(void) WM_operatortype_append(OBJECT_OT_modifier_add); WM_operatortype_append(OBJECT_OT_multires_subdivide); + WM_operatortype_append(OBJECT_OT_modifier_mdef_bind); WM_operatortype_append(OBJECT_OT_constraint_add); } From abfc3daaf4dc6234ac4a48e72747a0b3fa559d2c Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Wed, 3 Jun 2009 00:14:12 +0000 Subject: [PATCH 10/35] UI: * Added initial color ramp and curve mapping templates. --- source/blender/editors/include/UI_interface.h | 5 +- .../blender/editors/interface/interface_api.c | 15 +++ .../editors/interface/interface_templates.c | 34 +++++ .../editors/interface/interface_utils.c | 127 ++++++++++++++++++ 4 files changed, 180 insertions(+), 1 deletion(-) diff --git a/source/blender/editors/include/UI_interface.h b/source/blender/editors/include/UI_interface.h index 45f26ecdcab..4c2634e2a75 100644 --- a/source/blender/editors/include/UI_interface.h +++ b/source/blender/editors/include/UI_interface.h @@ -52,6 +52,7 @@ struct rctf; struct uiStyle; struct uiFontStyle; struct ColorBand; +struct CurveMapping; typedef struct uiBut uiBut; typedef struct uiBlock uiBlock; @@ -514,9 +515,9 @@ void test_imapoin_but(struct bContext *C, char *name, struct ID **idpp); void autocomplete_bone(struct bContext *C, char *str, void *arg_v); void autocomplete_vgroup(struct bContext *C, char *str, void *arg_v); -struct CurveMapping; struct rctf; void curvemap_buttons(uiBlock *block, struct CurveMapping *cumap, char labeltype, short event, short redraw, struct rctf *rect); +void colorband_buttons(uiBlock *block, struct ColorBand *coba, struct rctf *rect, int small); /* Module @@ -604,6 +605,8 @@ void uiTemplateHeaderID(uiLayout *layout, struct bContext *C, struct PointerRNA uiLayout *uiTemplateModifier(uiLayout *layout, struct PointerRNA *ptr); uiLayout *uiTemplateConstraint(uiLayout *layout, struct PointerRNA *ptr); void uiTemplatePreview(uiLayout *layout, struct ID *id); +void uiTemplateColorRamp(uiLayout *layout, struct ColorBand *coba, int expand); +void uiTemplateCurveMapping(uiLayout *layout, struct CurveMapping *cumap, int type); /* items */ void uiItemO(uiLayout *layout, char *name, int icon, char *opname); diff --git a/source/blender/editors/interface/interface_api.c b/source/blender/editors/interface/interface_api.c index 2bbaee857d1..5aff0c0ad82 100644 --- a/source/blender/editors/interface/interface_api.c +++ b/source/blender/editors/interface/interface_api.c @@ -54,6 +54,12 @@ void RNA_api_ui_layout(StructRNA *srna) FunctionRNA *func; PropertyRNA *parm; + static EnumPropertyItem curve_type_items[] = { + {0, "NONE", "None", ""}, + {'v', "VECTOR", "Vector", ""}, + {'c', "COLOR", "Color", ""}, + {0, NULL, NULL, NULL}}; + /* simple layout specifiers */ func= RNA_def_function(srna, "row", "uiLayoutRow"); parm= RNA_def_pointer(func, "layout", "UILayout", "", "Sub-layout to put items in."); @@ -214,5 +220,14 @@ void RNA_api_ui_layout(StructRNA *srna) parm= RNA_def_pointer(func, "id", "ID", "", "ID datablock."); RNA_def_property_flag(parm, PROP_REQUIRED); + func= RNA_def_function(srna, "template_curve_mapping", "uiTemplateCurveMapping"); + parm= RNA_def_pointer(func, "curvemap", "CurveMapping", "", "Curve mapping pointer."); + RNA_def_property_flag(parm, PROP_REQUIRED); + RNA_def_enum(func, "type", curve_type_items, 0, "Type", "Type of curves to display."); + + func= RNA_def_function(srna, "template_color_ramp", "uiTemplateColorRamp"); + parm= RNA_def_pointer(func, "ramp", "ColorRamp", "", "Color ramp pointer."); + RNA_def_property_flag(parm, PROP_REQUIRED); + RNA_def_boolean(func, "expand", 0, "", "Expand button to show more detail."); } diff --git a/source/blender/editors/interface/interface_templates.c b/source/blender/editors/interface/interface_templates.c index 4df5f99f224..12954fe77c0 100644 --- a/source/blender/editors/interface/interface_templates.c +++ b/source/blender/editors/interface/interface_templates.c @@ -1311,3 +1311,37 @@ void uiTemplatePreview(uiLayout *layout, ID *id) } +/********************** ColorRamp Template **************************/ + +void uiTemplateColorRamp(uiLayout *layout, ColorBand *coba, int expand) +{ + uiBlock *block; + rctf rect; + + if(coba) { + rect.xmin= 0; rect.xmax= 200; + rect.ymin= 0; rect.ymax= 190; + + block= uiLayoutFreeBlock(layout); + colorband_buttons(block, coba, &rect, !expand); + } +} + +/********************* CurveMapping Template ************************/ + +#include "DNA_color_types.h" + +void uiTemplateCurveMapping(uiLayout *layout, CurveMapping *cumap, int type) +{ + uiBlock *block; + rctf rect; + + if(cumap) { + rect.xmin= 0; rect.xmax= 200; + rect.ymin= 0; rect.ymax= 190; + + block= uiLayoutFreeBlock(layout); + curvemap_buttons(block, cumap, type, 0, 0, &rect); + } +} + diff --git a/source/blender/editors/interface/interface_utils.c b/source/blender/editors/interface/interface_utils.c index 7c739adf1b9..76247258a71 100644 --- a/source/blender/editors/interface/interface_utils.c +++ b/source/blender/editors/interface/interface_utils.c @@ -35,6 +35,7 @@ #include "DNA_material_types.h" #include "DNA_object_types.h" #include "DNA_screen_types.h" +#include "DNA_texture_types.h" #include "DNA_windowmanager_types.h" #include "BKE_colortools.h" @@ -42,6 +43,7 @@ #include "BKE_idprop.h" #include "BKE_library.h" #include "BKE_main.h" +#include "BKE_texture.h" #include "BKE_utildefines.h" #include "RNA_access.h" @@ -1098,3 +1100,128 @@ void curvemap_buttons(uiBlock *block, CurveMapping *cumap, char labeltype, short cumap, 0.0f, 1.0f, 0, 0, ""); } +#define B_BANDCOL 1 + +static int vergcband(const void *a1, const void *a2) +{ + const CBData *x1=a1, *x2=a2; + + if( x1->pos > x2->pos ) return 1; + else if( x1->pos < x2->pos) return -1; + return 0; +} + +static void colorband_pos_cb(bContext *C, void *coba_v, void *unused_v) +{ + ColorBand *coba= coba_v; + int a; + + if(coba->tot<2) return; + + for(a=0; atot; a++) coba->data[a].cur= a; + qsort(coba->data, coba->tot, sizeof(CBData), vergcband); + for(a=0; atot; a++) { + if(coba->data[a].cur==coba->cur) { + // XXX if(coba->cur!=a) addqueue(curarea->win, REDRAW, 0); /* button cur */ + coba->cur= a; + break; + } + } +} + +static void colorband_add_cb(bContext *C, void *coba_v, void *unused_v) +{ + ColorBand *coba= coba_v; + + if(coba->tot < MAXCOLORBAND-1) coba->tot++; + coba->cur= coba->tot-1; + + colorband_pos_cb(C, coba, NULL); + ED_undo_push(C, "Add colorband"); +} + +static void colorband_del_cb(bContext *C, void *coba_v, void *unused_v) +{ + ColorBand *coba= coba_v; + int a; + + if(coba->tot<2) return; + + for(a=coba->cur; atot; a++) { + coba->data[a]= coba->data[a+1]; + } + if(coba->cur) coba->cur--; + coba->tot--; + + ED_undo_push(C, "Delete colorband"); + // XXX BIF_preview_changed(ID_TE); +} + + +/* offset aligns from bottom, standard width 300, height 115 */ +static void colorband_buttons_large(uiBlock *block, ColorBand *coba, int xoffs, int yoffs, int redraw) +{ + CBData *cbd; + uiBut *bt; + + if(coba==NULL) return; + + bt= uiDefBut(block, BUT, redraw, "Add", 80+xoffs,95+yoffs,37,20, 0, 0, 0, 0, 0, "Adds a new color position to the colorband"); + uiButSetFunc(bt, colorband_add_cb, coba, NULL); + uiDefButS(block, NUM, redraw, "Cur:", 117+xoffs,95+yoffs,81,20, &coba->cur, 0.0, (float)(coba->tot-1), 0, 0, "Displays the active color from the colorband"); + bt= uiDefBut(block, BUT, redraw, "Del", 199+xoffs,95+yoffs,37,20, 0, 0, 0, 0, 0, "Deletes the active position"); + uiButSetFunc(bt, colorband_del_cb, coba, NULL); + + uiDefButS(block, MENU, redraw, "Interpolation %t|Ease %x1|Cardinal %x3|Linear %x0|B-Spline %x2|Constant %x4", + 236+xoffs, 95+yoffs, 64, 20, &coba->ipotype, 0.0, 0.0, 0, 0, "Sets interpolation type"); + + uiDefBut(block, BUT_COLORBAND, redraw, "", xoffs,65+yoffs,300,30, coba, 0, 0, 0, 0, ""); + + cbd= coba->data + coba->cur; + + uiBlockBeginAlign(block); + bt= uiDefButF(block, NUM, redraw, "Pos", xoffs,40+yoffs,110,20, &cbd->pos, 0.0, 1.0, 10, 0, "Sets the position of the active color"); + uiButSetFunc(bt, colorband_pos_cb, coba, NULL); + uiDefButF(block, COL, redraw, "", xoffs,20+yoffs,110,20, &(cbd->r), 0, 0, 0, B_BANDCOL, ""); + uiDefButF(block, NUMSLI, redraw, "A ", xoffs,yoffs,110,20, &cbd->a, 0.0, 1.0, 10, 0, "Sets the alpha value for this position"); + + uiBlockBeginAlign(block); + uiDefButF(block, NUMSLI, redraw, "R ", 115+xoffs,40+yoffs,185,20, &cbd->r, 0.0, 1.0, B_BANDCOL, 0, "Sets the red value for the active color"); + uiDefButF(block, NUMSLI, redraw, "G ", 115+xoffs,20+yoffs,185,20, &cbd->g, 0.0, 1.0, B_BANDCOL, 0, "Sets the green value for the active color"); + uiDefButF(block, NUMSLI, redraw, "B ", 115+xoffs,yoffs,185,20, &cbd->b, 0.0, 1.0, B_BANDCOL, 0, "Sets the blue value for the active color"); + uiBlockEndAlign(block); +} + +static void colorband_buttons_small(uiBlock *block, ColorBand *coba, rctf *butr, int event) +{ + CBData *cbd; + uiBut *bt; + float unit= (butr->xmax-butr->xmin)/14.0f; + float xs= butr->xmin; + + cbd= coba->data + coba->cur; + + uiBlockBeginAlign(block); + uiDefButF(block, COL, event, "", xs,butr->ymin+20.0f,2.0f*unit,20, &(cbd->r), 0, 0, 0, B_BANDCOL, ""); + uiDefButF(block, NUM, event, "A:", xs+2.0f*unit,butr->ymin+20.0f,4.0f*unit,20, &(cbd->a), 0.0f, 1.0f, 10, 2, ""); + bt= uiDefBut(block, BUT, event, "Add", xs+6.0f*unit,butr->ymin+20.0f,2.0f*unit,20, NULL, 0, 0, 0, 0, "Adds a new color position to the colorband"); + uiButSetFunc(bt, colorband_add_cb, coba, NULL); + bt= uiDefBut(block, BUT, event, "Del", xs+8.0f*unit,butr->ymin+20.0f,2.0f*unit,20, NULL, 0, 0, 0, 0, "Deletes the active position"); + uiButSetFunc(bt, colorband_del_cb, coba, NULL); + + uiDefButS(block, MENU, event, "Interpolation %t|Ease %x1|Cardinal %x3|Linear %x0|B-Spline %x2|Constant %x4", + xs+10.0f*unit, butr->ymin+20.0f, unit*4, 20, &coba->ipotype, 0.0, 0.0, 0, 0, "Sets interpolation type"); + + uiDefBut(block, BUT_COLORBAND, event, "", xs,butr->ymin,butr->xmax-butr->xmin,20.0f, coba, 0, 0, 0, 0, ""); + uiBlockEndAlign(block); + +} + +void colorband_buttons(uiBlock *block, ColorBand *coba, rctf *butr, int small) +{ + if(small) + colorband_buttons_small(block, coba, butr, 0); + else + colorband_buttons_large(block, coba, 0, 0, 0); +} + From dc7d0ef474d235b59c4889b8fdb2eb1551f3df83 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Wed, 3 Jun 2009 00:17:35 +0000 Subject: [PATCH 11/35] UI: * Add Lamp Fallof Curve and Texture Color Ramp panels. * Use button space context data. * A few other minor python layout script updates. --- release/ui/buttons_data_armature.py | 13 ++- release/ui/buttons_data_bone.py | 5 +- release/ui/buttons_data_camera.py | 9 +- release/ui/buttons_data_curve.py | 16 ++-- release/ui/buttons_data_empty.py | 6 +- release/ui/buttons_data_lamp.py | 46 ++++++++--- release/ui/buttons_data_lattice.py | 7 +- release/ui/buttons_data_mesh.py | 7 +- release/ui/buttons_data_modifier.py | 35 +++++--- release/ui/buttons_data_text.py | 12 +-- release/ui/buttons_material.py | 40 ++++----- release/ui/buttons_object_constraint.py | 18 ++-- release/ui/buttons_objects.py | 13 +-- release/ui/buttons_particle.py | 5 +- release/ui/buttons_physic_cloth.py | 21 ++--- release/ui/buttons_scene.py | 2 +- release/ui/buttons_texture.py | 104 ++++++++++++++---------- release/ui/buttons_world.py | 26 +++--- 18 files changed, 211 insertions(+), 174 deletions(-) diff --git a/release/ui/buttons_data_armature.py b/release/ui/buttons_data_armature.py index 1d0043a5179..46a077ebfdb 100644 --- a/release/ui/buttons_data_armature.py +++ b/release/ui/buttons_data_armature.py @@ -7,15 +7,14 @@ class DataButtonsPanel(bpy.types.Panel): __context__ = "data" def poll(self, context): - ob = context.active_object - return (ob and ob.type == 'ARMATURE') + return (context.armature != None) class DATA_PT_skeleton(DataButtonsPanel): __idname__ = "DATA_PT_skeleton" __label__ = "Skeleton" def draw(self, context): - arm = context.active_object.data + arm = context.armature layout = self.layout layout.itemR(arm, "rest_position") @@ -42,7 +41,7 @@ class DATA_PT_display(DataButtonsPanel): __label__ = "Display" def draw(self, context): - arm = context.active_object.data + arm = context.armature layout = self.layout split = layout.split() @@ -62,7 +61,7 @@ class DATA_PT_paths(DataButtonsPanel): __label__ = "Paths" def draw(self, context): - arm = context.active_object.data + arm = context.armature layout = self.layout split = layout.split() @@ -90,7 +89,7 @@ class DATA_PT_ghost(DataButtonsPanel): __label__ = "Ghost" def draw(self, context): - arm = context.active_object.data + arm = context.armature layout = self.layout split = layout.split() @@ -111,4 +110,4 @@ class DATA_PT_ghost(DataButtonsPanel): bpy.types.register(DATA_PT_skeleton) bpy.types.register(DATA_PT_display) bpy.types.register(DATA_PT_paths) -bpy.types.register(DATA_PT_ghost) \ No newline at end of file +bpy.types.register(DATA_PT_ghost) diff --git a/release/ui/buttons_data_bone.py b/release/ui/buttons_data_bone.py index a4e0fe4e2fb..75c201f015e 100644 --- a/release/ui/buttons_data_bone.py +++ b/release/ui/buttons_data_bone.py @@ -7,15 +7,14 @@ class BoneButtonsPanel(bpy.types.Panel): __context__ = "bone" def poll(self, context): - ob = context.active_object - return (ob and ob.type == 'ARMATURE') + return (context.bone != None) class BONE_PT_bone(BoneButtonsPanel): __idname__ = "BONE_PT_bone" __label__ = "Bone" def draw(self, context): - bone = context.active_object.data.bones[0] + bone = context.bone layout = self.layout split = layout.split() diff --git a/release/ui/buttons_data_camera.py b/release/ui/buttons_data_camera.py index d4dabea9480..7f3682b1c94 100644 --- a/release/ui/buttons_data_camera.py +++ b/release/ui/buttons_data_camera.py @@ -7,15 +7,14 @@ class DataButtonsPanel(bpy.types.Panel): __context__ = "data" def poll(self, context): - ob = context.active_object - return (ob and ob.type == 'CAMERA') + return (context.camera != None) class DATA_PT_cameralens(DataButtonsPanel): __idname__ = "DATA_PT_camera" __label__ = "Lens" def draw(self, context): - cam = context.active_object.data + cam = context.camera layout = self.layout layout.itemR(cam, "type", expand=True) @@ -52,7 +51,7 @@ class DATA_PT_cameradisplay(DataButtonsPanel): __label__ = "Display" def draw(self, context): - cam = context.active_object.data + cam = context.camera layout = self.layout split = layout.split() @@ -71,4 +70,4 @@ class DATA_PT_cameradisplay(DataButtonsPanel): col.itemR(cam, "draw_size", text="Size") bpy.types.register(DATA_PT_cameralens) -bpy.types.register(DATA_PT_cameradisplay) \ No newline at end of file +bpy.types.register(DATA_PT_cameradisplay) diff --git a/release/ui/buttons_data_curve.py b/release/ui/buttons_data_curve.py index 754c26aa3e6..9baee5516be 100644 --- a/release/ui/buttons_data_curve.py +++ b/release/ui/buttons_data_curve.py @@ -7,15 +7,15 @@ class DataButtonsPanel(bpy.types.Panel): __context__ = "data" def poll(self, context): - ob = context.active_object - return (ob and ob.type == 'CURVE') + ob = context.object + return (ob and ob.type == 'CURVE' and context.curve) class DATA_PT_shape_curve(DataButtonsPanel): __idname__ = "DATA_PT_shape_curve" __label__ = "Shape" def draw(self, context): - curve = context.active_object.data + curve = context.curve layout = self.layout layout.itemR(curve, "curve_2d") @@ -50,7 +50,7 @@ class DATA_PT_geometry(DataButtonsPanel): __label__ = "Geometry" def draw(self, context): - curve = context.active_object.data + curve = context.curve layout = self.layout split = layout.split() @@ -72,13 +72,13 @@ class DATA_PT_pathanim(DataButtonsPanel): __label__ = "Path Animation" def draw_header(self, context): - curve = context.active_object.data + curve = context.curve layout = self.layout layout.itemR(curve, "path", text="") def draw(self, context): - curve = context.active_object.data + curve = context.curve layout = self.layout layout.active = curve.path @@ -97,7 +97,7 @@ class DATA_PT_current_curve(DataButtonsPanel): __label__ = "Current Curve" def draw(self, context): - currentcurve = context.active_object.data.curves[0] + currentcurve = context.curve.curves[0] # XXX layout = self.layout split = layout.split() @@ -128,4 +128,4 @@ class DATA_PT_current_curve(DataButtonsPanel): bpy.types.register(DATA_PT_shape_curve) bpy.types.register(DATA_PT_geometry) bpy.types.register(DATA_PT_pathanim) -bpy.types.register(DATA_PT_current_curve) \ No newline at end of file +bpy.types.register(DATA_PT_current_curve) diff --git a/release/ui/buttons_data_empty.py b/release/ui/buttons_data_empty.py index 94caa4ed700..7f994c94a07 100644 --- a/release/ui/buttons_data_empty.py +++ b/release/ui/buttons_data_empty.py @@ -7,7 +7,7 @@ class DataButtonsPanel(bpy.types.Panel): __context__ = "data" def poll(self, context): - ob = context.active_object + ob = context.object return (ob and ob.type == 'EMPTY') class DATA_PT_empty(DataButtonsPanel): @@ -15,10 +15,10 @@ class DATA_PT_empty(DataButtonsPanel): __label__ = "Empty" def draw(self, context): - ob = context.active_object + ob = context.object layout = self.layout layout.itemR(ob, "empty_draw_type") layout.itemR(ob, "empty_draw_size") -bpy.types.register(DATA_PT_empty) \ No newline at end of file +bpy.types.register(DATA_PT_empty) diff --git a/release/ui/buttons_data_lamp.py b/release/ui/buttons_data_lamp.py index a2a6ad0426c..86be9cd1a68 100644 --- a/release/ui/buttons_data_lamp.py +++ b/release/ui/buttons_data_lamp.py @@ -7,15 +7,14 @@ class DataButtonsPanel(bpy.types.Panel): __context__ = "data" def poll(self, context): - ob = context.active_object - return (ob and ob.type == 'LAMP') + return (context.lamp != None) class DATA_PT_lamp(DataButtonsPanel): __idname__ = "DATA_PT_lamp" __label__ = "Lamp" def draw(self, context): - lamp = context.active_object.data + lamp = context.lamp layout = self.layout layout.itemR(lamp, "type", expand=True) @@ -56,11 +55,11 @@ class DATA_PT_sunsky(DataButtonsPanel): __label__ = "Sun/Sky" def poll(self, context): - ob = context.active_object - return (ob.type == 'LAMP' and ob.data.type == 'SUN') + lamp = context.lamp + return (lamp and lamp.type == 'SUN') def draw(self, context): - lamp = context.active_object.data.sky + lamp = context.lamp.sky layout = self.layout row = layout.row() @@ -99,11 +98,11 @@ class DATA_PT_shadow(DataButtonsPanel): __label__ = "Shadow" def poll(self, context): - ob = context.active_object - return (ob.type == 'LAMP' and ob.data.type in ('POINT','SUN', 'SPOT', 'AREA')) + lamp = context.lamp + return (lamp and lamp.type in ('POINT','SUN', 'SPOT', 'AREA')) def draw(self, context): - lamp = context.active_object.data + lamp = context.lamp layout = self.layout layout.itemR(lamp, "shadow_method", expand=True) @@ -178,11 +177,11 @@ class DATA_PT_spot(DataButtonsPanel): __label__ = "Spot" def poll(self, context): - ob = context.active_object - return (ob.type == 'LAMP' and ob.data.type == 'SPOT') + lamp = context.lamp + return (lamp and lamp.type == 'SPOT') def draw(self, context): - lamp = context.active_object.data + lamp = context.lamp layout = self.layout split = layout.split() @@ -200,7 +199,28 @@ class DATA_PT_spot(DataButtonsPanel): if lamp.shadow_method == 'BUFFER_SHADOW': colsub.itemR(lamp, "halo_step", text="Step") +class DATA_PT_falloff_curve(DataButtonsPanel): + __idname__ = "DATA_PT_falloff_curve" + __label__ = "Falloff Curve" + + def poll(self, context): + lamp = context.lamp + + if lamp and lamp.type in ('POINT', 'SPOT'): + if lamp.falloff_type == 'CUSTOM_CURVE': + return True + + return False + + def draw(self, context): + lamp = context.lamp + layout = self.layout + + layout.template_curve_mapping(lamp.falloff_curve) + bpy.types.register(DATA_PT_lamp) bpy.types.register(DATA_PT_shadow) bpy.types.register(DATA_PT_sunsky) -bpy.types.register(DATA_PT_spot) \ No newline at end of file +bpy.types.register(DATA_PT_spot) +bpy.types.register(DATA_PT_falloff_curve) + diff --git a/release/ui/buttons_data_lattice.py b/release/ui/buttons_data_lattice.py index 4bcff9f5389..6172c255d15 100644 --- a/release/ui/buttons_data_lattice.py +++ b/release/ui/buttons_data_lattice.py @@ -7,15 +7,14 @@ class DataButtonsPanel(bpy.types.Panel): __context__ = "data" def poll(self, context): - ob = context.active_object - return (ob and ob.type == 'LATTICE') + return (context.lattice != None) class DATA_PT_lattice(DataButtonsPanel): __idname__ = "DATA_PT_lattice" __label__ = "Lattice" def draw(self, context): - lat = context.active_object.data + lat = context.lattice layout = self.layout row = layout.row() @@ -34,4 +33,4 @@ class DATA_PT_lattice(DataButtonsPanel): row.itemR(lat, "outside") row.itemR(lat, "shape_keys") -bpy.types.register(DATA_PT_lattice) \ No newline at end of file +bpy.types.register(DATA_PT_lattice) diff --git a/release/ui/buttons_data_mesh.py b/release/ui/buttons_data_mesh.py index 6e9a30cefbc..fceb235343a 100644 --- a/release/ui/buttons_data_mesh.py +++ b/release/ui/buttons_data_mesh.py @@ -7,15 +7,14 @@ class DataButtonsPanel(bpy.types.Panel): __context__ = "data" def poll(self, context): - ob = context.active_object - return (ob and ob.type == 'MESH') + return (context.mesh != None) class DATA_PT_surface(DataButtonsPanel): __idname__ = "DATA_PT_surface" __label__ = "Mesh" def draw(self, context): - mesh = context.active_object.data + mesh = context.mesh layout = self.layout split = layout.split() @@ -31,4 +30,4 @@ class DATA_PT_surface(DataButtonsPanel): layout.itemR(mesh, "texco_mesh") -bpy.types.register(DATA_PT_surface) \ No newline at end of file +bpy.types.register(DATA_PT_surface) diff --git a/release/ui/buttons_data_modifier.py b/release/ui/buttons_data_modifier.py index c087e5f5e36..0f5d446f889 100644 --- a/release/ui/buttons_data_modifier.py +++ b/release/ui/buttons_data_modifier.py @@ -7,7 +7,7 @@ class DataButtonsPanel(bpy.types.Panel): __context__ = "modifier" def poll(self, context): - ob = context.active_object + ob = context.object return (ob and ob.type in ('MESH', 'CURVE', 'SURFACE', 'TEXT', 'LATTICE')) class DATA_PT_modifiers(DataButtonsPanel): @@ -15,7 +15,7 @@ class DATA_PT_modifiers(DataButtonsPanel): __label__ = "Modifiers" def draw(self, context): - ob = context.active_object + ob = context.object layout = self.layout row = layout.row() @@ -61,7 +61,7 @@ class DATA_PT_modifiers(DataButtonsPanel): if md.type == 'MASK': self.mask(box, md) if md.type == 'MESH_DEFORM': - self.meshdeform(box, md) + self.mesh_deform(box, md) if md.type == 'MIRROR': self.mirror(box, md) if md.type == 'MULTIRES': @@ -104,6 +104,8 @@ class DATA_PT_modifiers(DataButtonsPanel): layout.itemR(md, "length") if md.fit_type == 'FIT_CURVE': layout.itemR(md, "curve") + + layout.itemS() split = layout.split() @@ -112,7 +114,10 @@ class DATA_PT_modifiers(DataButtonsPanel): col.itemR(md, "constant_offset") colsub = col.column() colsub.active = md.constant_offset - colsub.itemR(md, "constant_offset_displacement", text="Displacement") + colsub.itemR(md, "constant_offset_displacement", text="") + + col.itemS() + sub = col.row().itemR(md, "merge_adjacent_vertices", text="Merge") colsub = col.column() colsub.active = md.merge_adjacent_vertices @@ -124,12 +129,17 @@ class DATA_PT_modifiers(DataButtonsPanel): col.itemR(md, "relative_offset") colsub = col.column() colsub.active = md.relative_offset - colsub.itemR(md, "relative_offset_displacement", text="Displacement") + colsub.itemR(md, "relative_offset_displacement", text="") + + col.itemS() + col = col.column() col.itemR(md, "add_offset_object") colsub = col.column() colsub.active = md.add_offset_object - colsub.itemR(md, "offset_object") + colsub.itemR(md, "offset_object", text="") + + layout.itemS() col = layout.column() col.itemR(md, "start_cap") @@ -249,13 +259,16 @@ class DATA_PT_modifiers(DataButtonsPanel): layout.itemR(md, "vertex_group") layout.itemR(md, "inverse") - def meshdeform(self, layout, md): + def mesh_deform(self, layout, md): layout.itemR(md, "object") layout.itemR(md, "vertex_group") layout.itemR(md, "invert") - layout.itemR(md, "precision") - layout.itemR(md, "dynamic") - # Missing: "Bind" + + layout.itemS() + layout.itemO("OBJECT_OT_modifier_mdef_bind", text="Bind") + row = layout.row() + row.itemR(md, "precision") + row.itemR(md, "dynamic") def mirror(self, layout, md): layout.itemR(md, "merge_limit") @@ -402,4 +415,4 @@ class DATA_PT_modifiers(DataButtonsPanel): col.itemR(md, "width", slider=True) col.itemR(md, "narrowness", slider=True) -bpy.types.register(DATA_PT_modifiers) \ No newline at end of file +bpy.types.register(DATA_PT_modifiers) diff --git a/release/ui/buttons_data_text.py b/release/ui/buttons_data_text.py index 96147270209..9683dbee22b 100644 --- a/release/ui/buttons_data_text.py +++ b/release/ui/buttons_data_text.py @@ -7,7 +7,7 @@ class DataButtonsPanel(bpy.types.Panel): __context__ = "data" def poll(self, context): - ob = context.active_object + ob = context.object return (ob and ob.type == 'TEXT') class DATA_PT_shape_text(DataButtonsPanel): @@ -15,7 +15,7 @@ class DATA_PT_shape_text(DataButtonsPanel): __label__ = "Shape" def draw(self, context): - curve = context.active_object.data + curve = context.curve layout = self.layout layout.itemR(curve, "curve_2d") @@ -46,7 +46,7 @@ class DATA_PT_font(DataButtonsPanel): __label__ = "Font" def draw(self, context): - text = context.active_object.data + text = context.curve layout = self.layout layout.row() @@ -77,7 +77,7 @@ class DATA_PT_paragraph(DataButtonsPanel): __label__ = "Paragraph" def draw(self, context): - text = context.active_object.data + text = context.curve layout = self.layout layout.itemL(text="Align:") @@ -102,10 +102,10 @@ class DATA_PT_textboxes(DataButtonsPanel): __label__ = "Text Boxes" def draw(self, context): - text = context.active_object.data + text = context.curve layout = self.layout bpy.types.register(DATA_PT_shape_text) bpy.types.register(DATA_PT_font) bpy.types.register(DATA_PT_paragraph) -#bpy.types.register(DATA_PT_textboxes) \ No newline at end of file +#bpy.types.register(DATA_PT_textboxes) diff --git a/release/ui/buttons_material.py b/release/ui/buttons_material.py index c9a5fa6db06..7cffb5b18cf 100644 --- a/release/ui/buttons_material.py +++ b/release/ui/buttons_material.py @@ -7,8 +7,7 @@ class MaterialButtonsPanel(bpy.types.Panel): __context__ = "material" def poll(self, context): - ob = context.active_object - return (ob and ob.active_material) + return (context.material != None) class MATERIAL_PT_preview(MaterialButtonsPanel): __idname__= "MATERIAL_PT_preview" @@ -17,7 +16,7 @@ class MATERIAL_PT_preview(MaterialButtonsPanel): def draw(self, context): layout = self.layout - mat = context.active_object.active_material + mat = context.material layout.template_preview(mat) class MATERIAL_PT_material(MaterialButtonsPanel): @@ -26,7 +25,7 @@ class MATERIAL_PT_material(MaterialButtonsPanel): def draw(self, context): layout = self.layout - mat = context.active_object.active_material + mat = context.material layout.itemR(mat, "type", expand=True) @@ -42,18 +41,18 @@ class MATERIAL_PT_sss(MaterialButtonsPanel): __label__ = "Subsurface Scattering" def poll(self, context): - ob = context.active_object - return (ob and ob.active_material and ob.active_material.type == "SURFACE") + mat = context.material + return (mat and mat.type == "SURFACE") def draw_header(self, context): - sss = context.active_object.active_material.subsurface_scattering + sss = context.material.subsurface_scattering layout = self.layout layout.itemR(sss, "enabled", text="") def draw(self, context): layout = self.layout - sss = context.active_object.active_material.subsurface_scattering + sss = context.material.subsurface_scattering layout.active = sss.enabled flow = layout.column_flow() @@ -76,18 +75,18 @@ class MATERIAL_PT_raymir(MaterialButtonsPanel): __label__ = "Ray Mirror" def poll(self, context): - ob = context.active_object - return (ob and ob.active_material and ob.active_material.type == "SURFACE") + mat = context.material + return (mat and mat.type == "SURFACE") def draw_header(self, context): - raym = context.active_object.active_material.raytrace_mirror + raym = context.material.raytrace_mirror layout = self.layout layout.itemR(raym, "enabled", text="") def draw(self, context): layout = self.layout - raym = context.active_object.active_material.raytrace_mirror + raym = context.material.raytrace_mirror layout.active = raym.enabled split = layout.split() @@ -113,18 +112,18 @@ class MATERIAL_PT_raytransp(MaterialButtonsPanel): __label__= "Ray Transparency" def poll(self, context): - ob = context.active_object - return (ob and ob.active_material and ob.active_material.type == "SURFACE") + mat = context.material + return (mat and mat.type == "SURFACE") def draw_header(self, context): - rayt = context.active_object.active_material.raytrace_transparency + rayt = context.material.raytrace_transparency layout = self.layout layout.itemR(rayt, "enabled", text="") def draw(self, context): layout = self.layout - rayt = context.active_object.active_material.raytrace_transparency + rayt = context.material.raytrace_transparency layout.active = rayt.enabled split = layout.split() @@ -151,12 +150,12 @@ class MATERIAL_PT_halo(MaterialButtonsPanel): __label__= "Halo" def poll(self, context): - ob = context.active_object - return (ob and ob.active_material and ob.active_material.type == "HALO") + mat = context.material + return (mat and mat.type == "HALO") def draw(self, context): layout = self.layout - mat = context.active_object.active_material + mat = context.material halo = mat.halo split = layout.split() @@ -202,4 +201,5 @@ bpy.types.register(MATERIAL_PT_material) bpy.types.register(MATERIAL_PT_raymir) bpy.types.register(MATERIAL_PT_raytransp) bpy.types.register(MATERIAL_PT_sss) -bpy.types.register(MATERIAL_PT_halo) \ No newline at end of file +bpy.types.register(MATERIAL_PT_halo) + diff --git a/release/ui/buttons_object_constraint.py b/release/ui/buttons_object_constraint.py index 593010128a2..5b32124ff33 100644 --- a/release/ui/buttons_object_constraint.py +++ b/release/ui/buttons_object_constraint.py @@ -43,8 +43,8 @@ class ConstraintButtonsPanel(bpy.types.Panel): self.stretch_to(box, con) elif con.type == "FLOOR": self.floor(box, con) - #elif con.type == "RIGID_BODY_JOINT": - # self.rigid_body(box, con) + elif con.type == "RIGID_BODY_JOINT": + self.rigid_body(box, con) elif con.type == "CLAMP_TO": self.clamp_to(box, con) elif con.type == "TRANSFORM": @@ -512,11 +512,10 @@ class OBJECT_PT_constraints(ConstraintButtonsPanel): __context__ = "object" def poll(self, context): - ob = context.active_object - return (ob != None) + return (context.object != None) def draw(self, context): - ob = context.active_object + ob = context.object layout = self.layout row = layout.row() @@ -532,12 +531,12 @@ class BONE_PT_constraints(ConstraintButtonsPanel): __context__ = "bone" def poll(self, context): - ob = context.active_object + ob = context.object return (ob and ob.type == "ARMATURE") def draw(self, context): - ob = context.active_object - pchan = ob.pose.pose_channels[0] + ob = context.object + pchan = ob.pose.pose_channels[0] # XXX layout = self.layout #row = layout.row() @@ -548,4 +547,5 @@ class BONE_PT_constraints(ConstraintButtonsPanel): self.draw_constraint(con) bpy.types.register(OBJECT_PT_constraints) -bpy.types.register(BONE_PT_constraints) \ No newline at end of file +bpy.types.register(BONE_PT_constraints) + diff --git a/release/ui/buttons_objects.py b/release/ui/buttons_objects.py index a5074614515..6d75146fe5f 100644 --- a/release/ui/buttons_objects.py +++ b/release/ui/buttons_objects.py @@ -7,14 +7,14 @@ class ObjectButtonsPanel(bpy.types.Panel): __context__ = "object" def poll(self, context): - return (context.active_object != None) + return (context.object != None) class OBJECT_PT_transform(ObjectButtonsPanel): __idname__ = "OBJECT_PT_transform" __label__ = "Transform" def draw(self, context): - ob = context.active_object + ob = context.object layout = self.layout row = layout.row() @@ -27,7 +27,7 @@ class OBJECT_PT_groups(ObjectButtonsPanel): __label__ = "Groups" def draw(self, context): - ob = context.active_object + ob = context.object layout = self.layout row = layout.row() @@ -54,7 +54,7 @@ class OBJECT_PT_display(ObjectButtonsPanel): __label__ = "Display" def draw(self, context): - ob = context.active_object + ob = context.object layout = self.layout row = layout.row() @@ -74,7 +74,7 @@ class OBJECT_PT_duplication(ObjectButtonsPanel): __label__ = "Duplication" def draw(self, context): - ob = context.active_object + ob = context.object layout = self.layout layout.itemR(ob, "dupli_type", expand=True) @@ -108,7 +108,7 @@ class OBJECT_PT_animation(ObjectButtonsPanel): __label__ = "Animation" def draw(self, context): - ob = context.active_object + ob = context.object layout = self.layout split = layout.split() @@ -132,3 +132,4 @@ bpy.types.register(OBJECT_PT_groups) bpy.types.register(OBJECT_PT_display) bpy.types.register(OBJECT_PT_duplication) bpy.types.register(OBJECT_PT_animation) + diff --git a/release/ui/buttons_particle.py b/release/ui/buttons_particle.py index 52e20b03538..737aa1a4393 100644 --- a/release/ui/buttons_particle.py +++ b/release/ui/buttons_particle.py @@ -7,8 +7,7 @@ class ParticleButtonsPanel(bpy.types.Panel): __context__ = "particle" def poll(self, context): - ob = context.active_object - return (ob and ob.active_particle_system) + return (context.particle_system != None) class PARTICLE_PT_particles(ParticleButtonsPanel): __idname__= "PARTICLE_PT_particles" @@ -17,7 +16,7 @@ class PARTICLE_PT_particles(ParticleButtonsPanel): def draw(self, context): layout = self.layout - psys = context.active_object.active_particle_system + psys = context.particle_system part = psys.settings layout.itemR(part, "amount") diff --git a/release/ui/buttons_physic_cloth.py b/release/ui/buttons_physic_cloth.py index 6dab2bcf57c..1b114871453 100644 --- a/release/ui/buttons_physic_cloth.py +++ b/release/ui/buttons_physic_cloth.py @@ -6,17 +6,8 @@ class PhysicButtonsPanel(bpy.types.Panel): __region_type__ = "WINDOW" __context__ = "physics" - def cloth_modifier(self, context): - ob = context.active_object - for md in ob.modifiers: - if md.type == 'CLOTH': - return md - - return None - def poll(self, context): - md = self.cloth_modifier(context) - return (md != None) + return (context.cloth != None) class Physic_PT_cloth(PhysicButtonsPanel): __idname__ = "Physic_PT_cloth" @@ -24,7 +15,7 @@ class Physic_PT_cloth(PhysicButtonsPanel): def draw(self, context): layout = self.layout - md = self.cloth_modifier(context) + md = context.cloth cloth = md.settings split = layout.split() @@ -60,7 +51,7 @@ class Physic_PT_cloth_collision(PhysicButtonsPanel): def draw_header(self, context): layout = self.layout - md = self.cloth_modifier(context) + md = context.cloth cloth = md.collision_settings layout.itemR(cloth, "enable_collision", text="") @@ -91,7 +82,7 @@ class Physic_PT_cloth_stiffness(PhysicButtonsPanel): def draw_header(self, context): layout = self.layout - md = self.cloth_modifier(context) + md = context.cloth cloth = md.settings layout.itemR(cloth, "stiffness_scaling", text="") @@ -99,7 +90,7 @@ class Physic_PT_cloth_stiffness(PhysicButtonsPanel): def draw(self, context): layout = self.layout - md = self.cloth_modifier(context) + md = context.cloth cloth = md.settings layout.active = cloth.stiffness_scaling @@ -117,4 +108,4 @@ class Physic_PT_cloth_stiffness(PhysicButtonsPanel): bpy.types.register(Physic_PT_cloth) bpy.types.register(Physic_PT_cloth_collision) -bpy.types.register(Physic_PT_cloth_stiffness) \ No newline at end of file +bpy.types.register(Physic_PT_cloth_stiffness) diff --git a/release/ui/buttons_scene.py b/release/ui/buttons_scene.py index 561e5b94e3e..d7f215f2297 100644 --- a/release/ui/buttons_scene.py +++ b/release/ui/buttons_scene.py @@ -218,4 +218,4 @@ bpy.types.register(RENDER_PT_dimensions) bpy.types.register(RENDER_PT_antialiasing) bpy.types.register(RENDER_PT_shading) bpy.types.register(RENDER_PT_output) -bpy.types.register(RENDER_PT_stamp) \ No newline at end of file +bpy.types.register(RENDER_PT_stamp) diff --git a/release/ui/buttons_texture.py b/release/ui/buttons_texture.py index ccdbda5d54d..7d0ef9371d7 100644 --- a/release/ui/buttons_texture.py +++ b/release/ui/buttons_texture.py @@ -7,8 +7,7 @@ class TextureButtonsPanel(bpy.types.Panel): __context__ = "texture" def poll(self, context): - try: return (context.active_object.active_material.active_texture.texture != None) - except:return False + return (context.texture != None) class TEXTURE_PT_preview(TextureButtonsPanel): __idname__= "TEXTURE_PT_preview" @@ -17,7 +16,7 @@ class TEXTURE_PT_preview(TextureButtonsPanel): def draw(self, context): layout = self.layout - tex = context.active_object.active_material.active_texture.texture + tex = context.texture layout.template_preview(tex) class TEXTURE_PT_texture(TextureButtonsPanel): @@ -26,21 +25,38 @@ class TEXTURE_PT_texture(TextureButtonsPanel): def draw(self, context): layout = self.layout - tex = context.active_object.active_material.active_texture.texture + tex = context.texture layout.itemR(tex, "type") +class TEXTURE_PT_colors(TextureButtonsPanel): + __idname__= "TEXTURE_PT_colors" + __label__ = "Colors" + + def draw(self, context): + layout = self.layout + tex = context.texture + + if tex.color_ramp: + layout.template_color_ramp(tex.color_ramp, expand=True) + else: + layout.itemR(tex, "rgb_factor") + + row = layout.row() + row.itemR(tex, "brightness") + row.itemR(tex, "contrast") + class TEXTURE_PT_clouds(TextureButtonsPanel): __idname__= "TEXTURE_PT_clouds" __label__ = "Clouds" def poll(self, context): - try: return (context.active_object.active_material.active_texture.texture.type == 'CLOUDS') - except:return False + tex = context.texture + return (tex and tex.type == 'CLOUDS') def draw(self, context): layout = self.layout - tex = context.active_object.active_material.active_texture.texture + tex = context.texture layout.itemR(tex, "stype", expand=True) layout.itemL(text="Noise:") @@ -57,12 +73,12 @@ class TEXTURE_PT_wood(TextureButtonsPanel): __label__ = "Wood" def poll(self, context): - try: return (context.active_object.active_material.active_texture.texture.type == 'WOOD') - except:return False + tex = context.texture + return (tex and tex.type == 'WOOD') def draw(self, context): layout = self.layout - tex = context.active_object.active_material.active_texture.texture + tex = context.texture layout.itemR(tex, "stype", expand=True) layout.itemR(tex, "noisebasis2", expand=True) @@ -80,12 +96,12 @@ class TEXTURE_PT_marble(TextureButtonsPanel): __label__ = "Marble" def poll(self, context): - try: return (context.active_object.active_material.active_texture.texture.type == 'MARBLE') - except:return False + tex = context.texture + return (tex and tex.type == 'MARBLE') def draw(self, context): layout = self.layout - tex = context.active_object.active_material.active_texture.texture + tex = context.texture layout.itemR(tex, "stype", expand=True) layout.itemR(tex, "noisebasis2", expand=True) @@ -104,12 +120,12 @@ class TEXTURE_PT_magic(TextureButtonsPanel): __label__ = "Magic" def poll(self, context): - try: return (context.active_object.active_material.active_texture.texture.type == 'MAGIC') - except:return False + tex = context.texture + return (tex and tex.type == 'MAGIC') def draw(self, context): layout = self.layout - tex = context.active_object.active_material.active_texture.texture + tex = context.texture row = layout.row() row.itemR(tex, "noise_depth", text="Depth") @@ -120,12 +136,12 @@ class TEXTURE_PT_blend(TextureButtonsPanel): __label__ = "Blend" def poll(self, context): - try: return (context.active_object.active_material.active_texture.texture.type == 'BLEND') - except:return False + tex = context.texture + return (tex and tex.type == 'BLEND') def draw(self, context): layout = self.layout - tex = context.active_object.active_material.active_texture.texture + tex = context.texture layout.itemR(tex, "progression") layout.itemR(tex, "flip_axis") @@ -135,12 +151,12 @@ class TEXTURE_PT_stucci(TextureButtonsPanel): __label__ = "Stucci" def poll(self, context): - try: return (context.active_object.active_material.active_texture.texture.type == 'STUCCI') - except:return False + tex = context.texture + return (tex and tex.type == 'STUCCI') def draw(self, context): layout = self.layout - tex = context.active_object.active_material.active_texture.texture + tex = context.texture layout.itemR(tex, "stype", expand=True) layout.itemL(text="Noise:") @@ -156,12 +172,12 @@ class TEXTURE_PT_image(TextureButtonsPanel): __label__ = "Image/Movie" def poll(self, context): - try: return (context.active_object.active_material.active_texture.texture.type == 'IMAGE') - except:return False + tex = context.texture + return (tex and tex.type == 'IMAGE') def draw(self, context): layout = self.layout - tex = context.active_object.active_material.active_texture.texture + tex = context.texture split = layout.split() @@ -183,12 +199,12 @@ class TEXTURE_PT_mapping(TextureButtonsPanel): __label__ = "Mapping" def poll(self, context): - try: return (context.active_object.active_material.active_texture.texture.type == 'IMAGE') - except:return False + tex = context.texture + return (tex and tex.type == 'IMAGE') def draw(self, context): layout = self.layout - tex = context.active_object.active_material.active_texture.texture + tex = context.texture split = layout.split() @@ -226,12 +242,12 @@ class TEXTURE_PT_plugin(TextureButtonsPanel): __label__ = "Plugin" def poll(self, context): - try: return (context.active_object.active_material.active_texture.texture.type == 'PLUGIN') - except:return False + tex = context.texture + return (tex and tex.type == 'PLUGIN') def draw(self, context): layout = self.layout - tex = context.active_object.active_material.active_texture.texture + tex = context.texture layout.itemL(text="Nothing yet") @@ -240,12 +256,12 @@ class TEXTURE_PT_envmap(TextureButtonsPanel): __label__ = "Environment Map" def poll(self, context): - try: return (context.active_object.active_material.active_texture.texture.type == 'ENVIRONMENT_MAP') - except:return False + tex = context.texture + return (tex and tex.type == 'ENVIRONMENT_MAP') def draw(self, context): layout = self.layout - tex = context.active_object.active_material.active_texture.texture + tex = context.texture layout.itemL(text="Nothing yet") @@ -254,12 +270,12 @@ class TEXTURE_PT_musgrave(TextureButtonsPanel): __label__ = "Musgrave" def poll(self, context): - try: return (context.active_object.active_material.active_texture.texture.type == 'MUSGRAVE') - except:return False + tex = context.texture + return (tex and tex.type == 'MUSGRAVE') def draw(self, context): layout = self.layout - tex = context.active_object.active_material.active_texture.texture + tex = context.texture layout.itemR(tex, "musgrave_type") @@ -289,13 +305,12 @@ class TEXTURE_PT_voronoi(TextureButtonsPanel): __label__ = "Voronoi" def poll(self, context): - try: return (context.active_object.active_material.active_texture.texture.type == 'VORONOI') - except:return False - + tex = context.texture + return (tex and tex.type == 'VORONOI') def draw(self, context): layout = self.layout - tex = context.active_object.active_material.active_texture.texture + tex = context.texture layout.itemR(tex, "distance_metric") layout.itemR(tex, "coloring") @@ -321,12 +336,12 @@ class TEXTURE_PT_distortednoise(TextureButtonsPanel): __label__ = "Distorted Noise" def poll(self, context): - try: return (context.active_object.active_material.active_texture.texture.type == 'DISTORTED_NOISE') - except:return False + tex = context.texture + return (tex and tex.type == 'DISTORTED_NOISE') def draw(self, context): layout = self.layout - tex = context.active_object.active_material.active_texture.texture + tex = context.texture layout.itemR(tex, "noise_distortion") layout.itemR(tex, "noise_basis", text="Basis") @@ -342,6 +357,7 @@ class TEXTURE_PT_distortednoise(TextureButtonsPanel): bpy.types.register(TEXTURE_PT_preview) bpy.types.register(TEXTURE_PT_texture) +bpy.types.register(TEXTURE_PT_colors) bpy.types.register(TEXTURE_PT_clouds) bpy.types.register(TEXTURE_PT_wood) bpy.types.register(TEXTURE_PT_marble) diff --git a/release/ui/buttons_world.py b/release/ui/buttons_world.py index f12a76bfb66..79826e04dfc 100644 --- a/release/ui/buttons_world.py +++ b/release/ui/buttons_world.py @@ -7,7 +7,7 @@ class WorldButtonsPanel(bpy.types.Panel): __context__ = "world" def poll(self, context): - return (context.scene.world != None) + return (context.world != None) class WORLD_PT_preview(WorldButtonsPanel): __label__ = "Preview" @@ -15,14 +15,14 @@ class WORLD_PT_preview(WorldButtonsPanel): def draw(self, context): layout = self.layout - world = context.scene.world + world = context.world layout.template_preview(world) class WORLD_PT_world(WorldButtonsPanel): __label__ = "World" def draw(self, context): - world = context.scene.world + world = context.world layout = self.layout row = layout.row() @@ -32,14 +32,16 @@ class WORLD_PT_world(WorldButtonsPanel): row = layout.row() row.column().itemR(world, "horizon_color") - row.column().itemR(world, "zenith_color") + col = row.column() + col.itemR(world, "zenith_color") + col.active = world.blend_sky row.column().itemR(world, "ambient_color") class WORLD_PT_color_correction(WorldButtonsPanel): __label__ = "Color Correction" def draw(self, context): - world = context.scene.world + world = context.world layout = self.layout row = layout.row() @@ -50,13 +52,13 @@ class WORLD_PT_mist(WorldButtonsPanel): __label__ = "Mist" def draw_header(self, context): - world = context.scene.world + world = context.world layout = self.layout layout.itemR(world.mist, "enabled", text="") def draw(self, context): - world = context.scene.world + world = context.world layout = self.layout layout.active = world.mist.enabled @@ -73,13 +75,13 @@ class WORLD_PT_stars(WorldButtonsPanel): __label__ = "Stars" def draw_header(self, context): - world = context.scene.world + world = context.world layout = self.layout layout.itemR(world.stars, "enabled", text="") def draw(self, context): - world = context.scene.world + world = context.world layout = self.layout layout.active = world.stars.enabled @@ -93,13 +95,13 @@ class WORLD_PT_ambient_occlusion(WorldButtonsPanel): __label__ = "Ambient Occlusion" def draw_header(self, context): - world = context.scene.world + world = context.world layout = self.layout layout.itemR(world.ambient_occlusion, "enabled", text="") def draw(self, context): - world = context.scene.world + world = context.world ao = world.ambient_occlusion layout = self.layout layout.active = ao.enabled @@ -150,4 +152,4 @@ bpy.types.register(WORLD_PT_world) bpy.types.register(WORLD_PT_ambient_occlusion) bpy.types.register(WORLD_PT_mist) bpy.types.register(WORLD_PT_stars) -bpy.types.register(WORLD_PT_color_correction) \ No newline at end of file +bpy.types.register(WORLD_PT_color_correction) From a3c0730f990fda65c305736e45925ced9abe8bcc Mon Sep 17 00:00:00 2001 From: Robin Allen Date: Wed, 3 Jun 2009 00:40:38 +0000 Subject: [PATCH 12/35] RNA: more compositor nodes wrapped --- source/blender/makesrna/intern/rna_nodetree.c | 722 ++++++++++++++---- .../makesrna/intern/rna_nodetree_types.h | 214 +++--- 2 files changed, 682 insertions(+), 254 deletions(-) diff --git a/source/blender/makesrna/intern/rna_nodetree.c b/source/blender/makesrna/intern/rna_nodetree.c index 9594a1a4a05..ff7984ff1b1 100644 --- a/source/blender/makesrna/intern/rna_nodetree.c +++ b/source/blender/makesrna/intern/rna_nodetree.c @@ -32,6 +32,7 @@ #include "DNA_node_types.h" #include "DNA_scene_types.h" +#include "DNA_texture_types.h" #include "BKE_node.h" #ifdef RNA_RUNTIME @@ -341,26 +342,6 @@ static void def_texture(BlenderRNA *brna, int id) } -/* -- Shader Node Storage Types --------------------------------------------- */ - -static void rna_def_storage_node_geometry(BlenderRNA *brna) -{ - StructRNA *srna; - PropertyRNA *prop; - - srna = RNA_def_struct(brna, "NodeGeometry", NULL); - RNA_def_struct_ui_text(srna, "Node Geometry", ""); - - prop = RNA_def_property(srna, "uv_layer", PROP_STRING, PROP_NONE); - RNA_def_property_string_sdna(prop, NULL, "uvname"); - RNA_def_property_ui_text(prop, "UV Layer", ""); - - prop = RNA_def_property(srna, "color_layer", PROP_STRING, PROP_NONE); - RNA_def_property_string_sdna(prop, NULL, "colname"); - RNA_def_property_ui_text(prop, "Vertex Color Layer", ""); -} - - /* -- Shader Nodes ---------------------------------------------------------- */ static void def_sh_material(BlenderRNA *brna, int id) @@ -408,109 +389,15 @@ static void def_sh_geometry(BlenderRNA *brna, int id) PropertyRNA *prop; srna = def_node(brna, id); + RNA_def_struct_sdna_from(srna, "NodeGeometry", "storage"); - prop = RNA_def_property(srna, "settings", PROP_POINTER, PROP_NONE); - RNA_def_property_pointer_sdna(prop, NULL, "storage"); - RNA_def_property_struct_type(prop, "NodeGeometry"); - RNA_def_property_ui_text(prop, "Settings", ""); -} - - -/* -- Compositor Node Storage Types ----------------------------------------- */ - -static void rna_def_storage_node_blur_data(BlenderRNA *brna) -{ - StructRNA *srna; - PropertyRNA *prop; - - static EnumPropertyItem filter_type_items[] ={ - {R_FILTER_BOX, "FLAT", "Flat", ""}, - {R_FILTER_TENT, "TENT", "Tent", ""}, - {R_FILTER_QUAD, "QUAD", "Quadratic", ""}, - {R_FILTER_CUBIC, "CUBIC", "Cubic", ""}, - {R_FILTER_GAUSS, "GAUSS", "Gaussian", ""}, - {R_FILTER_FAST_GAUSS, "FAST_GAUSS", "Fast Gaussian", ""}, - {R_FILTER_CATROM, "CATROM", "Catrom", ""}, - {R_FILTER_MITCH, "MITCH", "Mitch", ""}, - {0, NULL, NULL, NULL} - }; - - srna = RNA_def_struct(brna, "NodeBlurData", NULL); - RNA_def_struct_ui_text(srna, "Node Blur Data", ""); - - /**/ - - prop = RNA_def_property(srna, "sizex", PROP_INT, PROP_NONE); - RNA_def_property_int_sdna(prop, NULL, "sizex"); - RNA_def_property_ui_text(prop, "Size X", ""); - - prop = RNA_def_property(srna, "sizey", PROP_INT, PROP_NONE); - RNA_def_property_int_sdna(prop, NULL, "sizey"); - RNA_def_property_ui_text(prop, "Size Y", ""); - - /**/ - - prop = RNA_def_property(srna, "samples", PROP_INT, PROP_NONE); - RNA_def_property_int_sdna(prop, NULL, "samples"); - RNA_def_property_ui_text(prop, "Samples", ""); - - /**/ - - prop = RNA_def_property(srna, "max_speed", PROP_INT, PROP_NONE); - RNA_def_property_int_sdna(prop, NULL, "maxspeed"); - RNA_def_property_ui_text(prop, "Max Speed", ""); - - prop = RNA_def_property(srna, "min_speed", PROP_INT, PROP_NONE); - RNA_def_property_int_sdna(prop, NULL, "minspeed"); - RNA_def_property_ui_text(prop, "Min Speed", ""); - - /**/ - - prop = RNA_def_property(srna, "relative", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "relative", 1); - RNA_def_property_ui_text(prop, "Relative", ""); - - /**/ - - prop = RNA_def_property(srna, "factor", PROP_FLOAT, PROP_NONE); - RNA_def_property_float_sdna(prop, NULL, "fac"); - RNA_def_property_ui_text(prop, "Factor", ""); - - /* These aren't percentages */ - prop = RNA_def_property(srna, "factor_x", PROP_FLOAT, PROP_NONE); - RNA_def_property_float_sdna(prop, NULL, "percentx"); - RNA_def_property_ui_text(prop, "Relative Size X", ""); - - prop = RNA_def_property(srna, "factor_y", PROP_FLOAT, PROP_NONE); - RNA_def_property_float_sdna(prop, NULL, "percenty"); - RNA_def_property_ui_text(prop, "Relative Size Y", ""); - - /**/ - - prop = RNA_def_property(srna, "filter_type", PROP_ENUM, PROP_NONE); - RNA_def_property_enum_sdna(prop, NULL, "filtertype"); - RNA_def_property_enum_items(prop, filter_type_items); - RNA_def_property_ui_text(prop, "Filter Type", ""); - - /**/ - - prop = RNA_def_property(srna, "bokeh", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "bokeh", 1); - RNA_def_property_ui_text(prop, "Bokeh", ""); - - prop = RNA_def_property(srna, "gamma", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "gamma", 1); - RNA_def_property_ui_text(prop, "Gamma", ""); - - /* - Also: - curved - image_in_width - image_in_height - - Don't know if these need wrapping - */ + prop = RNA_def_property(srna, "uv_layer", PROP_STRING, PROP_NONE); + RNA_def_property_string_sdna(prop, NULL, "uvname"); + RNA_def_property_ui_text(prop, "UV Layer", ""); + prop = RNA_def_property(srna, "color_layer", PROP_STRING, PROP_NONE); + RNA_def_property_string_sdna(prop, NULL, "colname"); + RNA_def_property_ui_text(prop, "Vertex Color Layer", ""); } @@ -534,13 +421,80 @@ static void def_cmp_blur(BlenderRNA *brna, int id) { StructRNA *srna; PropertyRNA *prop; + + static EnumPropertyItem filter_type_items[] ={ + {R_FILTER_BOX, "FLAT", "Flat", ""}, + {R_FILTER_TENT, "TENT", "Tent", ""}, + {R_FILTER_QUAD, "QUAD", "Quadratic", ""}, + {R_FILTER_CUBIC, "CUBIC", "Cubic", ""}, + {R_FILTER_GAUSS, "GAUSS", "Gaussian", ""}, + {R_FILTER_FAST_GAUSS, "FAST_GAUSS", "Fast Gaussian", ""}, + {R_FILTER_CATROM, "CATROM", "Catrom", ""}, + {R_FILTER_MITCH, "MITCH", "Mitch", ""}, + {0, NULL, NULL, NULL} + }; srna = def_node(brna, id); + RNA_def_struct_sdna_from(srna, "NodeBlurData", "storage"); + + prop = RNA_def_property(srna, "sizex", PROP_INT, PROP_NONE); + RNA_def_property_int_sdna(prop, NULL, "sizex"); + RNA_def_property_ui_text(prop, "Size X", ""); + + prop = RNA_def_property(srna, "sizey", PROP_INT, PROP_NONE); + RNA_def_property_int_sdna(prop, NULL, "sizey"); + RNA_def_property_ui_text(prop, "Size Y", ""); + + prop = RNA_def_property(srna, "samples", PROP_INT, PROP_NONE); + RNA_def_property_int_sdna(prop, NULL, "samples"); + RNA_def_property_ui_text(prop, "Samples", ""); + + prop = RNA_def_property(srna, "max_speed", PROP_INT, PROP_NONE); + RNA_def_property_int_sdna(prop, NULL, "maxspeed"); + RNA_def_property_ui_text(prop, "Max Speed", ""); + + prop = RNA_def_property(srna, "min_speed", PROP_INT, PROP_NONE); + RNA_def_property_int_sdna(prop, NULL, "minspeed"); + RNA_def_property_ui_text(prop, "Min Speed", ""); + + prop = RNA_def_property(srna, "relative", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "relative", 1); + RNA_def_property_ui_text(prop, "Relative", ""); + + prop = RNA_def_property(srna, "factor", PROP_FLOAT, PROP_NONE); + RNA_def_property_float_sdna(prop, NULL, "fac"); + RNA_def_property_ui_text(prop, "Factor", ""); + + prop = RNA_def_property(srna, "factor_x", PROP_FLOAT, PROP_NONE); + RNA_def_property_float_sdna(prop, NULL, "percentx"); + RNA_def_property_ui_text(prop, "Relative Size X", ""); + + prop = RNA_def_property(srna, "factor_y", PROP_FLOAT, PROP_NONE); + RNA_def_property_float_sdna(prop, NULL, "percenty"); + RNA_def_property_ui_text(prop, "Relative Size Y", ""); + + prop = RNA_def_property(srna, "filter_type", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_sdna(prop, NULL, "filtertype"); + RNA_def_property_enum_items(prop, filter_type_items); + RNA_def_property_ui_text(prop, "Filter Type", ""); + + prop = RNA_def_property(srna, "bokeh", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "bokeh", 1); + RNA_def_property_ui_text(prop, "Bokeh", ""); + + prop = RNA_def_property(srna, "gamma", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "gamma", 1); + RNA_def_property_ui_text(prop, "Gamma", ""); + + /* + TODO: + curved + image_in_width + image_in_height + + Don't know if these need wrapping + */ - prop = RNA_def_property(srna, "settings", PROP_POINTER, PROP_NONE); - RNA_def_property_pointer_sdna(prop, NULL, "storage"); - RNA_def_property_struct_type(prop, "NodeBlurData"); - RNA_def_property_ui_text(prop, "Settings", ""); } static void def_cmp_filter(BlenderRNA *brna, int id) @@ -567,22 +521,505 @@ static void def_cmp_filter(BlenderRNA *brna, int id) RNA_def_property_ui_text(prop, "Type", ""); } - -/* -- Texture Node Storage Types --------------------------------------------- */ - -static void rna_def_storage_tex_node_output(BlenderRNA *brna) +static void def_cmp_map_value(BlenderRNA *brna, int id) { StructRNA *srna; PropertyRNA *prop; - srna = RNA_def_struct(brna, "TexNodeOutput", NULL); - RNA_def_struct_ui_text(srna, "Texture Node Output", ""); + srna = def_node(brna, id); + RNA_def_struct_sdna_from(srna, "TexMapping", "storage"); - prop = RNA_def_property(srna, "name", PROP_STRING, PROP_NONE); - RNA_def_property_string_sdna(prop, NULL, "name"); - RNA_def_property_ui_text(prop, "Name", ""); + prop = RNA_def_property(srna, "offset", PROP_FLOAT, PROP_NONE); + RNA_def_property_float_sdna(prop, NULL, "loc"); + RNA_def_property_ui_text(prop, "Offset", ""); + + prop = RNA_def_property(srna, "size", PROP_FLOAT, PROP_NONE); + RNA_def_property_float_sdna(prop, NULL, "size"); + RNA_def_property_ui_text(prop, "Size", ""); + + prop = RNA_def_property(srna, "use_min", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", TEXMAP_CLIP_MIN); + RNA_def_property_ui_text(prop, "Use Minimum", ""); + + prop = RNA_def_property(srna, "use_max", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", TEXMAP_CLIP_MAX); + RNA_def_property_ui_text(prop, "Use Maximum", ""); + + prop = RNA_def_property(srna, "min", PROP_FLOAT, PROP_NONE); + RNA_def_property_float_sdna(prop, NULL, "min"); + RNA_def_property_ui_text(prop, "Minimum", ""); + + prop = RNA_def_property(srna, "max", PROP_FLOAT, PROP_NONE); + RNA_def_property_float_sdna(prop, NULL, "max"); + RNA_def_property_ui_text(prop, "Maximum", ""); } +static void def_cmp_vector_blur(BlenderRNA *brna, int id) +{ + StructRNA *srna; + PropertyRNA *prop; + + srna = def_node(brna, id); + RNA_def_struct_sdna_from(srna, "NodeBlurData", "storage"); + + prop = RNA_def_property(srna, "samples", PROP_INT, PROP_NONE); + RNA_def_property_int_sdna(prop, NULL, "samples"); + RNA_def_property_ui_text(prop, "Samples", ""); + + prop = RNA_def_property(srna, "min_speed", PROP_INT, PROP_NONE); + RNA_def_property_int_sdna(prop, NULL, "minspeed"); + RNA_def_property_ui_text(prop, "Min Speed", "Minimum speed for a pixel to be blurred; used to separate background from foreground"); + + prop = RNA_def_property(srna, "max_speed", PROP_INT, PROP_NONE); + RNA_def_property_int_sdna(prop, NULL, "maxspeed"); + RNA_def_property_ui_text(prop, "Min Speed", "Maximum speed, or zero for none"); + + prop = RNA_def_property(srna, "factor", PROP_FLOAT, PROP_NONE); + RNA_def_property_float_sdna(prop, NULL, "fac"); + RNA_def_property_ui_text(prop, "Blur Factor", "Scaling factor for motion vectors; actually 'shutter speed' in frames"); + + prop = RNA_def_property(srna, "curved", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "curved", 1); + RNA_def_property_ui_text(prop, "Curved", "Interpolate between frames in a bezier curve, rather than linearly"); +} + +static void def_cmp_image(BlenderRNA *brna, int id) +{ + StructRNA *srna; + PropertyRNA *prop; + + srna = def_node(brna, id); + RNA_def_struct_sdna_from(srna, "ImageUser", "storage"); + + /* TODO. uses storage and id. */ + +} + +static void def_cmp_render_layers(BlenderRNA *brna, int id) +{ + StructRNA *srna; + PropertyRNA *prop; + + srna = def_node(brna, id); + + /* TODO. users customx and id. */ + +} + +static void def_cmp_output_file(BlenderRNA *brna, int id) +{ + StructRNA *srna; + PropertyRNA *prop; + + srna = def_node(brna, id); + + /* TODO. */ + +} + +static void def_cmp_texture(BlenderRNA *brna, int id) +{ + StructRNA *srna; + PropertyRNA *prop; + + srna = def_node(brna, id); + + /* TODO. */ + +} + +static void def_cmp_dilate_erode(BlenderRNA *brna, int id) +{ + StructRNA *srna; + PropertyRNA *prop; + + srna = def_node(brna, id); + + prop = RNA_def_property(srna, "distance", PROP_INT, PROP_NONE); + RNA_def_property_int_sdna(prop, NULL, "custom2"); + RNA_def_property_ui_text(prop, "Distance", "Distance to grow/shrink (number of iterations)"); +} + +static void def_cmp_scale(BlenderRNA *brna, int id) +{ + StructRNA *srna; + PropertyRNA *prop; + + static EnumPropertyItem space_items[] ={ + {0, "RELATIVE", "Relative", ""}, + {1, "ABSOLUTE", "Absolute", ""}, + {2, "SCENE_SIZE", "Scene Size", ""}, + {0, NULL, NULL, NULL} + }; + + srna = def_node(brna, id); + + prop = RNA_def_property(srna, "space", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_sdna(prop, NULL, "custom1"); + RNA_def_property_enum_items(prop, space_items); + RNA_def_property_ui_text(prop, "Space", "Coordinate space to scale relative to"); +} + +static void def_cmp_diff_matte(BlenderRNA *brna, int id) +{ + StructRNA *srna; + PropertyRNA *prop; + + static EnumPropertyItem color_space_items[] ={ + {1, "RGB", "RGB", ""}, + {2, "HSV", "HSV", ""}, + {3, "YUV", "YUV", ""}, + {4, "YCC", "YCbCr", ""}, + {0, NULL, NULL, NULL} + }; + + srna = def_node(brna, id); + + prop = RNA_def_property(srna, "color_space", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_sdna(prop, NULL, "custom1"); + RNA_def_property_enum_items(prop, color_space_items); + RNA_def_property_ui_text(prop, "Color Space", ""); + + RNA_def_struct_sdna_from(srna, "NodeChroma", "storage"); + + /* TODO: nicer wrapping for tolerances */ + + prop = RNA_def_property(srna, "tolerance1", PROP_FLOAT, PROP_NONE); + RNA_def_property_float_sdna(prop, NULL, "t1"); + RNA_def_property_ui_text(prop, "Channel 1 Tolerance", ""); + + prop = RNA_def_property(srna, "tolerance2", PROP_FLOAT, PROP_NONE); + RNA_def_property_float_sdna(prop, NULL, "t2"); + RNA_def_property_ui_text(prop, "Channel 2 Tolerance", ""); + + prop = RNA_def_property(srna, "tolerance3", PROP_FLOAT, PROP_NONE); + RNA_def_property_float_sdna(prop, NULL, "t3"); + RNA_def_property_ui_text(prop, "Channel 3 Tolerance", ""); + + + prop = RNA_def_property(srna, "falloff", PROP_FLOAT, PROP_NONE); + RNA_def_property_float_sdna(prop, NULL, "fstrength"); + RNA_def_property_ui_text(prop, "Falloff", ""); +} + +static void def_cmp_color_spill(BlenderRNA *brna, int id) +{ + StructRNA *srna; + PropertyRNA *prop; + + static EnumPropertyItem channel_items[] ={ + {1, "R", "Red", ""}, + {2, "G", "Green", ""}, + {3, "B", "Blue", ""}, + {0, NULL, NULL, NULL} + }; + + srna = def_node(brna, id); + + prop = RNA_def_property(srna, "channel", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_sdna(prop, NULL, "custom1"); + RNA_def_property_enum_items(prop, channel_items); + RNA_def_property_ui_text(prop, "Channel", ""); + + RNA_def_struct_sdna_from(srna, "NodeChroma", "storage"); + + prop = RNA_def_property(srna, "factor", PROP_FLOAT, PROP_NONE); + RNA_def_property_float_sdna(prop, NULL, "t1"); + RNA_def_property_ui_text(prop, "Amount", "How much the selected channel is affected by"); +} + +static void def_cmp_chroma(BlenderRNA *brna, int id) +{ + StructRNA *srna; + PropertyRNA *prop; + + srna = def_node(brna, id); + + RNA_def_struct_sdna_from(srna, "NodeChroma", "storage"); + + prop = RNA_def_property(srna, "acceptance", PROP_FLOAT, PROP_NONE); + RNA_def_property_float_sdna(prop, NULL, "t1"); + RNA_def_property_ui_text(prop, "Acceptance", "Tolerance for a color to be considered a keying color"); + + prop = RNA_def_property(srna, "cutoff", PROP_FLOAT, PROP_NONE); + RNA_def_property_float_sdna(prop, NULL, "t2"); + RNA_def_property_ui_text(prop, "Cutoff", "Tolerance below which colors will be considered as exact matches"); + + prop = RNA_def_property(srna, "lift", PROP_FLOAT, PROP_NONE); + RNA_def_property_float_sdna(prop, NULL, "fsize"); + RNA_def_property_ui_text(prop, "Lift", "Alpha lift"); + + prop = RNA_def_property(srna, "gain", PROP_FLOAT, PROP_NONE); + RNA_def_property_float_sdna(prop, NULL, "fstrength"); + RNA_def_property_ui_text(prop, "Gain", "Alpha gain"); + + prop = RNA_def_property(srna, "shadow_adjust", PROP_FLOAT, PROP_NONE); + RNA_def_property_float_sdna(prop, NULL, "t3"); + RNA_def_property_ui_text(prop, "Shadow Adjust", "Adjusts the brightness of any shadows captured"); + + /* TODO: + if(c->t2 > c->t1) + c->t2=c->t1; + */ +} + +static void def_cmp_channel_matte(BlenderRNA *brna, int id) +{ + StructRNA *srna; + PropertyRNA *prop; + + static EnumPropertyItem color_space_items[] ={ + {1, "RGB", "RGB", ""}, + {2, "HSV", "HSV", ""}, + {3, "YUV", "YUV", ""}, + {4, "YCC", "YCbCr", ""}, + {0, NULL, NULL, NULL} + }; + + srna = def_node(brna, id); + + prop = RNA_def_property(srna, "color_space", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_sdna(prop, NULL, "custom1"); + RNA_def_property_enum_items(prop, color_space_items); + RNA_def_property_ui_text(prop, "Color Space", ""); + + /* TODO: channel must be 1, 2 or 3 */ + prop = RNA_def_property(srna, "channel", PROP_INT, PROP_NONE); + RNA_def_property_int_sdna(prop, NULL, "custom2"); + RNA_def_property_ui_text(prop, "Channel", ""); + + RNA_def_struct_sdna_from(srna, "NodeChroma", "storage"); + + prop = RNA_def_property(srna, "high", PROP_FLOAT, PROP_NONE); + RNA_def_property_float_sdna(prop, NULL, "t1"); + RNA_def_property_ui_text(prop, "High", "Values higher than this setting are 100% opaque"); + + prop = RNA_def_property(srna, "low", PROP_FLOAT, PROP_NONE); + RNA_def_property_float_sdna(prop, NULL, "t2"); + RNA_def_property_ui_text(prop, "Low", "Values lower than this setting are 100% keyed"); + + /* TODO: + if(c->t2 > c->t1) + c->t2=c->t1; + */ +} + +static void def_cmp_flip(BlenderRNA *brna, int id) +{ + StructRNA *srna; + PropertyRNA *prop; + + static EnumPropertyItem axis_items[] ={ + {0, "X", "X", ""}, + {1, "Y", "Y", ""}, + {2, "XY", "X & Y", ""}, + {0, NULL, NULL, NULL} + }; + + srna = def_node(brna, id); + + prop = RNA_def_property(srna, "axis", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_sdna(prop, NULL, "custom1"); + RNA_def_property_enum_items(prop, axis_items); + RNA_def_property_ui_text(prop, "Axis", ""); +} + +static void def_cmp_splitviewer(BlenderRNA *brna, int id) +{ + StructRNA *srna; + PropertyRNA *prop; + + static EnumPropertyItem axis_items[] ={ + {0, "X", "X", ""}, + {1, "Y", "Y", ""}, + {0, NULL, NULL, NULL} + }; + + srna = def_node(brna, id); + + prop = RNA_def_property(srna, "axis", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_sdna(prop, NULL, "custom2"); + RNA_def_property_enum_items(prop, axis_items); + RNA_def_property_ui_text(prop, "Axis", ""); + + /* TODO: percentage */ + prop = RNA_def_property(srna, "factor", PROP_FLOAT, PROP_NONE); + RNA_def_property_float_sdna(prop, NULL, "custom1"); + RNA_def_property_ui_text(prop, "Factor", ""); +} + +static void def_cmp_id_mask(BlenderRNA *brna, int id) +{ + StructRNA *srna; + PropertyRNA *prop; + + srna = def_node(brna, id); + + prop = RNA_def_property(srna, "index", PROP_INT, PROP_NONE); + RNA_def_property_int_sdna(prop, NULL, "custom1"); + RNA_def_property_ui_text(prop, "Index", "Pass index number to convert to alpha"); +} + +static void def_cmp_map_uv(BlenderRNA *brna, int id) +{ + StructRNA *srna; + PropertyRNA *prop; + + srna = def_node(brna, id); + + /* TODO: percentage */ + prop = RNA_def_property(srna, "alpha", PROP_INT, PROP_NONE); + RNA_def_property_int_sdna(prop, NULL, "custom1"); + RNA_def_property_ui_text(prop, "Alpha", ""); +} + +static void def_cmp_defocus(BlenderRNA *brna, int id) +{ + StructRNA *srna; + PropertyRNA *prop; + + static EnumPropertyItem bokeh_items[] ={ + {8, "Octagon", "OCTAGON", "8 sides"}, + {7, "Heptagon", "HEPTAGON", "7 sides"}, + {6, "Hexagon", "HEXAGON", "6 sides"}, + {5, "Pentagon", "PENTAGON", "5 sides"}, + {4, "Square", "SQUARE", "4 sides"}, + {3, "Triangle", "TRIANGLE", "3 sides"}, + {0, "Circle", "CIRCLE", ""}, + {0, NULL, NULL, NULL} + }; + + srna = def_node(brna, id); + + RNA_def_struct_sdna_from(srna, "NodeDefocus", "storage"); + + prop = RNA_def_property(srna, "bokeh", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_sdna(prop, NULL, "bktype"); + RNA_def_property_enum_items(prop, bokeh_items); + RNA_def_property_ui_text(prop, "Bokeh Type", ""); + + /* TODO: angle in degrees */ + prop = RNA_def_property(srna, "angle", PROP_INT, PROP_NONE); + RNA_def_property_int_sdna(prop, NULL, "rotation"); + RNA_def_property_ui_text(prop, "Angle", "Bokeh shape rotation offset in degrees"); + + prop = RNA_def_property(srna, "gamma_correction", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "gamco", 1); + RNA_def_property_ui_text(prop, "Gamma Correction", "Enable gamma correction before and after main process"); + + /* TODO */ + prop = RNA_def_property(srna, "f_stop", PROP_FLOAT, PROP_NONE); + RNA_def_property_float_sdna(prop, NULL, "fstop"); + RNA_def_property_ui_text(prop, "fStop", "Amount of focal blur, 128=infinity=perfect focus, half the value doubles the blur radius"); + + prop = RNA_def_property(srna, "max_blur", PROP_FLOAT, PROP_NONE); + RNA_def_property_float_sdna(prop, NULL, "maxblur"); + RNA_def_property_ui_text(prop, "Max Blur", "blur limit, maximum CoC radius, 0=no limit"); + + prop = RNA_def_property(srna, "threshold", PROP_FLOAT, PROP_NONE); + RNA_def_property_float_sdna(prop, NULL, "bthresh"); + RNA_def_property_ui_text(prop, "Threshold", "CoC radius threshold, prevents background bleed on in-focus midground, 0=off"); + + prop = RNA_def_property(srna, "preview", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "preview", 1); + RNA_def_property_ui_text(prop, "Preview", "Enable sampling mode, useful for preview when using low samplecounts"); + + prop = RNA_def_property(srna, "samples", PROP_INT, PROP_NONE); + RNA_def_property_int_sdna(prop, NULL, "samples"); + RNA_def_property_ui_text(prop, "Samples", "Number of samples (16=grainy, higher=less noise)"); + + prop = RNA_def_property(srna, "use_zbuffer", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "no_zbuf", 1); + RNA_def_property_ui_text(prop, "Use Z-Buffer", "Disable when using an image as input instead of actual zbuffer (auto enabled if node not image based, eg. time node)"); + + prop = RNA_def_property(srna, "z_scale", PROP_FLOAT, PROP_NONE); + RNA_def_property_float_sdna(prop, NULL, "scale"); + RNA_def_property_ui_text(prop, "Z-Scale", "Scales the Z input when not using a zbuffer, controls maximum blur designated by the color white or input value 1"); + +} + +static void def_cmp_luma_matte(BlenderRNA *brna, int id) +{ + StructRNA *srna; + PropertyRNA *prop; + + srna = def_node(brna, id); + +} + +static void def_cmp_invert(BlenderRNA *brna, int id) +{ + StructRNA *srna; + PropertyRNA *prop; + + srna = def_node(brna, id); + +} + +static void def_cmp_crop(BlenderRNA *brna, int id) +{ + StructRNA *srna; + PropertyRNA *prop; + + srna = def_node(brna, id); + +} + +static void def_cmp_dblur(BlenderRNA *brna, int id) +{ + StructRNA *srna; + PropertyRNA *prop; + + srna = def_node(brna, id); + +} + +static void def_cmp_bilateral_blur(BlenderRNA *brna, int id) +{ + StructRNA *srna; + PropertyRNA *prop; + + srna = def_node(brna, id); + +} + +static void def_cmp_premul_key(BlenderRNA *brna, int id) +{ + StructRNA *srna; + PropertyRNA *prop; + + srna = def_node(brna, id); + +} + +static void def_cmp_glare(BlenderRNA *brna, int id) +{ + StructRNA *srna; + PropertyRNA *prop; + + srna = def_node(brna, id); + +} + +static void def_cmp_tonemap(BlenderRNA *brna, int id) +{ + StructRNA *srna; + PropertyRNA *prop; + + srna = def_node(brna, id); + +} + +static void def_cmp_lensdist(BlenderRNA *brna, int id) +{ + StructRNA *srna; + PropertyRNA *prop; + + srna = def_node(brna, id); + +} + + /* -- Texture Nodes --------------------------------------------------------- */ @@ -592,11 +1029,11 @@ static void def_tex_output(BlenderRNA *brna, int id) PropertyRNA *prop; srna = def_node(brna, id); + RNA_def_struct_sdna_from(srna, "TexNodeOutput", "storage"); - prop = RNA_def_property(srna, "settings", PROP_POINTER, PROP_NONE); - RNA_def_property_pointer_sdna(prop, NULL, "storage"); - RNA_def_property_struct_type(prop, "TexNodeOutput"); - RNA_def_property_ui_text(prop, "Settings", ""); + prop = RNA_def_property(srna, "name", PROP_STRING, PROP_NONE); + RNA_def_property_string_sdna(prop, NULL, "name"); + RNA_def_property_ui_text(prop, "Name", ""); } static void def_tex_image(BlenderRNA *brna, int id) @@ -654,9 +1091,6 @@ static void rna_def_shader_node(BlenderRNA *brna) RNA_def_property_clear_flag(prop, PROP_EDITABLE); RNA_def_property_enum_items(prop, node_type_items); RNA_def_property_ui_text(prop, "Type", ""); - - /* Shader storage types */ - rna_def_storage_node_geometry(brna); } static void rna_def_compositor_node(BlenderRNA *brna) @@ -675,9 +1109,6 @@ static void rna_def_compositor_node(BlenderRNA *brna) RNA_def_property_clear_flag(prop, PROP_EDITABLE); RNA_def_property_enum_items(prop, node_type_items); RNA_def_property_ui_text(prop, "Type", ""); - - /* Compositor storage types */ - rna_def_storage_node_blur_data(brna); } static void rna_def_texture_node(BlenderRNA *brna) @@ -696,9 +1127,6 @@ static void rna_def_texture_node(BlenderRNA *brna) RNA_def_property_clear_flag(prop, PROP_EDITABLE); RNA_def_property_enum_items(prop, node_type_items); RNA_def_property_ui_text(prop, "Type", ""); - - /* Texture storage types */ - rna_def_storage_tex_node_output(brna); } /* -------------------------------------------------------------------------- */ diff --git a/source/blender/makesrna/intern/rna_nodetree_types.h b/source/blender/makesrna/intern/rna_nodetree_types.h index 0c333dfef56..6f934a83e54 100644 --- a/source/blender/makesrna/intern/rna_nodetree_types.h +++ b/source/blender/makesrna/intern/rna_nodetree_types.h @@ -24,110 +24,110 @@ #define TODO 0 -/* Tree type Node ID RNA def function Enum name Struct name UI Name UI Description */ -DefNode( ShaderNode, SH_NODE_OUTPUT, 0, "OUTPUT", Output, "Output", "" ) -DefNode( ShaderNode, SH_NODE_MATERIAL, def_sh_material, "MATERIAL", Material, "Material", "" ) -DefNode( ShaderNode, SH_NODE_RGB, 0, "RGB", RGB, "RGB", "" ) -DefNode( ShaderNode, SH_NODE_VALUE, 0, "VALUE", Value, "Value", "" ) -DefNode( ShaderNode, SH_NODE_MIX_RGB, def_mix_rgb, "MIX_RGB", MixRGB, "MixRGB", "" ) -DefNode( ShaderNode, SH_NODE_VALTORGB, def_val_to_rgb, "VALTORGB", ValToRGB, "Value to RGB", "" ) -DefNode( ShaderNode, SH_NODE_RGBTOBW, 0, "RGBTOBW", RGBToBW, "RGB to BW", "" ) -DefNode( ShaderNode, SH_NODE_TEXTURE, def_texture, "TEXTURE", Texture, "Texture", "" ) -DefNode( ShaderNode, SH_NODE_NORMAL, 0, "NORMAL", Normal, "Normal", "" ) -DefNode( ShaderNode, SH_NODE_GEOMETRY, def_sh_geometry, "GEOMETRY", Geometry, "Geometry", "" ) -DefNode( ShaderNode, SH_NODE_MAPPING, def_sh_mapping, "MAPPING", Mapping, "Mapping", "" ) -DefNode( ShaderNode, SH_NODE_CURVE_VEC, def_vector_curve, "CURVE_VEC", VectorCurve, "Vector Curve", "" ) -DefNode( ShaderNode, SH_NODE_CURVE_RGB, def_rgb_curve, "CURVE_RGB", RGBCurve, "RGB Curve", "" ) -DefNode( ShaderNode, SH_NODE_CAMERA, 0, "CAMERA", CameraData, "Camera Data", "" ) -DefNode( ShaderNode, SH_NODE_MATH, def_math, "MATH", Math, "Math", "" ) -DefNode( ShaderNode, SH_NODE_VECT_MATH, def_vector_math, "VECT_MATH", VectorMath, "Vector Math", "" ) -DefNode( ShaderNode, SH_NODE_SQUEEZE, 0, "SQUEEZE", Squeeze, "Squeeze", "" ) -DefNode( ShaderNode, SH_NODE_MATERIAL_EXT, def_sh_material, "MATERIAL_EXT", ExtendedMaterial, "Extended Material", "" ) -DefNode( ShaderNode, SH_NODE_INVERT, 0, "INVERT", Invert, "Invert", "" ) -DefNode( ShaderNode, SH_NODE_SEPRGB, 0, "SEPRGB", SeparateRGB, "Separate RGB", "" ) -DefNode( ShaderNode, SH_NODE_COMBRGB, 0, "COMBRGB", CombineRGB, "Combine RGB", "" ) -DefNode( ShaderNode, SH_NODE_HUE_SAT, 0, "HUE_SAT", HueSaturation, "Hue/Saturation", "" ) - -DefNode( CompositorNode, CMP_NODE_VIEWER, 0, "VIEWER", Viewer, "Viewer", "" ) -DefNode( CompositorNode, CMP_NODE_RGB, 0, "RGB", RGB, "RGB", "" ) -DefNode( CompositorNode, CMP_NODE_VALUE, 0, "VALUE", Value, "Value", "" ) -DefNode( CompositorNode, CMP_NODE_MIX_RGB, def_mix_rgb, "MIX_RGB", MixRGB, "Mix RGB", "" ) -DefNode( CompositorNode, CMP_NODE_VALTORGB, def_val_to_rgb, "VALTORGB", ValToRGB, "Val to RGB", "" ) -DefNode( CompositorNode, CMP_NODE_RGBTOBW, 0, "RGBTOBW", RGBToBW, "RGB to BW", "" ) -DefNode( CompositorNode, CMP_NODE_NORMAL, 0, "NORMAL", Normal, "Normal", "" ) -DefNode( CompositorNode, CMP_NODE_CURVE_VEC, def_vector_curve, "CURVE_VEC", CurveVec, "Vector Curve", "" ) -DefNode( CompositorNode, CMP_NODE_CURVE_RGB, def_rgb_curve, "CURVE_RGB", CurveRGB, "RGB Curve", "" ) -DefNode( CompositorNode, CMP_NODE_ALPHAOVER, def_cmp_alpha_over, "ALPHAOVER", AlphaOver, "Alpha Over", "" ) -DefNode( CompositorNode, CMP_NODE_BLUR, def_cmp_blur, "BLUR", Blur, "Blur", "" ) -DefNode( CompositorNode, CMP_NODE_FILTER, def_cmp_filter, "FILTER", Filter, "Filter", "" ) -DefNode( CompositorNode, CMP_NODE_MAP_VALUE, TODO, "MAP_VALUE", MapValue, "Map Value", "" ) -DefNode( CompositorNode, CMP_NODE_TIME, def_time, "TIME", Time, "Time", "" ) -DefNode( CompositorNode, CMP_NODE_VECBLUR, TODO, "VECBLUR", VecBlur, "Vector Blur", "" ) -DefNode( CompositorNode, CMP_NODE_SEPRGBA, 0, "SEPRGBA", SepRGBA, "Separate RGBA", "" ) -DefNode( CompositorNode, CMP_NODE_SEPHSVA, 0, "SEPHSVA", SepHSVA, "Separate HSVA", "" ) -DefNode( CompositorNode, CMP_NODE_SETALPHA, 0, "SETALPHA", SetAlpha, "Set Alpha", "" ) -DefNode( CompositorNode, CMP_NODE_HUE_SAT, 0, "HUE_SAT", HueSat, "Hue/Saturation", "" ) -DefNode( CompositorNode, CMP_NODE_IMAGE, TODO, "IMAGE", Image, "Image", "" ) -DefNode( CompositorNode, CMP_NODE_R_LAYERS, TODO, "R_LAYERS", RLayers, "Render Layers", "" ) -DefNode( CompositorNode, CMP_NODE_COMPOSITE, 0, "COMPOSITE", Composite, "Composite", "" ) -DefNode( CompositorNode, CMP_NODE_OUTPUT_FILE, TODO, "OUTPUT_FILE", OutputFile, "Output File", "" ) -DefNode( CompositorNode, CMP_NODE_TEXTURE, TODO, "TEXTURE", Texture, "Texture", "" ) -DefNode( CompositorNode, CMP_NODE_TRANSLATE, 0, "TRANSLATE", Translate, "Translate", "" ) -DefNode( CompositorNode, CMP_NODE_ZCOMBINE, 0, "ZCOMBINE", Zcombine, "Z Combine", "" ) -DefNode( CompositorNode, CMP_NODE_COMBRGBA, 0, "COMBRGBA", CombRGBA, "Combine RGBA", "" ) -DefNode( CompositorNode, CMP_NODE_DILATEERODE, TODO, "DILATEERODE", DilateErode, "Dilate/Erode", "" ) -DefNode( CompositorNode, CMP_NODE_ROTATE, 0, "ROTATE", Rotate, "Rotate", "" ) -DefNode( CompositorNode, CMP_NODE_SCALE, TODO, "SCALE", Scale, "Scale", "" ) -DefNode( CompositorNode, CMP_NODE_SEPYCCA, 0, "SEPYCCA", SepYCCA, "Separate YCCA", "" ) -DefNode( CompositorNode, CMP_NODE_COMBYCCA, 0, "COMBYCCA", CombYCCA, "Combine YCCA", "" ) -DefNode( CompositorNode, CMP_NODE_SEPYUVA, 0, "SEPYUVA", SepYUVA, "Separate YUVA", "" ) -DefNode( CompositorNode, CMP_NODE_COMBYUVA, 0, "COMBYUVA", CombYUVA, "Combine YUVA", "" ) -DefNode( CompositorNode, CMP_NODE_DIFF_MATTE, TODO, "DIFF_MATTE", DiffMatte, "Diff Matte", "" ) -DefNode( CompositorNode, CMP_NODE_COLOR_SPILL, TODO, "COLOR_SPILL", ColorSpill, "Color Spill", "" ) -DefNode( CompositorNode, CMP_NODE_CHROMA, TODO, "CHROMA", Chroma, "Chroma", "" ) -DefNode( CompositorNode, CMP_NODE_CHANNEL_MATTE, TODO, "CHANNEL_MATTE", ChannelMatte, "Channel Matte", "" ) -DefNode( CompositorNode, CMP_NODE_FLIP, TODO, "FLIP", Flip, "Flip", "" ) -DefNode( CompositorNode, CMP_NODE_SPLITVIEWER, TODO, "SPLITVIEWER", SplitViewer, "Split Viewer", "" ) -DefNode( CompositorNode, CMP_NODE_INDEX_MASK, TODO, "INDEX_MASK", IndexMask, "Index Mask", "" ) -DefNode( CompositorNode, CMP_NODE_MAP_UV, TODO, "MAP_UV", MapUV, "Map UV", "" ) -DefNode( CompositorNode, CMP_NODE_ID_MASK, TODO, "ID_MASK", IDMask, "ID Mask", "" ) -DefNode( CompositorNode, CMP_NODE_DEFOCUS, TODO, "DEFOCUS", Defocus, "Defocus", "" ) -DefNode( CompositorNode, CMP_NODE_DISPLACE, 0, "DISPLACE", Displace, "Displace", "" ) -DefNode( CompositorNode, CMP_NODE_COMBHSVA, 0, "COMBHSVA", CombHSVA, "Combine HSVA", "" ) -DefNode( CompositorNode, CMP_NODE_MATH, def_math, "MATH", Math, "Math", "" ) -DefNode( CompositorNode, CMP_NODE_LUMA_MATTE, TODO, "LUMA_MATTE", LumaMatte, "Luma Matte", "" ) -DefNode( CompositorNode, CMP_NODE_BRIGHTCONTRAST, 0, "BRIGHTCONTRAST", BrightContrast, "Bright Contrast", "" ) -DefNode( CompositorNode, CMP_NODE_GAMMA, 0, "GAMMA", Gamma, "Gamma", "" ) -DefNode( CompositorNode, CMP_NODE_INVERT, TODO, "INVERT", Invert, "Invert", "" ) -DefNode( CompositorNode, CMP_NODE_NORMALIZE, 0, "NORMALIZE", Normalize, "Normalize", "" ) -DefNode( CompositorNode, CMP_NODE_CROP, TODO, "CROP", Crop, "Crop", "" ) -DefNode( CompositorNode, CMP_NODE_DBLUR, TODO, "DBLUR", DBlur, "DBlur", "" ) -DefNode( CompositorNode, CMP_NODE_BILATERALBLUR, TODO, "BILATERALBLUR", Bilateralblur, "Bilateral Blur", "" ) -DefNode( CompositorNode, CMP_NODE_PREMULKEY, TODO, "PREMULKEY", PremulKey, "Premul Key", "" ) -DefNode( CompositorNode, CMP_NODE_GLARE, TODO, "GLARE", Glare, "Glare", "" ) -DefNode( CompositorNode, CMP_NODE_TONEMAP, TODO, "TONEMAP", Tonemap, "Tonemap", "" ) -DefNode( CompositorNode, CMP_NODE_LENSDIST, TODO, "LENSDIST", Lensdist, "Lensdist", "" ) - -DefNode( TextureNode, TEX_NODE_OUTPUT, def_tex_output, "OUTPUT", Output, "Output", "" ) -DefNode( TextureNode, TEX_NODE_CHECKER, 0, "CHECKER", Checker, "Checker", "" ) -DefNode( TextureNode, TEX_NODE_TEXTURE, def_texture, "TEXTURE", Texture, "Texture", "" ) -DefNode( TextureNode, TEX_NODE_BRICKS, def_tex_bricks, "BRICKS", Bricks, "Bricks", "" ) -DefNode( TextureNode, TEX_NODE_MATH, def_math, "MATH", Math, "Math", "" ) -DefNode( TextureNode, TEX_NODE_MIX_RGB, def_mix_rgb, "MIX_RGB", MixRGB, "Mix RGB", "" ) -DefNode( TextureNode, TEX_NODE_RGBTOBW, 0, "RGBTOBW", RGBToBW, "RGB To BW", "" ) -DefNode( TextureNode, TEX_NODE_VALTORGB, def_val_to_rgb, "VALTORGB", ValToRGB, "Val To RGB", "" ) -DefNode( TextureNode, TEX_NODE_IMAGE, def_tex_image, "IMAGE", Image, "Image", "" ) -DefNode( TextureNode, TEX_NODE_CURVE_RGB, def_rgb_curve, "CURVE_RGB", CurveRGB, "RGB Curve", "" ) -DefNode( TextureNode, TEX_NODE_INVERT, 0, "INVERT", Invert, "Invert", "" ) -DefNode( TextureNode, TEX_NODE_HUE_SAT, 0, "HUE_SAT", HueSaturation, "Hue/Saturation", "" ) -DefNode( TextureNode, TEX_NODE_CURVE_TIME, def_time, "CURVE_TIME", CurveTime, "Curve Time", "" ) -DefNode( TextureNode, TEX_NODE_ROTATE, 0, "ROTATE", Rotate, "Rotate", "" ) -DefNode( TextureNode, TEX_NODE_VIEWER, 0, "VIEWER", Viewer, "Viewer", "" ) -DefNode( TextureNode, TEX_NODE_TRANSLATE, 0, "TRANSLATE", Translate, "Translate", "" ) -DefNode( TextureNode, TEX_NODE_COORD, 0, "COORD", Coordinates, "Coordinates", "" ) -DefNode( TextureNode, TEX_NODE_DISTANCE, 0, "DISTANCE", Distance, "Distance", "" ) -DefNode( TextureNode, TEX_NODE_COMPOSE, 0, "COMPOSE", Compose, "Compose", "" ) -DefNode( TextureNode, TEX_NODE_DECOMPOSE, 0, "DECOMPOSE", Decompose, "Decompose", "" ) -DefNode( TextureNode, TEX_NODE_VALTONOR, 0, "VALTONOR", ValToNor, "Val to Nor", "" ) -DefNode( TextureNode, TEX_NODE_SCALE, 0, "SCALE", Scale, "Scale", "" ) - +/* Tree type Node ID RNA def function Enum name Struct name UI Name UI Description */ +DefNode( ShaderNode, SH_NODE_OUTPUT, 0, "OUTPUT", Output, "Output", "" ) +DefNode( ShaderNode, SH_NODE_MATERIAL, def_sh_material, "MATERIAL", Material, "Material", "" ) +DefNode( ShaderNode, SH_NODE_RGB, 0, "RGB", RGB, "RGB", "" ) +DefNode( ShaderNode, SH_NODE_VALUE, 0, "VALUE", Value, "Value", "" ) +DefNode( ShaderNode, SH_NODE_MIX_RGB, def_mix_rgb, "MIX_RGB", MixRGB, "MixRGB", "" ) +DefNode( ShaderNode, SH_NODE_VALTORGB, def_val_to_rgb, "VALTORGB", ValToRGB, "Value to RGB", "" ) +DefNode( ShaderNode, SH_NODE_RGBTOBW, 0, "RGBTOBW", RGBToBW, "RGB to BW", "" ) +DefNode( ShaderNode, SH_NODE_TEXTURE, def_texture, "TEXTURE", Texture, "Texture", "" ) +DefNode( ShaderNode, SH_NODE_NORMAL, 0, "NORMAL", Normal, "Normal", "" ) +DefNode( ShaderNode, SH_NODE_GEOMETRY, def_sh_geometry, "GEOMETRY", Geometry, "Geometry", "" ) +DefNode( ShaderNode, SH_NODE_MAPPING, def_sh_mapping, "MAPPING", Mapping, "Mapping", "" ) +DefNode( ShaderNode, SH_NODE_CURVE_VEC, def_vector_curve, "CURVE_VEC", VectorCurve, "Vector Curve", "" ) +DefNode( ShaderNode, SH_NODE_CURVE_RGB, def_rgb_curve, "CURVE_RGB", RGBCurve, "RGB Curve", "" ) +DefNode( ShaderNode, SH_NODE_CAMERA, 0, "CAMERA", CameraData, "Camera Data", "" ) +DefNode( ShaderNode, SH_NODE_MATH, def_math, "MATH", Math, "Math", "" ) +DefNode( ShaderNode, SH_NODE_VECT_MATH, def_vector_math, "VECT_MATH", VectorMath, "Vector Math", "" ) +DefNode( ShaderNode, SH_NODE_SQUEEZE, 0, "SQUEEZE", Squeeze, "Squeeze", "" ) +DefNode( ShaderNode, SH_NODE_MATERIAL_EXT, def_sh_material, "MATERIAL_EXT", ExtendedMaterial, "Extended Material", "" ) +DefNode( ShaderNode, SH_NODE_INVERT, 0, "INVERT", Invert, "Invert", "" ) +DefNode( ShaderNode, SH_NODE_SEPRGB, 0, "SEPRGB", SeparateRGB, "Separate RGB", "" ) +DefNode( ShaderNode, SH_NODE_COMBRGB, 0, "COMBRGB", CombineRGB, "Combine RGB", "" ) +DefNode( ShaderNode, SH_NODE_HUE_SAT, 0, "HUE_SAT", HueSaturation, "Hue/Saturation", "" ) + +DefNode( CompositorNode, CMP_NODE_VIEWER, 0, "VIEWER", Viewer, "Viewer", "" ) +DefNode( CompositorNode, CMP_NODE_RGB, 0, "RGB", RGB, "RGB", "" ) +DefNode( CompositorNode, CMP_NODE_VALUE, 0, "VALUE", Value, "Value", "" ) +DefNode( CompositorNode, CMP_NODE_MIX_RGB, def_mix_rgb, "MIX_RGB", MixRGB, "Mix RGB", "" ) +DefNode( CompositorNode, CMP_NODE_VALTORGB, def_val_to_rgb, "VALTORGB", ValToRGB, "Val to RGB", "" ) +DefNode( CompositorNode, CMP_NODE_RGBTOBW, 0, "RGBTOBW", RGBToBW, "RGB to BW", "" ) +DefNode( CompositorNode, CMP_NODE_NORMAL, 0, "NORMAL", Normal, "Normal", "" ) +DefNode( CompositorNode, CMP_NODE_CURVE_VEC, def_vector_curve, "CURVE_VEC", CurveVec, "Vector Curve", "" ) +DefNode( CompositorNode, CMP_NODE_CURVE_RGB, def_rgb_curve, "CURVE_RGB", CurveRGB, "RGB Curve", "" ) +DefNode( CompositorNode, CMP_NODE_ALPHAOVER, def_cmp_alpha_over, "ALPHAOVER", AlphaOver, "Alpha Over", "" ) +DefNode( CompositorNode, CMP_NODE_BLUR, def_cmp_blur, "BLUR", Blur, "Blur", "" ) +DefNode( CompositorNode, CMP_NODE_FILTER, def_cmp_filter, "FILTER", Filter, "Filter", "" ) +DefNode( CompositorNode, CMP_NODE_MAP_VALUE, def_cmp_map_value, "MAP_VALUE", MapValue, "Map Value", "" ) +DefNode( CompositorNode, CMP_NODE_TIME, def_time, "TIME", Time, "Time", "" ) +DefNode( CompositorNode, CMP_NODE_VECBLUR, def_cmp_vector_blur, "VECBLUR", VecBlur, "Vector Blur", "" ) +DefNode( CompositorNode, CMP_NODE_SEPRGBA, 0, "SEPRGBA", SepRGBA, "Separate RGBA", "" ) +DefNode( CompositorNode, CMP_NODE_SEPHSVA, 0, "SEPHSVA", SepHSVA, "Separate HSVA", "" ) +DefNode( CompositorNode, CMP_NODE_SETALPHA, 0, "SETALPHA", SetAlpha, "Set Alpha", "" ) +DefNode( CompositorNode, CMP_NODE_HUE_SAT, 0, "HUE_SAT", HueSat, "Hue/Saturation", "" ) +DefNode( CompositorNode, CMP_NODE_IMAGE, def_cmp_image, "IMAGE", Image, "Image", "" ) +DefNode( CompositorNode, CMP_NODE_R_LAYERS, def_cmp_render_layers, "R_LAYERS", RLayers, "Render Layers", "" ) +DefNode( CompositorNode, CMP_NODE_COMPOSITE, 0, "COMPOSITE", Composite, "Composite", "" ) +DefNode( CompositorNode, CMP_NODE_OUTPUT_FILE, def_cmp_output_file, "OUTPUT_FILE", OutputFile, "Output File", "" ) +DefNode( CompositorNode, CMP_NODE_TEXTURE, def_cmp_texture, "TEXTURE", Texture, "Texture", "" ) +DefNode( CompositorNode, CMP_NODE_TRANSLATE, 0, "TRANSLATE", Translate, "Translate", "" ) +DefNode( CompositorNode, CMP_NODE_ZCOMBINE, 0, "ZCOMBINE", Zcombine, "Z Combine", "" ) +DefNode( CompositorNode, CMP_NODE_COMBRGBA, 0, "COMBRGBA", CombRGBA, "Combine RGBA", "" ) +DefNode( CompositorNode, CMP_NODE_DILATEERODE, def_cmp_dilate_erode, "DILATEERODE", DilateErode, "Dilate/Erode", "" ) +DefNode( CompositorNode, CMP_NODE_ROTATE, 0, "ROTATE", Rotate, "Rotate", "" ) +DefNode( CompositorNode, CMP_NODE_SCALE, def_cmp_scale, "SCALE", Scale, "Scale", "" ) +DefNode( CompositorNode, CMP_NODE_SEPYCCA, 0, "SEPYCCA", SepYCCA, "Separate YCCA", "" ) +DefNode( CompositorNode, CMP_NODE_COMBYCCA, 0, "COMBYCCA", CombYCCA, "Combine YCCA", "" ) +DefNode( CompositorNode, CMP_NODE_SEPYUVA, 0, "SEPYUVA", SepYUVA, "Separate YUVA", "" ) +DefNode( CompositorNode, CMP_NODE_COMBYUVA, 0, "COMBYUVA", CombYUVA, "Combine YUVA", "" ) +DefNode( CompositorNode, CMP_NODE_DIFF_MATTE, def_cmp_diff_matte, "DIFF_MATTE", DiffMatte, "Difference Key", "" ) +DefNode( CompositorNode, CMP_NODE_COLOR_SPILL, def_cmp_color_spill, "COLOR_SPILL", ColorSpill, "Color Spill", "" ) +DefNode( CompositorNode, CMP_NODE_CHROMA, def_cmp_chroma, "CHROMA", Chroma, "Chroma Key", "" ) +DefNode( CompositorNode, CMP_NODE_CHANNEL_MATTE, def_cmp_channel_matte, "CHANNEL_MATTE", ChannelMatte, "Channel Key", "" ) +DefNode( CompositorNode, CMP_NODE_FLIP, def_cmp_flip, "FLIP", Flip, "Flip", "" ) +DefNode( CompositorNode, CMP_NODE_SPLITVIEWER, def_cmp_splitviewer, "SPLITVIEWER", SplitViewer, "Split Viewer", "" ) +DefNode( CompositorNode, CMP_NODE_MAP_UV, def_cmp_map_uv, "MAP_UV", MapUV, "Map UV", "" ) +DefNode( CompositorNode, CMP_NODE_ID_MASK, def_cmp_id_mask, "ID_MASK", IDMask, "ID Mask", "" ) +DefNode( CompositorNode, CMP_NODE_DEFOCUS, def_cmp_defocus, "DEFOCUS", Defocus, "Defocus", "" ) +DefNode( CompositorNode, CMP_NODE_DISPLACE, 0, "DISPLACE", Displace, "Displace", "" ) +DefNode( CompositorNode, CMP_NODE_COMBHSVA, 0, "COMBHSVA", CombHSVA, "Combine HSVA", "" ) +DefNode( CompositorNode, CMP_NODE_MATH, def_math, "MATH", Math, "Math", "" ) +DefNode( CompositorNode, CMP_NODE_LUMA_MATTE, def_cmp_luma_matte, "LUMA_MATTE", LumaMatte, "Luma Matte", "" ) +DefNode( CompositorNode, CMP_NODE_BRIGHTCONTRAST, 0, "BRIGHTCONTRAST", BrightContrast, "Bright Contrast", "" ) +DefNode( CompositorNode, CMP_NODE_GAMMA, 0, "GAMMA", Gamma, "Gamma", "" ) +DefNode( CompositorNode, CMP_NODE_INVERT, def_cmp_invert, "INVERT", Invert, "Invert", "" ) +DefNode( CompositorNode, CMP_NODE_NORMALIZE, 0, "NORMALIZE", Normalize, "Normalize", "" ) +DefNode( CompositorNode, CMP_NODE_CROP, def_cmp_crop, "CROP", Crop, "Crop", "" ) +DefNode( CompositorNode, CMP_NODE_DBLUR, def_cmp_dblur, "DBLUR", DBlur, "DBlur", "" ) +DefNode( CompositorNode, CMP_NODE_BILATERALBLUR, def_cmp_bilateral_blur, "BILATERALBLUR", Bilateralblur, "Bilateral Blur", "" ) +DefNode( CompositorNode, CMP_NODE_PREMULKEY, def_cmp_premul_key, "PREMULKEY", PremulKey, "Premul Key", "" ) +DefNode( CompositorNode, CMP_NODE_GLARE, def_cmp_glare, "GLARE", Glare, "Glare", "" ) +DefNode( CompositorNode, CMP_NODE_TONEMAP, def_cmp_tonemap, "TONEMAP", Tonemap, "Tonemap", "" ) +DefNode( CompositorNode, CMP_NODE_LENSDIST, def_cmp_lensdist, "LENSDIST", Lensdist, "Lensdist", "" ) + +DefNode( TextureNode, TEX_NODE_OUTPUT, def_tex_output, "OUTPUT", Output, "Output", "" ) +DefNode( TextureNode, TEX_NODE_CHECKER, 0, "CHECKER", Checker, "Checker", "" ) +DefNode( TextureNode, TEX_NODE_TEXTURE, def_texture, "TEXTURE", Texture, "Texture", "" ) +DefNode( TextureNode, TEX_NODE_BRICKS, def_tex_bricks, "BRICKS", Bricks, "Bricks", "" ) +DefNode( TextureNode, TEX_NODE_MATH, def_math, "MATH", Math, "Math", "" ) +DefNode( TextureNode, TEX_NODE_MIX_RGB, def_mix_rgb, "MIX_RGB", MixRGB, "Mix RGB", "" ) +DefNode( TextureNode, TEX_NODE_RGBTOBW, 0, "RGBTOBW", RGBToBW, "RGB To BW", "" ) +DefNode( TextureNode, TEX_NODE_VALTORGB, def_val_to_rgb, "VALTORGB", ValToRGB, "Val To RGB", "" ) +DefNode( TextureNode, TEX_NODE_IMAGE, def_tex_image, "IMAGE", Image, "Image", "" ) +DefNode( TextureNode, TEX_NODE_CURVE_RGB, def_rgb_curve, "CURVE_RGB", CurveRGB, "RGB Curve", "" ) +DefNode( TextureNode, TEX_NODE_INVERT, 0, "INVERT", Invert, "Invert", "" ) +DefNode( TextureNode, TEX_NODE_HUE_SAT, 0, "HUE_SAT", HueSaturation, "Hue/Saturation", "" ) +DefNode( TextureNode, TEX_NODE_CURVE_TIME, def_time, "CURVE_TIME", CurveTime, "Curve Time", "" ) +DefNode( TextureNode, TEX_NODE_ROTATE, 0, "ROTATE", Rotate, "Rotate", "" ) +DefNode( TextureNode, TEX_NODE_VIEWER, 0, "VIEWER", Viewer, "Viewer", "" ) +DefNode( TextureNode, TEX_NODE_TRANSLATE, 0, "TRANSLATE", Translate, "Translate", "" ) +DefNode( TextureNode, TEX_NODE_COORD, 0, "COORD", Coordinates, "Coordinates", "" ) +DefNode( TextureNode, TEX_NODE_DISTANCE, 0, "DISTANCE", Distance, "Distance", "" ) +DefNode( TextureNode, TEX_NODE_COMPOSE, 0, "COMPOSE", Compose, "Compose", "" ) +DefNode( TextureNode, TEX_NODE_DECOMPOSE, 0, "DECOMPOSE", Decompose, "Decompose", "" ) +DefNode( TextureNode, TEX_NODE_VALTONOR, 0, "VALTONOR", ValToNor, "Val to Nor", "" ) +DefNode( TextureNode, TEX_NODE_SCALE, 0, "SCALE", Scale, "Scale", "" ) + +#undef TODO From 9b869755867bc47cf48ad2622503a57832745fbf Mon Sep 17 00:00:00 2001 From: Thomas Dinges Date: Wed, 3 Jun 2009 09:06:32 +0000 Subject: [PATCH 13/35] Cloth Buttons: Cloth Collision settings dindt't use the new button space context data. --- release/ui/buttons_physic_cloth.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/release/ui/buttons_physic_cloth.py b/release/ui/buttons_physic_cloth.py index 1b114871453..efa796df5b0 100644 --- a/release/ui/buttons_physic_cloth.py +++ b/release/ui/buttons_physic_cloth.py @@ -59,7 +59,7 @@ class Physic_PT_cloth_collision(PhysicButtonsPanel): def draw(self, context): layout = self.layout - md = self.cloth_modifier(context) + md = context.cloth cloth = md.collision_settings layout.active = cloth.enable_collision @@ -108,4 +108,4 @@ class Physic_PT_cloth_stiffness(PhysicButtonsPanel): bpy.types.register(Physic_PT_cloth) bpy.types.register(Physic_PT_cloth_collision) -bpy.types.register(Physic_PT_cloth_stiffness) +bpy.types.register(Physic_PT_cloth_stiffness) \ No newline at end of file From 7c3c9df2c07f739448e804d2ed9fc3d596f5022a Mon Sep 17 00:00:00 2001 From: Ton Roosendaal Date: Wed, 3 Jun 2009 18:31:37 +0000 Subject: [PATCH 14/35] 2.5 Further work on new "text search" button. - Now allows to browse items (mouse, arrow key) - Assigns active value - Uses different backdrop to distinguish from popup menus - Cleaned API for it, so it can be used nicely generic Also added a search menu, which shows all currently working operators: CTRL+ALT+F. (mind the looks, it needs some tweaks!) To make a menu activating a button I've added a new event... could use some tweaks. Important note: the callback to pass on "old string" for text button (bone rename) couldn't work yet, added first code for new callback, but has to be worked on further. When bone rename gets added it can be tested. --- source/blender/editors/include/UI_interface.h | 17 +-- source/blender/editors/interface/interface.c | 14 +- .../editors/interface/interface_handlers.c | 83 +++++++++-- .../editors/interface/interface_intern.h | 6 + .../editors/interface/interface_regions.c | 141 +++++++++++++++--- .../editors/interface/interface_widgets.c | 24 ++- source/blender/editors/screen/area.c | 5 + .../blender/editors/space_info/info_header.c | 24 ++- .../windowmanager/intern/wm_operators.c | 89 +++++++++++ source/blender/windowmanager/wm_event_types.h | 1 + 10 files changed, 350 insertions(+), 54 deletions(-) diff --git a/source/blender/editors/include/UI_interface.h b/source/blender/editors/include/UI_interface.h index 4c2634e2a75..feca59bca30 100644 --- a/source/blender/editors/include/UI_interface.h +++ b/source/blender/editors/include/UI_interface.h @@ -436,31 +436,30 @@ uiBut *uiFindInlink(uiBlock *block, void *poin); * * uiButSetNFunc will free the argument with MEM_freeN. */ -typedef struct uiSearchItems { - int maxitem, totitem, maxstrlen; - - char **names; - void **pointers; - -} uiSearchItems; - +typedef struct uiSearchItems uiSearchItems; typedef void (*uiButHandleFunc)(struct bContext *C, void *arg1, void *arg2); +typedef void (*uiButHandleRenameFunc)(struct bContext *C, void *arg, char *origstr); typedef void (*uiButHandleNFunc)(struct bContext *C, void *argN, void *arg2); typedef void (*uiButCompleteFunc)(struct bContext *C, char *str, void *arg); typedef void (*uiButSearchFunc)(const struct bContext *C, void *arg, char *str, uiSearchItems *items); typedef void (*uiBlockHandleFunc)(struct bContext *C, void *arg, int event); + + /* use inside searchfunc to add items */ +int uiSearchItemAdd(uiSearchItems *items, const char *name, void *poin); + /* bfunc gets search item *poin as arg2, or if NULL the old string */ +void uiButSetSearchFunc (uiBut *but, uiButSearchFunc sfunc, void *arg1, uiButHandleFunc bfunc); void uiBlockSetHandleFunc(uiBlock *block, uiBlockHandleFunc func, void *arg); void uiBlockSetButmFunc (uiBlock *block, uiMenuHandleFunc func, void *arg); void uiBlockSetFunc (uiBlock *block, uiButHandleFunc func, void *arg1, void *arg2); +void uiBlockSetRenameFunc(uiBlock *block, uiButHandleRenameFunc func, void *arg1); void uiButSetFunc (uiBut *but, uiButHandleFunc func, void *arg1, void *arg2); void uiButSetNFunc (uiBut *but, uiButHandleNFunc func, void *argN, void *arg2); void uiButSetCompleteFunc(uiBut *but, uiButCompleteFunc func, void *arg); -void uiButSetSearchFunc (uiBut *but, uiButSearchFunc func, void *arg); void uiBlockSetDrawExtraFunc(uiBlock *block, void (*func)(struct bContext *C, uiBlock *block)); diff --git a/source/blender/editors/interface/interface.c b/source/blender/editors/interface/interface.c index 69ee0d470d0..68973fe540c 100644 --- a/source/blender/editors/interface/interface.c +++ b/source/blender/editors/interface/interface.c @@ -2963,6 +2963,11 @@ void uiBlockSetFunc(uiBlock *block, uiButHandleFunc func, void *arg1, void *arg2 block->func_arg2= arg2; } +void uiBlockSetRenameFunc(uiBlock *block, uiButHandleRenameFunc func, void *arg1) +{ + +} + void uiBlockSetDrawExtraFunc(uiBlock *block, void (*func)()) { block->drawextra= func; @@ -3083,7 +3088,7 @@ void uiDefKeyevtButS(uiBlock *block, int retval, char *str, short x1, short y1, ui_check_but(but); } -/* arg is pointer to string/name, use callbacks below to make this work */ +/* arg is pointer to string/name, use uiButSetSearchFunc() below to make this work */ uiBut *uiDefSearchBut(uiBlock *block, void *arg, int retval, int icon, int maxlen, short x1, short y1, short x2, short y2, char *tip) { uiBut *but= ui_def_but(block, SEARCH_MENU, retval, "", x1, y1, x2, y2, arg, 0.0, maxlen, 0.0, 0.0, tip); @@ -3099,10 +3104,13 @@ uiBut *uiDefSearchBut(uiBlock *block, void *arg, int retval, int icon, int maxle return but; } -void uiButSetSearchFunc(uiBut *but, uiButSearchFunc func, void *arg) +/* arg is user value, searchfunc and handlefunc both get it as arg */ +void uiButSetSearchFunc(uiBut *but, uiButSearchFunc sfunc, void *arg, uiButHandleFunc bfunc) { - but->search_func= func; + but->search_func= sfunc; but->search_arg= arg; + + uiButSetFunc(but, bfunc, arg, NULL); } diff --git a/source/blender/editors/interface/interface_handlers.c b/source/blender/editors/interface/interface_handlers.c index 5617874ab0e..c009c5cfc7b 100644 --- a/source/blender/editors/interface/interface_handlers.c +++ b/source/blender/editors/interface/interface_handlers.c @@ -142,7 +142,8 @@ typedef struct uiAfterFunc { uiButHandleFunc func; void *func_arg1; void *func_arg2; - + void *func_arg3; + uiButHandleNFunc funcN; void *func_argN; @@ -233,6 +234,7 @@ static void ui_apply_but_func(bContext *C, uiBut *but) after->func= but->func; after->func_arg1= but->func_arg1; after->func_arg2= but->func_arg2; + after->func_arg3= but->func_arg3; after->funcN= but->funcN; after->func_argN= but->func_argN; @@ -418,9 +420,10 @@ static void ui_apply_but_TEX(bContext *C, uiBut *but, uiHandleButtonData *data) /* give butfunc the original text too */ /* feature used for bone renaming, channels, etc */ - if(but->func_arg2==NULL) but->func_arg2= data->origstr; + /* XXX goes via uiButHandleRenameFunc now */ +// if(but->func_arg2==NULL) but->func_arg2= data->origstr; ui_apply_but_func(C, but); - if(but->func_arg2==data->origstr) but->func_arg2= NULL; +// if(but->func_arg2==data->origstr) but->func_arg2= NULL; data->retval= but->retval; data->applied= 1; @@ -888,7 +891,7 @@ static int ui_textedit_type_ascii(uiBut *but, uiHandleButtonData *data, char asc } } - return WM_UI_HANDLER_BREAK; + return changed; } void ui_textedit_move(uiBut *but, uiHandleButtonData *data, int direction, int select, int jump) @@ -1047,7 +1050,7 @@ static int ui_textedit_delete(uiBut *but, uiHandleButtonData *data, int directio else { /* backspace */ if(len!=0) { if ((but->selend - but->selsta) > 0) { - ui_textedit_delete_selection(but, data); + changed= ui_textedit_delete_selection(but, data); } else if(but->pos>0) { for(x=but->pos; xeditstr= 0; - but->pos= -1; - - if(data->searchbox) + if(data->searchbox) { + if(data->cancel==0) + ui_searchbox_apply(but, data->searchbox); + ui_searchbox_free(C, data->searchbox); - data->searchbox= NULL; + data->searchbox= NULL; + } + + but->editstr= NULL; + but->pos= -1; } } @@ -1232,11 +1239,17 @@ static void ui_textedit_prev_but(uiBlock *block, uiBut *actbut, uiHandleButtonDa } } + static void ui_do_but_textedit(bContext *C, uiBlock *block, uiBut *but, uiHandleButtonData *data, wmEvent *event) { - int mx, my, changed= 0, retval= WM_UI_HANDLER_CONTINUE; + int mx, my, changed= 0, inbox=0, retval= WM_UI_HANDLER_CONTINUE; switch(event->type) { + case MOUSEMOVE: + if(data->searchbox) + ui_searchbox_event(data->searchbox, event); + + break; case RIGHTMOUSE: case ESCKEY: data->cancel= 1; @@ -1244,6 +1257,11 @@ static void ui_do_but_textedit(bContext *C, uiBlock *block, uiBut *but, uiHandle retval= WM_UI_HANDLER_BREAK; break; case LEFTMOUSE: { + + /* exit on LMB only on RELEASE for searchbox, to mimic other popups, and allow multiple menu levels */ + if(data->searchbox) + inbox= BLI_in_rcti(&data->searchbox->winrct, event->x, event->y); + if(event->val==KM_PRESS) { mx= event->x; my= event->y; @@ -1257,11 +1275,15 @@ static void ui_do_but_textedit(bContext *C, uiBlock *block, uiBut *but, uiHandle button_activate_state(C, but, BUTTON_STATE_TEXT_SELECTING); retval= WM_UI_HANDLER_BREAK; } - else { + else if(inbox==0) { button_activate_state(C, but, BUTTON_STATE_EXIT); retval= WM_UI_HANDLER_BREAK; } } + else if(inbox) { + button_activate_state(C, but, BUTTON_STATE_EXIT); + retval= WM_UI_HANDLER_BREAK; + } break; } } @@ -1291,11 +1313,21 @@ static void ui_do_but_textedit(bContext *C, uiBlock *block, uiBut *but, uiHandle retval= WM_UI_HANDLER_BREAK; break; case DOWNARROWKEY: + if(data->searchbox) { + ui_searchbox_event(data->searchbox, event); + break; + } + /* pass on purposedly */ case ENDKEY: ui_textedit_move_end(but, data, 1, event->shift); retval= WM_UI_HANDLER_BREAK; break; case UPARROWKEY: + if(data->searchbox) { + ui_searchbox_event(data->searchbox, event); + break; + } + /* pass on purposedly */ case HOMEKEY: ui_textedit_move_end(but, data, 0, event->shift); retval= WM_UI_HANDLER_BREAK; @@ -1579,7 +1611,7 @@ static int ui_do_but_KEYEVT(bContext *C, uiBut *but, uiHandleButtonData *data, w static int ui_do_but_TEX(bContext *C, uiBlock *block, uiBut *but, uiHandleButtonData *data, wmEvent *event) { if(data->state == BUTTON_STATE_HIGHLIGHT) { - if(ELEM3(event->type, LEFTMOUSE, PADENTER, RETKEY) && event->val==KM_PRESS) { + if(ELEM4(event->type, LEFTMOUSE, PADENTER, RETKEY, EVT_BUT_OPEN) && event->val==KM_PRESS) { button_activate_state(C, but, BUTTON_STATE_TEXT_EDITING); return WM_UI_HANDLER_BREAK; } @@ -3013,7 +3045,9 @@ static void button_activate_init(bContext *C, ARegion *ar, uiBut *but, uiButtonA data= MEM_callocN(sizeof(uiHandleButtonData), "uiHandleButtonData"); data->window= CTX_wm_window(C); data->region= ar; - data->interactive= but->type==BUT_CURVE?0:1; // XXX temp + if( ELEM(but->type, BUT_CURVE, SEARCH_MENU) ); // XXX curve is temp + else data->interactive= 1; + data->state = BUTTON_STATE_INIT; /* activate button */ @@ -3115,16 +3149,35 @@ void ui_button_active_cancel(const bContext *C, uiBut *but) /************** handle activating a button *************/ +static uiBut *uit_but_find_open_event(ARegion *ar, wmEvent *event) +{ + uiBlock *block; + uiBut *but; + + for(block=ar->uiblocks.first; block; block=block->next) { + for(but=block->buttons.first; but; but= but->next) + if(but==event->customdata) + return but; + } + return NULL; +} + static int ui_handle_button_over(bContext *C, wmEvent *event, ARegion *ar) { uiBut *but; if(event->type == MOUSEMOVE) { but= ui_but_find_mouse_over(ar, event->x, event->y); - if(but) button_activate_init(C, ar, but, BUTTON_ACTIVATE_OVER); } + else if(event->type == EVT_BUT_OPEN) { + but= uit_but_find_open_event(ar, event); + if(but) { + button_activate_init(C, ar, but, BUTTON_ACTIVATE_OVER); + ui_do_button(C, but->block, but, event); + } + } return WM_UI_HANDLER_CONTINUE; } diff --git a/source/blender/editors/interface/interface_intern.h b/source/blender/editors/interface/interface_intern.h index f4483a0540d..db100d8cf86 100644 --- a/source/blender/editors/interface/interface_intern.h +++ b/source/blender/editors/interface/interface_intern.h @@ -164,6 +164,7 @@ struct uiBut { uiButHandleFunc func; void *func_arg1; void *func_arg2; + void *func_arg3; uiButHandleNFunc funcN; void *func_argN; @@ -354,8 +355,11 @@ uiBlock *ui_block_func_COL(struct bContext *C, uiPopupBlockHandle *handle, void struct ARegion *ui_tooltip_create(struct bContext *C, struct ARegion *butregion, uiBut *but); void ui_tooltip_free(struct bContext *C, struct ARegion *ar); +/* searchbox for string button */ ARegion *ui_searchbox_create(struct bContext *C, struct ARegion *butregion, uiBut *but); void ui_searchbox_update(struct bContext *C, struct ARegion *ar, uiBut *but); +void ui_searchbox_event(struct ARegion *ar, struct wmEvent *event); +void ui_searchbox_apply(uiBut *but, struct ARegion *ar); void ui_searchbox_free(struct bContext *C, struct ARegion *ar); typedef uiBlock* (*uiBlockHandleCreateFunc)(struct bContext *C, struct uiPopupBlockHandle *handle, void *arg1); @@ -396,6 +400,8 @@ extern int ui_button_is_active(struct ARegion *ar); /* interface_widgets.c */ void ui_draw_anti_tria(float x1, float y1, float x2, float y2, float x3, float y3); void ui_draw_menu_back(struct uiStyle *style, uiBlock *block, rcti *rect); +void ui_draw_search_back(struct uiStyle *style, uiBlock *block, rcti *rect); + extern void ui_draw_but(ARegion *ar, struct uiStyle *style, uiBut *but, rcti *rect); /* theme color init */ struct ThemeUI; diff --git a/source/blender/editors/interface/interface_regions.c b/source/blender/editors/interface/interface_regions.c index 3441abc94bd..0bde1be2107 100644 --- a/source/blender/editors/interface/interface_regions.c +++ b/source/blender/editors/interface/interface_regions.c @@ -386,15 +386,121 @@ void ui_tooltip_free(bContext *C, ARegion *ar) /************************* Creating Search Box **********************/ +struct uiSearchItems { + int maxitem, totitem, maxstrlen; + + char **names; + void **pointers; + +}; typedef struct uiSearchboxData { rcti bbox; uiFontStyle fstyle; uiSearchItems items; + int active; } uiSearchboxData; #define SEARCH_ITEMS 10 +/* exported for use by search callbacks */ +/* returns zero if nothing to add */ +int uiSearchItemAdd(uiSearchItems *items, const char *name, void *poin) +{ + + if(items->totitem>=items->maxitem) + return 0; + + BLI_strncpy(items->names[items->totitem], name, items->maxstrlen); + items->pointers[items->totitem]= poin; + + items->totitem++; + + return items->totitemmaxitem; +} + + +/* ar is the search box itself */ +static void ui_searchbox_select(ARegion *ar, int step) +{ + uiSearchboxData *data= ar->regiondata; + + /* apply step */ + data->active+= step; + + if(data->items.totitem==0) + data->active= 0; + else if(data->active> data->items.totitem) + data->active= 1; + else if(data->active < 0) + data->active= data->items.totitem; + + ED_region_tag_redraw(ar); +} + +static void ui_searchbox_butrect(rcti *rect, uiSearchboxData *data, int itemnr) +{ + int buth= (data->bbox.ymax-data->bbox.ymin - 2*MENU_SEPR_HEIGHT)/SEARCH_ITEMS; + + *rect= data->bbox; + rect->xmin= data->bbox.xmin + 3.0f; + rect->xmax= data->bbox.xmax - 3.0f; + + rect->ymax= data->bbox.ymax - MENU_SEPR_HEIGHT - itemnr*buth; + rect->ymin= rect->ymax - buth; + +} + +/* string validated to be of correct length (but->hardmax) */ +void ui_searchbox_apply(uiBut *but, ARegion *ar) +{ + uiSearchboxData *data= ar->regiondata; + + but->func_arg2= NULL; + + if(data->active) { + char *name= data->items.names[data->active-1]; + char *cpoin= strchr(name, '|'); + + if(cpoin) cpoin[0]= 0; + BLI_strncpy(but->editstr, name, data->items.maxstrlen); + if(cpoin) cpoin[0]= '|'; + + but->func_arg2= data->items.pointers[data->active-1]; + } +} + +void ui_searchbox_event(ARegion *ar, wmEvent *event) +{ + uiSearchboxData *data= ar->regiondata; + + switch(event->type) { + case UPARROWKEY: + ui_searchbox_select(ar, -1); + break; + case DOWNARROWKEY: + ui_searchbox_select(ar, 1); + break; + case MOUSEMOVE: + if(BLI_in_rcti(&ar->winrct, event->x, event->y)) { + rcti rect; + int a; + + for(a=0; aitems.totitem; a++) { + ui_searchbox_butrect(&rect, data, a); + if(BLI_in_rcti(&rect, event->x - ar->winrct.xmin, event->y - ar->winrct.ymin)) { + if( data->active!= a+1) { + data->active= a+1; + ui_searchbox_select(ar, 0); + break; + } + } + } + } + break; + } +} + /* ar is the search box itself */ void ui_searchbox_update(bContext *C, ARegion *ar, uiBut *but) { @@ -402,7 +508,12 @@ void ui_searchbox_update(bContext *C, ARegion *ar, uiBut *but) /* callback */ data->items.totitem= 0; - but->search_func(C, but->search_arg, but->editstr, &data->items); + data->active= 0; + if(but->search_func) + but->search_func(C, but->search_arg, but->editstr, &data->items); + + /* validate selected item */ + ui_searchbox_select(ar, 0); ED_region_tag_redraw(ar); } @@ -411,25 +522,21 @@ static void ui_searchbox_region_draw(const bContext *C, ARegion *ar) { uiSearchboxData *data= ar->regiondata; - ui_draw_menu_back(U.uistyles.first, NULL, &data->bbox); + /* pixel space */ + wmOrtho2(-0.01f, ar->winx-0.01f, -0.01f, ar->winy-0.01f); + + ui_draw_search_back(U.uistyles.first, NULL, &data->bbox); /* draw text */ if(data->items.totitem) { rcti rect; - int a, buth; + int a; /* draw items */ - buth= (data->bbox.ymax-data->bbox.ymin - 2*MENU_SEPR_HEIGHT)/SEARCH_ITEMS; - rect= data->bbox; - rect.xmin= data->bbox.xmin + 3.0f; - rect.xmax= data->bbox.xmax - 3.0f; - rect.ymax= data->bbox.ymax - MENU_SEPR_HEIGHT; - rect.ymin= rect.ymax - buth; - for(a=0; aitems.totitem; a++) { - ui_draw_menu_item(&data->fstyle, &rect, data->items.names[a], a==0?UI_ACTIVE:0); - rect.ymax -= buth; - rect.ymin -= buth; + ui_searchbox_butrect(&rect, data, a); + + ui_draw_menu_item(&data->fstyle, &rect, data->items.names[a], (a+1)==data->active?UI_ACTIVE:0); } } } @@ -533,7 +640,7 @@ ARegion *ui_searchbox_create(bContext *C, ARegion *butregion, uiBut *but) ar->winrct.xmin= x1 - MENU_SHADOW_SIDE; ar->winrct.xmax= x2 + MENU_SHADOW_SIDE; ar->winrct.ymin= y1 - MENU_SHADOW_BOTTOM; - ar->winrct.ymax= y2 + MENU_TOP; + ar->winrct.ymax= y2; /* adds subwindow */ ED_region_init(C, ar); @@ -879,8 +986,6 @@ uiPopupBlockHandle *ui_popup_block_create(bContext *C, ARegion *butregion, uiBut /* get winmat now that we actually have the subwindow */ wmSubWindowSet(window, ar->swinid); - // XXX ton, AA pixel space... - wmOrtho2(0.0, (float)ar->winrct.xmax-ar->winrct.xmin+1, 0.0, (float)ar->winrct.ymax-ar->winrct.ymin+1); wm_subwindow_getmatrix(window, ar->swinid, block->winmat); @@ -892,7 +997,9 @@ uiPopupBlockHandle *ui_popup_block_create(bContext *C, ARegion *butregion, uiBut void ui_popup_block_free(bContext *C, uiPopupBlockHandle *handle) { - ui_remove_temporary_region(C, CTX_wm_screen(C), handle->region); + /* XXX ton added, chrash on load file with popup open... need investigate */ + if(CTX_wm_screen(C)) + ui_remove_temporary_region(C, CTX_wm_screen(C), handle->region); MEM_freeN(handle); } diff --git a/source/blender/editors/interface/interface_widgets.c b/source/blender/editors/interface/interface_widgets.c index 82bfb898f99..47c4a729956 100644 --- a/source/blender/editors/interface/interface_widgets.c +++ b/source/blender/editors/interface/interface_widgets.c @@ -1913,6 +1913,23 @@ void ui_draw_menu_back(uiStyle *style, uiBlock *block, rcti *rect) } +void ui_draw_search_back(uiStyle *style, uiBlock *block, rcti *rect) +{ + uiWidgetType *wt= widget_type(UI_WTYPE_BOX); + + glEnable(GL_BLEND); + widget_softshadow(rect, 15, 5.0f, 8.0f); + glDisable(GL_BLEND); + + wt->state(wt, 0); + if(block) + wt->draw(&wt->wcol, rect, block->flag, 15); + else + wt->draw(&wt->wcol, rect, 0, 15); + +} + + /* helper call to draw a menu item without button */ /* state: UI_ACTIVE or 0 */ void ui_draw_menu_item(uiFontStyle *fstyle, rcti *rect, char *name, int state) @@ -1932,7 +1949,10 @@ void ui_draw_menu_item(uiFontStyle *fstyle, rcti *rect, char *name, int state) /* cut string in 2 parts? */ cpoin= strchr(name, '|'); - if(cpoin) *cpoin= 0; + if(cpoin) { + *cpoin= 0; + rect->xmax -= BLF_width(cpoin+1) -10; + } glColor3ubv(wt->wcol.text); uiStyleFontDraw(fstyle, rect, name); @@ -1940,7 +1960,7 @@ void ui_draw_menu_item(uiFontStyle *fstyle, rcti *rect, char *name, int state) /* part text right aligned */ if(cpoin) { fstyle->align= UI_STYLE_TEXT_RIGHT; - rect->xmax-=5; + rect->xmax= _rect.xmax - 5; uiStyleFontDraw(fstyle, rect, cpoin+1); *cpoin= '|'; } diff --git a/source/blender/editors/screen/area.c b/source/blender/editors/screen/area.c index ad6b6e04b8e..7d9cc748d05 100644 --- a/source/blender/editors/screen/area.c +++ b/source/blender/editors/screen/area.c @@ -837,6 +837,11 @@ void ED_region_init(bContext *C, ARegion *ar) ar->winx= ar->winrct.xmax - ar->winrct.xmin + 1; ar->winy= ar->winrct.ymax - ar->winrct.ymin + 1; + + /* UI convention */ + wmLoadIdentity(); + wmOrtho2(-0.01f, ar->winx-0.01f, -0.01f, ar->winy-0.01f); + } diff --git a/source/blender/editors/space_info/info_header.c b/source/blender/editors/space_info/info_header.c index 38e778848b9..09f5640dbf6 100644 --- a/source/blender/editors/space_info/info_header.c +++ b/source/blender/editors/space_info/info_header.c @@ -387,6 +387,14 @@ static void scene_idpoin_handle(bContext *C, ID *id, int event) } } +static void operator_call_cb(struct bContext *C, void *arg1, void *arg2) +{ + wmOperatorType *ot= arg2; + + if(ot) + WM_operator_name_call(C, ot->idname, WM_OP_INVOKE_DEFAULT, NULL); +} + static void operator_search_cb(const struct bContext *C, void *arg, char *str, uiSearchItems *items) { wmOperatorType *ot = WM_operatortype_first(); @@ -395,19 +403,19 @@ static void operator_search_cb(const struct bContext *C, void *arg, char *str, u if(BLI_strcasestr(ot->name, str)) { if(ot->poll==NULL || ot->poll((bContext *)C)) { + char name[256]; int len= strlen(ot->name); - BLI_strncpy(items->names[items->totitem], ot->name, items->maxstrlen); + /* display name for menu, can hold hotkey */ + BLI_strncpy(name, ot->name, 256); /* check for hotkey */ - if(len < items->maxstrlen-6) { - if(WM_key_event_operator_string(C, ot->idname, WM_OP_EXEC_DEFAULT, NULL, items->names[items->totitem]+len+1, items->maxstrlen-len-1)) { - items->names[items->totitem][len]= '|'; - } + if(len < 256-6) { + if(WM_key_event_operator_string(C, ot->idname, WM_OP_EXEC_DEFAULT, NULL, &name[len+1], 256-len-1)) + name[len]= '|'; } - items->totitem++; - if(items->totitem>=items->maxitem) + if(0==uiSearchItemAdd(items, name, ot)) break; } } @@ -483,7 +491,7 @@ void info_header_buttons(const bContext *C, ARegion *ar) static char search[256]= ""; uiBut *but= uiDefSearchBut(block, search, 0, ICON_PROP_ON, 256, xco+5, yco, 120, 19, ""); - uiButSetSearchFunc(but, operator_search_cb, NULL); + uiButSetSearchFunc(but, operator_search_cb, NULL, operator_call_cb); xco+= 125; } diff --git a/source/blender/windowmanager/intern/wm_operators.c b/source/blender/windowmanager/intern/wm_operators.c index a76a9ea94bf..b020e4c24a8 100644 --- a/source/blender/windowmanager/intern/wm_operators.c +++ b/source/blender/windowmanager/intern/wm_operators.c @@ -373,6 +373,93 @@ static void WM_OT_debug_menu(wmOperatorType *ot) RNA_def_int(ot->srna, "debugval", 0, -10000, 10000, "Debug Value", "", INT_MIN, INT_MAX); } +/* ***************** Search menu ************************* */ +static void operator_call_cb(struct bContext *C, void *arg1, void *arg2) +{ + wmOperatorType *ot= arg2; + + if(ot) + WM_operator_name_call(C, ot->idname, WM_OP_INVOKE_DEFAULT, NULL); +} + +static void operator_search_cb(const struct bContext *C, void *arg, char *str, uiSearchItems *items) +{ + wmOperatorType *ot = WM_operatortype_first(); + + for(; ot; ot= ot->next) { + + if(BLI_strcasestr(ot->name, str)) { + if(ot->poll==NULL || ot->poll((bContext *)C)) { + char name[256]; + int len= strlen(ot->name); + + /* display name for menu, can hold hotkey */ + BLI_strncpy(name, ot->name, 256); + + /* check for hotkey */ + if(len < 256-6) { + if(WM_key_event_operator_string(C, ot->idname, WM_OP_EXEC_DEFAULT, NULL, &name[len+1], 256-len-1)) + name[len]= '|'; + } + + if(0==uiSearchItemAdd(items, name, ot)) + break; + } + } + } +} + +static uiBlock *wm_block_search_menu(bContext *C, ARegion *ar, void *arg_op) +{ + static char search[256]= ""; + wmEvent event; + wmWindow *win= CTX_wm_window(C); + uiBlock *block; + uiBut *but; + + block= uiBeginBlock(C, ar, "_popup", UI_EMBOSS); + uiBlockSetFlag(block, UI_BLOCK_LOOP|UI_BLOCK_RET_1); + + but= uiDefSearchBut(block, search, 0, ICON_PROP_ON, 256, 10, 10, 180, 19, ""); + uiButSetSearchFunc(but, operator_search_cb, NULL, operator_call_cb); + + uiPopupBoundsBlock(block, 0.0f, 0, -20); /* move it downwards, mouse over button */ + uiEndBlock(C, block); + + event= *(win->eventstate); /* XXX huh huh? make api call */ + event.type= EVT_BUT_OPEN; + event.val= KM_PRESS; + event.customdata= but; + event.customdatafree= FALSE; + wm_event_add(win, &event); + + return block; +} + +static int wm_search_menu_exec(bContext *C, wmOperator *op) +{ + + return OPERATOR_FINISHED; +} + +static int wm_search_menu_invoke(bContext *C, wmOperator *op, wmEvent *event) +{ + + uiPupBlock(C, wm_block_search_menu, op); + + return OPERATOR_CANCELLED; +} + +static void WM_OT_search_menu(wmOperatorType *ot) +{ + ot->name= "Search Menu"; + ot->idname= "WM_OT_search_menu"; + + ot->invoke= wm_search_menu_invoke; + ot->exec= wm_search_menu_exec; + ot->poll= WM_operator_winactive; +} + /* ************ window / screen operator definitions ************** */ @@ -1437,6 +1524,7 @@ void wm_operatortype_init(void) WM_operatortype_append(WM_OT_save_mainfile); WM_operatortype_append(WM_OT_ten_timer); WM_operatortype_append(WM_OT_debug_menu); + WM_operatortype_append(WM_OT_search_menu); } /* default keymap for windows and screens, only call once per WM */ @@ -1461,6 +1549,7 @@ void wm_window_keymap(wmWindowManager *wm) /* debug/testing */ WM_keymap_verify_item(keymap, "WM_OT_ten_timer", TKEY, KM_PRESS, KM_ALT|KM_CTRL, 0); WM_keymap_verify_item(keymap, "WM_OT_debug_menu", DKEY, KM_PRESS, KM_ALT|KM_CTRL, 0); + WM_keymap_verify_item(keymap, "WM_OT_search_menu", FKEY, KM_PRESS, KM_ALT|KM_CTRL, 0); } diff --git a/source/blender/windowmanager/wm_event_types.h b/source/blender/windowmanager/wm_event_types.h index 4de7f645bfa..39c267b132c 100644 --- a/source/blender/windowmanager/wm_event_types.h +++ b/source/blender/windowmanager/wm_event_types.h @@ -238,6 +238,7 @@ #define EVT_FILESELECT_EXEC 3 #define EVT_FILESELECT_CANCEL 4 +#define EVT_BUT_OPEN 0x5021 #endif /* WM_EVENT_TYPES_H */ From 34014df367d61bca0223eee25a9aa7b2c5a0e232 Mon Sep 17 00:00:00 2001 From: Thomas Dinges Date: Wed, 3 Jun 2009 22:19:04 +0000 Subject: [PATCH 15/35] 2.5 RNA: * Started wrapping object force. * Added "absorption" property in Collision Modifier RNA. --- source/blender/makesrna/RNA_access.h | 3 + source/blender/makesrna/intern/rna_modifier.c | 7 + .../makesrna/intern/rna_object_force.c | 146 +++++++++++++++++- 3 files changed, 154 insertions(+), 2 deletions(-) diff --git a/source/blender/makesrna/RNA_access.h b/source/blender/makesrna/RNA_access.h index ccc94fd35d5..cb5b213c558 100644 --- a/source/blender/makesrna/RNA_access.h +++ b/source/blender/makesrna/RNA_access.h @@ -89,6 +89,9 @@ extern StructRNA RNA_CurveMapping; extern StructRNA RNA_CurveModifier; extern StructRNA RNA_CurvePoint; extern StructRNA RNA_DecimateModifier; +extern StructRNA RNA_DefCollision; +extern StructRNA RNA_DefField; +extern StructRNA RNA_DefPointcache; extern StructRNA RNA_DelaySensor; extern StructRNA RNA_DisplaceModifier; extern StructRNA RNA_DistortedNoiseTexture; diff --git a/source/blender/makesrna/intern/rna_modifier.c b/source/blender/makesrna/intern/rna_modifier.c index bc3da3b5a9e..86bea0e7981 100644 --- a/source/blender/makesrna/intern/rna_modifier.c +++ b/source/blender/makesrna/intern/rna_modifier.c @@ -1369,10 +1369,17 @@ static void rna_def_modifier_cloth(BlenderRNA *brna) static void rna_def_modifier_collision(BlenderRNA *brna) { StructRNA *srna; + PropertyRNA *prop; srna= RNA_def_struct(brna, "CollisionModifier", "Modifier"); RNA_def_struct_ui_text(srna, "Collision Modifier", "Collision modifier defining modifier stack position used for collision."); RNA_def_struct_sdna(srna, "CollisionModifierData"); + + prop= RNA_def_property(srna, "absorption", PROP_INT, PROP_PERCENTAGE); + RNA_def_property_int_sdna(prop, NULL, "absorption"); + RNA_def_property_ui_range(prop, 0, 100, 1, 2); + RNA_def_property_ui_text(prop, "Absorption %", "How much of effector force gets lost during collision with this object (in percent)."); + RNA_def_property_update(prop, NC_OBJECT|ND_MODIFIER, "rna_Modifier_update"); } static void rna_def_modifier_bevel(BlenderRNA *brna) diff --git a/source/blender/makesrna/intern/rna_object_force.c b/source/blender/makesrna/intern/rna_object_force.c index 22521528d68..3c68f8630ef 100644 --- a/source/blender/makesrna/intern/rna_object_force.c +++ b/source/blender/makesrna/intern/rna_object_force.c @@ -17,7 +17,7 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * - * Contributor(s): Blender Foundation (2008). + * Contributor(s): Blender Foundation (2008), Thomas Dinges * * ***** END GPL LICENSE BLOCK ***** */ @@ -39,27 +39,170 @@ static void rna_def_pointcache(BlenderRNA *brna) { StructRNA *srna; + PropertyRNA *prop; srna= RNA_def_struct(brna, "PointCache", NULL); RNA_def_struct_ui_text(srna, "Point Cache", "Point cache for physics simulations."); + + prop= RNA_def_property(srna, "start_frame", PROP_INT, PROP_NONE); + RNA_def_property_int_sdna(prop, NULL, "startframe"); + RNA_def_property_range(prop, 1, 300000); + RNA_def_property_ui_text(prop, "Start", "Frame on which the simulation starts."); + + prop= RNA_def_property(srna, "end_frame", PROP_INT, PROP_NONE); + RNA_def_property_int_sdna(prop, NULL, "endframe"); + RNA_def_property_range(prop, 1, 300000); + RNA_def_property_ui_text(prop, "End", "Frame on which the simulation stops."); } static void rna_def_collision(BlenderRNA *brna) { StructRNA *srna; + PropertyRNA *prop; srna= RNA_def_struct(brna, "CollisionSettings", NULL); RNA_def_struct_sdna(srna, "PartDeflect"); RNA_def_struct_ui_text(srna, "Collision Settings", "Collision settings for object in physics simulation."); + + prop= RNA_def_property(srna, "enabled", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "deflect", 1); + RNA_def_property_ui_text(prop, "Enabled", "Enable this objects as a collider for physics systems"); + + /* Particle Interaction */ + + prop= RNA_def_property(srna, "damping_factor", PROP_FLOAT, PROP_NONE); + RNA_def_property_float_sdna(prop, NULL, "pdef_damp"); + RNA_def_property_range(prop, 0.0f, 1.0f); + RNA_def_property_ui_text(prop, "Damping Factor", "Amount of damping during particle collision"); + + prop= RNA_def_property(srna, "random_damping", PROP_FLOAT, PROP_NONE); + RNA_def_property_float_sdna(prop, NULL, "pdef_rdamp"); + RNA_def_property_range(prop, 0.0f, 1.0f); + RNA_def_property_ui_text(prop, "Random Damping", "Random variation of damping"); + + prop= RNA_def_property(srna, "friction_factor", PROP_FLOAT, PROP_NONE); + RNA_def_property_float_sdna(prop, NULL, "pdef_frict"); + RNA_def_property_range(prop, 0.0f, 1.0f); + RNA_def_property_ui_text(prop, "Friction Factor", "Amount of friction during particle collision"); + + prop= RNA_def_property(srna, "random_friction", PROP_FLOAT, PROP_NONE); + RNA_def_property_float_sdna(prop, NULL, "pdef_rfrict"); + RNA_def_property_range(prop, 0.0f, 1.0f); + RNA_def_property_ui_text(prop, "Random Friction", "Random variation of friction"); + + prop= RNA_def_property(srna, "permeability", PROP_FLOAT, PROP_NONE); + RNA_def_property_float_sdna(prop, NULL, "pdef_perm"); + RNA_def_property_range(prop, 0.0f, 1.0f); + RNA_def_property_ui_text(prop, "Permeability", "Chance that the particle will pass through the mesh"); + + prop= RNA_def_property(srna, "kill_particles", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", PDEFLE_KILL_PART); + RNA_def_property_ui_text(prop, "Kill Particles", "Kill collided particles"); + + /* Soft Body and Cloth Interaction */ + + prop= RNA_def_property(srna, "inner_thickness", PROP_FLOAT, PROP_NONE); + RNA_def_property_float_sdna(prop, NULL, "pdef_sbift"); + RNA_def_property_range(prop, 0.001f, 1.0f); + RNA_def_property_ui_text(prop, "Inner Thickness", "Inner face thickness"); + + prop= RNA_def_property(srna, "outer_thickness", PROP_FLOAT, PROP_NONE); + RNA_def_property_float_sdna(prop, NULL, "pdef_sboft"); + RNA_def_property_range(prop, 0.001f, 1.0f); + RNA_def_property_ui_text(prop, "Outer Thickness", "Outer face thickness"); + + prop= RNA_def_property(srna, "damping", PROP_FLOAT, PROP_NONE); + RNA_def_property_float_sdna(prop, NULL, "pdef_sbdamp"); + RNA_def_property_range(prop, 0.0f, 1.0f); + RNA_def_property_ui_text(prop, "Damping", "Amount of damping during collision"); + + /* Does this belong here? + prop= RNA_def_property(srna, "collision_stack", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "softflag", OB_SB_COLLFINAL); + RNA_def_property_ui_text(prop, "Collision from Stack", "Pick collision object from modifier stack (softbody only)"); + */ } static void rna_def_field(BlenderRNA *brna) { StructRNA *srna; + PropertyRNA *prop; + + static EnumPropertyItem field_type_items[] = { + {PFIELD_FORCE, "FORCE", "None", ""}, + {PFIELD_VORTEX, "VORTEX", "Vortex", ""}, + {PFIELD_MAGNET, "MAGNET", "Magnetic", ""}, + {PFIELD_WIND, "WIND", "Wind", ""}, + {PFIELD_GUIDE, "GUIDE", "Spherical", ""}, + {PFIELD_TEXTURE, "TEXTURE", "Texture", ""}, + {PFIELD_HARMONIC, "HARMONIC", "Harmonic", ""}, + {PFIELD_CHARGE, "CHARGE", "Charge", ""}, + {PFIELD_LENNARDJ, "LENNARDJ", "Lennard-Jones", ""}, + {0, NULL, NULL, NULL}}; + + static EnumPropertyItem falloff_items[] = { + {PFIELD_FALL_SPHERE, "SPHERE", "Sphere", ""}, + {PFIELD_FALL_TUBE, "TUBE", "Tube", ""}, + {PFIELD_FALL_CONE, "CONE", "Cone", ""}, + {0, NULL, NULL, NULL}}; srna= RNA_def_struct(brna, "FieldSettings", NULL); RNA_def_struct_sdna(srna, "PartDeflect"); RNA_def_struct_ui_text(srna, "Field Settings", "Field settings for an object in physics simulation."); + + /* Enums */ + + prop= RNA_def_property(srna, "field_type", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_sdna(prop, NULL, "forcefield"); + RNA_def_property_enum_items(prop, field_type_items); + RNA_def_property_ui_text(prop, "Field Type", "Choose Field Type"); + + prop= RNA_def_property(srna, "falloff_type", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_sdna(prop, NULL, "falloff"); + RNA_def_property_enum_items(prop, falloff_items); + RNA_def_property_ui_text(prop, "Fall-Off", "Fall-Off Shape"); + + /* Float */ + + prop= RNA_def_property(srna, "strength", PROP_FLOAT, PROP_NONE); + RNA_def_property_float_sdna(prop, NULL, "f_strength"); + RNA_def_property_range(prop, -1000.0f, 1000.0f); + RNA_def_property_ui_text(prop, "Strength", "Strength of force field"); + + prop= RNA_def_property(srna, "falloff_power", PROP_FLOAT, PROP_NONE); + RNA_def_property_float_sdna(prop, NULL, "f_power"); + RNA_def_property_range(prop, 0.0f, 10.0f); + RNA_def_property_ui_text(prop, "Falloff Power", "Falloff power (real gravitational falloff = 2)"); + + prop= RNA_def_property(srna, "harmonic_damping", PROP_FLOAT, PROP_NONE); + RNA_def_property_float_sdna(prop, NULL, "f_damp"); + RNA_def_property_range(prop, 0.0f, 10.0f); + RNA_def_property_ui_text(prop, "Harmonic Damping", "Damping of the harmonic force"); + + prop= RNA_def_property(srna, "minimum_distance", PROP_FLOAT, PROP_NONE); + RNA_def_property_float_sdna(prop, NULL, "mindist"); + RNA_def_property_range(prop, 0.0f, 1000.0f); + RNA_def_property_ui_text(prop, "Minimum Distance", "Minimum distance for the field's fall-off"); + + prop= RNA_def_property(srna, "maximum_distance", PROP_FLOAT, PROP_NONE); + RNA_def_property_float_sdna(prop, NULL, "maxdist"); + RNA_def_property_range(prop, 0.0f, 1000.0f); + RNA_def_property_ui_text(prop, "Maximum Distance", "Maximum distance for the field to work"); + + prop= RNA_def_property(srna, "radial_minimum", PROP_FLOAT, PROP_NONE); + RNA_def_property_float_sdna(prop, NULL, "minrad"); + RNA_def_property_range(prop, 0.0f, 1000.0f); + RNA_def_property_ui_text(prop, "Minimum Radial Distance", "Minimum radial distance for the field's fall-off"); + + prop= RNA_def_property(srna, "radial_maximum", PROP_FLOAT, PROP_NONE); + RNA_def_property_float_sdna(prop, NULL, "maxrad"); + RNA_def_property_range(prop, 0.0f, 1000.0f); + RNA_def_property_ui_text(prop, "Maximum Radial Distance", "Maximum radial distance for the field to work"); + + prop= RNA_def_property(srna, "radial_falloff", PROP_FLOAT, PROP_NONE); + RNA_def_property_float_sdna(prop, NULL, "f_power_r"); + RNA_def_property_range(prop, 0.0f, 10.0f); + RNA_def_property_ui_text(prop, "Radial Falloff Power", "Radial falloff power (real gravitational falloff = 2)"); } static void rna_def_game_softbody(BlenderRNA *brna) @@ -90,4 +233,3 @@ void RNA_def_object_force(BlenderRNA *brna) } #endif - From a8f69a7f5cf59943b244126f428d1c12ca7e61af Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Wed, 3 Jun 2009 23:16:51 +0000 Subject: [PATCH 16/35] UI/RNA: * Added an icon entry to RNA structs, instead of the UI_GetIconRNA function, to keep code together a bit more and make the lookup faster. --- source/blender/editors/include/UI_resources.h | 3 - .../editors/interface/interface_layout.c | 6 +- .../editors/interface/interface_utils.c | 182 +----------------- .../blender/editors/space_outliner/outliner.c | 2 +- source/blender/makesrna/RNA_access.h | 1 + source/blender/makesrna/RNA_define.h | 1 + source/blender/makesrna/intern/makesrna.c | 2 +- source/blender/makesrna/intern/rna_ID.c | 3 + source/blender/makesrna/intern/rna_access.c | 8 + source/blender/makesrna/intern/rna_action.c | 1 + source/blender/makesrna/intern/rna_armature.c | 2 + source/blender/makesrna/intern/rna_brush.c | 1 + source/blender/makesrna/intern/rna_camera.c | 1 + source/blender/makesrna/intern/rna_curve.c | 1 + source/blender/makesrna/intern/rna_define.c | 7 + source/blender/makesrna/intern/rna_fcurve.c | 1 + source/blender/makesrna/intern/rna_group.c | 1 + source/blender/makesrna/intern/rna_image.c | 1 + source/blender/makesrna/intern/rna_internal.h | 2 + .../makesrna/intern/rna_internal_types.h | 2 + source/blender/makesrna/intern/rna_key.c | 2 + source/blender/makesrna/intern/rna_lamp.c | 1 + source/blender/makesrna/intern/rna_lattice.c | 1 + source/blender/makesrna/intern/rna_main.c | 3 + source/blender/makesrna/intern/rna_material.c | 1 + source/blender/makesrna/intern/rna_mesh.c | 8 +- source/blender/makesrna/intern/rna_meta.c | 4 +- source/blender/makesrna/intern/rna_modifier.c | 29 +++ source/blender/makesrna/intern/rna_nodetree.c | 1 + source/blender/makesrna/intern/rna_object.c | 3 + source/blender/makesrna/intern/rna_particle.c | 1 + source/blender/makesrna/intern/rna_rna.c | 7 + source/blender/makesrna/intern/rna_scene.c | 1 + source/blender/makesrna/intern/rna_screen.c | 1 + .../blender/makesrna/intern/rna_scriptlink.c | 1 + source/blender/makesrna/intern/rna_sound.c | 1 + source/blender/makesrna/intern/rna_text.c | 1 + source/blender/makesrna/intern/rna_texture.c | 1 + source/blender/makesrna/intern/rna_vfont.c | 1 + source/blender/makesrna/intern/rna_world.c | 1 + 40 files changed, 106 insertions(+), 191 deletions(-) diff --git a/source/blender/editors/include/UI_resources.h b/source/blender/editors/include/UI_resources.h index 84ce3762f86..5339a255dbc 100644 --- a/source/blender/editors/include/UI_resources.h +++ b/source/blender/editors/include/UI_resources.h @@ -1098,9 +1098,6 @@ void UI_ColorPtrBlendShade3ubv(char *cp1, char *cp2, float fac, int offset); // get a 3 byte color, blended and shaded between two other char color pointers void UI_GetColorPtrBlendShade3ubv(char *cp1, char *cp2, char *col, float fac, int offset); -// get pointer from RNA pointer -int UI_GetIconRNA(struct PointerRNA *ptr); - // internal (blender) usage only, for init and set active void UI_SetTheme(int spacetype, int regionid); diff --git a/source/blender/editors/interface/interface_layout.c b/source/blender/editors/interface/interface_layout.c index bb2be0da874..8ef1cd32f22 100644 --- a/source/blender/editors/interface/interface_layout.c +++ b/source/blender/editors/interface/interface_layout.c @@ -213,7 +213,7 @@ static int ui_item_fit(int item, int pos, int all, int available, int last, int static int ui_layout_vary_direction(uiLayout *layout) { - return (layout->root->type == UI_LAYOUT_HEADER)? UI_ITEM_VARY_X: UI_ITEM_VARY_Y; + return (layout->root->type == UI_LAYOUT_HEADER || layout->alignment != UI_LAYOUT_ALIGN_EXPAND)? UI_ITEM_VARY_X: UI_ITEM_VARY_Y; } /* estimated size of text + icon */ @@ -224,9 +224,9 @@ static int ui_text_icon_width(uiLayout *layout, char *name, int icon) if(icon && strcmp(name, "") == 0) return UI_UNIT_X; /* icon only */ else if(icon) - return (variable)? UI_GetStringWidth(name) + UI_UNIT_X: 10*UI_UNIT_X; /* icon + text */ + return (variable)? UI_GetStringWidth(name) + 4 + UI_UNIT_X: 10*UI_UNIT_X; /* icon + text */ else - return (variable)? UI_GetStringWidth(name) + UI_UNIT_X: 10*UI_UNIT_X; /* text only */ + return (variable)? UI_GetStringWidth(name) + 4 + UI_UNIT_X: 10*UI_UNIT_X; /* text only */ } static void ui_item_size(uiItem *item, int *r_w, int *r_h) diff --git a/source/blender/editors/interface/interface_utils.c b/source/blender/editors/interface/interface_utils.c index 76247258a71..564ae2c0205 100644 --- a/source/blender/editors/interface/interface_utils.c +++ b/source/blender/editors/interface/interface_utils.c @@ -65,186 +65,6 @@ /*************************** RNA Utilities ******************************/ -int UI_GetIconRNA(PointerRNA *ptr) -{ - StructRNA *rnatype= ptr->type; - - if(rnatype == &RNA_Scene) - return ICON_SCENE_DATA; - else if(rnatype == &RNA_World) - return ICON_WORLD_DATA; - else if(rnatype == &RNA_Object) - return ICON_OBJECT_DATA; - else if(rnatype == &RNA_Mesh) - return ICON_MESH_DATA; - else if(rnatype == &RNA_MeshVertex) - return ICON_VERTEXSEL; - else if(rnatype == &RNA_MeshEdge) - return ICON_EDGESEL; - else if(rnatype == &RNA_MeshFace) - return ICON_FACESEL; - else if(rnatype == &RNA_MeshTextureFace) - return ICON_FACESEL_HLT; - else if(rnatype == &RNA_VertexGroup) - return ICON_GROUP_VERTEX; - else if(rnatype == &RNA_VertexGroupElement) - return ICON_GROUP_VERTEX; - else if(rnatype == &RNA_Curve) - return ICON_CURVE_DATA; - else if(rnatype == &RNA_MetaBall) - return ICON_META_DATA; - else if(rnatype == &RNA_MetaElement) - return ICON_OUTLINER_DATA_META; - else if(rnatype == &RNA_Lattice) - return ICON_LATTICE_DATA; - else if(rnatype == &RNA_Armature) - return ICON_ARMATURE_DATA; - else if(rnatype == &RNA_Bone) - return ICON_BONE_DATA; - else if(rnatype == &RNA_Camera) - return ICON_CAMERA_DATA; - else if(rnatype == &RNA_LocalLamp) - return ICON_LAMP_DATA; - else if(rnatype == &RNA_AreaLamp) - return ICON_LAMP_DATA; - else if(rnatype == &RNA_SpotLamp) - return ICON_LAMP_DATA; - else if(rnatype == &RNA_SunLamp) - return ICON_LAMP_DATA; - else if(rnatype == &RNA_HemiLamp) - return ICON_LAMP_DATA; - else if(rnatype == &RNA_Lamp) - return ICON_LAMP_DATA; - else if(rnatype == &RNA_Group) - return ICON_GROUP; - else if(rnatype == &RNA_ParticleSystem) - return ICON_PARTICLE_DATA; - else if(rnatype == &RNA_ParticleSettings) - return ICON_PARTICLE_DATA; - else if(rnatype == &RNA_Material) - return ICON_MATERIAL_DATA; - else if(rnatype == &RNA_Texture) - return ICON_TEXTURE_DATA; - else if(rnatype == &RNA_TextureSlot) - return ICON_TEXTURE_DATA; - else if(rnatype == &RNA_WorldTextureSlot) - return ICON_TEXTURE_DATA; - else if(rnatype == &RNA_MaterialTextureSlot) - return ICON_TEXTURE_DATA; - else if(rnatype == &RNA_Image) - return ICON_IMAGE_DATA; - else if(rnatype == &RNA_Screen) - return ICON_SPLITSCREEN; - else if(rnatype == &RNA_NodeTree) - return ICON_NODE; - else if(rnatype == &RNA_Text) - return ICON_TEXT; - else if(rnatype == &RNA_Sound) - return ICON_SOUND; - else if(rnatype == &RNA_Brush) - return ICON_BRUSH_DATA; - else if(rnatype == &RNA_VectorFont) - return ICON_FONT_DATA; - else if(rnatype == &RNA_Library) - return ICON_LIBRARY_DATA_DIRECT; - else if(rnatype == &RNA_Action) - return ICON_ACTION; - else if(rnatype == &RNA_FCurve) - return ICON_ANIM_DATA; - //else if(rnatype == &RNA_Ipo) - // return ICON_ANIM_DATA; - else if(rnatype == &RNA_Key) - return ICON_SHAPEKEY_DATA; - else if(rnatype == &RNA_Main) - return ICON_BLENDER; - else if(rnatype == &RNA_Struct) - return ICON_RNA; - else if(rnatype == &RNA_Property) - return ICON_RNA; - else if(rnatype == &RNA_BooleanProperty) - return ICON_RNA; - else if(rnatype == &RNA_IntProperty) - return ICON_RNA; - else if(rnatype == &RNA_FloatProperty) - return ICON_RNA; - else if(rnatype == &RNA_StringProperty) - return ICON_RNA; - else if(rnatype == &RNA_EnumProperty) - return ICON_RNA; - else if(rnatype == &RNA_EnumPropertyItem) - return ICON_RNA; - else if(rnatype == &RNA_PointerProperty) - return ICON_RNA; - else if(rnatype == &RNA_CollectionProperty) - return ICON_RNA; - else if(rnatype == &RNA_GameObjectSettings) - return ICON_GAME; - else if(rnatype == &RNA_ScriptLink) - return ICON_PYTHON; - - /* modifiers */ - else if(rnatype == &RNA_SubsurfModifier) - return ICON_MOD_SUBSURF; - else if(rnatype == &RNA_ArmatureModifier) - return ICON_MOD_ARMATURE; - else if(rnatype == &RNA_LatticeModifier) - return ICON_MOD_LATTICE; - else if(rnatype == &RNA_CurveModifier) - return ICON_MOD_CURVE; - else if(rnatype == &RNA_BuildModifier) - return ICON_MOD_BUILD; - else if(rnatype == &RNA_MirrorModifier) - return ICON_MOD_MIRROR; - else if(rnatype == &RNA_DecimateModifier) - return ICON_MOD_DECIM; - else if(rnatype == &RNA_WaveModifier) - return ICON_MOD_WAVE; - else if(rnatype == &RNA_HookModifier) - return ICON_HOOK; - else if(rnatype == &RNA_SoftbodyModifier) - return ICON_MOD_SOFT; - else if(rnatype == &RNA_BooleanModifier) - return ICON_MOD_BOOLEAN; - else if(rnatype == &RNA_ParticleInstanceModifier) - return ICON_MOD_PARTICLES; - else if(rnatype == &RNA_ParticleSystemModifier) - return ICON_MOD_PARTICLES; - else if(rnatype == &RNA_EdgeSplitModifier) - return ICON_MOD_EDGESPLIT; - else if(rnatype == &RNA_ArrayModifier) - return ICON_MOD_ARRAY; - else if(rnatype == &RNA_UVProjectModifier) - return ICON_MOD_UVPROJECT; - else if(rnatype == &RNA_DisplaceModifier) - return ICON_MOD_DISPLACE; - else if(rnatype == &RNA_ShrinkwrapModifier) - return ICON_MOD_SHRINKWRAP; - else if(rnatype == &RNA_CastModifier) - return ICON_MOD_CAST; - else if(rnatype == &RNA_MeshDeformModifier) - return ICON_MOD_MESHDEFORM; - else if(rnatype == &RNA_BevelModifier) - return ICON_MOD_BEVEL; - else if(rnatype == &RNA_SmoothModifier) - return ICON_MOD_SMOOTH; - else if(rnatype == &RNA_SimpleDeformModifier) - return ICON_MOD_SIMPLEDEFORM; - else if(rnatype == &RNA_MaskModifier) - return ICON_MOD_MASK; - else if(rnatype == &RNA_ClothModifier) - return ICON_MOD_CLOTH; - else if(rnatype == &RNA_ExplodeModifier) - return ICON_MOD_EXPLODE; - else if(rnatype == &RNA_CollisionModifier) - return ICON_MOD_PHYSICS; - else if(rnatype == &RNA_FluidSimulationModifier) - return ICON_MOD_FLUIDSIM; - else if(rnatype == &RNA_MultiresModifier) - return ICON_MOD_MULTIRES; - else - return ICON_DOT; -} - uiBut *uiDefAutoButR(uiBlock *block, PointerRNA *ptr, PropertyRNA *prop, int index, char *name, int icon, int x1, int y1, int x2, int y2) { uiBut *but=NULL; @@ -297,7 +117,7 @@ uiBut *uiDefAutoButR(uiBlock *block, PointerRNA *ptr, PropertyRNA *prop, int ind pptr= RNA_property_pointer_get(ptr, prop); if(!pptr.type) pptr.type= RNA_property_pointer_type(prop); - icon= UI_GetIconRNA(&pptr); + icon= RNA_struct_ui_icon(pptr.type); but= uiDefIconTextButR(block, IDPOIN, 0, icon, name, x1, y1, x2, y2, ptr, propname, index, 0, 0, -1, -1, NULL); break; diff --git a/source/blender/editors/space_outliner/outliner.c b/source/blender/editors/space_outliner/outliner.c index 2d544b402ec..cde0683318f 100644 --- a/source/blender/editors/space_outliner/outliner.c +++ b/source/blender/editors/space_outliner/outliner.c @@ -3643,7 +3643,7 @@ static void tselem_draw_icon(float x, float y, TreeStoreElem *tselem, TreeElemen UI_icon_draw(x, y, ICON_OBJECT_DATA); break; case TSE_RNA_STRUCT: - UI_icon_draw(x, y, UI_GetIconRNA(&te->rnaptr)); + UI_icon_draw(x, y, RNA_struct_ui_icon(te->rnaptr.type)); break; default: UI_icon_draw(x, y, ICON_DOT); break; diff --git a/source/blender/makesrna/RNA_access.h b/source/blender/makesrna/RNA_access.h index cb5b213c558..f1b52ae49ed 100644 --- a/source/blender/makesrna/RNA_access.h +++ b/source/blender/makesrna/RNA_access.h @@ -331,6 +331,7 @@ void RNA_blender_rna_pointer_create(PointerRNA *r_ptr); const char *RNA_struct_identifier(StructRNA *type); const char *RNA_struct_ui_name(StructRNA *type); const char *RNA_struct_ui_description(StructRNA *type); +int RNA_struct_ui_icon(StructRNA *type); PropertyRNA *RNA_struct_name_property(StructRNA *type); PropertyRNA *RNA_struct_iterator_property(StructRNA *type); diff --git a/source/blender/makesrna/RNA_define.h b/source/blender/makesrna/RNA_define.h index 0754114d7f7..5fcf2a30271 100644 --- a/source/blender/makesrna/RNA_define.h +++ b/source/blender/makesrna/RNA_define.h @@ -59,6 +59,7 @@ void RNA_def_struct_register_funcs(StructRNA *srna, const char *reg, const char void RNA_def_struct_path_func(StructRNA *srna, const char *path); void RNA_def_struct_identifier(StructRNA *srna, const char *identifier); void RNA_def_struct_ui_text(StructRNA *srna, const char *name, const char *description); +void RNA_def_struct_ui_icon(StructRNA *srna, int icon); void RNA_struct_free(BlenderRNA *brna, StructRNA *srna); /* Compact Property Definitions */ diff --git a/source/blender/makesrna/intern/makesrna.c b/source/blender/makesrna/intern/makesrna.c index 438100243e3..1cfba4286c7 100644 --- a/source/blender/makesrna/intern/makesrna.c +++ b/source/blender/makesrna/intern/makesrna.c @@ -1713,7 +1713,7 @@ static void rna_generate_struct(BlenderRNA *brna, StructRNA *srna, FILE *f) rna_print_c_string(f, srna->name); fprintf(f, ", "); rna_print_c_string(f, srna->description); - fprintf(f, ",\n"); + fprintf(f, ",\n %d,\n", srna->icon); prop= srna->nameproperty; if(prop) { diff --git a/source/blender/makesrna/intern/rna_ID.c b/source/blender/makesrna/intern/rna_ID.c index ad1c7eae95e..eb57c91a9f7 100644 --- a/source/blender/makesrna/intern/rna_ID.c +++ b/source/blender/makesrna/intern/rna_ID.c @@ -30,6 +30,8 @@ #include "DNA_ID.h" +#include "rna_internal.h" + #ifdef RNA_RUNTIME #include "BKE_idprop.h" @@ -221,6 +223,7 @@ static void rna_def_library(BlenderRNA *brna) srna= RNA_def_struct(brna, "Library", "ID"); RNA_def_struct_ui_text(srna, "Library", "External .blend file from which data is linked."); + RNA_def_struct_ui_icon(srna, ICON_LIBRARY_DATA_DIRECT); prop= RNA_def_property(srna, "filename", PROP_STRING, PROP_FILEPATH); RNA_def_property_string_sdna(prop, NULL, "name"); diff --git a/source/blender/makesrna/intern/rna_access.c b/source/blender/makesrna/intern/rna_access.c index 41e1f4753f0..cf52c5fb1ec 100644 --- a/source/blender/makesrna/intern/rna_access.c +++ b/source/blender/makesrna/intern/rna_access.c @@ -339,6 +339,14 @@ const char *RNA_struct_ui_name(StructRNA *type) return type->name; } +int RNA_struct_ui_icon(StructRNA *type) +{ + if(type) + return type->icon; + else + return ICON_DOT; +} + const char *RNA_struct_ui_description(StructRNA *type) { return type->description; diff --git a/source/blender/makesrna/intern/rna_action.c b/source/blender/makesrna/intern/rna_action.c index 0a09462988b..3639d6d3fff 100644 --- a/source/blender/makesrna/intern/rna_action.c +++ b/source/blender/makesrna/intern/rna_action.c @@ -84,6 +84,7 @@ void rna_def_action(BlenderRNA *brna) srna= RNA_def_struct(brna, "Action", "ID"); RNA_def_struct_sdna(srna, "bAction"); RNA_def_struct_ui_text(srna, "Action", "A collection of F-Curves for animation."); + RNA_def_struct_ui_icon(srna, ICON_ACTION); prop= RNA_def_property(srna, "fcurves", PROP_COLLECTION, PROP_NONE); RNA_def_property_collection_sdna(prop, NULL, "curves", NULL); diff --git a/source/blender/makesrna/intern/rna_armature.c b/source/blender/makesrna/intern/rna_armature.c index c7f7b8cfebc..d49e5d14714 100644 --- a/source/blender/makesrna/intern/rna_armature.c +++ b/source/blender/makesrna/intern/rna_armature.c @@ -110,6 +110,7 @@ static void rna_def_bone(BlenderRNA *brna) srna= RNA_def_struct(brna, "Bone", NULL); RNA_def_struct_ui_text(srna, "Bone", "Bone in an Armature datablock."); + RNA_def_struct_ui_icon(srna, ICON_BONE_DATA); /* pointers/collections */ /* parent (pointer) */ @@ -266,6 +267,7 @@ void rna_def_armature(BlenderRNA *brna) srna= RNA_def_struct(brna, "Armature", "ID"); RNA_def_struct_ui_text(srna, "Armature", "Armature datablock containing a hierarchy of bones, usually used for rigging characters."); + RNA_def_struct_ui_icon(srna, ICON_ARMATURE_DATA); RNA_def_struct_sdna(srna, "bArmature"); diff --git a/source/blender/makesrna/intern/rna_brush.c b/source/blender/makesrna/intern/rna_brush.c index 778485c6e20..3deb38a3a07 100644 --- a/source/blender/makesrna/intern/rna_brush.c +++ b/source/blender/makesrna/intern/rna_brush.c @@ -93,6 +93,7 @@ void rna_def_brush(BlenderRNA *brna) srna= RNA_def_struct(brna, "Brush", "ID"); RNA_def_struct_ui_text(srna, "Brush", "Brush datablock for storing brush settings for painting and sculpting."); + RNA_def_struct_ui_icon(srna, ICON_BRUSH_DATA); /* enums */ prop= RNA_def_property(srna, "blend", PROP_ENUM, PROP_NONE); diff --git a/source/blender/makesrna/intern/rna_camera.c b/source/blender/makesrna/intern/rna_camera.c index 1b2bd4b4aab..bee8a21ad7d 100644 --- a/source/blender/makesrna/intern/rna_camera.c +++ b/source/blender/makesrna/intern/rna_camera.c @@ -52,6 +52,7 @@ void RNA_def_camera(BlenderRNA *brna) srna= RNA_def_struct(brna, "Camera", "ID"); RNA_def_struct_ui_text(srna, "Camera", "Camera datablock for storing camera settings."); + RNA_def_struct_ui_icon(srna, ICON_CAMERA_DATA); /* Enums */ prop= RNA_def_property(srna, "type", PROP_ENUM, PROP_NONE); diff --git a/source/blender/makesrna/intern/rna_curve.c b/source/blender/makesrna/intern/rna_curve.c index bdc33715145..c0b75c3c65f 100644 --- a/source/blender/makesrna/intern/rna_curve.c +++ b/source/blender/makesrna/intern/rna_curve.c @@ -459,6 +459,7 @@ void rna_def_curve(BlenderRNA *brna) srna= RNA_def_struct(brna, "Curve", "ID"); RNA_def_struct_ui_text(srna, "Curve", "Curve datablock storing curves, splines and NURBS."); + RNA_def_struct_ui_icon(srna, ICON_CURVE_DATA); rna_def_animdata_common(srna); rna_def_texmat_common(srna, "rna_Curve_texspace_editable"); diff --git a/source/blender/makesrna/intern/rna_define.c b/source/blender/makesrna/intern/rna_define.c index 49c8c69fbcf..12d96965e36 100644 --- a/source/blender/makesrna/intern/rna_define.c +++ b/source/blender/makesrna/intern/rna_define.c @@ -572,6 +572,8 @@ StructRNA *RNA_def_struct(BlenderRNA *brna, const char *identifier, const char * srna->identifier= identifier; srna->name= identifier; /* may be overwritten later RNA_def_struct_ui_text */ srna->description= ""; + if(!srnafrom) + srna->icon= ICON_DOT; rna_addtail(&brna->structs, srna); @@ -777,6 +779,11 @@ void RNA_def_struct_ui_text(StructRNA *srna, const char *name, const char *descr srna->description= description; } +void RNA_def_struct_ui_icon(StructRNA *srna, int icon) +{ + srna->icon= icon; +} + /* Property Definition */ PropertyRNA *RNA_def_property(StructOrFunctionRNA *cont_, const char *identifier, int type, int subtype) diff --git a/source/blender/makesrna/intern/rna_fcurve.c b/source/blender/makesrna/intern/rna_fcurve.c index d57e302263e..ea26118f267 100644 --- a/source/blender/makesrna/intern/rna_fcurve.c +++ b/source/blender/makesrna/intern/rna_fcurve.c @@ -586,6 +586,7 @@ void rna_def_fcurve(BlenderRNA *brna) srna= RNA_def_struct(brna, "FCurve", NULL); RNA_def_struct_ui_text(srna, "F-Curve", "F-Curve defining values of a period of time."); + RNA_def_struct_ui_icon(srna, ICON_ANIM_DATA); /* Enums */ prop= RNA_def_property(srna, "extrapolation", PROP_ENUM, PROP_NONE); diff --git a/source/blender/makesrna/intern/rna_group.c b/source/blender/makesrna/intern/rna_group.c index 35dddc122fe..059b2ce78f7 100644 --- a/source/blender/makesrna/intern/rna_group.c +++ b/source/blender/makesrna/intern/rna_group.c @@ -50,6 +50,7 @@ void RNA_def_group(BlenderRNA *brna) srna= RNA_def_struct(brna, "Group", "ID"); RNA_def_struct_ui_text(srna, "Group", "Group of Object datablocks."); + RNA_def_struct_ui_icon(srna, ICON_GROUP); prop= RNA_def_property(srna, "dupli_offset", PROP_FLOAT, PROP_VECTOR); RNA_def_property_float_sdna(prop, NULL, "dupli_ofs"); diff --git a/source/blender/makesrna/intern/rna_image.c b/source/blender/makesrna/intern/rna_image.c index a4a1636d212..8620a933d61 100644 --- a/source/blender/makesrna/intern/rna_image.c +++ b/source/blender/makesrna/intern/rna_image.c @@ -113,6 +113,7 @@ static void rna_def_image(BlenderRNA *brna) srna= RNA_def_struct(brna, "Image", "ID"); RNA_def_struct_ui_text(srna, "Image", "Image datablock referencing an external or packed image."); + RNA_def_struct_ui_icon(srna, ICON_IMAGE_DATA); prop= RNA_def_property(srna, "filename", PROP_STRING, PROP_FILEPATH); RNA_def_property_string_sdna(prop, NULL, "name"); diff --git a/source/blender/makesrna/intern/rna_internal.h b/source/blender/makesrna/intern/rna_internal.h index 04779c035d0..9071efe71f7 100644 --- a/source/blender/makesrna/intern/rna_internal.h +++ b/source/blender/makesrna/intern/rna_internal.h @@ -25,6 +25,8 @@ #ifndef RNA_INTERNAL_H #define RNA_INTERNAL_H +#include "UI_resources.h" + #include "rna_internal_types.h" #define RNA_MAGIC ((int)~0) diff --git a/source/blender/makesrna/intern/rna_internal_types.h b/source/blender/makesrna/intern/rna_internal_types.h index bd1c82fc049..60f057efa63 100644 --- a/source/blender/makesrna/intern/rna_internal_types.h +++ b/source/blender/makesrna/intern/rna_internal_types.h @@ -265,6 +265,8 @@ struct StructRNA { const char *name; /* single line description, displayed in the tooltip for example */ const char *description; + /* icon ID */ + int icon; /* property that defines the name */ PropertyRNA *nameproperty; diff --git a/source/blender/makesrna/intern/rna_key.c b/source/blender/makesrna/intern/rna_key.c index 0a21ad1d940..d5f28503e4a 100644 --- a/source/blender/makesrna/intern/rna_key.c +++ b/source/blender/makesrna/intern/rna_key.c @@ -285,6 +285,7 @@ static void rna_def_keyblock(BlenderRNA *brna) srna= RNA_def_struct(brna, "ShapeKey", NULL); RNA_def_struct_ui_text(srna, "Shape Key", "Shape key in a shape keys datablock."); RNA_def_struct_sdna(srna, "KeyBlock"); + RNA_def_struct_ui_icon(srna, ICON_SHAPEKEY_DATA); prop= RNA_def_property(srna, "name", PROP_STRING, PROP_NONE); RNA_def_property_ui_text(prop, "Name", ""); @@ -344,6 +345,7 @@ static void rna_def_key(BlenderRNA *brna) srna= RNA_def_struct(brna, "Key", "ID"); RNA_def_struct_ui_text(srna, "Key", "Shape keys datablock containing different shapes of geometric datablocks."); + RNA_def_struct_ui_icon(srna, ICON_SHAPEKEY_DATA); prop= RNA_def_property(srna, "reference_key", PROP_POINTER, PROP_NEVER_NULL); RNA_def_property_clear_flag(prop, PROP_EDITABLE); diff --git a/source/blender/makesrna/intern/rna_lamp.c b/source/blender/makesrna/intern/rna_lamp.c index d7f9c8728e8..77ac4de814e 100644 --- a/source/blender/makesrna/intern/rna_lamp.c +++ b/source/blender/makesrna/intern/rna_lamp.c @@ -263,6 +263,7 @@ static void rna_def_lamp(BlenderRNA *brna) srna= RNA_def_struct(brna, "Lamp", "ID"); RNA_def_struct_refine_func(srna, "rna_Lamp_refine"); RNA_def_struct_ui_text(srna, "Lamp", "Lamp datablock for lighting a scene."); + RNA_def_struct_ui_icon(srna, ICON_LAMP_DATA); prop= RNA_def_property(srna, "type", PROP_ENUM, PROP_NONE); RNA_def_property_enum_items(prop, prop_type_items); diff --git a/source/blender/makesrna/intern/rna_lattice.c b/source/blender/makesrna/intern/rna_lattice.c index ca77d3b519f..26c4ebb7b23 100644 --- a/source/blender/makesrna/intern/rna_lattice.c +++ b/source/blender/makesrna/intern/rna_lattice.c @@ -117,6 +117,7 @@ static void rna_def_lattice(BlenderRNA *brna) srna= RNA_def_struct(brna, "Lattice", "ID"); RNA_def_struct_ui_text(srna, "Lattice", "Lattice datablock defining a grid for deforming other objects."); + RNA_def_struct_ui_icon(srna, ICON_LATTICE_DATA); prop= RNA_def_property(srna, "points_u", PROP_INT, PROP_NONE); RNA_def_property_int_sdna(prop, NULL, "pntsu"); diff --git a/source/blender/makesrna/intern/rna_main.c b/source/blender/makesrna/intern/rna_main.c index 03ce385be32..fdd0349b25e 100644 --- a/source/blender/makesrna/intern/rna_main.c +++ b/source/blender/makesrna/intern/rna_main.c @@ -28,6 +28,8 @@ #include "RNA_define.h" #include "RNA_types.h" +#include "rna_internal.h" + #ifdef RNA_RUNTIME #include "BKE_main.h" @@ -248,6 +250,7 @@ void RNA_def_main(BlenderRNA *brna) srna= RNA_def_struct(brna, "Main", NULL); RNA_def_struct_ui_text(srna, "Main", "Main data structure representing a .blend file and all its datablocks."); + RNA_def_struct_ui_icon(srna, ICON_BLENDER); prop= RNA_def_property(srna, "filename", PROP_STRING, PROP_FILEPATH); RNA_def_property_string_maxlength(prop, 240); diff --git a/source/blender/makesrna/intern/rna_material.c b/source/blender/makesrna/intern/rna_material.c index 15cca0f3dfa..721bf621c22 100644 --- a/source/blender/makesrna/intern/rna_material.c +++ b/source/blender/makesrna/intern/rna_material.c @@ -731,6 +731,7 @@ void RNA_def_material(BlenderRNA *brna) srna= RNA_def_struct(brna, "Material", "ID"); RNA_def_struct_ui_text(srna, "Material", "Material datablock to defined the appearance of geometric objects for rendering."); + RNA_def_struct_ui_icon(srna, ICON_MATERIAL_DATA); prop= RNA_def_property(srna, "type", PROP_ENUM, PROP_NONE); RNA_def_property_enum_sdna(prop, NULL, "material_type"); diff --git a/source/blender/makesrna/intern/rna_mesh.c b/source/blender/makesrna/intern/rna_mesh.c index c75558dafe4..92e53cf7606 100644 --- a/source/blender/makesrna/intern/rna_mesh.c +++ b/source/blender/makesrna/intern/rna_mesh.c @@ -597,9 +597,10 @@ static void rna_def_mvert_group(BlenderRNA *brna) PropertyRNA *prop; srna= RNA_def_struct(brna, "VertexGroupElement", NULL); - RNA_def_struct_ui_text(srna, "Vertex Group Element", "Weight value of a vertex in a vertex group."); RNA_def_struct_sdna(srna, "MDeformWeight"); RNA_def_struct_path_func(srna, "rna_VertexGroupElement_path"); + RNA_def_struct_ui_text(srna, "Vertex Group Element", "Weight value of a vertex in a vertex group."); + RNA_def_struct_ui_icon(srna, ICON_GROUP_VERTEX); /* we can't point to actual group, it is in the object and so * there is no unique group to point to, hence the index */ @@ -622,6 +623,7 @@ static void rna_def_mvert(BlenderRNA *brna) RNA_def_struct_sdna(srna, "MVert"); RNA_def_struct_ui_text(srna, "Mesh Vertex", "Vertex in a Mesh datablock."); RNA_def_struct_path_func(srna, "rna_MeshVertex_path"); + RNA_def_struct_ui_icon(srna, ICON_VERTEXSEL); prop= RNA_def_property(srna, "co", PROP_FLOAT, PROP_VECTOR); RNA_def_property_ui_text(prop, "Location", ""); @@ -658,6 +660,7 @@ static void rna_def_medge(BlenderRNA *brna) RNA_def_struct_sdna(srna, "MEdge"); RNA_def_struct_ui_text(srna, "Mesh Edge", "Edge in a Mesh datablock."); RNA_def_struct_path_func(srna, "rna_MeshEdge_path"); + RNA_def_struct_ui_icon(srna, ICON_EDGESEL); prop= RNA_def_property(srna, "verts", PROP_INT, PROP_UNSIGNED); RNA_def_property_int_sdna(prop, NULL, "v1"); @@ -699,6 +702,7 @@ static void rna_def_mface(BlenderRNA *brna) RNA_def_struct_sdna(srna, "MFace"); RNA_def_struct_ui_text(srna, "Mesh Face", "Face in a Mesh datablock."); RNA_def_struct_path_func(srna, "rna_MeshFace_path"); + RNA_def_struct_ui_icon(srna, ICON_FACESEL); prop= RNA_def_property(srna, "verts", PROP_INT, PROP_UNSIGNED); RNA_def_property_int_sdna(prop, NULL, "v1"); @@ -763,6 +767,7 @@ static void rna_def_mtface(BlenderRNA *brna) RNA_def_struct_sdna(srna, "MTFace"); RNA_def_struct_ui_text(srna, "Mesh Texture Face", "UV mapping, texturing and game engine data for a face."); RNA_def_struct_path_func(srna, "rna_MeshTextureFace_path"); + RNA_def_struct_ui_icon(srna, ICON_FACESEL_HLT); prop= RNA_def_property(srna, "image", PROP_POINTER, PROP_NONE); RNA_def_property_pointer_sdna(prop, NULL, "tpage"); @@ -1042,6 +1047,7 @@ static void rna_def_mesh(BlenderRNA *brna) srna= RNA_def_struct(brna, "Mesh", "ID"); RNA_def_struct_ui_text(srna, "Mesh", "Mesh datablock to define geometric surfaces."); + RNA_def_struct_ui_icon(srna, ICON_MESH_DATA); prop= RNA_def_property(srna, "verts", PROP_COLLECTION, PROP_NONE); RNA_def_property_collection_sdna(prop, NULL, "mvert", "totvert"); diff --git a/source/blender/makesrna/intern/rna_meta.c b/source/blender/makesrna/intern/rna_meta.c index 737bb52a466..472e776f500 100644 --- a/source/blender/makesrna/intern/rna_meta.c +++ b/source/blender/makesrna/intern/rna_meta.c @@ -55,8 +55,9 @@ void rna_def_metaelement(BlenderRNA *brna) {0, NULL, NULL, NULL}}; srna= RNA_def_struct(brna, "MetaElement", NULL); - RNA_def_struct_ui_text(srna, "Meta Element", "Blobby element in a MetaBall datablock."); RNA_def_struct_sdna(srna, "MetaElem"); + RNA_def_struct_ui_text(srna, "Meta Element", "Blobby element in a MetaBall datablock."); + RNA_def_struct_ui_icon(srna, ICON_OUTLINER_DATA_META); /* enums */ prop= RNA_def_property(srna, "type", PROP_ENUM, PROP_NONE); @@ -112,6 +113,7 @@ void rna_def_metaball(BlenderRNA *brna) srna= RNA_def_struct(brna, "MetaBall", "ID"); RNA_def_struct_ui_text(srna, "MetaBall", "Metaball datablock to defined blobby surfaces."); + RNA_def_struct_ui_icon(srna, ICON_META_DATA); prop= RNA_def_property(srna, "elements", PROP_COLLECTION, PROP_NONE); RNA_def_property_collection_sdna(prop, NULL, "elems", NULL); diff --git a/source/blender/makesrna/intern/rna_modifier.c b/source/blender/makesrna/intern/rna_modifier.c index 86bea0e7981..8dd6fa1b75b 100644 --- a/source/blender/makesrna/intern/rna_modifier.c +++ b/source/blender/makesrna/intern/rna_modifier.c @@ -372,6 +372,7 @@ static void rna_def_modifier_subsurf(BlenderRNA *brna) srna= RNA_def_struct(brna, "SubsurfModifier", "Modifier"); RNA_def_struct_ui_text(srna, "Subsurf Modifier", "Subdivision surface modifier."); RNA_def_struct_sdna(srna, "SubsurfModifierData"); + RNA_def_struct_ui_icon(srna, ICON_MOD_SUBSURF); rna_def_property_subdivision_common(srna, "subdivType"); @@ -407,6 +408,7 @@ static void rna_def_modifier_multires(BlenderRNA *brna) srna= RNA_def_struct(brna, "MultiresModifier", "Modifier"); RNA_def_struct_ui_text(srna, "Multires Modifier", "Multiresolution mesh modifier."); RNA_def_struct_sdna(srna, "MultiresModifierData"); + RNA_def_struct_ui_icon(srna, ICON_MOD_MULTIRES); rna_def_property_subdivision_common(srna, "simple"); @@ -425,6 +427,7 @@ static void rna_def_modifier_lattice(BlenderRNA *brna) srna= RNA_def_struct(brna, "LatticeModifier", "Modifier"); RNA_def_struct_ui_text(srna, "Lattice Modifier", "Lattice deformation modifier."); RNA_def_struct_sdna(srna, "LatticeModifierData"); + RNA_def_struct_ui_icon(srna, ICON_MOD_LATTICE); prop= RNA_def_property(srna, "object", PROP_POINTER, PROP_NONE); RNA_def_property_ui_text(prop, "Object", "Lattice object to deform with."); @@ -456,6 +459,7 @@ static void rna_def_modifier_curve(BlenderRNA *brna) srna= RNA_def_struct(brna, "CurveModifier", "Modifier"); RNA_def_struct_ui_text(srna, "Curve Modifier", "Curve deformation modifier."); RNA_def_struct_sdna(srna, "CurveModifierData"); + RNA_def_struct_ui_icon(srna, ICON_MOD_CURVE); prop= RNA_def_property(srna, "object", PROP_POINTER, PROP_NONE); RNA_def_property_ui_text(prop, "Object", "Curve object to deform with."); @@ -484,6 +488,7 @@ static void rna_def_modifier_build(BlenderRNA *brna) srna= RNA_def_struct(brna, "BuildModifier", "Modifier"); RNA_def_struct_ui_text(srna, "Build Modifier", "Build effect modifier."); RNA_def_struct_sdna(srna, "BuildModifierData"); + RNA_def_struct_ui_icon(srna, ICON_MOD_BUILD); prop= RNA_def_property(srna, "start", PROP_FLOAT, PROP_NONE); RNA_def_property_range(prop, 1, MAXFRAMEF); @@ -513,6 +518,7 @@ static void rna_def_modifier_mirror(BlenderRNA *brna) srna= RNA_def_struct(brna, "MirrorModifier", "Modifier"); RNA_def_struct_ui_text(srna, "Mirror Modifier", "Mirroring modifier."); RNA_def_struct_sdna(srna, "MirrorModifierData"); + RNA_def_struct_ui_icon(srna, ICON_MOD_MIRROR); prop= RNA_def_property(srna, "x", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", MOD_MIR_AXIS_X); @@ -571,6 +577,7 @@ static void rna_def_modifier_decimate(BlenderRNA *brna) srna= RNA_def_struct(brna, "DecimateModifier", "Modifier"); RNA_def_struct_ui_text(srna, "Decimate Modifier", "Decimation modifier."); RNA_def_struct_sdna(srna, "DecimateModifierData"); + RNA_def_struct_ui_icon(srna, ICON_MOD_DECIM); prop= RNA_def_property(srna, "ratio", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "percent"); @@ -599,6 +606,7 @@ static void rna_def_modifier_wave(BlenderRNA *brna) srna= RNA_def_struct(brna, "WaveModifier", "Modifier"); RNA_def_struct_ui_text(srna, "Wave Modifier", "Wave effect modifier."); RNA_def_struct_sdna(srna, "WaveModifierData"); + RNA_def_struct_ui_icon(srna, ICON_MOD_WAVE); prop= RNA_def_property(srna, "x", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", MOD_WAVE_X); @@ -742,6 +750,7 @@ static void rna_def_modifier_armature(BlenderRNA *brna) srna= RNA_def_struct(brna, "ArmatureModifier", "Modifier"); RNA_def_struct_ui_text(srna, "Armature Modifier", "Armature deformation modifier."); RNA_def_struct_sdna(srna, "ArmatureModifierData"); + RNA_def_struct_ui_icon(srna, ICON_MOD_ARMATURE); prop= RNA_def_property(srna, "object", PROP_POINTER, PROP_NONE); RNA_def_property_ui_text(prop, "Object", "Armature object to deform with."); @@ -794,6 +803,7 @@ static void rna_def_modifier_hook(BlenderRNA *brna) srna= RNA_def_struct(brna, "HookModifier", "Modifier"); RNA_def_struct_ui_text(srna, "Hook Modifier", "Hook modifier to modify the location of vertices."); RNA_def_struct_sdna(srna, "HookModifierData"); + RNA_def_struct_ui_icon(srna, ICON_HOOK); prop= RNA_def_property(srna, "falloff", PROP_FLOAT, PROP_NONE); RNA_def_property_range(prop, 0, FLT_MAX); @@ -825,6 +835,7 @@ static void rna_def_modifier_softbody(BlenderRNA *brna) srna= RNA_def_struct(brna, "SoftbodyModifier", "Modifier"); RNA_def_struct_ui_text(srna, "Softbody Modifier", "Softbody simulation modifier."); RNA_def_struct_sdna(srna, "SoftbodyModifierData"); + RNA_def_struct_ui_icon(srna, ICON_MOD_SOFT); } static void rna_def_modifier_boolean(BlenderRNA *brna) @@ -841,6 +852,7 @@ static void rna_def_modifier_boolean(BlenderRNA *brna) srna= RNA_def_struct(brna, "BooleanModifier", "Modifier"); RNA_def_struct_ui_text(srna, "Boolean Modifier", "Boolean operations modifier."); RNA_def_struct_sdna(srna, "BooleanModifierData"); + RNA_def_struct_ui_icon(srna, ICON_MOD_BOOLEAN); prop= RNA_def_property(srna, "object", PROP_POINTER, PROP_NONE); RNA_def_property_ui_text(prop, "Object", "Mesh object to use for boolean operation."); @@ -868,6 +880,7 @@ static void rna_def_modifier_array(BlenderRNA *brna) srna= RNA_def_struct(brna, "ArrayModifier", "Modifier"); RNA_def_struct_ui_text(srna, "Array Modifier", "Array duplication modifier."); RNA_def_struct_sdna(srna, "ArrayModifierData"); + RNA_def_struct_ui_icon(srna, ICON_MOD_ARRAY); /* Length parameters */ prop= RNA_def_property(srna, "fit_type", PROP_ENUM, PROP_NONE); @@ -967,6 +980,7 @@ static void rna_def_modifier_edgesplit(BlenderRNA *brna) srna= RNA_def_struct(brna, "EdgeSplitModifier", "Modifier"); RNA_def_struct_ui_text(srna, "EdgeSplit Modifier", "Edge splitting modifier to create sharp edges."); RNA_def_struct_sdna(srna, "EdgeSplitModifierData"); + RNA_def_struct_ui_icon(srna, ICON_MOD_EDGESPLIT); prop= RNA_def_property(srna, "split_angle", PROP_FLOAT, PROP_NONE); RNA_def_property_range(prop, 0, 180); @@ -1008,6 +1022,7 @@ static void rna_def_modifier_displace(BlenderRNA *brna) srna= RNA_def_struct(brna, "DisplaceModifier", "Modifier"); RNA_def_struct_ui_text(srna, "Displace Modifier", "Displacement modifier."); RNA_def_struct_sdna(srna, "DisplaceModifierData"); + RNA_def_struct_ui_icon(srna, ICON_MOD_DISPLACE); prop= RNA_def_property(srna, "vertex_group", PROP_STRING, PROP_NONE); RNA_def_property_string_sdna(prop, NULL, "defgrp_name"); @@ -1064,6 +1079,7 @@ static void rna_def_modifier_uvproject(BlenderRNA *brna) srna= RNA_def_struct(brna, "UVProjectModifier", "Modifier"); RNA_def_struct_ui_text(srna, "UVProject Modifier", "UV projection modifier to sets UVs from a projector."); RNA_def_struct_sdna(srna, "UVProjectModifierData"); + RNA_def_struct_ui_icon(srna, ICON_MOD_UVPROJECT); prop= RNA_def_property(srna, "uv_layer", PROP_STRING, PROP_NONE); RNA_def_property_string_sdna(prop, NULL, "uvlayer_name"); @@ -1109,6 +1125,7 @@ static void rna_def_modifier_smooth(BlenderRNA *brna) srna= RNA_def_struct(brna, "SmoothModifier", "Modifier"); RNA_def_struct_ui_text(srna, "Smooth Modifier", "Smoothing effect modifier."); RNA_def_struct_sdna(srna, "SmoothModifierData"); + RNA_def_struct_ui_icon(srna, ICON_MOD_SMOOTH); prop= RNA_def_property(srna, "x", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", MOD_SMOOTH_X); @@ -1158,6 +1175,7 @@ static void rna_def_modifier_cast(BlenderRNA *brna) srna= RNA_def_struct(brna, "CastModifier", "Modifier"); RNA_def_struct_ui_text(srna, "Cast Modifier", "Cast modifier to cast to other shapes."); RNA_def_struct_sdna(srna, "CastModifierData"); + RNA_def_struct_ui_icon(srna, ICON_MOD_CAST); prop= RNA_def_property(srna, "cast_type", PROP_ENUM, PROP_NONE); RNA_def_property_enum_sdna(prop, NULL, "type"); @@ -1214,6 +1232,7 @@ static void rna_def_modifier_meshdeform(BlenderRNA *brna) srna= RNA_def_struct(brna, "MeshDeformModifier", "Modifier"); RNA_def_struct_ui_text(srna, "MeshDeform Modifier", "Mesh deformation modifier to deform with other meshes."); RNA_def_struct_sdna(srna, "MeshDeformModifierData"); + RNA_def_struct_ui_icon(srna, ICON_MOD_MESHDEFORM); prop= RNA_def_property(srna, "object", PROP_POINTER, PROP_NONE); RNA_def_property_ui_text(prop, "Object", "Mesh object to deform with."); @@ -1252,6 +1271,7 @@ static void rna_def_modifier_particlesystem(BlenderRNA *brna) srna= RNA_def_struct(brna, "ParticleSystemModifier", "Modifier"); RNA_def_struct_ui_text(srna, "ParticleSystem Modifier", "Particle system simulation modifier."); RNA_def_struct_sdna(srna, "ParticleSystemModifierData"); + RNA_def_struct_ui_icon(srna, ICON_MOD_PARTICLES); } static void rna_def_modifier_particleinstance(BlenderRNA *brna) @@ -1262,6 +1282,7 @@ static void rna_def_modifier_particleinstance(BlenderRNA *brna) srna= RNA_def_struct(brna, "ParticleInstanceModifier", "Modifier"); RNA_def_struct_ui_text(srna, "ParticleInstance Modifier", "Particle system instancing modifier."); RNA_def_struct_sdna(srna, "ParticleInstanceModifierData"); + RNA_def_struct_ui_icon(srna, ICON_MOD_PARTICLES); prop= RNA_def_property(srna, "object", PROP_POINTER, PROP_NONE); RNA_def_property_pointer_sdna(prop, NULL, "ob"); @@ -1314,6 +1335,7 @@ static void rna_def_modifier_explode(BlenderRNA *brna) srna= RNA_def_struct(brna, "ExplodeModifier", "Modifier"); RNA_def_struct_ui_text(srna, "Explode Modifier", "Explosion effect modifier based on a particle system."); RNA_def_struct_sdna(srna, "ExplodeModifierData"); + RNA_def_struct_ui_icon(srna, ICON_MOD_EXPLODE); prop= RNA_def_property(srna, "vertex_group", PROP_STRING, PROP_NONE); RNA_def_property_string_funcs(prop, "rna_ExplodeModifier_vgroup_get", "rna_ExplodeModifier_vgroup_length", "rna_ExplodeModifier_vgroup_set"); @@ -1353,6 +1375,7 @@ static void rna_def_modifier_cloth(BlenderRNA *brna) srna= RNA_def_struct(brna, "ClothModifier", "Modifier"); RNA_def_struct_ui_text(srna, "Cloth Modifier", "Cloth simulation modifier."); RNA_def_struct_sdna(srna, "ClothModifierData"); + RNA_def_struct_ui_icon(srna, ICON_MOD_CLOTH); prop= RNA_def_property(srna, "settings", PROP_POINTER, PROP_NEVER_NULL); RNA_def_property_pointer_sdna(prop, NULL, "sim_parms"); @@ -1374,6 +1397,7 @@ static void rna_def_modifier_collision(BlenderRNA *brna) srna= RNA_def_struct(brna, "CollisionModifier", "Modifier"); RNA_def_struct_ui_text(srna, "Collision Modifier", "Collision modifier defining modifier stack position used for collision."); RNA_def_struct_sdna(srna, "CollisionModifierData"); + RNA_def_struct_ui_icon(srna, ICON_MOD_PHYSICS); prop= RNA_def_property(srna, "absorption", PROP_INT, PROP_PERCENTAGE); RNA_def_property_int_sdna(prop, NULL, "absorption"); @@ -1402,6 +1426,7 @@ static void rna_def_modifier_bevel(BlenderRNA *brna) srna= RNA_def_struct(brna, "BevelModifier", "Modifier"); RNA_def_struct_ui_text(srna, "Bevel Modifier", "Bevel modifier to make edges and vertices more rounded."); RNA_def_struct_sdna(srna, "BevelModifierData"); + RNA_def_struct_ui_icon(srna, ICON_MOD_BEVEL); prop= RNA_def_property(srna, "width", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "value"); @@ -1448,6 +1473,7 @@ static void rna_def_modifier_shrinkwrap(BlenderRNA *brna) srna= RNA_def_struct(brna, "ShrinkwrapModifier", "Modifier"); RNA_def_struct_ui_text(srna, "Shrinkwrap Modifier", "Shrink wrapping modifier to shrink wrap and object to a target."); RNA_def_struct_sdna(srna, "ShrinkwrapModifierData"); + RNA_def_struct_ui_icon(srna, ICON_MOD_SHRINKWRAP); prop= RNA_def_property(srna, "mode", PROP_ENUM, PROP_NONE); RNA_def_property_enum_sdna(prop, NULL, "shrinkType"); @@ -1537,6 +1563,7 @@ static void rna_def_modifier_fluidsim(BlenderRNA *brna) srna= RNA_def_struct(brna, "FluidSimulationModifier", "Modifier"); RNA_def_struct_ui_text(srna, "Fluid Simulation Modifier", "Fluid simulation modifier."); RNA_def_struct_sdna(srna, "FluidsimModifierData"); + RNA_def_struct_ui_icon(srna, ICON_MOD_FLUIDSIM); prop= RNA_def_property(srna, "settings", PROP_POINTER, PROP_NEVER_NULL); RNA_def_property_pointer_sdna(prop, NULL, "fss"); @@ -1556,6 +1583,7 @@ static void rna_def_modifier_mask(BlenderRNA *brna) srna= RNA_def_struct(brna, "MaskModifier", "Modifier"); RNA_def_struct_ui_text(srna, "Mask Modifier", "Mask modifier to hide parts of the mesh."); RNA_def_struct_sdna(srna, "MaskModifierData"); + RNA_def_struct_ui_icon(srna, ICON_MOD_MASK); prop= RNA_def_property(srna, "mode", PROP_ENUM, PROP_NONE); RNA_def_property_enum_items(prop, prop_mode_items); @@ -1596,6 +1624,7 @@ static void rna_def_modifier_simpledeform(BlenderRNA *brna) srna= RNA_def_struct(brna, "SimpleDeformModifier", "Modifier"); RNA_def_struct_ui_text(srna, "SimpleDeform Modifier", "Simple deformation modifier to apply effects such as twisting and bending."); RNA_def_struct_sdna(srna, "SimpleDeformModifierData"); + RNA_def_struct_ui_icon(srna, ICON_MOD_SIMPLEDEFORM); prop= RNA_def_property(srna, "mode", PROP_ENUM, PROP_NONE); RNA_def_property_enum_items(prop, prop_mode_items); diff --git a/source/blender/makesrna/intern/rna_nodetree.c b/source/blender/makesrna/intern/rna_nodetree.c index ff7984ff1b1..d75d3a5ddf6 100644 --- a/source/blender/makesrna/intern/rna_nodetree.c +++ b/source/blender/makesrna/intern/rna_nodetree.c @@ -1160,6 +1160,7 @@ static void rna_def_nodetree(BlenderRNA *brna) srna = RNA_def_struct(brna, "NodeTree", "ID"); RNA_def_struct_ui_text(srna, "Node Tree", "Node tree consisting of linked nodes used for materials, textures and compositing."); RNA_def_struct_sdna(srna, "bNodeTree"); + RNA_def_struct_ui_icon(srna, ICON_NODE); prop = RNA_def_property(srna, "nodes", PROP_COLLECTION, PROP_NONE); RNA_def_property_collection_sdna(prop, NULL, "nodes", NULL); diff --git a/source/blender/makesrna/intern/rna_object.c b/source/blender/makesrna/intern/rna_object.c index 6baf5083d31..bfd3864bddd 100644 --- a/source/blender/makesrna/intern/rna_object.c +++ b/source/blender/makesrna/intern/rna_object.c @@ -263,6 +263,7 @@ static void rna_def_vertex_group(BlenderRNA *brna) srna= RNA_def_struct(brna, "VertexGroup", NULL); RNA_def_struct_sdna(srna, "bDeformGroup"); RNA_def_struct_ui_text(srna, "Vertex Group", "Group of vertices, used for armature deform and other purposes."); + RNA_def_struct_ui_icon(srna, ICON_GROUP_VERTEX); prop= RNA_def_property(srna, "name", PROP_STRING, PROP_NONE); RNA_def_property_ui_text(prop, "Name", "Vertex group name."); @@ -301,6 +302,7 @@ static void rna_def_object_game_settings(BlenderRNA *brna) RNA_def_struct_sdna(srna, "Object"); RNA_def_struct_nested(brna, srna, "Object"); RNA_def_struct_ui_text(srna, "Game Object Settings", "Game engine related settings for the object."); + RNA_def_struct_ui_icon(srna, ICON_GAME); /* logic */ @@ -522,6 +524,7 @@ static StructRNA *rna_def_object(BlenderRNA *brna) srna= RNA_def_struct(brna, "Object", "ID"); RNA_def_struct_ui_text(srna, "Object", "Object datablock defining an object in a scene.."); RNA_def_struct_clear_flag(srna, STRUCT_ID_REFCOUNT); + RNA_def_struct_ui_icon(srna, ICON_OBJECT_DATA); prop= RNA_def_property(srna, "data", PROP_POINTER, PROP_NONE); RNA_def_property_struct_type(prop, "ID"); diff --git a/source/blender/makesrna/intern/rna_particle.c b/source/blender/makesrna/intern/rna_particle.c index 36a1992670a..40069a995ea 100644 --- a/source/blender/makesrna/intern/rna_particle.c +++ b/source/blender/makesrna/intern/rna_particle.c @@ -435,6 +435,7 @@ static void rna_def_particle_settings(BlenderRNA *brna) srna= RNA_def_struct(brna, "ParticleSettings", "ID"); RNA_def_struct_ui_text(srna, "Particle Settings", "Particle settings, reusable by multiple particle systems."); + RNA_def_struct_ui_icon(srna, ICON_PARTICLE_DATA); /* flag */ prop= RNA_def_property(srna, "react_start_end", PROP_BOOLEAN, PROP_NONE); diff --git a/source/blender/makesrna/intern/rna_rna.c b/source/blender/makesrna/intern/rna_rna.c index 05aa10ec2eb..75bdbebb474 100644 --- a/source/blender/makesrna/intern/rna_rna.c +++ b/source/blender/makesrna/intern/rna_rna.c @@ -30,6 +30,8 @@ #include "RNA_define.h" #include "RNA_types.h" +#include "rna_internal.h" + #ifdef RNA_RUNTIME /* Struct */ @@ -570,6 +572,7 @@ static void rna_def_struct(BlenderRNA *brna) srna= RNA_def_struct(brna, "Struct", NULL); RNA_def_struct_ui_text(srna, "Struct Definition", "RNA structure definition"); + RNA_def_struct_ui_icon(srna, ICON_RNA); prop= RNA_def_property(srna, "name", PROP_STRING, PROP_NONE); RNA_def_property_clear_flag(prop, PROP_EDITABLE); @@ -647,6 +650,7 @@ static void rna_def_property(BlenderRNA *brna) srna= RNA_def_struct(brna, "Property", NULL); RNA_def_struct_ui_text(srna, "Property Definition", "RNA property definition."); RNA_def_struct_refine_func(srna, "rna_Property_refine"); + RNA_def_struct_ui_icon(srna, ICON_RNA); prop= RNA_def_property(srna, "name", PROP_STRING, PROP_NONE); RNA_def_property_clear_flag(prop, PROP_EDITABLE); @@ -699,6 +703,7 @@ static void rna_def_function(BlenderRNA *brna) srna= RNA_def_struct(brna, "Function", NULL); RNA_def_struct_ui_text(srna, "Function Definition", "RNA function definition"); + RNA_def_struct_ui_icon(srna, ICON_RNA); prop= RNA_def_property(srna, "identifier", PROP_STRING, PROP_NONE); RNA_def_property_clear_flag(prop, PROP_EDITABLE); @@ -800,6 +805,7 @@ static void rna_def_enum_property(BlenderRNA *brna, StructRNA *srna) srna= RNA_def_struct(brna, "EnumPropertyItem", NULL); RNA_def_struct_ui_text(srna, "Enum Item Definition", "Definition of a choice in an RNA enum property."); + RNA_def_struct_ui_icon(srna, ICON_RNA); prop= RNA_def_property(srna, "name", PROP_STRING, PROP_NONE); RNA_def_property_clear_flag(prop, PROP_EDITABLE); @@ -884,6 +890,7 @@ void RNA_def_rna(BlenderRNA *brna) /* Blender RNA */ srna= RNA_def_struct(brna, "BlenderRNA", NULL); RNA_def_struct_ui_text(srna, "Blender RNA", "Blender RNA structure definitions."); + RNA_def_struct_ui_icon(srna, ICON_RNA); prop= RNA_def_property(srna, "structs", PROP_COLLECTION, PROP_NONE); RNA_def_property_clear_flag(prop, PROP_EDITABLE); diff --git a/source/blender/makesrna/intern/rna_scene.c b/source/blender/makesrna/intern/rna_scene.c index caa6e73903a..226e6b17b47 100644 --- a/source/blender/makesrna/intern/rna_scene.c +++ b/source/blender/makesrna/intern/rna_scene.c @@ -607,6 +607,7 @@ void RNA_def_scene(BlenderRNA *brna) srna= RNA_def_struct(brna, "Scene", "ID"); RNA_def_struct_ui_text(srna, "Scene", "Scene consisting objects and defining time and render related settings."); + RNA_def_struct_ui_icon(srna, ICON_SCENE_DATA); RNA_def_struct_clear_flag(srna, STRUCT_ID_REFCOUNT); prop= RNA_def_property(srna, "camera", PROP_POINTER, PROP_NONE); diff --git a/source/blender/makesrna/intern/rna_screen.c b/source/blender/makesrna/intern/rna_screen.c index e8b766ff2ea..e153994e7a6 100644 --- a/source/blender/makesrna/intern/rna_screen.c +++ b/source/blender/makesrna/intern/rna_screen.c @@ -90,6 +90,7 @@ static void rna_def_bscreen(BlenderRNA *brna) srna= RNA_def_struct(brna, "Screen", "ID"); RNA_def_struct_sdna(srna, "Screen"); /* it is actually bScreen but for 2.5 the dna is patched! */ RNA_def_struct_ui_text(srna, "Screen", "Screen datablock, defining the layout of areas in a window."); + RNA_def_struct_ui_icon(srna, ICON_SPLITSCREEN); prop= RNA_def_property(srna, "scene", PROP_POINTER, PROP_NEVER_NULL); RNA_def_property_ui_text(prop, "Scene", "Active scene to be edited in the screen."); diff --git a/source/blender/makesrna/intern/rna_scriptlink.c b/source/blender/makesrna/intern/rna_scriptlink.c index f073065f6bc..b486cd4a874 100644 --- a/source/blender/makesrna/intern/rna_scriptlink.c +++ b/source/blender/makesrna/intern/rna_scriptlink.c @@ -41,6 +41,7 @@ void RNA_def_scriptlink(BlenderRNA *brna) srna= RNA_def_struct(brna, "ScriptLink", NULL); RNA_def_struct_ui_text(srna, "Script Link", "Scripts linked to a datablock, to be executed on changes to the datablock."); + RNA_def_struct_ui_icon(srna, ICON_PYTHON); } #endif diff --git a/source/blender/makesrna/intern/rna_sound.c b/source/blender/makesrna/intern/rna_sound.c index c6515385757..118c39655e8 100644 --- a/source/blender/makesrna/intern/rna_sound.c +++ b/source/blender/makesrna/intern/rna_sound.c @@ -134,6 +134,7 @@ static void rna_def_sound(BlenderRNA *brna) srna= RNA_def_struct(brna, "Sound", "ID"); RNA_def_struct_sdna(srna, "bSound"); RNA_def_struct_ui_text(srna, "Sound", "Sound datablock referencing an external or packed sound file."); + RNA_def_struct_ui_icon(srna, ICON_SOUND); //rna_def_ipo_common(srna); diff --git a/source/blender/makesrna/intern/rna_text.c b/source/blender/makesrna/intern/rna_text.c index d3e4a34b9a7..cd39c317bc5 100644 --- a/source/blender/makesrna/intern/rna_text.c +++ b/source/blender/makesrna/intern/rna_text.c @@ -172,6 +172,7 @@ static void rna_def_text(BlenderRNA *brna) srna = RNA_def_struct(brna, "Text", "ID"); RNA_def_struct_ui_text(srna, "Text", "Text datablock referencing an external or packed text file."); + RNA_def_struct_ui_icon(srna, ICON_TEXT); RNA_def_struct_clear_flag(srna, STRUCT_ID_REFCOUNT); prop= RNA_def_property(srna, "filename", PROP_STRING, PROP_NONE); diff --git a/source/blender/makesrna/intern/rna_texture.c b/source/blender/makesrna/intern/rna_texture.c index b0fa4458f22..be97fd863f5 100644 --- a/source/blender/makesrna/intern/rna_texture.c +++ b/source/blender/makesrna/intern/rna_texture.c @@ -990,6 +990,7 @@ static void rna_def_texture(BlenderRNA *brna) srna= RNA_def_struct(brna, "Texture", "ID"); RNA_def_struct_sdna(srna, "Tex"); RNA_def_struct_ui_text(srna, "Texture", "Texture datablock used by materials, lamps, worlds and brushes."); + RNA_def_struct_ui_icon(srna, ICON_TEXTURE_DATA); RNA_def_struct_refine_func(srna, "rna_Texture_refine"); prop= RNA_def_property(srna, "type", PROP_ENUM, PROP_NONE); diff --git a/source/blender/makesrna/intern/rna_vfont.c b/source/blender/makesrna/intern/rna_vfont.c index d18b87e73ee..aa2aaaf6342 100644 --- a/source/blender/makesrna/intern/rna_vfont.c +++ b/source/blender/makesrna/intern/rna_vfont.c @@ -43,6 +43,7 @@ void RNA_def_vfont(BlenderRNA *brna) srna= RNA_def_struct(brna, "VectorFont", "ID"); RNA_def_struct_ui_text(srna, "Vector Font", "Vector font for Text objects."); RNA_def_struct_sdna(srna, "VFont"); + RNA_def_struct_ui_icon(srna, ICON_FONT_DATA); prop= RNA_def_property(srna, "filename", PROP_STRING, PROP_FILEPATH); RNA_def_property_clear_flag(prop, PROP_EDITABLE); diff --git a/source/blender/makesrna/intern/rna_world.c b/source/blender/makesrna/intern/rna_world.c index 7fb7fe656f5..81fad658a7e 100644 --- a/source/blender/makesrna/intern/rna_world.c +++ b/source/blender/makesrna/intern/rna_world.c @@ -338,6 +338,7 @@ void RNA_def_world(BlenderRNA *brna) srna= RNA_def_struct(brna, "World", "ID"); RNA_def_struct_ui_text(srna, "World", "World datablock describing the environment and ambient lighting of a scene."); + RNA_def_struct_ui_icon(srna, ICON_WORLD_DATA); rna_def_animdata_common(srna); rna_def_mtex_common(srna, "rna_World_mtex_begin", "rna_World_active_texture_get", "WorldTextureSlot"); From 4df00c670ef2e03d3dc55b67594e96cc49766831 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Wed, 3 Jun 2009 23:22:43 +0000 Subject: [PATCH 17/35] RNA: * Added a MaterialSlot collection in Object rather than giving the list of materials immediately. This should more correctly reflect how this data is organized, even though there is no equivalent C struct. * Added name properties to MaterialSlot/TextureSlot/ParticleSystem. --- source/blender/makesrna/RNA_access.h | 1 + source/blender/makesrna/intern/rna_object.c | 119 ++++++++++++++---- source/blender/makesrna/intern/rna_particle.c | 32 +++++ source/blender/makesrna/intern/rna_texture.c | 54 ++++++++ 4 files changed, 185 insertions(+), 21 deletions(-) diff --git a/source/blender/makesrna/RNA_access.h b/source/blender/makesrna/RNA_access.h index f1b52ae49ed..70490259832 100644 --- a/source/blender/makesrna/RNA_access.h +++ b/source/blender/makesrna/RNA_access.h @@ -156,6 +156,7 @@ extern StructRNA RNA_Material; extern StructRNA RNA_MaterialHalo; extern StructRNA RNA_MaterialRaytraceMirror; extern StructRNA RNA_MaterialRaytraceTransparency; +extern StructRNA RNA_MaterialSlot; extern StructRNA RNA_MaterialStrand; extern StructRNA RNA_MaterialSubsurfaceScattering; extern StructRNA RNA_MaterialTextureSlot; diff --git a/source/blender/makesrna/intern/rna_object.c b/source/blender/makesrna/intern/rna_object.c index bfd3864bddd..d945fb26982 100644 --- a/source/blender/makesrna/intern/rna_object.c +++ b/source/blender/makesrna/intern/rna_object.c @@ -22,6 +22,7 @@ * ***** END GPL LICENSE BLOCK ***** */ +#include #include #include "RNA_define.h" @@ -30,6 +31,7 @@ #include "rna_internal.h" #include "DNA_customdata_types.h" +#include "DNA_material_types.h" #include "DNA_mesh_types.h" #include "DNA_object_types.h" #include "DNA_property_types.h" @@ -175,7 +177,7 @@ static void rna_Object_active_material_index_range(PointerRNA *ptr, int *min, in static PointerRNA rna_Object_active_material_get(PointerRNA *ptr) { Object *ob= (Object*)ptr->id.data; - return rna_pointer_inherit_refine(ptr, &RNA_Material, give_current_material(ob, ob->actcol)); + return rna_pointer_inherit_refine(ptr, &RNA_MaterialSlot, ob->mat+ob->actcol); } #if 0 @@ -187,20 +189,68 @@ static void rna_Object_active_material_set(PointerRNA *ptr, PointerRNA value) } #endif -static int rna_Object_active_material_link_get(PointerRNA *ptr) +static PointerRNA rna_MaterialSlot_material_get(PointerRNA *ptr) { Object *ob= (Object*)ptr->id.data; - return (ob->colbits & 1<<(ob->actcol)) != 0; + Material *ma; + int index= (Material**)ptr->data - ob->mat; + + ma= give_current_material(ob, index+1); + return rna_pointer_inherit_refine(ptr, &RNA_Material, ma); } -static void rna_Object_active_material_link_set(PointerRNA *ptr, int value) +static void rna_MaterialSlot_material_set(PointerRNA *ptr, PointerRNA value) { Object *ob= (Object*)ptr->id.data; + int index= (Material**)ptr->data - ob->mat; + + assign_material(ob, value.data, index+1); +} + +static int rna_MaterialSlot_link_get(PointerRNA *ptr) +{ + Object *ob= (Object*)ptr->id.data; + int index= (Material**)ptr->data - ob->mat; + + return (ob->colbits & (1<id.data; + int index= (Material**)ptr->data - ob->mat; if(value) - ob->colbits |= (1<<(ob->actcol)); + ob->colbits |= (1<colbits &= ~(1<<(ob->actcol)); + ob->colbits &= ~(1<id.data; + Material *ma; + int index= (Material**)ptr->data - ob->mat; + + ma= give_current_material(ob, index+1); + + if(ma) + return strlen(ma->id.name+2) + 10; + + return 10; +} + +static void rna_MaterialSlot_name_get(PointerRNA *ptr, char *str) +{ + Object *ob= (Object*)ptr->id.data; + Material *ma; + int index= (Material**)ptr->data - ob->mat; + + sprintf(str, "%d: ", index+1); + + ma= give_current_material(ob, index+1); + if(ma) + strcat(str, ma->id.name+2); } static PointerRNA rna_Object_active_particle_system_get(PointerRNA *ptr) @@ -275,6 +325,42 @@ static void rna_def_vertex_group(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Index", "Index number of the vertex group."); } +static void rna_def_material_slot(BlenderRNA *brna) +{ + StructRNA *srna; + PropertyRNA *prop; + + static EnumPropertyItem link_items[] = { + {0, "DATA", "Data", ""}, + {1, "OBJECT", "Object", ""}, + {0, NULL, NULL, NULL}}; + + /* NOTE: there is no MaterialSlot equivalent in DNA, so the internal + * pointer data points to ob->mat + index, and we manually implement + * get/set for the properties. */ + + srna= RNA_def_struct(brna, "MaterialSlot", NULL); + RNA_def_struct_ui_text(srna, "Material Slot", "Material slot in an object."); + RNA_def_struct_ui_icon(srna, ICON_MATERIAL_DATA); + + prop= RNA_def_property(srna, "material", PROP_POINTER, PROP_NONE); + RNA_def_property_struct_type(prop, "Material"); + RNA_def_property_flag(prop, PROP_EDITABLE); + RNA_def_property_pointer_funcs(prop, "rna_MaterialSlot_material_get", "rna_MaterialSlot_material_set"); + RNA_def_property_ui_text(prop, "Material", "Material datablock used by this material slot."); + + prop= RNA_def_property(srna, "link", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_items(prop, link_items); + RNA_def_property_enum_funcs(prop, "rna_MaterialSlot_link_get", "rna_MaterialSlot_link_set", NULL); + RNA_def_property_ui_text(prop, "Link", "Link material to object or the object's data."); + + prop= RNA_def_property(srna, "name", PROP_STRING, PROP_NONE); + RNA_def_property_string_funcs(prop, "rna_MaterialSlot_name_get", "rna_MaterialSlot_name_length", NULL); + RNA_def_property_ui_text(prop, "Name", "Material slot name."); + RNA_def_property_clear_flag(prop, PROP_EDITABLE); + RNA_def_struct_name_property(srna, prop); +} + static void rna_def_object_game_settings(BlenderRNA *brna) { StructRNA *srna; @@ -508,11 +594,6 @@ static StructRNA *rna_def_object(BlenderRNA *brna) {OB_BOUND_POLYH, "POLYHEDER", "Polyheder", ""}, {0, NULL, NULL, NULL}}; - static EnumPropertyItem material_link_items[] = { - {0, "DATA", "Data", ""}, - {1, "OBJECT", "Object", ""}, - {0, NULL, NULL, NULL}}; - static EnumPropertyItem dupli_items[] = { {0, "NONE", "None", ""}, {OB_DUPLIFRAMES, "FRAMES", "Frames", "Make copy of object for every frame."}, @@ -590,26 +671,21 @@ static StructRNA *rna_def_object(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Proxy Group", "Library group duplicator object this proxy object controls."); /* materials */ - prop= RNA_def_property(srna, "materials", PROP_COLLECTION, PROP_NONE); RNA_def_property_collection_sdna(prop, NULL, "mat", "totcol"); - RNA_def_property_struct_type(prop, "Material"); - RNA_def_property_ui_text(prop, "Materials", ""); + RNA_def_property_struct_type(prop, "MaterialSlot"); + RNA_def_property_collection_funcs(prop, NULL, NULL, NULL, "rna_iterator_array_get", 0, 0, 0); /* don't dereference pointer! */ + RNA_def_property_ui_text(prop, "Materials", "Material slots in the object."); prop= RNA_def_property(srna, "active_material", PROP_POINTER, PROP_NONE); - RNA_def_property_struct_type(prop, "Material"); + RNA_def_property_struct_type(prop, "MaterialSlot"); RNA_def_property_pointer_funcs(prop, "rna_Object_active_material_get", NULL); RNA_def_property_ui_text(prop, "Active Material", "Active material being displayed."); prop= RNA_def_property(srna, "active_material_index", PROP_INT, PROP_UNSIGNED); RNA_def_property_int_sdna(prop, NULL, "actcol"); RNA_def_property_int_funcs(prop, NULL, NULL, "rna_Object_active_material_index_range"); - RNA_def_property_ui_text(prop, "Active Material Index", "Index of active material."); - - prop= RNA_def_property(srna, "active_material_link", PROP_ENUM, PROP_NONE); - RNA_def_property_enum_items(prop, material_link_items); - RNA_def_property_enum_funcs(prop, "rna_Object_active_material_link_get", "rna_Object_active_material_link_set", NULL); - RNA_def_property_ui_text(prop, "Active Material Link", "Use material from object or data for the active material."); + RNA_def_property_ui_text(prop, "Active Material Index", "Index of active material slot."); /* transform */ @@ -971,6 +1047,7 @@ void RNA_def_object(BlenderRNA *brna) rna_def_object(brna); rna_def_object_game_settings(brna); rna_def_vertex_group(brna); + rna_def_material_slot(brna); } #endif diff --git a/source/blender/makesrna/intern/rna_particle.c b/source/blender/makesrna/intern/rna_particle.c index 40069a995ea..ee755fca27e 100644 --- a/source/blender/makesrna/intern/rna_particle.c +++ b/source/blender/makesrna/intern/rna_particle.c @@ -22,6 +22,7 @@ * ***** END GPL LICENSE BLOCK ***** */ +#include #include #include "limits.h" @@ -33,6 +34,7 @@ #include "DNA_particle_types.h" #include "DNA_object_force.h" +#include "DNA_object_types.h" #ifdef RNA_RUNTIME @@ -86,6 +88,29 @@ static float rna_PartSetting_linelenhead_get(struct PointerRNA *ptr) ParticleSettings *settings = (ParticleSettings*)ptr->data; return settings->draw_line[1]; } + +static int rna_ParticleSystem_name_length(PointerRNA *ptr) +{ + ParticleSystem *psys= ptr->data; + + if(psys->part) + return strlen(psys->part->id.name+2) + 10; + + return 10; +} + +static void rna_ParticleSystem_name_get(PointerRNA *ptr, char *str) +{ + Object *ob= ptr->id.data; + ParticleSystem *psys= ptr->data; + int index= BLI_findindex(&ob->particlesystem, psys); + + sprintf(str, "%d: ", index+1); + + if(psys->part) + strcat(str, psys->part->id.name+2); +} + #else static void rna_def_particle_hair_key(BlenderRNA *brna) @@ -1176,6 +1201,13 @@ static void rna_def_particle_system(BlenderRNA *brna) srna= RNA_def_struct(brna, "ParticleSystem", NULL); RNA_def_struct_ui_text(srna, "Particle System", "Particle system in an object."); + RNA_def_struct_ui_icon(srna, ICON_PARTICLE_DATA); + + prop= RNA_def_property(srna, "name", PROP_STRING, PROP_NONE); + RNA_def_property_string_funcs(prop, "rna_ParticleSystem_name_get", "rna_ParticleSystem_name_length", NULL); + RNA_def_property_ui_text(prop, "Name", "Particle system name."); + RNA_def_property_clear_flag(prop, PROP_EDITABLE); + RNA_def_struct_name_property(srna, prop); prop= RNA_def_property(srna, "settings", PROP_POINTER, PROP_NEVER_NULL); RNA_def_property_pointer_sdna(prop, NULL, "part"); diff --git a/source/blender/makesrna/intern/rna_texture.c b/source/blender/makesrna/intern/rna_texture.c index be97fd863f5..1d8a63bf83a 100644 --- a/source/blender/makesrna/intern/rna_texture.c +++ b/source/blender/makesrna/intern/rna_texture.c @@ -23,6 +23,7 @@ */ #include +#include #include #include "RNA_define.h" @@ -30,8 +31,11 @@ #include "rna_internal.h" +#include "DNA_brush_types.h" +#include "DNA_lamp_types.h" #include "DNA_material_types.h" #include "DNA_texture_types.h" +#include "DNA_world_types.h" #ifdef RNA_RUNTIME @@ -71,6 +75,50 @@ StructRNA *rna_Texture_refine(struct PointerRNA *ptr) } } +static int rna_texture_slot_index(PointerRNA *ptr) +{ + ID *id= ptr->id.data; + MTex **mtex; + int a; + + if(id) { + switch(GS(id->name)) { + case ID_MA: mtex= ((Material*)id)->mtex; break; + case ID_WO: mtex= ((World*)id)->mtex; break; + case ID_LA: mtex= ((Lamp*)id)->mtex; break; + case ID_BR: mtex= ((Brush*)id)->mtex; break; + default: return 0; + } + + for(a=0; adata) + return a; + } + + return 0; +} + +static int rna_TextureSlot_name_length(PointerRNA *ptr) +{ + MTex *mtex= ptr->data; + + if(mtex->tex) + return strlen(mtex->tex->id.name+2) + 10; + + return 10; +} + +static void rna_TextureSlot_name_get(PointerRNA *ptr, char *str) +{ + MTex *mtex= ptr->data; + int index= rna_texture_slot_index(ptr); + + sprintf(str, "%d: ", index+1); + + if(mtex->tex) + strcat(str, mtex->tex->id.name+2); +} + #else static void rna_def_color_ramp_element(BlenderRNA *brna) @@ -190,6 +238,12 @@ static void rna_def_mtex(BlenderRNA *brna) RNA_def_property_flag(prop, PROP_EDITABLE); RNA_def_property_ui_text(prop, "Texture", "Texture datablock used by this texture slot."); + prop= RNA_def_property(srna, "name", PROP_STRING, PROP_NONE); + RNA_def_property_string_funcs(prop, "rna_TextureSlot_name_get", "rna_TextureSlot_name_length", NULL); + RNA_def_property_ui_text(prop, "Name", "Texture slot name."); + RNA_def_property_clear_flag(prop, PROP_EDITABLE); + RNA_def_struct_name_property(srna, prop); + /* mapping */ prop= RNA_def_property(srna, "offset", PROP_FLOAT, PROP_VECTOR); RNA_def_property_float_sdna(prop, NULL, "ofs"); From 5587e9bd09d7e23526775cd01b8e7bb75578e7d1 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Wed, 3 Jun 2009 23:33:56 +0000 Subject: [PATCH 18/35] UI: * First step for buttons context browsing, read-only still. * Drawn in a panel now, though this should become a separate region. * Path of the context is constructed as an array of RNA pointers and then used for drawing and context lookups from python. --- source/blender/blenloader/intern/readfile.c | 18 +- .../editors/interface/interface_panel.c | 2 +- .../blender/editors/preview/previewrender.c | 2 +- source/blender/editors/screen/area.c | 2 +- .../editors/space_buttons/buttons_context.c | 521 +++++++++++++++--- .../editors/space_buttons/buttons_intern.h | 2 + .../editors/space_buttons/space_buttons.c | 11 +- .../blender/editors/space_outliner/outliner.c | 4 +- source/blender/makesdna/DNA_space_types.h | 6 +- source/blender/makesrna/intern/rna_texture.c | 1 + 10 files changed, 467 insertions(+), 102 deletions(-) diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c index f8657125014..78a156559ff 100644 --- a/source/blender/blenloader/intern/readfile.c +++ b/source/blender/blenloader/intern/readfile.c @@ -4190,6 +4190,7 @@ static void lib_link_screen(FileData *fd, Main *main) SpaceButs *sbuts= (SpaceButs *)sl; sbuts->lockpoin= NULL; sbuts->ri= NULL; + sbuts->pinid= newlibadr(fd, sc->id.lib, sbuts->pinid); if(main->versionfile<132) butspace_version_132(sbuts); } @@ -4391,6 +4392,7 @@ void lib_link_screen_restore(Main *newmain, bScreen *curscreen, Scene *curscene) else if(sl->spacetype==SPACE_BUTS) { SpaceButs *sbuts= (SpaceButs *)sl; sbuts->lockpoin= NULL; + sbuts->pinid = restore_pointer_by_name(newmain, sbuts->pinid, 0); //XXX if (sbuts->ri) sbuts->ri->curtile = 0; } else if(sl->spacetype==SPACE_FILE) { @@ -4674,6 +4676,10 @@ static void direct_link_screen(FileData *fd, bScreen *sc) direct_link_gpencil(fd, sseq->gpd); } } + else if(sl->spacetype==SPACE_BUTS) { + SpaceButs *sbuts= (SpaceButs *)sl; + sbuts->path= NULL; + } } sa->actionzones.first= sa->actionzones.last= NULL; @@ -6744,26 +6750,26 @@ static void do_versions(FileData *fd, Library *lib, Main *main) if(sbuts->mainb==BUTS_LAMP) { sbuts->mainb= CONTEXT_SHADING; - sbuts->tab[CONTEXT_SHADING]= TAB_SHADING_LAMP; + //sbuts->tab[CONTEXT_SHADING]= TAB_SHADING_LAMP; } else if(sbuts->mainb==BUTS_MAT) { sbuts->mainb= CONTEXT_SHADING; - sbuts->tab[CONTEXT_SHADING]= TAB_SHADING_MAT; + //sbuts->tab[CONTEXT_SHADING]= TAB_SHADING_MAT; } else if(sbuts->mainb==BUTS_TEX) { sbuts->mainb= CONTEXT_SHADING; - sbuts->tab[CONTEXT_SHADING]= TAB_SHADING_TEX; + //sbuts->tab[CONTEXT_SHADING]= TAB_SHADING_TEX; } else if(sbuts->mainb==BUTS_ANIM) { sbuts->mainb= CONTEXT_OBJECT; } else if(sbuts->mainb==BUTS_WORLD) { sbuts->mainb= CONTEXT_SCENE; - sbuts->tab[CONTEXT_SCENE]= TAB_SCENE_WORLD; + //sbuts->tab[CONTEXT_SCENE]= TAB_SCENE_WORLD; } else if(sbuts->mainb==BUTS_RENDER) { sbuts->mainb= CONTEXT_SCENE; - sbuts->tab[CONTEXT_SCENE]= TAB_SCENE_RENDER; + //sbuts->tab[CONTEXT_SCENE]= TAB_SCENE_RENDER; } else if(sbuts->mainb==BUTS_GAME) { sbuts->mainb= CONTEXT_LOGIC; @@ -6773,7 +6779,7 @@ static void do_versions(FileData *fd, Library *lib, Main *main) } else if(sbuts->mainb==BUTS_RADIO) { sbuts->mainb= CONTEXT_SHADING; - sbuts->tab[CONTEXT_SHADING]= TAB_SHADING_RAD; + //sbuts->tab[CONTEXT_SHADING]= TAB_SHADING_RAD; } else if(sbuts->mainb==BUTS_CONSTRAINT) { sbuts->mainb= CONTEXT_OBJECT; diff --git a/source/blender/editors/interface/interface_panel.c b/source/blender/editors/interface/interface_panel.c index 539f18c2cd8..a141e58fbe9 100644 --- a/source/blender/editors/interface/interface_panel.c +++ b/source/blender/editors/interface/interface_panel.c @@ -119,7 +119,7 @@ static int panels_re_align(ScrArea *sa, ARegion *ar, Panel **r_pa) SpaceButs *sbuts= sa->spacedata.first; if(sbuts->align) - if(sbuts->re_align || sbuts->mainbo!=sbuts->mainb || sbuts->tabo!=sbuts->tab[sbuts->mainb]) + if(sbuts->re_align || sbuts->mainbo!=sbuts->mainb) return 1; } else if(ar->regiontype==RGN_TYPE_UI) diff --git a/source/blender/editors/preview/previewrender.c b/source/blender/editors/preview/previewrender.c index 1d5d809a9ee..85cb1e4e1bf 100644 --- a/source/blender/editors/preview/previewrender.c +++ b/source/blender/editors/preview/previewrender.c @@ -586,7 +586,7 @@ void BIF_previewrender_buts(Scene *scene, SpaceButs *sbuts) sbuts->lockpoin= id; if(sbuts->mainb==CONTEXT_SHADING) { - int tab= sbuts->tab[CONTEXT_SHADING]; + int tab= TAB_SHADING_MAT; // XXX sbuts->tab[CONTEXT_SHADING]; if(tab==TAB_SHADING_MAT) idshow = sbuts->lockpoin; diff --git a/source/blender/editors/screen/area.c b/source/blender/editors/screen/area.c index 7d9cc748d05..81b63b694ba 100644 --- a/source/blender/editors/screen/area.c +++ b/source/blender/editors/screen/area.c @@ -1137,7 +1137,7 @@ void ED_region_panels(const bContext *C, ARegion *ar, int vertical, char *contex for(pt= ar->type->paneltypes.first; pt; pt= pt->next) { /* verify context */ if(context) - if(!pt->context || strcmp(context, pt->context) != 0) + if(pt->context[0] && strcmp(context, pt->context) != 0) continue; /* draw panel */ diff --git a/source/blender/editors/space_buttons/buttons_context.c b/source/blender/editors/space_buttons/buttons_context.c index 642aab52e9d..3e6fa9c6cff 100644 --- a/source/blender/editors/space_buttons/buttons_context.c +++ b/source/blender/editors/space_buttons/buttons_context.c @@ -26,154 +26,455 @@ */ #include +#include + +#include "MEM_guardedalloc.h" #include "DNA_armature_types.h" -#include "DNA_object_types.h" +#include "DNA_lamp_types.h" #include "DNA_material_types.h" #include "DNA_modifier_types.h" +#include "DNA_object_types.h" #include "DNA_scene_types.h" +#include "DNA_screen_types.h" +#include "DNA_space_types.h" #include "DNA_particle_types.h" #include "DNA_texture_types.h" #include "DNA_world_types.h" +#include "BLI_listbase.h" + #include "BKE_context.h" #include "BKE_material.h" #include "BKE_modifier.h" #include "BKE_particle.h" +#include "BKE_screen.h" +#include "BKE_utildefines.h" #include "RNA_access.h" +#include "UI_interface.h" +#include "UI_resources.h" + #include "buttons_intern.h" // own include +typedef struct ButsContextPath { + PointerRNA ptr[8]; + int len; +} ButsContextPath; + +/************************* Creating the Path ************************/ + +static int buttons_context_path_scene(ButsContextPath *path) +{ + PointerRNA *ptr= &path->ptr[path->len-1]; + + /* this one just verifies */ + return RNA_struct_is_a(ptr->type, &RNA_Scene); +} + +static int buttons_context_path_world(ButsContextPath *path) +{ + Scene *scene; + PointerRNA *ptr= &path->ptr[path->len-1]; + + /* if we already have a (pinned) world, we're done */ + if(RNA_struct_is_a(ptr->type, &RNA_World)) { + return 1; + } + /* if we have a scene, use the scene's world */ + else if(buttons_context_path_scene(path)) { + scene= path->ptr[path->len-1].data; + + RNA_id_pointer_create(&scene->world->id, &path->ptr[path->len]); + path->len++; + + return 1; + } + + /* no path to a world possible */ + return 0; +} + +static int buttons_context_path_object(ButsContextPath *path) +{ + Scene *scene; + Object *ob; + PointerRNA *ptr= &path->ptr[path->len-1]; + + /* if we already have a (pinned) object, we're done */ + if(RNA_struct_is_a(ptr->type, &RNA_Object)) { + return 1; + } + /* if we have a scene, use the scene's active object */ + else if(buttons_context_path_scene(path)) { + scene= path->ptr[path->len-1].data; + ob= (scene->basact)? scene->basact->object: NULL; + + if(ob) { + RNA_id_pointer_create(&ob->id, &path->ptr[path->len]); + path->len++; + + return 1; + } + } + + /* no path to a object possible */ + return 0; +} + +static int buttons_context_path_data(ButsContextPath *path, int type) +{ + Object *ob; + + /* try to get an object in the path, no pinning supported here */ + if(buttons_context_path_object(path)) { + ob= path->ptr[path->len-1].data; + + if(type == -1 || type == ob->type) { + RNA_id_pointer_create(ob->data, &path->ptr[path->len]); + path->len++; + + return 1; + } + } + + /* no path to data possible */ + return 0; +} + +static int buttons_context_path_material(ButsContextPath *path) +{ + Object *ob; + PointerRNA *ptr= &path->ptr[path->len-1]; + + /* if we already have a (pinned) material, we're done */ + if(RNA_struct_is_a(ptr->type, &RNA_Material)) { + return 1; + } + /* if we have an object, use the object material slot */ + else if(buttons_context_path_object(path)) { + ob= path->ptr[path->len-1].data; + + if(ob && ob->type && (ob->typeid, &RNA_MaterialSlot, ob->mat+ob->actcol-1, &path->ptr[path->len]); + path->len++; + return 1; + } + } + + /* no path to a material possible */ + return 0; +} + +static Bone *find_active_bone(Bone *bone) +{ + Bone *active; + + for(; bone; bone=bone->next) { + if(bone->flag & BONE_ACTIVE) + return bone; + + active= find_active_bone(bone->childbase.first); + if(active) + return active; + } + + return NULL; +} + +static int buttons_context_path_bone(ButsContextPath *path) +{ + bArmature *arm; + Bone *bone; + + /* if we have an armature, get the active bone */ + if(buttons_context_path_data(path, OB_ARMATURE)) { + arm= path->ptr[path->len-1].data; + bone= find_active_bone(arm->bonebase.first); + + if(bone) { + RNA_pointer_create(&arm->id, &RNA_Bone, bone, &path->ptr[path->len]); + path->len++; + return 1; + } + } + + /* no path to a bone possible */ + return 0; +} + +static int buttons_context_path_particle(ButsContextPath *path) +{ + Object *ob; + ParticleSystem *psys; + + /* if we have an object, get the active particle system */ + if(buttons_context_path_object(path)) { + ob= path->ptr[path->len-1].data; + psys= psys_get_current(ob); + + RNA_pointer_create(&ob->id, &RNA_ParticleSystem, psys, &path->ptr[path->len]); + path->len++; + return 1; + } + + /* no path to a particle system possible */ + return 0; +} + +static int buttons_context_path_texture(ButsContextPath *path) +{ + Object *ob; + Lamp *la; + Material *ma; + PointerRNA *ptr= &path->ptr[path->len-1]; + + /* if we already have a (pinned) texture, we're done */ + if(RNA_struct_is_a(ptr->type, &RNA_Texture)) { + return 1; + } + /* try to get the active material */ + else if(buttons_context_path_material(path)) { + ptr= &path->ptr[path->len-1]; + + if(RNA_struct_is_a(ptr->type, &RNA_Material)) { + ma= ptr->data; + } + else if(RNA_struct_is_a(ptr->type, &RNA_MaterialSlot)) { + ob= ptr->id.data; + ma= give_current_material(ob, (Material**)ptr->data - ob->mat); + } + else + ma= NULL; + + if(ma) { + RNA_pointer_create(&ma->id, &RNA_TextureSlot, ma->mtex[(int)ma->texact], &path->ptr[path->len]); + path->len++; + return 1; + } + } + /* try to get the active lamp */ + else if(buttons_context_path_data(path, OB_LAMP)) { + la= path->ptr[path->len-1].data; + + if(la) { + RNA_pointer_create(&la->id, &RNA_TextureSlot, la->mtex[(int)la->texact], &path->ptr[path->len]); + path->len++; + return 1; + } + } + /* TODO: world, brush */ + + /* no path to a particle system possible */ + return 0; +} + +static int buttons_context_path(const bContext *C, ButsContextPath *path) +{ + SpaceButs *sbuts= (SpaceButs*)CTX_wm_space_data(C); + ID *id; + int found; + + memset(path, 0, sizeof(*path)); + + /* if some ID datablock is pinned, set the root pointer */ + if(sbuts->pinid) { + id= sbuts->pinid; + + RNA_id_pointer_create(id, &path->ptr[0]); + path->len++; + } + + /* no pinned root, use scene as root */ + if(path->len == 0) { + id= (ID*)CTX_data_scene(C); + RNA_id_pointer_create(id, &path->ptr[0]); + path->len++; + } + + /* now for each buttons context type, we try to construct a path, + * tracing back recursively */ + switch(sbuts->mainb) { + case BCONTEXT_SCENE: + found= buttons_context_path_scene(path); + break; + case BCONTEXT_WORLD: + found= buttons_context_path_world(path); + break; + case BCONTEXT_OBJECT: + case BCONTEXT_PHYSICS: + case BCONTEXT_MODIFIER: + found= buttons_context_path_object(path); + break; + case BCONTEXT_DATA: + found= buttons_context_path_data(path, -1); + break; + case BCONTEXT_PARTICLE: + found= buttons_context_path_particle(path); + break; + case BCONTEXT_MATERIAL: + found= buttons_context_path_material(path); + break; + case BCONTEXT_TEXTURE: + found= buttons_context_path_texture(path); + break; + case BCONTEXT_BONE: + found= buttons_context_path_bone(path); + break; + default: + found= 0; + break; + } + + return found; +} + +void buttons_context_compute(const bContext *C, SpaceButs *sbuts) +{ + if(!sbuts->path) + sbuts->path= MEM_callocN(sizeof(ButsContextPath), "ButsContextPath"); + + buttons_context_path(C, sbuts->path); +} + +/************************* Context Callback ************************/ + +static int set_pointer_type(ButsContextPath *path, bContextDataResult *result, StructRNA *type) +{ + PointerRNA *ptr; + int a; + + for(a=0; alen; a++) { + ptr= &path->ptr[a]; + + if(RNA_struct_is_a(ptr->type, type)) { + CTX_data_pointer_set(result, ptr->id.data, ptr->type, ptr->data); + return 1; + } + } + + return 0; +} + +static PointerRNA *get_pointer_type(ButsContextPath *path, StructRNA *type) +{ + PointerRNA *ptr; + int a; + + for(a=0; alen; a++) { + ptr= &path->ptr[a]; + + if(RNA_struct_is_a(ptr->type, type)) + return ptr; + } + + return NULL; +} + int buttons_context(const bContext *C, const char *member, bContextDataResult *result) { - Scene *scene= CTX_data_scene(C); - Object *ob= (scene->basact)? scene->basact->object: NULL; + SpaceButs *sbuts= (SpaceButs*)CTX_wm_space_data(C); + ButsContextPath *path= sbuts->path; - if(CTX_data_equals(member, "scene")) { - CTX_data_pointer_set(result, &scene->id, &RNA_Scene, scene); - return 1; - } - else if(CTX_data_equals(member, "world")) { - CTX_data_pointer_set(result, &scene->world->id, &RNA_World, scene->world); + if(!path) + return 0; + + /* here we handle context, getting data from precomputed path */ + + if(CTX_data_equals(member, "world")) { + set_pointer_type(path, result, &RNA_World); return 1; } else if(CTX_data_equals(member, "object")) { - CTX_data_pointer_set(result, &ob->id, &RNA_Object, ob); + set_pointer_type(path, result, &RNA_Object); return 1; } else if(CTX_data_equals(member, "mesh")) { - if(ob && ob->type == OB_MESH) { - CTX_data_pointer_set(result, ob->data, &RNA_Mesh, ob->data); - return 1; - } + set_pointer_type(path, result, &RNA_Mesh); + return 1; } else if(CTX_data_equals(member, "armature")) { - if(ob && ob->type == OB_ARMATURE) { - CTX_data_pointer_set(result, ob->data, &RNA_Armature, ob->data); - return 1; - } + set_pointer_type(path, result, &RNA_Armature); + return 1; } else if(CTX_data_equals(member, "lattice")) { - if(ob && ob->type == OB_LATTICE) { - CTX_data_pointer_set(result, ob->data, &RNA_Lattice, ob->data); - return 1; - } + set_pointer_type(path, result, &RNA_Lattice); + return 1; } else if(CTX_data_equals(member, "curve")) { - if(ob && ob->type == OB_CURVE) { - CTX_data_pointer_set(result, ob->data, &RNA_Curve, ob->data); - return 1; - } + set_pointer_type(path, result, &RNA_Curve); + return 1; } else if(CTX_data_equals(member, "meta_ball")) { - if(ob && ob->type == OB_MBALL) { - CTX_data_pointer_set(result, ob->data, &RNA_MetaBall, ob->data); - return 1; - } + set_pointer_type(path, result, &RNA_MetaBall); + return 1; } else if(CTX_data_equals(member, "lamp")) { - if(ob && ob->type == OB_LAMP) { - CTX_data_pointer_set(result, ob->data, &RNA_Lamp, ob->data); - return 1; - } + set_pointer_type(path, result, &RNA_Lamp); + return 1; } else if(CTX_data_equals(member, "camera")) { - if(ob && ob->type == OB_CAMERA) { - CTX_data_pointer_set(result, ob->data, &RNA_Camera, ob->data); - return 1; - } + set_pointer_type(path, result, &RNA_Camera); + return 1; } else if(CTX_data_equals(member, "material")) { - if(ob && ob->type && (ob->typeactcol); - CTX_data_pointer_set(result, &ma->id, &RNA_Material, ma); - return 1; + if(!set_pointer_type(path, result, &RNA_Material)) { + PointerRNA *ptr= get_pointer_type(path, &RNA_MaterialSlot); + + if(ptr && ptr->data) { + Object *ob= ptr->id.data; + Material *ma= give_current_material(ob, (Material**)ptr->data - ob->mat); + CTX_data_id_pointer_set(result, &ma->id); + } } + + return 1; } else if(CTX_data_equals(member, "texture")) { - if(ob && ob->type && (ob->typeactcol); + if(!set_pointer_type(path, result, &RNA_Texture)) { + PointerRNA *ptr= get_pointer_type(path, &RNA_TextureSlot); - if(ma) { - MTex *mtex= ma->mtex[(int)ma->texact]; - - if(mtex->tex) { - CTX_data_pointer_set(result, &mtex->tex->id, &RNA_Texture, mtex->tex); - return 1; - } - } + if(ptr && ptr->data) + CTX_data_id_pointer_set(result, &((MTex*)ptr->data)->tex->id); } + + return 1; } else if(CTX_data_equals(member, "material_slot")) { + set_pointer_type(path, result, &RNA_MaterialSlot); + return 1; } else if(CTX_data_equals(member, "texture_slot")) { - if(ob && ob->type && (ob->typeactcol); - - if(ma) { - MTex *mtex= ma->mtex[(int)ma->texact]; - - CTX_data_pointer_set(result, &ma->id, &RNA_TextureSlot, mtex); - return 1; - } - } + set_pointer_type(path, result, &RNA_TextureSlot); + return 1; } else if(CTX_data_equals(member, "bone")) { - if(ob && ob->type == OB_ARMATURE) { - bArmature *arm= ob->data; - Bone *bone; - - for(bone=arm->bonebase.first; bone; bone=bone->next) { - if(bone->flag & BONE_ACTIVE) { - CTX_data_pointer_set(result, &arm->id, &RNA_Bone, bone); - return 1; - } - } - } + set_pointer_type(path, result, &RNA_Bone); + return 1; } else if(CTX_data_equals(member, "particle_system")) { - if(ob) { - ParticleSystem *psys= psys_get_current(ob); - CTX_data_pointer_set(result, &ob->id, &RNA_ParticleSystem, psys); - return 1; - } + set_pointer_type(path, result, &RNA_ParticleSystem); + return 1; } else if(CTX_data_equals(member, "cloth")) { - if(ob) { - ModifierData *md= modifiers_findByType(ob, eModifierType_Cloth); - CTX_data_pointer_set(result, &ob->id, &RNA_ClothModifier, md); - return 1; - } + set_pointer_type(path, result, &RNA_ClothModifier); + return 1; } else if(CTX_data_equals(member, "soft_body")) { - if(ob) { + PointerRNA *ptr= get_pointer_type(path, &RNA_Object); + + if(ptr && ptr->data) { + Object *ob= ptr->data; CTX_data_pointer_set(result, &ob->id, &RNA_SoftBodySettings, ob->soft); return 1; } } else if(CTX_data_equals(member, "fluid")) { - if(ob) { + PointerRNA *ptr= get_pointer_type(path, &RNA_Object); + + if(ptr && ptr->data) { + Object *ob= ptr->data; ModifierData *md= modifiers_findByType(ob, eModifierType_Fluidsim); CTX_data_pointer_set(result, &ob->id, &RNA_FluidSimulationModifier, md); return 1; @@ -183,3 +484,53 @@ int buttons_context(const bContext *C, const char *member, bContextDataResult *r return 0; } +/************************* Drawing the Path ************************/ + +static void buttons_panel_context(const bContext *C, Panel *pa) +{ + SpaceButs *sbuts= (SpaceButs*)CTX_wm_space_data(C); + ButsContextPath *path= sbuts->path; + uiLayout *row; + PointerRNA *ptr; + PropertyRNA *nameprop; + char namebuf[128], *name; + int a, icon; + + if(!path) + return; + + row= uiLayoutRow(pa->layout, 0); + uiLayoutSetAlignment(row, UI_LAYOUT_ALIGN_LEFT); + + for(a=0; alen; a++) { + ptr= &path->ptr[a]; + + if(ptr->data) { + icon= RNA_struct_ui_icon(ptr->type); + nameprop= RNA_struct_name_property(ptr->type); + + if(nameprop) { + name= RNA_property_string_get_alloc(ptr, nameprop, namebuf, sizeof(namebuf)); + + uiItemL(row, name, icon); + + if(name != namebuf) + MEM_freeN(name); + } + else + uiItemL(row, "", icon); + } + } +} + +void buttons_context_register(ARegionType *art) +{ + PanelType *pt; + + pt= MEM_callocN(sizeof(PanelType), "spacetype buttons panel context"); + strcpy(pt->idname, "BUTTONS_PT_context"); + strcpy(pt->label, "Context"); + pt->draw= buttons_panel_context; + BLI_addtail(&art->paneltypes, pt); +} + diff --git a/source/blender/editors/space_buttons/buttons_intern.h b/source/blender/editors/space_buttons/buttons_intern.h index ea1fe7db29e..04c7241c465 100644 --- a/source/blender/editors/space_buttons/buttons_intern.h +++ b/source/blender/editors/space_buttons/buttons_intern.h @@ -52,7 +52,9 @@ struct bContextDataResult; void buttons_header_buttons(const struct bContext *C, struct ARegion *ar); /* buttons_context.c */ +void buttons_context_compute(const struct bContext *C, SpaceButs *sbuts); int buttons_context(const struct bContext *C, const char *member, struct bContextDataResult *result); +void buttons_context_register(struct ARegionType *art); #endif /* ED_BUTTONS_INTERN_H */ diff --git a/source/blender/editors/space_buttons/space_buttons.c b/source/blender/editors/space_buttons/space_buttons.c index 838316fd4af..57ca7cc23d8 100644 --- a/source/blender/editors/space_buttons/space_buttons.c +++ b/source/blender/editors/space_buttons/space_buttons.c @@ -122,9 +122,10 @@ static void buttons_free(SpaceLink *sl) if (sbuts->ri->rect) MEM_freeN(sbuts->ri->rect); MEM_freeN(sbuts->ri); } - -} + if(sbuts->path) + MEM_freeN(sbuts->path); +} /* spacetype; init callback */ static void buttons_init(struct wmWindowManager *wm, ScrArea *sa) @@ -146,6 +147,7 @@ static SpaceLink *buttons_duplicate(SpaceLink *sl) /* clear or remove stuff from old */ sbutsn->ri= NULL; + sbutsn->path= NULL; return (SpaceLink *)sbutsn; } @@ -168,6 +170,8 @@ static void buttons_main_area_draw(const bContext *C, ARegion *ar) SpaceButs *sbuts= (SpaceButs*)CTX_wm_space_data(C); int vertical= (sbuts->align == BUT_VERTICAL); + buttons_context_compute(C, sbuts); + if(sbuts->mainb == BCONTEXT_SCENE) ED_region_panels(C, ar, vertical, "scene"); else if(sbuts->mainb == BCONTEXT_WORLD) @@ -191,7 +195,6 @@ static void buttons_main_area_draw(const bContext *C, ARegion *ar) sbuts->re_align= 0; sbuts->mainbo= sbuts->mainb; - sbuts->tabo= sbuts->tab[sbuts->mainb]; } void buttons_operatortypes(void) @@ -282,6 +285,8 @@ void ED_spacetype_buttons(void) art->listener= buttons_area_listener; art->keymapflag= ED_KEYMAP_UI|ED_KEYMAP_FRAMES; BLI_addhead(&st->regiontypes, art); + + buttons_context_register(art); /* regions: header */ art= MEM_callocN(sizeof(ARegionType), "spacetype buttons region"); diff --git a/source/blender/editors/space_outliner/outliner.c b/source/blender/editors/space_outliner/outliner.c index cde0683318f..16748af39d5 100644 --- a/source/blender/editors/space_outliner/outliner.c +++ b/source/blender/editors/space_outliner/outliner.c @@ -1750,7 +1750,7 @@ static int tree_element_active_texture(Scene *scene, SpaceOops *soops, TreeEleme if(set) { if(sbuts) { - sbuts->tabo= TAB_SHADING_TEX; // hack from header_buttonswin.c + // XXX sbuts->tabo= TAB_SHADING_TEX; // hack from header_buttonswin.c sbuts->texfrom= 1; } // XXX extern_set_butspace(F6KEY, 0); // force shading buttons texture @@ -1764,7 +1764,7 @@ static int tree_element_active_texture(Scene *scene, SpaceOops *soops, TreeEleme Lamp *la= (Lamp *)tselemp->id; if(set) { if(sbuts) { - sbuts->tabo= TAB_SHADING_TEX; // hack from header_buttonswin.c + // XXX sbuts->tabo= TAB_SHADING_TEX; // hack from header_buttonswin.c sbuts->texfrom= 2; } // XXX extern_set_butspace(F6KEY, 0); // force shading buttons texture diff --git a/source/blender/makesdna/DNA_space_types.h b/source/blender/makesdna/DNA_space_types.h index ad07237fdc5..b2c5121c1ed 100644 --- a/source/blender/makesdna/DNA_space_types.h +++ b/source/blender/makesdna/DNA_space_types.h @@ -121,7 +121,7 @@ typedef struct SpaceButs { struct RenderInfo *ri; short cursens, curact; - short align, tabo; /* align for panels, tab is old tab */ + short align, pad; /* align for panels */ View2D v2d; /* depricated, copied to region */ short mainb, menunr; /* texnr and menunr have to remain shorts */ @@ -139,8 +139,8 @@ typedef struct SpaceButs { short oldkeypress; /* for keeping track of the sub tab key cycling */ char flag, texact; - char tab[8]; /* storing tabs for each context */ - + void *path; /* runtime */ + ID *pinid; } SpaceButs; typedef struct SpaceSeq { diff --git a/source/blender/makesrna/intern/rna_texture.c b/source/blender/makesrna/intern/rna_texture.c index 1d8a63bf83a..55336b5e8b4 100644 --- a/source/blender/makesrna/intern/rna_texture.c +++ b/source/blender/makesrna/intern/rna_texture.c @@ -231,6 +231,7 @@ static void rna_def_mtex(BlenderRNA *brna) 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."); + RNA_def_struct_ui_icon(srna, ICON_TEXTURE_DATA); prop= RNA_def_property(srna, "texture", PROP_POINTER, PROP_NONE); RNA_def_property_pointer_sdna(prop, NULL, "tex"); From 1205579af3fcb8826cab309922a253590776b7e0 Mon Sep 17 00:00:00 2001 From: Thomas Dinges Date: Thu, 4 Jun 2009 10:56:39 +0000 Subject: [PATCH 19/35] 2.5 RNA: * Wrapped some more object force properties. * Fixed a bug in the field_type_items. --- .../makesrna/intern/rna_object_force.c | 64 ++++++++++++++++++- 1 file changed, 62 insertions(+), 2 deletions(-) diff --git a/source/blender/makesrna/intern/rna_object_force.c b/source/blender/makesrna/intern/rna_object_force.c index 3c68f8630ef..d20552cbdb0 100644 --- a/source/blender/makesrna/intern/rna_object_force.c +++ b/source/blender/makesrna/intern/rna_object_force.c @@ -129,11 +129,12 @@ static void rna_def_field(BlenderRNA *brna) PropertyRNA *prop; static EnumPropertyItem field_type_items[] = { - {PFIELD_FORCE, "FORCE", "None", ""}, + {0, "NONE", "None", ""}, + {PFIELD_FORCE, "SPHERICAL", "Spherical", ""}, {PFIELD_VORTEX, "VORTEX", "Vortex", ""}, {PFIELD_MAGNET, "MAGNET", "Magnetic", ""}, {PFIELD_WIND, "WIND", "Wind", ""}, - {PFIELD_GUIDE, "GUIDE", "Spherical", ""}, + {PFIELD_GUIDE, "GUIDE", "Curve Guide", ""}, {PFIELD_TEXTURE, "TEXTURE", "Texture", ""}, {PFIELD_HARMONIC, "HARMONIC", "Harmonic", ""}, {PFIELD_CHARGE, "CHARGE", "Charge", ""}, @@ -145,6 +146,12 @@ static void rna_def_field(BlenderRNA *brna) {PFIELD_FALL_TUBE, "TUBE", "Tube", ""}, {PFIELD_FALL_CONE, "CONE", "Cone", ""}, {0, NULL, NULL, NULL}}; + + static EnumPropertyItem texture_items[] = { + {PFIELD_TEX_RGB, "RGB", "RGB", ""}, + {PFIELD_TEX_GRAD, "GRADIENT", "Gradient", ""}, + {PFIELD_TEX_CURL, "CURL", "Curl", ""}, + {0, NULL, NULL, NULL}}; srna= RNA_def_struct(brna, "FieldSettings", NULL); RNA_def_struct_sdna(srna, "PartDeflect"); @@ -162,6 +169,11 @@ static void rna_def_field(BlenderRNA *brna) RNA_def_property_enum_items(prop, falloff_items); RNA_def_property_ui_text(prop, "Fall-Off", "Fall-Off Shape"); + 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, texture_items); + RNA_def_property_ui_text(prop, "Texture Mode", "How the texture effect is calculated (RGB & Curl need a RGB texture else Gradient will be used instead)"); + /* Float */ prop= RNA_def_property(srna, "strength", PROP_FLOAT, PROP_NONE); @@ -203,6 +215,54 @@ static void rna_def_field(BlenderRNA *brna) RNA_def_property_float_sdna(prop, NULL, "f_power_r"); RNA_def_property_range(prop, 0.0f, 10.0f); RNA_def_property_ui_text(prop, "Radial Falloff Power", "Radial falloff power (real gravitational falloff = 2)"); + + /* Boolean */ + + prop= RNA_def_property(srna, "use_min_distance", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", PFIELD_USEMIN); + RNA_def_property_ui_text(prop, "Use Min", "Use a minimum distance for the field's fall-off"); + + prop= RNA_def_property(srna, "use_max_distance", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", PFIELD_USEMAX); + RNA_def_property_ui_text(prop, "Use Max", "Use a maximum distance for the field to work"); + + prop= RNA_def_property(srna, "use_radial_min", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", PFIELD_USEMINR); + RNA_def_property_ui_text(prop, "Use Min", "Use a minimum radial distance for the field's fall-off"); + // "Use a minimum angle for the field's fall-off" + + prop= RNA_def_property(srna, "use_radial_max", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", PFIELD_USEMAXR); + RNA_def_property_ui_text(prop, "Use Max", "Use a maximum radial distance for the field to work"); + // "Use a maximum angle for the field to work" + + prop= RNA_def_property(srna, "guide_path_add", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", PFIELD_GUIDE_PATH_ADD); + RNA_def_property_ui_text(prop, "Additive", "Based on distance/falloff it adds a portion of the entire path"); + + prop= RNA_def_property(srna, "planar", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", PFIELD_PLANAR); + RNA_def_property_ui_text(prop, "Planar", "Create planar field"); + + prop= RNA_def_property(srna, "surface", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", PFIELD_SURFACE); + RNA_def_property_ui_text(prop, "Surface", "Use closest point on surface"); + + prop= RNA_def_property(srna, "positive_z", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", PFIELD_POSZ); + RNA_def_property_ui_text(prop, "Positive", "Effect only in direction of positive Z axis"); + + prop= RNA_def_property(srna, "use_coordinates", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", PFIELD_TEX_OBJECT); + RNA_def_property_ui_text(prop, "Use Coordinates", "Use object/global coordinates for texture"); + + prop= RNA_def_property(srna, "force_2d", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", PFIELD_TEX_2D); + RNA_def_property_ui_text(prop, "2D", "Apply force only in 2d"); + + prop= RNA_def_property(srna, "root_coords", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", PFIELD_TEX_ROOTCO); + RNA_def_property_ui_text(prop, "Root Texture Coordinates", "Texture coordinates from root particle locations"); } static void rna_def_game_softbody(BlenderRNA *brna) From 1d6e679f3ed8da36d93f965528ab2b690b12d4e1 Mon Sep 17 00:00:00 2001 From: Thomas Dinges Date: Thu, 4 Jun 2009 11:05:36 +0000 Subject: [PATCH 20/35] 2.5 RNA: Bugfix: Smooth Modifier didn't accept negative factor values. Patch by Wahooney. Thanks! --- source/blender/makesrna/intern/rna_modifier.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/blender/makesrna/intern/rna_modifier.c b/source/blender/makesrna/intern/rna_modifier.c index 8dd6fa1b75b..82d544ff539 100644 --- a/source/blender/makesrna/intern/rna_modifier.c +++ b/source/blender/makesrna/intern/rna_modifier.c @@ -1144,7 +1144,7 @@ static void rna_def_modifier_smooth(BlenderRNA *brna) prop= RNA_def_property(srna, "factor", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "fac"); - RNA_def_property_range(prop, FLT_MIN, FLT_MAX); + RNA_def_property_range(prop, -FLT_MAX, FLT_MAX); RNA_def_property_ui_range(prop, -10, 10, 0.5, 2); RNA_def_property_ui_text(prop, "Factor", ""); RNA_def_property_update(prop, NC_OBJECT|ND_MODIFIER, "rna_Modifier_update"); From c12163c0c5c7ebdf2c254855ec040e423dc1da73 Mon Sep 17 00:00:00 2001 From: Thomas Dinges Date: Thu, 4 Jun 2009 11:16:56 +0000 Subject: [PATCH 21/35] 2.5 RNA: * Found more bugs in factor properties. --- source/blender/makesrna/intern/rna_modifier.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/source/blender/makesrna/intern/rna_modifier.c b/source/blender/makesrna/intern/rna_modifier.c index 82d544ff539..6673b8d43f7 100644 --- a/source/blender/makesrna/intern/rna_modifier.c +++ b/source/blender/makesrna/intern/rna_modifier.c @@ -1200,7 +1200,7 @@ static void rna_def_modifier_cast(BlenderRNA *brna) prop= RNA_def_property(srna, "factor", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "fac"); - RNA_def_property_range(prop, FLT_MIN, FLT_MAX); + RNA_def_property_range(prop, -FLT_MAX, FLT_MAX); RNA_def_property_ui_range(prop, -10, 10, 5, 2); RNA_def_property_ui_text(prop, "Factor", ""); RNA_def_property_update(prop, NC_OBJECT|ND_MODIFIER, "rna_Modifier_update"); @@ -1648,7 +1648,7 @@ static void rna_def_modifier_simpledeform(BlenderRNA *brna) RNA_def_property_update(prop, NC_OBJECT|ND_MODIFIER, "rna_Modifier_update"); prop= RNA_def_property(srna, "factor", PROP_FLOAT, PROP_NONE); - RNA_def_property_range(prop, FLT_MIN, FLT_MAX); + RNA_def_property_range(prop, -FLT_MAX, FLT_MAX); RNA_def_property_ui_range(prop, -10, 10, 0.5, 2); RNA_def_property_ui_text(prop, "Factor", ""); RNA_def_property_update(prop, NC_OBJECT|ND_MODIFIER, "rna_Modifier_update"); From 0f9841b01af9d01d6d93b81b0714897e84042dfe Mon Sep 17 00:00:00 2001 From: Robin Allen Date: Thu, 4 Jun 2009 13:55:02 +0000 Subject: [PATCH 22/35] All nodes are now wrapped! Some still need limits and extra logic though. --- source/blender/makesrna/intern/rna_nodetree.c | 414 ++++++++++++++++-- .../makesrna/intern/rna_nodetree_types.h | 7 +- 2 files changed, 378 insertions(+), 43 deletions(-) diff --git a/source/blender/makesrna/intern/rna_nodetree.c b/source/blender/makesrna/intern/rna_nodetree.c index d75d3a5ddf6..731d30fd7f4 100644 --- a/source/blender/makesrna/intern/rna_nodetree.c +++ b/source/blender/makesrna/intern/rna_nodetree.c @@ -33,7 +33,9 @@ #include "DNA_node_types.h" #include "DNA_scene_types.h" #include "DNA_texture_types.h" + #include "BKE_node.h" +#include "BKE_image.h" #ifdef RNA_RUNTIME @@ -171,7 +173,7 @@ static void def_math(BlenderRNA *brna, int id) StructRNA *srna; PropertyRNA *prop; - static EnumPropertyItem items[] ={ + static EnumPropertyItem items[] = { { 0, "ADD", "Add", ""}, { 1, "SUBTRACT", "Subtract", ""}, { 2, "MULTIPLY", "Multiply", ""}, @@ -206,7 +208,7 @@ static void def_vector_math(BlenderRNA *brna, int id) StructRNA *srna; PropertyRNA *prop; - static EnumPropertyItem items[] ={ + static EnumPropertyItem items[] = { {0, "ADD", "Add", ""}, {1, "SUBTRACT", "Subtract", ""}, {2, "AVERAGE", "Average", ""}, @@ -275,12 +277,12 @@ static void def_time(BlenderRNA *brna, int id) static void def_val_to_rgb(BlenderRNA *brna, int id) { StructRNA *srna; -// PropertyRNA *prop; + /*PropertyRNA *prop;*/ srna = def_node(brna, id); - /* TODO: uncomment when ColorBand is wrapped */ - /*prop = RNA_def_property(srna, "color_band", PROP_POINTER, PROP_NONE); + /* TODO: uncomment when ColorBand is wrapped *//* + prop = RNA_def_property(srna, "color_band", PROP_POINTER, PROP_NONE); RNA_def_property_pointer_sdna(prop, NULL, "storage"); RNA_def_property_struct_type(prop, "ColorBand"); RNA_def_property_ui_text(prop, "Color Band", "");*/ @@ -291,7 +293,7 @@ static void def_mix_rgb(BlenderRNA *brna, int id) StructRNA *srna; PropertyRNA *prop; - static EnumPropertyItem blend_type_items[] ={ + static EnumPropertyItem blend_type_items[] = { { 0, "MIX", "Mix", ""}, { 1, "ADD", "Add", ""}, { 3, "SUBTRACT", "Subtract", ""}, @@ -414,7 +416,11 @@ static void def_cmp_alpha_over(BlenderRNA *brna, int id) RNA_def_property_boolean_sdna(prop, NULL, "custom1", 1); RNA_def_property_ui_text(prop, "convert_premul", "TODO: don't know what this is"); - /* TODO: uses NodeTwoFloats storage */ + RNA_def_struct_sdna_from(srna, "NodeTwoFloats", "storage"); + + prop = RNA_def_property(srna, "premul", PROP_FLOAT, PROP_NONE); + RNA_def_property_float_sdna(prop, NULL, "x"); + RNA_def_property_ui_text(prop, "Premul", "Mix Factor"); } static void def_cmp_blur(BlenderRNA *brna, int id) @@ -422,7 +428,7 @@ static void def_cmp_blur(BlenderRNA *brna, int id) StructRNA *srna; PropertyRNA *prop; - static EnumPropertyItem filter_type_items[] ={ + static EnumPropertyItem filter_type_items[] = { {R_FILTER_BOX, "FLAT", "Flat", ""}, {R_FILTER_TENT, "TENT", "Tent", ""}, {R_FILTER_QUAD, "QUAD", "Quadratic", ""}, @@ -492,7 +498,7 @@ static void def_cmp_blur(BlenderRNA *brna, int id) image_in_width image_in_height - Don't know if these need wrapping + Don't know if these need wrapping, can't find them in interface */ } @@ -502,7 +508,7 @@ static void def_cmp_filter(BlenderRNA *brna, int id) StructRNA *srna; PropertyRNA *prop; - static EnumPropertyItem type_items[] ={ + static EnumPropertyItem type_items[] = { {0, "SOFTEN", "Soften", ""}, {1, "SHARPEN", "Sharpen", ""}, {2, "LAPLACE", "Laplace", ""}, @@ -588,10 +594,57 @@ static void def_cmp_image(BlenderRNA *brna, int id) StructRNA *srna; PropertyRNA *prop; - srna = def_node(brna, id); - RNA_def_struct_sdna_from(srna, "ImageUser", "storage"); + static EnumPropertyItem type_items[] = { + {IMA_SRC_FILE, "IMAGE", "Image", ""}, + {IMA_SRC_MOVIE, "MOVIE", "Movie", ""}, + {IMA_SRC_SEQUENCE, "SEQUENCE", "Sequence", ""}, + {IMA_SRC_GENERATED, "GENERATED", "Generated", ""}, + {0, NULL, NULL, NULL} + }; - /* TODO. uses storage and id. */ + srna = def_node(brna, id); + + prop = RNA_def_property(srna, "image", PROP_POINTER, PROP_NONE); + RNA_def_property_pointer_sdna(prop, NULL, "id"); + RNA_def_property_struct_type(prop, "Image"); + RNA_def_property_flag(prop, PROP_EDITABLE); + RNA_def_property_ui_text(prop, "Image", ""); + + RNA_def_struct_sdna_from(srna, "ImageUser", "storage"); + + /* TODO: if movie or sequence { */ + + prop = RNA_def_property(srna, "frames", PROP_INT, PROP_NONE); + RNA_def_property_int_sdna(prop, NULL, "frames"); + RNA_def_property_ui_text(prop, "Frames", "Number of images used in animation"); + + prop = RNA_def_property(srna, "start", PROP_INT, PROP_NONE); + RNA_def_property_int_sdna(prop, NULL, "sfra"); + RNA_def_property_ui_text(prop, "Start Frame", ""); + + prop = RNA_def_property(srna, "offset", PROP_INT, PROP_NONE); + RNA_def_property_int_sdna(prop, NULL, "offset"); + RNA_def_property_ui_text(prop, "Offset", "Offsets the number of the frame to use in the animation"); + + prop = RNA_def_property(srna, "cyclic", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "cycl", 1); + RNA_def_property_ui_text(prop, "Cyclic", ""); + + prop = RNA_def_property(srna, "auto_refresh", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", IMA_ANIM_ALWAYS); + RNA_def_property_ui_text(prop, "Auto-Refresh", ""); + + /* } */ + + /* if type == multilayer { */ + + prop = RNA_def_property(srna, "layer", PROP_INT, PROP_NONE); + RNA_def_property_int_sdna(prop, NULL, "layer"); + RNA_def_property_ui_text(prop, "Layer", ""); + + /* } */ + + /* TODO: refresh on change */ } @@ -602,7 +655,21 @@ static void def_cmp_render_layers(BlenderRNA *brna, int id) srna = def_node(brna, id); - /* TODO. users customx and id. */ + prop = RNA_def_property(srna, "scene", PROP_POINTER, PROP_NONE); + RNA_def_property_pointer_sdna(prop, NULL, "id"); + RNA_def_property_struct_type(prop, "Scene"); + RNA_def_property_flag(prop, PROP_EDITABLE); + RNA_def_property_ui_text(prop, "Scene", ""); + + /* TODO: layers in menu */ + prop = RNA_def_property(srna, "layer", PROP_INT, PROP_NONE); + RNA_def_property_int_sdna(prop, NULL, "custom1"); + RNA_def_property_ui_text(prop, "Layer", ""); + + /* TODO: comments indicate this might be a hack */ + prop = RNA_def_property(srna, "re_render", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "custom2", 1); + RNA_def_property_ui_text(prop, "Re-render", ""); } @@ -611,20 +678,68 @@ static void def_cmp_output_file(BlenderRNA *brna, int id) StructRNA *srna; PropertyRNA *prop; - srna = def_node(brna, id); + static EnumPropertyItem type_items[] = { + {R_TARGA, "TARGA", "Targa", ""}, + {R_RAWTGA, "RAW_TARGA", "Targa Raw", ""}, + {R_PNG, "PNG", "PNG", ""}, + {R_BMP, "BMP", "BMP", ""}, + {R_JPEG90, "JPEG", "JPEG", ""}, + {R_IRIS, "IRIS", "IRIS", ""}, + {R_RADHDR, "RADIANCE_HDR", "Radiance HDR", ""}, + {R_CINEON, "CINEON", "Cineon", ""}, + {R_DPX, "DPX", "DPX", ""}, + {R_OPENEXR, "OPENEXR", "OpenEXR", ""}, + {0, NULL, NULL, NULL} + }; - /* TODO. */ - -} - -static void def_cmp_texture(BlenderRNA *brna, int id) -{ - StructRNA *srna; - PropertyRNA *prop; + static EnumPropertyItem openexr_codec_items[] = { + {0, "NONE", "None", ""}, + {1, "PXR24", "Pxr24 (lossy)", ""}, + {2, "ZIP", "ZIP (lossless)", ""}, + {3, "PIZ", "PIX (lossless)", ""}, + {4, "RLE", "RLE (lossless)", ""}, + {0, NULL, NULL, NULL} + }; srna = def_node(brna, id); - /* TODO. */ + RNA_def_struct_sdna_from(srna, "NodeImageFile", "storage"); + + prop = RNA_def_property(srna, "name", PROP_STRING, PROP_NONE); + RNA_def_property_string_sdna(prop, NULL, "name"); + RNA_def_property_ui_text(prop, "Name", ""); + + prop = RNA_def_property(srna, "type", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_sdna(prop, NULL, "imtype"); + RNA_def_property_enum_items(prop, type_items); + RNA_def_property_ui_text(prop, "Type", ""); + + /* TODO: openexr only { */ + + prop = RNA_def_property(srna, "half", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "subimtype", R_OPENEXR_HALF); + RNA_def_property_ui_text(prop, "Half", ""); + + prop = RNA_def_property(srna, "codec", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_sdna(prop, NULL, "codec"); + RNA_def_property_enum_items(prop, openexr_codec_items); + RNA_def_property_ui_text(prop, "Codec", ""); + + /* } else { */ + + prop = RNA_def_property(srna, "quality", PROP_INT, PROP_NONE); + RNA_def_property_int_sdna(prop, NULL, "quality"); + RNA_def_property_ui_text(prop, "Quality", ""); + + /* } */ + + prop = RNA_def_property(srna, "start", PROP_INT, PROP_NONE); + RNA_def_property_int_sdna(prop, NULL, "sfra"); + RNA_def_property_ui_text(prop, "Start Frame", ""); + + prop = RNA_def_property(srna, "end", PROP_INT, PROP_NONE); + RNA_def_property_int_sdna(prop, NULL, "efra"); + RNA_def_property_ui_text(prop, "End Frame", ""); } @@ -645,7 +760,7 @@ static void def_cmp_scale(BlenderRNA *brna, int id) StructRNA *srna; PropertyRNA *prop; - static EnumPropertyItem space_items[] ={ + static EnumPropertyItem space_items[] = { {0, "RELATIVE", "Relative", ""}, {1, "ABSOLUTE", "Absolute", ""}, {2, "SCENE_SIZE", "Scene Size", ""}, @@ -665,7 +780,7 @@ static void def_cmp_diff_matte(BlenderRNA *brna, int id) StructRNA *srna; PropertyRNA *prop; - static EnumPropertyItem color_space_items[] ={ + static EnumPropertyItem color_space_items[] = { {1, "RGB", "RGB", ""}, {2, "HSV", "HSV", ""}, {3, "YUV", "YUV", ""}, @@ -707,7 +822,7 @@ static void def_cmp_color_spill(BlenderRNA *brna, int id) StructRNA *srna; PropertyRNA *prop; - static EnumPropertyItem channel_items[] ={ + static EnumPropertyItem channel_items[] = { {1, "R", "Red", ""}, {2, "G", "Green", ""}, {3, "B", "Blue", ""}, @@ -768,7 +883,7 @@ static void def_cmp_channel_matte(BlenderRNA *brna, int id) StructRNA *srna; PropertyRNA *prop; - static EnumPropertyItem color_space_items[] ={ + static EnumPropertyItem color_space_items[] = { {1, "RGB", "RGB", ""}, {2, "HSV", "HSV", ""}, {3, "YUV", "YUV", ""}, @@ -809,7 +924,7 @@ static void def_cmp_flip(BlenderRNA *brna, int id) StructRNA *srna; PropertyRNA *prop; - static EnumPropertyItem axis_items[] ={ + static EnumPropertyItem axis_items[] = { {0, "X", "X", ""}, {1, "Y", "Y", ""}, {2, "XY", "X & Y", ""}, @@ -829,7 +944,7 @@ static void def_cmp_splitviewer(BlenderRNA *brna, int id) StructRNA *srna; PropertyRNA *prop; - static EnumPropertyItem axis_items[] ={ + static EnumPropertyItem axis_items[] = { {0, "X", "X", ""}, {1, "Y", "Y", ""}, {0, NULL, NULL, NULL} @@ -878,14 +993,14 @@ static void def_cmp_defocus(BlenderRNA *brna, int id) StructRNA *srna; PropertyRNA *prop; - static EnumPropertyItem bokeh_items[] ={ - {8, "Octagon", "OCTAGON", "8 sides"}, - {7, "Heptagon", "HEPTAGON", "7 sides"}, - {6, "Hexagon", "HEXAGON", "6 sides"}, - {5, "Pentagon", "PENTAGON", "5 sides"}, - {4, "Square", "SQUARE", "4 sides"}, - {3, "Triangle", "TRIANGLE", "3 sides"}, - {0, "Circle", "CIRCLE", ""}, + static EnumPropertyItem bokeh_items[] = { + {8, "OCTAGON", "Octagonal", "8 sides"}, + {7, "HEPTAGON", "Heptagonal", "7 sides"}, + {6, "HEXAGON", "Hexagonal", "6 sides"}, + {5, "PENTAGON", "Pentagonal", "5 sides"}, + {4, "SQUARE", "Square", "4 sides"}, + {3, "TRIANGLE", "Triangular", "3 sides"}, + {0, "CIRCLE", "Circular", ""}, {0, NULL, NULL, NULL} }; @@ -945,6 +1060,18 @@ static void def_cmp_luma_matte(BlenderRNA *brna, int id) srna = def_node(brna, id); + RNA_def_struct_sdna_from(srna, "NodeChroma", "storage"); + + prop = RNA_def_property(srna, "high", PROP_FLOAT, PROP_NONE); + RNA_def_property_float_sdna(prop, NULL, "t1"); + RNA_def_property_ui_text(prop, "High", "Values higher than this setting are 100% opaque"); + + prop = RNA_def_property(srna, "low", PROP_FLOAT, PROP_NONE); + RNA_def_property_float_sdna(prop, NULL, "t2"); + RNA_def_property_ui_text(prop, "Low", "Values lower than this setting are 100% keyed"); + + /* TODO: keep low less than high */ + } static void def_cmp_invert(BlenderRNA *brna, int id) @@ -954,6 +1081,13 @@ static void def_cmp_invert(BlenderRNA *brna, int id) srna = def_node(brna, id); + prop = RNA_def_property(srna, "rgb", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "custom1", CMP_CHAN_RGB); + RNA_def_property_ui_text(prop, "RGB", ""); + + prop = RNA_def_property(srna, "alpha", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "custom1", CMP_CHAN_A); + RNA_def_property_ui_text(prop, "Alpha", ""); } static void def_cmp_crop(BlenderRNA *brna, int id) @@ -963,6 +1097,28 @@ static void def_cmp_crop(BlenderRNA *brna, int id) srna = def_node(brna, id); + prop = RNA_def_property(srna, "crop_size", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "custom1", 1); + RNA_def_property_ui_text(prop, "Crop Image Size", "Whether to crop the size of the input image"); + + RNA_def_struct_sdna_from(srna, "NodeTwoXYs", "storage"); + + prop = RNA_def_property(srna, "x1", PROP_INT, PROP_NONE); + RNA_def_property_int_sdna(prop, NULL, "x1"); + RNA_def_property_ui_text(prop, "X1", ""); + + prop = RNA_def_property(srna, "x2", PROP_INT, PROP_NONE); + RNA_def_property_int_sdna(prop, NULL, "x2"); + RNA_def_property_ui_text(prop, "X2", ""); + + prop = RNA_def_property(srna, "y1", PROP_INT, PROP_NONE); + RNA_def_property_int_sdna(prop, NULL, "y1"); + RNA_def_property_ui_text(prop, "Y1", ""); + + prop = RNA_def_property(srna, "y2", PROP_INT, PROP_NONE); + RNA_def_property_int_sdna(prop, NULL, "y2"); + RNA_def_property_ui_text(prop, "Y2", ""); + } static void def_cmp_dblur(BlenderRNA *brna, int id) @@ -972,6 +1128,39 @@ static void def_cmp_dblur(BlenderRNA *brna, int id) srna = def_node(brna, id); + RNA_def_struct_sdna_from(srna, "NodeDBlurData", "storage"); + + prop = RNA_def_property(srna, "iterations", PROP_INT, PROP_NONE); + RNA_def_property_int_sdna(prop, NULL, "iter"); + RNA_def_property_ui_text(prop, "Iterations", ""); + + prop = RNA_def_property(srna, "wrap", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "wrap", 1); + RNA_def_property_ui_text(prop, "Wrap", ""); + + prop = RNA_def_property(srna, "center_x", PROP_FLOAT, PROP_NONE); + RNA_def_property_float_sdna(prop, NULL, "center_x"); + RNA_def_property_ui_text(prop, "Center X", ""); + + prop = RNA_def_property(srna, "center_y", PROP_FLOAT, PROP_NONE); + RNA_def_property_float_sdna(prop, NULL, "center_y"); + RNA_def_property_ui_text(prop, "Center Y", ""); + + prop = RNA_def_property(srna, "distance", PROP_FLOAT, PROP_NONE); + RNA_def_property_float_sdna(prop, NULL, "distance"); + RNA_def_property_ui_text(prop, "Distance", ""); + + prop = RNA_def_property(srna, "angle", PROP_FLOAT, PROP_NONE); + RNA_def_property_float_sdna(prop, NULL, "angle"); + RNA_def_property_ui_text(prop, "Angle", ""); + + prop = RNA_def_property(srna, "spin", PROP_FLOAT, PROP_NONE); + RNA_def_property_float_sdna(prop, NULL, "spin"); + RNA_def_property_ui_text(prop, "Spin", ""); + + prop = RNA_def_property(srna, "zoom", PROP_FLOAT, PROP_NONE); + RNA_def_property_float_sdna(prop, NULL, "zoom"); + RNA_def_property_ui_text(prop, "Zoom", ""); } static void def_cmp_bilateral_blur(BlenderRNA *brna, int id) @@ -981,6 +1170,20 @@ static void def_cmp_bilateral_blur(BlenderRNA *brna, int id) srna = def_node(brna, id); + RNA_def_struct_sdna_from(srna, "NodeBilateralBlurData", "storage"); + + prop = RNA_def_property(srna, "iterations", PROP_INT, PROP_NONE); + RNA_def_property_int_sdna(prop, NULL, "iter"); + RNA_def_property_ui_text(prop, "Iterations", ""); + + prop = RNA_def_property(srna, "sigma_color", PROP_FLOAT, PROP_NONE); + RNA_def_property_float_sdna(prop, NULL, "sigma_color"); + RNA_def_property_ui_text(prop, "Color Sigma", ""); + + prop = RNA_def_property(srna, "sigma_space", PROP_FLOAT, PROP_NONE); + RNA_def_property_float_sdna(prop, NULL, "sigma_space"); + RNA_def_property_ui_text(prop, "Space Sigma", ""); + } static void def_cmp_premul_key(BlenderRNA *brna, int id) @@ -988,8 +1191,19 @@ static void def_cmp_premul_key(BlenderRNA *brna, int id) StructRNA *srna; PropertyRNA *prop; + static EnumPropertyItem type_items[] = { + {0, "KEY_TO_PREMUL", "Key to Premul", ""}, + {1, "PREMUL_TO_KEY", "Premul to Key", ""}, + {0, NULL, NULL, NULL} + }; + srna = def_node(brna, id); + prop = RNA_def_property(srna, "type", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_sdna(prop, NULL, "custom1"); + RNA_def_property_enum_items(prop, type_items); + RNA_def_property_ui_text(prop, "Blend Type", "Conversion between premultiplied alpha and key alpha"); + } static void def_cmp_glare(BlenderRNA *brna, int id) @@ -997,8 +1211,72 @@ static void def_cmp_glare(BlenderRNA *brna, int id) StructRNA *srna; PropertyRNA *prop; + static EnumPropertyItem type_items[] = { + {3, "GHOSTS", "Ghosts", ""}, + {2, "STREAKS", "Streaks", ""}, + {1, "FOG_GLOW", "Fog Glow", ""}, + {0, "SIMPLE_STAR", "Simple Star", ""}, + {0, NULL, NULL, NULL} + }; + + static EnumPropertyItem quality_items[] = { + {0, "HIGH", "High", ""}, + {1, "MEDIUM", "Medium", ""}, + {2, "LOW", "Low", ""}, + {0, NULL, NULL, NULL} + }; + srna = def_node(brna, id); + RNA_def_struct_sdna_from(srna, "NodeGlare", "storage"); + + prop = RNA_def_property(srna, "type", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_sdna(prop, NULL, "type"); + RNA_def_property_enum_items(prop, type_items); + RNA_def_property_ui_text(prop, "Type", ""); + + prop = RNA_def_property(srna, "quality", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_sdna(prop, NULL, "quality"); + RNA_def_property_enum_items(prop, type_items); + RNA_def_property_ui_text(prop, "Quality", "If not set to high quality, the effect will be applied to a low-res copy of the source image"); + + prop = RNA_def_property(srna, "iterations", PROP_INT, PROP_NONE); + RNA_def_property_int_sdna(prop, NULL, "iter"); + RNA_def_property_ui_text(prop, "Iterations", ""); + + prop = RNA_def_property(srna, "color_modulation", PROP_FLOAT, PROP_NONE); + RNA_def_property_float_sdna(prop, NULL, "colmod"); + RNA_def_property_ui_text(prop, "Color Modulation", ""); + + prop = RNA_def_property(srna, "mix", PROP_FLOAT, PROP_NONE); + RNA_def_property_float_sdna(prop, NULL, "mix"); + RNA_def_property_ui_text(prop, "Mix", "-1 is original image only, 0 is exact 50/50 mix, 1 is processed image only"); + + prop = RNA_def_property(srna, "threshold", PROP_FLOAT, PROP_NONE); + RNA_def_property_float_sdna(prop, NULL, "threshold"); + RNA_def_property_ui_text(prop, "Threshold", "The glare filter will only be applied to pixels brighter than this value"); + + prop = RNA_def_property(srna, "streaks", PROP_INT, PROP_NONE); + RNA_def_property_int_sdna(prop, NULL, "angle"); + RNA_def_property_ui_text(prop, "Streaks", "Total number of streaks"); + + prop = RNA_def_property(srna, "angle_offset", PROP_FLOAT, PROP_NONE); + RNA_def_property_float_sdna(prop, NULL, "angle_ofs"); + RNA_def_property_ui_text(prop, "Angle Offset", "Streak angle offset in degrees"); + + prop = RNA_def_property(srna, "fade", PROP_FLOAT, PROP_NONE); + RNA_def_property_float_sdna(prop, NULL, "fade"); + RNA_def_property_ui_text(prop, "Fade", "Streak fade-out factor"); + + prop = RNA_def_property(srna, "rotate_45", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "angle", 1); + RNA_def_property_ui_text(prop, "Rotate 45", "Simple star filter: add 45 degree rotation offset"); + + prop = RNA_def_property(srna, "size", PROP_INT, PROP_NONE); + RNA_def_property_int_sdna(prop, NULL, "size"); + RNA_def_property_ui_text(prop, "Size", "Glow/glare size (not actual size; relative to initial size of bright area of pixels)"); + + /* TODO */ } static void def_cmp_tonemap(BlenderRNA *brna, int id) @@ -1006,8 +1284,52 @@ static void def_cmp_tonemap(BlenderRNA *brna, int id) StructRNA *srna; PropertyRNA *prop; + static EnumPropertyItem type_items[] = { + {1, "RD_PHOTORECEPTOR", "R/D Photoreceptor", ""}, + {0, "RH_SIMPLE", "Rh Simple", ""}, + {0, NULL, NULL, NULL} + }; + srna = def_node(brna, id); + RNA_def_struct_sdna_from(srna, "NodeTonemap", "storage"); + + prop = RNA_def_property(srna, "type", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_sdna(prop, NULL, "type"); + RNA_def_property_enum_items(prop, type_items); + RNA_def_property_ui_text(prop, "Type", ""); + + /* TODO: if type==0 { */ + + prop = RNA_def_property(srna, "key", PROP_FLOAT, PROP_NONE); + RNA_def_property_float_sdna(prop, NULL, "key"); + RNA_def_property_ui_text(prop, "Key", "The value the average luminance is mapped to"); + + prop = RNA_def_property(srna, "offset", PROP_FLOAT, PROP_NONE); + RNA_def_property_float_sdna(prop, NULL, "offset"); + RNA_def_property_ui_text(prop, "Offset", "Normally always 1, but can be used as an extra control to alter the brightness curve"); + + prop = RNA_def_property(srna, "gamma", PROP_FLOAT, PROP_NONE); + RNA_def_property_float_sdna(prop, NULL, "gamma"); + RNA_def_property_ui_text(prop, "Gamma", "If not used, set to 1"); + + /* TODO: } else { */ + + prop = RNA_def_property(srna, "intensity", PROP_FLOAT, PROP_NONE); + RNA_def_property_float_sdna(prop, NULL, "f"); + RNA_def_property_ui_text(prop, "Intensity", "If less than zero, darkens image; otherwise, makes it brighter"); + + prop = RNA_def_property(srna, "contrast", PROP_FLOAT, PROP_NONE); + RNA_def_property_float_sdna(prop, NULL, "m"); + RNA_def_property_ui_text(prop, "Contrast", "Set to 0 to use estimate from input image"); + + prop = RNA_def_property(srna, "adaptation", PROP_FLOAT, PROP_NONE); + RNA_def_property_float_sdna(prop, NULL, "a"); + RNA_def_property_ui_text(prop, "Adaptation", "If 0, global; if 1, based on pixel intensity"); + + prop = RNA_def_property(srna, "correction", PROP_FLOAT, PROP_NONE); + RNA_def_property_float_sdna(prop, NULL, "c"); + RNA_def_property_ui_text(prop, "Color Correction", "If 0, same for all channels; if 1, each independent"); } static void def_cmp_lensdist(BlenderRNA *brna, int id) @@ -1017,6 +1339,22 @@ static void def_cmp_lensdist(BlenderRNA *brna, int id) srna = def_node(brna, id); + RNA_def_struct_sdna_from(srna, "NodeLensDist", "storage"); + + prop = RNA_def_property(srna, "projector", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "proj", 1); + RNA_def_property_ui_text(prop, "Projector", "Enable/disable projector mode. Effect is applied in horizontal direction only."); + + /* TODO: if proj mode is off { */ + + prop = RNA_def_property(srna, "jitter", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "jit", 1); + RNA_def_property_ui_text(prop, "Jitter", "Enable/disable jittering; faster, but also noisier"); + + prop = RNA_def_property(srna, "fit", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "fit", 1); + RNA_def_property_ui_text(prop, "Fit", "For positive distortion factor only: scale image such that black areas are not visible"); + } diff --git a/source/blender/makesrna/intern/rna_nodetree_types.h b/source/blender/makesrna/intern/rna_nodetree_types.h index 6f934a83e54..47a7be163b1 100644 --- a/source/blender/makesrna/intern/rna_nodetree_types.h +++ b/source/blender/makesrna/intern/rna_nodetree_types.h @@ -22,8 +22,6 @@ * ***** END GPL LICENSE BLOCK ***** */ -#define TODO 0 - /* Tree type Node ID RNA def function Enum name Struct name UI Name UI Description */ DefNode( ShaderNode, SH_NODE_OUTPUT, 0, "OUTPUT", Output, "Output", "" ) DefNode( ShaderNode, SH_NODE_MATERIAL, def_sh_material, "MATERIAL", Material, "Material", "" ) @@ -71,7 +69,7 @@ DefNode( CompositorNode, CMP_NODE_IMAGE, def_cmp_image, "IMAGE DefNode( CompositorNode, CMP_NODE_R_LAYERS, def_cmp_render_layers, "R_LAYERS", RLayers, "Render Layers", "" ) DefNode( CompositorNode, CMP_NODE_COMPOSITE, 0, "COMPOSITE", Composite, "Composite", "" ) DefNode( CompositorNode, CMP_NODE_OUTPUT_FILE, def_cmp_output_file, "OUTPUT_FILE", OutputFile, "Output File", "" ) -DefNode( CompositorNode, CMP_NODE_TEXTURE, def_cmp_texture, "TEXTURE", Texture, "Texture", "" ) +DefNode( CompositorNode, CMP_NODE_TEXTURE, def_texture, "TEXTURE", Texture, "Texture", "" ) DefNode( CompositorNode, CMP_NODE_TRANSLATE, 0, "TRANSLATE", Translate, "Translate", "" ) DefNode( CompositorNode, CMP_NODE_ZCOMBINE, 0, "ZCOMBINE", Zcombine, "Z Combine", "" ) DefNode( CompositorNode, CMP_NODE_COMBRGBA, 0, "COMBRGBA", CombRGBA, "Combine RGBA", "" ) @@ -129,5 +127,4 @@ DefNode( TextureNode, TEX_NODE_COMPOSE, 0, "COMPO DefNode( TextureNode, TEX_NODE_DECOMPOSE, 0, "DECOMPOSE", Decompose, "Decompose", "" ) DefNode( TextureNode, TEX_NODE_VALTONOR, 0, "VALTONOR", ValToNor, "Val to Nor", "" ) DefNode( TextureNode, TEX_NODE_SCALE, 0, "SCALE", Scale, "Scale", "" ) - -#undef TODO + From d2ea71a296a741b90c895bdfcadebf089f328bad Mon Sep 17 00:00:00 2001 From: Robin Allen Date: Thu, 4 Jun 2009 14:11:39 +0000 Subject: [PATCH 23/35] Cleaned up the node wrapping code --- source/blender/makesrna/intern/rna_nodetree.c | 225 ++++-------------- 1 file changed, 48 insertions(+), 177 deletions(-) diff --git a/source/blender/makesrna/intern/rna_nodetree.c b/source/blender/makesrna/intern/rna_nodetree.c index 731d30fd7f4..96249b062f6 100644 --- a/source/blender/makesrna/intern/rna_nodetree.c +++ b/source/blender/makesrna/intern/rna_nodetree.c @@ -168,9 +168,8 @@ static EnumPropertyItem* alloc_node_type_items(int category) /* -- Common nodes ---------------------------------------------------------- */ -static void def_math(BlenderRNA *brna, int id) +static void def_math(StructRNA *srna) { - StructRNA *srna; PropertyRNA *prop; static EnumPropertyItem items[] = { @@ -195,17 +194,14 @@ static void def_math(BlenderRNA *brna, int id) {0, NULL, NULL, NULL} }; - srna = def_node(brna, id); - prop = RNA_def_property(srna, "operation", PROP_ENUM, PROP_NONE); RNA_def_property_enum_sdna(prop, NULL, "custom1"); RNA_def_property_enum_items(prop, items); RNA_def_property_ui_text(prop, "Operation", ""); } -static void def_vector_math(BlenderRNA *brna, int id) +static void def_vector_math(StructRNA *srna) { - StructRNA *srna; PropertyRNA *prop; static EnumPropertyItem items[] = { @@ -219,47 +215,36 @@ static void def_vector_math(BlenderRNA *brna, int id) {0, NULL, NULL, NULL} }; - srna = def_node(brna, id); - prop = RNA_def_property(srna, "operation", PROP_ENUM, PROP_NONE); RNA_def_property_enum_sdna(prop, NULL, "custom1"); RNA_def_property_enum_items(prop, items); RNA_def_property_ui_text(prop, "Operation", ""); } -static void def_rgb_curve(BlenderRNA *brna, int id) +static void def_rgb_curve(StructRNA *srna) { - StructRNA *srna; PropertyRNA *prop; - srna = def_node(brna, id); - prop = RNA_def_property(srna, "mapping", PROP_POINTER, PROP_NONE); RNA_def_property_pointer_sdna(prop, NULL, "storage"); RNA_def_property_struct_type(prop, "CurveMapping"); RNA_def_property_ui_text(prop, "Mapping", ""); } -static void def_vector_curve(BlenderRNA *brna, int id) +static void def_vector_curve(StructRNA *srna) { - StructRNA *srna; PropertyRNA *prop; - srna = def_node(brna, id); - prop = RNA_def_property(srna, "mapping", PROP_POINTER, PROP_NONE); RNA_def_property_pointer_sdna(prop, NULL, "storage"); RNA_def_property_struct_type(prop, "CurveMapping"); RNA_def_property_ui_text(prop, "Mapping", ""); } -static void def_time(BlenderRNA *brna, int id) +static void def_time(StructRNA *srna) { - StructRNA *srna; PropertyRNA *prop; - srna = def_node(brna, id); - prop = RNA_def_property(srna, "curve", PROP_POINTER, PROP_NONE); RNA_def_property_pointer_sdna(prop, NULL, "storage"); RNA_def_property_struct_type(prop, "CurveMapping"); @@ -274,13 +259,10 @@ static void def_time(BlenderRNA *brna, int id) RNA_def_property_ui_text(prop, "End Frame", ""); } -static void def_val_to_rgb(BlenderRNA *brna, int id) +static void def_val_to_rgb(StructRNA *srna) { - StructRNA *srna; /*PropertyRNA *prop;*/ - srna = def_node(brna, id); - /* TODO: uncomment when ColorBand is wrapped *//* prop = RNA_def_property(srna, "color_band", PROP_POINTER, PROP_NONE); RNA_def_property_pointer_sdna(prop, NULL, "storage"); @@ -288,9 +270,8 @@ static void def_val_to_rgb(BlenderRNA *brna, int id) RNA_def_property_ui_text(prop, "Color Band", "");*/ } -static void def_mix_rgb(BlenderRNA *brna, int id) +static void def_mix_rgb(StructRNA *srna) { - StructRNA *srna; PropertyRNA *prop; static EnumPropertyItem blend_type_items[] = { @@ -313,8 +294,6 @@ static void def_mix_rgb(BlenderRNA *brna, int id) {0, NULL, NULL, NULL} }; - srna = def_node(brna, id); - prop = RNA_def_property(srna, "blend_type", PROP_ENUM, PROP_NONE); RNA_def_property_enum_sdna(prop, NULL, "custom1"); RNA_def_property_enum_items(prop, blend_type_items); @@ -325,13 +304,10 @@ static void def_mix_rgb(BlenderRNA *brna, int id) RNA_def_property_ui_text(prop, "Diffuse", "Include alpha of second input in this operation"); } -static void def_texture(BlenderRNA *brna, int id) +static void def_texture(StructRNA *srna) { - StructRNA *srna; PropertyRNA *prop; - srna = def_node(brna, id); - prop = RNA_def_property(srna, "texture", PROP_POINTER, PROP_NONE); RNA_def_property_pointer_sdna(prop, NULL, "id"); RNA_def_property_struct_type(prop, "Texture"); @@ -346,13 +322,10 @@ static void def_texture(BlenderRNA *brna, int id) /* -- Shader Nodes ---------------------------------------------------------- */ -static void def_sh_material(BlenderRNA *brna, int id) +static void def_sh_material(StructRNA *srna) { - StructRNA *srna; PropertyRNA *prop; - srna = def_node(brna, id); - prop = RNA_def_property(srna, "material", PROP_POINTER, PROP_NONE); RNA_def_property_pointer_sdna(prop, NULL, "id"); RNA_def_property_struct_type(prop, "Material"); @@ -372,25 +345,20 @@ static void def_sh_material(BlenderRNA *brna, int id) RNA_def_property_ui_text(prop, "Invert Normal", "Material Node uses inverted normal"); } -static void def_sh_mapping(BlenderRNA *brna, int id) +static void def_sh_mapping(StructRNA *srna) { - StructRNA *srna; PropertyRNA *prop; - srna = def_node(brna, id); - prop = RNA_def_property(srna, "mapping", PROP_POINTER, PROP_NONE); RNA_def_property_pointer_sdna(prop, NULL, "storage"); RNA_def_property_struct_type(prop, "TexMapping"); RNA_def_property_ui_text(prop, "Mapping", ""); } -static void def_sh_geometry(BlenderRNA *brna, int id) +static void def_sh_geometry(StructRNA *srna) { - StructRNA *srna; PropertyRNA *prop; - srna = def_node(brna, id); RNA_def_struct_sdna_from(srna, "NodeGeometry", "storage"); prop = RNA_def_property(srna, "uv_layer", PROP_STRING, PROP_NONE); @@ -405,13 +373,10 @@ static void def_sh_geometry(BlenderRNA *brna, int id) /* -- Compositor Nodes ------------------------------------------------------ */ -static void def_cmp_alpha_over(BlenderRNA *brna, int id) +static void def_cmp_alpha_over(StructRNA *srna) { - StructRNA *srna; PropertyRNA *prop; - srna = def_node(brna, id); - prop = RNA_def_property(srna, "convert_premul", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "custom1", 1); RNA_def_property_ui_text(prop, "convert_premul", "TODO: don't know what this is"); @@ -423,9 +388,8 @@ static void def_cmp_alpha_over(BlenderRNA *brna, int id) RNA_def_property_ui_text(prop, "Premul", "Mix Factor"); } -static void def_cmp_blur(BlenderRNA *brna, int id) +static void def_cmp_blur(StructRNA *srna) { - StructRNA *srna; PropertyRNA *prop; static EnumPropertyItem filter_type_items[] = { @@ -440,7 +404,6 @@ static void def_cmp_blur(BlenderRNA *brna, int id) {0, NULL, NULL, NULL} }; - srna = def_node(brna, id); RNA_def_struct_sdna_from(srna, "NodeBlurData", "storage"); prop = RNA_def_property(srna, "sizex", PROP_INT, PROP_NONE); @@ -503,9 +466,8 @@ static void def_cmp_blur(BlenderRNA *brna, int id) } -static void def_cmp_filter(BlenderRNA *brna, int id) +static void def_cmp_filter(StructRNA *srna) { - StructRNA *srna; PropertyRNA *prop; static EnumPropertyItem type_items[] = { @@ -519,20 +481,16 @@ static void def_cmp_filter(BlenderRNA *brna, int id) {0, NULL, NULL, NULL} }; - srna = def_node(brna, id); - prop = RNA_def_property(srna, "type", PROP_ENUM, PROP_NONE); RNA_def_property_enum_sdna(prop, NULL, "custom1"); RNA_def_property_enum_items(prop, type_items); RNA_def_property_ui_text(prop, "Type", ""); } -static void def_cmp_map_value(BlenderRNA *brna, int id) +static void def_cmp_map_value(StructRNA *srna) { - StructRNA *srna; PropertyRNA *prop; - srna = def_node(brna, id); RNA_def_struct_sdna_from(srna, "TexMapping", "storage"); prop = RNA_def_property(srna, "offset", PROP_FLOAT, PROP_NONE); @@ -560,12 +518,10 @@ static void def_cmp_map_value(BlenderRNA *brna, int id) RNA_def_property_ui_text(prop, "Maximum", ""); } -static void def_cmp_vector_blur(BlenderRNA *brna, int id) +static void def_cmp_vector_blur(StructRNA *srna) { - StructRNA *srna; PropertyRNA *prop; - srna = def_node(brna, id); RNA_def_struct_sdna_from(srna, "NodeBlurData", "storage"); prop = RNA_def_property(srna, "samples", PROP_INT, PROP_NONE); @@ -589,9 +545,8 @@ static void def_cmp_vector_blur(BlenderRNA *brna, int id) RNA_def_property_ui_text(prop, "Curved", "Interpolate between frames in a bezier curve, rather than linearly"); } -static void def_cmp_image(BlenderRNA *brna, int id) +static void def_cmp_image(StructRNA *srna) { - StructRNA *srna; PropertyRNA *prop; static EnumPropertyItem type_items[] = { @@ -602,8 +557,6 @@ static void def_cmp_image(BlenderRNA *brna, int id) {0, NULL, NULL, NULL} }; - srna = def_node(brna, id); - prop = RNA_def_property(srna, "image", PROP_POINTER, PROP_NONE); RNA_def_property_pointer_sdna(prop, NULL, "id"); RNA_def_property_struct_type(prop, "Image"); @@ -648,13 +601,10 @@ static void def_cmp_image(BlenderRNA *brna, int id) } -static void def_cmp_render_layers(BlenderRNA *brna, int id) +static void def_cmp_render_layers(StructRNA *srna) { - StructRNA *srna; PropertyRNA *prop; - srna = def_node(brna, id); - prop = RNA_def_property(srna, "scene", PROP_POINTER, PROP_NONE); RNA_def_property_pointer_sdna(prop, NULL, "id"); RNA_def_property_struct_type(prop, "Scene"); @@ -670,12 +620,10 @@ static void def_cmp_render_layers(BlenderRNA *brna, int id) prop = RNA_def_property(srna, "re_render", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "custom2", 1); RNA_def_property_ui_text(prop, "Re-render", ""); - } -static void def_cmp_output_file(BlenderRNA *brna, int id) +static void def_cmp_output_file(StructRNA *srna) { - StructRNA *srna; PropertyRNA *prop; static EnumPropertyItem type_items[] = { @@ -701,8 +649,6 @@ static void def_cmp_output_file(BlenderRNA *brna, int id) {0, NULL, NULL, NULL} }; - srna = def_node(brna, id); - RNA_def_struct_sdna_from(srna, "NodeImageFile", "storage"); prop = RNA_def_property(srna, "name", PROP_STRING, PROP_NONE); @@ -740,24 +686,19 @@ static void def_cmp_output_file(BlenderRNA *brna, int id) prop = RNA_def_property(srna, "end", PROP_INT, PROP_NONE); RNA_def_property_int_sdna(prop, NULL, "efra"); RNA_def_property_ui_text(prop, "End Frame", ""); - } -static void def_cmp_dilate_erode(BlenderRNA *brna, int id) +static void def_cmp_dilate_erode(StructRNA *srna) { - StructRNA *srna; PropertyRNA *prop; - srna = def_node(brna, id); - prop = RNA_def_property(srna, "distance", PROP_INT, PROP_NONE); RNA_def_property_int_sdna(prop, NULL, "custom2"); RNA_def_property_ui_text(prop, "Distance", "Distance to grow/shrink (number of iterations)"); } -static void def_cmp_scale(BlenderRNA *brna, int id) +static void def_cmp_scale(StructRNA *srna) { - StructRNA *srna; PropertyRNA *prop; static EnumPropertyItem space_items[] = { @@ -767,17 +708,14 @@ static void def_cmp_scale(BlenderRNA *brna, int id) {0, NULL, NULL, NULL} }; - srna = def_node(brna, id); - prop = RNA_def_property(srna, "space", PROP_ENUM, PROP_NONE); RNA_def_property_enum_sdna(prop, NULL, "custom1"); RNA_def_property_enum_items(prop, space_items); RNA_def_property_ui_text(prop, "Space", "Coordinate space to scale relative to"); } -static void def_cmp_diff_matte(BlenderRNA *brna, int id) +static void def_cmp_diff_matte(StructRNA *srna) { - StructRNA *srna; PropertyRNA *prop; static EnumPropertyItem color_space_items[] = { @@ -788,8 +726,6 @@ static void def_cmp_diff_matte(BlenderRNA *brna, int id) {0, NULL, NULL, NULL} }; - srna = def_node(brna, id); - prop = RNA_def_property(srna, "color_space", PROP_ENUM, PROP_NONE); RNA_def_property_enum_sdna(prop, NULL, "custom1"); RNA_def_property_enum_items(prop, color_space_items); @@ -811,15 +747,13 @@ static void def_cmp_diff_matte(BlenderRNA *brna, int id) RNA_def_property_float_sdna(prop, NULL, "t3"); RNA_def_property_ui_text(prop, "Channel 3 Tolerance", ""); - prop = RNA_def_property(srna, "falloff", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "fstrength"); RNA_def_property_ui_text(prop, "Falloff", ""); } -static void def_cmp_color_spill(BlenderRNA *brna, int id) +static void def_cmp_color_spill(StructRNA *srna) { - StructRNA *srna; PropertyRNA *prop; static EnumPropertyItem channel_items[] = { @@ -829,8 +763,6 @@ static void def_cmp_color_spill(BlenderRNA *brna, int id) {0, NULL, NULL, NULL} }; - srna = def_node(brna, id); - prop = RNA_def_property(srna, "channel", PROP_ENUM, PROP_NONE); RNA_def_property_enum_sdna(prop, NULL, "custom1"); RNA_def_property_enum_items(prop, channel_items); @@ -843,13 +775,10 @@ static void def_cmp_color_spill(BlenderRNA *brna, int id) RNA_def_property_ui_text(prop, "Amount", "How much the selected channel is affected by"); } -static void def_cmp_chroma(BlenderRNA *brna, int id) +static void def_cmp_chroma(StructRNA *srna) { - StructRNA *srna; PropertyRNA *prop; - srna = def_node(brna, id); - RNA_def_struct_sdna_from(srna, "NodeChroma", "storage"); prop = RNA_def_property(srna, "acceptance", PROP_FLOAT, PROP_NONE); @@ -878,9 +807,8 @@ static void def_cmp_chroma(BlenderRNA *brna, int id) */ } -static void def_cmp_channel_matte(BlenderRNA *brna, int id) +static void def_cmp_channel_matte(StructRNA *srna) { - StructRNA *srna; PropertyRNA *prop; static EnumPropertyItem color_space_items[] = { @@ -891,8 +819,6 @@ static void def_cmp_channel_matte(BlenderRNA *brna, int id) {0, NULL, NULL, NULL} }; - srna = def_node(brna, id); - prop = RNA_def_property(srna, "color_space", PROP_ENUM, PROP_NONE); RNA_def_property_enum_sdna(prop, NULL, "custom1"); RNA_def_property_enum_items(prop, color_space_items); @@ -919,9 +845,8 @@ static void def_cmp_channel_matte(BlenderRNA *brna, int id) */ } -static void def_cmp_flip(BlenderRNA *brna, int id) +static void def_cmp_flip(StructRNA *srna) { - StructRNA *srna; PropertyRNA *prop; static EnumPropertyItem axis_items[] = { @@ -931,17 +856,14 @@ static void def_cmp_flip(BlenderRNA *brna, int id) {0, NULL, NULL, NULL} }; - srna = def_node(brna, id); - prop = RNA_def_property(srna, "axis", PROP_ENUM, PROP_NONE); RNA_def_property_enum_sdna(prop, NULL, "custom1"); RNA_def_property_enum_items(prop, axis_items); RNA_def_property_ui_text(prop, "Axis", ""); } -static void def_cmp_splitviewer(BlenderRNA *brna, int id) +static void def_cmp_splitviewer(StructRNA *srna) { - StructRNA *srna; PropertyRNA *prop; static EnumPropertyItem axis_items[] = { @@ -950,8 +872,6 @@ static void def_cmp_splitviewer(BlenderRNA *brna, int id) {0, NULL, NULL, NULL} }; - srna = def_node(brna, id); - prop = RNA_def_property(srna, "axis", PROP_ENUM, PROP_NONE); RNA_def_property_enum_sdna(prop, NULL, "custom2"); RNA_def_property_enum_items(prop, axis_items); @@ -963,34 +883,27 @@ static void def_cmp_splitviewer(BlenderRNA *brna, int id) RNA_def_property_ui_text(prop, "Factor", ""); } -static void def_cmp_id_mask(BlenderRNA *brna, int id) +static void def_cmp_id_mask(StructRNA *srna) { - StructRNA *srna; PropertyRNA *prop; - srna = def_node(brna, id); - prop = RNA_def_property(srna, "index", PROP_INT, PROP_NONE); RNA_def_property_int_sdna(prop, NULL, "custom1"); RNA_def_property_ui_text(prop, "Index", "Pass index number to convert to alpha"); } -static void def_cmp_map_uv(BlenderRNA *brna, int id) +static void def_cmp_map_uv(StructRNA *srna) { - StructRNA *srna; PropertyRNA *prop; - srna = def_node(brna, id); - /* TODO: percentage */ prop = RNA_def_property(srna, "alpha", PROP_INT, PROP_NONE); RNA_def_property_int_sdna(prop, NULL, "custom1"); RNA_def_property_ui_text(prop, "Alpha", ""); } -static void def_cmp_defocus(BlenderRNA *brna, int id) +static void def_cmp_defocus(StructRNA *srna) { - StructRNA *srna; PropertyRNA *prop; static EnumPropertyItem bokeh_items[] = { @@ -1004,8 +917,6 @@ static void def_cmp_defocus(BlenderRNA *brna, int id) {0, NULL, NULL, NULL} }; - srna = def_node(brna, id); - RNA_def_struct_sdna_from(srna, "NodeDefocus", "storage"); prop = RNA_def_property(srna, "bokeh", PROP_ENUM, PROP_NONE); @@ -1050,16 +961,12 @@ static void def_cmp_defocus(BlenderRNA *brna, int id) prop = RNA_def_property(srna, "z_scale", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "scale"); RNA_def_property_ui_text(prop, "Z-Scale", "Scales the Z input when not using a zbuffer, controls maximum blur designated by the color white or input value 1"); - } -static void def_cmp_luma_matte(BlenderRNA *brna, int id) +static void def_cmp_luma_matte(StructRNA *srna) { - StructRNA *srna; PropertyRNA *prop; - srna = def_node(brna, id); - RNA_def_struct_sdna_from(srna, "NodeChroma", "storage"); prop = RNA_def_property(srna, "high", PROP_FLOAT, PROP_NONE); @@ -1074,13 +981,10 @@ static void def_cmp_luma_matte(BlenderRNA *brna, int id) } -static void def_cmp_invert(BlenderRNA *brna, int id) +static void def_cmp_invert(StructRNA *srna) { - StructRNA *srna; PropertyRNA *prop; - srna = def_node(brna, id); - prop = RNA_def_property(srna, "rgb", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "custom1", CMP_CHAN_RGB); RNA_def_property_ui_text(prop, "RGB", ""); @@ -1090,13 +994,10 @@ static void def_cmp_invert(BlenderRNA *brna, int id) RNA_def_property_ui_text(prop, "Alpha", ""); } -static void def_cmp_crop(BlenderRNA *brna, int id) +static void def_cmp_crop(StructRNA *srna) { - StructRNA *srna; PropertyRNA *prop; - srna = def_node(brna, id); - prop = RNA_def_property(srna, "crop_size", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "custom1", 1); RNA_def_property_ui_text(prop, "Crop Image Size", "Whether to crop the size of the input image"); @@ -1118,16 +1019,12 @@ static void def_cmp_crop(BlenderRNA *brna, int id) prop = RNA_def_property(srna, "y2", PROP_INT, PROP_NONE); RNA_def_property_int_sdna(prop, NULL, "y2"); RNA_def_property_ui_text(prop, "Y2", ""); - } -static void def_cmp_dblur(BlenderRNA *brna, int id) +static void def_cmp_dblur(StructRNA *srna) { - StructRNA *srna; PropertyRNA *prop; - srna = def_node(brna, id); - RNA_def_struct_sdna_from(srna, "NodeDBlurData", "storage"); prop = RNA_def_property(srna, "iterations", PROP_INT, PROP_NONE); @@ -1163,13 +1060,10 @@ static void def_cmp_dblur(BlenderRNA *brna, int id) RNA_def_property_ui_text(prop, "Zoom", ""); } -static void def_cmp_bilateral_blur(BlenderRNA *brna, int id) +static void def_cmp_bilateral_blur(StructRNA *srna) { - StructRNA *srna; PropertyRNA *prop; - srna = def_node(brna, id); - RNA_def_struct_sdna_from(srna, "NodeBilateralBlurData", "storage"); prop = RNA_def_property(srna, "iterations", PROP_INT, PROP_NONE); @@ -1186,9 +1080,8 @@ static void def_cmp_bilateral_blur(BlenderRNA *brna, int id) } -static void def_cmp_premul_key(BlenderRNA *brna, int id) +static void def_cmp_premul_key(StructRNA *srna) { - StructRNA *srna; PropertyRNA *prop; static EnumPropertyItem type_items[] = { @@ -1197,8 +1090,6 @@ static void def_cmp_premul_key(BlenderRNA *brna, int id) {0, NULL, NULL, NULL} }; - srna = def_node(brna, id); - prop = RNA_def_property(srna, "type", PROP_ENUM, PROP_NONE); RNA_def_property_enum_sdna(prop, NULL, "custom1"); RNA_def_property_enum_items(prop, type_items); @@ -1206,9 +1097,8 @@ static void def_cmp_premul_key(BlenderRNA *brna, int id) } -static void def_cmp_glare(BlenderRNA *brna, int id) +static void def_cmp_glare(StructRNA *srna) { - StructRNA *srna; PropertyRNA *prop; static EnumPropertyItem type_items[] = { @@ -1226,8 +1116,6 @@ static void def_cmp_glare(BlenderRNA *brna, int id) {0, NULL, NULL, NULL} }; - srna = def_node(brna, id); - RNA_def_struct_sdna_from(srna, "NodeGlare", "storage"); prop = RNA_def_property(srna, "type", PROP_ENUM, PROP_NONE); @@ -1279,9 +1167,8 @@ static void def_cmp_glare(BlenderRNA *brna, int id) /* TODO */ } -static void def_cmp_tonemap(BlenderRNA *brna, int id) +static void def_cmp_tonemap(StructRNA *srna) { - StructRNA *srna; PropertyRNA *prop; static EnumPropertyItem type_items[] = { @@ -1290,8 +1177,6 @@ static void def_cmp_tonemap(BlenderRNA *brna, int id) {0, NULL, NULL, NULL} }; - srna = def_node(brna, id); - RNA_def_struct_sdna_from(srna, "NodeTonemap", "storage"); prop = RNA_def_property(srna, "type", PROP_ENUM, PROP_NONE); @@ -1332,13 +1217,10 @@ static void def_cmp_tonemap(BlenderRNA *brna, int id) RNA_def_property_ui_text(prop, "Color Correction", "If 0, same for all channels; if 1, each independent"); } -static void def_cmp_lensdist(BlenderRNA *brna, int id) +static void def_cmp_lensdist(StructRNA *srna) { - StructRNA *srna; PropertyRNA *prop; - srna = def_node(brna, id); - RNA_def_struct_sdna_from(srna, "NodeLensDist", "storage"); prop = RNA_def_property(srna, "projector", PROP_BOOLEAN, PROP_NONE); @@ -1354,19 +1236,16 @@ static void def_cmp_lensdist(BlenderRNA *brna, int id) prop = RNA_def_property(srna, "fit", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "fit", 1); RNA_def_property_ui_text(prop, "Fit", "For positive distortion factor only: scale image such that black areas are not visible"); - } /* -- Texture Nodes --------------------------------------------------------- */ -static void def_tex_output(BlenderRNA *brna, int id) +static void def_tex_output(StructRNA *srna) { - StructRNA *srna; PropertyRNA *prop; - srna = def_node(brna, id); RNA_def_struct_sdna_from(srna, "TexNodeOutput", "storage"); prop = RNA_def_property(srna, "name", PROP_STRING, PROP_NONE); @@ -1374,26 +1253,20 @@ static void def_tex_output(BlenderRNA *brna, int id) RNA_def_property_ui_text(prop, "Name", ""); } -static void def_tex_image(BlenderRNA *brna, int id) +static void def_tex_image(StructRNA *srna) { - StructRNA *srna; PropertyRNA *prop; - srna = def_node(brna, id); - prop = RNA_def_property(srna, "settings", PROP_POINTER, PROP_NONE); RNA_def_property_pointer_sdna(prop, NULL, "storage"); RNA_def_property_struct_type(prop, "ImageUser"); RNA_def_property_ui_text(prop, "Settings", ""); } -static void def_tex_bricks(BlenderRNA *brna, int id) +static void def_tex_bricks(StructRNA *srna) { - StructRNA *srna; PropertyRNA *prop; - srna = def_node(brna, id); - prop = RNA_def_property(srna, "offset", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "custom3"); RNA_def_property_ui_text(prop, "Offset Amount", ""); @@ -1506,14 +1379,12 @@ static void rna_def_nodetree(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Nodes", ""); } -static void define_simple_node(BlenderRNA *brna, int id) +static void define_specific_node(BlenderRNA *brna, int id, void (*func)(StructRNA*)) { - def_node(brna, id); -} - -static void define_specific_node(BlenderRNA *brna, int id, void (*func)(BlenderRNA*, int)) -{ - func(brna, id); + StructRNA *srna = def_node(brna, id); + + if(func) + func(srna); } void RNA_def_nodetree(BlenderRNA *brna) @@ -1526,7 +1397,7 @@ void RNA_def_nodetree(BlenderRNA *brna) rna_def_texture_node(brna); #define DefNode(Category, ID, DefFunc, EnumName, StructName, UIName, UIDesc) \ - define_specific_node(brna, ID, DefFunc != 0 ? DefFunc : define_simple_node); + define_specific_node(brna, ID, DefFunc); #include "rna_nodetree_types.h" From 59333375b31fe4ba055f875c1d42be10e1611249 Mon Sep 17 00:00:00 2001 From: Ton Roosendaal Date: Thu, 4 Jun 2009 14:32:10 +0000 Subject: [PATCH 24/35] 2.5 Two small fixes; - Search menu options text could overlap with hotkey - Operator "duplicate area into window" didnt work for non-actionzone --- .../editors/interface/interface_widgets.c | 2 +- source/blender/editors/screen/screen_ops.c | 22 +++++++++++++------ 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/source/blender/editors/interface/interface_widgets.c b/source/blender/editors/interface/interface_widgets.c index 47c4a729956..628efa220ed 100644 --- a/source/blender/editors/interface/interface_widgets.c +++ b/source/blender/editors/interface/interface_widgets.c @@ -1951,7 +1951,7 @@ void ui_draw_menu_item(uiFontStyle *fstyle, rcti *rect, char *name, int state) cpoin= strchr(name, '|'); if(cpoin) { *cpoin= 0; - rect->xmax -= BLF_width(cpoin+1) -10; + rect->xmax -= BLF_width(cpoin+1) + 10; } glColor3ubv(wt->wcol.text); diff --git a/source/blender/editors/screen/screen_ops.c b/source/blender/editors/screen/screen_ops.c index e8314deeae9..a61db5d5e1a 100644 --- a/source/blender/editors/screen/screen_ops.c +++ b/source/blender/editors/screen/screen_ops.c @@ -608,18 +608,25 @@ static int area_dupli_invoke(bContext *C, wmOperator *op, wmEvent *event) bScreen *newsc, *sc; ScrArea *sa; rcti rect; - sActionzoneData *sad= event->customdata; - - if(sad==NULL) - return OPERATOR_PASS_THROUGH; win= CTX_wm_window(C); sc= CTX_wm_screen(C); - sa= sad->sa1; + sa= CTX_wm_area(C); + + /* XXX hrmf! */ + if(event->type==EVT_ACTIONZONE_AREA) { + sActionzoneData *sad= event->customdata; + if(sad==NULL) + return OPERATOR_PASS_THROUGH; + + sa= sad->sa1; + } + /* poll() checks area context, but we don't accept full-area windows */ if(sc->full != SCREENNORMAL) { - actionzone_exit(C, op); + if(event->type==EVT_ACTIONZONE_AREA) + actionzone_exit(C, op); return OPERATOR_CANCELLED; } @@ -638,7 +645,8 @@ static int area_dupli_invoke(bContext *C, wmOperator *op, wmEvent *event) /* screen, areas init */ WM_event_add_notifier(C, NC_SCREEN|NA_EDITED, NULL); - actionzone_exit(C, op); + if(event->type==EVT_ACTIONZONE_AREA) + actionzone_exit(C, op); return OPERATOR_FINISHED; } From 33b0ba4a76b4f772aad6e0cdecb75806a1f092d7 Mon Sep 17 00:00:00 2001 From: Ton Roosendaal Date: Thu, 4 Jun 2009 15:19:48 +0000 Subject: [PATCH 25/35] 2.5 Bugfix: Icons were drawing on wrong subpixel positions, distorting badly. Now it's crispy and tasty! Noticed there's a magnifier icon already, using it for the search option. --- .../editors/interface/interface_widgets.c | 23 ++++++++++--------- .../blender/editors/space_info/info_header.c | 2 +- .../windowmanager/intern/wm_operators.c | 2 +- 3 files changed, 14 insertions(+), 13 deletions(-) diff --git a/source/blender/editors/interface/interface_widgets.c b/source/blender/editors/interface/interface_widgets.c index 628efa220ed..c0d788ef0a9 100644 --- a/source/blender/editors/interface/interface_widgets.c +++ b/source/blender/editors/interface/interface_widgets.c @@ -630,7 +630,8 @@ static void widgetbase_draw(uiWidgetBase *wtb, uiWidgetColors *wcol) static void widget_draw_icon(uiBut *but, BIFIconID icon, int blend, rcti *rect) { - float xs=0, ys=0, aspect, height; + int xs=0, ys=0; + float aspect, height; /* this icon doesn't need draw... */ if(icon==ICON_BLANK1 && (but->flag & UI_ICON_SUBMENU)==0) return; @@ -663,33 +664,33 @@ static void widget_draw_icon(uiBut *but, BIFIconID icon, int blend, rcti *rect) if(but->flag & UI_ICON_LEFT) { if (but->type==BUT_TOGDUAL) { if (but->drawstr[0]) { - xs= rect->xmin-1.0; + xs= rect->xmin-1; } else { - xs= (rect->xmin+rect->xmax- height)/2.0; + xs= (rect->xmin+rect->xmax- height)/2; } } else if (but->block->flag & UI_BLOCK_LOOP) { - xs= rect->xmin+1.0; + xs= rect->xmin+1; } else if ((but->type==ICONROW) || (but->type==ICONTEXTROW)) { - xs= rect->xmin+3.0; + xs= rect->xmin+3; } else { - xs= rect->xmin+4.0; + xs= rect->xmin+4; } - ys= (rect->ymin+rect->ymax- height)/2.0; + ys= (rect->ymin+rect->ymax- height)/2; } else { - xs= (rect->xmin+rect->xmax- height)/2.0; - ys= (rect->ymin+rect->ymax- height)/2.0; + xs= (rect->xmin+rect->xmax- height)/2; + ys= (rect->ymin+rect->ymax- height)/2; } UI_icon_draw_aspect_blended(xs, ys, icon, aspect, blend); } if(but->flag & UI_ICON_SUBMENU) { - xs= rect->xmax-17.0; - ys= (rect->ymin+rect->ymax- height)/2.0; + xs= rect->xmax-17; + ys= (rect->ymin+rect->ymax- height)/2; UI_icon_draw_aspect_blended(xs, ys, ICON_RIGHTARROW_THIN, aspect, blend); } diff --git a/source/blender/editors/space_info/info_header.c b/source/blender/editors/space_info/info_header.c index 09f5640dbf6..c8dd3df8425 100644 --- a/source/blender/editors/space_info/info_header.c +++ b/source/blender/editors/space_info/info_header.c @@ -489,7 +489,7 @@ void info_header_buttons(const bContext *C, ARegion *ar) { static char search[256]= ""; - uiBut *but= uiDefSearchBut(block, search, 0, ICON_PROP_ON, 256, xco+5, yco, 120, 19, ""); + uiBut *but= uiDefSearchBut(block, search, 0, ICON_VIEWZOOM, 256, xco+5, yco, 120, 19, ""); uiButSetSearchFunc(but, operator_search_cb, NULL, operator_call_cb); diff --git a/source/blender/windowmanager/intern/wm_operators.c b/source/blender/windowmanager/intern/wm_operators.c index b020e4c24a8..418a231a7e9 100644 --- a/source/blender/windowmanager/intern/wm_operators.c +++ b/source/blender/windowmanager/intern/wm_operators.c @@ -420,7 +420,7 @@ static uiBlock *wm_block_search_menu(bContext *C, ARegion *ar, void *arg_op) block= uiBeginBlock(C, ar, "_popup", UI_EMBOSS); uiBlockSetFlag(block, UI_BLOCK_LOOP|UI_BLOCK_RET_1); - but= uiDefSearchBut(block, search, 0, ICON_PROP_ON, 256, 10, 10, 180, 19, ""); + but= uiDefSearchBut(block, search, 0, ICON_VIEWZOOM, 256, 10, 10, 180, 19, ""); uiButSetSearchFunc(but, operator_search_cb, NULL, operator_call_cb); uiPopupBoundsBlock(block, 0.0f, 0, -20); /* move it downwards, mouse over button */ From 3f0d2bd334125d57cdd33afc054e22b2f4fa8da7 Mon Sep 17 00:00:00 2001 From: Ton Roosendaal Date: Thu, 4 Jun 2009 18:38:10 +0000 Subject: [PATCH 26/35] 2.5 Just a minor tweak in menu draw, makes Search menu a tinsy prettier. Tomorrow more! --- source/blender/editors/interface/interface_widgets.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/source/blender/editors/interface/interface_widgets.c b/source/blender/editors/interface/interface_widgets.c index c0d788ef0a9..1b9ab076b4a 100644 --- a/source/blender/editors/interface/interface_widgets.c +++ b/source/blender/editors/interface/interface_widgets.c @@ -1215,8 +1215,8 @@ static void widget_menu_back(uiWidgetColors *wcol, rcti *rect, int flag, int dir /* menu is 2nd level or deeper */ if (flag & UI_BLOCK_POPUP) { - rect->ymin -= 4.0; - rect->ymax += 4.0; + //rect->ymin -= 4.0; + //rect->ymax += 4.0; } else if (direction == UI_DOWN) { roundboxalign= 12; From 35914d8ca2333808f9ec354ba91e3f63efe16e9c Mon Sep 17 00:00:00 2001 From: Andrea Weikert Date: Thu, 4 Jun 2009 20:05:08 +0000 Subject: [PATCH 27/35] 2.5 MSVC projectfiles * added file editors/space_buttons/buttons_context.c * removed BRE_yafray project --- projectfiles_vc9/blender/blender.sln | 17 ----------------- .../blender/editors/ED_editors.vcproj | 4 ++++ 2 files changed, 4 insertions(+), 17 deletions(-) diff --git a/projectfiles_vc9/blender/blender.sln b/projectfiles_vc9/blender/blender.sln index 315adc06723..b782f9b8a86 100644 --- a/projectfiles_vc9/blender/blender.sln +++ b/projectfiles_vc9/blender/blender.sln @@ -39,7 +39,6 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "blender", "blender.vcproj", {BAC615B0-F1AF-418B-8D23-A10FD8870D6A} = {BAC615B0-F1AF-418B-8D23-A10FD8870D6A} {E90C7BC2-CF30-4A60-A8F2-0050D592E358} = {E90C7BC2-CF30-4A60-A8F2-0050D592E358} {8B8D4FC3-3234-4E54-8376-5AB83D00D164} = {8B8D4FC3-3234-4E54-8376-5AB83D00D164} - {9991A3C3-83FE-4AFE-9E18-9D01CB57E879} = {9991A3C3-83FE-4AFE-9E18-9D01CB57E879} {4B6AFCC5-968C-424A-8F20-76E41B3BEF74} = {4B6AFCC5-968C-424A-8F20-76E41B3BEF74} {0112CAD5-3584-412A-A2E5-1315A00437B4} = {0112CAD5-3584-412A-A2E5-1315A00437B4} {EB75F4D6-2970-4A3A-8D99-2BAD7201C0E9} = {EB75F4D6-2970-4A3A-8D99-2BAD7201C0E9} @@ -210,8 +209,6 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "gen_messaging", "..\kernel\ EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "PHY_Sumo", "..\gameengine\physics\PHY_Physics\PHY_Sumo\PHY_Sumo.vcproj", "{9625642D-6F20-4FB6-A089-BE7441B223E3}" EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "BRE_yafray", "yafray\BRE_yafray.vcproj", "{9991A3C3-83FE-4AFE-9E18-9D01CB57E879}" -EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "PHY_Bullet", "..\gameengine\physics\PHY_Physics\PHY_Bullet\PHY_Bullet.vcproj", "{E90C7BC2-CF30-4A60-A8F2-0050D592E358}" ProjectSection(ProjectDependencies) = postProject {FFD3C64A-30E2-4BC7-BC8F-51818C320400} = {FFD3C64A-30E2-4BC7-BC8F-51818C320400} @@ -831,20 +828,6 @@ Global {9625642D-6F20-4FB6-A089-BE7441B223E3}.Debug|Win32.Build.0 = 3D Plugin Debug|Win32 {9625642D-6F20-4FB6-A089-BE7441B223E3}.Release|Win32.ActiveCfg = BlenderPlayer Release|Win32 {9625642D-6F20-4FB6-A089-BE7441B223E3}.Release|Win32.Build.0 = BlenderPlayer Release|Win32 - {9991A3C3-83FE-4AFE-9E18-9D01CB57E879}.3D Plugin Debug|Win32.ActiveCfg = Blender Release|Win32 - {9991A3C3-83FE-4AFE-9E18-9D01CB57E879}.3D Plugin Debug|Win32.Build.0 = Blender Release|Win32 - {9991A3C3-83FE-4AFE-9E18-9D01CB57E879}.3D Plugin Release|Win32.ActiveCfg = Blender Release|Win32 - {9991A3C3-83FE-4AFE-9E18-9D01CB57E879}.3D Plugin Release|Win32.Build.0 = Blender Release|Win32 - {9991A3C3-83FE-4AFE-9E18-9D01CB57E879}.Blender Debug|Win32.ActiveCfg = Blender Debug|Win32 - {9991A3C3-83FE-4AFE-9E18-9D01CB57E879}.Blender Debug|Win32.Build.0 = Blender Debug|Win32 - {9991A3C3-83FE-4AFE-9E18-9D01CB57E879}.Blender Release|Win32.ActiveCfg = Blender Release|Win32 - {9991A3C3-83FE-4AFE-9E18-9D01CB57E879}.Blender Release|Win32.Build.0 = Blender Release|Win32 - {9991A3C3-83FE-4AFE-9E18-9D01CB57E879}.BlenderPlayer Debug|Win32.ActiveCfg = Blender Debug|Win32 - {9991A3C3-83FE-4AFE-9E18-9D01CB57E879}.BlenderPlayer Release|Win32.ActiveCfg = Blender Release|Win32 - {9991A3C3-83FE-4AFE-9E18-9D01CB57E879}.Debug|Win32.ActiveCfg = Blender Debug|Win32 - {9991A3C3-83FE-4AFE-9E18-9D01CB57E879}.Debug|Win32.Build.0 = Blender Debug|Win32 - {9991A3C3-83FE-4AFE-9E18-9D01CB57E879}.Release|Win32.ActiveCfg = Blender Release|Win32 - {9991A3C3-83FE-4AFE-9E18-9D01CB57E879}.Release|Win32.Build.0 = Blender Release|Win32 {E90C7BC2-CF30-4A60-A8F2-0050D592E358}.3D Plugin Debug|Win32.ActiveCfg = 3D Plugin Debug|Win32 {E90C7BC2-CF30-4A60-A8F2-0050D592E358}.3D Plugin Debug|Win32.Build.0 = 3D Plugin Debug|Win32 {E90C7BC2-CF30-4A60-A8F2-0050D592E358}.3D Plugin Release|Win32.ActiveCfg = 3D Plugin Release|Win32 diff --git a/projectfiles_vc9/blender/editors/ED_editors.vcproj b/projectfiles_vc9/blender/editors/ED_editors.vcproj index 3ed0e772d2f..8fa89f2c4a5 100644 --- a/projectfiles_vc9/blender/editors/ED_editors.vcproj +++ b/projectfiles_vc9/blender/editors/ED_editors.vcproj @@ -714,6 +714,10 @@ + + From b0b8700a83c9cc6df0582336743cfcd3f863917c Mon Sep 17 00:00:00 2001 From: Andrea Weikert Date: Thu, 4 Jun 2009 20:07:06 +0000 Subject: [PATCH 28/35] 2.5 filebrowser * code cleanup: removed unused fileselect mode (type) * brought back 'hide dot files', needs proper storing of the settings still. --- .../blender/editors/include/ED_fileselect.h | 5 +- source/blender/editors/space_file/file_draw.c | 4 +- .../blender/editors/space_file/file_header.c | 39 ++++---- source/blender/editors/space_file/filelist.c | 99 ++++++++----------- source/blender/editors/space_file/filelist.h | 3 +- source/blender/editors/space_file/filesel.c | 31 ++---- .../blender/editors/space_file/space_file.c | 2 - .../windowmanager/intern/wm_event_system.c | 16 ++- 8 files changed, 83 insertions(+), 116 deletions(-) diff --git a/source/blender/editors/include/ED_fileselect.h b/source/blender/editors/include/ED_fileselect.h index 7cbef4984d7..34aefa91225 100644 --- a/source/blender/editors/include/ED_fileselect.h +++ b/source/blender/editors/include/ED_fileselect.h @@ -35,7 +35,6 @@ struct SpaceFile; #define FILE_IMGDISPLAY 3 typedef struct FileSelectParams { - int type; /* the mode of the filebrowser, FILE_BLENDER, FILE_SPECIAL, FILE_MAIN or FILE_LOADLIB */ char title[24]; /* title, also used for the text of the execute button */ char dir[240]; /* directory */ char file[80]; /* file */ @@ -96,8 +95,8 @@ typedef struct FileLayout FileSelectParams* ED_fileselect_get_params(struct SpaceFile *sfile); -short ED_fileselect_set_params(struct SpaceFile *sfile, int type, const char *title, const char *path, - short flag, short display, short filter); +short ED_fileselect_set_params(struct SpaceFile *sfile, const char *title, const char *path, + short flag, short display, short filter, short sort); void ED_fileselect_reset_params(struct SpaceFile *sfile); diff --git a/source/blender/editors/space_file/file_draw.c b/source/blender/editors/space_file/file_draw.c index bbe8245a3f7..6ed8f87d987 100644 --- a/source/blender/editors/space_file/file_draw.c +++ b/source/blender/editors/space_file/file_draw.c @@ -444,13 +444,11 @@ void file_draw_list(const bContext *C, ARegion *ar) int colorid = 0; short sx, sy; int offset; - short type; int i; float sw, spos; numfiles = filelist_numfiles(files); - type = filelist_gettype(files); - + sx = ar->v2d.tot.xmin + layout->tile_border_x/2; sy = ar->v2d.cur.ymax - layout->tile_border_y; diff --git a/source/blender/editors/space_file/file_header.c b/source/blender/editors/space_file/file_header.c index bfa0a553334..4799003d6c7 100644 --- a/source/blender/editors/space_file/file_header.c +++ b/source/blender/editors/space_file/file_header.c @@ -63,6 +63,7 @@ #define B_SORTIMASELLIST 1 #define B_RELOADIMASELDIR 2 #define B_FILTERIMASELDIR 3 +#define B_HIDEDOTFILES 4 /* ************************ header area region *********************** */ @@ -88,6 +89,14 @@ static void do_file_header_buttons(bContext *C, void *arg, int event) } } WM_event_add_notifier(C, NC_WINDOW, NULL); + break; + case B_HIDEDOTFILES: + if(sfile->params) { + filelist_free(sfile->files); + filelist_hidedot(sfile->files, sfile->params->flag & FILE_HIDE_DOT); + WM_event_add_notifier(C, NC_WINDOW, NULL); + } + break; } } @@ -126,15 +135,14 @@ void file_header_buttons(const bContext *C, ARegion *ar) xco += 5; - if (sfile->params->type != FILE_MAIN) { - uiBlockBeginAlign(block); - uiDefIconButS(block, ROW, B_RELOADIMASELDIR, ICON_SHORTDISPLAY, xco+=XIC, yco, XIC,YIC, ¶ms->display, 1.0, FILE_SHORTDISPLAY, 0, 0, "Displays short file description"); - uiDefIconButS(block, ROW, B_RELOADIMASELDIR, ICON_LONGDISPLAY, xco+=XIC, yco, XIC,YIC, ¶ms->display, 1.0, FILE_LONGDISPLAY, 0, 0, "Displays long file description"); - uiDefIconButS(block, ROW, B_RELOADIMASELDIR, ICON_IMGDISPLAY, xco+=XIC, yco, XIC,YIC, ¶ms->display, 1.0, FILE_IMGDISPLAY, 0, 0, "Displays files as thumbnails"); - uiBlockEndAlign(block); - - xco+=XIC; - } + uiBlockBeginAlign(block); + uiDefIconButS(block, ROW, B_RELOADIMASELDIR, ICON_SHORTDISPLAY, xco+=XIC, yco, XIC,YIC, ¶ms->display, 1.0, FILE_SHORTDISPLAY, 0, 0, "Displays short file description"); + uiDefIconButS(block, ROW, B_RELOADIMASELDIR, ICON_LONGDISPLAY, xco+=XIC, yco, XIC,YIC, ¶ms->display, 1.0, FILE_LONGDISPLAY, 0, 0, "Displays long file description"); + uiDefIconButS(block, ROW, B_RELOADIMASELDIR, ICON_IMGDISPLAY, xco+=XIC, yco, XIC,YIC, ¶ms->display, 1.0, FILE_IMGDISPLAY, 0, 0, "Displays files as thumbnails"); + uiBlockEndAlign(block); + + xco+=XIC; + uiBlockBeginAlign(block); uiDefIconButS(block, ROW, B_SORTIMASELLIST, ICON_SORTALPHA, xco+=XIC, yco, XIC,YIC, ¶ms->sort, 1.0, 0.0, 0, 0, "Sorts files alphabetically"); @@ -144,17 +152,8 @@ void file_header_buttons(const bContext *C, ARegion *ar) uiBlockEndAlign(block); xco+=XIC; - - /* replace with consistent sub-region collapsing - if (sfile->params->type != FILE_MAIN) { - uiBlockBeginAlign(block); - // uiDefIconButBitS(block, TOG, FILE_BOOKMARKS, B_RELOADIMASELDIR, ICON_BOOKMARKS,xco+=XIC,0,XIC,YIC, ¶ms->flag, 0, 0, 0, 0, "Toggles Bookmarks on/off"); - uiDefIconButO(block, TOG, "FILE_OT_bookmark_toggle", WM_OP_INVOKE_DEFAULT, ICON_BOOKMARKS, xco+XIC,yco,20,20, "Toggle Bookmarks"); - uiBlockEndAlign(block); - xco+=XIC; - } - */ - + uiDefIconButBitS(block, TOG, FILE_HIDE_DOT, B_HIDEDOTFILES, ICON_GHOST,xco+=XIC,yco,XIC,YIC, ¶ms->flag, 0, 0, 0, 0, "Hide dot files"); + xco+=XIC; uiDefIconButBitS(block, TOG, FILE_FILTER, B_FILTERIMASELDIR, ICON_FILTER,xco+=XIC,yco,XIC,YIC, ¶ms->flag, 0, 0, 0, 0, "Filter files"); if (params->flag & FILE_FILTER) { diff --git a/source/blender/editors/space_file/filelist.c b/source/blender/editors/space_file/filelist.c index 01cdf559c58..f60b6f08348 100644 --- a/source/blender/editors/space_file/filelist.c +++ b/source/blender/editors/space_file/filelist.c @@ -113,7 +113,6 @@ typedef struct FileList int numfiles; int numfiltered; char dir[FILE_MAX]; - short type; int has_func; short prv_w; short prv_h; @@ -358,12 +357,6 @@ void filelist_free_icons() struct FileList* filelist_new() { FileList* p = MEM_callocN( sizeof(FileList), "filelist" ); - p->filelist = 0; - p->numfiles = 0; - p->dir[0] = '\0'; - p->type = 0; - p->has_func = 0; - p->filter = 0; return p; } @@ -373,7 +366,6 @@ struct FileList* filelist_copy(struct FileList* filelist) BLI_strncpy(p->dir, filelist->dir, FILE_MAX); p->filelist = NULL; p->fidx = NULL; - p->type = filelist->type; return p; } @@ -413,6 +405,7 @@ void filelist_free(struct FileList* filelist) filelist->filelist = 0; filelist->filter = 0; filelist->numfiltered =0; + filelist->hide_dot =0; } int filelist_numfiles(struct FileList* filelist) @@ -510,48 +503,46 @@ void filelist_loadimage(struct FileList* filelist, int index) if (!filelist->filelist[fidx].image) { - if (filelist->type != FILE_MAIN) - { - if ( (filelist->filelist[fidx].flags & IMAGEFILE) || (filelist->filelist[fidx].flags & MOVIEFILE) ) { - imb = IMB_thumb_read(filelist->dir, filelist->filelist[fidx].relname, THB_NORMAL); - } - if (imb) { - if (imb->x > imb->y) { - scaledx = (float)imgwidth; - scaledy = ( (float)imb->y/(float)imb->x )*imgwidth; + + if ( (filelist->filelist[fidx].flags & IMAGEFILE) || (filelist->filelist[fidx].flags & MOVIEFILE) ) { + imb = IMB_thumb_read(filelist->dir, filelist->filelist[fidx].relname, THB_NORMAL); + } + if (imb) { + if (imb->x > imb->y) { + scaledx = (float)imgwidth; + scaledy = ( (float)imb->y/(float)imb->x )*imgwidth; + } + else { + scaledy = (float)imgheight; + scaledx = ( (float)imb->x/(float)imb->y )*imgheight; + } + ex = (short)scaledx; + ey = (short)scaledy; + + dx = imgwidth - ex; + dy = imgheight - ey; + + // IMB_scaleImBuf(imb, ex, ey); + filelist->filelist[fidx].image = imb; + } else { + /* prevent loading image twice */ + FileImage* limg = filelist->loadimages.first; + short found= 0; + while(limg) { + if (limg->index == fidx) { + found= 1; + break; } - else { - scaledy = (float)imgheight; - scaledx = ( (float)imb->x/(float)imb->y )*imgheight; - } - ex = (short)scaledx; - ey = (short)scaledy; - - dx = imgwidth - ex; - dy = imgheight - ey; - - // IMB_scaleImBuf(imb, ex, ey); - filelist->filelist[fidx].image = imb; - } else { - /* prevent loading image twice */ - FileImage* limg = filelist->loadimages.first; - short found= 0; - while(limg) { - if (limg->index == fidx) { - found= 1; - break; - } - limg= limg->next; - } - if (!found) { - FileImage* limg = MEM_callocN(sizeof(struct FileImage), "loadimage"); - limg->index= fidx; - limg->lock= 0; - limg->filelist= filelist; - BLI_addtail(&filelist->loadimages, limg); - } - } - } + limg= limg->next; + } + if (!found) { + FileImage* limg = MEM_callocN(sizeof(struct FileImage), "loadimage"); + limg->index= fidx; + limg->lock= 0; + limg->filelist= filelist; + BLI_addtail(&filelist->loadimages, limg); + } + } } } @@ -826,16 +817,6 @@ void filelist_swapselect(struct FileList* filelist) } } -void filelist_settype(struct FileList* filelist, int type) -{ - filelist->type = type; -} - -short filelist_gettype(struct FileList* filelist) -{ - return filelist->type; -} - void filelist_sort(struct FileList* filelist, short sort) { struct direntry *file; diff --git a/source/blender/editors/space_file/filelist.h b/source/blender/editors/space_file/filelist.h index 4aa8359b068..f10c89926d6 100644 --- a/source/blender/editors/space_file/filelist.h +++ b/source/blender/editors/space_file/filelist.h @@ -70,8 +70,7 @@ void filelist_readdir(struct FileList* filelist); int filelist_empty(struct FileList* filelist); void filelist_parent(struct FileList* filelist); void filelist_setfiletypes(struct FileList* filelist, short has_quicktime); -void filelist_settype(struct FileList* filelist, int type); -short filelist_gettype(struct FileList* filelist); + #ifdef __cplusplus } diff --git a/source/blender/editors/space_file/filesel.c b/source/blender/editors/space_file/filesel.c index cbd1457e562..d57fc7f90bc 100644 --- a/source/blender/editors/space_file/filesel.c +++ b/source/blender/editors/space_file/filesel.c @@ -84,13 +84,13 @@ FileSelectParams* ED_fileselect_get_params(struct SpaceFile *sfile) { if (!sfile->params) { - ED_fileselect_set_params(sfile, FILE_UNIX, "", "/", 0, FILE_SHORTDISPLAY, 0); + ED_fileselect_set_params(sfile, "", "/", 0, FILE_SHORTDISPLAY, 0, FILE_SORTALPHA); } return sfile->params; } -short ED_fileselect_set_params(SpaceFile *sfile, int type, const char *title, const char *path, - short flag, short display, short filter) +short ED_fileselect_set_params(SpaceFile *sfile, const char *title, const char *path, + short flag, short display, short filter, short sort) { char name[FILE_MAX], dir[FILE_MAX], file[FILE_MAX]; FileSelectParams *params; @@ -101,39 +101,26 @@ short ED_fileselect_set_params(SpaceFile *sfile, int type, const char *title, co params = sfile->params; - params->type = type; params->flag = flag; params->display = display; params->filter = filter; + params->sort = sort; BLI_strncpy(params->title, title, sizeof(params->title)); BLI_strncpy(name, path, sizeof(name)); BLI_convertstringcode(name, G.sce); - - switch(type) { - case FILE_MAIN: - break; - case FILE_LOADLIB: - break; - case FILE_BLENDER: - case FILE_LOADFONT: - default: - { - BLI_split_dirfile(name, dir, file); - BLI_strncpy(params->file, file, sizeof(params->file)); - BLI_strncpy(params->dir, dir, sizeof(params->dir)); - BLI_make_file_string(G.sce, params->dir, dir, ""); /* XXX needed ? - also solve G.sce */ - } - break; - } + + BLI_split_dirfile(name, dir, file); + BLI_strncpy(params->file, file, sizeof(params->file)); + BLI_strncpy(params->dir, dir, sizeof(params->dir)); + BLI_make_file_string(G.sce, params->dir, dir, ""); /* XXX needed ? - also solve G.sce */ return 1; } void ED_fileselect_reset_params(SpaceFile *sfile) { - sfile->params->type = FILE_UNIX; sfile->params->flag = 0; sfile->params->title[0] = '\0'; } diff --git a/source/blender/editors/space_file/space_file.c b/source/blender/editors/space_file/space_file.c index 084fcf1e5f6..37d8f2bffa4 100644 --- a/source/blender/editors/space_file/space_file.c +++ b/source/blender/editors/space_file/space_file.c @@ -156,7 +156,6 @@ static SpaceLink *file_duplicate(SpaceLink *sl) sfilen->params= MEM_dupallocN(sfileo->params); filelist_setdir(sfilen->files, sfilen->params->dir); - filelist_settype(sfilen->files, sfilen->params->type); } if (sfileo->layout) { sfilen->layout= MEM_dupallocN(sfileo->layout); @@ -193,7 +192,6 @@ static void file_main_area_draw(const bContext *C, ARegion *ar) if (!sfile->files) { sfile->files = filelist_new(); filelist_setdir(sfile->files, params->dir); - filelist_settype(sfile->files, params->type); params->active_file = -1; // added this so it opens nicer (ton) } diff --git a/source/blender/windowmanager/intern/wm_event_system.c b/source/blender/windowmanager/intern/wm_event_system.c index e142a5f9640..fc0f1496c6a 100644 --- a/source/blender/windowmanager/intern/wm_event_system.c +++ b/source/blender/windowmanager/intern/wm_event_system.c @@ -773,12 +773,9 @@ static int wm_handler_fileselect_call(bContext *C, ListBase *handlers, wmEventHa case EVT_FILESELECT_OPEN: case EVT_FILESELECT_FULL_OPEN: { - int filetype= FILE_BLENDER; + short flag =0; short display =FILE_SHORTDISPLAY; short filter =0; short sort =FILE_SORTALPHA; char *path= RNA_string_get_alloc(handler->op->ptr, "filename", NULL, 0); - if(RNA_struct_find_property(handler->op->ptr, "filetype")) - filetype= RNA_int_get(handler->op->ptr, "filetype"); - if(event->val==EVT_FILESELECT_OPEN) ED_area_newspace(C, handler->op_area, SPACE_FILE); else @@ -788,7 +785,16 @@ static int wm_handler_fileselect_call(bContext *C, ListBase *handlers, wmEventHa sfile= (SpaceFile*)CTX_wm_space_data(C); sfile->op= handler->op; - ED_fileselect_set_params(sfile, filetype, handler->op->type->name, path, 0, FILE_SHORTDISPLAY, 0); + /* XXX for now take the settings from the existing (previous) filebrowser + should be stored in settings and passed via the operator */ + if (sfile->params) { + flag = sfile->params->flag; + filter = sfile->params->filter; + display = sfile->params->display; + sort = sfile->params->sort; + } + + ED_fileselect_set_params(sfile, handler->op->type->name, path, flag, display, filter, sort); MEM_freeN(path); action= WM_HANDLER_BREAK; From 13376a903b6167f26c04e14bad344374469fef25 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Fri, 5 Jun 2009 00:39:42 +0000 Subject: [PATCH 29/35] UI: * Make ESC-key close the search popup menu. * Also make ESC-key cancel number button dragging. --- .../editors/interface/interface_handlers.c | 29 ++++++++++++++----- 1 file changed, 21 insertions(+), 8 deletions(-) diff --git a/source/blender/editors/interface/interface_handlers.c b/source/blender/editors/interface/interface_handlers.c index c009c5cfc7b..52b14d6823e 100644 --- a/source/blender/editors/interface/interface_handlers.c +++ b/source/blender/editors/interface/interface_handlers.c @@ -97,7 +97,7 @@ typedef struct uiHandleButtonData { /* overall state */ uiHandleButtonState state; - int cancel, retval; + int cancel, escapecancel, retval; int applied, appliedinteractive; wmTimer *flashtimer; @@ -1253,6 +1253,7 @@ static void ui_do_but_textedit(bContext *C, uiBlock *block, uiBut *but, uiHandle case RIGHTMOUSE: case ESCKEY: data->cancel= 1; + data->escapecancel= 1; button_activate_state(C, but, BUTTON_STATE_EXIT); retval= WM_UI_HANDLER_BREAK; break; @@ -1772,7 +1773,12 @@ static int ui_do_but_NUM(bContext *C, uiBlock *block, uiBut *but, uiHandleButton } } else if(data->state == BUTTON_STATE_NUM_EDITING) { - if(event->type == LEFTMOUSE && event->val!=KM_PRESS) { + if(event->type == ESCKEY) { + data->cancel= 1; + data->escapecancel= 1; + button_activate_state(C, but, BUTTON_STATE_EXIT); + } + else if(event->type == LEFTMOUSE && event->val!=KM_PRESS) { if(data->dragchange) button_activate_state(C, but, BUTTON_STATE_EXIT); else @@ -1968,7 +1974,12 @@ static int ui_do_but_SLI(bContext *C, uiBlock *block, uiBut *but, uiHandleButton } } else if(data->state == BUTTON_STATE_NUM_EDITING) { - if(event->type == LEFTMOUSE && event->val!=KM_PRESS) { + if(event->type == ESCKEY) { + data->cancel= 1; + data->escapecancel= 1; + button_activate_state(C, but, BUTTON_STATE_EXIT); + } + else if(event->type == LEFTMOUSE && event->val!=KM_PRESS) { if(data->dragchange) button_activate_state(C, but, BUTTON_STATE_EXIT); else @@ -3100,12 +3111,14 @@ static void button_activate_exit(bContext *C, uiHandleButtonData *data, uiBut *b /* if this button is in a menu, this will set the button return * value to the button value and the menu return value to ok, the * menu return value will be picked up and the menu will close */ - if(block->handle && !(block->flag & UI_BLOCK_KEEP_OPEN) && !data->cancel) { - uiPopupBlockHandle *menu; + if(block->handle && !(block->flag & UI_BLOCK_KEEP_OPEN)) { + if(!data->cancel || data->escapecancel) { + uiPopupBlockHandle *menu; - menu= block->handle; - menu->butretval= data->retval; - menu->menuretval= UI_RETURN_OK; + menu= block->handle; + menu->butretval= data->retval; + menu->menuretval= (data->cancel)? UI_RETURN_CANCEL: UI_RETURN_OK; + } } /* disable tooltips until mousemove */ From 52d8e64b857530c85efb6e1c38b4b4fd40d9c345 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 5 Jun 2009 12:48:58 +0000 Subject: [PATCH 30/35] PyRNA - Support for python to convert a PyObject into a collection (uses a list of dicts - quite verbose :/) - Operators can now take collection args when called from python. - Support for printing operators that use collections (macro recording). - Added RNA_pointer_as_string which prints all pointer prop values as a python dict. Example that can run in the in test.py (F7 key) bpy.ops.VIEW3D_OT_select_lasso(path=[{"loc":(0, 0), "time":0}, {"loc":(1000, 0), "time":0}, {"loc":(1000, 1000), "time":0}], type='SELECT') for some reason lasso locations always print as 0,0. Need to look into why this is. --- source/blender/makesrna/RNA_access.h | 1 + source/blender/makesrna/intern/rna_access.c | 63 +++++++++++- source/blender/python/intern/bpy_operator.c | 69 +------------ source/blender/python/intern/bpy_operator.h | 3 - .../blender/python/intern/bpy_operator_wrap.c | 2 +- source/blender/python/intern/bpy_rna.c | 96 ++++++++++++++++++- source/blender/python/intern/bpy_rna.h | 1 + source/blender/python/intern/bpy_ui.c | 4 +- 8 files changed, 162 insertions(+), 77 deletions(-) diff --git a/source/blender/makesrna/RNA_access.h b/source/blender/makesrna/RNA_access.h index 70490259832..4df5aa67104 100644 --- a/source/blender/makesrna/RNA_access.h +++ b/source/blender/makesrna/RNA_access.h @@ -536,6 +536,7 @@ int RNA_property_is_set(PointerRNA *ptr, const char *name); /* python compatible string representation of this property, (must be freed!) */ char *RNA_property_as_string(PointerRNA *ptr, PropertyRNA *prop); +char *RNA_pointer_as_string(PointerRNA *ptr); /* Function */ diff --git a/source/blender/makesrna/intern/rna_access.c b/source/blender/makesrna/intern/rna_access.c index cf52c5fb1ec..91b46e8e3d7 100644 --- a/source/blender/makesrna/intern/rna_access.c +++ b/source/blender/makesrna/intern/rna_access.c @@ -2185,6 +2185,47 @@ int RNA_property_is_set(PointerRNA *ptr, const char *name) /* string representation of a property, python * compatible but can be used for display too*/ +char *RNA_pointer_as_string(PointerRNA *ptr) +{ + DynStr *dynstr= BLI_dynstr_new(); + char *cstring; + + PropertyRNA *prop, *iterprop; + CollectionPropertyIterator iter; + const char *propname; + int first_time = 1; + + BLI_dynstr_append(dynstr, "{"); + + iterprop= RNA_struct_iterator_property(ptr->type); + RNA_property_collection_begin(ptr, iterprop, &iter); + + for(; iter.valid; RNA_property_collection_next(&iter)) { + prop= iter.ptr.data; + propname = RNA_property_identifier(prop); + + if(strcmp(propname, "rna_type")==0) + continue; + + if(first_time==0) + BLI_dynstr_append(dynstr, ", "); + first_time= 0; + + cstring = RNA_property_as_string(&iter.ptr, prop); + BLI_dynstr_appendf(dynstr, "\"%s\":%s", propname, cstring); + MEM_freeN(cstring); + first_time= 0; + } + + RNA_property_collection_end(&iter); + BLI_dynstr_append(dynstr, "}"); + + + cstring = BLI_dynstr_get_cstring(dynstr); + BLI_dynstr_free(dynstr); + return cstring; +} + char *RNA_property_as_string(PointerRNA *ptr, PropertyRNA *prop) { int type = RNA_property_type(prop); @@ -2262,8 +2303,28 @@ char *RNA_property_as_string(PointerRNA *ptr, PropertyRNA *prop) break; } case PROP_COLLECTION: - BLI_dynstr_append(dynstr, "''"); /* TODO */ + { + int first_time = 1; + CollectionPropertyIterator collect_iter; + BLI_dynstr_append(dynstr, "["); + + for(RNA_property_collection_begin(ptr, prop, &collect_iter); collect_iter.valid; RNA_property_collection_next(&collect_iter)) { + PointerRNA itemptr= collect_iter.ptr; + + if(first_time==0) + BLI_dynstr_append(dynstr, ", "); + first_time= 0; + + /* now get every prop of the collection */ + cstring= RNA_pointer_as_string(&itemptr); + BLI_dynstr_append(dynstr, cstring); + MEM_freeN(cstring); + } + + RNA_property_collection_end(&collect_iter); + BLI_dynstr_append(dynstr, "]"); break; + } default: BLI_dynstr_append(dynstr, "''"); /* TODO */ break; diff --git a/source/blender/python/intern/bpy_operator.c b/source/blender/python/intern/bpy_operator.c index b03540fb765..004cf2fb7c7 100644 --- a/source/blender/python/intern/bpy_operator.c +++ b/source/blender/python/intern/bpy_operator.c @@ -41,73 +41,6 @@ extern ListBase global_ops; /* evil, temp use */ - - -/* This function is only used by operators right now - * Its used for taking keyword args and filling in property values */ -int PYOP_props_from_dict(PointerRNA *ptr, PyObject *kw) -{ - int error_val = 0; - int totkw; - const char *arg_name= NULL; - PyObject *item; - - PropertyRNA *prop, *iterprop; - CollectionPropertyIterator iter; - - iterprop= RNA_struct_iterator_property(ptr->type); - RNA_property_collection_begin(ptr, iterprop, &iter); - - totkw = kw ? PyDict_Size(kw):0; - - for(; iter.valid; RNA_property_collection_next(&iter)) { - prop= iter.ptr.data; - - arg_name= RNA_property_identifier(prop); - - if (strcmp(arg_name, "rna_type")==0) continue; - - if (kw==NULL) { - PyErr_Format( PyExc_AttributeError, "no args, expected \"%s\"", arg_name ? arg_name : ""); - error_val= -1; - break; - } - - item= PyDict_GetItemString(kw, arg_name); - - if (item == NULL) { - PyErr_Format( PyExc_AttributeError, "argument \"%s\" missing", arg_name ? arg_name : ""); - error_val = -1; /* pyrna_py_to_prop sets the error */ - break; - } - - if (pyrna_py_to_prop(ptr, prop, NULL, item)) { - error_val= -1; - break; - } - - totkw--; - } - - RNA_property_collection_end(&iter); - - if (error_val==0 && totkw > 0) { /* some keywords were given that were not used :/ */ - PyObject *key, *value; - Py_ssize_t pos = 0; - - while (PyDict_Next(kw, &pos, &key, &value)) { - arg_name= _PyUnicode_AsString(key); - if (RNA_struct_find_property(ptr, arg_name) == NULL) break; - arg_name= NULL; - } - - PyErr_Format( PyExc_AttributeError, "argument \"%s\" unrecognized", arg_name ? arg_name : ""); - error_val = -1; - } - - return error_val; -} - static PyObject *pyop_base_dir(PyObject *self); static PyObject *pyop_base_rna(PyObject *self, PyObject *pyname); static struct PyMethodDef pyop_base_methods[] = { @@ -148,7 +81,7 @@ static PyObject *pyop_base_call( PyObject * self, PyObject * args, PyObject * k WM_operator_properties_create(&ptr, opname); - error_val= PYOP_props_from_dict(&ptr, kw); + error_val= pyrna_pydict_to_props(&ptr, kw, "Converting py args to operator properties: "); if (error_val==0) { ReportList reports; diff --git a/source/blender/python/intern/bpy_operator.h b/source/blender/python/intern/bpy_operator.h index c4741f936bf..46ea144fd4d 100644 --- a/source/blender/python/intern/bpy_operator.h +++ b/source/blender/python/intern/bpy_operator.h @@ -42,7 +42,4 @@ typedef struct { PyObject *BPY_operator_module(void); -/* fill in properties from a python dict */ -int PYOP_props_from_dict(PointerRNA *ptr, PyObject *kw); - #endif diff --git a/source/blender/python/intern/bpy_operator_wrap.c b/source/blender/python/intern/bpy_operator_wrap.c index 43d62b3005f..bf92db832af 100644 --- a/source/blender/python/intern/bpy_operator_wrap.c +++ b/source/blender/python/intern/bpy_operator_wrap.c @@ -272,7 +272,7 @@ static int PYTHON_OT_generic(int mode, bContext *C, wmOperator *op, wmEvent *eve * thrown away anyway * * If we ever want to do this and use the props again, - * it can be done with - PYOP_props_from_dict(op->ptr, kw) + * it can be done with - pyrna_pydict_to_props(op->ptr, kw, "") */ Py_DECREF(ret); diff --git a/source/blender/python/intern/bpy_rna.c b/source/blender/python/intern/bpy_rna.c index c1778faa1cd..d9a0d9408c7 100644 --- a/source/blender/python/intern/bpy_rna.c +++ b/source/blender/python/intern/bpy_rna.c @@ -204,6 +204,71 @@ PyObject * pyrna_prop_to_py(PointerRNA *ptr, PropertyRNA *prop) return ret; } +/* This function is only used by operators right now + * Its used for taking keyword args and filling in property values */ +int pyrna_pydict_to_props(PointerRNA *ptr, PyObject *kw, const char *error_prefix) +{ + int error_val = 0; + int totkw; + const char *arg_name= NULL; + PyObject *item; + + PropertyRNA *prop, *iterprop; + CollectionPropertyIterator iter; + + iterprop= RNA_struct_iterator_property(ptr->type); + RNA_property_collection_begin(ptr, iterprop, &iter); + + totkw = kw ? PyDict_Size(kw):0; + + for(; iter.valid; RNA_property_collection_next(&iter)) { + prop= iter.ptr.data; + + arg_name= RNA_property_identifier(prop); + + if (strcmp(arg_name, "rna_type")==0) continue; + + if (kw==NULL) { + PyErr_Format( PyExc_AttributeError, "%s: no keywords, expected \"%s\"", error_prefix, arg_name ? arg_name : ""); + error_val= -1; + break; + } + + item= PyDict_GetItemString(kw, arg_name); + + if (item == NULL) { + PyErr_Format( PyExc_AttributeError, "%s: keyword \"%s\" missing", error_prefix, arg_name ? arg_name : ""); + error_val = -1; /* pyrna_py_to_prop sets the error */ + break; + } + + if (pyrna_py_to_prop(ptr, prop, NULL, item)) { + error_val= -1; + break; + } + + totkw--; + } + + RNA_property_collection_end(&iter); + + if (error_val==0 && totkw > 0) { /* some keywords were given that were not used :/ */ + PyObject *key, *value; + Py_ssize_t pos = 0; + + while (PyDict_Next(kw, &pos, &key, &value)) { + arg_name= _PyUnicode_AsString(key); + if (RNA_struct_find_property(ptr, arg_name) == NULL) break; + arg_name= NULL; + } + + PyErr_Format( PyExc_AttributeError, "%s: keyword \"%s\" unrecognized", error_prefix, arg_name ? arg_name : ""); + error_val = -1; + } + + return error_val; +} + static PyObject * pyrna_func_call(PyObject * self, PyObject *args, PyObject *kw); PyObject *pyrna_func_to_py(PointerRNA *ptr, FunctionRNA *func) @@ -447,9 +512,36 @@ int pyrna_py_to_prop(PointerRNA *ptr, PropertyRNA *prop, void *data, PyObject *v break; } case PROP_COLLECTION: - PyErr_SetString(PyExc_AttributeError, "cant convert collections yet"); - return -1; + { + int seq_len, i; + PyObject *item; + PointerRNA itemptr; + + /* convert a sequence of dict's into a collection */ + if(!PySequence_Check(value)) { + PyErr_SetString(PyExc_TypeError, "expected a sequence of dicts for an RNA collection"); + return -1; + } + + seq_len = PySequence_Length(value); + for(i=0; iptr, py_keywords) == -1) + if (pyrna_pydict_to_props(km->ptr, py_keywords, "Registering keybinding") == -1) return NULL; } From f7e5fd94386cada0e800e9dcd66492cc77e1c201 Mon Sep 17 00:00:00 2001 From: Shaul Kedem Date: Fri, 5 Jun 2009 13:20:42 +0000 Subject: [PATCH 31/35] MSVC cries of uninitialized param --- source/blender/editors/space_view3d/view3d_view.c | 1 + 1 file changed, 1 insertion(+) diff --git a/source/blender/editors/space_view3d/view3d_view.c b/source/blender/editors/space_view3d/view3d_view.c index 06e5f69bbdf..e1a6f32aa41 100644 --- a/source/blender/editors/space_view3d/view3d_view.c +++ b/source/blender/editors/space_view3d/view3d_view.c @@ -203,6 +203,7 @@ void smooth_view(bContext *C, Object *oldcamera, Object *camera, float *ofs, flo struct SmoothViewStore sms; /* initialize sms */ + memset(&sms,0,sizeof(struct SmoothViewStore)); VECCOPY(sms.new_ofs, rv3d->ofs); QUATCOPY(sms.new_quat, rv3d->viewquat); sms.new_dist= rv3d->dist; From 45ed196344a7534c9965015ca653c90f5f00d97f Mon Sep 17 00:00:00 2001 From: Ton Roosendaal Date: Fri, 5 Jun 2009 16:11:18 +0000 Subject: [PATCH 32/35] 2.5 Search menu: - Made nicer drawing for popup version of search. It now uses entire backdrop like pulldowns. Search boxes for text buttons will use different style still; if we use this option all over it shouldn't look too intrusive. - Search menu allows scroll, to view all items. It doesn't cycle anymore. - Click outside search menu now cancels - If a match is in search button, it highlights it. This also allows ALT+CTRL+F - Enter to redo last op. - Search popup draws higher when no no space below. No order flipping! --- source/blender/editors/include/UI_interface.h | 3 +- .../editors/interface/interface_handlers.c | 13 +- .../editors/interface/interface_intern.h | 4 +- .../editors/interface/interface_regions.c | 114 ++++++++++++++---- .../editors/interface/interface_widgets.c | 7 +- .../windowmanager/intern/wm_operators.c | 5 +- 6 files changed, 113 insertions(+), 33 deletions(-) diff --git a/source/blender/editors/include/UI_interface.h b/source/blender/editors/include/UI_interface.h index feca59bca30..6511d4d91eb 100644 --- a/source/blender/editors/include/UI_interface.h +++ b/source/blender/editors/include/UI_interface.h @@ -449,7 +449,8 @@ typedef void (*uiBlockHandleFunc)(struct bContext *C, void *arg, int event); int uiSearchItemAdd(uiSearchItems *items, const char *name, void *poin); /* bfunc gets search item *poin as arg2, or if NULL the old string */ void uiButSetSearchFunc (uiBut *but, uiButSearchFunc sfunc, void *arg1, uiButHandleFunc bfunc); - + /* height in pixels, it's using hardcoded values still */ +int uiSearchBoxhHeight(void); void uiBlockSetHandleFunc(uiBlock *block, uiBlockHandleFunc func, void *arg); void uiBlockSetButmFunc (uiBlock *block, uiMenuHandleFunc func, void *arg); diff --git a/source/blender/editors/interface/interface_handlers.c b/source/blender/editors/interface/interface_handlers.c index 52b14d6823e..933d57c8983 100644 --- a/source/blender/editors/interface/interface_handlers.c +++ b/source/blender/editors/interface/interface_handlers.c @@ -1169,7 +1169,7 @@ static void ui_textedit_begin(bContext *C, uiBut *but, uiHandleButtonData *data) /* optional searchbox */ if(but->type==SEARCH_MENU) { data->searchbox= ui_searchbox_create(C, data->region, but); - ui_searchbox_update(C, data->searchbox, but); + ui_searchbox_update(C, data->searchbox, but, 1); /* 1= reset */ } ui_check_but(but); @@ -1247,7 +1247,7 @@ static void ui_do_but_textedit(bContext *C, uiBlock *block, uiBut *but, uiHandle switch(event->type) { case MOUSEMOVE: if(data->searchbox) - ui_searchbox_event(data->searchbox, event); + ui_searchbox_event(C, data->searchbox, but, event); break; case RIGHTMOUSE: @@ -1277,6 +1277,9 @@ static void ui_do_but_textedit(bContext *C, uiBlock *block, uiBut *but, uiHandle retval= WM_UI_HANDLER_BREAK; } else if(inbox==0) { + /* if searchbox, click outside will cancel */ + if(data->searchbox) + data->cancel= data->escapecancel= 1; button_activate_state(C, but, BUTTON_STATE_EXIT); retval= WM_UI_HANDLER_BREAK; } @@ -1315,7 +1318,7 @@ static void ui_do_but_textedit(bContext *C, uiBlock *block, uiBut *but, uiHandle break; case DOWNARROWKEY: if(data->searchbox) { - ui_searchbox_event(data->searchbox, event); + ui_searchbox_event(C, data->searchbox, but, event); break; } /* pass on purposedly */ @@ -1325,7 +1328,7 @@ static void ui_do_but_textedit(bContext *C, uiBlock *block, uiBut *but, uiHandle break; case UPARROWKEY: if(data->searchbox) { - ui_searchbox_event(data->searchbox, event); + ui_searchbox_event(C, data->searchbox, but, event); break; } /* pass on purposedly */ @@ -1378,7 +1381,7 @@ static void ui_do_but_textedit(bContext *C, uiBlock *block, uiBut *but, uiHandle else ui_check_but(but); if(data->searchbox) - ui_searchbox_update(C, data->searchbox, but); + ui_searchbox_update(C, data->searchbox, but, 1); /* 1 = reset */ } if(changed || (retval == WM_UI_HANDLER_BREAK)) diff --git a/source/blender/editors/interface/interface_intern.h b/source/blender/editors/interface/interface_intern.h index db100d8cf86..c6a93d8f74a 100644 --- a/source/blender/editors/interface/interface_intern.h +++ b/source/blender/editors/interface/interface_intern.h @@ -357,8 +357,8 @@ void ui_tooltip_free(struct bContext *C, struct ARegion *ar); /* searchbox for string button */ ARegion *ui_searchbox_create(struct bContext *C, struct ARegion *butregion, uiBut *but); -void ui_searchbox_update(struct bContext *C, struct ARegion *ar, uiBut *but); -void ui_searchbox_event(struct ARegion *ar, struct wmEvent *event); +void ui_searchbox_update(struct bContext *C, struct ARegion *ar, uiBut *but, int reset); +void ui_searchbox_event(struct bContext *C, struct ARegion *ar, uiBut *but, struct wmEvent *event); void ui_searchbox_apply(uiBut *but, struct ARegion *ar); void ui_searchbox_free(struct bContext *C, struct ARegion *ar); diff --git a/source/blender/editors/interface/interface_regions.c b/source/blender/editors/interface/interface_regions.c index 0bde1be2107..8ea686dfbd6 100644 --- a/source/blender/editors/interface/interface_regions.c +++ b/source/blender/editors/interface/interface_regions.c @@ -56,6 +56,7 @@ #include "BIF_gl.h" #include "UI_interface.h" +#include "UI_interface_icons.h" #include "UI_view2d.h" #include "BLF_api.h" @@ -389,6 +390,9 @@ void ui_tooltip_free(bContext *C, ARegion *ar) struct uiSearchItems { int maxitem, totitem, maxstrlen; + int offset, offset_i; /* offset for inserting in array */ + int more; /* flag indicating there are more items */ + char **names; void **pointers; @@ -398,7 +402,8 @@ typedef struct uiSearchboxData { rcti bbox; uiFontStyle fstyle; uiSearchItems items; - int active; + int active; /* index in items array */ + int noback; /* when menu opened with enough space for this */ } uiSearchboxData; #define SEARCH_ITEMS 10 @@ -408,20 +413,32 @@ typedef struct uiSearchboxData { int uiSearchItemAdd(uiSearchItems *items, const char *name, void *poin) { - if(items->totitem>=items->maxitem) + if(items->totitem>=items->maxitem) { + items->more= 1; return 0; + } + + /* skip first items in list */ + if(items->offset_i > 0) { + items->offset_i--; + return 1; + } BLI_strncpy(items->names[items->totitem], name, items->maxstrlen); items->pointers[items->totitem]= poin; items->totitem++; - return items->totitemmaxitem; + return 1; } +int uiSearchBoxhHeight(void) +{ + return SEARCH_ITEMS*MENU_BUTTON_HEIGHT + 2*MENU_TOP; +} /* ar is the search box itself */ -static void ui_searchbox_select(ARegion *ar, int step) +static void ui_searchbox_select(bContext *C, ARegion *ar, uiBut *but, int step) { uiSearchboxData *data= ar->regiondata; @@ -430,23 +447,37 @@ static void ui_searchbox_select(ARegion *ar, int step) if(data->items.totitem==0) data->active= 0; - else if(data->active> data->items.totitem) - data->active= 1; - else if(data->active < 0) - data->active= data->items.totitem; + else if(data->active > data->items.totitem) { + if(data->items.more) { + data->items.offset++; + data->active= data->items.totitem; + ui_searchbox_update(C, ar, but, 0); + } + else + data->active= data->items.totitem; + } + else if(data->active < 1) { + if(data->items.offset) { + data->items.offset--; + data->active= 1; + ui_searchbox_update(C, ar, but, 0); + } + else if(data->active < 0) + data->active= 0; + } ED_region_tag_redraw(ar); } static void ui_searchbox_butrect(rcti *rect, uiSearchboxData *data, int itemnr) { - int buth= (data->bbox.ymax-data->bbox.ymin - 2*MENU_SEPR_HEIGHT)/SEARCH_ITEMS; + int buth= (data->bbox.ymax-data->bbox.ymin - 2*MENU_TOP)/SEARCH_ITEMS; *rect= data->bbox; rect->xmin= data->bbox.xmin + 3.0f; rect->xmax= data->bbox.xmax - 3.0f; - rect->ymax= data->bbox.ymax - MENU_SEPR_HEIGHT - itemnr*buth; + rect->ymax= data->bbox.ymax - MENU_TOP - itemnr*buth; rect->ymin= rect->ymax - buth; } @@ -470,16 +501,16 @@ void ui_searchbox_apply(uiBut *but, ARegion *ar) } } -void ui_searchbox_event(ARegion *ar, wmEvent *event) +void ui_searchbox_event(bContext *C, ARegion *ar, uiBut *but, wmEvent *event) { uiSearchboxData *data= ar->regiondata; switch(event->type) { case UPARROWKEY: - ui_searchbox_select(ar, -1); + ui_searchbox_select(C, ar, but, -1); break; case DOWNARROWKEY: - ui_searchbox_select(ar, 1); + ui_searchbox_select(C, ar, but, 1); break; case MOUSEMOVE: if(BLI_in_rcti(&ar->winrct, event->x, event->y)) { @@ -491,7 +522,7 @@ void ui_searchbox_event(ARegion *ar, wmEvent *event) if(BLI_in_rcti(&rect, event->x - ar->winrct.xmin, event->y - ar->winrct.ymin)) { if( data->active!= a+1) { data->active= a+1; - ui_searchbox_select(ar, 0); + ui_searchbox_select(C, ar, but, 0); break; } } @@ -502,18 +533,39 @@ void ui_searchbox_event(ARegion *ar, wmEvent *event) } /* ar is the search box itself */ -void ui_searchbox_update(bContext *C, ARegion *ar, uiBut *but) +void ui_searchbox_update(bContext *C, ARegion *ar, uiBut *but, int reset) { uiSearchboxData *data= ar->regiondata; - /* callback */ + /* reset vars */ data->items.totitem= 0; - data->active= 0; + data->items.more= 0; + if(reset==0) + data->items.offset_i= data->items.offset; + else { + data->items.offset_i= data->items.offset= 0; + data->active= 0; + } + + /* callback */ if(but->search_func) but->search_func(C, but->search_arg, but->editstr, &data->items); + if(reset) { + int a; + /* handle case where editstr is equal to one of items */ + for(a=0; aitems.totitem; a++) { + char *cpoin= strchr(data->items.names[a], '|'); + + if(cpoin) cpoin[0]= 0; + if(0==strcmp(but->editstr, data->items.names[a])) + data->active= a+1; + if(cpoin) cpoin[0]= '|'; + } + } + /* validate selected item */ - ui_searchbox_select(ar, 0); + ui_searchbox_select(C, ar, but, 0); ED_region_tag_redraw(ar); } @@ -525,7 +577,8 @@ static void ui_searchbox_region_draw(const bContext *C, ARegion *ar) /* pixel space */ wmOrtho2(-0.01f, ar->winx-0.01f, -0.01f, ar->winy-0.01f); - ui_draw_search_back(U.uistyles.first, NULL, &data->bbox); + if(!data->noback) + ui_draw_search_back(U.uistyles.first, NULL, &data->bbox); /* draw text */ if(data->items.totitem) { @@ -537,6 +590,18 @@ static void ui_searchbox_region_draw(const bContext *C, ARegion *ar) ui_searchbox_butrect(&rect, data, a); ui_draw_menu_item(&data->fstyle, &rect, data->items.names[a], (a+1)==data->active?UI_ACTIVE:0); + + } + /* indicate more */ + if(data->items.more) { + glEnable(GL_BLEND); + UI_icon_draw((data->bbox.xmax-data->bbox.xmin)/2, 8, ICON_TRIA_DOWN); + glDisable(GL_BLEND); + } + if(data->items.offset) { + glEnable(GL_BLEND); + UI_icon_draw((data->bbox.xmax-data->bbox.xmin)/2, data->bbox.ymax-13, ICON_TRIA_UP); + glDisable(GL_BLEND); } } } @@ -585,14 +650,19 @@ ARegion *ui_searchbox_create(bContext *C, ARegion *butregion, uiBut *but) ar->regiondata= data; + /* special case, hardcoded feature, not draw backdrop when called from menus, + assume for design that popup already added it */ + if(but->block->flag & UI_BLOCK_LOOP) + data->noback= 1; + /* compute position */ ofsx= (but->block->panel)? but->block->panel->ofsx: 0; ofsy= (but->block->panel)? but->block->panel->ofsy: 0; - x1f= but->x1; - x2f= but->x2; + x1f= but->x1 - 5; /* align text with button */ + x2f= but->x2 + 5; /* symmetrical */ y2f= but->y1; - y1f= y2f - SEARCH_ITEMS*MENU_BUTTON_HEIGHT - 2*MENU_SEPR_HEIGHT; + y1f= y2f - uiSearchBoxhHeight(); /* minimal width */ if(x2f - x1f < 180) x2f= x1f+180; // XXX arbitrary diff --git a/source/blender/editors/interface/interface_widgets.c b/source/blender/editors/interface/interface_widgets.c index 1b9ab076b4a..e3f850ddfd4 100644 --- a/source/blender/editors/interface/interface_widgets.c +++ b/source/blender/editors/interface/interface_widgets.c @@ -670,7 +670,10 @@ static void widget_draw_icon(uiBut *but, BIFIconID icon, int blend, rcti *rect) } } else if (but->block->flag & UI_BLOCK_LOOP) { - xs= rect->xmin+1; + if(but->type==SEARCH_MENU) + xs= rect->xmin+4; + else + xs= rect->xmin+1; } else if ((but->type==ICONROW) || (but->type==ICONTEXTROW)) { xs= rect->xmin+3; @@ -1468,7 +1471,7 @@ static void widget_textbut(uiWidgetColors *wcol, rcti *rect, int state, int roun widget_init(&wtb); /* half rounded */ - round_box_edges(&wtb, roundboxalign, rect, 4.0f); + round_box_edges(&wtb, roundboxalign, rect, 5.0f); widgetbase_draw(&wtb, wcol); diff --git a/source/blender/windowmanager/intern/wm_operators.c b/source/blender/windowmanager/intern/wm_operators.c index 418a231a7e9..3b6d605df61 100644 --- a/source/blender/windowmanager/intern/wm_operators.c +++ b/source/blender/windowmanager/intern/wm_operators.c @@ -423,7 +423,10 @@ static uiBlock *wm_block_search_menu(bContext *C, ARegion *ar, void *arg_op) but= uiDefSearchBut(block, search, 0, ICON_VIEWZOOM, 256, 10, 10, 180, 19, ""); uiButSetSearchFunc(but, operator_search_cb, NULL, operator_call_cb); - uiPopupBoundsBlock(block, 0.0f, 0, -20); /* move it downwards, mouse over button */ + /* fake button, it holds space for search items */ + uiDefBut(block, LABEL, 0, "", 10, 10 - uiSearchBoxhHeight(), 180, uiSearchBoxhHeight(), NULL, 0, 0, 0, 0, NULL); + + uiPopupBoundsBlock(block, 6.0f, 0, -20); /* move it downwards, mouse over button */ uiEndBlock(C, block); event= *(win->eventstate); /* XXX huh huh? make api call */ From 07b3e41e18611cc5c7206d1400303104f73054fc Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 5 Jun 2009 16:11:35 +0000 Subject: [PATCH 33/35] Blender file selector support for setting multiple selected files/dirs which operators can use. This allows the sequencers Add-Image strip to work like it does in 2.4x. - as well as setting the "filename" operator property, operators can have collections called "files" and "dirs" which are set when available. - RNA_OperatorFileListElement as new collection type, its a bit redundant since each item only has a "name" property but its needed since we don't have a string array type. - the file selector now prints operators it runs. Tested with python, adding a list of images works to the sequencer works. bpy.ops.SEQUENCER_OT_image_strip_add(name="MyImages", start_frame=54, channel=2, filename="/somedir/", replace_sel=True, files=[{"name":"test1.png"}, {"name":"test2.png"}]) --- source/blender/editors/space_file/file_ops.c | 30 +++++++++++++++++ .../editors/space_sequencer/sequencer_add.c | 32 +++++++++++-------- source/blender/makesrna/RNA_access.h | 1 + source/blender/makesrna/intern/rna_access.c | 1 - source/blender/makesrna/intern/rna_wm.c | 16 ++++++++++ source/blender/python/intern/bpy_interface.c | 1 + .../windowmanager/intern/wm_event_system.c | 7 +++- 7 files changed, 72 insertions(+), 16 deletions(-) diff --git a/source/blender/editors/space_file/file_ops.c b/source/blender/editors/space_file/file_ops.c index 94c023207f5..01f94741f59 100644 --- a/source/blender/editors/space_file/file_ops.c +++ b/source/blender/editors/space_file/file_ops.c @@ -480,6 +480,36 @@ int file_exec(bContext *C, wmOperator *unused) strcat(name, sfile->params->file); RNA_string_set(op->ptr, "filename", name); + /* some ops have multiple files to select */ + { + PointerRNA itemptr; + int i, numfiles = filelist_numfiles(sfile->files); + struct direntry *file; + if(RNA_struct_find_property(op->ptr, "files")) { + for (i=0; ifiles, i); + if(file->flags & ACTIVE) { + if ((file->type & S_IFDIR)==0) { + RNA_collection_add(op->ptr, "files", &itemptr); + RNA_string_set(&itemptr, "name", file->relname); + } + } + } + } + + if(RNA_struct_find_property(op->ptr, "dirs")) { + for (i=0; ifiles, i); + if(file->flags & ACTIVE) { + if ((file->type & S_IFDIR)) { + RNA_collection_add(op->ptr, "dirs", &itemptr); + RNA_string_set(&itemptr, "name", file->relname); + } + } + } + } + } + fsmenu_insert_entry(fsmenu_get(), FS_CATEGORY_RECENT, sfile->params->dir,0, 1); BLI_make_file_string(G.sce, name, BLI_gethome(), ".Bfs"); fsmenu_write_file(fsmenu_get(), name); diff --git a/source/blender/editors/space_sequencer/sequencer_add.c b/source/blender/editors/space_sequencer/sequencer_add.c index 6e38ff053be..8373f588fb2 100644 --- a/source/blender/editors/space_sequencer/sequencer_add.c +++ b/source/blender/editors/space_sequencer/sequencer_add.c @@ -423,9 +423,7 @@ static int sequencer_add_image_strip_exec(bContext *C, wmOperator *op) Scene *scene= CTX_data_scene(C); Editing *ed= seq_give_editing(scene, TRUE); - - int tot_images= 1; //XXX FIXME, we need string arrays! - //int a; + int tot_images; char filename[FILE_MAX]; @@ -440,26 +438,30 @@ static int sequencer_add_image_strip_exec(bContext *C, wmOperator *op) RNA_string_get(op->ptr, "filename", filename); - seq = alloc_sequence(ed->seqbasep, start_frame, channel); - + seq = alloc_sequence(ed->seqbasep, start_frame, channel); seq->type= SEQ_IMAGE; /* basic defaults */ seq->strip= strip= MEM_callocN(sizeof(Strip), "strip"); - strip->len = seq->len = tot_images; + BLI_split_dirfile_basic(filename, strip->dir, NULL); + + tot_images= RNA_property_collection_length(op->ptr, RNA_struct_find_property(op->ptr, "files")); + + strip->len = seq->len = tot_images?tot_images:1; strip->us= 1; strip->stripdata= se= MEM_callocN(seq->len*sizeof(StripElem), "stripelem"); - - BLI_split_dirfile_basic(filename, strip->dir, se->name); // XXX se->name assignment should be moved into the loop below - -#if 0 // XXX - for(a=0; alen; a++) { - strncpy(se->name, name, FILE_MAXFILE-1); - se++; + if(tot_images) { + RNA_BEGIN(op->ptr, itemptr, "files") { + RNA_string_get(&itemptr, "name", se->name); + se++; + } + RNA_END; + } + else { + BLI_split_dirfile_basic(filename, NULL, se->name); } -#endif RNA_string_get(op->ptr, "name", seq->name); @@ -507,6 +509,8 @@ void SEQUENCER_OT_image_strip_add(struct wmOperatorType *ot) ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; sequencer_generic_props__internal(ot, SEQPROP_STARTFRAME|SEQPROP_FILENAME); + + RNA_def_collection_runtime(ot->srna, "files", &RNA_OperatorFileListElement, "Files", ""); } diff --git a/source/blender/makesrna/RNA_access.h b/source/blender/makesrna/RNA_access.h index 4df5aa67104..eb355a34f9f 100644 --- a/source/blender/makesrna/RNA_access.h +++ b/source/blender/makesrna/RNA_access.h @@ -196,6 +196,7 @@ extern StructRNA RNA_NorController; extern StructRNA RNA_Object; extern StructRNA RNA_ObstacleFluidSettings; extern StructRNA RNA_Operator; +extern StructRNA RNA_OperatorFileListElement; extern StructRNA RNA_OperatorMousePath; extern StructRNA RNA_OperatorProperties; extern StructRNA RNA_OperatorStrokeElement; diff --git a/source/blender/makesrna/intern/rna_access.c b/source/blender/makesrna/intern/rna_access.c index 91b46e8e3d7..e762d1626f5 100644 --- a/source/blender/makesrna/intern/rna_access.c +++ b/source/blender/makesrna/intern/rna_access.c @@ -2214,7 +2214,6 @@ char *RNA_pointer_as_string(PointerRNA *ptr) cstring = RNA_property_as_string(&iter.ptr, prop); BLI_dynstr_appendf(dynstr, "\"%s\":%s", propname, cstring); MEM_freeN(cstring); - first_time= 0; } RNA_property_collection_end(&iter); diff --git a/source/blender/makesrna/intern/rna_wm.c b/source/blender/makesrna/intern/rna_wm.c index a8f63566349..b4d2cb35121 100644 --- a/source/blender/makesrna/intern/rna_wm.c +++ b/source/blender/makesrna/intern/rna_wm.c @@ -133,6 +133,21 @@ static void rna_def_operator_utils(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Time", "Time of mouse location."); } +static void rna_def_operator_filelist_element(BlenderRNA *brna) +{ + StructRNA *srna; + PropertyRNA *prop; + + srna= RNA_def_struct(brna, "OperatorFileListElement", "IDPropertyGroup"); + RNA_def_struct_ui_text(srna, "Operator File List Element", ""); + + + prop= RNA_def_property(srna, "name", PROP_STRING, PROP_NONE); + RNA_def_property_flag(prop, PROP_IDPROPERTY); + RNA_def_property_ui_text(prop, "Name", "the name of a file or directory within a file list"); +} + + static void rna_def_windowmanager(BlenderRNA *brna) { StructRNA *srna; @@ -151,6 +166,7 @@ void RNA_def_wm(BlenderRNA *brna) { rna_def_operator(brna); rna_def_operator_utils(brna); + rna_def_operator_filelist_element(brna); rna_def_windowmanager(brna); } diff --git a/source/blender/python/intern/bpy_interface.c b/source/blender/python/intern/bpy_interface.c index 999f6d8e9cb..7b3a67ebff5 100644 --- a/source/blender/python/intern/bpy_interface.c +++ b/source/blender/python/intern/bpy_interface.c @@ -19,6 +19,7 @@ #include "bpy_rna.h" #include "bpy_operator.h" #include "bpy_ui.h" +#include "bpy_util.h" #include "DNA_anim_types.h" #include "DNA_space_types.h" diff --git a/source/blender/windowmanager/intern/wm_event_system.c b/source/blender/windowmanager/intern/wm_event_system.c index fc0f1496c6a..53f70f6ab8f 100644 --- a/source/blender/windowmanager/intern/wm_event_system.c +++ b/source/blender/windowmanager/intern/wm_event_system.c @@ -826,7 +826,12 @@ static int wm_handler_fileselect_call(bContext *C, ListBase *handlers, wmEventHa uiPupMenuSaveOver(C, handler->op, path); } else { - handler->op->type->exec(C, handler->op); + int retval= handler->op->type->exec(C, handler->op); + + if (retval & OPERATOR_FINISHED) + if(G.f & G_DEBUG) + wm_operator_print(handler->op); + WM_operator_free(handler->op); } From 8cea65a3233b9663f53e52d0ec0c8ba780acb419 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 5 Jun 2009 19:43:33 +0000 Subject: [PATCH 34/35] fix for printing operator collection values, also set some freed pointers to NULL --- source/blender/makesrna/intern/rna_access.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/source/blender/makesrna/intern/rna_access.c b/source/blender/makesrna/intern/rna_access.c index e762d1626f5..64c826d2c1e 100644 --- a/source/blender/makesrna/intern/rna_access.c +++ b/source/blender/makesrna/intern/rna_access.c @@ -1505,6 +1505,7 @@ void *rna_iterator_listbase_get(CollectionPropertyIterator *iter) void rna_iterator_listbase_end(CollectionPropertyIterator *iter) { MEM_freeN(iter->internal); + iter->internal= NULL; } void rna_iterator_array_begin(CollectionPropertyIterator *iter, void *ptr, int itemsize, int length, IteratorSkipFunc skip) @@ -1561,6 +1562,7 @@ void *rna_iterator_array_dereference_get(CollectionPropertyIterator *iter) void rna_iterator_array_end(CollectionPropertyIterator *iter) { MEM_freeN(iter->internal); + iter->internal= NULL; } /* RNA Path - Experiment */ @@ -2198,9 +2200,8 @@ char *RNA_pointer_as_string(PointerRNA *ptr) BLI_dynstr_append(dynstr, "{"); iterprop= RNA_struct_iterator_property(ptr->type); - RNA_property_collection_begin(ptr, iterprop, &iter); - for(; iter.valid; RNA_property_collection_next(&iter)) { + for(RNA_property_collection_begin(ptr, iterprop, &iter); iter.valid; RNA_property_collection_next(&iter)) { prop= iter.ptr.data; propname = RNA_property_identifier(prop); @@ -2211,7 +2212,7 @@ char *RNA_pointer_as_string(PointerRNA *ptr) BLI_dynstr_append(dynstr, ", "); first_time= 0; - cstring = RNA_property_as_string(&iter.ptr, prop); + cstring = RNA_property_as_string(ptr, prop); BLI_dynstr_appendf(dynstr, "\"%s\":%s", propname, cstring); MEM_freeN(cstring); } @@ -2409,6 +2410,7 @@ ParameterList *RNA_parameter_list_create(PointerRNA *ptr, FunctionRNA *func) void RNA_parameter_list_free(ParameterList *parms) { MEM_freeN(parms->data); + parms->data= NULL; parms->func= NULL; From 880c43ad5a53203b64a6d6a51e239a4bfc6ed540 Mon Sep 17 00:00:00 2001 From: Janne Karhu Date: Fri, 5 Jun 2009 23:59:33 +0000 Subject: [PATCH 35/35] First new particle code: -Many things not yet working properly :) -Experimental new (hopefully more logical) categorization of buttons, feedback on this is very welcome. -Separate render & draw types, for example now there is actually a render option "halo" instead of all the different point draw types. -Particles get recalculated only from buttons that actually change something that has to be recalculated, for example changing visualization doesn't reset particles any more. -Boid physics buttons are still missing as I'm currently redoing the whole boids code. -Point caching is still very wip, so baking is not possible for example, but I added a few cache baking flags for rna that were/will be needed for particle buttons logic. --- release/ui/buttons_particle.py | 570 +++++++++++++++++- source/blender/blenkernel/BKE_particle.h | 2 +- source/blender/blenkernel/intern/modifier.c | 3 +- source/blender/blenkernel/intern/particle.c | 55 +- .../blenkernel/intern/particle_system.c | 36 +- source/blender/blenkernel/intern/pointcache.c | 2 + source/blender/blenloader/intern/readfile.c | 20 +- source/blender/editors/physics/editparticle.c | 2 +- .../editors/sculpt_paint/paint_vertex.c | 2 +- .../blender/editors/space_view3d/drawobject.c | 7 +- .../editors/space_view3d/space_view3d.c | 1 + source/blender/makesdna/DNA_particle_types.h | 23 +- .../makesrna/intern/rna_object_force.c | 7 + source/blender/makesrna/intern/rna_particle.c | 380 ++++++++++-- .../render/intern/source/convertblender.c | 14 +- source/blender/windowmanager/WM_types.h | 1 + 16 files changed, 996 insertions(+), 129 deletions(-) diff --git a/release/ui/buttons_particle.py b/release/ui/buttons_particle.py index 737aa1a4393..da04fad4adc 100644 --- a/release/ui/buttons_particle.py +++ b/release/ui/buttons_particle.py @@ -1,25 +1,589 @@ import bpy +def particle_panel_enabled(psys): + return psys.point_cache.baked==False and psys.editable==False + +def particle_panel_poll(context): + psys = context.particle_system + type = psys.settings.type + return psys != None and (type=='EMITTER' or type=='REACTOR'or type=='HAIR') + class ParticleButtonsPanel(bpy.types.Panel): __space_type__ = "BUTTONS_WINDOW" __region_type__ = "WINDOW" __context__ = "particle" def poll(self, context): - return (context.particle_system != None) + psys = context.particle_system + type = psys.settings.type + return psys != None and (type=='EMITTER' or type=='REACTOR'or type=='HAIR') class PARTICLE_PT_particles(ParticleButtonsPanel): __idname__= "PARTICLE_PT_particles" - __label__ = "Particles" + __label__ = "ParticleSystem" + + def poll(self, context): + return (context.particle_system != None) + + def draw(self, context): + layout = self.layout + + psys = context.particle_system + part = psys.settings + + #row = layout.row() + #row.itemL(text="Particle system datablock") + #row.itemL(text="Viewport") + #row.itemL(text="Render") + + type = psys.settings.type + + if(type!='EMITTER' and type!='REACTOR' and type!='HAIR'): + layout.itemL(text="No settings for fluid particles") + return + + row = layout.row() + row.enabled = particle_panel_enabled(psys) + row.itemR(part, "type") + row.itemR(psys, "seed") + + row = layout.row() + if part.type=='HAIR': + if psys.editable==True: + row.itemO("PARTICLE_OT_editable_set", text="Free Edit") + else: + row.itemO("PARTICLE_OT_editable_set", text="Make Editable") + subrow = row.row() + subrow.enabled = particle_panel_enabled(psys) + subrow.itemR(part, "hair_step") + elif part.type=='REACTOR': + row.itemR(psys, "reactor_target_object") + row.itemR(psys, "reactor_target_particle_system", text="Particle System") + +class PARTICLE_PT_emission(ParticleButtonsPanel): + __idname__= "PARTICLE_PT_emission" + __label__ = "Emission" + + def draw(self, context): + layout = self.layout + + psys = context.particle_system + part = psys.settings + + layout.enabled = particle_panel_enabled(psys) + + row = layout.row() + #col.itemL(text="TODO: Rate instead of amount") + row.itemR(part, "amount") + row.itemL(text="") + + split = layout.split() + + col = split.column(align=True) + col.itemR(part, "start") + col.itemR(part, "end") + + col = split.column(align=True) + col.itemR(part, "lifetime") + col.itemR(part, "random_lifetime", slider=True) + +class PARTICLE_PT_cache(ParticleButtonsPanel): + __idname__= "PARTICLE_PT_cache" + __label__ = "Cache" + + def poll(self, context): + psys = context.particle_system + type = psys.settings.type + return psys != None and (type=='EMITTER' or type== 'REACTOR') def draw(self, context): layout = self.layout psys = context.particle_system part = psys.settings + cache = psys.point_cache + + #if cache.baked==True: + #layout.itemO("PARTICLE_OT_free_bake", text="BAKE") + #else: + row = layout.row() + #row.itemO("PARTICLE_OT_bake", text="BAKE") + row.itemR(cache, "start_frame") + row.itemR(cache, "end_frame") + + #layout.row().itemL(text="No simulation frames in disk cache.") + + +class PARTICLE_PT_initial(ParticleButtonsPanel): + __idname__= "PARTICLE_PT_initial" + __label__ = "Initial values" - layout.itemR(part, "amount") + def draw(self, context): + layout = self.layout + psys = context.particle_system + part = psys.settings + + layout.enabled = particle_panel_enabled(psys) + + layout.row().itemL(text="Location from:") + + box = layout.box() + row = box.row() + row.itemR(part, "trand") + + col = row.column() + col.row().itemR(part, "emit_from", expand=True) + + if part.emit_from=='FACE' or part.emit_from=='VOLUME': + row = box.row() + + if part.distribution!='GRID': + row.itemR(part, "even_distribution") + else: + row.itemL(text="") + + row.itemR(part, "distribution", expand=True) + + row = box.row() + + if part.distribution=='JIT': + row.itemR(part, "userjit", text="Particles/Face") + row.itemR(part, "jitter_factor", text="Jittering Amount", slider=True) + elif part.distribution=='GRID': + row.itemR(part, "grid_resolution") + + #layout.row().itemL(text="") + + layout.row().itemL(text="Velocity:") + box = layout.box() + row = box.row() + col = row.column() + col.itemR(part, "normal_factor") + if part.emit_from=='PARTICLE': + col.itemR(part, "particle_factor") + else: + col.itemR(part, "object_factor", slider=True) + col.itemR(part, "random_factor") + + col = row.column(align=True) + col.itemL(text="TODO:") + col.itemL(text="Object aligned") + col.itemL(text="direction: X, Y, Z") + + row = box.row() + col = row.column(align=True) + col.itemR(part, "tangent_factor") + col.itemR(part, "tangent_phase", slider=True) + + col = row.column(align=True) + if part.type=='REACTOR': + col.itemR(part, "reactor_factor") + col.itemR(part, "reaction_shape", slider=True) + else: + col.itemL(text="") + + layout.row().itemL(text="Rotation:") + box = layout.box() + box.row().itemR(part, "rotation_dynamic") + + row = box.row() + col = row.column(align=True) + col.itemR(part, "rotation_mode", text="") + col.itemR(part, "random_rotation_factor", slider=True) + col = row.column(align=True) + col.itemR(part, "phase_factor", slider=True) + col.itemR(part, "random_phase_factor", text="Random", slider=True) + + + layout.row().itemL(text="Angular velocity:") + + box = layout.box() + row = box.row() + row.itemR(part, "angular_velocity_mode", expand=True) + row.itemR(part, "angular_velocity_factor", text="") + +class PARTICLE_PT_physics(ParticleButtonsPanel): + __idname__= "PARTICLE_PT_physics" + __label__ = "Physics" + + def draw(self, context): + layout = self.layout + + psys = context.particle_system + part = psys.settings + + layout.enabled = layout.enabled = particle_panel_enabled(psys) + + layout.itemR(part, "effector_group") + + layout.itemL(text="General:") + box = layout.box() + row = box.row() + col = row.column(align=True) + col.itemR(part, "particle_size") + col.itemR(part, "random_size", slider=True) + col = row.column(align=True) + col.itemR(part, "mass") + col.itemR(part, "sizemass", text="Multiply mass with size") + + layout.row().itemL(text="") + + row = layout.row() + row.itemL(text="Physics Type:") + row.itemR(part, "physics_type", expand=True) + + if part.physics_type != 'NO': + box = layout.box() + row = box.row() + + if part.physics_type == 'NEWTON': + row.itemR(part, "integrator") + row = box.row() + col = row.column(align=True) + col.itemL(text="Forces:") + col.itemR(part, "brownian_factor") + col.itemR(part, "drag_factor", slider=True) + col.itemR(part, "damp_factor", slider=True) + + row.column().itemR(part, "acceleration") + elif part.physics_type == 'KEYED': + row.itemR(psys, "keyed_first") + if psys.keyed_first==True: + row.itemR(psys, "timed_keys", text="Key timing") + else: + row.itemR(part, "keyed_time") + + row = box.row() + row.itemL(text="Next key from object:") + row.itemR(psys, "keyed_object", text="") + row.itemR(psys, "keyed_particle_system") + + if part.physics_type=='NEWTON' or part.physics_type=='BOIDS': + row = box.row() + row.itemR(part, "size_deflect") + row.itemR(part, "die_on_collision") + row.itemR(part, "sticky") + +class PARTICLE_PT_render(ParticleButtonsPanel): + __idname__= "PARTICLE_PT_render" + __label__ = "Render" + + def poll(self, context): + return (context.particle_system != None) + + def draw(self, context): + layout = self.layout + + psys = context.particle_system + part = psys.settings + + row = layout.row() + row.itemR(part, "material") + col = row.column() + col.itemR(part, "emitter"); + col.itemR(part, "parent"); + col = row.column() + col.itemR(part, "unborn"); + col.itemR(part, "died"); + + row = layout.row() + row.itemR(part, "ren_as", expand=True) + + row = layout.row(align=True) + + if part.ren_as == 'LINE': + row.itemR(part, "line_length_tail") + row.itemR(part, "line_length_head") + row.itemR(part, "velocity_length") + elif part.ren_as == 'PATH': + + if (part.type!='HAIR' and psys.point_cache.baked==False): + box = layout.box() + box.itemL(text="Baked or keyed particles needed for correct rendering.") + return + + row.itemR(part, "hair_bspline") + row.itemR(part, "render_step", text="Steps") + + row = layout.row() + row.itemR(part, "abs_length") + col = row.column(align=True) + col.itemR(part, "absolute_length") + col.itemR(part, "random_length", slider=True) + + #row = layout.row() + #row.itemR(part, "timed_path") + #col = row.column(align=True) + #col.active = part.timed_path == True + #col.itemR(part, "line_length_tail", text="Start") + #col.itemR(part, "line_length_head", text="End") + + row = layout.row() + col = row.column() + col.itemR(part, "render_strand") + + subrow = col.row() + subrow.active = part.render_strand == False + subrow.itemR(part, "render_adaptive") + col = row.column(align=True) + subrow = col.row() + subrow.active = part.render_adaptive or part.render_strand == True + subrow.itemR(part, "adaptive_angle") + subrow = col.row() + subrow.active = part.render_adaptive == True and part.render_strand == False + subrow.itemR(part, "adaptive_pix") + + if part.type=='HAIR' and part.render_strand==True and part.child_type=='FACES': + layout.itemR(part, "enable_simplify") + if part.enable_simplify==True: + box = layout.box() + row = box.row() + row.itemR(part, "simplify_refsize") + row.itemR(part, "simplify_rate") + row.itemR(part, "simplify_transition") + row = box.row() + row.itemR(part, "viewport") + subrow = row.row() + subrow.active = part.viewport==True + subrow.itemR(part, "simplify_viewport") + + + elif part.ren_as == 'OBJECT': + row.itemR(part, "dupli_object") + elif part.ren_as == 'GROUP': + split = layout.split() + col = split.column() + row = col.row() + row.itemR(part, "whole_group") + subcol = row.column() + subcol.active = part.whole_group == False + subcol.itemR(part, "rand_group") + split.column().itemR(part, "dupli_group", text="") + elif part.ren_as == 'BILLBOARD': + row.itemL(text="Align:") + row.itemR(part, "billboard_lock", text="Lock") + row = layout.row() + row.itemR(part, "billboard_align", expand=True) + row = layout.row() + row.itemR(part, "billboard_object") + + row = layout.row() + col = row.column(align=True) + col.itemL(text="Tilt:") + col.itemR(part, "billboard_tilt", text="Angle", slider=True) + col.itemR(part, "billboard_random_tilt", slider=True) + col = row.column() + col.itemR(part, "billboard_offset") + + row = layout.row() + row.itemR(psys, "billboard_normal_uv") + row = layout.row() + row.itemR(psys, "billboard_time_index_uv") + + row = layout.row() + row.itemL(text="Split uv's:") + row.itemR(part, "billboard_uv_split", text="Number of splits") + row = layout.row() + row.itemR(psys, "billboard_split_uv") + row = layout.row() + row.itemL(text="Animate:") + row.itemR(part, "billboard_animation", expand=True) + row.itemL(text="Offset:") + row.itemR(part, "billboard_split_offset", expand=True) + +class PARTICLE_PT_draw(ParticleButtonsPanel): + __idname__= "PARTICLE_PT_draw" + __label__ = "Draw" + + def poll(self, context): + return (context.particle_system != None) + + def draw(self, context): + layout = self.layout + + psys = context.particle_system + part = psys.settings + + row = layout.row() + row.itemR(part, "draw_as", expand=True) + + if part.draw_as=='NONE' or (part.ren_as=='NONE' and part.draw_as=='RENDER'): + return + + path = (part.ren_as=='PATH' and part.draw_as=='RENDER') or part.draw_as=='PATH' + + if path and part.type!='HAIR' and psys.point_cache.baked==False: + box = layout.box() + box.itemL(text="Baked or keyed particles needed for correct drawing.") + return + + row = layout.row() + row.itemR(part, "display", slider=True) + if part.draw_as!='RENDER' or part.ren_as=='HALO': + row.itemR(part, "draw_size") + else: + row.itemL(text="") + + row = layout.row() + col = row.column() + col.itemR(part, "show_size") + col.itemR(part, "velocity") + col.itemR(part, "num") + if part.physics_type == 'BOIDS': + col.itemR(part, "draw_health") + + col = row.column() + if (path): + box = col.box() + box.itemR(part, "draw_step") + else: + col.itemR(part, "material_color", text="Use material color") + subcol = col.column() + subcol.active = part.material_color==False + #subcol.itemL(text="color") + #subcol.itemL(text="Override material color") + + +class PARTICLE_PT_children(ParticleButtonsPanel): + __idname__= "PARTICLE_PT_children" + __label__ = "Children" + + def draw(self, context): + layout = self.layout + + psys = context.particle_system + part = psys.settings + + layout.row().itemR(part, "child_type", expand=True) + + if part.child_type=='NONE': + return + + row = layout.row() + + col = row.column(align=True) + col.itemR(part, "child_nbr", text="Draw") + col.itemR(part, "rendered_child_nbr", text="Render") + + col = row.column(align=True) + + if part.child_type=='FACES': + col.itemR(part, "virtual_parents", slider=True) + else: + col.itemR(part, "child_radius", text="Radius") + col.itemR(part, "child_roundness", text="Roundness", slider=True) + + col = row.column(align=True) + col.itemR(part, "child_size", text="Size") + col.itemR(part, "child_random_size", text="Random") + + layout.row().itemL(text="Effects:") + + row = layout.row() + + col = row.column(align=True) + col.itemR(part, "clump_factor", slider=True) + col.itemR(part, "clumppow", slider=True) + + col = row.column(align=True) + col.itemR(part, "rough_endpoint") + col.itemR(part, "rough_end_shape") + + row = layout.row() + + col = row.column(align=True) + col.itemR(part, "rough1") + col.itemR(part, "rough1_size") + + col = row.column(align=True) + col.itemR(part, "rough2") + col.itemR(part, "rough2_size") + col.itemR(part, "rough2_thres", slider=True) + + layout.row().itemL(text="Kink:") + layout.row().itemR(part, "kink", expand=True) + + row = layout.row() + row.itemR(part, "kink_amplitude") + row.itemR(part, "kink_frequency") + row.itemR(part, "kink_shape", slider=True) + + + +class PARTICLE_PT_vertexgroups(ParticleButtonsPanel): + __idname__= "PARTICLE_PT_vertexgroups" + __label__ = "Vertexgroups" + + def draw(self, context): + layout = self.layout + + psys = context.particle_system + part = psys.settings + + layout.itemL(text="Nothing here yet.") + + #row = layout.row() + #row.itemL(text="Vertex Group") + #row.itemL(text="Negate") + + + #row = layout.row() + #row.itemR(psys, "vertex_group_density") + #row.itemR(psys, "vertex_group_density_negate", text="") + + #row = layout.row() + #row.itemR(psys, "vertex_group_velocity") + #row.itemR(psys, "vertex_group_velocity_negate", text="") + + #row = layout.row() + #row.itemR(psys, "vertex_group_length") + #row.itemR(psys, "vertex_group_length_negate", text="") + + #row = layout.row() + #row.itemR(psys, "vertex_group_clump") + #row.itemR(psys, "vertex_group_clump_negate", text="") + + #row = layout.row() + #row.itemR(psys, "vertex_group_kink") + #row.itemR(psys, "vertex_group_kink_negate", text="") + + #row = layout.row() + #row.itemR(psys, "vertex_group_roughness1") + #row.itemR(psys, "vertex_group_roughness1_negate", text="") + + #row = layout.row() + #row.itemR(psys, "vertex_group_roughness2") + #row.itemR(psys, "vertex_group_roughness2_negate", text="") + + #row = layout.row() + #row.itemR(psys, "vertex_group_roughness_end") + #row.itemR(psys, "vertex_group_roughness_end_negate", text="") + + #row = layout.row() + #row.itemR(psys, "vertex_group_size") + #row.itemR(psys, "vertex_group_size_negate", text="") + + #row = layout.row() + #row.itemR(psys, "vertex_group_tangent") + #row.itemR(psys, "vertex_group_tangent_negate", text="") + + #row = layout.row() + #row.itemR(psys, "vertex_group_rotation") + #row.itemR(psys, "vertex_group_rotation_negate", text="") + + #row = layout.row() + #row.itemR(psys, "vertex_group_field") + #row.itemR(psys, "vertex_group_field_negate", text="") + bpy.types.register(PARTICLE_PT_particles) +bpy.types.register(PARTICLE_PT_cache) +bpy.types.register(PARTICLE_PT_emission) +bpy.types.register(PARTICLE_PT_initial) +bpy.types.register(PARTICLE_PT_physics) +bpy.types.register(PARTICLE_PT_render) +bpy.types.register(PARTICLE_PT_draw) +bpy.types.register(PARTICLE_PT_children) +bpy.types.register(PARTICLE_PT_vertexgroups) diff --git a/source/blender/blenkernel/BKE_particle.h b/source/blender/blenkernel/BKE_particle.h index db4d948216e..4efd9a7f8ba 100644 --- a/source/blender/blenkernel/BKE_particle.h +++ b/source/blender/blenkernel/BKE_particle.h @@ -251,7 +251,7 @@ struct ParticleSystemModifierData *psys_get_modifier(struct Object *ob, struct P struct ParticleSettings *psys_new_settings(char *name, struct Main *main); struct ParticleSettings *psys_copy_settings(struct ParticleSettings *part); -void psys_flush_settings(struct Scene *scene, struct ParticleSettings *part, int event, int hair_recalc); +void psys_flush_particle_settings(struct Scene *scene, struct ParticleSettings *part, int recalc); void make_local_particlesettings(struct ParticleSettings *part); struct LinkNode *psys_using_settings(struct Scene *scene, struct ParticleSettings *part, int flush_update); diff --git a/source/blender/blenkernel/intern/modifier.c b/source/blender/blenkernel/intern/modifier.c index 5610db355e1..ec8d28aee6c 100644 --- a/source/blender/blenkernel/intern/modifier.c +++ b/source/blender/blenkernel/intern/modifier.c @@ -6347,8 +6347,7 @@ static void particleSystemModifier_deformVerts( psmd->dm->getNumFaces(psmd->dm)!=psmd->totdmface){ /* in file read dm hasn't really changed but just wasn't saved in file */ - psys->recalc |= PSYS_RECALC_HAIR; - psys->recalc |= PSYS_DISTR; + psys->recalc |= PSYS_RECALC_RESET; psmd->flag |= eParticleSystemFlag_DM_changed; psmd->totdmvert= psmd->dm->getNumVerts(psmd->dm); diff --git a/source/blender/blenkernel/intern/particle.c b/source/blender/blenkernel/intern/particle.c index 7d998a481f6..6cef9959d8b 100644 --- a/source/blender/blenkernel/intern/particle.c +++ b/source/blender/blenkernel/intern/particle.c @@ -348,8 +348,17 @@ void free_hair(ParticleSystem *psys, int softbody) } void free_keyed_keys(ParticleSystem *psys) { - if(psys->particles && psys->particles->keys) + if(psys->particles && psys->particles->keys) { + ParticleData *pa; + int i, totpart=psys->totpart; + MEM_freeN(psys->particles->keys); + + for(i=0, pa=psys->particles; ikeys = NULL; + pa->totkey = 0; + } + } } void free_child_path_cache(ParticleSystem *psys) { @@ -1739,12 +1748,12 @@ static void do_path_effectors(Scene *scene, Object *ob, ParticleSystem *psys, in Normalize(force); + VECADDFAC(ca->co, (ca-1)->co, force, *length); + if(k < steps) { VecSubf(vec, (ca+1)->co, ca->co); *length = VecLength(vec); } - - VECADDFAC(ca->co, (ca-1)->co, force, *length); } static int check_path_length(int k, ParticleCacheKey *keys, ParticleCacheKey *state, float max_length, float *cur_length, float length, float *dvec) { @@ -3052,42 +3061,22 @@ void make_local_particlesettings(ParticleSettings *part) } } -/* should be integrated to depgraph signals */ -void psys_flush_settings(struct Scene *scene, ParticleSettings *part, int event, int hair_recalc) +void psys_flush_particle_settings(Scene *scene, ParticleSettings *part, int recalc) { - Base *base; - Object *ob, *tob; + Base *base = scene->base.first; ParticleSystem *psys; int flush; - /* update all that have same particle settings */ - for(base = scene->base.first; base; base= base->next) { - if(base->object->particlesystem.first) { - ob=base->object; - flush=0; - for(psys=ob->particlesystem.first; psys; psys=psys->next){ - if(psys->part==part){ - psys->recalc |= event; - if(hair_recalc) - psys->recalc |= PSYS_RECALC_HAIR; - flush++; - } - else if(psys->part->type==PART_REACTOR){ - ParticleSystem *tpsys; - tob=psys->target_ob; - if(tob==0) - tob=ob; - tpsys=BLI_findlink(&tob->particlesystem,psys->target_psys-1); - - if(tpsys && tpsys->part==part){ - psys->recalc |= event; - flush++; - } - } + for(base = scene->base.first; base; base = base->next) { + flush = 0; + for(psys = base->object->particlesystem.first; psys; psys=psys->next) { + if(psys->part == part) { + psys->recalc |= recalc; + flush++; } - if(flush) - DAG_object_flush_update(scene, ob, OB_RECALC_DATA); } + if(flush) + DAG_object_flush_update(scene, base->object, OB_RECALC_DATA); } } diff --git a/source/blender/blenkernel/intern/particle_system.c b/source/blender/blenkernel/intern/particle_system.c index f8b1852b728..f097af279b6 100644 --- a/source/blender/blenkernel/intern/particle_system.c +++ b/source/blender/blenkernel/intern/particle_system.c @@ -4173,10 +4173,10 @@ static void psys_update_path_cache(Scene *scene, Object *ob, ParticleSystemModif ParticleEditSettings *pset=&scene->toolsettings->particle; int distr=0,alloc=0; - if((psys->part->childtype && psys->totchild != get_psys_tot_child(scene, psys)) || psys->recalc&PSYS_ALLOC) + if((psys->part->childtype && psys->totchild != get_psys_tot_child(scene, psys)) || psys->recalc&PSYS_RECALC_RESET) alloc=1; - if(alloc || psys->recalc&PSYS_DISTR || (psys->vgroup[PSYS_VG_DENSITY] && (G.f & G_WEIGHTPAINT))) + if(alloc || psys->recalc&PSYS_RECALC_RESET || (psys->vgroup[PSYS_VG_DENSITY] && (G.f & G_WEIGHTPAINT))) distr=1; if(distr){ @@ -4194,8 +4194,9 @@ static void psys_update_path_cache(Scene *scene, Object *ob, ParticleSystemModif } } - if((part->type==PART_HAIR || psys->flag&PSYS_KEYED) && (psys_in_edit_mode(scene, psys) - || (part->type==PART_HAIR || part->draw_as==PART_DRAW_PATH))){ + if((part->type==PART_HAIR || psys->flag&PSYS_KEYED) && ( psys_in_edit_mode(scene, psys) || (part->type==PART_HAIR + || (part->ren_as == PART_DRAW_PATH && (part->draw_as == PART_DRAW_REND || psys->renderdata))))){ + psys_cache_paths(scene, ob, psys, cfra, 0); /* for render, child particle paths are computed on the fly */ @@ -4247,7 +4248,7 @@ static void hair_step(Scene *scene, Object *ob, ParticleSystemModifierData *psmd pa->flag &= ~PARS_NO_DISP; } - if(psys->recalc & PSYS_DISTR) + if(psys->recalc & PSYS_RECALC_RESET) /* need this for changing subsurf levels */ psys_calc_dmcache(ob, psmd->dm, psys); @@ -4367,16 +4368,14 @@ void psys_changed_type(ParticleSystem *psys) psys->flag &= ~PSYS_KEYED; if(part->type == PART_HAIR) { - part->draw_as = PART_DRAW_PATH; - part->rotfrom = PART_ROT_IINCR; - } - else { - free_hair(psys, 1); + if(ELEM4(part->ren_as, PART_DRAW_NOT, PART_DRAW_PATH, PART_DRAW_OB, PART_DRAW_GR)==0) + part->ren_as = PART_DRAW_PATH; - if(part->draw_as == PART_DRAW_PATH) - if(psys->part->phystype != PART_PHYS_KEYED) - part->draw_as = PART_DRAW_DOT; + if(ELEM3(part->draw_as, PART_DRAW_NOT, PART_DRAW_REND, PART_DRAW_PATH)==0) + part->draw_as = PART_DRAW_REND; } + else + free_hair(psys, 1); psys->softflag= 0; @@ -4574,7 +4573,7 @@ static void system_step(Scene *scene, Object *ob, ParticleSystem *psys, Particle init= 1; } - if(psys->recalc & PSYS_DISTR) { + if(psys->recalc & PSYS_RECALC_RESET) { distr= 1; init= 1; } @@ -4594,6 +4593,8 @@ static void system_step(Scene *scene, Object *ob, ParticleSystem *psys, Particle } if(only_children_changed==0) { + free_keyed_keys(psys); + initialize_all_particles(ob, psys, psmd); if(alloc) @@ -4747,8 +4748,8 @@ static void psys_to_softbody(Scene *scene, Object *ob, ParticleSystem *psys) static int hair_needs_recalc(ParticleSystem *psys) { if((psys->flag & PSYS_EDITED)==0 && - ((psys->flag & PSYS_HAIR_DONE)==0 || psys->recalc & PSYS_RECALC_HAIR)) { - psys->recalc &= ~PSYS_RECALC_HAIR; + ((psys->flag & PSYS_HAIR_DONE)==0 || psys->recalc & PSYS_RECALC_REDO)) { + psys->recalc &= ~PSYS_RECALC_REDO; return 1; } @@ -4778,6 +4779,9 @@ void particle_system_update(Scene *scene, Object *ob, ParticleSystem *psys) if(!psmd->dm) return; + if(psys->recalc & PSYS_RECALC_TYPE) + psys_changed_type(psys); + /* (re-)create hair */ if(psys->part->type==PART_HAIR && hair_needs_recalc(psys)) { float hcfra=0.0f; diff --git a/source/blender/blenkernel/intern/pointcache.c b/source/blender/blenkernel/intern/pointcache.c index 9c74014853d..b00755f7135 100644 --- a/source/blender/blenkernel/intern/pointcache.c +++ b/source/blender/blenkernel/intern/pointcache.c @@ -492,6 +492,8 @@ int BKE_ptcache_object_reset(Object *ob, int mode) else skip = 1; } + else if((psys->recalc & PSYS_RECALC_RESET)==0) + skip = 1; if(skip == 0) { BKE_ptcache_id_from_particles(&pid, ob, psys); diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c index 78a156559ff..c459d766937 100644 --- a/source/blender/blenloader/intern/readfile.c +++ b/source/blender/blenloader/intern/readfile.c @@ -8406,7 +8406,7 @@ static void do_versions(FileData *fd, Library *lib, Main *main) part->draw_as = PART_DRAW_PATH; part->type = PART_HAIR; - psys->recalc |= PSYS_RECALC_HAIR; + psys->recalc |= PSYS_RECALC_REDO; part->normfac *= fac; part->randfac *= fac; @@ -8872,6 +8872,7 @@ static void do_versions(FileData *fd, Library *lib, Main *main) Mesh *me; Scene *sce; Tex *tx; + ParticleSettings *part; for(screen= main->screen.first; screen; screen= screen->id.next) { do_versions_windowmanager_2_50(screen); @@ -8913,6 +8914,23 @@ static void do_versions(FileData *fd, Library *lib, Main *main) for(me= main->mesh.first; me; me= me->id.next) { me->drawflag= ME_DRAWEDGES|ME_DRAWFACES|ME_DRAWCREASES; } + + /* particle settings conversion */ + for(part= main->particle.first; part; part= part->id.next) { + if(part->draw_as) { + if(part->draw_as == PART_DRAW_DOT) { + part->ren_as = PART_DRAW_HALO; + part->draw_as = PART_DRAW_REND; + } + else if(part->draw_as <= PART_DRAW_AXIS) { + part->ren_as = PART_DRAW_HALO; + } + else { + part->ren_as = part->draw_as; + part->draw_as = PART_DRAW_REND; + } + } + } } /* TODO: should be moved into one of the version blocks once this branch moves to trunk and we can diff --git a/source/blender/editors/physics/editparticle.c b/source/blender/editors/physics/editparticle.c index 1c2b3c6b309..f60d5493058 100644 --- a/source/blender/editors/physics/editparticle.c +++ b/source/blender/editors/physics/editparticle.c @@ -3759,7 +3759,7 @@ static int set_editable_exec(bContext *C, wmOperator *op) PE_free_particle_edit(psys); psys->flag &= ~PSYS_EDITED; - psys->recalc |= PSYS_RECALC_HAIR; + psys->recalc |= PSYS_RECALC_RESET; DAG_object_flush_update(scene, ob, OB_RECALC_DATA); } diff --git a/source/blender/editors/sculpt_paint/paint_vertex.c b/source/blender/editors/sculpt_paint/paint_vertex.c index 0c20c0cc1cf..0710079301b 100644 --- a/source/blender/editors/sculpt_paint/paint_vertex.c +++ b/source/blender/editors/sculpt_paint/paint_vertex.c @@ -1274,7 +1274,7 @@ static void wpaint_exit(bContext *C, wmOperator *op) for(psys= ob->particlesystem.first; psys; psys= psys->next) { for(i=0; ivgroup[i]==ob->actdef) { - psys->recalc |= PSYS_RECALC_HAIR; + psys->recalc |= PSYS_RECALC_RESET; break; } } diff --git a/source/blender/editors/space_view3d/drawobject.c b/source/blender/editors/space_view3d/drawobject.c index 054cd4e966e..a67e8c8a1c3 100644 --- a/source/blender/editors/space_view3d/drawobject.c +++ b/source/blender/editors/space_view3d/drawobject.c @@ -3042,7 +3042,11 @@ static void draw_new_particle_system(Scene *scene, View3D *v3d, RegionView3D *rv } totpart=psys->totpart; - draw_as=part->draw_as; + + if(part->draw_as==PART_DRAW_REND) + draw_as = part->ren_as; + else + draw_as = part->draw_as; if(part->flag&PART_GLOB_TIME) cfra=bsystem_time(scene, 0, (float)CFRA, 0.0f); @@ -3489,7 +3493,6 @@ static void draw_new_particle_system(Scene *scene, View3D *v3d, RegionView3D *rv glColorPointer(3, GL_FLOAT, 0, cdata); } - /* draw created data arrays */ switch(draw_as){ case PART_DRAW_AXIS: diff --git a/source/blender/editors/space_view3d/space_view3d.c b/source/blender/editors/space_view3d/space_view3d.c index 70f90a1a9d9..6e33b1dcaab 100644 --- a/source/blender/editors/space_view3d/space_view3d.c +++ b/source/blender/editors/space_view3d/space_view3d.c @@ -395,6 +395,7 @@ static void view3d_main_area_listener(ARegion *ar, wmNotifier *wmn) case ND_MODIFIER: case ND_CONSTRAINT: case ND_KEYS: + case ND_PARTICLE: ED_region_tag_redraw(ar); break; } diff --git a/source/blender/makesdna/DNA_particle_types.h b/source/blender/makesdna/DNA_particle_types.h index 575fcfd8ac7..6805082d094 100644 --- a/source/blender/makesdna/DNA_particle_types.h +++ b/source/blender/makesdna/DNA_particle_types.h @@ -106,6 +106,7 @@ typedef struct ParticleSettings { /* physics modes */ short phystype, rotmode, avemode, reactevent; short draw, draw_as, draw_size, childtype; + short ren_as, rt2[3]; /* number of path segments, power of 2 except */ short draw_step, ren_step; short hair_step, keys_step; @@ -302,12 +303,12 @@ typedef struct ParticleSystem{ /* note, make sure all (runtime) are NULL's in /* part->draw */ #define PART_DRAW_VEL 1 -#define PART_DRAW_ANG 2 +//#define PART_DRAW_PATH_LEN 2 #define PART_DRAW_SIZE 4 #define PART_DRAW_EMITTER 8 /* render emitter also */ -//#define PART_DRAW_KEYS 16 /* not used anywhere */ -#define PART_DRAW_ADAPT 32 -#define PART_DRAW_COS 64 +//#define PART_DRAW_HEALTH 16 +//#define PART_DRAW_TIMED_PATH 32 +//#define PART_DRAW_CACHED_PATH 64 #define PART_DRAW_BB_LOCK 128 #define PART_DRAW_PARENT 256 #define PART_DRAW_NUM 512 @@ -341,9 +342,11 @@ typedef struct ParticleSystem{ /* note, make sure all (runtime) are NULL's in #define PART_BB_OFF_LINEAR 1 #define PART_BB_OFF_RANDOM 2 -/* part->draw as */ +/* part->draw_as */ +/* part->ren_as*/ #define PART_DRAW_NOT 0 #define PART_DRAW_DOT 1 +#define PART_DRAW_HALO 1 #define PART_DRAW_CIRC 2 #define PART_DRAW_CROSS 3 #define PART_DRAW_AXIS 4 @@ -352,6 +355,7 @@ typedef struct ParticleSystem{ /* note, make sure all (runtime) are NULL's in #define PART_DRAW_OB 7 #define PART_DRAW_GR 8 #define PART_DRAW_BB 9 +#define PART_DRAW_REND 10 /* part->integrator */ #define PART_INT_EULER 0 @@ -382,11 +386,10 @@ typedef struct ParticleSystem{ /* note, make sure all (runtime) are NULL's in #define PART_CHILD_FACES 2 /* psys->recalc */ -#define PSYS_INIT 1 -#define PSYS_DISTR 2 -#define PSYS_ALLOC 4 -#define PSYS_TYPE 8 -#define PSYS_RECALC_HAIR 16 +#define PSYS_RECALC_REDO 1 /* only do pathcache etc */ +#define PSYS_RECALC_RESET 2 /* reset everything including pointcache */ +#define PSYS_RECALC_TYPE 4 /* handle system type change */ +#define PSYS_RECALC_CHILD 16 /* only child settings changed */ /* psys->flag */ #define PSYS_CURRENT 1 diff --git a/source/blender/makesrna/intern/rna_object_force.c b/source/blender/makesrna/intern/rna_object_force.c index d20552cbdb0..c3e1931c439 100644 --- a/source/blender/makesrna/intern/rna_object_force.c +++ b/source/blender/makesrna/intern/rna_object_force.c @@ -53,6 +53,13 @@ static void rna_def_pointcache(BlenderRNA *brna) RNA_def_property_int_sdna(prop, NULL, "endframe"); RNA_def_property_range(prop, 1, 300000); RNA_def_property_ui_text(prop, "End", "Frame on which the simulation stops."); + + /* flags */ + prop= RNA_def_property(srna, "baked", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", PTCACHE_BAKED); + + prop= RNA_def_property(srna, "baking", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", PTCACHE_BAKING); } static void rna_def_collision(BlenderRNA *brna) diff --git a/source/blender/makesrna/intern/rna_particle.c b/source/blender/makesrna/intern/rna_particle.c index ee755fca27e..7c4f4eba27f 100644 --- a/source/blender/makesrna/intern/rna_particle.c +++ b/source/blender/makesrna/intern/rna_particle.c @@ -35,9 +35,59 @@ #include "DNA_particle_types.h" #include "DNA_object_force.h" #include "DNA_object_types.h" +#include "DNA_scene_types.h" + +#include "WM_types.h" #ifdef RNA_RUNTIME +#include "BKE_context.h" +#include "BKE_depsgraph.h" +#include "BKE_particle.h" + +static void rna_Particle_redo(bContext *C, PointerRNA *ptr) +{ + ParticleSettings *part; + if(ptr->type==&RNA_ParticleSystem) + part = ((ParticleSystem*)ptr->data)->part; + else + part = ptr->id.data; + + psys_flush_particle_settings(CTX_data_scene(C), part, PSYS_RECALC_REDO); +} + +static void rna_Particle_reset(bContext *C, PointerRNA *ptr) +{ + ParticleSettings *part; + if(ptr->type==&RNA_ParticleSystem) + part = ((ParticleSystem*)ptr->data)->part; + else + part = ptr->id.data; + + psys_flush_particle_settings(CTX_data_scene(C), part, PSYS_RECALC_RESET|PSYS_RECALC_REDO); +} + +static void rna_Particle_change_type(bContext *C, PointerRNA *ptr) +{ + ParticleSettings *part; + if(ptr->type==&RNA_ParticleSystem) + part = ((ParticleSystem*)ptr->data)->part; + else + part = ptr->id.data; + + psys_flush_particle_settings(CTX_data_scene(C), part, PSYS_RECALC_RESET|PSYS_RECALC_TYPE|PSYS_RECALC_REDO); +} + +static void rna_Particle_redo_child(bContext *C, PointerRNA *ptr) +{ + ParticleSettings *part; + if(ptr->type==&RNA_ParticleSystem) + part = ((ParticleSystem*)ptr->data)->part; + else + part = ptr->id.data; + + psys_flush_particle_settings(CTX_data_scene(C), part, PSYS_RECALC_CHILD); +} static void rna_PartSettings_start_set(struct PointerRNA *ptr, float value) { ParticleSettings *settings = (ParticleSettings*)ptr->data; @@ -111,6 +161,88 @@ static void rna_ParticleSystem_name_get(PointerRNA *ptr, char *str) strcat(str, psys->part->id.name+2); } +static EnumPropertyItem from_items[] = { + {PART_FROM_VERT, "VERT", "Vertexes", ""}, + {PART_FROM_FACE, "FACE", "Faces", ""}, + {PART_FROM_VOLUME, "VOLUME", "Volume", ""}, + {0, NULL, NULL, NULL} +}; + +static EnumPropertyItem reactor_from_items[] = { + {PART_FROM_VERT, "VERT", "Vertexes", ""}, + {PART_FROM_FACE, "FACE", "Faces", ""}, + {PART_FROM_VOLUME, "VOLUME", "Volume", ""}, + {PART_FROM_PARTICLE, "PARTICLE", "Particle", ""}, + {0, NULL, NULL, NULL} +}; + +static EnumPropertyItem *rna_Particle_from_itemf(PointerRNA *ptr) +{ + ParticleSettings *part = ptr->id.data; + + if(part->type==PART_REACTOR) + return reactor_from_items; + else + return from_items; +} + +static EnumPropertyItem draw_as_items[] = { + {PART_DRAW_NOT, "NONE", "None", ""}, + {PART_DRAW_REND, "RENDER", "Rendered", ""}, + {PART_DRAW_DOT, "DOT", "Point", ""}, + {PART_DRAW_CIRC, "CIRC", "Circle", ""}, + {PART_DRAW_CROSS, "CROSS", "Cross", ""}, + {PART_DRAW_AXIS, "AXIS", "Axis", ""}, + {0, NULL, NULL, NULL} +}; + +static EnumPropertyItem hair_draw_as_items[] = { + {PART_DRAW_NOT, "NONE", "None", ""}, + {PART_DRAW_REND, "RENDER", "Rendered", ""}, + {PART_DRAW_PATH, "PATH", "Path", ""}, + {0, NULL, NULL, NULL} +}; + +static EnumPropertyItem ren_as_items[] = { + {PART_DRAW_NOT, "NONE", "None", ""}, + {PART_DRAW_HALO, "HALO", "Halo", ""}, + {PART_DRAW_LINE, "LINE", "Line", ""}, + {PART_DRAW_PATH, "PATH", "Path", ""}, + {PART_DRAW_OB, "OBJECT", "Object", ""}, + {PART_DRAW_GR, "GROUP", "Group", ""}, + {PART_DRAW_BB, "BILLBOARD", "Billboard", ""}, + {0, NULL, NULL, NULL} +}; + +static EnumPropertyItem hair_ren_as_items[] = { + {PART_DRAW_NOT, "NONE", "None", ""}, + {PART_DRAW_PATH, "PATH", "Path", ""}, + {PART_DRAW_OB, "OBJECT", "Object", ""}, + {PART_DRAW_GR, "GROUP", "Group", ""}, + {0, NULL, NULL, NULL} +}; + +static EnumPropertyItem *rna_Particle_draw_as_itemf(PointerRNA *ptr) +{ + ParticleSettings *part = ptr->id.data; + + if(part->type==PART_HAIR) + return hair_draw_as_items; + else + return draw_as_items; +} + +static EnumPropertyItem *rna_Particle_ren_as_itemf(PointerRNA *ptr) +{ + ParticleSettings *part = ptr->id.data; + + if(part->type==PART_HAIR) + return hair_ren_as_items; + else + return ren_as_items; +} + + #else static void rna_def_particle_hair_key(BlenderRNA *brna) @@ -326,16 +458,6 @@ static void rna_def_particle_settings(BlenderRNA *brna) {PART_EMITTER, "EMITTER", "Emitter", ""}, {PART_REACTOR, "REACTOR", "Reactor", ""}, {PART_HAIR, "HAIR", "Hair", ""}, - {PART_FLUID, "FLUID", "Fluid", ""}, - {0, NULL, NULL, NULL} - }; - - static EnumPropertyItem from_items[] = { - {PART_FROM_VERT, "VERT", "Vertexes", ""}, - {PART_FROM_FACE, "FACE", "Faces", ""}, - {PART_FROM_VOLUME, "VOLUME", "Volume", ""}, - {PART_FROM_PARTICLE, "PARTICLE", "Particle", ""}, - {PART_FROM_CHILD, "CHILD", "Child", ""}, {0, NULL, NULL, NULL} }; @@ -347,7 +469,7 @@ static void rna_def_particle_settings(BlenderRNA *brna) }; static EnumPropertyItem phys_type_items[] = { - {PART_PHYS_NO, "NO", "no", ""}, + {PART_PHYS_NO, "NO", "No", ""}, {PART_PHYS_NEWTON, "NEWTON", "Newtonian", ""}, {PART_PHYS_KEYED, "KEYED", "Keyed", ""}, {PART_PHYS_BOIDS, "BOIDS", "Boids", ""}, @@ -381,20 +503,6 @@ static void rna_def_particle_settings(BlenderRNA *brna) {0, NULL, NULL, NULL} }; - static EnumPropertyItem draw_as_items[] = { - {PART_DRAW_NOT, "NONE", "None", ""}, - {PART_DRAW_DOT, "DOT", "Point", ""}, - {PART_DRAW_CIRC, "CIRC", "Circle", ""}, - {PART_DRAW_CROSS, "CROSS", "Cross", ""}, - {PART_DRAW_AXIS, "AXIS", "Axis", ""}, - {PART_DRAW_LINE, "LINE", "Line", ""}, - {PART_DRAW_PATH, "PATH", "Path", ""}, - {PART_DRAW_OB, "OBJECT", "Object", ""}, - {PART_DRAW_GR, "GROUP", "Group", ""}, - {PART_DRAW_BB, "BILLBOARD", "Billboard", ""}, - {0, NULL, NULL, NULL} - }; - static EnumPropertyItem child_type_items[] = { {0, "NONE", "None", ""}, {PART_CHILD_PARTICLES, "PARTICLES", "Particles", ""}, @@ -466,15 +574,19 @@ static void rna_def_particle_settings(BlenderRNA *brna) prop= RNA_def_property(srna, "react_start_end", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", PART_REACT_STA_END); RNA_def_property_ui_text(prop, "Start/End", "Give birth to unreacted particles eventually."); + RNA_def_property_update(prop, NC_OBJECT|ND_PARTICLE, "rna_Particle_reset"); prop= RNA_def_property(srna, "react_multiple", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", PART_REACT_MULTIPLE); RNA_def_property_ui_text(prop, "Multi React", "React multiple times."); + RNA_def_property_update(prop, NC_OBJECT|ND_PARTICLE, "rna_Particle_reset"); prop= RNA_def_property(srna, "loop", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", PART_LOOP); RNA_def_property_ui_text(prop, "Loop", "Loop particle lives."); + RNA_def_property_update(prop, NC_OBJECT|ND_PARTICLE, "rna_Particle_reset"); + /* TODO: used somewhere? */ prop= RNA_def_property(srna, "hair_geometry", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", PART_HAIR_GEOMETRY); RNA_def_property_ui_text(prop, "Hair Geometry", "");//TODO: tooltip @@ -482,83 +594,104 @@ static void rna_def_particle_settings(BlenderRNA *brna) prop= RNA_def_property(srna, "unborn", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", PART_UNBORN); RNA_def_property_ui_text(prop, "Unborn", "Show particles before they are emitted."); + RNA_def_property_update(prop, NC_OBJECT|ND_PARTICLE, "rna_Particle_redo"); prop= RNA_def_property(srna, "died", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", PART_DIED); RNA_def_property_ui_text(prop, "Died", "Show particles after they have died"); + RNA_def_property_update(prop, NC_OBJECT|ND_PARTICLE, "rna_Particle_redo"); prop= RNA_def_property(srna, "trand", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", PART_TRAND); RNA_def_property_ui_text(prop, "Random", "Emit in random order of elements"); + RNA_def_property_update(prop, NC_OBJECT|ND_PARTICLE, "rna_Particle_reset"); prop= RNA_def_property(srna, "even_distribution", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", PART_EDISTR); RNA_def_property_ui_text(prop, "Even Distribution", "Use even distribution from faces based on face areas or edge lengths."); + RNA_def_property_update(prop, NC_OBJECT|ND_PARTICLE, "rna_Particle_reset"); prop= RNA_def_property(srna, "sticky", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", PART_STICKY); RNA_def_property_ui_text(prop, "Sticky", "Particles stick to collided objects if they die in the collision."); + RNA_def_property_update(prop, NC_OBJECT|ND_PARTICLE, "rna_Particle_reset"); prop= RNA_def_property(srna, "die_on_collision", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", PART_DIE_ON_COL); RNA_def_property_ui_text(prop, "Die on hit", "Particles die when they collide with a deflector object."); + RNA_def_property_update(prop, NC_OBJECT|ND_PARTICLE, "rna_Particle_reset"); prop= RNA_def_property(srna, "size_deflect", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", PART_SIZE_DEFL); RNA_def_property_ui_text(prop, "Size Deflect", "Use particle's size in deflection."); + RNA_def_property_update(prop, NC_OBJECT|ND_PARTICLE, "rna_Particle_reset"); prop= RNA_def_property(srna, "rotation_dynamic", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", PART_ROT_DYN); RNA_def_property_ui_text(prop, "Dynamic", "Sets rotation to dynamic/constant"); + RNA_def_property_update(prop, NC_OBJECT|ND_PARTICLE, "rna_Particle_reset"); prop= RNA_def_property(srna, "sizemass", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", PART_SIZEMASS); RNA_def_property_ui_text(prop, "Mass from Size", "Multiply mass with particle size."); + RNA_def_property_update(prop, NC_OBJECT|ND_PARTICLE, "rna_Particle_reset"); prop= RNA_def_property(srna, "abs_length", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", PART_ABS_LENGTH); RNA_def_property_ui_text(prop, "Abs Length", "Use maximum length for children"); + RNA_def_property_update(prop, NC_OBJECT|ND_PARTICLE, "rna_Particle_redo"); prop= RNA_def_property(srna, "absolute_time", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", PART_ABS_TIME); RNA_def_property_ui_text(prop, "Absolute Time", "Set all ipos that work on particles to be calculated in absolute/relative time."); + RNA_def_property_update(prop, NC_OBJECT|ND_PARTICLE, "rna_Particle_reset"); prop= RNA_def_property(srna, "global_time", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", PART_GLOB_TIME); RNA_def_property_ui_text(prop, "Global Time", "Set all ipos that work on particles to be calculated in global/object time."); + RNA_def_property_update(prop, NC_OBJECT|ND_PARTICLE, "rna_Particle_reset"); prop= RNA_def_property(srna, "boids_2d", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", PART_BOIDS_2D); RNA_def_property_ui_text(prop, "Boids 2D", "Constrain boids to a surface"); + RNA_def_property_update(prop, NC_OBJECT|ND_PARTICLE, "rna_Particle_reset"); prop= RNA_def_property(srna, "branching", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", PART_BRANCHING); RNA_def_property_ui_text(prop, "Branching", "Branch child paths from each other."); + RNA_def_property_update(prop, NC_OBJECT|ND_PARTICLE, "rna_Particle_redo_child"); prop= RNA_def_property(srna, "animate_branching", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", PART_ANIM_BRANCHING); RNA_def_property_ui_text(prop, "Animated", "Animate branching"); + RNA_def_property_update(prop, NC_OBJECT|ND_PARTICLE, "rna_Particle_redo_child"); prop= RNA_def_property(srna, "symmetric_branching", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", PART_SYMM_BRANCHING); RNA_def_property_ui_text(prop, "Symmetric", "Start and end points are the same."); + RNA_def_property_update(prop, NC_OBJECT|ND_PARTICLE, "rna_Particle_redo_child"); prop= RNA_def_property(srna, "hair_bspline", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", PART_HAIR_BSPLINE); RNA_def_property_ui_text(prop, "B-Spline", "Interpolate hair using B-Splines."); + RNA_def_property_update(prop, NC_OBJECT|ND_PARTICLE, "rna_Particle_redo"); prop= RNA_def_property(srna, "grid_invert", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", PART_GRID_INVERT); RNA_def_property_ui_text(prop, "Invert", "Invert what is considered object and what is not."); + RNA_def_property_update(prop, NC_OBJECT|ND_PARTICLE, "rna_Particle_reset"); prop= RNA_def_property(srna, "child_effector", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", PART_CHILD_EFFECT); RNA_def_property_ui_text(prop, "Children", "Apply effectors to children."); + RNA_def_property_update(prop, NC_OBJECT|ND_PARTICLE, "rna_Particle_redo"); prop= RNA_def_property(srna, "child_seams", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", PART_CHILD_SEAMS); RNA_def_property_ui_text(prop, "Use seams", "Use seams to determine parents"); + RNA_def_property_update(prop, NC_OBJECT|ND_PARTICLE, "rna_Particle_redo_child"); + /* TODO: used somewhere? */ prop= RNA_def_property(srna, "child_render", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", PART_CHILD_RENDER); RNA_def_property_ui_text(prop, "child_render", ""); @@ -566,129 +699,164 @@ static void rna_def_particle_settings(BlenderRNA *brna) prop= RNA_def_property(srna, "child_guide", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", PART_CHILD_GUIDE); RNA_def_property_ui_text(prop, "child_guide", ""); + RNA_def_property_update(prop, NC_OBJECT|ND_PARTICLE, "rna_Particle_redo"); prop= RNA_def_property(srna, "self_effect", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", PART_SELF_EFFECT); RNA_def_property_ui_text(prop, "Self Effect", "Particle effectors effect themselves."); + RNA_def_property_update(prop, NC_OBJECT|ND_PARTICLE, "rna_Particle_reset"); prop= RNA_def_property(srna, "type", PROP_ENUM, PROP_NONE); RNA_def_property_enum_items(prop, type_items); RNA_def_property_ui_text(prop, "Type", ""); + RNA_def_property_update(prop, NC_OBJECT|ND_PARTICLE, "rna_Particle_change_type"); prop= RNA_def_property(srna, "emit_from", PROP_ENUM, PROP_NONE); RNA_def_property_enum_sdna(prop, NULL, "from"); - RNA_def_property_enum_items(prop, from_items); + RNA_def_property_enum_funcs(prop, NULL, NULL, "rna_Particle_from_itemf"); RNA_def_property_ui_text(prop, "Emit From", "Where to emit particles from"); + RNA_def_property_update(prop, NC_OBJECT|ND_PARTICLE, "rna_Particle_reset"); prop= RNA_def_property(srna, "distribution", PROP_ENUM, PROP_NONE); RNA_def_property_enum_sdna(prop, NULL, "distr"); RNA_def_property_enum_items(prop, dist_items); RNA_def_property_ui_text(prop, "Distribution", "How to distribute particles on selected element"); + RNA_def_property_update(prop, NC_OBJECT|ND_PARTICLE, "rna_Particle_reset"); /* physics modes */ prop= RNA_def_property(srna, "physics_type", PROP_ENUM, PROP_NONE); RNA_def_property_enum_sdna(prop, NULL, "phystype"); RNA_def_property_enum_items(prop, phys_type_items); RNA_def_property_ui_text(prop, "Physics Type", "Particle physics type"); + RNA_def_property_update(prop, NC_OBJECT|ND_PARTICLE, "rna_Particle_reset"); prop= RNA_def_property(srna, "rotation_mode", PROP_ENUM, PROP_NONE); RNA_def_property_enum_sdna(prop, NULL, "rotmode"); RNA_def_property_enum_items(prop, rot_mode_items); RNA_def_property_ui_text(prop, "Rotation", "Particles initial rotation"); + RNA_def_property_update(prop, NC_OBJECT|ND_PARTICLE, "rna_Particle_reset"); prop= RNA_def_property(srna, "angular_velocity_mode", PROP_ENUM, PROP_NONE); RNA_def_property_enum_sdna(prop, NULL, "avemode"); RNA_def_property_enum_items(prop, ave_mode_items); RNA_def_property_ui_text(prop, "Angular Velocity Mode", "Particle angular velocity mode."); + RNA_def_property_update(prop, NC_OBJECT|ND_PARTICLE, "rna_Particle_reset"); prop= RNA_def_property(srna, "react_event", PROP_ENUM, PROP_NONE); RNA_def_property_enum_sdna(prop, NULL, "reactevent"); RNA_def_property_enum_items(prop, react_event_items); RNA_def_property_ui_text(prop, "React On", "The event of target particles to react on."); + RNA_def_property_update(prop, NC_OBJECT|ND_PARTICLE, "rna_Particle_reset"); /*draw flag*/ prop= RNA_def_property(srna, "velocity", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "draw", PART_DRAW_VEL); RNA_def_property_ui_text(prop, "Velocity", "Show particle velocity"); + RNA_def_property_update(prop, NC_OBJECT|ND_PARTICLE, "rna_Particle_redo"); - /* used? - prop= RNA_def_property(srna, "angle", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "draw", PART_DRAW_ANG); - RNA_def_property_ui_text(prop, "Angle", ""); - */ + //prop= RNA_def_property(srna, "draw_path_length", PROP_BOOLEAN, PROP_NONE); + //RNA_def_property_boolean_sdna(prop, NULL, "draw", PART_DRAW_PATH_LEN); + //RNA_def_property_ui_text(prop, "Path length", "Draw path length"); + //RNA_def_property_update(prop, NC_OBJECT|ND_PARTICLE, "rna_Particle_redo"); prop= RNA_def_property(srna, "show_size", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "draw", PART_DRAW_SIZE); RNA_def_property_ui_text(prop, "Size", "Show particle size"); + RNA_def_property_update(prop, NC_OBJECT|ND_PARTICLE, "rna_Particle_redo"); prop= RNA_def_property(srna, "emitter", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "draw", PART_DRAW_EMITTER); RNA_def_property_ui_text(prop, "Emitter", "Render emitter Object also."); + RNA_def_property_update(prop, NC_OBJECT|ND_PARTICLE, "rna_Particle_redo"); - /* used? - prop= RNA_def_property(srna, "adapt", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "draw", PART_DRAW_ADAPT); - RNA_def_property_ui_text(prop, "adapt", ""); + //prop= RNA_def_property(srna, "draw_health", PROP_BOOLEAN, PROP_NONE); + //RNA_def_property_boolean_sdna(prop, NULL, "draw", PART_DRAW_HEALTH); + //RNA_def_property_ui_text(prop, "Health", "Draw boid health"); + //RNA_def_property_update(prop, NC_OBJECT|ND_PARTICLE, "rna_Particle_redo"); - prop= RNA_def_property(srna, "cos", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "draw", PART_DRAW_COS); - RNA_def_property_ui_text(prop, "cos", ""); - */ + //prop= RNA_def_property(srna, "timed_path", PROP_BOOLEAN, PROP_NONE); + //RNA_def_property_boolean_sdna(prop, NULL, "draw", PART_DRAW_TIMED_PATH); + //RNA_def_property_ui_text(prop, "Clip with time", "Clip path based on time"); + //RNA_def_property_update(prop, NC_OBJECT|ND_PARTICLE, "rna_Particle_redo"); + + //prop= RNA_def_property(srna, "draw_cached_path", PROP_BOOLEAN, PROP_NONE); + //RNA_def_property_boolean_sdna(prop, NULL, "draw", PART_DRAW_CACHED_PATH); + //RNA_def_property_ui_text(prop, "Path", "Draw particle path if the path is baked"); + //RNA_def_property_update(prop, NC_OBJECT|ND_PARTICLE, "rna_Particle_redo"); prop= RNA_def_property(srna, "billboard_lock", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "draw", PART_DRAW_BB_LOCK); RNA_def_property_ui_text(prop, "Lock Billboard", "Lock the billboards align axis"); + RNA_def_property_update(prop, NC_OBJECT|ND_PARTICLE, "rna_Particle_redo"); prop= RNA_def_property(srna, "parent", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "draw", PART_DRAW_PARENT); RNA_def_property_ui_text(prop, "Parents", "Render parent particles."); + RNA_def_property_update(prop, NC_OBJECT|ND_PARTICLE, "rna_Particle_redo"); prop= RNA_def_property(srna, "num", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "draw", PART_DRAW_NUM); RNA_def_property_ui_text(prop, "Number", "Show particle number"); + RNA_def_property_update(prop, NC_OBJECT|ND_PARTICLE, "rna_Particle_redo"); prop= RNA_def_property(srna, "rand_group", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "draw", PART_DRAW_RAND_GR); RNA_def_property_ui_text(prop, "Pick Random", "Pick objects from group randomly"); + RNA_def_property_update(prop, NC_OBJECT|ND_PARTICLE, "rna_Particle_redo"); prop= RNA_def_property(srna, "render_adaptive", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "draw", PART_DRAW_REN_ADAPT); RNA_def_property_ui_text(prop, "Adaptive render", "Draw steps of the particle path"); + RNA_def_property_update(prop, NC_OBJECT|ND_PARTICLE, "rna_Particle_redo"); prop= RNA_def_property(srna, "velocity_length", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "draw", PART_DRAW_VEL_LENGTH); RNA_def_property_ui_text(prop, "Speed", "Multiply line length by particle speed"); + RNA_def_property_update(prop, NC_OBJECT|ND_PARTICLE, "rna_Particle_redo"); prop= RNA_def_property(srna, "material_color", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "draw", PART_DRAW_MAT_COL); RNA_def_property_ui_text(prop, "Material Color", "Draw particles using material's diffuse color."); + RNA_def_property_update(prop, NC_OBJECT|ND_PARTICLE, "rna_Particle_redo"); prop= RNA_def_property(srna, "whole_group", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "draw", PART_DRAW_WHOLE_GR); - RNA_def_property_ui_text(prop, "Dupli Group", "Use whole group at once."); + RNA_def_property_ui_text(prop, "Whole Group", "Use whole group at once."); + RNA_def_property_update(prop, NC_OBJECT|ND_PARTICLE, "rna_Particle_redo"); prop= RNA_def_property(srna, "render_strand", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "draw", PART_DRAW_REN_STRAND); RNA_def_property_ui_text(prop, "Strand render", "Use the strand primitive for rendering"); - + RNA_def_property_update(prop, NC_OBJECT|ND_PARTICLE, "rna_Particle_redo"); prop= RNA_def_property(srna, "draw_as", PROP_ENUM, PROP_NONE); - RNA_def_property_enum_items(prop, draw_as_items); - RNA_def_property_ui_text(prop, "Particle Visualization", "How particles are visualized"); + RNA_def_property_enum_sdna(prop, NULL, "draw_as"); + RNA_def_property_enum_funcs(prop, NULL, NULL, "rna_Particle_draw_as_itemf"); + RNA_def_property_ui_text(prop, "Particle Drawing", "How particles are drawn in viewport"); + RNA_def_property_update(prop, NC_OBJECT|ND_PARTICLE, "rna_Particle_redo"); + + prop= RNA_def_property(srna, "ren_as", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_sdna(prop, NULL, "ren_as"); + RNA_def_property_enum_funcs(prop, NULL, NULL, "rna_Particle_ren_as_itemf"); + RNA_def_property_ui_text(prop, "Particle Rendering", "How particles are rendered"); + RNA_def_property_update(prop, NC_OBJECT|ND_PARTICLE, "rna_Particle_redo"); prop= RNA_def_property(srna, "draw_size", PROP_INT, PROP_NONE); RNA_def_property_range(prop, 0, 10); RNA_def_property_ui_text(prop, "Draw Size", "Size of particles on viewport in pixels (0=default)"); + RNA_def_property_update(prop, NC_OBJECT|ND_PARTICLE, "rna_Particle_redo"); prop= RNA_def_property(srna, "child_type", PROP_ENUM, PROP_NONE); RNA_def_property_enum_sdna(prop, NULL, "childtype"); RNA_def_property_enum_items(prop, child_type_items); RNA_def_property_ui_text(prop, "Children From", "Create child particles"); + RNA_def_property_update(prop, NC_OBJECT|ND_PARTICLE, "rna_Particle_redo"); prop= RNA_def_property(srna, "draw_step", PROP_INT, PROP_NONE); RNA_def_property_range(prop, 0, 7); RNA_def_property_ui_text(prop, "Steps", "How many steps paths are drawn with (power of 2)"); + RNA_def_property_update(prop, NC_OBJECT|ND_PARTICLE, "rna_Particle_redo"); prop= RNA_def_property(srna, "render_step", PROP_INT, PROP_NONE); RNA_def_property_int_sdna(prop, NULL, "ren_step"); @@ -697,7 +865,9 @@ static void rna_def_particle_settings(BlenderRNA *brna) prop= RNA_def_property(srna, "hair_step", PROP_INT, PROP_NONE); RNA_def_property_range(prop, 2, 50); - RNA_def_property_ui_text(prop, "Segments", "Amount of hair segments"); + RNA_def_property_ui_text(prop, "Segments", "Number of hair segments"); + RNA_def_property_update(prop, NC_OBJECT|ND_PARTICLE, "rna_Particle_redo"); + //TODO: not found in UI, readonly? prop= RNA_def_property(srna, "keys_step", PROP_INT, PROP_NONE); @@ -719,11 +889,13 @@ static void rna_def_particle_settings(BlenderRNA *brna) RNA_def_property_int_sdna(prop, NULL, "disp"); RNA_def_property_range(prop, 0, 100); RNA_def_property_ui_text(prop, "Display", "Percentage of particles to display in 3d view"); + RNA_def_property_update(prop, NC_OBJECT|ND_PARTICLE, "rna_Particle_redo"); prop= RNA_def_property(srna, "material", PROP_INT, PROP_NONE); RNA_def_property_int_sdna(prop, NULL, "omat"); RNA_def_property_range(prop, 1, 16); RNA_def_property_ui_text(prop, "Material", "Specify material used for the particles"); + RNA_def_property_update(prop, NC_OBJECT|ND_PARTICLE, "rna_Particle_redo"); //interpolation @@ -738,14 +910,17 @@ static void rna_def_particle_settings(BlenderRNA *brna) prop= RNA_def_property(srna, "integrator", PROP_ENUM, PROP_NONE); RNA_def_property_enum_items(prop, integrator_type_items); RNA_def_property_ui_text(prop, "Integration", "Select physics integrator type"); + RNA_def_property_update(prop, NC_OBJECT|ND_PARTICLE, "rna_Particle_reset"); prop= RNA_def_property(srna, "kink", PROP_ENUM, PROP_NONE); RNA_def_property_enum_items(prop, kink_type_items); RNA_def_property_ui_text(prop, "Kink", "Type of periodic offset on the path"); + RNA_def_property_update(prop, NC_OBJECT|ND_PARTICLE, "rna_Particle_redo_child"); prop= RNA_def_property(srna, "kink_axis", PROP_ENUM, PROP_NONE); RNA_def_property_enum_items(prop, kink_axis_items); RNA_def_property_ui_text(prop, "Axis", "Which axis to use for offset"); + RNA_def_property_update(prop, NC_OBJECT|ND_PARTICLE, "rna_Particle_redo_child"); /* used? prop= RNA_def_property(srna, "inbetween", PROP_INT, PROP_NONE); @@ -758,12 +933,14 @@ static void rna_def_particle_settings(BlenderRNA *brna) RNA_def_property_int_sdna(prop, NULL, "boidneighbours"); RNA_def_property_range(prop, 1, 10); RNA_def_property_ui_text(prop, "Neighbours", "How many neighbours to consider for each boid"); + RNA_def_property_update(prop, NC_OBJECT|ND_PARTICLE, "rna_Particle_reset"); /* billboards */ prop= RNA_def_property(srna, "billboard_align", PROP_ENUM, PROP_NONE); RNA_def_property_enum_sdna(prop, NULL, "bb_align"); RNA_def_property_enum_items(prop, bb_align_items); RNA_def_property_ui_text(prop, "Align to", "In respect to what the billboards are aligned"); + RNA_def_property_update(prop, NC_OBJECT|ND_PARTICLE, "rna_Particle_redo"); prop= RNA_def_property(srna, "billboard_uv_split", PROP_INT, PROP_NONE); RNA_def_property_int_sdna(prop, NULL, "bb_uv_split"); @@ -784,17 +961,20 @@ static void rna_def_particle_settings(BlenderRNA *brna) RNA_def_property_float_sdna(prop, NULL, "bb_tilt"); RNA_def_property_range(prop, -1.0f, 1.0f); RNA_def_property_ui_text(prop, "Tilt", "Tilt of the billboards"); + RNA_def_property_update(prop, NC_OBJECT|ND_PARTICLE, "rna_Particle_redo"); prop= RNA_def_property(srna, "billboard_random_tilt", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "bb_rand_tilt"); RNA_def_property_range(prop, 0.0f, 1.0f); RNA_def_property_ui_text(prop, "Random Tilt", "Random tilt of the billboards"); + RNA_def_property_update(prop, NC_OBJECT|ND_PARTICLE, "rna_Particle_redo"); prop= RNA_def_property(srna, "billboard_offset", PROP_FLOAT, PROP_VECTOR); RNA_def_property_float_sdna(prop, NULL, "bb_offset"); RNA_def_property_array(prop, 2); RNA_def_property_range(prop, -1.0f, 1.0f); RNA_def_property_ui_text(prop, "Billboard Offset", ""); + RNA_def_property_update(prop, NC_OBJECT|ND_PARTICLE, "rna_Particle_redo"); /* simplification */ prop= RNA_def_property(srna, "enable_simplify", PROP_BOOLEAN, PROP_NONE); @@ -828,39 +1008,47 @@ static void rna_def_particle_settings(BlenderRNA *brna) RNA_def_property_range(prop, -30000.0f, 30000.0f); //TODO: replace 30000 with MAXFRAMEF when available in 2.5 RNA_def_property_float_funcs(prop, NULL, "rna_PartSettings_start_set", NULL); RNA_def_property_ui_text(prop, "Start", "Frame # to start emitting particles."); + RNA_def_property_update(prop, NC_OBJECT|ND_PARTICLE, "rna_Particle_reset"); prop= RNA_def_property(srna, "end", PROP_FLOAT, PROP_NONE); RNA_def_property_range(prop, -30000.0f, 30000.0f); //TODO: replace 30000 with MAXFRAMEF when available in 2.5 RNA_def_property_float_funcs(prop, NULL, "rna_PartSettings_end_set", NULL); RNA_def_property_ui_text(prop, "End", "Frame # to stop emitting particles."); + RNA_def_property_update(prop, NC_OBJECT|ND_PARTICLE, "rna_Particle_reset"); prop= RNA_def_property(srna, "lifetime", PROP_FLOAT, PROP_NONE); RNA_def_property_range(prop, 1.0f, 30000.0f); RNA_def_property_ui_text(prop, "Lifetime", "Specify the life span of the particles"); + RNA_def_property_update(prop, NC_OBJECT|ND_PARTICLE, "rna_Particle_reset"); prop= RNA_def_property(srna, "random_lifetime", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "randlife"); - RNA_def_property_range(prop, 0.0f, 2.0f); + RNA_def_property_range(prop, 0.0f, 1.0f); RNA_def_property_ui_text(prop, "Random", "Give the particle life a random variation."); + RNA_def_property_update(prop, NC_OBJECT|ND_PARTICLE, "rna_Particle_reset"); prop= RNA_def_property(srna, "time_tweak", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "timetweak"); RNA_def_property_range(prop, 0.0f, 10.0f); RNA_def_property_ui_text(prop, "Tweak", "A multiplier for physics timestep (1.0 means one frame = 1/25 seconds)"); + RNA_def_property_update(prop, NC_OBJECT|ND_PARTICLE, "rna_Particle_reset"); prop= RNA_def_property(srna, "jitter_factor", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "jitfac"); RNA_def_property_range(prop, 0.0f, 2.0f); RNA_def_property_ui_text(prop, "Amount", "Amount of jitter applied to the sampling."); + RNA_def_property_update(prop, NC_OBJECT|ND_PARTICLE, "rna_Particle_reset"); prop= RNA_def_property(srna, "keyed_time", PROP_FLOAT, PROP_NONE); RNA_def_property_range(prop, 0.0f, 1.0f); RNA_def_property_ui_text(prop, "Time", "Keyed key time relative to remaining particle life."); + RNA_def_property_update(prop, NC_OBJECT|ND_PARTICLE, "rna_Particle_reset"); prop= RNA_def_property(srna, "effect_hair", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "eff_hair"); RNA_def_property_range(prop, 0.0f, 1.0f); RNA_def_property_ui_text(prop, "Stiffnes", "Hair stiffness for effectors"); + RNA_def_property_update(prop, NC_OBJECT|ND_PARTICLE, "rna_Particle_redo"); //float rt; TODO:find where rt is used - can't find it in UI @@ -868,92 +1056,110 @@ static void rna_def_particle_settings(BlenderRNA *brna) RNA_def_property_int_sdna(prop, NULL, "totpart"); RNA_def_property_range(prop, 0, 100000); RNA_def_property_ui_text(prop, "Amount", "Total number of particles."); + RNA_def_property_update(prop, NC_OBJECT|ND_PARTICLE, "rna_Particle_reset"); prop= RNA_def_property(srna, "userjit", PROP_INT, PROP_UNSIGNED);//TODO: can we get a better name for userjit? RNA_def_property_int_sdna(prop, NULL, "userjit"); RNA_def_property_range(prop, 0, 1000); RNA_def_property_ui_text(prop, "P/F", "Emission locations / face (0 = automatic)."); + RNA_def_property_update(prop, NC_OBJECT|ND_PARTICLE, "rna_Particle_reset"); prop= RNA_def_property(srna, "grid_resolution", PROP_INT, PROP_UNSIGNED); RNA_def_property_int_sdna(prop, NULL, "grid_res"); RNA_def_property_range(prop, 1, 100); RNA_def_property_ui_text(prop, "Resolution", "The resolution of the particle grid."); + RNA_def_property_update(prop, NC_OBJECT|ND_PARTICLE, "rna_Particle_reset"); /* initial velocity factors */ prop= RNA_def_property(srna, "normal_factor", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "normfac");//optional if prop names are the same RNA_def_property_range(prop, -200.0f, 200.0f); RNA_def_property_ui_text(prop, "Normal", "Let the surface normal give the particle a starting speed."); + RNA_def_property_update(prop, NC_OBJECT|ND_PARTICLE, "rna_Particle_reset"); prop= RNA_def_property(srna, "object_factor", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "obfac"); RNA_def_property_range(prop, -1.0f, 1.0f); RNA_def_property_ui_text(prop, "Object", "Let the object give the particle a starting speed"); + RNA_def_property_update(prop, NC_OBJECT|ND_PARTICLE, "rna_Particle_reset"); prop= RNA_def_property(srna, "random_factor", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "randfac");//optional if prop names are the same RNA_def_property_range(prop, 0.0f, 200.0f); RNA_def_property_ui_text(prop, "Random", "Give the starting speed a random variation."); + RNA_def_property_update(prop, NC_OBJECT|ND_PARTICLE, "rna_Particle_reset"); prop= RNA_def_property(srna, "particle_factor", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "partfac"); RNA_def_property_range(prop, -10.0f, 10.0f); RNA_def_property_ui_text(prop, "Particle", "Let the target particle give the particle a starting speed."); + RNA_def_property_update(prop, NC_OBJECT|ND_PARTICLE, "rna_Particle_reset"); prop= RNA_def_property(srna, "tangent_factor", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "tanfac"); RNA_def_property_range(prop, -200.0f, 200.0f); RNA_def_property_ui_text(prop, "Tangent", "Let the surface tangent give the particle a starting speed."); + RNA_def_property_update(prop, NC_OBJECT|ND_PARTICLE, "rna_Particle_reset"); prop= RNA_def_property(srna, "tangent_phase", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "tanphase"); RNA_def_property_range(prop, -1.0f, 1.0f); RNA_def_property_ui_text(prop, "Rot", "Rotate the surface tangent."); + RNA_def_property_update(prop, NC_OBJECT|ND_PARTICLE, "rna_Particle_reset"); prop= RNA_def_property(srna, "reactor_factor", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "reactfac"); RNA_def_property_range(prop, -10.0f, 10.0f); RNA_def_property_ui_text(prop, "Reactor", "Let the vector away from the target particles location give the particle a starting speed."); + RNA_def_property_update(prop, NC_OBJECT|ND_PARTICLE, "rna_Particle_reset"); prop= RNA_def_property(srna, "angular_velocity_factor", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "avefac"); RNA_def_property_range(prop, -200.0f, 200.0f); RNA_def_property_ui_text(prop, "Angular Velocity", "Angular velocity amount"); + RNA_def_property_update(prop, NC_OBJECT|ND_PARTICLE, "rna_Particle_reset"); prop= RNA_def_property(srna, "phase_factor", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "phasefac"); RNA_def_property_range(prop, -1.0f, 1.0f); RNA_def_property_ui_text(prop, "Phase", "Initial rotation phase"); + RNA_def_property_update(prop, NC_OBJECT|ND_PARTICLE, "rna_Particle_reset"); prop= RNA_def_property(srna, "random_rotation_factor", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "randrotfac"); RNA_def_property_range(prop, 0.0f, 1.0f); RNA_def_property_ui_text(prop, "Random Rotation", "Randomize rotation"); + RNA_def_property_update(prop, NC_OBJECT|ND_PARTICLE, "rna_Particle_reset"); prop= RNA_def_property(srna, "random_phase_factor", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "randphasefac"); RNA_def_property_range(prop, 0.0f, 1.0f); RNA_def_property_ui_text(prop, "Random Phase", "Randomize rotation phase"); + RNA_def_property_update(prop, NC_OBJECT|ND_PARTICLE, "rna_Particle_reset"); /* physical properties */ prop= RNA_def_property(srna, "mass", PROP_FLOAT, PROP_NONE); RNA_def_property_range(prop, 0.01f, 100.0f); RNA_def_property_ui_text(prop, "Mass", "Specify the mass of the particles"); + RNA_def_property_update(prop, NC_OBJECT|ND_PARTICLE, "rna_Particle_reset"); prop= RNA_def_property(srna, "particle_size", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "size"); RNA_def_property_range(prop, 0.01f, 100.0f); RNA_def_property_ui_text(prop, "Size", "The size of the particles"); + RNA_def_property_update(prop, NC_OBJECT|ND_PARTICLE, "rna_Particle_reset"); prop= RNA_def_property(srna, "random_size", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "randsize"); RNA_def_property_range(prop, 0.0f, 1.0f); RNA_def_property_ui_text(prop, "Random Size", "Give the particle size a random variation"); + RNA_def_property_update(prop, NC_OBJECT|ND_PARTICLE, "rna_Particle_reset"); prop= RNA_def_property(srna, "reaction_shape", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "reactshape"); RNA_def_property_range(prop, 0.0f, 10.0f); RNA_def_property_ui_text(prop, "Shape", "Power of reaction strength dependence on distance to target."); + RNA_def_property_update(prop, NC_OBJECT|ND_PARTICLE, "rna_Particle_reset"); /* global physical properties */ @@ -962,21 +1168,25 @@ static void rna_def_particle_settings(BlenderRNA *brna) RNA_def_property_array(prop, 3); RNA_def_property_range(prop, -200.0f, 200.0f); RNA_def_property_ui_text(prop, "Accelaration", "Constant acceleration"); + RNA_def_property_update(prop, NC_OBJECT|ND_PARTICLE, "rna_Particle_reset"); prop= RNA_def_property(srna, "drag_factor", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "dragfac"); RNA_def_property_range(prop, 0.0f, 1.0f); RNA_def_property_ui_text(prop, "Drag", "Specify the amount of air-drag."); + RNA_def_property_update(prop, NC_OBJECT|ND_PARTICLE, "rna_Particle_reset"); prop= RNA_def_property(srna, "brownian_factor", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "brownfac"); RNA_def_property_range(prop, 0.0f, 200.0f); RNA_def_property_ui_text(prop, "Brownian", "Specify the amount of brownian motion"); + RNA_def_property_update(prop, NC_OBJECT|ND_PARTICLE, "rna_Particle_reset"); prop= RNA_def_property(srna, "damp_factor", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "dampfac"); RNA_def_property_range(prop, 0.0f, 1.0f); RNA_def_property_ui_text(prop, "Damp", "Specify the amount of damping"); + RNA_def_property_update(prop, NC_OBJECT|ND_PARTICLE, "rna_Particle_reset"); /* length */ //TODO: is this readonly? @@ -989,64 +1199,75 @@ static void rna_def_particle_settings(BlenderRNA *brna) RNA_def_property_float_sdna(prop, NULL, "abslength"); RNA_def_property_range(prop, 0.0f, 10000.0f); RNA_def_property_ui_text(prop, "Max Length", "Absolute maximum path length for children, in blender units."); + RNA_def_property_update(prop, NC_OBJECT|ND_PARTICLE, "rna_Particle_redo"); prop= RNA_def_property(srna, "random_length", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "randlength"); RNA_def_property_range(prop, 0.0f, 1.0f); RNA_def_property_ui_text(prop, "Random Length", "Give path length a random variation."); + RNA_def_property_update(prop, NC_OBJECT|ND_PARTICLE, "rna_Particle_redo"); /* children */ - prop= RNA_def_property(srna, "child_nbr", PROP_FLOAT, PROP_NONE); - RNA_def_property_float_sdna(prop, NULL, "child_nbr");//optional if prop names are the same - RNA_def_property_range(prop, 0.0f, MAX_PART_CHILDREN); + prop= RNA_def_property(srna, "child_nbr", PROP_INT, PROP_NONE); + RNA_def_property_int_sdna(prop, NULL, "child_nbr");//optional if prop names are the same + RNA_def_property_range(prop, 0, MAX_PART_CHILDREN); RNA_def_property_ui_text(prop, "Children Per Parent", "Amount of children/parent"); + RNA_def_property_update(prop, NC_OBJECT|ND_PARTICLE, "rna_Particle_redo_child"); - prop= RNA_def_property(srna, "rendered_child_nbr", PROP_FLOAT, PROP_NONE); - RNA_def_property_float_sdna(prop, NULL, "ren_child_nbr"); - RNA_def_property_range(prop, 0.0f, MAX_PART_CHILDREN); + prop= RNA_def_property(srna, "rendered_child_nbr", PROP_INT, PROP_NONE); + RNA_def_property_int_sdna(prop, NULL, "ren_child_nbr"); + RNA_def_property_range(prop, 0, MAX_PART_CHILDREN); RNA_def_property_ui_text(prop, "Rendered Children", "Amount of children/parent for rendering."); prop= RNA_def_property(srna, "virtual_parents", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "parents"); RNA_def_property_range(prop, 0.0f, 1.0f); RNA_def_property_ui_text(prop, "Virtual Parents", "Relative amount of virtual parents."); + RNA_def_property_update(prop, NC_OBJECT|ND_PARTICLE, "rna_Particle_redo_child"); prop= RNA_def_property(srna, "child_size", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "childsize"); RNA_def_property_range(prop, 0.01f, 100.0f); RNA_def_property_ui_text(prop, "Child Size", "A multiplier for the child particle size."); + RNA_def_property_update(prop, NC_OBJECT|ND_PARTICLE, "rna_Particle_redo_child"); prop= RNA_def_property(srna, "child_random_size", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "childrandsize"); RNA_def_property_range(prop, 0.0f, 1.0f); RNA_def_property_ui_text(prop, "Random Child Size", "Random variation to the size of the child particles."); + RNA_def_property_update(prop, NC_OBJECT|ND_PARTICLE, "rna_Particle_redo_child"); prop= RNA_def_property(srna, "child_radius", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "childrad"); RNA_def_property_range(prop, 0.0f, 10.0f); RNA_def_property_ui_text(prop, "Child Radius", "Radius of children around parent."); + RNA_def_property_update(prop, NC_OBJECT|ND_PARTICLE, "rna_Particle_redo_child"); prop= RNA_def_property(srna, "child_roundness", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "childflat"); RNA_def_property_range(prop, 0.0f, 1.0f); RNA_def_property_ui_text(prop, "Child Roundness", "Roundness of children around parent."); + RNA_def_property_update(prop, NC_OBJECT|ND_PARTICLE, "rna_Particle_redo_child"); //TODO: is this readonly? prop= RNA_def_property(srna, "child_spread", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "childspread"); // RNA_def_property_range(prop, 0.0f, upperLimitf); TODO: limits RNA_def_property_ui_text(prop, "Child Spread", ""); + RNA_def_property_update(prop, NC_OBJECT|ND_PARTICLE, "rna_Particle_redo_child"); /* clumping */ prop= RNA_def_property(srna, "clump_factor", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "clumpfac"); RNA_def_property_range(prop, -1.0f, 1.0f); RNA_def_property_ui_text(prop, "Clump", "Amount of clumping"); + RNA_def_property_update(prop, NC_OBJECT|ND_PARTICLE, "rna_Particle_redo_child"); prop= RNA_def_property(srna, "clumppow", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "clumppow"); RNA_def_property_range(prop, -0.999f, 0.999f); RNA_def_property_ui_text(prop, "Shape", "Shape of clumping"); + RNA_def_property_update(prop, NC_OBJECT|ND_PARTICLE, "rna_Particle_redo_child"); /* kink */ @@ -1054,101 +1275,121 @@ static void rna_def_particle_settings(BlenderRNA *brna) RNA_def_property_float_sdna(prop, NULL, "kink_amp"); RNA_def_property_range(prop, 0.0f, 10.0f); RNA_def_property_ui_text(prop, "Amplitude", "The amplitude of the offset."); + RNA_def_property_update(prop, NC_OBJECT|ND_PARTICLE, "rna_Particle_redo_child"); prop= RNA_def_property(srna, "kink_frequency", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "kink_freq"); RNA_def_property_range(prop, 0.0f, 10.0f); RNA_def_property_ui_text(prop, "Frequency", "The frequency of the offset (1/total length)"); + RNA_def_property_update(prop, NC_OBJECT|ND_PARTICLE, "rna_Particle_redo_child"); prop= RNA_def_property(srna, "kink_shape", PROP_FLOAT, PROP_NONE); RNA_def_property_range(prop, -0.999f, 0.999f); RNA_def_property_ui_text(prop, "Shape", "Adjust the offset to the beginning/end"); + RNA_def_property_update(prop, NC_OBJECT|ND_PARTICLE, "rna_Particle_redo_child"); /* rough */ prop= RNA_def_property(srna, "rough1", PROP_FLOAT, PROP_NONE); RNA_def_property_range(prop, 0.0f, 10.0f); RNA_def_property_ui_text(prop, "Rough1", "Amount of location dependent rough."); + RNA_def_property_update(prop, NC_OBJECT|ND_PARTICLE, "rna_Particle_redo_child"); prop= RNA_def_property(srna, "rough1_size", PROP_FLOAT, PROP_NONE); RNA_def_property_range(prop, 0.01f, 10.0f); RNA_def_property_ui_text(prop, "Size1", "Size of location dependent rough."); + RNA_def_property_update(prop, NC_OBJECT|ND_PARTICLE, "rna_Particle_redo_child"); prop= RNA_def_property(srna, "rough2", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "rough2"); RNA_def_property_range(prop, 0.0f, 10.0f); RNA_def_property_ui_text(prop, "Rough2", "Amount of random rough."); + RNA_def_property_update(prop, NC_OBJECT|ND_PARTICLE, "rna_Particle_redo_child"); prop= RNA_def_property(srna, "rough2_size", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "rough2_size"); RNA_def_property_range(prop, 0.01f, 10.0f); RNA_def_property_ui_text(prop, "Size2", "Size of random rough."); + RNA_def_property_update(prop, NC_OBJECT|ND_PARTICLE, "rna_Particle_redo_child"); prop= RNA_def_property(srna, "rough2_thres", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "rough2_thres"); RNA_def_property_range(prop, 0.0f, 1.0f); RNA_def_property_ui_text(prop, "Threshold", "Amount of particles left untouched by random rough."); + RNA_def_property_update(prop, NC_OBJECT|ND_PARTICLE, "rna_Particle_redo_child"); prop= RNA_def_property(srna, "rough_endpoint", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "rough_end"); RNA_def_property_range(prop, 0.0f, 10.0f); RNA_def_property_ui_text(prop, "Rough Endpoint", "Amount of end point rough."); + RNA_def_property_update(prop, NC_OBJECT|ND_PARTICLE, "rna_Particle_redo_child"); prop= RNA_def_property(srna, "rough_end_shape", PROP_FLOAT, PROP_NONE); RNA_def_property_range(prop, 0.0f, 10.0f); RNA_def_property_ui_text(prop, "Shape", "Shape of end point rough"); + RNA_def_property_update(prop, NC_OBJECT|ND_PARTICLE, "rna_Particle_redo_child"); /* branching */ prop= RNA_def_property(srna, "branch_threshold", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "branch_thres"); RNA_def_property_range(prop, 0.0f, 1.0f); RNA_def_property_ui_text(prop, "Threshold", "Threshold of branching."); + RNA_def_property_update(prop, NC_OBJECT|ND_PARTICLE, "rna_Particle_redo_child"); /* drawing stuff */ prop= RNA_def_property(srna, "line_length_tail", PROP_FLOAT, PROP_NONE); RNA_def_property_float_funcs(prop, "rna_PartSetting_linelentail_get", "rna_PartSetting_linelentail_set", NULL); RNA_def_property_range(prop, 0.0f, 10.0f); RNA_def_property_ui_text(prop, "Back", "Length of the line's tail"); + RNA_def_property_update(prop, NC_OBJECT|ND_PARTICLE, "rna_Particle_redo"); prop= RNA_def_property(srna, "line_length_head", PROP_FLOAT, PROP_NONE); RNA_def_property_float_funcs(prop, "rna_PartSetting_linelenhead_get", "rna_PartSetting_linelenhead_set", NULL); RNA_def_property_range(prop, 0.0f, 10.0f); RNA_def_property_ui_text(prop, "Head", "Length of the line's head"); + RNA_def_property_update(prop, NC_OBJECT|ND_PARTICLE, "rna_Particle_redo"); /* boids */ prop= RNA_def_property(srna, "max_velocity", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "max_vel"); RNA_def_property_range(prop, 0.0f, 200.0f); RNA_def_property_ui_text(prop, "Maximum Velocity", ""); + RNA_def_property_update(prop, NC_OBJECT|ND_PARTICLE, "rna_Particle_reset"); prop= RNA_def_property(srna, "lateral_acceleration_max", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "max_lat_acc"); RNA_def_property_range(prop, 0.0f, 1.0f); RNA_def_property_ui_text(prop, "Lateral Acceleration", "Lateral acceleration % of max velocity"); + RNA_def_property_update(prop, NC_OBJECT|ND_PARTICLE, "rna_Particle_reset"); prop= RNA_def_property(srna, "tangential_acceleration_max", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "max_tan_acc"); RNA_def_property_range(prop, 0.0f, 1.0f); RNA_def_property_ui_text(prop, "Tangential acceleration", "Tangential acceleration % of max velocity"); + RNA_def_property_update(prop, NC_OBJECT|ND_PARTICLE, "rna_Particle_reset"); prop= RNA_def_property(srna, "average_velocity", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "average_vel"); RNA_def_property_range(prop, 0.0f, 1.0f); RNA_def_property_ui_text(prop, "Average Velocity", "The usual speed % of max velocity"); + RNA_def_property_update(prop, NC_OBJECT|ND_PARTICLE, "rna_Particle_reset"); prop= RNA_def_property(srna, "banking", PROP_FLOAT, PROP_NONE); RNA_def_property_range(prop, -10.0f, 10.0f); RNA_def_property_ui_text(prop, "Banking", "Banking of boids on turns (1.0==natural banking)"); + RNA_def_property_update(prop, NC_OBJECT|ND_PARTICLE, "rna_Particle_reset"); prop= RNA_def_property(srna, "banking_max", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "max_bank"); RNA_def_property_range(prop, 0.0f, 1.0f); RNA_def_property_ui_text(prop, "Maximum Banking", "How much a boid can bank at a single step"); + RNA_def_property_update(prop, NC_OBJECT|ND_PARTICLE, "rna_Particle_reset"); prop= RNA_def_property(srna, "ground_z", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "groundz"); RNA_def_property_range(prop, -100.0f, 100.0f); RNA_def_property_ui_text(prop, "Ground Z", "Default Z value"); + RNA_def_property_update(prop, NC_OBJECT|ND_PARTICLE, "rna_Particle_reset"); /*TODO: not sure how to deal with this prop= RNA_def_property(srna, "boid_factor", PROP_FLOAT, PROP_VECTOR); @@ -1163,24 +1404,28 @@ static void rna_def_particle_settings(BlenderRNA *brna) RNA_def_property_struct_type(prop, "Group"); RNA_def_property_flag(prop, PROP_EDITABLE); RNA_def_property_ui_text(prop, "Dupli Group", "Show Objects in this Group in place of particles"); + RNA_def_property_update(prop, NC_OBJECT|ND_PARTICLE, "rna_Particle_redo"); prop= RNA_def_property(srna, "effector_group", PROP_POINTER, PROP_NONE); RNA_def_property_pointer_sdna(prop, NULL, "eff_group"); RNA_def_property_struct_type(prop, "Group"); RNA_def_property_flag(prop, PROP_EDITABLE); RNA_def_property_ui_text(prop, "Effector Group", "Limit effectors to this Group."); + RNA_def_property_update(prop, NC_OBJECT|ND_PARTICLE, "rna_Particle_reset"); prop= RNA_def_property(srna, "dupli_object", PROP_POINTER, PROP_NONE); RNA_def_property_pointer_sdna(prop, NULL, "dup_ob"); RNA_def_property_struct_type(prop, "Object"); RNA_def_property_flag(prop, PROP_EDITABLE); RNA_def_property_ui_text(prop, "Dupli Object", "Show this Object in place of particles."); + RNA_def_property_update(prop, NC_OBJECT|ND_PARTICLE, "rna_Particle_redo"); prop= RNA_def_property(srna, "billboard_object", PROP_POINTER, PROP_NONE); RNA_def_property_pointer_sdna(prop, NULL, "bb_ob"); RNA_def_property_struct_type(prop, "Object"); RNA_def_property_flag(prop, PROP_EDITABLE); RNA_def_property_ui_text(prop, "Billboard Object", "Billboards face this object (default is active camera)"); + RNA_def_property_update(prop, NC_OBJECT|ND_PARTICLE, "rna_Particle_redo"); #if 0 prop= RNA_def_property(srna, "ipo", PROP_POINTER, PROP_NONE); @@ -1225,6 +1470,7 @@ static void rna_def_particle_system(BlenderRNA *brna) prop= RNA_def_property(srna, "seed", PROP_INT, PROP_UNSIGNED); RNA_def_property_ui_text(prop, "Seed", "Offset in the random number table, to get a different randomized result."); + RNA_def_property_update(prop, NC_OBJECT|ND_PARTICLE, "rna_Particle_reset"); /* hair */ prop= RNA_def_property(srna, "softbody", PROP_POINTER, PROP_NONE); @@ -1245,37 +1491,43 @@ static void rna_def_particle_system(BlenderRNA *brna) RNA_def_property_pointer_sdna(prop, NULL, "target_ob"); RNA_def_property_flag(prop, PROP_EDITABLE); RNA_def_property_ui_text(prop, "Reactor Target Object", "For reactor systems, the object that has the target particle system (empty if same object)."); + RNA_def_property_update(prop, NC_OBJECT|ND_PARTICLE, "rna_Particle_reset"); prop= RNA_def_property(srna, "reactor_target_particle_system", PROP_INT, PROP_UNSIGNED); RNA_def_property_int_sdna(prop, NULL, "target_psys"); RNA_def_property_range(prop, 1, INT_MAX); RNA_def_property_ui_text(prop, "Reactor Target Particle System", "For reactor systems, index of particle system on the target object."); + RNA_def_property_update(prop, NC_OBJECT|ND_PARTICLE, "rna_Particle_reset"); /* boids */ prop= RNA_def_property(srna, "boids_surface_object", PROP_POINTER, PROP_NONE); RNA_def_property_pointer_sdna(prop, NULL, "keyed_ob"); RNA_def_property_flag(prop, PROP_EDITABLE); RNA_def_property_ui_text(prop, "Boids Surface Object", "For boids physics systems, constrain boids to this object's surface."); + RNA_def_property_update(prop, NC_OBJECT|ND_PARTICLE, "rna_Particle_reset"); /* keyed */ prop= RNA_def_property(srna, "keyed_object", PROP_POINTER, PROP_NONE); RNA_def_property_pointer_sdna(prop, NULL, "keyed_ob"); RNA_def_property_flag(prop, PROP_EDITABLE); RNA_def_property_ui_text(prop, "Keyed Object", "For keyed physics systems, the object that has the target particle system."); + RNA_def_property_update(prop, NC_OBJECT|ND_PARTICLE, "rna_Particle_reset"); prop= RNA_def_property(srna, "keyed_particle_system", PROP_INT, PROP_UNSIGNED); RNA_def_property_int_sdna(prop, NULL, "keyed_psys"); RNA_def_property_range(prop, 1, INT_MAX); RNA_def_property_ui_text(prop, "Keyed Particle System", "For keyed physics systems, index of particle system on the keyed object."); + RNA_def_property_update(prop, NC_OBJECT|ND_PARTICLE, "rna_Particle_reset"); prop= RNA_def_property(srna, "keyed_first", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", PSYS_FIRST_KEYED); RNA_def_property_ui_text(prop, "Keyed First", "Set the system to be the starting point of keyed particles"); + RNA_def_property_update(prop, NC_OBJECT|ND_PARTICLE, "rna_Particle_reset"); prop= RNA_def_property(srna, "keyed_timed", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", PSYS_KEYED_TIME); RNA_def_property_ui_text(prop, "Keyed Timed", "Use intermediate key times for keyed particles (setting for starting point only)."); - + RNA_def_property_update(prop, NC_OBJECT|ND_PARTICLE, "rna_Particle_reset"); /* billboard */ prop= RNA_def_property(srna, "billboard_normal_uv", PROP_STRING, PROP_NONE); @@ -1297,98 +1549,122 @@ static void rna_def_particle_system(BlenderRNA *brna) prop= RNA_def_property(srna, "vertex_group_density", PROP_INT, PROP_NONE); RNA_def_property_int_sdna(prop, NULL, "vgroup[0]"); RNA_def_property_ui_text(prop, "Vertex Group Density", "Vertex group to control density."); + RNA_def_property_update(prop, NC_OBJECT|ND_PARTICLE, "rna_Particle_reset"); prop= RNA_def_property(srna, "vertex_group_density_negate", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "vg_neg", (1 << PSYS_VG_DENSITY)); RNA_def_property_ui_text(prop, "Vertex Group Density Negate", "Negate the effect of the density vertex group."); + RNA_def_property_update(prop, NC_OBJECT|ND_PARTICLE, "rna_Particle_reset"); prop= RNA_def_property(srna, "vertex_group_velocity", PROP_INT, PROP_NONE); RNA_def_property_int_sdna(prop, NULL, "vgroup[1]"); RNA_def_property_ui_text(prop, "Vertex Group Velocity", "Vertex group to control velocity."); + RNA_def_property_update(prop, NC_OBJECT|ND_PARTICLE, "rna_Particle_reset"); prop= RNA_def_property(srna, "vertex_group_velocity_negate", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "vg_neg", (1 << PSYS_VG_VEL)); RNA_def_property_ui_text(prop, "Vertex Group Velocity Negate", "Negate the effect of the velocity vertex group."); + RNA_def_property_update(prop, NC_OBJECT|ND_PARTICLE, "rna_Particle_reset"); prop= RNA_def_property(srna, "vertex_group_length", PROP_INT, PROP_NONE); RNA_def_property_int_sdna(prop, NULL, "vgroup[2]"); RNA_def_property_ui_text(prop, "Vertex Group Length", "Vertex group to control length."); + RNA_def_property_update(prop, NC_OBJECT|ND_PARTICLE, "rna_Particle_redo"); prop= RNA_def_property(srna, "vertex_group_length_negate", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "vg_neg", (1 << PSYS_VG_LENGTH)); RNA_def_property_ui_text(prop, "Vertex Group Length Negate", "Negate the effect of the length vertex group."); + RNA_def_property_update(prop, NC_OBJECT|ND_PARTICLE, "rna_Particle_redo"); prop= RNA_def_property(srna, "vertex_group_clump", PROP_INT, PROP_NONE); RNA_def_property_int_sdna(prop, NULL, "vgroup[3]"); RNA_def_property_ui_text(prop, "Vertex Group Clump", "Vertex group to control clump."); + RNA_def_property_update(prop, NC_OBJECT|ND_PARTICLE, "rna_Particle_redo_child"); prop= RNA_def_property(srna, "vertex_group_clump_negate", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "vg_neg", (1 << PSYS_VG_CLUMP)); RNA_def_property_ui_text(prop, "Vertex Group Clump Negate", "Negate the effect of the clump vertex group."); + RNA_def_property_update(prop, NC_OBJECT|ND_PARTICLE, "rna_Particle_redo_child"); prop= RNA_def_property(srna, "vertex_group_kink", PROP_INT, PROP_NONE); RNA_def_property_int_sdna(prop, NULL, "vgroup[4]"); RNA_def_property_ui_text(prop, "Vertex Group Kink", "Vertex group to control kink."); + RNA_def_property_update(prop, NC_OBJECT|ND_PARTICLE, "rna_Particle_redo_child"); prop= RNA_def_property(srna, "vertex_group_kink_negate", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "vg_neg", (1 << PSYS_VG_KINK)); RNA_def_property_ui_text(prop, "Vertex Group Kink Negate", "Negate the effect of the kink vertex group."); + RNA_def_property_update(prop, NC_OBJECT|ND_PARTICLE, "rna_Particle_redo_child"); prop= RNA_def_property(srna, "vertex_group_roughness1", PROP_INT, PROP_NONE); RNA_def_property_int_sdna(prop, NULL, "vgroup[5]"); RNA_def_property_ui_text(prop, "Vertex Group Roughness 1", "Vertex group to control roughness 1."); + RNA_def_property_update(prop, NC_OBJECT|ND_PARTICLE, "rna_Particle_redo_child"); prop= RNA_def_property(srna, "vertex_group_roughness1_negate", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "vg_neg", (1 << PSYS_VG_ROUGH1)); RNA_def_property_ui_text(prop, "Vertex Group Roughness 1 Negate", "Negate the effect of the roughness 1 vertex group."); + RNA_def_property_update(prop, NC_OBJECT|ND_PARTICLE, "rna_Particle_redo_child"); prop= RNA_def_property(srna, "vertex_group_roughness2", PROP_INT, PROP_NONE); RNA_def_property_int_sdna(prop, NULL, "vgroup[6]"); RNA_def_property_ui_text(prop, "Vertex Group Roughness 2", "Vertex group to control roughness 2."); + RNA_def_property_update(prop, NC_OBJECT|ND_PARTICLE, "rna_Particle_redo_child"); prop= RNA_def_property(srna, "vertex_group_roughness2_negate", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "vg_neg", (1 << PSYS_VG_ROUGH2)); RNA_def_property_ui_text(prop, "Vertex Group Roughness 2 Negate", "Negate the effect of the roughness 2 vertex group."); + RNA_def_property_update(prop, NC_OBJECT|ND_PARTICLE, "rna_Particle_redo_child"); prop= RNA_def_property(srna, "vertex_group_roughness_end", PROP_INT, PROP_NONE); RNA_def_property_int_sdna(prop, NULL, "vgroup[7]"); RNA_def_property_ui_text(prop, "Vertex Group Roughness End", "Vertex group to control roughness end."); + RNA_def_property_update(prop, NC_OBJECT|ND_PARTICLE, "rna_Particle_redo_child"); prop= RNA_def_property(srna, "vertex_group_roughness_end_negate", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "vg_neg", (1 << PSYS_VG_ROUGHE)); RNA_def_property_ui_text(prop, "Vertex Group Roughness End Negate", "Negate the effect of the roughness end vertex group."); + RNA_def_property_update(prop, NC_OBJECT|ND_PARTICLE, "rna_Particle_redo_child"); prop= RNA_def_property(srna, "vertex_group_size", PROP_INT, PROP_NONE); RNA_def_property_int_sdna(prop, NULL, "vgroup[8]"); RNA_def_property_ui_text(prop, "Vertex Group Size", "Vertex group to control size."); + RNA_def_property_update(prop, NC_OBJECT|ND_PARTICLE, "rna_Particle_reset"); prop= RNA_def_property(srna, "vertex_group_size_negate", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "vg_neg", (1 << PSYS_VG_SIZE)); RNA_def_property_ui_text(prop, "Vertex Group Size Negate", "Negate the effect of the size vertex group."); + RNA_def_property_update(prop, NC_OBJECT|ND_PARTICLE, "rna_Particle_reset"); prop= RNA_def_property(srna, "vertex_group_tangent", PROP_INT, PROP_NONE); RNA_def_property_int_sdna(prop, NULL, "vgroup[9]"); RNA_def_property_ui_text(prop, "Vertex Group Tangent", "Vertex group to control tangent."); + RNA_def_property_update(prop, NC_OBJECT|ND_PARTICLE, "rna_Particle_reset"); prop= RNA_def_property(srna, "vertex_group_tangent_negate", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "vg_neg", (1 << PSYS_VG_TAN)); RNA_def_property_ui_text(prop, "Vertex Group Tangent Negate", "Negate the effect of the tangent vertex group."); + RNA_def_property_update(prop, NC_OBJECT|ND_PARTICLE, "rna_Particle_reset"); prop= RNA_def_property(srna, "vertex_group_rotation", PROP_INT, PROP_NONE); RNA_def_property_int_sdna(prop, NULL, "vgroup[10]"); RNA_def_property_ui_text(prop, "Vertex Group Rotation", "Vertex group to control rotation."); + RNA_def_property_update(prop, NC_OBJECT|ND_PARTICLE, "rna_Particle_reset"); prop= RNA_def_property(srna, "vertex_group_rotation_negate", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "vg_neg", (1 << PSYS_VG_ROT)); RNA_def_property_ui_text(prop, "Vertex Group Rotation Negate", "Negate the effect of the rotation vertex group."); + RNA_def_property_update(prop, NC_OBJECT|ND_PARTICLE, "rna_Particle_reset"); prop= RNA_def_property(srna, "vertex_group_field", PROP_INT, PROP_NONE); RNA_def_property_int_sdna(prop, NULL, "vgroup[11]"); RNA_def_property_ui_text(prop, "Vertex Group Field", "Vertex group to control field."); + RNA_def_property_update(prop, NC_OBJECT|ND_PARTICLE, "rna_Particle_reset"); prop= RNA_def_property(srna, "vertex_group_field_negate", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "vg_neg", (1 << PSYS_VG_EFFECTOR)); RNA_def_property_ui_text(prop, "Vertex Group Field Negate", "Negate the effect of the field vertex group."); + RNA_def_property_update(prop, NC_OBJECT|ND_PARTICLE, "rna_Particle_reset"); /* pointcache */ prop= RNA_def_property(srna, "point_cache", PROP_POINTER, PROP_NEVER_NULL); diff --git a/source/blender/render/intern/source/convertblender.c b/source/blender/render/intern/source/convertblender.c index 6bc88f7499b..996bf2c3b19 100644 --- a/source/blender/render/intern/source/convertblender.c +++ b/source/blender/render/intern/source/convertblender.c @@ -1459,7 +1459,7 @@ static int render_new_particle_system(Render *re, ObjectRen *obr, ParticleSystem if(part==NULL || pars==NULL || !psys_check_enabled(ob, psys)) return 0; - if(part->draw_as==PART_DRAW_OB || part->draw_as==PART_DRAW_GR || part->draw_as==PART_DRAW_NOT) + if(part->ren_as==PART_DRAW_OB || part->ren_as==PART_DRAW_GR || part->ren_as==PART_DRAW_NOT) return 1; /* 2. start initialising things */ @@ -1522,7 +1522,7 @@ static int render_new_particle_system(Render *re, ObjectRen *obr, ParticleSystem sd.mcol = MEM_callocN(sd.totcol * sizeof(MCol), "particle_mcols"); /* 2.2 setup billboards */ - if(part->draw_as == PART_DRAW_BB) { + if(part->ren_as == PART_DRAW_BB) { int first_uv = CustomData_get_layer_index(&psmd->dm->faceData, CD_MTFACE); bb.uv[0] = CustomData_get_named_layer_index(&psmd->dm->faceData, CD_MTFACE, psys->bb_uvname[0]); @@ -1577,7 +1577,7 @@ static int render_new_particle_system(Render *re, ObjectRen *obr, ParticleSystem Mat3Transp(nmat); /* 2.6 setup strand rendering */ - if(part->draw_as == PART_DRAW_PATH && psys->pathcache){ + if(part->ren_as == PART_DRAW_PATH && psys->pathcache){ path_nbr=(int)pow(2.0,(double) part->ren_step); if(path_nbr) { @@ -1884,10 +1884,10 @@ static int render_new_particle_system(Render *re, ObjectRen *obr, ParticleSystem continue; VECCOPY(loc,state.co); - if(part->draw_as!=PART_DRAW_BB) + if(part->ren_as!=PART_DRAW_BB) MTC_Mat4MulVecfl(re->viewmat,loc); - switch(part->draw_as) { + switch(part->ren_as) { case PART_DRAW_LINE: sd.line = 1; sd.time = 0.0f; @@ -4379,7 +4379,7 @@ static int allow_render_dupli_instance(Render *re, DupliObject *dob, Object *obd } for(psys=obd->particlesystem.first; psys; psys=psys->next) - if(!ELEM5(psys->part->draw_as, PART_DRAW_BB, PART_DRAW_LINE, PART_DRAW_PATH, PART_DRAW_OB, PART_DRAW_GR)) + if(!ELEM5(psys->part->ren_as, PART_DRAW_BB, PART_DRAW_LINE, PART_DRAW_PATH, PART_DRAW_OB, PART_DRAW_GR)) return 0; /* don't allow lamp, animated duplis, or radio render */ @@ -4402,7 +4402,7 @@ static void dupli_render_particle_set(Render *re, Object *ob, int timeoffset, in if(ob->transflag & OB_DUPLIPARTS) { for(psys=ob->particlesystem.first; psys; psys=psys->next) { - if(ELEM(psys->part->draw_as, PART_DRAW_OB, PART_DRAW_GR)) { + if(ELEM(psys->part->ren_as, PART_DRAW_OB, PART_DRAW_GR)) { if(enable) psys_render_set(ob, psys, re->viewmat, re->winmat, re->winx, re->winy, timeoffset); else diff --git a/source/blender/windowmanager/WM_types.h b/source/blender/windowmanager/WM_types.h index 09b81d69ac0..8b04d55c696 100644 --- a/source/blender/windowmanager/WM_types.h +++ b/source/blender/windowmanager/WM_types.h @@ -197,6 +197,7 @@ typedef struct wmNotifier { #define ND_KEYS (24<<16) #define ND_GEOM_DATA (25<<16) #define ND_CONSTRAINT (26<<16) +#define ND_PARTICLE (27<<16) /* NC_MATERIAL Material */ #define ND_SHADING (30<<16)