fix [#36073] Changing list items misses undo push
authorCampbell Barton <ideasman42@gmail.com>
Tue, 9 Jul 2013 23:40:53 +0000 (23:40 +0000)
committerCampbell Barton <ideasman42@gmail.com>
Tue, 9 Jul 2013 23:40:53 +0000 (23:40 +0000)
source/blender/editors/include/UI_interface.h
source/blender/editors/interface/interface.c
source/blender/editors/interface/interface_handlers.c
source/blender/editors/interface/interface_layout.c
source/blender/editors/interface/interface_templates.c

index b566fd360b6081e0628b54730d9232d8f6208aa0..e5cc0dd8ea726d31ddc28fd04aed3edbb4e0ba9c 100644 (file)
@@ -236,6 +236,8 @@ typedef enum {
        BUT_NORMAL    = (31 << 9),
        BUT_CURVE     = (32 << 9),
        ICONTOGN      = (34 << 9),
+       LISTBOX       = (35 << 9),
+       LISTROW       = (36 << 9),
        TOGBUT        = (37 << 9),
        OPTION        = (38 << 9),
        OPTIONN       = (39 << 9),
@@ -244,8 +246,6 @@ typedef enum {
        SEARCH_MENU   = (41 << 9),
        BUT_EXTRA     = (42 << 9),
        HSVCIRCLE     = (43 << 9),
-       LISTBOX       = (44 << 9),
-       LISTROW       = (45 << 9),
        HOTKEYEVT     = (46 << 9),
        BUT_IMAGE     = (47 << 9),
        HISTOGRAM     = (48 << 9),
index c3bc87ac6473055fe8f4c06c8b9b3b2b3f1ac354..898e653d5620589d582e182d810895a725da78ed 100644 (file)
@@ -2861,7 +2861,7 @@ static uiBut *ui_def_but(uiBlock *block, int type, int retval, const char *str,
        }
 
        /* keep track of UI_interface.h */
-       if      (ELEM9(but->type, BLOCK, BUT, LABEL, PULLDOWN, ROUNDBOX, LISTBOX, BUTM, SCROLL, SEPR /* , FTPREVIEW */)) {}
+       if      (ELEM8(but->type, BLOCK, BUT, LABEL, PULLDOWN, ROUNDBOX, BUTM, SCROLL, SEPR)) {}
        else if (but->type >= SEARCH_MENU) {}
        else but->flag |= UI_BUT_UNDO;
 
index 8782076798eb421f5ac981d8022424dfc03f0706..c0a059531569a3dea5a9af7c8a323d478089edff 100644 (file)
@@ -6419,7 +6419,6 @@ static int ui_handle_list_event(bContext *C, const wmEvent *event, ARegion *ar)
 {
        uiBut *but = ui_list_find_mouse_over(ar, event->x, event->y);
        int retval = WM_UI_HANDLER_CONTINUE;
-       int value, min, max;
        int type = event->type, val = event->val;
 
        if (but) {
@@ -6442,8 +6441,11 @@ static int ui_handle_list_event(bContext *C, const wmEvent *event, ARegion *ar)
                                if (ELEM(type, UPARROWKEY, DOWNARROWKEY) ||
                                        ((ELEM(type, WHEELUPMOUSE, WHEELDOWNMOUSE) && event->alt)))
                                {
+                                       const int value_orig = RNA_property_int_get(&but->rnapoin, but->rnaprop);
+                                       int value, min, max;
+
                                        /* activate up/down the list */
-                                       value = RNA_property_int_get(&but->rnapoin, but->rnaprop);
+                                       value = value_orig;
 
                                        if (ELEM(type, UPARROWKEY, WHEELUPMOUSE))
                                                value--;
@@ -6460,9 +6462,13 @@ static int ui_handle_list_event(bContext *C, const wmEvent *event, ARegion *ar)
                                        RNA_property_int_range(&but->rnapoin, but->rnaprop, &min, &max);
                                        value = CLAMPIS(value, min, max);
 
-                                       RNA_property_int_set(&but->rnapoin, but->rnaprop, value);
-                                       RNA_property_update(C, &but->rnapoin, but->rnaprop);
-                                       ED_region_tag_redraw(ar);
+                                       if (value != value_orig) {
+                                               RNA_property_int_set(&but->rnapoin, but->rnaprop, value);
+                                               RNA_property_update(C, &but->rnapoin, but->rnaprop);
+
+                                               ui_apply_undo(but);
+                                               ED_region_tag_redraw(ar);
+                                       }
 
                                        retval = WM_UI_HANDLER_BREAK;
                                }
index 2a6a9600582f201b943b857cdd9109ccccbca604..461d0b24d576abd07d54bac08931f8ed1814b3b1 100644 (file)
@@ -2429,6 +2429,11 @@ uiLayout *uiLayoutListBox(uiLayout *layout, uiList *ui_list, PointerRNA *ptr, Pr
        but->rnapoin = *actptr;
        but->rnaprop = actprop;
 
+       /* only for the undo string */
+       if (but->flag & UI_BUT_UNDO) {
+               but->tip = RNA_property_description(actprop);
+       }
+
        return (uiLayout *)box;
 }
 
index e061ff3502569a66e576b13aca5dac7fde607f16..910d284e86ba18998e630124da68d8cca118abe3 100644 (file)
@@ -2646,7 +2646,7 @@ void uiTemplateList(uiLayout *layout, bContext *C, const char *listtype_name, co
                                                sub = uiLayoutRow(overlap, FALSE);
 
                                                but = uiDefButR_prop(subblock, LISTROW, 0, "", 0, 0, UI_UNIT_X * 10, UI_UNIT_Y,
-                                                                    active_dataptr, activeprop, 0, 0, i, 0, 0, "");
+                                                                    active_dataptr, activeprop, 0, 0, i, 0, 0, NULL);
                                                uiButSetFlag(but, UI_BUT_NO_TOOLTIP);
 
                                                sub = uiLayoutRow(overlap, FALSE);
@@ -2734,7 +2734,7 @@ void uiTemplateList(uiLayout *layout, bContext *C, const char *listtype_name, co
                                        sub = uiLayoutRow(overlap, FALSE);
 
                                        but = uiDefButR_prop(subblock, LISTROW, 0, "", 0, 0, UI_UNIT_X * 10, UI_UNIT_Y,
-                                                            active_dataptr, activeprop, 0, 0, i, 0, 0, "");
+                                                            active_dataptr, activeprop, 0, 0, i, 0, 0, NULL);
                                        uiButSetFlag(but, UI_BUT_NO_TOOLTIP);
 
                                        sub = uiLayoutRow(overlap, FALSE);