1
1

UI: remove extraneous inversion of "inverted" button state

Fix an issue where a `UI_BTYPE_CHECKBOX_N` button couldn't be toggled.

When toggling the value of a property, the `UI_BTYPE_TOGGLE_N`,
`UI_BTYPE_ICON_TOGGLE_N`, and `UI_BTYPE_CHECKBOX_N` types shouldn't
matter. These determine the inverted display of the value, but toggles
of that value should still happen once.

For these button types, the toggle happened twice, effectively making it
a no-op. The code for individual values is now also consistent with the
code for handling bit-flags.

Actually found & over-the-shoulder-reviewed by @Severin
This commit is contained in:
2022-10-06 18:22:07 +02:00
parent bd77cdde58
commit 26df25caef

View File

@@ -1118,9 +1118,6 @@ static void ui_apply_but_TOG(bContext *C, uiBut *but, uiHandleButtonData *data)
}
else {
value_toggle = (value == 0.0);
if (ELEM(but->type, UI_BTYPE_TOGGLE_N, UI_BTYPE_ICON_TOGGLE_N, UI_BTYPE_CHECKBOX_N)) {
value_toggle = !value_toggle;
}
}
ui_but_value_set(but, (double)value_toggle);