Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoshua Leung <aligorith@gmail.com>2009-10-13 09:50:26 +0400
committerJoshua Leung <aligorith@gmail.com>2009-10-13 09:50:26 +0400
commitf8ab477f4569dec1853ec7c9114d21f9a84a062f (patch)
tree0cb46acfa690ab061e6dffcbc12d233807cfd31d /source/blender/editors/armature
parent7171c5928e6bece26d3a3dde41c088e77dbba423 (diff)
2.5 Bugfixes:
* Reverting some changes I made to try and get Action Groups with no viewable F-Curves, but were collapsed to get hidden. These were causing buggy behaviour * Move bones to armature layers, and change armature layer operators now use the new automatic properties drawing invoke callback. This allows changing the buttons there immediately affect the bones in the viewport * #19581: Text Editor: "Jump To" (go to line) not working Made this use the automatic operator props invoke callback, and fixed an RNA properties bug for this (the default value and range values were swapped). * PoseLib rename pose operator now works again. Once again, this uses the auto-props popup. Also, improved the code here while I was at it. * Disabled non-functional/old entry in Select Linked operator ("IPO's")
Diffstat (limited to 'source/blender/editors/armature')
-rw-r--r--source/blender/editors/armature/poselib.c102
-rw-r--r--source/blender/editors/armature/poseobject.c47
2 files changed, 79 insertions, 70 deletions
diff --git a/source/blender/editors/armature/poselib.c b/source/blender/editors/armature/poselib.c
index d34da201ef5..b06c7286859 100644
--- a/source/blender/editors/armature/poselib.c
+++ b/source/blender/editors/armature/poselib.c
@@ -285,6 +285,9 @@ static void poselib_add_menu_invoke__replacemenu (bContext *C, uiLayout *layout,
bAction *act= ob->poselib;
TimeMarker *marker;
+ /* set the operator execution context correctly */
+ uiLayoutSetOperatorContext(layout, WM_OP_EXEC_DEFAULT);
+
/* add each marker to this menu */
for (marker= act->markers.first; marker; marker= marker->next)
uiItemIntO(layout, marker->name, ICON_ARMATURE_DATA, "POSELIB_OT_pose_add", "frame", marker->frame);
@@ -398,7 +401,6 @@ static int poselib_add_exec (bContext *C, wmOperator *op)
return OPERATOR_FINISHED;
}
-
void POSELIB_OT_pose_add (wmOperatorType *ot)
{
/* identifiers */
@@ -421,35 +423,35 @@ void POSELIB_OT_pose_add (wmOperatorType *ot)
/* ----- */
-static int poselib_stored_pose_menu_invoke (bContext *C, wmOperator *op, wmEvent *evt)
+static EnumPropertyItem *poselib_stored_pose_itemf(bContext *C, PointerRNA *ptr, int *free)
{
Object *ob= CTX_data_active_object(C);
bAction *act= (ob) ? ob->poselib : NULL;
TimeMarker *marker;
- uiPopupMenu *pup;
- uiLayout *layout;
- int i;
-
- /* sanity check */
- if (ELEM(NULL, ob, act))
- return OPERATOR_CANCELLED;
-
- /* start building */
- pup= uiPupMenuBegin(C, op->type->name, 0);
- layout= uiPupMenuLayout(pup);
- uiLayoutSetOperatorContext(layout, WM_OP_EXEC_DEFAULT);
-
- /* add each marker to this menu */
- for (marker=act->markers.first, i=0; marker; marker= marker->next, i++)
- uiItemIntO(layout, marker->name, ICON_ARMATURE_DATA, op->idname, "index", i);
-
- uiPupMenuEnd(C, pup);
-
- /* this operator is only for a menu, not used further */
- return OPERATOR_CANCELLED;
-}
+ EnumPropertyItem *item= NULL, item_tmp;
+ int totitem= 0;
+ int i= 0;
+
+ if (C == NULL)
+ return NULL;
+
+ memset(&item_tmp, 0, sizeof(item_tmp));
+ /* add each marker to the list */
+ for (marker=act->markers.first, i=0; marker; marker= marker->next, i++) {
+ item_tmp.identifier= item_tmp.name= marker->name;
+ item_tmp.icon= ICON_ARMATURE_DATA;
+ item_tmp.value= i;
+ RNA_enum_item_add(&item, &totitem, &item_tmp);
+ }
+ if (i > 0) {
+ *free= 1;
+ return item;
+ }
+ else
+ return NULL;
+}
static int poselib_remove_exec (bContext *C, wmOperator *op)
{
@@ -465,7 +467,7 @@ static int poselib_remove_exec (bContext *C, wmOperator *op)
}
/* get index (and pointer) of pose to remove */
- marker= BLI_findlink(&act->markers, RNA_int_get(op->ptr, "index"));
+ marker= BLI_findlink(&act->markers, RNA_int_get(op->ptr, "pose"));
if (marker == NULL) {
BKE_report(op->reports, RPT_ERROR, "Invalid index for Pose");
return OPERATOR_CANCELLED;
@@ -499,13 +501,18 @@ static int poselib_remove_exec (bContext *C, wmOperator *op)
void POSELIB_OT_pose_remove (wmOperatorType *ot)
{
+ PropertyRNA *prop;
+ static EnumPropertyItem prop_poses_dummy_types[] = {
+ {0, NULL, 0, NULL, NULL}
+ };
+
/* identifiers */
ot->name= "PoseLib Remove Pose";
ot->idname= "POSELIB_OT_pose_remove";
ot->description= "Remove nth pose from the active Pose Library";
/* api callbacks */
- ot->invoke= poselib_stored_pose_menu_invoke;
+ ot->invoke= WM_menu_invoke;
ot->exec= poselib_remove_exec;
ot->poll= ED_operator_posemode;
@@ -513,10 +520,37 @@ void POSELIB_OT_pose_remove (wmOperatorType *ot)
ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
/* properties */
- RNA_def_int(ot->srna, "index", 0, 0, INT_MAX, "Index", "The index of the pose to remove", 0, INT_MAX);
+ prop= RNA_def_enum(ot->srna, "pose", prop_poses_dummy_types, 0, "Pose", "The pose to remove");
+ RNA_def_enum_funcs(prop, poselib_stored_pose_itemf);
}
-
+static int poselib_rename_invoke (bContext *C, wmOperator *op, wmEvent *evt)
+{
+ Object *ob= CTX_data_active_object(C);
+ bAction *act= (ob) ? ob->poselib : NULL;
+ TimeMarker *marker;
+
+ /* check if valid poselib */
+ if (act == NULL) {
+ BKE_report(op->reports, RPT_ERROR, "Object doesn't have PoseLib data");
+ return OPERATOR_CANCELLED;
+ }
+
+ /* get index (and pointer) of pose to remove */
+ marker= BLI_findlink(&act->markers, act->active_marker-1);
+ if (marker == NULL) {
+ BKE_report(op->reports, RPT_ERROR, "Invalid index for Pose");
+ return OPERATOR_CANCELLED;
+ }
+ else {
+ /* use the existing name of the marker as the name, and use the active marker as the one to rename */
+ RNA_enum_set(op->ptr, "pose", act->active_marker-1);
+ RNA_string_set(op->ptr, "name", marker->name);
+ }
+
+ /* part to sync with other similar operators... */
+ return WM_operator_props_popup(C, op, evt);
+}
static int poselib_rename_exec (bContext *C, wmOperator *op)
{
@@ -532,7 +566,7 @@ static int poselib_rename_exec (bContext *C, wmOperator *op)
}
/* get index (and pointer) of pose to remove */
- marker= BLI_findlink(&act->markers, RNA_int_get(op->ptr, "index"));
+ marker= BLI_findlink(&act->markers, RNA_int_get(op->ptr, "pose"));
if (marker == NULL) {
BKE_report(op->reports, RPT_ERROR, "Invalid index for Pose");
return OPERATOR_CANCELLED;
@@ -551,13 +585,18 @@ static int poselib_rename_exec (bContext *C, wmOperator *op)
void POSELIB_OT_pose_rename (wmOperatorType *ot)
{
+ PropertyRNA *prop;
+ static EnumPropertyItem prop_poses_dummy_types[] = {
+ {0, NULL, 0, NULL, NULL}
+ };
+
/* identifiers */
ot->name= "PoseLib Rename Pose";
ot->idname= "POSELIB_OT_pose_rename";
ot->description= "Rename nth pose from the active Pose Library";
/* api callbacks */
- ot->invoke= poselib_stored_pose_menu_invoke;
+ ot->invoke= poselib_rename_invoke;
ot->exec= poselib_rename_exec;
ot->poll= ED_operator_posemode;
@@ -565,7 +604,8 @@ void POSELIB_OT_pose_rename (wmOperatorType *ot)
ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
/* properties */
- RNA_def_int(ot->srna, "index", 0, 0, INT_MAX, "Index", "The index of the pose to remove", 0, INT_MAX);
+ prop= RNA_def_enum(ot->srna, "pose", prop_poses_dummy_types, 0, "Pose", "The pose to rename");
+ RNA_def_enum_funcs(prop, poselib_stored_pose_itemf);
RNA_def_string(ot->srna, "name", "RenamedPose", 64, "New Pose Name", "New name for pose");
}
diff --git a/source/blender/editors/armature/poseobject.c b/source/blender/editors/armature/poseobject.c
index 1531d922e04..57fe083b319 100644
--- a/source/blender/editors/armature/poseobject.c
+++ b/source/blender/editors/armature/poseobject.c
@@ -1728,31 +1728,6 @@ void pose_activate_flipped_bone(Scene *scene)
/* ********************************************** */
/* Present a popup to get the layers that should be used */
-// TODO: move to wm?
-static uiBlock *wm_layers_select_create_menu(bContext *C, ARegion *ar, void *arg_op)
-{
- wmOperator *op= arg_op;
- uiBlock *block;
- uiLayout *layout;
- uiStyle *style= U.uistyles.first;
-
- block= uiBeginBlock(C, ar, "_popup", UI_EMBOSS);
- uiBlockClearFlag(block, UI_BLOCK_LOOP);
- uiBlockSetFlag(block, UI_BLOCK_KEEP_OPEN);
-
- layout= uiBlockLayout(block, UI_LAYOUT_VERTICAL, UI_LAYOUT_PANEL, 0, 0, 150, 20, style);
- uiItemL(layout, op->type->name, 0);
- uiTemplateLayers(layout, op->ptr, "layers"); /* must have a property named layers setup */
-
- uiPopupBoundsBlock(block, 4.0f, 0, 0);
- uiEndBlock(C, block);
-
- return block;
-}
-
-/* ------------------- */
-
-/* Present a popup to get the layers that should be used */
static int pose_armature_layers_invoke (bContext *C, wmOperator *op, wmEvent *evt)
{
Object *ob= CTX_data_active_object(C);
@@ -1769,10 +1744,8 @@ static int pose_armature_layers_invoke (bContext *C, wmOperator *op, wmEvent *ev
RNA_boolean_get_array(&ptr, "layer", layers);
RNA_boolean_set_array(op->ptr, "layers", layers);
- /* part to sync with other similar operators... */
- /* pass on operator, so return modal */
- uiPupBlockOperator(C, wm_layers_select_create_menu, op, WM_OP_EXEC_DEFAULT);
- return OPERATOR_RUNNING_MODAL|OPERATOR_PASS_THROUGH;
+ /* part to sync with other similar operators... */
+ return WM_operator_props_popup(C, op, evt);
}
/* Set the visible layers for the active armature (edit and pose modes) */
@@ -1813,7 +1786,7 @@ void POSE_OT_armature_layers (wmOperatorType *ot)
ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
/* properties */
- RNA_def_boolean_array(ot->srna, "layers", 16, NULL, "Layers", "Armature layers to make visible.");
+ RNA_def_boolean_layer_member(ot->srna, "layers", 16, NULL, "Layer", "Armature layers to make visible");
}
void ARMATURE_OT_armature_layers (wmOperatorType *ot)
@@ -1832,7 +1805,7 @@ void ARMATURE_OT_armature_layers (wmOperatorType *ot)
ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
/* properties */
- RNA_def_boolean_array(ot->srna, "layers", 16, NULL, "Layers", "Armature layers to make visible.");
+ RNA_def_boolean_layer_member(ot->srna, "layers", 16, NULL, "Layer", "Armature layers to make visible");
}
/* ------------------- */
@@ -1861,9 +1834,7 @@ static int pose_bone_layers_invoke (bContext *C, wmOperator *op, wmEvent *evt)
RNA_boolean_set_array(op->ptr, "layers", layers);
/* part to sync with other similar operators... */
- /* pass on operator, so return modal */
- uiPupBlockOperator(C, wm_layers_select_create_menu, op, WM_OP_EXEC_DEFAULT);
- return OPERATOR_RUNNING_MODAL|OPERATOR_PASS_THROUGH;
+ return WM_operator_props_popup(C, op, evt);
}
/* Set the visible layers for the active armature (edit and pose modes) */
@@ -1908,7 +1879,7 @@ void POSE_OT_bone_layers (wmOperatorType *ot)
ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
/* properties */
- RNA_def_boolean_array(ot->srna, "layers", 16, NULL, "Layers", "Armature layers that bone belongs to.");
+ RNA_def_boolean_layer_member(ot->srna, "layers", 16, NULL, "Layer", "Armature layers that bone belongs to");
}
/* ------------------- */
@@ -1937,9 +1908,7 @@ static int armature_bone_layers_invoke (bContext *C, wmOperator *op, wmEvent *ev
RNA_boolean_set_array(op->ptr, "layers", layers);
/* part to sync with other similar operators... */
- /* pass on operator, so return modal */
- uiPupBlockOperator(C, wm_layers_select_create_menu, op, WM_OP_EXEC_DEFAULT);
- return OPERATOR_RUNNING_MODAL|OPERATOR_PASS_THROUGH;
+ return WM_operator_props_popup(C, op, evt);
}
/* Set the visible layers for the active armature (edit and pose modes) */
@@ -1984,7 +1953,7 @@ void ARMATURE_OT_bone_layers (wmOperatorType *ot)
ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
/* properties */
- RNA_def_boolean_array(ot->srna, "layers", 16, NULL, "Layers", "Armature layers that bone belongs to.");
+ RNA_def_boolean_layer_member(ot->srna, "layers", 16, NULL, "Layer", "Armature layers that bone belongs to");
}
/* ********************************************** */