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:
authorCampbell Barton <ideasman42@gmail.com>2011-09-28 22:45:17 +0400
committerCampbell Barton <ideasman42@gmail.com>2011-09-28 22:45:17 +0400
commit2ad45b5c4f54765ad8804d26dd28b1eca2c235e5 (patch)
tree908bbba4c048936c779d8b143895636ac79b1a29 /source/blender/editors/interface
parent4ea3f1cc29b86f0464553c9da05d9f483b7da134 (diff)
fix 2 bugs with reset-default failing on operators redo panel.
- The operator its self was registered so resetting the defaults would unhelpfully replace the toolbar with the reset to defaults operator panel. - The callback for the operator wasnt being used so the settings were changed but the operator didnt re-run.
Diffstat (limited to 'source/blender/editors/interface')
-rw-r--r--source/blender/editors/interface/interface.c2
-rw-r--r--source/blender/editors/interface/interface_handlers.c52
-rw-r--r--source/blender/editors/interface/interface_ops.c25
3 files changed, 63 insertions, 16 deletions
diff --git a/source/blender/editors/interface/interface.c b/source/blender/editors/interface/interface.c
index 286906402b9..bcf83f7bfb9 100644
--- a/source/blender/editors/interface/interface.c
+++ b/source/blender/editors/interface/interface.c
@@ -746,7 +746,7 @@ static int ui_but_is_rna_undo(uiBut *but)
* unforseen conciquences, so best check for ID's we _know_ are not
* handled by undo - campbell */
ID *id= but->rnapoin.id.data;
- if(ELEM(GS(id->name), ID_SCR, ID_WM)) {
+ if(ID_CHECK_UNDO(id) == FALSE) {
return FALSE;
}
else {
diff --git a/source/blender/editors/interface/interface_handlers.c b/source/blender/editors/interface/interface_handlers.c
index 082ddb5b060..929a8bf1dc6 100644
--- a/source/blender/editors/interface/interface_handlers.c
+++ b/source/blender/editors/interface/interface_handlers.c
@@ -5089,19 +5089,16 @@ 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)
+static uiBut *ui_context_rna_button_active(const bContext *C)
{
- ARegion *ar= CTX_wm_region(C);
+ uiBut *rnabut= NULL;
- memset(ptr, 0, sizeof(*ptr));
- *prop= NULL;
- *index= 0;
+ ARegion *ar= CTX_wm_region(C);
while(ar) {
uiBlock *block;
uiBut *but, *activebut= NULL;
-
+
/* find active button */
for(block=ar->uiblocks.first; block; block=block->next) {
for(but=block->buttons.first; but; but= but->next) {
@@ -5115,24 +5112,53 @@ void uiContextActiveProperty(const bContext *C, struct PointerRNA *ptr, struct P
if(activebut && activebut->rnapoin.data) {
uiHandleButtonData *data= activebut->active;
- /* found RNA button */
- *ptr= activebut->rnapoin;
- *prop= activebut->rnaprop;
- *index= activebut->rnaindex;
+ rnabut= activebut;
/* recurse into opened menu, like colorpicker case */
if(data && data->menu && (ar != data->menu->region)) {
ar = data->menu->region;
}
else {
- return;
+ return rnabut;
}
}
else {
/* no active button */
- return;
+ return rnabut;
}
}
+
+ return rnabut;
+}
+
+/* helper function for insert keyframe, reset to default, etc operators */
+void uiContextActiveProperty(const bContext *C, struct PointerRNA *ptr, struct PropertyRNA **prop, int *index)
+{
+ uiBut *activebut= ui_context_rna_button_active(C);
+
+ memset(ptr, 0, sizeof(*ptr));
+
+ if(activebut && activebut->rnapoin.data) {
+ *ptr= activebut->rnapoin;
+ *prop= activebut->rnaprop;
+ *index= activebut->rnaindex;
+ }
+ else {
+ *prop= NULL;
+ *index= 0;
+ }
+}
+
+void uiContextActivePropertyHandle(bContext *C)
+{
+ uiBut *activebut= ui_context_rna_button_active(C);
+ if(activebut) {
+ /* TODO, look into a better way to handle the button change
+ * currently this is mainly so reset defaults works for the
+ * operator redo panel - campbell */
+ uiBlock *block= activebut->block;
+ block->handle_func(C, block->handle_func_arg, 0);
+ }
}
/* helper function for insert keyframe, reset to default, etc operators */
diff --git a/source/blender/editors/interface/interface_ops.c b/source/blender/editors/interface/interface_ops.c
index fd9386dc5ab..ea7e8fb81bc 100644
--- a/source/blender/editors/interface/interface_ops.c
+++ b/source/blender/editors/interface/interface_ops.c
@@ -295,10 +295,31 @@ static int reset_default_button_exec(bContext *C, wmOperator *op)
if(RNA_property_reset(&ptr, prop, (all)? -1: index)) {
/* perform updates required for this property */
RNA_property_update(C, &ptr, prop);
+
+ /* as if we pressed the button */
+ uiContextActivePropertyHandle(C);
+
success= 1;
}
}
-
+
+ /* Since we dont want to undo _all_ edits to settings, eg window
+ * edits on the screen or on operator settings.
+ * it might be better to move undo's inline - campbell */
+ /* Note that buttons already account for this, it might be better to
+ * have a way to edit the buttons rather than set the rna since block
+ * callbacks also fail to run. */
+ if(success) {
+ ID *id= ptr.id.data;
+ if(id && ID_CHECK_UNDO(id)) {
+ /* do nothing, go ahead with undo */
+ }
+ else {
+ return OPERATOR_CANCELLED;
+ }
+ }
+ /* end hack */
+
return (success)? OPERATOR_FINISHED: OPERATOR_CANCELLED;
}
@@ -314,7 +335,7 @@ static void UI_OT_reset_default_button(wmOperatorType *ot)
ot->exec= reset_default_button_exec;
/* flags */
- ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
+ ot->flag= OPTYPE_UNDO;
/* properties */
RNA_def_boolean(ot->srna, "all", 1, "All", "Reset to default values all elements of the array");