fix [#36073] Changing list items misses undo push
This commit is contained in:
@@ -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),
|
||||
|
@@ -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;
|
||||
|
||||
|
@@ -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);
|
||||
|
||||
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;
|
||||
}
|
||||
|
@@ -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;
|
||||
}
|
||||
|
||||
|
@@ -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);
|
||||
|
Reference in New Issue
Block a user