diff options
author | Campbell Barton <ideasman42@gmail.com> | 2018-09-19 05:05:58 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2018-09-19 05:12:21 +0300 |
commit | bb3ec3ebafbc2c0e5d8530148a433242e0adad30 (patch) | |
tree | d30aaa3df2d03f90f6e7749bdc075445a5642045 /source/blender/editors/interface | |
parent | 4c918efd44be11d47afc1efed684a15ad5579722 (diff) |
BLI_utildefines: rename pointer conversion macros
Terms get/set don't make much sense when casting values.
Name macros so the conversion is obvious,
use common prefix for easier completion.
- GET_INT_FROM_POINTER -> POINTER_AS_INT
- SET_INT_IN_POINTER -> POINTER_FROM_INT
- GET_UINT_FROM_POINTER -> POINTER_AS_UINT
- SET_UINT_IN_POINTER -> POINTER_FROM_UINT
Diffstat (limited to 'source/blender/editors/interface')
-rw-r--r-- | source/blender/editors/interface/interface.c | 4 | ||||
-rw-r--r-- | source/blender/editors/interface/interface_layout.c | 12 | ||||
-rw-r--r-- | source/blender/editors/interface/interface_templates.c | 24 |
3 files changed, 20 insertions, 20 deletions
diff --git a/source/blender/editors/interface/interface.c b/source/blender/editors/interface/interface.c index 2e4cab5ec24..0b611a8e4c8 100644 --- a/source/blender/editors/interface/interface.c +++ b/source/blender/editors/interface/interface.c @@ -4484,7 +4484,7 @@ static void operator_enum_search_cb(const struct bContext *C, void *but, const c for (item = item_array; item->identifier; item++) { /* note: need to give the index rather than the identifier because the enum can be freed */ if (BLI_strcasestr(item->name, str)) { - if (false == UI_search_item_add(items, item->name, SET_INT_IN_POINTER(item->value), 0)) + if (false == UI_search_item_add(items, item->name, POINTER_FROM_INT(item->value), 0)) break; } } @@ -4502,7 +4502,7 @@ static void operator_enum_call_cb(struct bContext *UNUSED(C), void *but, void *a if (ot) { if (ot->prop) { - RNA_property_enum_set(opptr, ot->prop, GET_INT_FROM_POINTER(arg2)); + RNA_property_enum_set(opptr, ot->prop, POINTER_AS_INT(arg2)); /* We do not call op from here, will be called by button code. * ui_apply_but_funcs_after() (in interface_handlers.c) called this func before checking operators, * because one of its parameters is the button itself! diff --git a/source/blender/editors/interface/interface_layout.c b/source/blender/editors/interface/interface_layout.c index edd568e4fea..81810baf2cf 100644 --- a/source/blender/editors/interface/interface_layout.c +++ b/source/blender/editors/interface/interface_layout.c @@ -370,7 +370,7 @@ static void ui_layer_but_cb(bContext *C, void *arg_but, void *arg_index) uiBut *but = arg_but, *cbut; PointerRNA *ptr = &but->rnapoin; PropertyRNA *prop = but->rnaprop; - int i, index = GET_INT_FROM_POINTER(arg_index); + int i, index = POINTER_AS_INT(arg_index); int shift = win->eventstate->shift; int len = RNA_property_array_length(ptr, prop); @@ -463,7 +463,7 @@ static void ui_item_array( but = uiDefAutoButR(block, ptr, prop, layer_num, "", icon, x + butw * a, y + buth, butw, buth); if (subtype == PROP_LAYER_MEMBER) - UI_but_func_set(but, ui_layer_but_cb, but, SET_INT_IN_POINTER(layer_num)); + UI_but_func_set(but, ui_layer_but_cb, but, POINTER_FROM_INT(layer_num)); } for (a = 0; a < colbuts; a++) { const int layer_num = a + len / 2 + b * colbuts; @@ -481,7 +481,7 @@ static void ui_item_array( but = uiDefAutoButR(block, ptr, prop, layer_num, "", icon, x + butw * a, y, butw, buth); if (subtype == PROP_LAYER_MEMBER) - UI_but_func_set(but, ui_layer_but_cb, but, SET_INT_IN_POINTER(layer_num)); + UI_but_func_set(but, ui_layer_but_cb, but, POINTER_FROM_INT(layer_num)); } UI_block_align_end(block); @@ -567,7 +567,7 @@ static void ui_item_enum_expand_handle(bContext *C, void *arg1, void *arg2) if (!win->eventstate->shift) { uiBut *but = (uiBut *)arg1; - int enum_value = GET_INT_FROM_POINTER(arg2); + int enum_value = POINTER_AS_INT(arg2); int current_value = RNA_property_enum_get(&but->rnapoin, but->rnaprop); if (!(current_value & enum_value)) { @@ -645,7 +645,7 @@ static void ui_item_enum_expand( but = uiDefButR_prop(block, UI_BTYPE_ROW, 0, name, 0, 0, itemw, h, ptr, prop, -1, 0, value, -1, -1, NULL); if (RNA_property_flag(prop) & PROP_ENUM_FLAG) { - UI_but_func_set(but, ui_item_enum_expand_handle, but, SET_INT_IN_POINTER(value)); + UI_but_func_set(but, ui_item_enum_expand_handle, but, POINTER_FROM_INT(value)); } if (ui_layout_local_dir(layout) != UI_LAYOUT_HORIZONTAL) @@ -1741,7 +1741,7 @@ static void rna_search_cb(const struct bContext *C, void *arg_but, const char *s /* add search items from temporary list */ for (cis = items_list->first; cis; cis = cis->next) { - if (false == UI_search_item_add(items, cis->name, SET_INT_IN_POINTER(cis->index), cis->iconid)) { + if (false == UI_search_item_add(items, cis->name, POINTER_FROM_INT(cis->index), cis->iconid)) { break; } } diff --git a/source/blender/editors/interface/interface_templates.c b/source/blender/editors/interface/interface_templates.c index be489072439..2bafc3b641b 100644 --- a/source/blender/editors/interface/interface_templates.c +++ b/source/blender/editors/interface/interface_templates.c @@ -349,7 +349,7 @@ static void template_id_cb(bContext *C, void *arg_litem, void *arg_event) TemplateID *template_ui = (TemplateID *)arg_litem; PointerRNA idptr = RNA_property_pointer_get(&template_ui->ptr, template_ui->prop); ID *id = idptr.data; - int event = GET_INT_FROM_POINTER(arg_event); + int event = POINTER_AS_INT(arg_event); switch (event) { case UI_ID_BROWSE: @@ -535,7 +535,7 @@ static void template_ID( but = uiDefButR( block, UI_BTYPE_TEXT, 0, name, 0, 0, UI_UNIT_X * 6, UI_UNIT_Y, &idptr, "name", -1, 0, 0, -1, -1, RNA_struct_ui_description(type)); - UI_but_funcN_set(but, template_id_cb, MEM_dupallocN(template_ui), SET_INT_IN_POINTER(UI_ID_RENAME)); + UI_but_funcN_set(but, template_id_cb, MEM_dupallocN(template_ui), POINTER_FROM_INT(UI_ID_RENAME)); if (user_alert) UI_but_flag_enable(but, UI_BUT_REDALERT); if (id->lib) { @@ -553,7 +553,7 @@ static void template_ID( UI_but_flag_enable(but, UI_BUT_DISABLED); } - UI_but_funcN_set(but, template_id_cb, MEM_dupallocN(template_ui), SET_INT_IN_POINTER(UI_ID_LOCAL)); + UI_but_funcN_set(but, template_id_cb, MEM_dupallocN(template_ui), POINTER_FROM_INT(UI_ID_LOCAL)); } if (id->us > 1) { @@ -568,7 +568,7 @@ static void template_ID( TIP_("Display number of users of this data (click to make a single-user copy)")); but->flag |= UI_BUT_UNDO; - UI_but_funcN_set(but, template_id_cb, MEM_dupallocN(template_ui), SET_INT_IN_POINTER(UI_ID_ALONE)); + UI_but_funcN_set(but, template_id_cb, MEM_dupallocN(template_ui), POINTER_FROM_INT(UI_ID_ALONE)); if (/* test only */ (id_copy(CTX_data_main(C), id, NULL, true) == false) || (idfrom && idfrom->lib) || @@ -626,13 +626,13 @@ static void template_ID( but = uiDefIconTextButO( block, UI_BTYPE_BUT, newop, WM_OP_INVOKE_DEFAULT, ICON_ZOOMIN, (id) ? "" : CTX_IFACE_(template_id_context(type), "New"), 0, 0, w, UI_UNIT_Y, NULL); - UI_but_funcN_set(but, template_id_cb, MEM_dupallocN(template_ui), SET_INT_IN_POINTER(UI_ID_ADD_NEW)); + UI_but_funcN_set(but, template_id_cb, MEM_dupallocN(template_ui), POINTER_FROM_INT(UI_ID_ADD_NEW)); } else { but = uiDefIconTextBut( block, UI_BTYPE_BUT, 0, ICON_ZOOMIN, (id) ? "" : CTX_IFACE_(template_id_context(type), "New"), 0, 0, w, UI_UNIT_Y, NULL, 0, 0, 0, 0, NULL); - UI_but_funcN_set(but, template_id_cb, MEM_dupallocN(template_ui), SET_INT_IN_POINTER(UI_ID_ADD_NEW)); + UI_but_funcN_set(but, template_id_cb, MEM_dupallocN(template_ui), POINTER_FROM_INT(UI_ID_ADD_NEW)); } if ((idfrom && idfrom->lib) || !editable) @@ -658,13 +658,13 @@ static void template_ID( but = uiDefIconTextButO( block, UI_BTYPE_BUT, openop, WM_OP_INVOKE_DEFAULT, ICON_FILESEL, (id) ? "" : IFACE_("Open"), 0, 0, w, UI_UNIT_Y, NULL); - UI_but_funcN_set(but, template_id_cb, MEM_dupallocN(template_ui), SET_INT_IN_POINTER(UI_ID_OPEN)); + UI_but_funcN_set(but, template_id_cb, MEM_dupallocN(template_ui), POINTER_FROM_INT(UI_ID_OPEN)); } else { but = uiDefIconTextBut( block, UI_BTYPE_BUT, 0, ICON_FILESEL, (id) ? "" : IFACE_("Open"), 0, 0, w, UI_UNIT_Y, NULL, 0, 0, 0, 0, NULL); - UI_but_funcN_set(but, template_id_cb, MEM_dupallocN(template_ui), SET_INT_IN_POINTER(UI_ID_OPEN)); + UI_but_funcN_set(but, template_id_cb, MEM_dupallocN(template_ui), POINTER_FROM_INT(UI_ID_OPEN)); } if ((idfrom && idfrom->lib) || !editable) @@ -688,7 +688,7 @@ static void template_ID( block, UI_BTYPE_BUT, 0, ICON_X, 0, 0, UI_UNIT_X, UI_UNIT_Y, NULL, 0, 0, 0, 0, TIP_("Unlink data-block " "(Shift + Click to set users to zero, data will then not be saved)")); - UI_but_funcN_set(but, template_id_cb, MEM_dupallocN(template_ui), SET_INT_IN_POINTER(UI_ID_DELETE)); + UI_but_funcN_set(but, template_id_cb, MEM_dupallocN(template_ui), POINTER_FROM_INT(UI_ID_DELETE)); if (RNA_property_flag(template_ui->prop) & PROP_NEVER_NULL) { UI_but_flag_enable(but, UI_BUT_DISABLED); @@ -2598,7 +2598,7 @@ void uiTemplateCryptoPicker(uiLayout *layout, PointerRNA *ptr, const char *propn static void handle_layer_buttons(bContext *C, void *arg1, void *arg2) { uiBut *but = arg1; - int cur = GET_INT_FROM_POINTER(arg2); + int cur = POINTER_AS_INT(arg2); wmWindow *win = CTX_wm_window(C); int i, tot, shift = win->eventstate->shift; @@ -2682,7 +2682,7 @@ void uiTemplateLayers( icon = ICON_LAYER_USED; but = uiDefAutoButR(block, ptr, prop, layer, "", icon, 0, 0, UI_UNIT_X / 2, UI_UNIT_Y / 2); - UI_but_func_set(but, handle_layer_buttons, but, SET_INT_IN_POINTER(layer)); + UI_but_func_set(but, handle_layer_buttons, but, POINTER_FROM_INT(layer)); but->type = UI_BTYPE_TOGGLE; } } @@ -2753,7 +2753,7 @@ void uiTemplateGameStates( but = uiDefIconButR_prop( block, UI_BTYPE_ICON_TOGGLE, 0, icon, 0, 0, UI_UNIT_X / 2, UI_UNIT_Y / 2, ptr, prop, state, 0, 0, -1, -1, sca_state_name_get(ob, state)); - UI_but_func_set(but, handle_layer_buttons, but, SET_INT_IN_POINTER(state)); + UI_but_func_set(but, handle_layer_buttons, but, POINTER_FROM_INT(state)); but->type = UI_BTYPE_TOGGLE; } } |