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>2019-03-25 08:17:39 +0300
committerCampbell Barton <ideasman42@gmail.com>2019-03-25 08:21:13 +0300
commitca0cc0518f23ad0fa8c0a3c3614d6a469f4af20e (patch)
treeff9b030fd8ed97ccbde0ab620f2c4516c3f8911c /source/blender/editors/interface/interface_handlers.c
parentdec9e34361b4ca0c3b90926f753477944818f80a (diff)
Cleanup: simplify toggle button logic
Diffstat (limited to 'source/blender/editors/interface/interface_handlers.c')
-rw-r--r--source/blender/editors/interface/interface_handlers.c41
1 files changed, 10 insertions, 31 deletions
diff --git a/source/blender/editors/interface/interface_handlers.c b/source/blender/editors/interface/interface_handlers.c
index 7448de07e0e..6474ccc7794 100644
--- a/source/blender/editors/interface/interface_handlers.c
+++ b/source/blender/editors/interface/interface_handlers.c
@@ -856,44 +856,23 @@ static void ui_apply_but_BLOCK(bContext *C, uiBut *but, uiHandleButtonData *data
static void ui_apply_but_TOG(bContext *C, uiBut *but, uiHandleButtonData *data)
{
- double value;
- int w, lvalue, push;
-
- value = ui_but_value_get(but);
- lvalue = (int)value;
-
+ const double value = ui_but_value_get(but);
+ int value_toggle;
if (but->bit) {
- w = UI_BITBUT_TEST(lvalue, but->bitnr);
- if (w) {
- lvalue = UI_BITBUT_CLR(lvalue, but->bitnr);
- }
- else {
- lvalue = UI_BITBUT_SET(lvalue, but->bitnr);
- }
-
- ui_but_value_set(but, (double)lvalue);
- if (but->type == UI_BTYPE_ICON_TOGGLE || but->type == UI_BTYPE_ICON_TOGGLE_N) {
- ui_but_update_edited(but);
- }
+ value_toggle = UI_BITBUT_VALUE_TOGGLED((int)value, but->bitnr);
}
else {
-
- if (value == 0.0) {
- push = 1;
- }
- else {
- push = 0;
- }
-
+ value_toggle = (value == 0.0);
if (ELEM(but->type, UI_BTYPE_TOGGLE_N, UI_BTYPE_ICON_TOGGLE_N, UI_BTYPE_CHECKBOX_N)) {
- push = !push;
- }
- ui_but_value_set(but, (double)push);
- if (but->type == UI_BTYPE_ICON_TOGGLE || but->type == UI_BTYPE_ICON_TOGGLE_N) {
- ui_but_update_edited(but);
+ value_toggle = !value_toggle;
}
}
+ ui_but_value_set(but, (double)value_toggle);
+ if (but->type == UI_BTYPE_ICON_TOGGLE || but->type == UI_BTYPE_ICON_TOGGLE_N) {
+ ui_but_update_edited(but);
+ }
+
ui_apply_but_func(C, but);
data->retval = but->retval;