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:
authorBrecht Van Lommel <brechtvanlommel@pandora.be>2010-09-25 18:32:26 +0400
committerBrecht Van Lommel <brechtvanlommel@pandora.be>2010-09-25 18:32:26 +0400
commit58082beda937b05cb2aa42e4f9f0b801a3e8663d (patch)
tree0d396166631478123871c7cbdcbd6d20db0c7c81
parentcd429bdb505d7ef05503bd1b60960df8f9b849a1 (diff)
Fix #23847: keyframe insert on button not working in popup menus, e.g.
the vector popup for node inputs.
-rw-r--r--source/blender/editors/animation/drivers.c16
-rw-r--r--source/blender/editors/animation/keyframing.c8
-rw-r--r--source/blender/editors/animation/keyingsets.c4
-rw-r--r--source/blender/editors/include/UI_interface.h3
-rw-r--r--source/blender/editors/interface/interface_anim.c40
-rw-r--r--source/blender/editors/interface/interface_handlers.c93
-rw-r--r--source/blender/editors/interface/interface_ops.c12
7 files changed, 129 insertions, 47 deletions
diff --git a/source/blender/editors/animation/drivers.c b/source/blender/editors/animation/drivers.c
index 9b776fc0859..898d7db89fc 100644
--- a/source/blender/editors/animation/drivers.c
+++ b/source/blender/editors/animation/drivers.c
@@ -372,7 +372,7 @@ static int add_driver_button_exec (bContext *C, wmOperator *op)
/* try to create driver using property retrieved from UI */
memset(&ptr, 0, sizeof(PointerRNA));
- uiAnimContextProperty(C, &ptr, &prop, &index);
+ uiContextActiveProperty(C, &ptr, &prop, &index);
if (all)
index= -1;
@@ -389,6 +389,8 @@ static int add_driver_button_exec (bContext *C, wmOperator *op)
if (success) {
/* send updates */
+ uiContextAnimUpdate(C);
+
DAG_ids_flush_update(CTX_data_main(C), 0);
WM_event_add_notifier(C, NC_ANIMATION|ND_FCURVES_ORDER, NULL); // XXX
@@ -427,7 +429,7 @@ static int remove_driver_button_exec (bContext *C, wmOperator *op)
/* try to find driver using property retrieved from UI */
memset(&ptr, 0, sizeof(PointerRNA));
- uiAnimContextProperty(C, &ptr, &prop, &index);
+ uiContextActiveProperty(C, &ptr, &prop, &index);
if (all)
index= -1;
@@ -440,6 +442,8 @@ static int remove_driver_button_exec (bContext *C, wmOperator *op)
if (success) {
/* send updates */
+ uiContextAnimUpdate(C);
+
DAG_ids_flush_update(CTX_data_main(C), 0);
WM_event_add_notifier(C, NC_ANIMATION|ND_FCURVES_ORDER, NULL); // XXX
@@ -478,7 +482,7 @@ static int copy_driver_button_exec (bContext *C, wmOperator *op)
/* try to create driver using property retrieved from UI */
memset(&ptr, 0, sizeof(PointerRNA));
- uiAnimContextProperty(C, &ptr, &prop, &index);
+ uiContextActiveProperty(C, &ptr, &prop, &index);
if (ptr.id.data && ptr.data && prop && RNA_property_animateable(&ptr, prop)) {
path= RNA_path_from_ID_to_property(&ptr, prop);
@@ -486,6 +490,8 @@ static int copy_driver_button_exec (bContext *C, wmOperator *op)
if (path) {
/* only copy the driver for the button that this was involved for */
success= ANIM_copy_driver(ptr.id.data, path, index, 0);
+
+ uiContextAnimUpdate(C);
MEM_freeN(path);
}
@@ -522,7 +528,7 @@ static int paste_driver_button_exec (bContext *C, wmOperator *op)
/* try to create driver using property retrieved from UI */
memset(&ptr, 0, sizeof(PointerRNA));
- uiAnimContextProperty(C, &ptr, &prop, &index);
+ uiContextActiveProperty(C, &ptr, &prop, &index);
if (ptr.id.data && ptr.data && prop && RNA_property_animateable(&ptr, prop)) {
path= RNA_path_from_ID_to_property(&ptr, prop);
@@ -530,6 +536,8 @@ static int paste_driver_button_exec (bContext *C, wmOperator *op)
if (path) {
/* only copy the driver for the button that this was involved for */
success= ANIM_paste_driver(ptr.id.data, path, index, 0);
+
+ uiContextAnimUpdate(C);
MEM_freeN(path);
}
diff --git a/source/blender/editors/animation/keyframing.c b/source/blender/editors/animation/keyframing.c
index 176c6a1f72a..e92065eea91 100644
--- a/source/blender/editors/animation/keyframing.c
+++ b/source/blender/editors/animation/keyframing.c
@@ -1362,7 +1362,7 @@ static int insert_key_button_exec (bContext *C, wmOperator *op)
/* try to insert keyframe using property retrieved from UI */
memset(&ptr, 0, sizeof(PointerRNA));
- uiAnimContextProperty(C, &ptr, &prop, &index);
+ uiContextActiveProperty(C, &ptr, &prop, &index);
if ((ptr.id.data && ptr.data && prop) && RNA_property_animateable(&ptr, prop)) {
path= RNA_path_from_ID_to_property(&ptr, prop);
@@ -1405,6 +1405,8 @@ static int insert_key_button_exec (bContext *C, wmOperator *op)
if (success) {
/* send updates */
+ uiContextAnimUpdate(C);
+
DAG_ids_flush_update(bmain, 0);
/* send notifiers that keyframes have been changed */
@@ -1446,7 +1448,7 @@ static int delete_key_button_exec (bContext *C, wmOperator *op)
/* try to insert keyframe using property retrieved from UI */
memset(&ptr, 0, sizeof(PointerRNA));
- uiAnimContextProperty(C, &ptr, &prop, &index);
+ uiContextActiveProperty(C, &ptr, &prop, &index);
if (ptr.id.data && ptr.data && prop) {
path= RNA_path_from_ID_to_property(&ptr, prop);
@@ -1476,6 +1478,8 @@ static int delete_key_button_exec (bContext *C, wmOperator *op)
if (success) {
/* send updates */
+ uiContextAnimUpdate(C);
+
DAG_ids_flush_update(bmain, 0);
/* send notifiers that keyframes have been changed */
diff --git a/source/blender/editors/animation/keyingsets.c b/source/blender/editors/animation/keyingsets.c
index c54cd74383a..d80ccf2cd29 100644
--- a/source/blender/editors/animation/keyingsets.c
+++ b/source/blender/editors/animation/keyingsets.c
@@ -323,7 +323,7 @@ static int add_keyingset_button_exec (bContext *C, wmOperator *op)
/* try to add to keyingset using property retrieved from UI */
memset(&ptr, 0, sizeof(PointerRNA));
- uiAnimContextProperty(C, &ptr, &prop, &index);
+ uiContextActiveProperty(C, &ptr, &prop, &index);
/* check if property is able to be added */
if (ptr.id.data && ptr.data && prop && RNA_property_animateable(&ptr, prop)) {
@@ -409,7 +409,7 @@ static int remove_keyingset_button_exec (bContext *C, wmOperator *op)
/* try to add to keyingset using property retrieved from UI */
memset(&ptr, 0, sizeof(PointerRNA));
- uiAnimContextProperty(C, &ptr, &prop, &index);
+ uiContextActiveProperty(C, &ptr, &prop, &index);
if (ptr.id.data && ptr.data && prop) {
path= RNA_path_from_ID_to_property(&ptr, prop);
diff --git a/source/blender/editors/include/UI_interface.h b/source/blender/editors/include/UI_interface.h
index 7d56698f7b9..54a627da2da 100644
--- a/source/blender/editors/include/UI_interface.h
+++ b/source/blender/editors/include/UI_interface.h
@@ -737,7 +737,8 @@ void uiItemMenuEnumR(uiLayout *layout, struct PointerRNA *ptr, char *propname, c
void UI_buttons_operatortypes(void);
/* Helpers for Operators */
-void uiAnimContextProperty(const struct bContext *C, struct PointerRNA *ptr, struct PropertyRNA **prop, int *index);
+void uiContextActiveProperty(const struct bContext *C, struct PointerRNA *ptr, struct PropertyRNA **prop, int *index);
+void uiContextAnimUpdate(const struct bContext *C);
void uiFileBrowseContextProperty(const struct bContext *C, struct PointerRNA *ptr, struct PropertyRNA **prop);
void uiIDContextProperty(struct bContext *C, struct PointerRNA *ptr, struct PropertyRNA **prop);
diff --git a/source/blender/editors/interface/interface_anim.c b/source/blender/editors/interface/interface_anim.c
index 0e4de9fabaa..2a30a36ffe0 100644
--- a/source/blender/editors/interface/interface_anim.c
+++ b/source/blender/editors/interface/interface_anim.c
@@ -114,74 +114,50 @@ void ui_but_anim_autokey(bContext *C, uiBut *but, Scene *scene, float cfra)
}
}
-void uiAnimContextProperty(const bContext *C, struct PointerRNA *ptr, struct PropertyRNA **prop, int *index)
-{
- ARegion *ar= CTX_wm_region(C);
- uiBlock *block;
- uiBut *but;
-
- memset(ptr, 0, sizeof(*ptr));
- *prop= NULL;
- *index= 0;
-
- if(ar) {
- for(block=ar->uiblocks.first; block; block=block->next) {
- for(but=block->buttons.first; but; but= but->next) {
- if((but->active || but->flag & UI_BUT_LAST_ACTIVE) && but->rnapoin.data) {
- *ptr= but->rnapoin;
- *prop= but->rnaprop;
- *index= but->rnaindex;
- return;
- }
- }
- }
- }
-}
-
void ui_but_anim_insert_keyframe(bContext *C)
{
- /* this operator calls uiAnimContextProperty above */
+ /* this operator calls uiContextActiveProperty */
WM_operator_name_call(C, "ANIM_OT_keyframe_insert_button", WM_OP_INVOKE_DEFAULT, NULL);
}
void ui_but_anim_delete_keyframe(bContext *C)
{
- /* this operator calls uiAnimContextProperty above */
+ /* this operator calls uiContextActiveProperty */
WM_operator_name_call(C, "ANIM_OT_keyframe_delete_button", WM_OP_INVOKE_DEFAULT, NULL);
}
void ui_but_anim_add_driver(bContext *C)
{
- /* this operator calls uiAnimContextProperty above */
+ /* this operator calls uiContextActiveProperty */
WM_operator_name_call(C, "ANIM_OT_driver_button_add", WM_OP_INVOKE_DEFAULT, NULL);
}
void ui_but_anim_remove_driver(bContext *C)
{
- /* this operator calls uiAnimContextProperty above */
+ /* this operator calls uiContextActiveProperty */
WM_operator_name_call(C, "ANIM_OT_driver_button_remove", WM_OP_INVOKE_DEFAULT, NULL);
}
void ui_but_anim_copy_driver(bContext *C)
{
- /* this operator calls uiAnimContextProperty above */
+ /* this operator calls uiContextActiveProperty */
WM_operator_name_call(C, "ANIM_OT_copy_driver_button", WM_OP_INVOKE_DEFAULT, NULL);
}
void ui_but_anim_paste_driver(bContext *C)
{
- /* this operator calls uiAnimContextProperty above */
+ /* this operator calls uiContextActiveProperty */
WM_operator_name_call(C, "ANIM_OT_paste_driver_button", WM_OP_INVOKE_DEFAULT, NULL);
}
void ui_but_anim_add_keyingset(bContext *C)
{
- /* this operator calls uiAnimContextProperty above */
+ /* this operator calls uiContextActiveProperty */
WM_operator_name_call(C, "ANIM_OT_keyingset_button_add", WM_OP_INVOKE_DEFAULT, NULL);
}
void ui_but_anim_remove_keyingset(bContext *C)
{
- /* this operator calls uiAnimContextProperty above */
+ /* this operator calls uiContextActiveProperty */
WM_operator_name_call(C, "ANIM_OT_keyingset_button_remove", WM_OP_INVOKE_DEFAULT, NULL);
}
diff --git a/source/blender/editors/interface/interface_handlers.c b/source/blender/editors/interface/interface_handlers.c
index e411872964a..5bcde844d45 100644
--- a/source/blender/editors/interface/interface_handlers.c
+++ b/source/blender/editors/interface/interface_handlers.c
@@ -4255,6 +4255,7 @@ static int ui_but_menu(bContext *C, uiBut *but)
static int ui_do_button(bContext *C, uiBlock *block, uiBut *but, wmEvent *event)
{
+ Scene *scene= CTX_data_scene(C);
uiHandleButtonData *data;
int retval;
@@ -4906,6 +4907,98 @@ void ui_button_active_free(const bContext *C, uiBut *but)
}
}
+/* helper function for insert keyframe, reset to default, etc operators */
+void uiContextActiveProperty(const bContext *C, struct PointerRNA *ptr, struct PropertyRNA **prop, int *index)
+{
+ ARegion *ar= CTX_wm_region(C);
+ uiBlock *block;
+ uiBut *but, *activebut;
+
+ memset(ptr, 0, sizeof(*ptr));
+ *prop= NULL;
+ *index= 0;
+
+ while(ar) {
+ /* find active button */
+ activebut= NULL;
+
+ for(block=ar->uiblocks.first; block; block=block->next) {
+ for(but=block->buttons.first; but; but= but->next) {
+ if(but->active)
+ activebut= but;
+ else if(!activebut && (but->flag & UI_BUT_LAST_ACTIVE))
+ activebut= but;
+ }
+ }
+
+ if(activebut) {
+ if(activebut->rnapoin.data) {
+ /* found RNA button */
+ *ptr= activebut->rnapoin;
+ *prop= activebut->rnaprop;
+ *index= activebut->rnaindex;
+ return;
+ }
+ else {
+ /* recurse into opened menu */
+ uiHandleButtonData *data= activebut->active;
+ if(data && data->menu)
+ ar = data->menu->region;
+ else
+ return;
+ }
+ }
+ else {
+ /* no active button */
+ return;
+ }
+ }
+}
+
+/* helper function for insert keyframe, reset to default, etc operators */
+void uiContextAnimUpdate(const bContext *C)
+{
+ Scene *scene= CTX_data_scene(C);
+ ARegion *ar= CTX_wm_region(C);
+ uiBlock *block;
+ uiBut *but, *activebut;
+
+ while(ar) {
+ /* find active button */
+ activebut= NULL;
+
+ for(block=ar->uiblocks.first; block; block=block->next) {
+ for(but=block->buttons.first; but; but= but->next) {
+ ui_but_anim_flag(but, (scene)? scene->r.cfra: 0.0f);
+
+ if(but->active)
+ activebut= but;
+ else if(!activebut && (but->flag & UI_BUT_LAST_ACTIVE))
+ activebut= but;
+ }
+ }
+
+ if(activebut) {
+ if(activebut->rnapoin.data) {
+ /* found RNA button */
+ return;
+ }
+ else {
+ /* recurse into opened menu */
+ uiHandleButtonData *data= activebut->active;
+ if(data && data->menu)
+ ar = data->menu->region;
+ else
+ return;
+ }
+ }
+ else {
+ /* no active button */
+ return;
+ }
+ }
+}
+
/************** handle activating a button *************/
static uiBut *uit_but_find_open_event(ARegion *ar, wmEvent *event)
diff --git a/source/blender/editors/interface/interface_ops.c b/source/blender/editors/interface/interface_ops.c
index f0f69e06299..bcde54f473a 100644
--- a/source/blender/editors/interface/interface_ops.c
+++ b/source/blender/editors/interface/interface_ops.c
@@ -68,7 +68,7 @@ static int eyedropper_init(bContext *C, wmOperator *op)
op->customdata= eye= MEM_callocN(sizeof(Eyedropper), "Eyedropper");
- uiAnimContextProperty(C, &eye->ptr, &eye->prop, &eye->index);
+ uiContextActiveProperty(C, &eye->ptr, &eye->prop, &eye->index);
return (eye->ptr.data && eye->prop && RNA_property_editable(&eye->ptr, eye->prop));
}
@@ -228,7 +228,7 @@ static int copy_data_path_button_exec(bContext *C, wmOperator *op)
int index;
/* try to create driver using property retrieved from UI */
- uiAnimContextProperty(C, &ptr, &prop, &index);
+ uiContextActiveProperty(C, &ptr, &prop, &index);
if (ptr.id.data && ptr.data && prop) {
path= RNA_path_from_ID_to_property(&ptr, prop);
@@ -266,7 +266,7 @@ static int reset_default_button_poll(bContext *C)
PropertyRNA *prop;
int index;
- uiAnimContextProperty(C, &ptr, &prop, &index);
+ uiContextActiveProperty(C, &ptr, &prop, &index);
return (ptr.data && prop && RNA_property_editable(&ptr, prop));
}
@@ -279,7 +279,7 @@ static int reset_default_button_exec(bContext *C, wmOperator *op)
int index, all = RNA_boolean_get(op->ptr, "all");
/* try to reset the nominated setting to its default value */
- uiAnimContextProperty(C, &ptr, &prop, &index);
+ uiContextActiveProperty(C, &ptr, &prop, &index);
/* if there is a valid property that is editable... */
if (ptr.data && prop && RNA_property_editable(&ptr, prop)) {
@@ -335,7 +335,7 @@ static int copy_to_selected_button_poll(bContext *C)
PropertyRNA *prop;
int index, success= 0;
- uiAnimContextProperty(C, &ptr, &prop, &index);
+ uiContextActiveProperty(C, &ptr, &prop, &index);
if (ptr.data && prop) {
CollectionPointerLink *link;
@@ -361,7 +361,7 @@ static int copy_to_selected_button_exec(bContext *C, wmOperator *op)
int index, all = RNA_boolean_get(op->ptr, "all");
/* try to reset the nominated setting to its default value */
- uiAnimContextProperty(C, &ptr, &prop, &index);
+ uiContextActiveProperty(C, &ptr, &prop, &index);
/* if there is a valid property that is editable... */
if (ptr.data && prop) {