Fixing several issues with keyingsets:
*Add a new idname to keyingsets, keeping name as label-only (using same string for both made lookup fail when using i18n other than english, as it tried to compare an untranslated static string id against a translated RNA name). Also adding a description string (can be helpful with custom keyingsets, imho). *Fixed a few other bugs related to that area (namely, you can’t deselect current keyingset from the shift-ctrl-alt-I popup menu, and insert/delete key ops were using a rather strange way to get chosen custom keyingset…). *Fixed UI code so that it always uses (RNA) enum, and simplified menu-creation code.
This commit is contained in:
parent
a5f2db9992
commit
a80b7d6129
Notes:
blender-bot
2023-02-14 04:07:50 +01:00
Referenced by issue #61010, Keying Set - Description edit box disabled, for internal use only
|
@ -67,15 +67,16 @@ class ANIM_OT_keying_set_export(Operator):
|
|||
scene = context.scene
|
||||
ks = scene.keying_sets.active
|
||||
|
||||
f.write("# Keying Set: %s\n" % ks.name)
|
||||
f.write("# Keying Set: %s\n" % ks.bl_idname)
|
||||
|
||||
f.write("import bpy\n\n")
|
||||
# XXX, why not current scene?
|
||||
f.write("scene= bpy.data.scenes[0]\n\n")
|
||||
f.write("scene = bpy.context.scene\n\n")
|
||||
|
||||
# Add KeyingSet and set general settings
|
||||
f.write("# Keying Set Level declarations\n")
|
||||
f.write("ks= scene.keying_sets.new(name=\"%s\")\n" % ks.name)
|
||||
f.write("ks = scene.keying_sets.new(idname=\"%s\", name=\"%s\")\n"
|
||||
"" % (ks.bl_idname, ks.bl_label))
|
||||
f.write("ks.bl_description = \"%s\"\n" % ks.bl_description)
|
||||
|
||||
if not ks.is_path_absolute:
|
||||
f.write("ks.is_path_absolute = False\n")
|
||||
|
|
|
@ -115,7 +115,8 @@ class SCENE_PT_keying_sets(SceneButtonsPanel, Panel):
|
|||
row = layout.row()
|
||||
|
||||
col = row.column()
|
||||
col.prop(ks, "name")
|
||||
col.prop(ks, "bl_label")
|
||||
col.prop(ks, "bl_description")
|
||||
|
||||
subcol = col.column()
|
||||
subcol.operator_context = 'INVOKE_DEFAULT'
|
||||
|
|
|
@ -38,8 +38,20 @@ from bpy.types import KeyingSetInfo
|
|||
# Built-In KeyingSets
|
||||
|
||||
|
||||
# "Defines"
|
||||
# Keep these in sync with those in ED_keyframing.h!
|
||||
ANIM_KS_LOCATION_ID = "Location"
|
||||
ANIM_KS_ROTATION_ID = "Rotation"
|
||||
ANIM_KS_SCALING_ID = "Scaling"
|
||||
ANIM_KS_LOC_ROT_SCALE_ID = "LocRotScale"
|
||||
ANIM_KS_AVAILABLE_ID = "Available"
|
||||
ANIM_KS_WHOLE_CHARACTER_ID = "Whole Character"
|
||||
|
||||
|
||||
# Location
|
||||
class BUILTIN_KSI_Location(KeyingSetInfo):
|
||||
"""Insert a keyframe on each of the three location channels"""
|
||||
bl_idname = ANIM_KS_LOCATION_ID
|
||||
bl_label = "Location"
|
||||
|
||||
# poll - use predefined callback for selected bones/objects
|
||||
|
@ -54,6 +66,8 @@ class BUILTIN_KSI_Location(KeyingSetInfo):
|
|||
|
||||
# Rotation
|
||||
class BUILTIN_KSI_Rotation(KeyingSetInfo):
|
||||
"""Insert a keyframe on each of the rotation channels"""
|
||||
bl_idname = ANIM_KS_ROTATION_ID
|
||||
bl_label = "Rotation"
|
||||
|
||||
# poll - use predefined callback for selected bones/objects
|
||||
|
@ -62,12 +76,14 @@ class BUILTIN_KSI_Rotation(KeyingSetInfo):
|
|||
# iterator - use callback for selected bones/objects
|
||||
iterator = keyingsets_utils.RKS_ITER_selected_item
|
||||
|
||||
# generator - use callback for location
|
||||
# generator - use callback for rotation
|
||||
generate = keyingsets_utils.RKS_GEN_rotation
|
||||
|
||||
|
||||
# Scale
|
||||
class BUILTIN_KSI_Scaling(KeyingSetInfo):
|
||||
"""Insert a keyframe on each of the scale channels"""
|
||||
bl_idname = ANIM_KS_SCALING_ID
|
||||
bl_label = "Scaling"
|
||||
|
||||
# poll - use predefined callback for selected bones/objects
|
||||
|
@ -76,7 +92,7 @@ class BUILTIN_KSI_Scaling(KeyingSetInfo):
|
|||
# iterator - use callback for selected bones/objects
|
||||
iterator = keyingsets_utils.RKS_ITER_selected_item
|
||||
|
||||
# generator - use callback for location
|
||||
# generator - use callback for scaling
|
||||
generate = keyingsets_utils.RKS_GEN_scaling
|
||||
|
||||
# ------------
|
||||
|
@ -84,6 +100,7 @@ class BUILTIN_KSI_Scaling(KeyingSetInfo):
|
|||
|
||||
# LocRot
|
||||
class BUILTIN_KSI_LocRot(KeyingSetInfo):
|
||||
"""Insert a keyframe on each of the location and rotation channels"""
|
||||
bl_label = "LocRot"
|
||||
|
||||
# poll - use predefined callback for selected bones/objects
|
||||
|
@ -102,6 +119,7 @@ class BUILTIN_KSI_LocRot(KeyingSetInfo):
|
|||
|
||||
# LocScale
|
||||
class BUILTIN_KSI_LocScale(KeyingSetInfo):
|
||||
"""Insert a keyframe on each of the location and scale channels"""
|
||||
bl_label = "LocScale"
|
||||
|
||||
# poll - use predefined callback for selected bones/objects
|
||||
|
@ -120,6 +138,10 @@ class BUILTIN_KSI_LocScale(KeyingSetInfo):
|
|||
|
||||
# LocRotScale
|
||||
class BUILTIN_KSI_LocRotScale(KeyingSetInfo):
|
||||
"""
|
||||
Insert a keyframe on each of the location, rotation and scale channels
|
||||
"""
|
||||
bl_idname = ANIM_KS_LOC_ROT_SCALE_ID
|
||||
bl_label = "LocRotScale"
|
||||
|
||||
# poll - use predefined callback for selected bones/objects
|
||||
|
@ -140,6 +162,7 @@ class BUILTIN_KSI_LocRotScale(KeyingSetInfo):
|
|||
|
||||
# RotScale
|
||||
class BUILTIN_KSI_RotScale(KeyingSetInfo):
|
||||
"""Insert a keyframe on each of the rotation and scale channels"""
|
||||
bl_label = "RotScale"
|
||||
|
||||
# poll - use predefined callback for selected bones/objects
|
||||
|
@ -160,6 +183,10 @@ class BUILTIN_KSI_RotScale(KeyingSetInfo):
|
|||
|
||||
# Location
|
||||
class BUILTIN_KSI_VisualLoc(KeyingSetInfo):
|
||||
"""
|
||||
Insert a keyframe on each of the location channels, taking into account
|
||||
constraints and relationships effects
|
||||
"""
|
||||
bl_label = "Visual Location"
|
||||
|
||||
bl_options = {'INSERTKEY_VISUAL'}
|
||||
|
@ -176,6 +203,10 @@ class BUILTIN_KSI_VisualLoc(KeyingSetInfo):
|
|||
|
||||
# Rotation
|
||||
class BUILTIN_KSI_VisualRot(KeyingSetInfo):
|
||||
"""
|
||||
Insert a keyframe on each of the rotation channels, taking into account
|
||||
constraints and relationships effects
|
||||
"""
|
||||
bl_label = "Visual Rotation"
|
||||
|
||||
bl_options = {'INSERTKEY_VISUAL'}
|
||||
|
@ -192,6 +223,10 @@ class BUILTIN_KSI_VisualRot(KeyingSetInfo):
|
|||
|
||||
# VisualLocRot
|
||||
class BUILTIN_KSI_VisualLocRot(KeyingSetInfo):
|
||||
"""
|
||||
Insert a keyframe on each of the location and rotation channels),
|
||||
taking into account constraints and relationships effects
|
||||
"""
|
||||
bl_label = "Visual LocRot"
|
||||
|
||||
bl_options = {'INSERTKEY_VISUAL'}
|
||||
|
@ -214,6 +249,8 @@ class BUILTIN_KSI_VisualLocRot(KeyingSetInfo):
|
|||
|
||||
# Available
|
||||
class BUILTIN_KSI_Available(KeyingSetInfo):
|
||||
"""Insert a keyframe on each of the already existing F-Curves"""
|
||||
bl_idname = ANIM_KS_AVAILABLE_ID
|
||||
bl_label = "Available"
|
||||
|
||||
# poll - selected objects or selected object with animation data
|
||||
|
@ -236,6 +273,11 @@ class BUILTIN_KSI_Available(KeyingSetInfo):
|
|||
|
||||
# All properties that are likely to get animated in a character rig
|
||||
class BUILTIN_KSI_WholeCharacter(KeyingSetInfo):
|
||||
"""
|
||||
Insert a keyframe for all properties that are likely to get animated in a
|
||||
character rig (useful when blocking out a shot)
|
||||
"""
|
||||
bl_idname = ANIM_KS_WHOLE_CHARACTER_ID
|
||||
bl_label = "Whole Character"
|
||||
|
||||
# these prefixes should be avoided, as they are not really bones
|
||||
|
@ -379,6 +421,7 @@ class BUILTIN_KSI_WholeCharacter(KeyingSetInfo):
|
|||
|
||||
# Delta Location
|
||||
class BUILTIN_KSI_DeltaLocation(KeyingSetInfo):
|
||||
"""Insert keyframes for additional location offset"""
|
||||
bl_label = "Delta Location"
|
||||
|
||||
# poll - selected objects only (and only if active object in object mode)
|
||||
|
@ -404,6 +447,7 @@ class BUILTIN_KSI_DeltaLocation(KeyingSetInfo):
|
|||
|
||||
# Delta Rotation
|
||||
class BUILTIN_KSI_DeltaRotation(KeyingSetInfo):
|
||||
"""Insert keyframes for additional rotation offset"""
|
||||
bl_label = "Delta Rotation"
|
||||
|
||||
# poll - selected objects only (and only if active object in object mode)
|
||||
|
@ -437,6 +481,7 @@ class BUILTIN_KSI_DeltaRotation(KeyingSetInfo):
|
|||
|
||||
# Delta Scale
|
||||
class BUILTIN_KSI_DeltaScale(KeyingSetInfo):
|
||||
"""Insert keyframes for additional scaling factor"""
|
||||
bl_label = "Delta Scale"
|
||||
|
||||
# poll - selected objects only (and only if active object in object mode)
|
||||
|
|
|
@ -81,7 +81,7 @@ void BKE_relink_animdata(struct AnimData *adt);
|
|||
/* KeyingSets API */
|
||||
|
||||
/* Used to create a new 'custom' KeyingSet for the user, that will be automatically added to the stack */
|
||||
struct KeyingSet *BKE_keyingset_add(struct ListBase *list, const char name[], short flag, short keyingflag);
|
||||
struct KeyingSet *BKE_keyingset_add(struct ListBase *list, const char idname[], const char name[], short flag, short keyingflag);
|
||||
|
||||
/* Add a path to a KeyingSet */
|
||||
struct KS_Path *BKE_keyingset_add_path(struct KeyingSet *ks, struct ID *id, const char group_name[], const char rna_path[], int array_index, short flag, short groupmode);
|
||||
|
|
|
@ -941,14 +941,16 @@ KS_Path *BKE_keyingset_find_path (KeyingSet *ks, ID *id, const char group_name[]
|
|||
/* Defining Tools --------------------------- */
|
||||
|
||||
/* Used to create a new 'custom' KeyingSet for the user, that will be automatically added to the stack */
|
||||
KeyingSet *BKE_keyingset_add (ListBase *list, const char name[], short flag, short keyingflag)
|
||||
KeyingSet *BKE_keyingset_add (ListBase *list, const char idname[], const char name[], short flag, short keyingflag)
|
||||
{
|
||||
KeyingSet *ks;
|
||||
|
||||
/* allocate new KeyingSet */
|
||||
ks= MEM_callocN(sizeof(KeyingSet), "KeyingSet");
|
||||
|
||||
BLI_strncpy(ks->name, name ? name : "KeyingSet", sizeof(ks->name));
|
||||
BLI_strncpy(ks->idname, idname ? idname : name ? name : "KeyingSet", sizeof(ks->idname));
|
||||
|
||||
BLI_strncpy(ks->name, name ? name : idname ? idname : "Keying Set", sizeof(ks->name));
|
||||
|
||||
ks->flag= flag;
|
||||
ks->keyingflag= keyingflag;
|
||||
|
@ -956,8 +958,11 @@ KeyingSet *BKE_keyingset_add (ListBase *list, const char name[], short flag, sho
|
|||
/* add KeyingSet to list */
|
||||
BLI_addtail(list, ks);
|
||||
|
||||
/* make sure KeyingSet has a unique name (this helps with identification) */
|
||||
BLI_uniquename(list, ks, "KeyingSet", '.', offsetof(KeyingSet, name), sizeof(ks->name));
|
||||
/* Make sure KeyingSet has a unique idname. */
|
||||
BLI_uniquename(list, ks, "KeyingSet", '.', offsetof(KeyingSet, idname), sizeof(ks->idname));
|
||||
|
||||
/* Make sure KeyingSet has a unique label (this helps with identification). */
|
||||
BLI_uniquename(list, ks, "Keying Set", '.', offsetof(KeyingSet, name), sizeof(ks->name));
|
||||
|
||||
/* return new KeyingSet for further editing */
|
||||
return ks;
|
||||
|
|
|
@ -13245,6 +13245,20 @@ static void do_versions(FileData *fd, Library *lib, Main *main)
|
|||
do_versions_nodetree_multi_file_output_format_2_62_1(NULL, ntree);
|
||||
}
|
||||
|
||||
/* put compatibility code here until next subversion bump */
|
||||
{
|
||||
{
|
||||
/* Set new idname of keyingsets from their now "label-only" name. */
|
||||
Scene *scene;
|
||||
for (scene = main->scene.first; scene; scene = scene->id.next) {
|
||||
KeyingSet *ks;
|
||||
for (ks = scene->keyingsets.first; ks; ks = ks->next) {
|
||||
if (!ks->idname[0])
|
||||
BLI_strncpy(ks->idname, ks->name, sizeof(ks->idname));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* WATCH IT!!!: pointers from libdata have not been converted yet here! */
|
||||
/* WATCH IT 2!: Userdef struct init has to be in editors/interface/resources.c! */
|
||||
|
|
|
@ -71,6 +71,7 @@
|
|||
#include "ED_screen.h"
|
||||
|
||||
#include "UI_interface.h"
|
||||
#include "UI_resources.h"
|
||||
|
||||
#include "WM_api.h"
|
||||
#include "WM_types.h"
|
||||
|
@ -1115,7 +1116,7 @@ static int insert_key_exec (bContext *C, wmOperator *op)
|
|||
if (type == 0)
|
||||
type= scene->active_keyingset;
|
||||
if (type > 0)
|
||||
ks= BLI_findlink(&scene->keyingsets, scene->active_keyingset-1);
|
||||
ks= BLI_findlink(&scene->keyingsets, type-1);
|
||||
else
|
||||
ks= BLI_findlink(&builtin_keyingsets, -type-1);
|
||||
|
||||
|
@ -1193,8 +1194,15 @@ static int insert_key_menu_invoke (bContext *C, wmOperator *op, wmEvent *UNUSED(
|
|||
|
||||
/* if prompting or no active Keying Set, show the menu */
|
||||
if ((scene->active_keyingset == 0) || RNA_boolean_get(op->ptr, "always_prompt")) {
|
||||
uiPopupMenu *pup;
|
||||
uiLayout *layout;
|
||||
|
||||
/* call the menu, which will call this operator again, hence the canceled */
|
||||
ANIM_keying_sets_menu_setup(C, op->type->name, "ANIM_OT_keyframe_insert_menu");
|
||||
pup = uiPupMenuBegin(C, op->type->name, ICON_NONE);
|
||||
layout = uiPupMenuLayout(pup);
|
||||
uiItemsEnumO(layout, "ANIM_OT_keyframe_insert_menu", "type");
|
||||
uiPupMenuEnd(C, pup);
|
||||
|
||||
return OPERATOR_CANCELLED;
|
||||
}
|
||||
else {
|
||||
|
@ -1264,7 +1272,7 @@ static int delete_key_exec (bContext *C, wmOperator *op)
|
|||
if (type == 0)
|
||||
type= scene->active_keyingset;
|
||||
if (type > 0)
|
||||
ks= BLI_findlink(&scene->keyingsets, scene->active_keyingset-1);
|
||||
ks= BLI_findlink(&scene->keyingsets, type-1);
|
||||
else
|
||||
ks= BLI_findlink(&builtin_keyingsets, -type-1);
|
||||
|
||||
|
|
|
@ -127,7 +127,7 @@ static int add_default_keyingset_exec (bContext *C, wmOperator *UNUSED(op))
|
|||
keyingflag = ANIM_get_keyframing_flags(scene, 0);
|
||||
|
||||
/* call the API func, and set the active keyingset index */
|
||||
BKE_keyingset_add(&scene->keyingsets, NULL, flag, keyingflag);
|
||||
BKE_keyingset_add(&scene->keyingsets, NULL, NULL, flag, keyingflag);
|
||||
|
||||
scene->active_keyingset= BLI_countlist(&scene->keyingsets);
|
||||
|
||||
|
@ -317,7 +317,7 @@ static int add_keyingset_button_exec (bContext *C, wmOperator *op)
|
|||
keyingflag |= INSERTKEY_XYZ2RGB;
|
||||
|
||||
/* call the API func, and set the active keyingset index */
|
||||
ks= BKE_keyingset_add(&scene->keyingsets, "ButtonKeyingSet", flag, keyingflag);
|
||||
ks= BKE_keyingset_add(&scene->keyingsets, "ButtonKeyingSet", "Button Keying Set", flag, keyingflag);
|
||||
|
||||
scene->active_keyingset= BLI_countlist(&scene->keyingsets);
|
||||
}
|
||||
|
@ -468,22 +468,26 @@ void ANIM_OT_keyingset_button_remove (wmOperatorType *ot)
|
|||
|
||||
static int keyingset_active_menu_invoke (bContext *C, wmOperator *op, wmEvent *UNUSED(event))
|
||||
{
|
||||
uiPopupMenu *pup;
|
||||
uiLayout *layout;
|
||||
|
||||
/* call the menu, which will call this operator again, hence the canceled */
|
||||
ANIM_keying_sets_menu_setup(C, op->type->name, "ANIM_OT_keying_set_active_set");
|
||||
pup = uiPupMenuBegin(C, op->type->name, ICON_NONE);
|
||||
layout = uiPupMenuLayout(pup);
|
||||
uiItemsEnumO(layout, "ANIM_OT_keying_set_active_set", "type");
|
||||
uiPupMenuEnd(C, pup);
|
||||
|
||||
return OPERATOR_CANCELLED;
|
||||
}
|
||||
|
||||
static int keyingset_active_menu_exec (bContext *C, wmOperator *op)
|
||||
{
|
||||
Scene *scene= CTX_data_scene(C);
|
||||
int type= RNA_int_get(op->ptr, "type");
|
||||
Scene *scene = CTX_data_scene(C);
|
||||
int type = RNA_enum_get(op->ptr, "type");
|
||||
|
||||
/* If type == 0, it will deselect any active keying set. */
|
||||
scene->active_keyingset = type;
|
||||
|
||||
/* simply set the scene's active keying set index, unless the type == 0
|
||||
* (i.e. which happens if we want the current active to be maintained)
|
||||
*/
|
||||
if (type)
|
||||
scene->active_keyingset= type;
|
||||
|
||||
/* send notifiers */
|
||||
WM_event_add_notifier(C, NC_SCENE|ND_KEYINGSET, NULL);
|
||||
|
||||
|
@ -492,6 +496,8 @@ static int keyingset_active_menu_exec (bContext *C, wmOperator *op)
|
|||
|
||||
void ANIM_OT_keying_set_active_set (wmOperatorType *ot)
|
||||
{
|
||||
PropertyRNA *prop;
|
||||
|
||||
/* identifiers */
|
||||
ot->name= "Set Active Keying Set";
|
||||
ot->idname= "ANIM_OT_keying_set_active_set";
|
||||
|
@ -504,10 +510,10 @@ void ANIM_OT_keying_set_active_set (wmOperatorType *ot)
|
|||
/* flags */
|
||||
ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
|
||||
|
||||
/* keyingset to use
|
||||
* - here the type is int not enum, since many of the indices here are determined dynamically
|
||||
*/
|
||||
RNA_def_int(ot->srna, "type", 0, INT_MIN, INT_MAX, "Keying Set Number", "Index (determined internally) of the Keying Set to use", 0, 1);
|
||||
/* keyingset to use (dynamic enum) */
|
||||
prop= RNA_def_enum(ot->srna, "type", DummyRNA_DEFAULT_items, 0, "Keying Set", "The Keying Set to use");
|
||||
RNA_def_enum_funcs(prop, ANIM_keying_sets_enum_itemf);
|
||||
/* RNA_def_property_flag(prop, PROP_HIDDEN);*/
|
||||
}
|
||||
|
||||
/* ******************************************* */
|
||||
|
@ -546,10 +552,10 @@ KeyingSet *ANIM_builtin_keyingset_get_named (KeyingSet *prevKS, const char name[
|
|||
first= prevKS->next;
|
||||
else
|
||||
first= builtin_keyingsets.first;
|
||||
|
||||
|
||||
/* loop over KeyingSets checking names */
|
||||
for (ks= first; ks; ks= ks->next) {
|
||||
if (strcmp(name, ks->name) == 0)
|
||||
if (strcmp(name, ks->idname) == 0)
|
||||
return ks;
|
||||
}
|
||||
|
||||
|
@ -572,11 +578,14 @@ void ANIM_keyingset_info_register (KeyingSetInfo *ksi)
|
|||
/* create a new KeyingSet
|
||||
* - inherit name and keyframing settings from the typeinfo
|
||||
*/
|
||||
ks = BKE_keyingset_add(&builtin_keyingsets, ksi->name, 1, ksi->keyingflag);
|
||||
ks = BKE_keyingset_add(&builtin_keyingsets, ksi->idname, ksi->name, 1, ksi->keyingflag);
|
||||
|
||||
/* link this KeyingSet with its typeinfo */
|
||||
memcpy(&ks->typeinfo, ksi->idname, sizeof(ks->typeinfo));
|
||||
|
||||
/* Copy description... */
|
||||
BLI_strncpy(ks->description, ksi->description, sizeof(ks->description));
|
||||
|
||||
/* add type-info to the list */
|
||||
BLI_addtail(&keyingset_type_infos, ksi);
|
||||
}
|
||||
|
@ -717,23 +726,26 @@ EnumPropertyItem *ANIM_keying_sets_enum_itemf (bContext *C, PointerRNA *UNUSED(p
|
|||
*/
|
||||
if (scene->active_keyingset) {
|
||||
/* active Keying Set */
|
||||
item_tmp.identifier= item_tmp.name= "Active Keying Set";
|
||||
item_tmp.value= i++;
|
||||
item_tmp.identifier= "__ACTIVE__";
|
||||
item_tmp.name= "Active Keying Set";
|
||||
item_tmp.value= i;
|
||||
RNA_enum_item_add(&item, &totitem, &item_tmp);
|
||||
|
||||
/* separator */
|
||||
RNA_enum_item_add_separator(&item, &totitem);
|
||||
}
|
||||
else
|
||||
i++;
|
||||
|
||||
|
||||
i++;
|
||||
|
||||
/* user-defined Keying Sets
|
||||
* - these are listed in the order in which they were defined for the active scene
|
||||
*/
|
||||
if (scene->keyingsets.first) {
|
||||
for (ks= scene->keyingsets.first; ks; ks= ks->next, i++) {
|
||||
if (ANIM_keyingset_context_ok_poll(C, ks)) {
|
||||
item_tmp.identifier= item_tmp.name= ks->name;
|
||||
item_tmp.identifier = ks->idname;
|
||||
item_tmp.name = ks->name;
|
||||
item_tmp.description = ks->description;
|
||||
item_tmp.value= i;
|
||||
RNA_enum_item_add(&item, &totitem, &item_tmp);
|
||||
}
|
||||
|
@ -748,7 +760,9 @@ EnumPropertyItem *ANIM_keying_sets_enum_itemf (bContext *C, PointerRNA *UNUSED(p
|
|||
for (ks= builtin_keyingsets.first; ks; ks= ks->next, i--) {
|
||||
/* only show KeyingSet if context is suitable */
|
||||
if (ANIM_keyingset_context_ok_poll(C, ks)) {
|
||||
item_tmp.identifier= item_tmp.name= ks->name;
|
||||
item_tmp.identifier = ks->idname;
|
||||
item_tmp.name = ks->name;
|
||||
item_tmp.description = ks->description;
|
||||
item_tmp.value= i;
|
||||
RNA_enum_item_add(&item, &totitem, &item_tmp);
|
||||
}
|
||||
|
@ -760,50 +774,6 @@ EnumPropertyItem *ANIM_keying_sets_enum_itemf (bContext *C, PointerRNA *UNUSED(p
|
|||
return item;
|
||||
}
|
||||
|
||||
/* Create (and show) a menu containing all the Keying Sets which can be used in the current context */
|
||||
void ANIM_keying_sets_menu_setup (bContext *C, const char title[], const char op_name[])
|
||||
{
|
||||
Scene *scene= CTX_data_scene(C);
|
||||
KeyingSet *ks;
|
||||
uiPopupMenu *pup;
|
||||
uiLayout *layout;
|
||||
int i = 0;
|
||||
|
||||
pup= uiPupMenuBegin(C, title, ICON_NONE);
|
||||
layout= uiPupMenuLayout(pup);
|
||||
|
||||
/* active Keying Set
|
||||
* - only include entry if it exists
|
||||
*/
|
||||
if (scene->active_keyingset) {
|
||||
uiItemEnumO(layout, op_name, "Active Keying Set", ICON_NONE, "type", i++);
|
||||
uiItemS(layout);
|
||||
}
|
||||
else
|
||||
i++;
|
||||
|
||||
/* user-defined Keying Sets
|
||||
* - these are listed in the order in which they were defined for the active scene
|
||||
*/
|
||||
if (scene->keyingsets.first) {
|
||||
for (ks= scene->keyingsets.first; ks; ks=ks->next, i++) {
|
||||
if (ANIM_keyingset_context_ok_poll(C, ks))
|
||||
uiItemEnumO(layout, op_name, ks->name, ICON_NONE, "type", i);
|
||||
}
|
||||
uiItemS(layout);
|
||||
}
|
||||
|
||||
/* builtin Keying Sets */
|
||||
i= -1;
|
||||
for (ks= builtin_keyingsets.first; ks; ks=ks->next, i--) {
|
||||
/* only show KeyingSet if context is suitable */
|
||||
if (ANIM_keyingset_context_ok_poll(C, ks))
|
||||
uiItemEnumO(layout, op_name, ks->name, ICON_NONE, "type", i);
|
||||
}
|
||||
|
||||
uiPupMenuEnd(C, pup);
|
||||
}
|
||||
|
||||
/* ******************************************* */
|
||||
/* KEYFRAME MODIFICATION */
|
||||
|
||||
|
|
|
@ -132,10 +132,12 @@ typedef struct KeyingSetInfo {
|
|||
struct KeyingSetInfo *next, *prev;
|
||||
|
||||
/* info */
|
||||
/* identifier so that user can hook this up to a KeyingSet */
|
||||
char name[64];
|
||||
/* identifier used for class name, which KeyingSet instances reference as "Typeinfo Name" */
|
||||
char idname[64];
|
||||
/* identifier so that user can hook this up to a KeyingSet (used as label). */
|
||||
char name[64];
|
||||
/* short help/description. */
|
||||
char description[240]; /* RNA_DYN_DESCR_MAX */
|
||||
/* keying settings */
|
||||
short keyingflag;
|
||||
|
||||
|
@ -208,9 +210,6 @@ int ANIM_scene_get_keyingset_index(struct Scene *scene, struct KeyingSet *ks);
|
|||
/* Get Keying Set to use for Auto-Keyframing some transforms */
|
||||
struct KeyingSet *ANIM_get_keyingset_for_autokeying(struct Scene *scene, const char *tranformKSName);
|
||||
|
||||
/* Create (and show) a menu containing all the Keying Sets which can be used in the current context */
|
||||
void ANIM_keying_sets_menu_setup(struct bContext *C, const char title[], const char op_name[]);
|
||||
|
||||
/* Dynamically populate an enum of Keying Sets */
|
||||
struct EnumPropertyItem *ANIM_keying_sets_enum_itemf(struct bContext *C, struct PointerRNA *ptr, struct PropertyRNA *prop, int *free);
|
||||
|
||||
|
|
|
@ -1283,7 +1283,7 @@ static KeyingSet *verify_active_keyingset(Scene *scene, short add)
|
|||
/* add if none found */
|
||||
// XXX the default settings have yet to evolve
|
||||
if ((add) && (ks==NULL)) {
|
||||
ks= BKE_keyingset_add(&scene->keyingsets, NULL, KEYINGSET_ABSOLUTE, 0);
|
||||
ks= BKE_keyingset_add(&scene->keyingsets, NULL, NULL, KEYINGSET_ABSOLUTE, 0);
|
||||
scene->active_keyingset= BLI_countlist(&scene->keyingsets);
|
||||
}
|
||||
|
||||
|
|
|
@ -761,7 +761,9 @@ typedef struct KeyingSet {
|
|||
|
||||
ListBase paths; /* (KS_Path) paths to keyframe to */
|
||||
|
||||
char idname[64]; /* unique name (for search, etc.) */
|
||||
char name[64]; /* user-viewable name for KeyingSet (for menus, etc.) */
|
||||
char description[240]; /* (RNA_DYN_DESCR_MAX) short help text. */
|
||||
char typeinfo[64]; /* name of the typeinfo data used for the relative paths */
|
||||
|
||||
short flag; /* settings for KeyingSet */
|
||||
|
|
|
@ -194,7 +194,8 @@ static StructRNA *rna_KeyingSetInfo_register(Main *bmain, ReportList *reports, v
|
|||
return NULL;
|
||||
|
||||
if (strlen(identifier) >= sizeof(dummyksi.idname)) {
|
||||
BKE_reportf(reports, RPT_ERROR, "Registering keying set info class: '%s' is too long, maximum length is %d", identifier, (int)sizeof(dummyksi.idname));
|
||||
BKE_reportf(reports, RPT_ERROR, "Registering keying set info class: '%s' is too long, maximum length is %d",
|
||||
identifier, (int)sizeof(dummyksi.idname));
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -473,6 +474,13 @@ static void rna_def_common_keying_flags(StructRNA *srna, short reg)
|
|||
|
||||
/* --- */
|
||||
|
||||
/* To avoid repeating it twice! */
|
||||
#define KEYINGSET_IDNAME_DOC "If this is set, the Keying Set gets a custom ID, otherwise it takes " \
|
||||
"the name of the class used to define the Keying Set (for example, " \
|
||||
"if the class name is \"BUILTIN_KSI_location\", and bl_idname is not " \
|
||||
"set by the script, then bl_idname = \"BUILTIN_KSI_location\")"
|
||||
|
||||
|
||||
static void rna_def_keyingset_info(BlenderRNA *brna)
|
||||
{
|
||||
StructRNA *srna;
|
||||
|
@ -489,18 +497,24 @@ static void rna_def_keyingset_info(BlenderRNA *brna)
|
|||
/* Properties --------------------- */
|
||||
|
||||
RNA_define_verify_sdna(0); /* not in sdna */
|
||||
|
||||
|
||||
prop = RNA_def_property(srna, "bl_idname", PROP_STRING, PROP_NONE);
|
||||
RNA_def_property_string_sdna(prop, NULL, "idname");
|
||||
RNA_def_property_flag(prop, PROP_REGISTER|PROP_NEVER_CLAMP);
|
||||
|
||||
/* Name */
|
||||
prop = RNA_def_property(srna, "bl_label", PROP_STRING, PROP_TRANSLATE);
|
||||
RNA_def_property_ui_text(prop, "ID Name", KEYINGSET_IDNAME_DOC);
|
||||
|
||||
prop = RNA_def_property(srna, "bl_label", PROP_STRING, PROP_NONE);
|
||||
RNA_def_property_string_sdna(prop, NULL, "name");
|
||||
RNA_def_property_ui_text(prop, "Name", "");
|
||||
RNA_def_property_ui_text(prop, "UI Name", "");
|
||||
RNA_def_struct_name_property(srna, prop);
|
||||
RNA_def_property_flag(prop, PROP_REGISTER);
|
||||
|
||||
prop = RNA_def_property(srna, "bl_description", PROP_STRING, PROP_TRANSLATE);
|
||||
RNA_def_property_string_sdna(prop, NULL, "description");
|
||||
RNA_def_property_string_maxlength(prop, RNA_DYN_DESCR_MAX); /* else it uses the pointer size! */
|
||||
RNA_def_property_flag(prop, PROP_REGISTER_OPTIONAL);
|
||||
RNA_def_property_ui_text(prop, "Description", "A short description of the keying set");
|
||||
|
||||
rna_def_common_keying_flags(srna, 1); /* '1' arg here is to indicate that we need these to be set on registering */
|
||||
|
||||
RNA_define_verify_sdna(1);
|
||||
|
@ -671,12 +685,25 @@ static void rna_def_keyingset(BlenderRNA *brna)
|
|||
srna = RNA_def_struct(brna, "KeyingSet", NULL);
|
||||
RNA_def_struct_ui_text(srna, "Keying Set", "Settings that should be keyframed together");
|
||||
|
||||
/* Name */
|
||||
prop = RNA_def_property(srna, "name", PROP_STRING, PROP_NONE);
|
||||
RNA_def_property_ui_text(prop, "Name", "");
|
||||
/* Id/Label. */
|
||||
prop = RNA_def_property(srna, "bl_idname", PROP_STRING, PROP_NONE);
|
||||
RNA_def_property_string_sdna(prop, NULL, "idname");
|
||||
RNA_def_property_flag(prop, PROP_REGISTER|PROP_NEVER_CLAMP);
|
||||
RNA_def_property_ui_text(prop, "ID Name", KEYINGSET_IDNAME_DOC);
|
||||
RNA_def_property_update(prop, NC_SCENE|ND_KEYINGSET|NA_RENAME, NULL);
|
||||
|
||||
prop = RNA_def_property(srna, "bl_label", PROP_STRING, PROP_NONE);
|
||||
RNA_def_property_string_sdna(prop, NULL, "name");
|
||||
RNA_def_property_ui_text(prop, "UI Name", "");
|
||||
RNA_def_struct_ui_icon(srna, ICON_KEYINGSET);
|
||||
RNA_def_struct_name_property(srna, prop);
|
||||
RNA_def_property_update(prop, NC_SCENE|ND_KEYINGSET|NA_RENAME, NULL);
|
||||
/* RNA_def_property_update(prop, NC_SCENE|ND_KEYINGSET|NA_RENAME, NULL);*/
|
||||
|
||||
prop = RNA_def_property(srna, "bl_description", PROP_STRING, PROP_TRANSLATE);
|
||||
RNA_def_property_string_sdna(prop, NULL, "description");
|
||||
RNA_def_property_string_maxlength(prop, RNA_DYN_DESCR_MAX); /* else it uses the pointer size! */
|
||||
RNA_def_property_flag(prop, PROP_REGISTER_OPTIONAL);
|
||||
RNA_def_property_ui_text(prop, "Description", "A short description of the keying set");
|
||||
|
||||
/* KeyingSetInfo (Type Info) for Builtin Sets only */
|
||||
prop = RNA_def_property(srna, "type_info", PROP_POINTER, PROP_NONE);
|
||||
|
@ -705,6 +732,7 @@ static void rna_def_keyingset(BlenderRNA *brna)
|
|||
RNA_api_keyingset(srna);
|
||||
}
|
||||
|
||||
#undef KEYINGSET_IDNAME_DOC
|
||||
/* --- */
|
||||
|
||||
static void rna_api_animdata_nla_tracks(BlenderRNA *brna, PropertyRNA *cprop)
|
||||
|
|
|
@ -1321,12 +1321,12 @@ static void rna_TimeLine_clear(Scene *scene)
|
|||
WM_main_add_notifier(NC_ANIMATION|ND_MARKERS, NULL);
|
||||
}
|
||||
|
||||
static KeyingSet *rna_Scene_keying_set_new(Scene *sce, ReportList *reports, const char name[])
|
||||
static KeyingSet *rna_Scene_keying_set_new(Scene *sce, ReportList *reports, const char idname[], const char name[])
|
||||
{
|
||||
KeyingSet *ks = NULL;
|
||||
|
||||
/* call the API func, and set the active keyingset index */
|
||||
ks = BKE_keyingset_add(&sce->keyingsets, name, KEYINGSET_ABSOLUTE, 0);
|
||||
ks = BKE_keyingset_add(&sce->keyingsets, idname, name, KEYINGSET_ABSOLUTE, 0);
|
||||
|
||||
if (ks) {
|
||||
sce->active_keyingset = BLI_countlist(&sce->keyingsets);
|
||||
|
@ -3948,7 +3948,8 @@ static void rna_def_scene_keying_sets(BlenderRNA *brna, PropertyRNA *cprop)
|
|||
RNA_def_function_ui_description(func, "Add a new Keying Set to Scene");
|
||||
RNA_def_function_flag(func, FUNC_USE_REPORTS);
|
||||
/* name */
|
||||
RNA_def_string(func, "name", "KeyingSet", 64, "Name", "Name of Keying Set");
|
||||
RNA_def_string(func, "idname", "KeyingSet", 64, "IDName", "Internal identifier of Keying Set");
|
||||
RNA_def_string(func, "name", "KeyingSet", 64, "Name", "User visible name of Keying Set");
|
||||
|
||||
/* returns the new KeyingSet */
|
||||
parm = RNA_def_pointer(func, "keyingset", "KeyingSet", "", "Newly created Keying Set");
|
||||
|
|
Loading…
Reference in New Issue