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>2013-02-26 01:13:40 +0400
committerCampbell Barton <ideasman42@gmail.com>2013-02-26 01:13:40 +0400
commite2b41cb96f1ab9f3fc2e78eda2d5cc740487e95c (patch)
tree57bdb720f35f98dbd1c24fc978b485a614c50308 /source/blender
parentb7af3207cca5b28b5b901258412bdfab00b41fca (diff)
revert some changes from own commit r54850 which broke undo for toggle buttons, also make toggle buttons auto-key.
Diffstat (limited to 'source/blender')
-rw-r--r--source/blender/editors/interface/interface_handlers.c18
-rw-r--r--source/blender/editors/util/undo.c4
2 files changed, 15 insertions, 7 deletions
diff --git a/source/blender/editors/interface/interface_handlers.c b/source/blender/editors/interface/interface_handlers.c
index c74fa1a2712..053551f4cf8 100644
--- a/source/blender/editors/interface/interface_handlers.c
+++ b/source/blender/editors/interface/interface_handlers.c
@@ -406,9 +406,9 @@ static void ui_apply_but_func(bContext *C, uiBut *but)
}
}
-static void ui_apply_autokey_undo(bContext *C, uiBut *but)
+/* typically call ui_apply_undo(), ui_apply_autokey() */
+static void ui_apply_undo(uiBut *but)
{
- Scene *scene = CTX_data_scene(C);
uiAfterFunc *after;
if (but->flag & UI_BUT_UNDO) {
@@ -430,6 +430,11 @@ static void ui_apply_autokey_undo(bContext *C, uiBut *but)
BLI_strncpy(after->undostr, str, sizeof(after->undostr));
BLI_addtail(&UIAfterFuncs, after);
}
+}
+
+static void ui_apply_autokey(bContext *C, uiBut *but)
+{
+ Scene *scene = CTX_data_scene(C);
/* try autokey */
ui_but_anim_autokey(C, but, scene, scene->r.cfra);
@@ -770,6 +775,8 @@ static int ui_but_start_drag(bContext *C, uiBut *but, uiHandleButtonData *data,
/* assumes button has already been pressed */
const bool is_set = (ui_get_but_val(but) == 0.0);
PointerRNA ptr;
+ /* auto-key is typically called on mouse-up, but we'r leaving the button so call here */
+ ui_apply_autokey(C, but);
WM_operator_properties_create(&ptr, "UI_OT_drag_toggle");
RNA_boolean_set(&ptr, "state", !is_set);
RNA_int_set(&ptr, "last_x", data->dragstartx);
@@ -2504,12 +2511,11 @@ static int ui_do_but_TOG(bContext *C, uiBut *but, uiHandleButtonData *data, cons
}
else if (data->state == BUTTON_STATE_WAIT_DRAG) {
/* note: the 'BUTTON_STATE_WAIT_DRAG' part of 'ui_do_but_EXIT' could be refactored into its own function */
- data->cancel = true;
data->applied = false;
return ui_do_but_EXIT(C, but, data, event);
}
- return WM_UI_HANDLER_BREAK;
+ return WM_UI_HANDLER_CONTINUE;
}
static int ui_do_but_EXIT(bContext *C, uiBut *but, uiHandleButtonData *data, const wmEvent *event)
@@ -5800,7 +5806,8 @@ static void button_activate_exit(bContext *C, uiBut *but, uiHandleButtonData *da
if (!onfree && !data->cancel) {
/* autokey & undo push */
- ui_apply_autokey_undo(C, but);
+ ui_apply_undo(but);
+ ui_apply_autokey(C, but);
/* popup menu memory */
if (block->flag & UI_BLOCK_POPUP_MEMORY)
@@ -6089,6 +6096,7 @@ void ui_button_execute_do(struct bContext *C, struct ARegion *ar, uiBut *but)
data->region = ar;
ui_apply_button(C, but->block, but, data, true);
/* use onfree event so undo is handled by caller and apply is already done above */
+ ui_apply_autokey(C, but);
button_activate_exit((bContext *)C, but, data, false, true);
but->active = active_back;
}
diff --git a/source/blender/editors/util/undo.c b/source/blender/editors/util/undo.c
index 8a0ef06ef12..ac2ee21d09d 100644
--- a/source/blender/editors/util/undo.c
+++ b/source/blender/editors/util/undo.c
@@ -83,8 +83,8 @@ void ED_undo_push(bContext *C, const char *str)
Object *obact = CTX_data_active_object(C);
if (G.debug & G_DEBUG)
- printf("undo push %s\n", str);
-
+ printf("%s: %s\n", __func__, str);
+
if (obedit) {
if (U.undosteps == 0) return;