diff options
Diffstat (limited to 'source/blender/editors/interface/interface_handlers.c')
-rw-r--r-- | source/blender/editors/interface/interface_handlers.c | 952 |
1 files changed, 476 insertions, 476 deletions
diff --git a/source/blender/editors/interface/interface_handlers.c b/source/blender/editors/interface/interface_handlers.c index 0e3b8e8da63..992c72cacf8 100644 --- a/source/blender/editors/interface/interface_handlers.c +++ b/source/blender/editors/interface/interface_handlers.c @@ -104,8 +104,8 @@ #define UI_MAX_PASSWORD_STR 128 /* proto */ -static void ui_add_smart_controller(bContext *C, uiBut *from, uiBut *to); -static void ui_add_link(bContext *C, uiBut *from, uiBut *to); +static void ui_but_smart_controller_add(bContext *C, uiBut *from, uiBut *to); +static void ui_but_link_add(bContext *C, uiBut *from, uiBut *to); static int ui_do_but_EXIT(bContext *C, uiBut *but, struct uiHandleButtonData *data, const wmEvent *event); #ifdef USE_KEYNAV_LIMIT @@ -252,16 +252,16 @@ typedef struct uiHandleButtonData { CBData *dragcbd; #ifdef USE_CONT_MOUSE_CORRECT - /* when ungrabbing buttons which are #ui_is_a_warp_but(), we may want to position them + /* when ungrabbing buttons which are #ui_but_is_cursor_warp(), we may want to position them * FLT_MAX signifies do-nothing, use #ui_block_to_window_fl() to get this into a usable space */ float ungrab_mval[2]; #endif - /* menu open (watch uiFreeActiveButtons) */ + /* menu open (watch UI_screen_free_active_but) */ uiPopupBlockHandle *menu; int menuretval; - /* search box (watch uiFreeActiveButtons) */ + /* search box (watch UI_screen_free_active_but) */ ARegion *searchbox; #ifdef USE_KEYNAV_LIMIT struct uiKeyNavLock searchbox_keynav_state; @@ -313,9 +313,9 @@ typedef struct uiAfterFunc { -static bool ui_is_but_interactive(const uiBut *but, const bool labeledit); +static bool ui_but_is_interactive(const uiBut *but, const bool labeledit); static bool ui_but_contains_pt(uiBut *but, float mx, float my); -static bool ui_mouse_inside_button(ARegion *ar, uiBut *but, int x, int y); +static bool ui_but_contains_point_px(ARegion *ar, uiBut *but, int x, int y); static uiBut *ui_but_find_mouse_over_ex(ARegion *ar, const int x, const int y, const bool labeledit); static uiBut *ui_but_find_mouse_over(ARegion *ar, const wmEvent *event); static void button_activate_init(bContext *C, ARegion *ar, uiBut *but, uiButtonActivateType type); @@ -390,7 +390,7 @@ void ui_pan_to_scroll(const wmEvent *event, int *type, int *val) bool ui_but_is_editable(const uiBut *but) { - return !ELEM(but->type, LABEL, SEPR, SEPRLINE, ROUNDBOX, LISTBOX, PROGRESSBAR); + return !ELEM(but->type, UI_BTYPE_LABEL, UI_BTYPE_SEPR, UI_BTYPE_SEPR_LINE, UI_BTYPE_ROUNDBOX, UI_BTYPE_LISTBOX, UI_BTYPE_PROGRESS_BAR); } static uiBut *ui_but_prev(uiBut *but) @@ -435,10 +435,10 @@ static uiBut *ui_but_last(uiBlock *block) return NULL; } -static bool ui_is_a_warp_but(uiBut *but) +static bool ui_but_is_cursor_warp(uiBut *but) { if (U.uiflag & USER_CONTINUOUS_MOUSE) { - if (ELEM(but->type, NUM, NUMSLI, HSVCIRCLE, TRACKPREVIEW, HSVCUBE, BUT_CURVE)) { + if (ELEM(but->type, UI_BTYPE_NUM, UI_BTYPE_NUM_SLIDER, UI_BTYPE_HSVCIRCLE, UI_BTYPE_TRACK_PREVIEW, UI_BTYPE_HSVCUBE, UI_BTYPE_CURVE)) { return true; } } @@ -464,7 +464,7 @@ static void ui_mouse_scale_warp(uiHandleButtonData *data, } /* file selectors are exempt from utf-8 checks */ -bool ui_is_but_utf8(const uiBut *but) +bool ui_but_is_utf8(const uiBut *but) { if (but->rnaprop) { const int subtype = RNA_property_subtype(but->rnaprop); @@ -523,7 +523,7 @@ static void ui_apply_but_func(bContext *C, uiBut *but) * with these functions removing the buttons we are working with */ if (but->func || but->funcN || block->handle_func || but->rename_func || - (but->type == BUTM && block->butm_func) || but->optype || but->rnaprop) + (but->type == UI_BTYPE_BUT_MENU && block->butm_func) || but->optype || but->rnaprop) { after = ui_afterfunc_new(); @@ -548,7 +548,7 @@ static void ui_apply_but_func(bContext *C, uiBut *but) after->handle_func_arg = block->handle_func_arg; after->retval = but->retval; - if (but->type == BUTM) { + if (but->type == UI_BTYPE_BUT_MENU) { after->butm_func = block->butm_func; after->butm_func_arg = block->butm_func_arg; after->a2 = but->a2; @@ -570,8 +570,8 @@ static void ui_apply_but_func(bContext *C, uiBut *but) } } -/* typically call ui_apply_undo(), ui_apply_autokey() */ -static void ui_apply_undo(uiBut *but) +/* typically call ui_apply_but_undo(), ui_apply_but_autokey() */ +static void ui_apply_but_undo(uiBut *but) { uiAfterFunc *after; @@ -579,8 +579,8 @@ static void ui_apply_undo(uiBut *but) const char *str = NULL; /* define which string to use for undo */ - if (ELEM(but->type, LINK, INLINK)) str = "Add button link"; - else if (but->type == MENU) str = but->drawstr; + if (ELEM(but->type, UI_BTYPE_LINK, UI_BTYPE_INLINK)) str = "Add button link"; + else if (but->type == UI_BTYPE_MENU) str = but->drawstr; else if (but->drawstr[0]) str = but->drawstr; else str = but->tip; @@ -595,7 +595,7 @@ static void ui_apply_undo(uiBut *but) } } -static void ui_apply_autokey(bContext *C, uiBut *but) +static void ui_apply_but_autokey(bContext *C, uiBut *but) { Scene *scene = CTX_data_scene(C); @@ -689,7 +689,7 @@ static void ui_apply_but_BUT(bContext *C, uiBut *but, uiHandleButtonData *data) static void ui_apply_but_BUTM(bContext *C, uiBut *but, uiHandleButtonData *data) { - ui_set_but_val(but, but->hardmin); + ui_but_value_set(but, but->hardmin); ui_apply_but_func(C, but); data->retval = but->retval; @@ -698,10 +698,10 @@ static void ui_apply_but_BUTM(bContext *C, uiBut *but, uiHandleButtonData *data) static void ui_apply_but_BLOCK(bContext *C, uiBut *but, uiHandleButtonData *data) { - if (but->type == MENU) - ui_set_but_val(but, data->value); + if (but->type == UI_BTYPE_MENU) + ui_but_value_set(but, data->value); - ui_check_but(but); + ui_but_update(but); ui_apply_but_func(C, but); data->retval = but->retval; data->applied = true; @@ -712,7 +712,7 @@ static void ui_apply_but_TOG(bContext *C, uiBut *but, uiHandleButtonData *data) double value; int w, lvalue, push; - value = ui_get_but_val(but); + value = ui_but_value_get(but); lvalue = (int)value; if (but->bit) { @@ -720,17 +720,17 @@ static void ui_apply_but_TOG(bContext *C, uiBut *but, uiHandleButtonData *data) if (w) lvalue = UI_BITBUT_CLR(lvalue, but->bitnr); else lvalue = UI_BITBUT_SET(lvalue, but->bitnr); - ui_set_but_val(but, (double)lvalue); - if (but->type == ICONTOG || but->type == ICONTOGN) ui_check_but(but); + ui_but_value_set(but, (double)lvalue); + if (but->type == UI_BTYPE_ICON_TOGGLE || but->type == UI_BTYPE_ICON_TOGGLE_N) ui_but_update(but); } else { if (value == 0.0) push = 1; else push = 0; - if (ELEM(but->type, TOGN, ICONTOGN, OPTIONN)) push = !push; - ui_set_but_val(but, (double)push); - if (but->type == ICONTOG || but->type == ICONTOGN) ui_check_but(but); + 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(but); } ui_apply_but_func(C, but); @@ -743,14 +743,14 @@ static void ui_apply_but_ROW(bContext *C, uiBlock *block, uiBut *but, uiHandleBu { uiBut *bt; - ui_set_but_val(but, but->hardmax); + ui_but_value_set(but, but->hardmax); ui_apply_but_func(C, but); /* states of other row buttons */ for (bt = block->buttons.first; bt; bt = bt->next) - if (bt != but && bt->poin == but->poin && ELEM(bt->type, ROW, LISTROW)) - ui_check_but(bt); + if (bt != but && bt->poin == but->poin && ELEM(bt->type, UI_BTYPE_ROW, UI_BTYPE_LISTROW)) + ui_but_update(bt); data->retval = but->retval; data->applied = true; @@ -761,8 +761,8 @@ static void ui_apply_but_TEX(bContext *C, uiBut *but, uiHandleButtonData *data) if (!data->str) return; - ui_set_but_string(C, but, data->str); - ui_check_but(but); + ui_but_string_set(C, but, data->str); + ui_but_update(but); /* give butfunc the original text too */ /* feature used for bone renaming, channels, etc */ @@ -778,8 +778,8 @@ static void ui_apply_but_TEX(bContext *C, uiBut *but, uiHandleButtonData *data) static void ui_apply_but_NUM(bContext *C, uiBut *but, uiHandleButtonData *data) { if (data->str) { - if (ui_set_but_string(C, but, data->str)) { - data->value = ui_get_but_val(but); + if (ui_but_string_set(C, but, data->str)) { + data->value = ui_but_value_get(but); } else { data->cancel = true; @@ -787,9 +787,9 @@ static void ui_apply_but_NUM(bContext *C, uiBut *but, uiHandleButtonData *data) } } else - ui_set_but_val(but, data->value); + ui_but_value_set(but, data->value); - ui_check_but(but); + ui_but_update(but); ui_apply_but_func(C, but); data->retval = but->retval; @@ -798,8 +798,8 @@ static void ui_apply_but_NUM(bContext *C, uiBut *but, uiHandleButtonData *data) static void ui_apply_but_VEC(bContext *C, uiBut *but, uiHandleButtonData *data) { - ui_set_but_vectorf(but, data->vec); - ui_check_but(but); + ui_but_v3_set(but, data->vec); + ui_but_update(but); ui_apply_but_func(C, but); data->retval = but->retval; @@ -836,7 +836,7 @@ static void ui_multibut_add(uiHandleButtonData *data, uiBut *but) mbut_state = MEM_callocN(sizeof(*mbut_state), __func__); mbut_state->but = but; - mbut_state->origvalue = ui_get_but_val(but); + mbut_state->origvalue = ui_but_value_get(but); BLI_linklist_prepend(&data->multi_data.mbuts, mbut_state); @@ -868,7 +868,7 @@ static void ui_multibut_restore(uiHandleButtonData *data, uiBlock *block) if (but->flag & UI_BUT_DRAG_MULTI) { uiButMultiState *mbut_state = ui_multibut_lookup(data, but); if (mbut_state) { - ui_set_but_val(but, mbut_state->origvalue); + ui_but_value_set(but, mbut_state->origvalue); } } } @@ -915,11 +915,11 @@ static bool ui_multibut_states_tag(uiBut *but_active, uiHandleButtonData *data, drag_prev = true; } - if (ui_is_but_interactive(but, false)) { + if (ui_but_is_interactive(but, false)) { /* drag checks */ if (but_active != but) { - if (ui_is_but_compatible(but_active, but)) { + if (ui_but_is_compatible(but_active, but)) { BLI_assert(but->active == NULL); @@ -981,13 +981,13 @@ static void ui_multibut_states_apply(bContext *C, uiHandleButtonData *data, uiBl if (mbut_state) { void *active_back; - ui_button_execute_begin(C, ar, but, &active_back); + ui_but_execute_begin(C, ar, but, &active_back); BLI_assert(active_back == NULL); /* no need to check 'data->state' here */ if (data->str) { /* entering text (set all) */ but->active->value = data->value; - ui_set_but_string(C, but, data->str); + ui_but_string_set(C, but, data->str); } else { /* dragging (use delta) */ @@ -1001,7 +1001,7 @@ static void ui_multibut_states_apply(bContext *C, uiHandleButtonData *data, uiBl /* clamp based on soft limits, see: T40154 */ CLAMP(but->active->value, (double)but->softmin, (double)but->softmax); } - ui_button_execute_end(C, ar, but, active_back); + ui_but_execute_end(C, ar, but, active_back); } else { /* highly unlikely */ @@ -1050,18 +1050,18 @@ static bool ui_drag_toggle_set_xy_xy(bContext *C, ARegion *ar, const bool is_set for (but = block->buttons.first; but; but = but->next) { /* Note: ctrl is always true here because (at least for now) we always want to consider text control * in this case, even when not embossed. */ - if (ui_is_but_interactive(but, true)) { + if (ui_but_is_interactive(but, true)) { if (BLI_rctf_isect_segment(&but->rect, xy_a_block, xy_b_block)) { /* execute the button */ - if (ui_is_but_bool(but) && but->type == but_type_start) { + if (ui_but_is_bool(but) && but->type == but_type_start) { /* is it pressed? */ - bool is_set_but = ui_is_but_push(but); - BLI_assert(ui_is_but_bool(but) == true); + bool is_set_but = ui_but_is_pushed(but); + BLI_assert(ui_but_is_bool(but) == true); if (is_set_but != is_set) { - uiButExecute(C, but); + UI_but_execute(C, but); if (do_check) { - ui_check_but(but); + ui_but_update(but); } changed = true; } @@ -1164,7 +1164,7 @@ static int ui_handler_region_drag_toggle(bContext *C, const wmEvent *event, void uiBut *but = ui_but_find_mouse_over_ex(ar, drag_info->xy_init[0], drag_info->xy_init[1], true); if (but) { - ui_apply_undo(but); + ui_apply_but_undo(but); } WM_event_remove_ui_handler(&win->modalhandlers, @@ -1181,9 +1181,9 @@ static int ui_handler_region_drag_toggle(bContext *C, const wmEvent *event, void } } -static bool ui_is_but_drag_toggle(const uiBut *but) +static bool ui_but_is_drag_toggle(const uiBut *but) { - return ((ui_is_but_bool(but) == true) && + return ((ui_but_is_bool(but) == true) && /* menu check is importnt so the button dragged over isn't removed instantly */ (ui_block_is_menu(but->block) == false)); } @@ -1191,7 +1191,7 @@ static bool ui_is_but_drag_toggle(const uiBut *but) #endif /* USE_DRAG_TOGGLE */ -static bool ui_but_mouse_inside_icon(uiBut *but, ARegion *ar, const wmEvent *event) +static bool ui_but_contains_point_px_icon(uiBut *but, ARegion *ar, const wmEvent *event) { rcti rect; int x = event->x, y = event->y; @@ -1200,7 +1200,7 @@ static bool ui_but_mouse_inside_icon(uiBut *but, ARegion *ar, const wmEvent *eve BLI_rcti_rctf_copy(&rect, &but->rect); - if (but->imb || but->type == COLOR) { + if (but->imb || but->type == UI_BTYPE_COLOR) { /* use button size itself */ } else if (but->drawflag & UI_BUT_ICON_LEFT) { @@ -1215,7 +1215,7 @@ static bool ui_but_mouse_inside_icon(uiBut *but, ARegion *ar, const wmEvent *eve return BLI_rcti_isect_pt(&rect, x, y); } -static bool ui_but_start_drag(bContext *C, uiBut *but, uiHandleButtonData *data, const wmEvent *event) +static bool ui_but_drag_init(bContext *C, uiBut *but, uiHandleButtonData *data, const wmEvent *event) { /* prevent other WM gestures to start while we try to drag */ WM_gestures_remove(C); @@ -1225,15 +1225,15 @@ static bool ui_but_start_drag(bContext *C, uiBut *but, uiHandleButtonData *data, button_activate_state(C, but, BUTTON_STATE_EXIT); data->cancel = true; #ifdef USE_DRAG_TOGGLE - if (ui_is_but_bool(but)) { + if (ui_but_is_bool(but)) { uiDragToggleHandle *drag_info = MEM_callocN(sizeof(*drag_info), __func__); ARegion *ar_prev; /* call here because regular mouse-up event wont run, * typically 'button_activate_exit()' handles this */ - ui_apply_autokey(C, but); + ui_apply_but_autokey(C, but); - drag_info->is_set = ui_is_but_push(but); + drag_info->is_set = ui_but_is_pushed(but); drag_info->but_cent_start[0] = BLI_rctf_cent_x(&but->rect); drag_info->but_cent_start[1] = BLI_rctf_cent_y(&but->rect); drag_info->but_type_start = but->type; @@ -1253,7 +1253,7 @@ static bool ui_but_start_drag(bContext *C, uiBut *but, uiHandleButtonData *data, } else #endif - if (but->type == COLOR) { + if (but->type == UI_BTYPE_COLOR) { bool valid = false; uiDragColorHandle *drag_info = MEM_callocN(sizeof(*drag_info), __func__); @@ -1288,7 +1288,7 @@ static bool ui_but_start_drag(bContext *C, uiBut *but, uiHandleButtonData *data, else { wmDrag *drag; - drag = WM_event_start_drag(C, but->icon, but->dragtype, but->dragpoin, ui_get_but_val(but), WM_DRAG_NOP); + drag = WM_event_start_drag(C, but->icon, but->dragtype, but->dragpoin, ui_but_value_get(but), WM_DRAG_NOP); if (but->imb) WM_event_drag_image(drag, but->imb, but->imb_scale, BLI_rctf_size_x(&but->rect), BLI_rctf_size_y(&but->rect)); } @@ -1300,7 +1300,7 @@ static bool ui_but_start_drag(bContext *C, uiBut *but, uiHandleButtonData *data, /* ********************** linklines *********************** */ -static void ui_delete_active_linkline(uiBlock *block) +static void ui_linkline_remove_active(uiBlock *block) { uiBut *but; uiLink *link; @@ -1308,7 +1308,7 @@ static void ui_delete_active_linkline(uiBlock *block) int a, b; for (but = block->buttons.first; but; but = but->next) { - if (but->type == LINK && but->link) { + if (but->type == UI_BTYPE_LINK && but->link) { for (line = but->link->lines.first; line; line = nline) { nline = line->next; @@ -1349,7 +1349,7 @@ static void ui_delete_active_linkline(uiBlock *block) } -static uiLinkLine *ui_is_a_link(uiBut *from, uiBut *to) +static uiLinkLine *ui_but_find_link(uiBut *from, uiBut *to) { uiLinkLine *line; uiLink *link; @@ -1367,7 +1367,7 @@ static uiLinkLine *ui_is_a_link(uiBut *from, uiBut *to) /* XXX BAD BAD HACK, fixme later **************** */ /* Try to add an AND Controller between the sensor and the actuator logic bricks and to connect them all */ -static void ui_add_smart_controller(bContext *C, uiBut *from, uiBut *to) +static void ui_but_smart_controller_add(bContext *C, uiBut *from, uiBut *to) { Object *ob = NULL; bSensor *sens_iter; @@ -1422,15 +1422,15 @@ static void ui_add_smart_controller(bContext *C, uiBut *from, uiBut *to) /* (4) link the sensor->controller->actuator */ tmp_but = MEM_callocN(sizeof(uiBut), "uiBut"); - uiSetButLink(tmp_but, (void **)&cont, (void ***)&(cont->links), &(cont->totlinks), from->link->tocode, (int)to->hardmin); + UI_but_link_set(tmp_but, (void **)&cont, (void ***)&(cont->links), &(cont->totlinks), from->link->tocode, (int)to->hardmin); tmp_but->hardmin = from->link->tocode; tmp_but->poin = (char *)cont; - tmp_but->type = INLINK; - ui_add_link(C, from, tmp_but); + tmp_but->type = UI_BTYPE_INLINK; + ui_but_link_add(C, from, tmp_but); - tmp_but->type = LINK; - ui_add_link(C, tmp_but, to); + tmp_but->type = UI_BTYPE_LINK; + ui_but_link_add(C, tmp_but, to); /* (5) garbage collection */ MEM_freeN(tmp_but->link); @@ -1439,7 +1439,7 @@ static void ui_add_smart_controller(bContext *C, uiBut *from, uiBut *to) WM_operator_properties_free(&props_ptr); } -static void ui_add_link(bContext *C, uiBut *from, uiBut *to) +static void ui_but_link_add(bContext *C, uiBut *from, uiBut *to) { /* in 'from' we have to add a link to 'to' */ uiLink *link; @@ -1447,22 +1447,22 @@ static void ui_add_link(bContext *C, uiBut *from, uiBut *to) void **oldppoin; int a; - if ((line = ui_is_a_link(from, to))) { + if ((line = ui_but_find_link(from, to))) { line->flag |= UI_SELECT; - ui_delete_active_linkline(from->block); + ui_linkline_remove_active(from->block); return; } - if (from->type == INLINK && to->type == INLINK) { + if (from->type == UI_BTYPE_INLINK && to->type == UI_BTYPE_INLINK) { return; } - else if (from->type == LINK && to->type == INLINK) { + else if (from->type == UI_BTYPE_LINK && to->type == UI_BTYPE_INLINK) { if (from->link->tocode != (int)to->hardmin) { - ui_add_smart_controller(C, from, to); + ui_but_smart_controller_add(C, from, to); return; } } - else if (from->type == INLINK && to->type == LINK) { + else if (from->type == UI_BTYPE_INLINK && to->type == UI_BTYPE_LINK) { if (to->link->tocode == (int)from->hardmin) { return; } @@ -1497,15 +1497,15 @@ static void ui_apply_but_LINK(bContext *C, uiBut *but, uiHandleButtonData *data) uiBut *bt; for (bt = but->block->buttons.first; bt; bt = bt->next) { - if (ui_mouse_inside_button(ar, bt, but->linkto[0] + ar->winrct.xmin, but->linkto[1] + ar->winrct.ymin) ) + if (ui_but_contains_point_px(ar, bt, but->linkto[0] + ar->winrct.xmin, but->linkto[1] + ar->winrct.ymin) ) break; } if (bt && bt != but) { - if (!ELEM(bt->type, LINK, INLINK) || !ELEM(but->type, LINK, INLINK)) + if (!ELEM(bt->type, UI_BTYPE_LINK, UI_BTYPE_INLINK) || !ELEM(but->type, UI_BTYPE_LINK, UI_BTYPE_INLINK)) return; - if (but->type == LINK) ui_add_link(C, but, bt); - else ui_add_link(C, bt, but); + if (but->type == UI_BTYPE_LINK) ui_but_link_add(C, but, bt); + else ui_but_link_add(C, bt, but); ui_apply_but_func(C, but); data->retval = but->retval; @@ -1542,7 +1542,7 @@ static void ui_apply_but_TRACKPREVIEW(bContext *C, uiBut *but, uiHandleButtonDat } -static void ui_apply_button(bContext *C, uiBlock *block, uiBut *but, uiHandleButtonData *data, const bool interactive) +static void ui_apply_but(bContext *C, uiBlock *block, uiBut *but, uiHandleButtonData *data, const bool interactive) { char *editstr; double *editval; @@ -1591,76 +1591,76 @@ static void ui_apply_button(bContext *C, uiBlock *block, uiBut *but, uiHandleBut /* handle different types */ switch (but->type) { - case BUT: + case UI_BTYPE_BUT: ui_apply_but_BUT(C, but, data); break; - case TEX: - case SEARCH_MENU_UNLINK: - case SEARCH_MENU: + case UI_BTYPE_TEXT: + case UI_BTYPE_SEARCH_MENU_UNLINK: + case UI_BTYPE_SEARCH_MENU: ui_apply_but_TEX(C, but, data); break; - case TOGBUT: - case TOG: - case ICONTOG: - case ICONTOGN: - case TOGN: - case OPTION: - case OPTIONN: + case UI_BTYPE_BUT_TOGGLE: + case UI_BTYPE_TOGGLE: + case UI_BTYPE_TOGGLE_N: + case UI_BTYPE_ICON_TOGGLE: + case UI_BTYPE_ICON_TOGGLE_N: + case UI_BTYPE_CHECKBOX: + case UI_BTYPE_CHECKBOX_N: ui_apply_but_TOG(C, but, data); break; - case ROW: - case LISTROW: + case UI_BTYPE_ROW: + case UI_BTYPE_LISTROW: ui_apply_but_ROW(C, block, but, data); break; - case SCROLL: - case GRIP: - case NUM: - case NUMSLI: + case UI_BTYPE_SCROLL: + case UI_BTYPE_GRIP: + case UI_BTYPE_NUM: + case UI_BTYPE_NUM_SLIDER: ui_apply_but_NUM(C, but, data); break; - case MENU: - case BLOCK: - case PULLDOWN: + case UI_BTYPE_MENU: + case UI_BTYPE_BLOCK: + case UI_BTYPE_PULLDOWN: ui_apply_but_BLOCK(C, but, data); break; - case COLOR: + case UI_BTYPE_COLOR: if (data->cancel) ui_apply_but_VEC(C, but, data); else ui_apply_but_BLOCK(C, but, data); break; - case BUTM: + case UI_BTYPE_BUT_MENU: ui_apply_but_BUTM(C, but, data); break; - case BUT_NORMAL: - case HSVCUBE: - case HSVCIRCLE: + case UI_BTYPE_UNITVEC: + case UI_BTYPE_HSVCUBE: + case UI_BTYPE_HSVCIRCLE: ui_apply_but_VEC(C, but, data); break; - case BUT_COLORBAND: + case UI_BTYPE_COLORBAND: ui_apply_but_COLORBAND(C, but, data); break; - case BUT_CURVE: + case UI_BTYPE_CURVE: ui_apply_but_CURVE(C, but, data); break; - case KEYEVT: - case HOTKEYEVT: + case UI_BTYPE_KEY_EVENT: + case UI_BTYPE_HOTKEY_EVENT: ui_apply_but_BUT(C, but, data); break; - case LINK: - case INLINK: + case UI_BTYPE_LINK: + case UI_BTYPE_INLINK: ui_apply_but_LINK(C, but, data); break; - case BUT_IMAGE: + case UI_BTYPE_IMAGE: ui_apply_but_IMAGE(C, but, data); break; - case HISTOGRAM: + case UI_BTYPE_HISTOGRAM: ui_apply_but_HISTOGRAM(C, but, data); break; - case WAVEFORM: + case UI_BTYPE_WAVEFORM: ui_apply_but_WAVEFORM(C, but, data); break; - case TRACKPREVIEW: + case UI_BTYPE_TRACK_PREVIEW: ui_apply_but_TRACKPREVIEW(C, but, data); break; default: @@ -1698,13 +1698,13 @@ static void ui_but_drop(bContext *C, const wmEvent *event, uiBut *but, uiHandleB for (wmd = drags->first; wmd; wmd = wmd->next) { if (wmd->type == WM_DRAG_ID) { /* align these types with UI_but_active_drop_name */ - if (ELEM(but->type, TEX, SEARCH_MENU, SEARCH_MENU_UNLINK)) { + if (ELEM(but->type, UI_BTYPE_TEXT, UI_BTYPE_SEARCH_MENU, UI_BTYPE_SEARCH_MENU_UNLINK)) { ID *id = (ID *)wmd->poin; button_activate_state(C, but, BUTTON_STATE_TEXT_EDITING); BLI_strncpy(data->str, id->name + 2, data->maxlen); - if (ELEM(but->type, SEARCH_MENU, SEARCH_MENU_UNLINK)) { + if (ELEM(but->type, UI_BTYPE_SEARCH_MENU, UI_BTYPE_SEARCH_MENU_UNLINK)) { but->changed = true; ui_searchbox_update(C, data->searchbox, but, true); } @@ -1751,7 +1751,7 @@ static void ui_but_copy_paste(bContext *C, uiBut *but, uiHandleButtonData *data, /* numeric value */ - if (ELEM(but->type, NUM, NUMSLI)) { + if (ELEM(but->type, UI_BTYPE_NUM, UI_BTYPE_NUM_SLIDER)) { if (but->poin == NULL && but->rnapoin.data == NULL) { /* pass */ @@ -1760,7 +1760,7 @@ static void ui_but_copy_paste(bContext *C, uiBut *but, uiHandleButtonData *data, /* Get many decimal places, then strip trailing zeros. * note: too high values start to give strange results (6 or so is ok) */ char buf_copy[UI_MAX_DRAW_STR]; - ui_get_but_string_ex(but, buf_copy, sizeof(buf_copy), 6); + ui_but_string_get_ex(but, buf_copy, sizeof(buf_copy), 6); BLI_str_rstrip_float_zero(buf_copy, '\0'); WM_clipboard_text_set(buf_copy, 0); @@ -1768,17 +1768,17 @@ static void ui_but_copy_paste(bContext *C, uiBut *but, uiHandleButtonData *data, else { double val; - if (ui_set_but_string_eval_num(C, but, buf_paste, &val)) { + if (ui_but_string_set_eval_num(C, but, buf_paste, &val)) { button_activate_state(C, but, BUTTON_STATE_NUM_EDITING); data->value = val; - ui_set_but_string(C, but, buf_paste); + ui_but_string_set(C, but, buf_paste); button_activate_state(C, but, BUTTON_STATE_EXIT); } } } /* NORMAL button */ - else if (but->type == BUT_NORMAL) { + else if (but->type == UI_BTYPE_UNITVEC) { float xyz[3]; if (but->poin == NULL && but->rnapoin.data == NULL) { @@ -1786,7 +1786,7 @@ static void ui_but_copy_paste(bContext *C, uiBut *but, uiHandleButtonData *data, } else if (mode == 'c') { char buf_copy[UI_MAX_DRAW_STR]; - ui_get_but_vectorf(but, xyz); + ui_but_v3_get(but, xyz); BLI_snprintf(buf_copy, sizeof(buf_copy), "[%f, %f, %f]", xyz[0], xyz[1], xyz[2]); WM_clipboard_text_set(buf_copy, 0); } @@ -1797,7 +1797,7 @@ static void ui_but_copy_paste(bContext *C, uiBut *but, uiHandleButtonData *data, xyz[2] = 1.0; } button_activate_state(C, but, BUTTON_STATE_NUM_EDITING); - ui_set_but_vectorf(but, xyz); + ui_but_v3_set(but, xyz); button_activate_state(C, but, BUTTON_STATE_EXIT); } } @@ -1805,7 +1805,7 @@ static void ui_but_copy_paste(bContext *C, uiBut *but, uiHandleButtonData *data, /* RGB triple */ - else if (but->type == COLOR) { + else if (but->type == UI_BTYPE_COLOR) { float rgba[4]; if (but->poin == NULL && but->rnapoin.data == NULL) { @@ -1819,7 +1819,7 @@ static void ui_but_copy_paste(bContext *C, uiBut *but, uiHandleButtonData *data, else rgba[3] = 1.0f; - ui_get_but_vectorf(but, rgba); + ui_but_v3_get(but, rgba); /* convert to linear color to do compatible copy between gamma and non-gamma */ if (but->rnaprop && RNA_property_subtype(but->rnaprop) == PROP_COLOR_GAMMA) srgb_to_linearrgb_v3_v3(rgba, rgba); @@ -1835,7 +1835,7 @@ static void ui_but_copy_paste(bContext *C, uiBut *but, uiHandleButtonData *data, linearrgb_to_srgb_v3_v3(rgba, rgba); button_activate_state(C, but, BUTTON_STATE_NUM_EDITING); - ui_set_but_vectorf(but, rgba); + ui_but_v3_set(but, rgba); if (but->rnaprop && RNA_property_array_length(&but->rnapoin, but->rnaprop) == 4) RNA_property_float_set_index(&but->rnapoin, but->rnaprop, 3, rgba[3]); @@ -1845,7 +1845,7 @@ static void ui_but_copy_paste(bContext *C, uiBut *but, uiHandleButtonData *data, } /* text/string and ID data */ - else if (ELEM(but->type, TEX, SEARCH_MENU, SEARCH_MENU_UNLINK)) { + else if (ELEM(but->type, UI_BTYPE_TEXT, UI_BTYPE_SEARCH_MENU, UI_BTYPE_SEARCH_MENU_UNLINK)) { uiHandleButtonData *active_data = but->active; if (but->poin == NULL && but->rnapoin.data == NULL) { @@ -1860,12 +1860,12 @@ static void ui_but_copy_paste(bContext *C, uiBut *but, uiHandleButtonData *data, else { button_activate_state(C, but, BUTTON_STATE_TEXT_EDITING); - if (ui_is_but_utf8(but)) + if (ui_but_is_utf8(but)) BLI_strncpy_utf8(active_data->str, buf_paste, active_data->maxlen); else BLI_strncpy(active_data->str, buf_paste, active_data->maxlen); - if (ELEM(but->type, SEARCH_MENU, SEARCH_MENU_UNLINK)) { + if (ELEM(but->type, UI_BTYPE_SEARCH_MENU, UI_BTYPE_SEARCH_MENU_UNLINK)) { /* else uiSearchboxData.active member is not updated [#26856] */ but->changed = true; ui_searchbox_update(C, data->searchbox, but, true); @@ -1874,7 +1874,7 @@ static void ui_but_copy_paste(bContext *C, uiBut *but, uiHandleButtonData *data, } } /* colorband (not supported by system clipboard) */ - else if (but->type == BUT_COLORBAND) { + else if (but->type == UI_BTYPE_COLORBAND) { if (mode == 'c') { if (but->poin != NULL) { memcpy(&but_copypaste_coba, but->poin, sizeof(ColorBand)); @@ -1891,7 +1891,7 @@ static void ui_but_copy_paste(bContext *C, uiBut *but, uiHandleButtonData *data, } } } - else if (but->type == BUT_CURVE) { + else if (but->type == UI_BTYPE_CURVE) { if (mode == 'c') { if (but->poin != NULL) { but_copypaste_curve_alive = true; @@ -1916,7 +1916,7 @@ static void ui_but_copy_paste(bContext *C, uiBut *but, uiHandleButtonData *data, if (mode == 'c') { PointerRNA *opptr; char *str; - opptr = uiButGetOperatorPtrRNA(but); /* allocated when needed, the button owns it */ + opptr = UI_but_operator_ptr_get(but); /* allocated when needed, the button owns it */ str = WM_operator_pystring_ex(C, NULL, false, true, but->optype, opptr); @@ -1926,8 +1926,8 @@ static void ui_but_copy_paste(bContext *C, uiBut *but, uiHandleButtonData *data, } } /* menu (any type) */ - else if (ELEM(but->type, MENU, PULLDOWN)) { - MenuType *mt = uiButGetMenuType(but); + else if (ELEM(but->type, UI_BTYPE_MENU, UI_BTYPE_PULLDOWN)) { + MenuType *mt = UI_but_menutype_get(but); if (mt) { char str[32 + sizeof(mt->idname)]; BLI_snprintf(str, sizeof(str), "bpy.ops.wm.call_menu(name=\"%s\")", mt->idname); @@ -1971,7 +1971,7 @@ static int ui_text_position_to_hidden(uiBut *but, int pos) return BLI_strnlen_utf8(butstr, pos); } -void ui_button_text_password_hide(char password_str[UI_MAX_PASSWORD_STR], uiBut *but, const bool restore) +void ui_but_text_password_hide(char password_str[UI_MAX_PASSWORD_STR], uiBut *but, const bool restore) { char *butstr; @@ -2034,7 +2034,7 @@ static bool ui_textedit_delete_selection(uiBut *but, uiHandleButtonData *data) */ static void ui_textedit_set_cursor_pos(uiBut *but, uiHandleButtonData *data, const float x) { - uiStyle *style = UI_GetStyle(); // XXX pass on as arg + uiStyle *style = UI_style_get(); // XXX pass on as arg uiFontStyle *fstyle = &style->widget; const float aspect = but->block->aspect; const short fstyle_points_prev = fstyle->points; @@ -2047,18 +2047,18 @@ static void ui_textedit_set_cursor_pos(uiBut *but, uiHandleButtonData *data, con ui_fontscale(&fstyle->points, aspect); - uiStyleFontSet(fstyle); + UI_fontstyle_set(fstyle); if (fstyle->kerning == 1) /* for BLF_width */ BLF_enable(fstyle->uifont_id, BLF_KERNING_DEFAULT); - ui_button_text_password_hide(password_str, but, false); + ui_but_text_password_hide(password_str, but, false); origstr = MEM_mallocN(sizeof(char) * data->maxlen, "ui_textedit origstr"); BLI_strncpy(origstr, but->editstr, data->maxlen); - if (ELEM(but->type, TEX, SEARCH_MENU, SEARCH_MENU_UNLINK)) { + if (ELEM(but->type, UI_BTYPE_TEXT, UI_BTYPE_SEARCH_MENU, UI_BTYPE_SEARCH_MENU_UNLINK)) { if (but->flag & UI_HAS_ICON) { startx += UI_DPI_ICON_SIZE / aspect; } @@ -2128,7 +2128,7 @@ static void ui_textedit_set_cursor_pos(uiBut *but, uiHandleButtonData *data, con if (fstyle->kerning == 1) BLF_disable(fstyle->uifont_id, BLF_KERNING_DEFAULT); - ui_button_text_password_hide(password_str, but, true); + ui_but_text_password_hide(password_str, but, true); MEM_freeN(origstr); @@ -2145,7 +2145,7 @@ static void ui_textedit_set_cursor_select(uiBut *but, uiHandleButtonData *data, if (data->selextend == EXTEND_RIGHT) but->selend = but->pos; else if (data->selextend == EXTEND_LEFT) but->selsta = but->pos; - ui_check_but(but); + ui_but_update(but); } /* this is used for both utf8 and ascii, its meant to be used for single keys, @@ -2185,7 +2185,7 @@ static bool ui_textedit_type_ascii(uiBut *but, uiHandleButtonData *data, char as { char buf[2] = {ascii, '\0'}; - if (ui_is_but_utf8(but) && (BLI_str_utf8_size(buf) == -1)) { + if (ui_but_is_utf8(but) && (BLI_str_utf8_size(buf) == -1)) { printf("%s: entering invalid ascii char into an ascii key (%d)\n", __func__, (int)(unsigned char)ascii); @@ -2204,7 +2204,7 @@ static void ui_textedit_move(uiBut *but, uiHandleButtonData *data, strCursorJump const int pos_prev = but->pos; const bool has_sel = (but->selend - but->selsta) > 0; - ui_check_but(but); + ui_but_update(but); /* special case, quit selection and set cursor */ if (has_sel && !select) { @@ -2356,7 +2356,7 @@ static bool ui_textedit_copypaste(uiBut *but, uiHandleButtonData *data, const in /* paste */ if (mode == UI_TEXTEDIT_PASTE) { - /* TODO, ensure UTF8 ui_is_but_utf8() - campbell */ + /* TODO, ensure UTF8 ui_but_is_utf8() - campbell */ /* extract the first line from the clipboard */ pbuf = WM_clipboard_text_get_firstline(false, &buf_len); @@ -2426,7 +2426,7 @@ static void ui_textedit_begin(bContext *C, uiBut *but, uiHandleButtonData *data) if (data->applied_interactive) { /* remove any small changes so canceling edit doesn't restore invalid value: T40538 */ data->cancel = true; - ui_apply_button(C, but->block, but, data, true); + ui_apply_but(C, but->block, but, data, true); data->cancel = false; data->applied_interactive = false; @@ -2434,16 +2434,16 @@ static void ui_textedit_begin(bContext *C, uiBut *but, uiHandleButtonData *data) #endif /* retrieve string */ - data->maxlen = ui_get_but_string_max_length(but); + data->maxlen = ui_but_string_get_max_length(but); data->str = MEM_callocN(sizeof(char) * data->maxlen + 1, "textedit str"); - ui_get_but_string(but, data->str, data->maxlen); + ui_but_string_get(but, data->str, data->maxlen); - if (ui_is_but_float(but) && !ui_is_but_unit(but)) { + if (ui_but_is_float(but) && !ui_but_is_unit(but)) { BLI_str_rstrip_float_zero(data->str, '\0'); } - if (ELEM(but->type, NUM, NUMSLI)) { - ui_convert_to_unit_alt_name(but, data->str, data->maxlen); + if (ELEM(but->type, UI_BTYPE_NUM, UI_BTYPE_NUM_SLIDER)) { + ui_but_convert_to_unit_alt_name(but, data->str, data->maxlen); } /* won't change from now on */ @@ -2460,7 +2460,7 @@ static void ui_textedit_begin(bContext *C, uiBut *but, uiHandleButtonData *data) but->selend = len; /* optional searchbox */ - if (ELEM(but->type, SEARCH_MENU, SEARCH_MENU_UNLINK)) { + if (ELEM(but->type, UI_BTYPE_SEARCH_MENU, UI_BTYPE_SEARCH_MENU_UNLINK)) { data->searchbox = ui_searchbox_create(C, data->region, but); ui_searchbox_update(C, data->searchbox, but, true); /* true = reset */ } @@ -2468,7 +2468,7 @@ static void ui_textedit_begin(bContext *C, uiBut *but, uiHandleButtonData *data) /* reset alert flag (avoid confusion, will refresh on exit) */ but->flag &= ~UI_BUT_REDALERT; - ui_check_but(but); + ui_but_update(but); WM_cursor_modal_set(CTX_wm_window(C), BC_TEXTEDITCURSOR); } @@ -2476,7 +2476,7 @@ static void ui_textedit_begin(bContext *C, uiBut *but, uiHandleButtonData *data) static void ui_textedit_end(bContext *C, uiBut *but, uiHandleButtonData *data) { if (but) { - if (ui_is_but_utf8(but)) { + if (ui_but_is_utf8(but)) { int strip = BLI_utf8_invalid_strip(but->editstr, strlen(but->editstr)); /* not a file?, strip non utf-8 chars */ if (strip) { @@ -2513,11 +2513,11 @@ static void ui_textedit_next_but(uiBlock *block, uiBut *actbut, uiHandleButtonDa uiBut *but; /* label and roundbox can overlap real buttons (backdrops...) */ - if (ELEM(actbut->type, LABEL, SEPR, SEPRLINE, ROUNDBOX, LISTBOX)) + if (ELEM(actbut->type, UI_BTYPE_LABEL, UI_BTYPE_SEPR, UI_BTYPE_SEPR_LINE, UI_BTYPE_ROUNDBOX, UI_BTYPE_LISTBOX)) return; for (but = actbut->next; but; but = but->next) { - if (ELEM(but->type, TEX, NUM, NUMSLI, SEARCH_MENU, SEARCH_MENU_UNLINK)) { + if (ELEM(but->type, UI_BTYPE_TEXT, UI_BTYPE_NUM, UI_BTYPE_NUM_SLIDER, UI_BTYPE_SEARCH_MENU, UI_BTYPE_SEARCH_MENU_UNLINK)) { if (!(but->flag & UI_BUT_DISABLED)) { data->postbut = but; data->posttype = BUTTON_ACTIVATE_TEXT_EDITING; @@ -2526,7 +2526,7 @@ static void ui_textedit_next_but(uiBlock *block, uiBut *actbut, uiHandleButtonDa } } for (but = block->buttons.first; but != actbut; but = but->next) { - if (ELEM(but->type, TEX, NUM, NUMSLI, SEARCH_MENU, SEARCH_MENU_UNLINK)) { + if (ELEM(but->type, UI_BTYPE_TEXT, UI_BTYPE_NUM, UI_BTYPE_NUM_SLIDER, UI_BTYPE_SEARCH_MENU, UI_BTYPE_SEARCH_MENU_UNLINK)) { if (!(but->flag & UI_BUT_DISABLED)) { data->postbut = but; data->posttype = BUTTON_ACTIVATE_TEXT_EDITING; @@ -2541,11 +2541,11 @@ static void ui_textedit_prev_but(uiBlock *block, uiBut *actbut, uiHandleButtonDa uiBut *but; /* label and roundbox can overlap real buttons (backdrops...) */ - if (ELEM(actbut->type, LABEL, SEPR, SEPRLINE, ROUNDBOX, LISTBOX)) + if (ELEM(actbut->type, UI_BTYPE_LABEL, UI_BTYPE_SEPR, UI_BTYPE_SEPR_LINE, UI_BTYPE_ROUNDBOX, UI_BTYPE_LISTBOX)) return; for (but = actbut->prev; but; but = but->prev) { - if (ELEM(but->type, TEX, NUM, NUMSLI, SEARCH_MENU, SEARCH_MENU_UNLINK)) { + if (ELEM(but->type, UI_BTYPE_TEXT, UI_BTYPE_NUM, UI_BTYPE_NUM_SLIDER, UI_BTYPE_SEARCH_MENU, UI_BTYPE_SEARCH_MENU_UNLINK)) { if (!(but->flag & UI_BUT_DISABLED)) { data->postbut = but; data->posttype = BUTTON_ACTIVATE_TEXT_EDITING; @@ -2554,7 +2554,7 @@ static void ui_textedit_prev_but(uiBlock *block, uiBut *actbut, uiHandleButtonDa } } for (but = block->buttons.last; but != actbut; but = but->prev) { - if (ELEM(but->type, TEX, NUM, NUMSLI, SEARCH_MENU, SEARCH_MENU_UNLINK)) { + if (ELEM(but->type, UI_BTYPE_TEXT, UI_BTYPE_NUM, UI_BTYPE_NUM_SLIDER, UI_BTYPE_SEARCH_MENU, UI_BTYPE_SEARCH_MENU_UNLINK)) { if (!(but->flag & UI_BUT_DISABLED)) { data->postbut = but; data->posttype = BUTTON_ACTIVATE_TEXT_EDITING; @@ -2769,7 +2769,7 @@ static void ui_do_but_textedit(bContext *C, uiBlock *block, uiBut *but, uiHandle /* exception that's useful for number buttons, some keyboard * numpads have a comma instead of a period */ - if (ELEM(but->type, NUM, NUMSLI)) { /* could use data->min*/ + if (ELEM(but->type, UI_BTYPE_NUM, UI_BTYPE_NUM_SLIDER)) { /* could use data->min*/ if (event->type == PADPERIOD && ascii == ',') { ascii = '.'; utf8_buf = NULL; /* force ascii fallback */ @@ -2801,10 +2801,10 @@ static void ui_do_but_textedit(bContext *C, uiBlock *block, uiBut *but, uiHandle if (changed) { /* only update when typing for TAB key */ if (update && data->interactive) { - ui_apply_button(C, block, but, data, true); + ui_apply_but(C, block, but, data, true); } else { - ui_check_but(but); + ui_but_update(but); } but->changed = true; @@ -2839,7 +2839,7 @@ static void ui_do_but_textedit_select(bContext *C, uiBlock *block, uiBut *but, u } if (retval == WM_UI_HANDLER_BREAK) { - ui_check_but(but); + ui_but_update(but); ED_region_tag_redraw(data->region); } } @@ -2848,22 +2848,22 @@ static void ui_do_but_textedit_select(bContext *C, uiBlock *block, uiBut *but, u static void ui_numedit_begin(uiBut *but, uiHandleButtonData *data) { - if (but->type == BUT_CURVE) { + if (but->type == UI_BTYPE_CURVE) { but->editcumap = (CurveMapping *)but->poin; } - else if (but->type == BUT_COLORBAND) { + else if (but->type == UI_BTYPE_COLORBAND) { data->coba = (ColorBand *)but->poin; but->editcoba = data->coba; } - else if (ELEM(but->type, BUT_NORMAL, HSVCUBE, HSVCIRCLE, COLOR)) { - ui_get_but_vectorf(but, data->origvec); + else if (ELEM(but->type, UI_BTYPE_UNITVEC, UI_BTYPE_HSVCUBE, UI_BTYPE_HSVCIRCLE, UI_BTYPE_COLOR)) { + ui_but_v3_get(but, data->origvec); copy_v3_v3(data->vec, data->origvec); but->editvec = data->vec; } else { float softrange, softmin, softmax; - data->startvalue = ui_get_but_val(but); + data->startvalue = ui_but_value_get(but); data->origvalue = data->startvalue; data->value = data->origvalue; but->editval = &data->value; @@ -2897,10 +2897,10 @@ static void ui_numedit_end(uiBut *but, uiHandleButtonData *data) static void ui_numedit_apply(bContext *C, uiBlock *block, uiBut *but, uiHandleButtonData *data) { if (data->interactive) { - ui_apply_button(C, block, but, data, true); + ui_apply_but(C, block, but, data, true); } else { - ui_check_but(but); + ui_but_update(but); } ED_region_tag_redraw(data->region); @@ -2908,7 +2908,7 @@ static void ui_numedit_apply(bContext *C, uiBlock *block, uiBut *but, uiHandleBu /* ****************** menu opening for various types **************** */ -static void ui_blockopen_begin(bContext *C, uiBut *but, uiHandleButtonData *data) +static void ui_block_open_begin(bContext *C, uiBut *but, uiHandleButtonData *data) { uiBlockCreateFunc func = NULL; uiBlockHandleCreateFunc handlefunc = NULL; @@ -2916,8 +2916,8 @@ static void ui_blockopen_begin(bContext *C, uiBut *but, uiHandleButtonData *data void *arg = NULL; switch (but->type) { - case BLOCK: - case PULLDOWN: + case UI_BTYPE_BLOCK: + case UI_BTYPE_PULLDOWN: if (but->menu_create_func) { menufunc = but->menu_create_func; arg = but->poin; @@ -2927,13 +2927,13 @@ static void ui_blockopen_begin(bContext *C, uiBut *but, uiHandleButtonData *data arg = but->poin ? but->poin : but->func_argN; } break; - case MENU: + case UI_BTYPE_MENU: BLI_assert(but->menu_create_func); menufunc = but->menu_create_func; arg = but->poin; break; - case COLOR: - ui_get_but_vectorf(but, data->origvec); + case UI_BTYPE_COLOR: + ui_but_v3_get(but, data->origvec); copy_v3_v3(data->vec, data->origvec); but->editvec = data->vec; @@ -2961,7 +2961,7 @@ static void ui_blockopen_begin(bContext *C, uiBut *but, uiHandleButtonData *data //if (but->block->auto_open == 0) but->block->auto_open = 1; } -static void ui_blockopen_end(bContext *C, uiBut *but, uiHandleButtonData *data) +static void ui_block_open_end(bContext *C, uiBut *but, uiHandleButtonData *data) { if (but) { but->editval = NULL; @@ -2976,7 +2976,7 @@ static void ui_blockopen_end(bContext *C, uiBut *but, uiHandleButtonData *data) } } -int ui_button_open_menu_direction(uiBut *but) +int ui_but_menu_direction(uiBut *but) { uiHandleButtonData *data = but->active; @@ -2986,14 +2986,14 @@ int ui_button_open_menu_direction(uiBut *but) return 0; } -/* Hack for uiList LISTROW buttons to "give" events to overlaying TEX buttons (cltr-clic rename feature & co). */ +/* Hack for uiList UI_BTYPE_LISTROW buttons to "give" events to overlaying UI_BTYPE_TEXT buttons (cltr-clic rename feature & co). */ static uiBut *ui_but_list_row_text_activate(bContext *C, uiBut *but, uiHandleButtonData *data, const wmEvent *event, uiButtonActivateType activate_type) { ARegion *ar = CTX_wm_region(C); uiBut *labelbut = ui_but_find_mouse_over_ex(ar, event->x, event->y, true); - if (labelbut && labelbut->type == TEX && !(labelbut->flag & UI_BUT_DISABLED)) { + if (labelbut && labelbut->type == UI_BTYPE_TEXT && !(labelbut->flag & UI_BUT_DISABLED)) { /* exit listrow */ data->cancel = true; button_activate_exit(C, but, data, false, false); @@ -3056,10 +3056,10 @@ static int ui_do_but_HOTKEYEVT(bContext *C, uiBut *but, uiHandleButtonData *data if (event->type == LEFTMOUSE && event->val == KM_PRESS) { /* only cancel if click outside the button */ - if (ui_mouse_inside_button(but->active->region, but, event->x, event->y) == 0) { + if (ui_but_contains_point_px(but->active->region, but, event->x, event->y) == 0) { /* data->cancel doesnt work, this button opens immediate */ if (but->flag & UI_BUT_IMMEDIATE) - ui_set_but_val(but, 0); + ui_but_value_set(but, 0); else data->cancel = true; button_activate_state(C, but, BUTTON_STATE_EXIT); @@ -3074,14 +3074,14 @@ static int ui_do_but_HOTKEYEVT(bContext *C, uiBut *but, uiHandleButtonData *data if (event->ctrl) but->modifier_key |= KM_CTRL; if (event->oskey) but->modifier_key |= KM_OSKEY; - ui_check_but(but); + ui_but_update(but); ED_region_tag_redraw(data->region); if (event->val == KM_PRESS) { if (ISHOTKEY(event->type)) { if (WM_key_event_string(event->type)[0]) - ui_set_but_val(but, event->type); + ui_but_value_set(but, event->type); else data->cancel = true; @@ -3117,7 +3117,7 @@ static int ui_do_but_KEYEVT(bContext *C, uiBut *but, uiHandleButtonData *data, c if (event->val == KM_PRESS) { if (WM_key_event_string(event->type)[0]) - ui_set_but_val(but, event->type); + ui_but_value_set(but, event->type); else data->cancel = true; @@ -3132,10 +3132,10 @@ static int ui_do_but_TEX(bContext *C, uiBlock *block, uiBut *but, uiHandleButton { if (data->state == BUTTON_STATE_HIGHLIGHT) { if (ELEM(event->type, LEFTMOUSE, EVT_BUT_OPEN, PADENTER, RETKEY) && event->val == KM_PRESS) { - if (ELEM(event->type, PADENTER, RETKEY) && (!ui_is_but_utf8(but))) { + if (ELEM(event->type, PADENTER, RETKEY) && (!ui_but_is_utf8(but))) { /* pass - allow filesel, enter to execute */ } - else if (but->dt == UI_EMBOSSN && !event->ctrl) { + else if (but->dt == UI_EMBOSS_NONE && !event->ctrl) { /* pass */ } else { @@ -3160,7 +3160,7 @@ static int ui_do_but_SEARCH_UNLINK(bContext *C, uiBlock *block, uiBut *but, uiHa { /* unlink icon is on right */ if (ELEM(event->type, LEFTMOUSE, EVT_BUT_OPEN, PADENTER, RETKEY) && event->val == KM_PRESS && - ui_is_but_search_unlink_visible(but)) + ui_but_is_search_unlink_visible(but)) { ARegion *ar = data->region; rcti rect; @@ -3190,12 +3190,12 @@ static int ui_do_but_TOG(bContext *C, uiBut *but, uiHandleButtonData *data, cons { #ifdef USE_DRAG_TOGGLE if (data->state == BUTTON_STATE_HIGHLIGHT) { - if (event->type == LEFTMOUSE && event->val == KM_PRESS && ui_is_but_drag_toggle(but)) { + if (event->type == LEFTMOUSE && event->val == KM_PRESS && ui_but_is_drag_toggle(but)) { #if 0 /* UNUSED */ data->togdual = event->ctrl; data->togonly = !event->shift; #endif - ui_apply_button(C, but->block, but, data, true); + ui_apply_but(C, but->block, but, data, true); button_activate_state(C, but, BUTTON_STATE_WAIT_DRAG); data->dragstartx = event->x; data->dragstarty = event->y; @@ -3228,7 +3228,7 @@ static int ui_do_but_EXIT(bContext *C, uiBut *but, uiHandleButtonData *data, con /* first handle click on icondrag type button */ if (event->type == LEFTMOUSE && but->dragpoin) { - if (ui_but_mouse_inside_icon(but, data->region, event)) { + if (ui_but_contains_point_px_icon(but, data->region, event)) { /* tell the button to wait and keep checking further events to * see if it should start dragging */ @@ -3239,7 +3239,7 @@ static int ui_do_but_EXIT(bContext *C, uiBut *but, uiHandleButtonData *data, con } } #ifdef USE_DRAG_TOGGLE - if (event->type == LEFTMOUSE && ui_is_but_drag_toggle(but)) { + if (event->type == LEFTMOUSE && ui_but_is_drag_toggle(but)) { button_activate_state(C, but, BUTTON_STATE_WAIT_DRAG); data->dragstartx = event->x; data->dragstarty = event->y; @@ -3250,7 +3250,7 @@ static int ui_do_but_EXIT(bContext *C, uiBut *but, uiHandleButtonData *data, con if (ELEM(event->type, LEFTMOUSE, PADENTER, RETKEY) && event->val == KM_PRESS) { int ret = WM_UI_HANDLER_BREAK; /* XXX (a bit ugly) Special case handling for filebrowser drag button */ - if (but->dragpoin && but->imb && ui_but_mouse_inside_icon(but, data->region, event)) { + if (but->dragpoin && but->imb && ui_but_contains_point_px_icon(but, data->region, event)) { ret = WM_UI_HANDLER_CONTINUE; } button_activate_state(C, but, BUTTON_STATE_EXIT); @@ -3260,7 +3260,7 @@ static int ui_do_but_EXIT(bContext *C, uiBut *but, uiHandleButtonData *data, con else if (data->state == BUTTON_STATE_WAIT_DRAG) { /* this function also ends state */ - if (ui_but_start_drag(C, but, data, event)) { + if (ui_but_drag_init(C, but, data, event)) { return WM_UI_HANDLER_BREAK; } @@ -3290,9 +3290,9 @@ static float ui_numedit_apply_snapf(uiBut *but, float tempf, float softmin, floa else { float fac = 1.0f; - if (ui_is_but_unit(but)) { + if (ui_but_is_unit(but)) { UnitSettings *unit = but->block->unit; - int unit_type = RNA_SUBTYPE_UNIT_VALUE(uiButGetUnitType(but)); + int unit_type = RNA_SUBTYPE_UNIT_VALUE(UI_but_unit_type_get(but)); if (bUnit_IsValid(unit->system, unit_type)) { fac = (float)bUnit_BaseScalar(unit->system, unit_type); @@ -3358,7 +3358,7 @@ static bool ui_numedit_but_NUM(uiBut *but, uiHandleButtonData *data, float deler, tempf, softmin, softmax, softrange; int lvalue, temp; bool changed = false; - const bool is_float = ui_is_but_float(but); + const bool is_float = ui_but_is_float(but); if (mx == data->draglastx) return changed; @@ -3382,7 +3382,7 @@ static bool ui_numedit_but_NUM(uiBut *but, uiHandleButtonData *data, softmax = but->softmax; softrange = softmax - softmin; - if (ui_is_a_warp_but(but)) { + if (ui_but_is_cursor_warp(but)) { /* Mouse location isn't screen clamped to the screen so use a linear mapping * 2px == 1-int, or 1px == 1-ClickStep */ if (is_float) { @@ -3536,7 +3536,7 @@ static int ui_do_but_NUM(bContext *C, uiBlock *block, uiBut *but, uiHandleButton retval = WM_UI_HANDLER_BREAK; } else if (event->type == LEFTMOUSE) { - data->dragstartx = data->draglastx = ui_is_a_warp_but(but) ? screen_mx : mx; + data->dragstartx = data->draglastx = ui_but_is_cursor_warp(but) ? screen_mx : mx; button_activate_state(C, but, BUTTON_STATE_NUM_EDITING); retval = WM_UI_HANDLER_BREAK; } @@ -3594,7 +3594,7 @@ static int ui_do_but_NUM(bContext *C, uiBlock *block, uiBut *but, uiHandleButton if (event->shift) fac /= 10.0f; if (event->alt) fac /= 20.0f; - if (ui_numedit_but_NUM(but, data, (ui_is_a_warp_but(but) ? screen_mx : mx), snap, fac)) + if (ui_numedit_but_NUM(but, data, (ui_but_is_cursor_warp(but) ? screen_mx : mx), snap, fac)) ui_numedit_apply(C, block, but, data); #ifdef USE_DRAG_MULTINUM else if (data->multi_data.has_mbuts) { @@ -3627,7 +3627,7 @@ static int ui_do_but_NUM(bContext *C, uiBlock *block, uiBut *but, uiHandleButton handlewidth = min_ff(BLI_rctf_size_x(&but->rect) / 3, BLI_rctf_size_y(&but->rect)); - if (!ui_is_but_float(but)) { + if (!ui_but_is_float(but)) { if (mx < (but->rect.xmin + handlewidth)) { button_activate_state(C, but, BUTTON_STATE_NUM_EDITING); @@ -3705,11 +3705,11 @@ static bool ui_numedit_but_SLI(uiBut *but, uiHandleButtonData *data, /* yes, 'mx' as both x/y is intentional */ ui_mouse_scale_warp(data, mx, mx, &mx_fl, &my_fl, shift); - if (but->type == NUMSLI) { + if (but->type == UI_BTYPE_NUM_SLIDER) { offs = (BLI_rctf_size_y(&but->rect) / 2.0f); deler = BLI_rctf_size_x(&but->rect) - offs; } - else if (but->type == SCROLL) { + else if (but->type == UI_BTYPE_SCROLL) { const float size = (is_horizontal) ? BLI_rctf_size_x(&but->rect) : -BLI_rctf_size_y(&but->rect); deler = size * (but->softmax - but->softmin) / (but->softmax - but->softmin + but->a1); offs = 0.0; @@ -3725,7 +3725,7 @@ static bool ui_numedit_but_SLI(uiBut *but, uiHandleButtonData *data, /* deal with mouse correction */ #ifdef USE_CONT_MOUSE_CORRECT - if (ui_is_a_warp_but(but)) { + if (ui_but_is_cursor_warp(but)) { /* OK but can go outside bounds */ if (is_horizontal) { data->ungrab_mval[0] = (but->rect.xmin + offs) + (f * deler); @@ -3748,7 +3748,7 @@ static bool ui_numedit_but_SLI(uiBut *but, uiHandleButtonData *data, if (tempf == softmin || tempf == softmax) { /* pass */ } - else if (ui_is_but_float(but)) { + else if (ui_but_is_float(but)) { if (shift) { if (tempf == softmin || tempf == softmax) {} @@ -3768,7 +3768,7 @@ static bool ui_numedit_but_SLI(uiBut *but, uiHandleButtonData *data, } } - if (!ui_is_but_float(but)) { + if (!ui_but_is_float(but)) { lvalue = floor(data->value + 0.5); CLAMP(temp, softmin, softmax); @@ -3824,7 +3824,7 @@ static int ui_do_but_SLI(bContext *C, uiBlock *block, uiBut *but, uiHandleButton button_activate_state(C, but, BUTTON_STATE_TEXT_EDITING); retval = WM_UI_HANDLER_BREAK; } - /* alt-click on sides to get "arrows" like in NUM buttons, and match wheel usage above */ + /* alt-click on sides to get "arrows" like in UI_BTYPE_NUM buttons, and match wheel usage above */ else if (event->type == LEFTMOUSE && event->alt) { int halfpos = BLI_rctf_cent_x(&but->rect); click = 2; @@ -3932,7 +3932,7 @@ static int ui_do_but_SLI(bContext *C, uiBlock *block, uiBut *but, uiHandleButton f = softmin + f * softrange; - if (!ui_is_but_float(but)) { + if (!ui_but_is_float(but)) { if (f < temp) temp--; else temp++; @@ -4098,7 +4098,7 @@ static int ui_do_but_BLOCK(bContext *C, uiBut *but, uiHandleButtonData *data, co /* first handle click on icondrag type button */ if (event->type == LEFTMOUSE && but->dragpoin && event->val == KM_PRESS) { - if (ui_but_mouse_inside_icon(but, data->region, event)) { + if (ui_but_contains_point_px_icon(but, data->region, event)) { button_activate_state(C, but, BUTTON_STATE_WAIT_DRAG); data->dragstartx = event->x; data->dragstarty = event->y; @@ -4106,7 +4106,7 @@ static int ui_do_but_BLOCK(bContext *C, uiBut *but, uiHandleButtonData *data, co } } #ifdef USE_DRAG_TOGGLE - if (event->type == LEFTMOUSE && event->val == KM_PRESS && (ui_is_but_drag_toggle(but))) { + if (event->type == LEFTMOUSE && event->val == KM_PRESS && (ui_but_is_drag_toggle(but))) { button_activate_state(C, but, BUTTON_STATE_WAIT_DRAG); data->dragstartx = event->x; data->dragstarty = event->y; @@ -4118,14 +4118,14 @@ static int ui_do_but_BLOCK(bContext *C, uiBut *but, uiHandleButtonData *data, co button_activate_state(C, but, BUTTON_STATE_MENU_OPEN); return WM_UI_HANDLER_BREAK; } - else if (but->type == MENU) { + else if (but->type == UI_BTYPE_MENU) { if (ELEM(event->type, WHEELDOWNMOUSE, WHEELUPMOUSE) && event->alt) { const int direction = (event->type == WHEELDOWNMOUSE) ? -1 : 1; - data->value = ui_step_name_menu(but, direction); + data->value = ui_but_menu_step(but, direction); button_activate_state(C, but, BUTTON_STATE_EXIT); - ui_apply_button(C, but->block, but, data, true); + ui_apply_but(C, but->block, but, data, true); /* button's state need to be changed to EXIT so moving mouse away from this mouse wouldn't lead * to cancel changes made to this button, but changing state to EXIT also makes no button active for @@ -4154,12 +4154,12 @@ static int ui_do_but_BLOCK(bContext *C, uiBut *but, uiHandleButtonData *data, co else if (data->state == BUTTON_STATE_WAIT_DRAG) { /* this function also ends state */ - if (ui_but_start_drag(C, but, data, event)) { + if (ui_but_drag_init(C, but, data, event)) { return WM_UI_HANDLER_BREAK; } /* outside icon quit, not needed if drag activated */ - if (0 == ui_but_mouse_inside_icon(but, data->region, event)) { + if (0 == ui_but_contains_point_px_icon(but, data->region, event)) { button_activate_state(C, but, BUTTON_STATE_EXIT); data->cancel = true; return WM_UI_HANDLER_BREAK; @@ -4175,7 +4175,7 @@ static int ui_do_but_BLOCK(bContext *C, uiBut *but, uiHandleButtonData *data, co return WM_UI_HANDLER_CONTINUE; } -static bool ui_numedit_but_NORMAL(uiBut *but, uiHandleButtonData *data, +static bool ui_numedit_but_UNITVEC(uiBut *but, uiHandleButtonData *data, int mx, int my, const enum eSnapType snap) { @@ -4271,7 +4271,7 @@ static int ui_do_but_COLOR(bContext *C, uiBut *but, uiHandleButtonData *data, co /* first handle click on icondrag type button */ if (event->type == LEFTMOUSE && but->dragpoin && event->val == KM_PRESS) { ui_palette_set_active(but); - if (ui_but_mouse_inside_icon(but, data->region, event)) { + if (ui_but_contains_point_px_icon(but, data->region, event)) { button_activate_state(C, but, BUTTON_STATE_WAIT_DRAG); data->dragstartx = event->x; data->dragstarty = event->y; @@ -4299,7 +4299,7 @@ static int ui_do_but_COLOR(bContext *C, uiBut *but, uiHandleButtonData *data, co float *hsv = cpicker ? cpicker->color_data : hsv_static; float col[3]; - ui_get_but_vectorf(but, col); + ui_but_v3_get(but, col); rgb_to_hsv_compat_v(col, hsv); if (event->type == WHEELDOWNMOUSE) @@ -4312,10 +4312,10 @@ static int ui_do_but_COLOR(bContext *C, uiBut *but, uiHandleButtonData *data, co } hsv_to_rgb_v(hsv, data->vec); - ui_set_but_vectorf(but, data->vec); + ui_but_v3_set(but, data->vec); button_activate_state(C, but, BUTTON_STATE_EXIT); - ui_apply_button(C, but->block, but, data, true); + ui_apply_but(C, but->block, but, data, true); return WM_UI_HANDLER_BREAK; } else if ((int)(but->a1) == UI_PALETTE_COLOR && @@ -4333,12 +4333,12 @@ static int ui_do_but_COLOR(bContext *C, uiBut *but, uiHandleButtonData *data, co else if (data->state == BUTTON_STATE_WAIT_DRAG) { /* this function also ends state */ - if (ui_but_start_drag(C, but, data, event)) { + if (ui_but_drag_init(C, but, data, event)) { return WM_UI_HANDLER_BREAK; } /* outside icon quit, not needed if drag activated */ - if (0 == ui_but_mouse_inside_icon(but, data->region, event)) { + if (0 == ui_but_contains_point_px_icon(but, data->region, event)) { button_activate_state(C, but, BUTTON_STATE_EXIT); data->cancel = true; return WM_UI_HANDLER_BREAK; @@ -4357,7 +4357,7 @@ static int ui_do_but_COLOR(bContext *C, uiBut *but, uiHandleButtonData *data, co if (but->rnaprop && RNA_property_subtype(but->rnaprop) == PROP_COLOR_GAMMA) { RNA_property_float_get_array(&but->rnapoin, but->rnaprop, target); - ui_block_to_scene_linear_v3(but->block, target); + ui_block_cm_to_scene_linear_v3(but->block, target); } else if (but->rnaprop && RNA_property_subtype(but->rnaprop) == PROP_COLOR) { RNA_property_float_get_array(&but->rnapoin, but->rnaprop, target); @@ -4370,7 +4370,7 @@ static int ui_do_but_COLOR(bContext *C, uiBut *but, uiHandleButtonData *data, co } else if (but->rnaprop && RNA_property_subtype(but->rnaprop) == PROP_COLOR) { RNA_property_float_get_array(&but->rnapoin, but->rnaprop, color); - ui_block_to_display_space_v3(but->block, color); + ui_block_cm_to_display_space_v3(but->block, color); BKE_brush_color_set(scene, brush, color); } } @@ -4392,7 +4392,7 @@ static int ui_do_but_COLOR(bContext *C, uiBut *but, uiHandleButtonData *data, co return WM_UI_HANDLER_CONTINUE; } -static int ui_do_but_NORMAL(bContext *C, uiBlock *block, uiBut *but, uiHandleButtonData *data, const wmEvent *event) +static int ui_do_but_UNITVEC(bContext *C, uiBlock *block, uiBut *but, uiHandleButtonData *data, const wmEvent *event) { int mx, my; @@ -4410,7 +4410,7 @@ static int ui_do_but_NORMAL(bContext *C, uiBlock *block, uiBut *but, uiHandleBut button_activate_state(C, but, BUTTON_STATE_NUM_EDITING); /* also do drag the first time */ - if (ui_numedit_but_NORMAL(but, data, mx, my, snap)) + if (ui_numedit_but_UNITVEC(but, data, mx, my, snap)) ui_numedit_apply(C, block, but, data); return WM_UI_HANDLER_BREAK; @@ -4420,7 +4420,7 @@ static int ui_do_but_NORMAL(bContext *C, uiBlock *block, uiBut *but, uiHandleBut if (event->type == MOUSEMOVE) { if (mx != data->draglastx || my != data->draglasty) { const enum eSnapType snap = ui_event_to_snap(event); - if (ui_numedit_but_NORMAL(but, data, mx, my, snap)) + if (ui_numedit_but_UNITVEC(but, data, mx, my, snap)) ui_numedit_apply(C, block, but, data); } } @@ -4481,12 +4481,12 @@ static bool ui_numedit_but_HSVCUBE(uiBut *but, uiHandleButtonData *data, float x, y; float mx_fl, my_fl; bool changed = true; - bool use_display_colorspace = ui_color_picker_use_display_colorspace(but); + bool use_display_colorspace = ui_but_is_colorpicker_display_space(but); ui_mouse_scale_warp(data, mx, my, &mx_fl, &my_fl, shift); #ifdef USE_CONT_MOUSE_CORRECT - if (ui_is_a_warp_but(but)) { + if (ui_but_is_cursor_warp(but)) { /* OK but can go outside bounds */ data->ungrab_mval[0] = mx_fl; data->ungrab_mval[1] = my_fl; @@ -4494,10 +4494,10 @@ static bool ui_numedit_but_HSVCUBE(uiBut *but, uiHandleButtonData *data, } #endif - ui_get_but_vectorf(but, rgb); + ui_but_v3_get(but, rgb); if (use_display_colorspace) - ui_block_to_display_space_v3(but->block, rgb); + ui_block_cm_to_display_space_v3(but->block, rgb); ui_rgb_to_color_picker_HSVCUBE_compat_v(but, rgb, hsv); @@ -4511,7 +4511,7 @@ static bool ui_numedit_but_HSVCUBE(uiBut *but, uiHandleButtonData *data, /* calculate original hsv again */ copy_v3_v3(rgb, data->origvec); if (use_display_colorspace) - ui_block_to_display_space_v3(but->block, rgb); + ui_block_cm_to_display_space_v3(but->block, rgb); copy_v3_v3(hsvo, hsv); @@ -4575,7 +4575,7 @@ static bool ui_numedit_but_HSVCUBE(uiBut *but, uiHandleButtonData *data, ui_color_picker_to_rgb_HSVCUBE_v(but, hsv, rgb); if (use_display_colorspace) - ui_block_to_scene_linear_v3(but->block, rgb); + ui_block_cm_to_scene_linear_v3(but->block, rgb); /* clamp because with color conversion we can exceed range [#34295] */ if (but->a1 == UI_GRAD_V_ALT) { @@ -4599,12 +4599,12 @@ static void ui_ndofedit_but_HSVCUBE(uiBut *but, uiHandleButtonData *data, const float hsv_v_max = max_ff(hsv[2], but->softmax); float rgb[3]; float sensitivity = (shift ? 0.15f : 0.3f) * ndof->dt; - bool use_display_colorspace = ui_color_picker_use_display_colorspace(but); + bool use_display_colorspace = ui_but_is_colorpicker_display_space(but); - ui_get_but_vectorf(but, rgb); + ui_but_v3_get(but, rgb); if (use_display_colorspace) - ui_block_to_display_space_v3(but->block, rgb); + ui_block_cm_to_display_space_v3(but->block, rgb); ui_rgb_to_color_picker_HSVCUBE_compat_v(but, rgb, hsv); @@ -4656,10 +4656,10 @@ static void ui_ndofedit_but_HSVCUBE(uiBut *but, uiHandleButtonData *data, ui_color_picker_to_rgb_HSVCUBE_v(but, hsv, rgb); if (use_display_colorspace) - ui_block_to_scene_linear_v3(but->block, rgb); + ui_block_cm_to_scene_linear_v3(but->block, rgb); copy_v3_v3(data->vec, rgb); - ui_set_but_vectorf(but, data->vec); + ui_but_v3_set(but, data->vec); } static int ui_do_but_HSVCUBE(bContext *C, uiBlock *block, uiBut *but, uiHandleButtonData *data, const wmEvent *event) @@ -4693,7 +4693,7 @@ static int ui_do_but_HSVCUBE(bContext *C, uiBlock *block, uiBut *but, uiHandleBu ui_ndofedit_but_HSVCUBE(but, data, ndof, snap, event->shift != 0); button_activate_state(C, but, BUTTON_STATE_EXIT); - ui_apply_button(C, but->block, but, data, true); + ui_apply_but(C, but->block, but, data, true); return WM_UI_HANDLER_BREAK; } @@ -4714,14 +4714,14 @@ static int ui_do_but_HSVCUBE(bContext *C, uiBlock *block, uiBut *but, uiHandleBu RNA_property_float_get_default_array(&but->rnapoin, but->rnaprop, def); ui_rgb_to_color_picker_HSVCUBE_v(but, def, def_hsv); - ui_get_but_vectorf(but, rgb); + ui_but_v3_get(but, rgb); ui_rgb_to_color_picker_HSVCUBE_compat_v(but, rgb, hsv); def_hsv[0] = hsv[0]; def_hsv[1] = hsv[1]; ui_color_picker_to_rgb_HSVCUBE_v(but, def_hsv, rgb); - ui_set_but_vectorf(but, rgb); + ui_but_v3_set(but, rgb); RNA_property_update(C, &but->rnapoin, but->rnaprop); return WM_UI_HANDLER_BREAK; @@ -4765,12 +4765,12 @@ static bool ui_numedit_but_HSVCIRCLE(uiBut *but, uiHandleButtonData *data, float rgb[3]; ColorPicker *cpicker = but->custom_data; float *hsv = cpicker->color_data; - bool use_display_colorspace = ui_color_picker_use_display_colorspace(but); + bool use_display_colorspace = ui_but_is_colorpicker_display_space(but); ui_mouse_scale_warp(data, mx, my, &mx_fl, &my_fl, shift); #ifdef USE_CONT_MOUSE_CORRECT - if (ui_is_a_warp_but(but)) { + if (ui_but_is_cursor_warp(but)) { /* OK but can go outside bounds */ data->ungrab_mval[0] = mx_fl; data->ungrab_mval[1] = my_fl; @@ -4787,9 +4787,9 @@ static bool ui_numedit_but_HSVCIRCLE(uiBut *but, uiHandleButtonData *data, BLI_rcti_rctf_copy(&rect, &but->rect); - ui_get_but_vectorf(but, rgb); + ui_but_v3_get(but, rgb); if (use_display_colorspace) - ui_block_to_display_space_v3(but->block, rgb); + ui_block_cm_to_display_space_v3(but->block, rgb); ui_rgb_to_color_picker_compat_v(rgb, hsv); @@ -4813,7 +4813,7 @@ static bool ui_numedit_but_HSVCIRCLE(uiBut *but, uiHandleButtonData *data, copy_v3_v3(hsvo, hsv); copy_v3_v3(rgbo, data->origvec); if (use_display_colorspace) - ui_block_to_display_space_v3(but->block, rgbo); + ui_block_cm_to_display_space_v3(but->block, rgbo); ui_rgb_to_color_picker_compat_v(rgbo, hsvo); @@ -4842,9 +4842,9 @@ static bool ui_numedit_but_HSVCIRCLE(uiBut *but, uiHandleButtonData *data, } if (use_display_colorspace) - ui_block_to_scene_linear_v3(but->block, rgb); + ui_block_cm_to_scene_linear_v3(but->block, rgb); - ui_set_but_vectorf(but, rgb); + ui_but_v3_set(but, rgb); data->draglastx = mx; data->draglasty = my; @@ -4858,14 +4858,14 @@ static void ui_ndofedit_but_HSVCIRCLE(uiBut *but, uiHandleButtonData *data, { ColorPicker *cpicker = but->custom_data; float *hsv = cpicker->color_data; - bool use_display_colorspace = ui_color_picker_use_display_colorspace(but); + bool use_display_colorspace = ui_but_is_colorpicker_display_space(but); float rgb[3]; float phi, r /*, sqr */ /* UNUSED */, v[2]; float sensitivity = (shift ? 0.06f : 0.3f) * ndof->dt; - ui_get_but_vectorf(but, rgb); + ui_but_v3_get(but, rgb); if (use_display_colorspace) - ui_block_to_display_space_v3(but->block, rgb); + ui_block_cm_to_display_space_v3(but->block, rgb); ui_rgb_to_color_picker_compat_v(rgb, hsv); /* Convert current color on hue/sat disc to circular coordinates phi, r */ @@ -4918,9 +4918,9 @@ static void ui_ndofedit_but_HSVCIRCLE(uiBut *but, uiHandleButtonData *data, } if (use_display_colorspace) - ui_block_to_scene_linear_v3(but->block, data->vec); + ui_block_cm_to_scene_linear_v3(but->block, data->vec); - ui_set_but_vectorf(but, data->vec); + ui_but_v3_set(but, data->vec); } @@ -4955,7 +4955,7 @@ static int ui_do_but_HSVCIRCLE(bContext *C, uiBlock *block, uiBut *but, uiHandle ui_ndofedit_but_HSVCIRCLE(but, data, ndof, snap, event->shift != 0); button_activate_state(C, but, BUTTON_STATE_EXIT); - ui_apply_button(C, but->block, but, data, true); + ui_apply_but(C, but->block, but, data, true); return WM_UI_HANDLER_BREAK; } @@ -4974,14 +4974,14 @@ static int ui_do_but_HSVCIRCLE(bContext *C, uiBlock *block, uiBut *but, uiHandle RNA_property_float_get_default_array(&but->rnapoin, but->rnaprop, def); ui_color_picker_to_rgb_v(def, def_hsv); - ui_get_but_vectorf(but, rgb); + ui_but_v3_get(but, rgb); ui_rgb_to_color_picker_compat_v(rgb, hsv); def_hsv[0] = hsv[0]; def_hsv[2] = hsv[2]; hsv_to_rgb_v(def_hsv, rgb); - ui_set_but_vectorf(but, rgb); + ui_but_v3_set(but, rgb); RNA_property_update(C, &but->rnapoin, but->rnaprop); @@ -5001,12 +5001,12 @@ static int ui_do_but_HSVCIRCLE(bContext *C, uiBlock *block, uiBut *but, uiHandle /* XXX hardcoded keymap check.... */ else if (event->type == WHEELDOWNMOUSE) { hsv[2] = CLAMPIS(hsv[2] - 0.05f, 0.0f, 1.0f); - ui_set_but_hsv(but); /* converts to rgb */ + ui_but_hsv_set(but); /* converts to rgb */ ui_numedit_apply(C, block, but, data); } else if (event->type == WHEELUPMOUSE) { hsv[2] = CLAMPIS(hsv[2] + 0.05f, 0.0f, 1.0f); - ui_set_but_hsv(but); /* converts to rgb */ + ui_but_hsv_set(but); /* converts to rgb */ ui_numedit_apply(C, block, but, data); } else if (event->type == MOUSEMOVE) { @@ -5183,7 +5183,7 @@ static bool ui_numedit_but_CURVE(uiBlock *block, uiBut *but, uiHandleButtonData #ifdef USE_CONT_MOUSE_CORRECT /* note: using 'cmp_last' is weak since there may be multiple points selected, * but in practice this isnt really an issue */ - if (ui_is_a_warp_but(but)) { + if (ui_but_is_cursor_warp(but)) { /* OK but can go outside bounds */ data->ungrab_mval[0] = but->rect.xmin + ((cmp_last->x - cumap->curr.xmin) * zoomx); data->ungrab_mval[1] = but->rect.ymin + ((cmp_last->y - cumap->curr.ymin) * zoomy); @@ -5659,7 +5659,7 @@ static uiBlock *menu_change_shortcut(bContext *C, ARegion *ar, void *arg) wmKeyMapItem *kmi; PointerRNA ptr; uiLayout *layout; - uiStyle *style = UI_GetStyleDraw(); + uiStyle *style = UI_style_get_dpi(); IDProperty *prop = (but->opptr) ? but->opptr->data : NULL; int kmi_id = WM_key_event_operator_id(C, but->optype->idname, but->opcontext, prop, true, &km); @@ -5667,16 +5667,16 @@ static uiBlock *menu_change_shortcut(bContext *C, ARegion *ar, void *arg) RNA_pointer_create(&wm->id, &RNA_KeyMapItem, kmi, &ptr); - block = uiBeginBlock(C, ar, "_popup", UI_EMBOSS); - uiBlockSetHandleFunc(block, but_shortcut_name_func, but); - uiBlockSetFlag(block, UI_BLOCK_MOVEMOUSE_QUIT); - uiBlockSetDirection(block, UI_CENTER); + block = UI_block_begin(C, ar, "_popup", UI_EMBOSS); + UI_block_func_handle_set(block, but_shortcut_name_func, but); + UI_block_flag_enable(block, UI_BLOCK_MOVEMOUSE_QUIT); + UI_block_direction_set(block, UI_DIR_CENTER_Y); - layout = uiBlockLayout(block, UI_LAYOUT_VERTICAL, UI_LAYOUT_PANEL, 0, 0, 200, 20, 0, style); + layout = UI_block_layout(block, UI_LAYOUT_VERTICAL, UI_LAYOUT_PANEL, 0, 0, 200, 20, 0, style); uiItemR(layout, &ptr, "type", UI_ITEM_R_FULL_EVENT | UI_ITEM_R_IMMEDIATE, "", ICON_NONE); - uiPopupBoundsBlock(block, 6, -50, 26); + UI_block_bounds_set_popup(block, 6, -50, 26); return block; } @@ -5690,7 +5690,7 @@ static uiBlock *menu_add_shortcut(bContext *C, ARegion *ar, void *arg) wmKeyMapItem *kmi; PointerRNA ptr; uiLayout *layout; - uiStyle *style = UI_GetStyleDraw(); + uiStyle *style = UI_style_get_dpi(); IDProperty *prop = (but->opptr) ? but->opptr->data : NULL; int kmi_id; @@ -5712,15 +5712,15 @@ static uiBlock *menu_add_shortcut(bContext *C, ARegion *ar, void *arg) RNA_pointer_create(&wm->id, &RNA_KeyMapItem, kmi, &ptr); - block = uiBeginBlock(C, ar, "_popup", UI_EMBOSS); - uiBlockSetHandleFunc(block, but_shortcut_name_func, but); - uiBlockSetDirection(block, UI_CENTER); + block = UI_block_begin(C, ar, "_popup", UI_EMBOSS); + UI_block_func_handle_set(block, but_shortcut_name_func, but); + UI_block_direction_set(block, UI_DIR_CENTER_Y); - layout = uiBlockLayout(block, UI_LAYOUT_VERTICAL, UI_LAYOUT_PANEL, 0, 0, 200, 20, 0, style); + layout = UI_block_layout(block, UI_LAYOUT_VERTICAL, UI_LAYOUT_PANEL, 0, 0, 200, 20, 0, style); uiItemR(layout, &ptr, "type", UI_ITEM_R_FULL_EVENT | UI_ITEM_R_IMMEDIATE, "", ICON_NONE); - uiPopupBoundsBlock(block, 6, -50, 26); + UI_block_bounds_set_popup(block, 6, -50, 26); return block; } @@ -5741,7 +5741,7 @@ static void popup_change_shortcut_func(bContext *C, void *arg1, void *UNUSED(arg { uiBut *but = (uiBut *)arg1; button_timers_tooltip_remove(C, but); - uiPupBlock(C, menu_change_shortcut, but); + UI_popup_block_invoke(C, menu_change_shortcut, but); } static void remove_shortcut_func(bContext *C, void *arg1, void *UNUSED(arg2)) @@ -5762,7 +5762,7 @@ static void popup_add_shortcut_func(bContext *C, void *arg1, void *UNUSED(arg2)) { uiBut *but = (uiBut *)arg1; button_timers_tooltip_remove(C, but); - uiPupBlockEx(C, menu_add_shortcut, NULL, menu_add_shortcut_cancel, but); + UI_popup_block_ex(C, menu_add_shortcut, NULL, menu_add_shortcut_cancel, but); } /** @@ -5777,8 +5777,8 @@ void ui_panel_menu(bContext *C, ARegion *ar, Panel *pa) RNA_pointer_create(&sc->id, &RNA_Panel, pa, &ptr); - pup = uiPupMenuBegin(C, IFACE_("Panel"), ICON_NONE); - layout = uiPupMenuLayout(pup); + pup = UI_popup_menu_begin(C, IFACE_("Panel"), ICON_NONE); + layout = UI_popup_menu_layout(pup); if (UI_panel_category_is_visible(ar)) { char tmpstr[80]; BLI_snprintf(tmpstr, sizeof(tmpstr), "%s" UI_SEP_CHAR_S "%s", IFACE_("Pin"), IFACE_("Shift+Left Mouse")); @@ -5792,7 +5792,7 @@ void ui_panel_menu(bContext *C, ARegion *ar, Panel *pa) } } - uiPupMenuEnd(C, pup); + UI_popup_menu_end(C, pup); } static bool ui_but_menu(bContext *C, uiBut *but) @@ -5806,17 +5806,17 @@ static bool ui_but_menu(bContext *C, uiBut *but) /* return 0;*/ /* having this menu for some buttons makes no sense */ - if (but->type == BUT_IMAGE) { + if (but->type == UI_BTYPE_IMAGE) { return false; } button_timers_tooltip_remove(C, but); /* highly unlikely getting the label ever fails */ - uiButGetStrInfo(C, but, &label, NULL); + UI_but_string_info_get(C, but, &label, NULL); - pup = uiPupMenuBegin(C, label.strinfo ? label.strinfo : "", ICON_NONE); - layout = uiPupMenuLayout(pup); + pup = UI_popup_menu_begin(C, label.strinfo ? label.strinfo : "", ICON_NONE); + layout = UI_popup_menu_layout(pup); if (label.strinfo) MEM_freeN(label.strinfo); @@ -6007,19 +6007,19 @@ static bool ui_but_menu(bContext *C, uiBut *but) /* would rather use a block but, but gets weirdly positioned... */ //uiDefBlockBut(block, menu_change_shortcut, but, "Change Shortcut", 0, 0, uiLayoutGetWidth(layout), UI_UNIT_Y, ""); - but2 = uiDefIconTextBut(block, BUT, 0, 0, CTX_IFACE_(BLF_I18NCONTEXT_OPERATOR_DEFAULT, "Change Shortcut"), + but2 = uiDefIconTextBut(block, UI_BTYPE_BUT, 0, 0, CTX_IFACE_(BLF_I18NCONTEXT_OPERATOR_DEFAULT, "Change Shortcut"), 0, 0, w, UI_UNIT_Y, NULL, 0, 0, 0, 0, ""); - uiButSetFunc(but2, popup_change_shortcut_func, but, NULL); + UI_but_func_set(but2, popup_change_shortcut_func, but, NULL); - but2 = uiDefIconTextBut(block, BUT, 0, 0, CTX_IFACE_(BLF_I18NCONTEXT_OPERATOR_DEFAULT, "Remove Shortcut"), + but2 = uiDefIconTextBut(block, UI_BTYPE_BUT, 0, 0, CTX_IFACE_(BLF_I18NCONTEXT_OPERATOR_DEFAULT, "Remove Shortcut"), 0, 0, w, UI_UNIT_Y, NULL, 0, 0, 0, 0, ""); - uiButSetFunc(but2, remove_shortcut_func, but, NULL); + UI_but_func_set(but2, remove_shortcut_func, but, NULL); } /* only show 'add' if there's a suitable key map for it to go in */ else if (WM_keymap_guess_opname(C, but->optype->idname)) { - but2 = uiDefIconTextBut(block, BUT, 0, 0, CTX_IFACE_(BLF_I18NCONTEXT_OPERATOR_DEFAULT, "Add Shortcut"), + but2 = uiDefIconTextBut(block, UI_BTYPE_BUT, 0, 0, CTX_IFACE_(BLF_I18NCONTEXT_OPERATOR_DEFAULT, "Add Shortcut"), 0, 0, w, UI_UNIT_Y, NULL, 0, 0, 0, 0, ""); - uiButSetFunc(but2, popup_add_shortcut_func, but, NULL); + UI_but_func_set(but2, popup_add_shortcut_func, but, NULL); } uiItemS(layout); @@ -6093,7 +6093,7 @@ static bool ui_but_menu(bContext *C, uiBut *but) } uiItemFullO(layout, "UI_OT_edittranslation_init", NULL, ICON_NONE, NULL, WM_OP_INVOKE_DEFAULT, 0); - uiPupMenuEnd(C, pup); + UI_popup_menu_end(C, pup); return true; } @@ -6113,7 +6113,7 @@ static int ui_do_button(bContext *C, uiBlock *block, uiBut *but, const wmEvent * /* handle copy-paste */ if (ELEM(event->type, CKEY, VKEY) && event->val == KM_PRESS && (event->ctrl || event->oskey)) { /* Specific handling for listrows, we try to find their overlapping tex button. */ - if (but->type == LISTROW) { + if (but->type == UI_BTYPE_LISTROW) { uiBut *labelbut = ui_but_list_row_text_activate(C, but, data, event, BUTTON_ACTIVATE_OVER); if (labelbut) { but = labelbut; @@ -6134,11 +6134,11 @@ static int ui_do_button(bContext *C, uiBlock *block, uiBut *but, const wmEvent * /* pass */ } else { - if (but->type == COLOR) { + if (but->type == UI_BTYPE_COLOR) { WM_operator_name_call(C, "UI_OT_eyedropper_color", WM_OP_INVOKE_DEFAULT, NULL); return WM_UI_HANDLER_BREAK; } - else if (but->type == SEARCH_MENU_UNLINK) { + else if (but->type == UI_BTYPE_SEARCH_MENU_UNLINK) { if (but->rnaprop && RNA_property_type(but->rnaprop) == PROP_POINTER) { StructRNA *type = RNA_property_pointer_type(&but->rnapoin, but->rnaprop); const short idcode = RNA_type_to_ID_code(type); @@ -6227,107 +6227,107 @@ static int ui_do_button(bContext *C, uiBlock *block, uiBut *but, const wmEvent * } switch (but->type) { - case BUT: + case UI_BTYPE_BUT: retval = ui_do_but_BUT(C, but, data, event); break; - case KEYEVT: + case UI_BTYPE_KEY_EVENT: retval = ui_do_but_KEYEVT(C, but, data, event); break; - case HOTKEYEVT: + case UI_BTYPE_HOTKEY_EVENT: retval = ui_do_but_HOTKEYEVT(C, but, data, event); break; - case TOGBUT: - case TOG: - case ICONTOG: - case ICONTOGN: - case TOGN: - case OPTION: - case OPTIONN: + case UI_BTYPE_BUT_TOGGLE: + case UI_BTYPE_TOGGLE: + case UI_BTYPE_ICON_TOGGLE: + case UI_BTYPE_ICON_TOGGLE_N: + case UI_BTYPE_TOGGLE_N: + case UI_BTYPE_CHECKBOX: + case UI_BTYPE_CHECKBOX_N: retval = ui_do_but_TOG(C, but, data, event); break; - case SCROLL: + case UI_BTYPE_SCROLL: retval = ui_do_but_SCROLL(C, block, but, data, event); break; - case GRIP: + case UI_BTYPE_GRIP: retval = ui_do_but_GRIP(C, block, but, data, event); break; - case NUM: + case UI_BTYPE_NUM: retval = ui_do_but_NUM(C, block, but, data, event); break; - case NUMSLI: + case UI_BTYPE_NUM_SLIDER: retval = ui_do_but_SLI(C, block, but, data, event); break; - case LISTBOX: + case UI_BTYPE_LISTBOX: /* Nothing to do! */ break; - case LISTROW: + case UI_BTYPE_LISTROW: retval = ui_do_but_LISTROW(C, but, data, event); break; - case ROUNDBOX: - case LABEL: - case ROW: - case BUT_IMAGE: - case PROGRESSBAR: - case NODESOCKET: + case UI_BTYPE_ROUNDBOX: + case UI_BTYPE_LABEL: + case UI_BTYPE_ROW: + case UI_BTYPE_IMAGE: + case UI_BTYPE_PROGRESS_BAR: + case UI_BTYPE_NODE_SOCKET: retval = ui_do_but_EXIT(C, but, data, event); break; - case HISTOGRAM: + case UI_BTYPE_HISTOGRAM: retval = ui_do_but_HISTOGRAM(C, block, but, data, event); break; - case WAVEFORM: + case UI_BTYPE_WAVEFORM: retval = ui_do_but_WAVEFORM(C, block, but, data, event); break; - case VECTORSCOPE: + case UI_BTYPE_VECTORSCOPE: /* Nothing to do! */ break; - case TEX: - case SEARCH_MENU: + case UI_BTYPE_TEXT: + case UI_BTYPE_SEARCH_MENU: retval = ui_do_but_TEX(C, block, but, data, event); break; - case SEARCH_MENU_UNLINK: + case UI_BTYPE_SEARCH_MENU_UNLINK: retval = ui_do_but_SEARCH_UNLINK(C, block, but, data, event); break; - case MENU: - case BLOCK: - case PULLDOWN: + case UI_BTYPE_MENU: + case UI_BTYPE_BLOCK: + case UI_BTYPE_PULLDOWN: retval = ui_do_but_BLOCK(C, but, data, event); break; - case BUTM: + case UI_BTYPE_BUT_MENU: retval = ui_do_but_BUT(C, but, data, event); break; - case COLOR: + case UI_BTYPE_COLOR: if (but->a1 == -1) /* signal to prevent calling up color picker */ retval = ui_do_but_EXIT(C, but, data, event); else retval = ui_do_but_COLOR(C, but, data, event); break; - case BUT_NORMAL: - retval = ui_do_but_NORMAL(C, block, but, data, event); + case UI_BTYPE_UNITVEC: + retval = ui_do_but_UNITVEC(C, block, but, data, event); break; - case BUT_COLORBAND: + case UI_BTYPE_COLORBAND: retval = ui_do_but_COLORBAND(C, block, but, data, event); break; - case BUT_CURVE: + case UI_BTYPE_CURVE: retval = ui_do_but_CURVE(C, block, but, data, event); break; - case HSVCUBE: + case UI_BTYPE_HSVCUBE: retval = ui_do_but_HSVCUBE(C, block, but, data, event); break; - case HSVCIRCLE: + case UI_BTYPE_HSVCIRCLE: retval = ui_do_but_HSVCIRCLE(C, block, but, data, event); break; - case LINK: - case INLINK: + case UI_BTYPE_LINK: + case UI_BTYPE_INLINK: retval = ui_do_but_LINK(C, but, data, event); break; - case TRACKPREVIEW: + case UI_BTYPE_TRACK_PREVIEW: retval = ui_do_but_TRACKPREVIEW(C, block, but, data, event); break; /* quiet warnings for unhandled types */ - case SEPR: - case SEPRLINE: - case BUT_EXTRA: + case UI_BTYPE_SEPR: + case UI_BTYPE_SEPR_LINE: + case UI_BTYPE_EXTRA: break; } @@ -6340,7 +6340,7 @@ static int ui_do_button(bContext *C, uiBlock *block, uiBut *but, const wmEvent * (event->type == BACKSPACEKEY && event->val == KM_PRESS)) { /* ctrl+backspace = reset active button; backspace = reset a whole array*/ - ui_set_but_default(C, !event->ctrl, true); + ui_but_default_set(C, !event->ctrl, true); ED_region_tag_redraw(data->region); retval = WM_UI_HANDLER_BREAK; } @@ -6352,7 +6352,7 @@ static int ui_do_button(bContext *C, uiBlock *block, uiBut *but, const wmEvent * /* if we started dragging, progress on any event */ (data->multi_data.init == BUTTON_MULTI_INIT_SETUP)) { - if (ELEM(but->type, NUM, NUMSLI) && + if (ELEM(but->type, UI_BTYPE_NUM, UI_BTYPE_NUM_SLIDER) && ELEM(data->state, BUTTON_STATE_TEXT_EDITING, BUTTON_STATE_NUM_EDITING)) { /* initialize! */ @@ -6438,7 +6438,7 @@ static bool ui_but_isect_pie_seg(uiBlock *block, uiBut *but) return false; } -uiBut *ui_but_find_activated(ARegion *ar) +uiBut *ui_but_find_active_in_region(ARegion *ar) { uiBlock *block; uiBut *but; @@ -6451,26 +6451,26 @@ uiBut *ui_but_find_activated(ARegion *ar) return NULL; } -bool ui_button_is_active(ARegion *ar) +bool ui_but_is_active(ARegion *ar) { - return (ui_but_find_activated(ar) != NULL); + return (ui_but_find_active_in_region(ar) != NULL); } /* is called by notifier */ -void uiFreeActiveButtons(const bContext *C, bScreen *screen) +void UI_screen_free_active_but(const bContext *C, bScreen *screen) { ScrArea *sa = screen->areabase.first; for (; sa; sa = sa->next) { ARegion *ar = sa->regionbase.first; for (; ar; ar = ar->next) { - uiBut *but = ui_but_find_activated(ar); + uiBut *but = ui_but_find_active_in_region(ar); if (but) { uiHandleButtonData *data = but->active; if (data->menu == NULL && data->searchbox == NULL) if (data->state == BUTTON_STATE_HIGHLIGHT) - ui_button_active_free(C, but); + ui_but_active_free(C, but); } } } @@ -6483,10 +6483,10 @@ void uiFreeActiveButtons(const bContext *C, bScreen *screen) bool UI_but_active_drop_name(bContext *C) { ARegion *ar = CTX_wm_region(C); - uiBut *but = ui_but_find_activated(ar); + uiBut *but = ui_but_find_active_in_region(ar); if (but) { - if (ELEM(but->type, TEX, SEARCH_MENU, SEARCH_MENU_UNLINK)) + if (ELEM(but->type, UI_BTYPE_TEXT, UI_BTYPE_SEARCH_MENU, UI_BTYPE_SEARCH_MENU_UNLINK)) return 1; } @@ -6498,9 +6498,9 @@ bool UI_but_active_drop_color(bContext *C) ARegion *ar = CTX_wm_region(C); if (ar) { - uiBut *but = ui_but_find_activated(ar); + uiBut *but = ui_but_find_active_in_region(ar); - if (but && but->type == COLOR) + if (but && but->type == UI_BTYPE_COLOR) return true; } @@ -6520,7 +6520,7 @@ static void ui_blocks_set_tooltips(ARegion *ar, const bool enable) block->tooltipdisabled = !enable; } -static bool ui_mouse_inside_region(ARegion *ar, int x, int y) +static bool ui_region_contains_point_px(ARegion *ar, int x, int y) { uiBlock *block; @@ -6554,11 +6554,11 @@ static bool ui_mouse_inside_region(ARegion *ar, int x, int y) return true; } -static bool ui_mouse_inside_button(ARegion *ar, uiBut *but, int x, int y) +static bool ui_but_contains_point_px(ARegion *ar, uiBut *but, int x, int y) { uiBlock *block = but->block; float mx, my; - if (!ui_mouse_inside_region(ar, x, y)) + if (!ui_region_contains_point_px(ar, x, y)) return false; mx = x; @@ -6580,30 +6580,30 @@ static bool ui_mouse_inside_button(ARegion *ar, uiBut *but, int x, int y) /** * Can we mouse over the button or is it hidden/disabled/layout. - * Note: ctrl is kind of a hack currently, so that non-embossed TEX button behaves as a label when ctrl is not pressed. + * Note: ctrl is kind of a hack currently, so that non-embossed UI_BTYPE_TEXT button behaves as a label when ctrl is not pressed. */ -static bool ui_is_but_interactive(const uiBut *but, const bool labeledit) +static bool ui_but_is_interactive(const uiBut *but, const bool labeledit) { - /* note, LABEL is included for highlights, this allows drags */ - if ((but->type == LABEL) && but->dragpoin == NULL) + /* note, UI_BTYPE_LABEL is included for highlights, this allows drags */ + if ((but->type == UI_BTYPE_LABEL) && but->dragpoin == NULL) return false; - if (ELEM(but->type, ROUNDBOX, SEPR, SEPRLINE, LISTBOX)) + if (ELEM(but->type, UI_BTYPE_ROUNDBOX, UI_BTYPE_SEPR, UI_BTYPE_SEPR_LINE, UI_BTYPE_LISTBOX)) return false; if (but->flag & UI_HIDDEN) return false; if (but->flag & UI_SCROLLED) return false; - if ((but->type == TEX) && (but->dt == UI_EMBOSSN) && !labeledit) + if ((but->type == UI_BTYPE_TEXT) && (but->dt == UI_EMBOSS_NONE) && !labeledit) return false; - if ((but->type == LISTROW) && labeledit) + if ((but->type == UI_BTYPE_LISTROW) && labeledit) return false; return true; } -bool ui_is_but_search_unlink_visible(const uiBut *but) +bool ui_but_is_search_unlink_visible(const uiBut *but) { - BLI_assert(but->type == SEARCH_MENU_UNLINK); + BLI_assert(but->type == UI_BTYPE_SEARCH_MENU_UNLINK); return ((but->editstr == NULL) && (but->drawstr[0] != '\0')); } @@ -6617,7 +6617,7 @@ static uiBut *ui_but_find_mouse_over_ex(ARegion *ar, const int x, const int y, c // if (!win->active) // return NULL; - if (!ui_mouse_inside_region(ar, x, y)) + if (!ui_region_contains_point_px(ar, x, y)) return NULL; for (block = ar->uiblocks.first; block; block = block->next) { @@ -6626,7 +6626,7 @@ static uiBut *ui_but_find_mouse_over_ex(ARegion *ar, const int x, const int y, c ui_window_to_block_fl(ar, block, &mx, &my); for (but = block->buttons.last; but; but = but->prev) { - if (ui_is_but_interactive(but, labeledit)) { + if (ui_but_is_interactive(but, labeledit)) { if (but->pie_dir != UI_RADIAL_NONE) { if (ui_but_isect_pie_seg(block, but)) { butover = but; @@ -6664,7 +6664,7 @@ static uiBut *ui_list_find_mouse_over(ARegion *ar, int x, int y) uiBut *but; float mx, my; - if (!ui_mouse_inside_region(ar, x, y)) + if (!ui_region_contains_point_px(ar, x, y)) return NULL; for (block = ar->uiblocks.first; block; block = block->next) { @@ -6673,7 +6673,7 @@ static uiBut *ui_list_find_mouse_over(ARegion *ar, int x, int y) ui_window_to_block_fl(ar, block, &mx, &my); for (but = block->buttons.last; but; but = but->prev) { - if (but->type == LISTBOX && ui_but_contains_pt(but, mx, my)) { + if (but->type == UI_BTYPE_LISTBOX && ui_but_contains_pt(but, mx, my)) { return but; } } @@ -6754,14 +6754,14 @@ static void button_activate_state(bContext *C, uiBut *but, uiHandleButtonState s button_tooltip_timer_reset(C, but); /* automatic open pulldown block timer */ - if (ELEM(but->type, BLOCK, PULLDOWN)) { + if (ELEM(but->type, UI_BTYPE_BLOCK, UI_BTYPE_PULLDOWN)) { if (data->used_mouse && !data->autoopentimer) { int time; if (but->block->auto_open == true) { /* test for toolbox */ time = 1; } - else if ((but->block->flag & UI_BLOCK_LOOP && but->type != BLOCK) || but->block->auto_open == true) { + else if ((but->block->flag & UI_BLOCK_LOOP && but->type != UI_BTYPE_BLOCK) || but->block->auto_open == true) { time = 5 * U.menuthreshold2; } else if (U.uiflag & USER_MENUOPENAUTO) { @@ -6792,7 +6792,7 @@ static void button_activate_state(bContext *C, uiBut *but, uiHandleButtonState s /* number editing */ if (state == BUTTON_STATE_NUM_EDITING) { - if (ui_is_a_warp_but(but)) + if (ui_but_is_cursor_warp(but)) WM_cursor_grab_enable(CTX_wm_window(C), true, true, NULL); ui_numedit_begin(but, data); } @@ -6802,7 +6802,7 @@ static void button_activate_state(bContext *C, uiBut *but, uiHandleButtonState s if (but->flag & UI_BUT_DRIVEN) WM_report(C, RPT_INFO, "Can't edit driven number value, see graph editor for the driver setup."); - if (ui_is_a_warp_but(but)) { + if (ui_but_is_cursor_warp(but)) { #ifdef USE_CONT_MOUSE_CORRECT if (data->ungrab_mval[0] != FLT_MAX) { @@ -6823,9 +6823,9 @@ static void button_activate_state(bContext *C, uiBut *but, uiHandleButtonState s } /* menu open */ if (state == BUTTON_STATE_MENU_OPEN) - ui_blockopen_begin(C, but, data); + ui_block_open_begin(C, but, data); else if (data->state == BUTTON_STATE_MENU_OPEN) - ui_blockopen_end(C, but, data); + ui_block_open_end(C, but, data); /* add a short delay before exiting, to ensure there is some feedback */ if (state == BUTTON_STATE_WAIT_FLASH) { @@ -6859,13 +6859,13 @@ static void button_activate_state(bContext *C, uiBut *but, uiHandleButtonState s data->state = state; if (state != BUTTON_STATE_EXIT) { - /* When objects for eg. are removed, running ui_check_but() can access + /* When objects for eg. are removed, running ui_but_update() can access * the removed data - so disable update on exit. Also in case of * highlight when not in a popup menu, we remove because data used in * button below popup might have been removed by action of popup. Needs * a more reliable solution... */ if (state != BUTTON_STATE_HIGHLIGHT || (but->block->flag & UI_BLOCK_LOOP)) - ui_check_but(but); + ui_but_update(but); } /* redraw */ @@ -6886,7 +6886,7 @@ static void button_activate_init(bContext *C, ARegion *ar, uiBut *but, uiButtonA copy_v2_fl(data->ungrab_mval, FLT_MAX); #endif - if (ELEM(but->type, BUT_CURVE, SEARCH_MENU, SEARCH_MENU_UNLINK)) { + if (ELEM(but->type, UI_BTYPE_CURVE, UI_BTYPE_SEARCH_MENU, UI_BTYPE_SEARCH_MENU_UNLINK)) { /* XXX curve is temp */ } else { @@ -6913,7 +6913,7 @@ static void button_activate_init(bContext *C, ARegion *ar, uiBut *but, uiButtonA /* activate right away */ if (but->flag & UI_BUT_IMMEDIATE) { - if (but->type == HOTKEYEVT) + if (but->type == UI_BTYPE_HOTKEY_EVENT) button_activate_state(C, but, BUTTON_STATE_WAIT_KEY_EVENT); /* .. more to be added here */ } @@ -6940,7 +6940,7 @@ static void button_activate_init(bContext *C, ARegion *ar, uiBut *but, uiButtonA else if (type == BUTTON_ACTIVATE_APPLY) button_activate_state(C, but, BUTTON_STATE_WAIT_FLASH); - if (but->type == GRIP) { + if (but->type == UI_BTYPE_GRIP) { const bool horizontal = (BLI_rctf_size_x(&but->rect) < BLI_rctf_size_y(&but->rect)); WM_cursor_modal_set(data->window, horizontal ? CURSOR_X_MOVE : CURSOR_Y_MOVE); } @@ -6952,7 +6952,7 @@ static void button_activate_exit(bContext *C, uiBut *but, uiHandleButtonData *da uiBlock *block = but->block; uiBut *bt; - if (but->type == GRIP) { + if (but->type == UI_BTYPE_GRIP) { WM_cursor_modal_restore(data->window); } @@ -6962,7 +6962,7 @@ static void button_activate_exit(bContext *C, uiBut *but, uiHandleButtonData *da /* apply the button action or value */ if (!onfree) - ui_apply_button(C, block, but, data, false); + ui_apply_but(C, block, but, data, false); #ifdef USE_DRAG_MULTINUM if (data->multi_data.has_mbuts) { @@ -6971,7 +6971,7 @@ static void button_activate_exit(bContext *C, uiBut *but, uiHandleButtonData *da bt->flag &= ~UI_BUT_DRAG_MULTI; if (!data->cancel) { - ui_apply_autokey(C, bt); + ui_apply_but_autokey(C, bt); } } } @@ -6995,8 +6995,8 @@ static void button_activate_exit(bContext *C, uiBut *but, uiHandleButtonData *da if (!onfree && !data->cancel) { /* autokey & undo push */ - ui_apply_undo(but); - ui_apply_autokey(C, but); + ui_apply_but_undo(but); + ui_apply_but_autokey(C, but); /* popup menu memory */ if (block->flag & UI_BLOCK_POPUP_MEMORY) @@ -7031,7 +7031,7 @@ static void button_activate_exit(bContext *C, uiBut *but, uiHandleButtonData *da but->flag &= ~(UI_ACTIVE | UI_SELECT); but->flag |= UI_BUT_LAST_ACTIVE; if (!onfree) - ui_check_but(but); + ui_but_update(but); /* adds empty mousemove in queue for re-init handler, in case mouse is * still over a button. we cannot just check for this ourselfs because @@ -7040,7 +7040,7 @@ static void button_activate_exit(bContext *C, uiBut *but, uiHandleButtonData *da WM_event_add_mousemove(C); } -void ui_button_active_free(const bContext *C, uiBut *but) +void ui_but_active_free(const bContext *C, uiBut *but) { uiHandleButtonData *data; @@ -7106,13 +7106,13 @@ static uiBut *ui_context_rna_button_active(const bContext *C) return ui_context_button_active(C, ui_context_rna_button_active_test); } -uiBut *uiContextActiveButton(const struct bContext *C) +uiBut *UI_context_active_but_get(const struct bContext *C) { return ui_context_button_active(C, NULL); } /* helper function for insert keyframe, reset to default, etc operators */ -void uiContextActiveProperty(const bContext *C, struct PointerRNA *ptr, struct PropertyRNA **prop, int *index) +void UI_context_active_but_prop_get(const bContext *C, struct PointerRNA *ptr, struct PropertyRNA **prop, int *index) { uiBut *activebut = ui_context_rna_button_active(C); @@ -7129,7 +7129,7 @@ void uiContextActiveProperty(const bContext *C, struct PointerRNA *ptr, struct P } } -void uiContextActivePropertyHandle(bContext *C) +void UI_context_active_but_prop_handle(bContext *C) { uiBut *activebut = ui_context_rna_button_active(C); if (activebut) { @@ -7143,7 +7143,7 @@ void uiContextActivePropertyHandle(bContext *C) } } -wmOperator *uiContextActiveOperator(const struct bContext *C) +wmOperator *UI_context_active_operator_get(const struct bContext *C) { ARegion *ar_ctx = CTX_wm_region(C); uiBlock *block; @@ -7181,7 +7181,7 @@ wmOperator *uiContextActiveOperator(const struct bContext *C) } /* helper function for insert keyframe, reset to default, etc operators */ -void uiContextAnimUpdate(const bContext *C) +void UI_context_update_anim_flag(const bContext *C) { Scene *scene = CTX_data_scene(C); ARegion *ar = CTX_wm_region(C); @@ -7266,8 +7266,8 @@ static int ui_handle_button_over(bContext *C, const wmEvent *event, ARegion *ar) return WM_UI_HANDLER_CONTINUE; } -/* exported to interface.c: uiButActiveOnly() */ -void ui_button_activate_do(bContext *C, ARegion *ar, uiBut *but) +/* exported to interface.c: UI_but_active_only() */ +void ui_but_activate_event(bContext *C, ARegion *ar, uiBut *but) { wmWindow *win = CTX_wm_window(C); wmEvent event; @@ -7289,12 +7289,12 @@ void ui_button_activate_do(bContext *C, ARegion *ar, uiBut *but) * exported so menus can start with a highlighted button, * even if the mouse isnt over it */ -void ui_button_activate_over(bContext *C, ARegion *ar, uiBut *but) +void ui_but_activate_over(bContext *C, ARegion *ar, uiBut *but) { button_activate_init(C, ar, but, BUTTON_ACTIVATE_OVER); } -void ui_button_execute_begin(struct bContext *UNUSED(C), struct ARegion *ar, uiBut *but, void **active_back) +void ui_but_execute_begin(struct bContext *UNUSED(C), struct ARegion *ar, uiBut *but, void **active_back) { /* note: ideally we would not have to change 'but->active' however * some functions we call don't use data (as they should be doing) */ @@ -7305,12 +7305,12 @@ void ui_button_execute_begin(struct bContext *UNUSED(C), struct ARegion *ar, uiB data->region = ar; } -void ui_button_execute_end(struct bContext *C, struct ARegion *UNUSED(ar), uiBut *but, void *active_back) +void ui_but_execute_end(struct bContext *C, struct ARegion *UNUSED(ar), uiBut *but, void *active_back) { - ui_apply_button(C, but->block, but, but->active, true); + ui_apply_but(C, but->block, but, but->active, true); if ((but->flag & UI_BUT_DRAG_MULTI) == 0) { - ui_apply_autokey(C, but); + ui_apply_but_autokey(C, but); } /* use onfree event so undo is handled by caller and apply is already done above */ button_activate_exit((bContext *)C, but, but->active, false, true); @@ -7322,7 +7322,7 @@ static void ui_handle_button_activate(bContext *C, ARegion *ar, uiBut *but, uiBu uiBut *oldbut; uiHandleButtonData *data; - oldbut = ui_but_find_activated(ar); + oldbut = ui_but_find_active_in_region(ar); if (oldbut) { data = oldbut->active; data->cancel = true; @@ -7361,7 +7361,7 @@ static int ui_handle_button_event(bContext *C, const wmEvent *event, uiBut *but) bool exit = false; if ((!ui_block_is_menu(block) || ui_block_is_pie_menu(but->block)) && - !ui_mouse_inside_button(ar, but, event->x, event->y)) + !ui_but_contains_point_px(ar, but, event->x, event->y)) { exit = true; } @@ -7396,7 +7396,7 @@ static int ui_handle_button_event(bContext *C, const wmEvent *event, uiBut *but) WM_event_remove_timer(data->wm, data->window, data->autoopentimer); data->autoopentimer = NULL; - if (ui_mouse_inside_button(ar, but, event->x, event->y)) + if (ui_but_contains_point_px(ar, but, event->x, event->y)) button_activate_state(C, but, BUTTON_STATE_MENU_OPEN); } @@ -7424,7 +7424,7 @@ static int ui_handle_button_event(bContext *C, const wmEvent *event, uiBut *but) break; case MOUSEMOVE: - if (ELEM(but->type, LINK, INLINK)) { + if (ELEM(but->type, UI_BTYPE_LINK, UI_BTYPE_INLINK)) { ARegion *ar = data->region; but->flag |= UI_SELECT; ui_do_button(C, block, but, event); @@ -7433,7 +7433,7 @@ static int ui_handle_button_event(bContext *C, const wmEvent *event, uiBut *but) else { /* deselect the button when moving the mouse away */ /* also de-activate for buttons that only show higlights */ - if (ui_mouse_inside_button(ar, but, event->x, event->y)) { + if (ui_but_contains_point_px(ar, but, event->x, event->y)) { if (!(but->flag & UI_SELECT)) { but->flag |= (UI_SELECT | UI_ACTIVE); data->cancel = false; @@ -7478,7 +7478,7 @@ static int ui_handle_button_event(bContext *C, const wmEvent *event, uiBut *but) uiBut *bt; if (data->menu && data->menu->region) { - if (ui_mouse_inside_region(data->menu->region, event->x, event->y)) { + if (ui_region_contains_point_px(data->menu->region, event->x, event->y)) { break; } } @@ -7486,7 +7486,7 @@ static int ui_handle_button_event(bContext *C, const wmEvent *event, uiBut *but) bt = ui_but_find_mouse_over(ar, event); if (bt && bt->active != data) { - if (but->type != COLOR) { /* exception */ + if (but->type != UI_BTYPE_COLOR) { /* exception */ data->cancel = true; } button_activate_state(C, but, BUTTON_STATE_EXIT); @@ -7631,7 +7631,7 @@ static int ui_handle_list_event(bContext *C, const wmEvent *event, ARegion *ar) RNA_property_int_set(&but->rnapoin, but->rnaprop, value); RNA_property_update(C, &but->rnapoin, but->rnaprop); - ui_apply_undo(but); + ui_apply_but_undo(but); ui_list->flag |= UILST_SCROLL_TO_ACTIVE_ITEM; ED_region_tag_redraw(ar); @@ -7675,18 +7675,18 @@ static void ui_handle_button_return_submenu(bContext *C, const wmEvent *event, u /* copy over return values from the closing menu */ if ((menu->menuretval & UI_RETURN_OK) || (menu->menuretval & UI_RETURN_UPDATE)) { - if (but->type == COLOR) + if (but->type == UI_BTYPE_COLOR) copy_v3_v3(data->vec, menu->retvec); - else if (but->type == MENU) + else if (but->type == UI_BTYPE_MENU) data->value = menu->retvalue; } if (menu->menuretval & UI_RETURN_UPDATE) { if (data->interactive) { - ui_apply_button(C, but->block, but, data, true); + ui_apply_but(C, but->block, but, data, true); } else { - ui_check_but(but); + ui_but_update(but); } menu->menuretval = 0; @@ -7700,7 +7700,7 @@ static void ui_handle_button_return_submenu(bContext *C, const wmEvent *event, u button_activate_exit(C, but, data, true, false); } else if (menu->menuretval & UI_RETURN_OUT) { - if (event->type == MOUSEMOVE && ui_mouse_inside_button(data->region, but, event->x, event->y)) { + if (event->type == MOUSEMOVE && ui_but_contains_point_px(data->region, but, event->x, event->y)) { button_activate_state(C, but, BUTTON_STATE_HIGHLIGHT); } else { @@ -7960,7 +7960,7 @@ static bool ui_menu_pass_event_to_parent_if_nonactive(uiPopupBlockHandle *menu, static int ui_handle_menu_button(bContext *C, const wmEvent *event, uiPopupBlockHandle *menu) { ARegion *ar = menu->region; - uiBut *but = ui_but_find_activated(ar); + uiBut *but = ui_but_find_active_in_region(ar); int retval; if (but) { @@ -7972,11 +7972,11 @@ static int ui_handle_menu_button(bContext *C, const wmEvent *event, uiPopupBlock else if (!ui_block_is_menu(but->block) || ui_block_is_pie_menu(but->block)) { /* pass, skip for dialogs */ } - else if (!ui_mouse_inside_region(but->active->region, event->x, event->y)) { + else if (!ui_region_contains_point_px(but->active->region, event->x, event->y)) { /* pass, needed to click-exit outside of non-flaoting menus */ } else if ((!ELEM(event->type, MOUSEMOVE, WHEELUPMOUSE, WHEELDOWNMOUSE, MOUSEPAN)) && ISMOUSE(event->type)) { - if (!ui_mouse_inside_button(but->active->region, but, event->x, event->y)) { + if (!ui_but_contains_point_px(but->active->region, but, event->x, event->y)) { but = NULL; } } @@ -8001,7 +8001,7 @@ static int ui_handle_menu_button(bContext *C, const wmEvent *event, uiPopupBlock return retval; } -float ui_block_calculate_pie_segment(uiBlock *block, const float event_xy[2]) +float ui_block_calc_pie_segment(uiBlock *block, const float event_xy[2]) { float seg1[2]; float seg2[2]; @@ -8052,7 +8052,7 @@ static int ui_handle_menu_event( inside_title = inside && ((my + (UI_UNIT_Y * 1.5f)) > block->rect.ymax); /* if there's an active modal button, don't check events or outside, except for search menu */ - but = ui_but_find_activated(ar); + but = ui_but_find_active_in_region(ar); #ifdef USE_DRAG_POPUP if (menu->is_grab) { @@ -8128,15 +8128,15 @@ static int ui_handle_menu_event( if (ui_menu_pass_event_to_parent_if_nonactive(menu, but, level, retval)) break; - but = ui_but_find_activated(ar); + but = ui_but_find_active_in_region(ar); if (!but) { /* no item active, we make first active */ - if (block->direction & UI_TOP) but = ui_but_last(block); + if (block->direction & UI_DIR_UP) but = ui_but_last(block); else but = ui_but_first(block); } - if (but && ELEM(but->type, BLOCK, PULLDOWN)) + if (but && ELEM(but->type, UI_BTYPE_BLOCK, UI_BTYPE_PULLDOWN)) ui_handle_button_activate(C, ar, but, BUTTON_ACTIVATE_OPEN); } @@ -8161,7 +8161,7 @@ static int ui_handle_menu_event( ui_pan_to_scroll(event, &type, &val); if (val == KM_PRESS) { - const eButType type_flip = BUT | ROW; + const eButType type_flip = UI_BTYPE_BUT | UI_BTYPE_ROW; if (ui_menu_pass_event_to_parent_if_nonactive(menu, but, level, retval)) break; @@ -8170,14 +8170,14 @@ static int ui_handle_menu_event( ui_mouse_motion_keynav_init(&menu->keynav_state, event); #endif - but = ui_but_find_activated(ar); + but = ui_but_find_active_in_region(ar); if (but) { - /* is there a situation where UI_LEFT or UI_RIGHT would also change navigation direction? */ - if (((ELEM(type, DOWNARROWKEY, WHEELDOWNMOUSE)) && (block->direction & UI_DOWN)) || - ((ELEM(type, DOWNARROWKEY, WHEELDOWNMOUSE)) && (block->direction & UI_RIGHT)) || - ((ELEM(type, UPARROWKEY, WHEELUPMOUSE)) && (block->direction & UI_TOP))) + /* is there a situation where UI_DIR_LEFT or UI_DIR_RIGHT would also change navigation direction? */ + if (((ELEM(type, DOWNARROWKEY, WHEELDOWNMOUSE)) && (block->direction & UI_DIR_DOWN)) || + ((ELEM(type, DOWNARROWKEY, WHEELDOWNMOUSE)) && (block->direction & UI_DIR_RIGHT)) || + ((ELEM(type, UPARROWKEY, WHEELUPMOUSE)) && (block->direction & UI_DIR_UP))) { - /* the following is just a hack - uiBut->type set to BUT and BUTM have there menus built + /* the following is just a hack - uiBut->type set to UI_BTYPE_BUT and UI_BTYPE_BUT_MENU have there menus built * opposite ways - this should be changed so that all popup-menus use the same uiBlock->direction */ if (but->type & type_flip) but = ui_but_next(but); @@ -8198,9 +8198,9 @@ static int ui_handle_menu_event( } if (!but) { - if (((ELEM(type, UPARROWKEY, WHEELUPMOUSE)) && (block->direction & UI_DOWN)) || - ((ELEM(type, UPARROWKEY, WHEELUPMOUSE)) && (block->direction & UI_RIGHT)) || - ((ELEM(type, DOWNARROWKEY, WHEELDOWNMOUSE)) && (block->direction & UI_TOP))) + if (((ELEM(type, UPARROWKEY, WHEELUPMOUSE)) && (block->direction & UI_DIR_DOWN)) || + ((ELEM(type, UPARROWKEY, WHEELUPMOUSE)) && (block->direction & UI_DIR_RIGHT)) || + ((ELEM(type, DOWNARROWKEY, WHEELDOWNMOUSE)) && (block->direction & UI_DIR_UP))) { if ((bt = ui_but_first(block)) && (bt->type & type_flip)) { bt = ui_but_last(block); @@ -8263,7 +8263,7 @@ static int ui_handle_menu_event( for (but = block->buttons.first; but; but = but->next) { bool doit = false; - if (!ELEM(but->type, LABEL, SEPR, SEPRLINE)) + if (!ELEM(but->type, UI_BTYPE_LABEL, UI_BTYPE_SEPR, UI_BTYPE_SEPR_LINE)) count++; /* exception for rna layer buts */ @@ -8281,7 +8281,7 @@ static int ui_handle_menu_event( if (doit) { /* activate buttons but open menu's */ uiButtonActivateType activate; - if (but->type == PULLDOWN) { + if (but->type == UI_BTYPE_PULLDOWN) { activate = BUTTON_ACTIVATE_OPEN; } else { @@ -8336,15 +8336,15 @@ static int ui_handle_menu_event( for (but = block->buttons.first; but; but = but->next) { if (but->menu_key == event->type) { - if (ELEM(but->type, BUT, BUTM)) { + if (ELEM(but->type, UI_BTYPE_BUT, UI_BTYPE_BUT_MENU)) { /* mainly for operator buttons */ ui_handle_button_activate(C, ar, but, BUTTON_ACTIVATE_APPLY); } - else if (ELEM(but->type, BLOCK, PULLDOWN)) { + else if (ELEM(but->type, UI_BTYPE_BLOCK, UI_BTYPE_PULLDOWN)) { /* open submenus (like right arrow key) */ ui_handle_button_activate(C, ar, but, BUTTON_ACTIVATE_OPEN); } - else if (but->type == MENU) { + else if (but->type == UI_BTYPE_MENU) { /* activate menu items */ ui_handle_button_activate(C, ar, but, BUTTON_ACTIVATE); } @@ -8409,14 +8409,14 @@ static int ui_handle_menu_event( else if (ELEM(event->type, RETKEY, PADENTER) && event->val == KM_PRESS) { /* enter will always close this block, we let the event * get handled by the button if it is activated, otherwise we cancel */ - if (!ui_but_find_activated(ar)) + if (!ui_but_find_active_in_region(ar)) menu->menuretval = UI_RETURN_CANCEL | UI_RETURN_POPUP_OK; } #ifdef USE_DRAG_POPUP else if ((event->type == LEFTMOUSE) && (event->val == KM_PRESS) && (inside && is_floating && inside_title)) { - if (!but || !ui_mouse_inside_button(ar, but, event->x, event->y)) { + if (!but || !ui_but_contains_point_px(ar, but, event->x, event->y)) { if (but) { button_timers_tooltip_remove(C, but); } @@ -8496,7 +8496,7 @@ static int ui_handle_menu_return_submenu(bContext *C, const wmEvent *event, uiPo ar = menu->region; block = ar->uiblocks.first; - but = ui_but_find_activated(ar); + but = ui_but_find_active_in_region(ar); data = but->active; submenu = data->menu; @@ -8538,7 +8538,7 @@ static int ui_handle_menu_return_submenu(bContext *C, const wmEvent *event, uiPo static bool ui_but_pie_menu_supported_apply(uiBut *but) { - return (!ELEM(but->type, NUMSLI, NUM)); + return (!ELEM(but->type, UI_BTYPE_NUM_SLIDER, UI_BTYPE_NUM)); } static int ui_but_pie_menu_apply(bContext *C, uiPopupBlockHandle *menu, uiBut *but, bool force_close) @@ -8546,10 +8546,10 @@ static int ui_but_pie_menu_apply(bContext *C, uiPopupBlockHandle *menu, uiBut *b int retval = WM_UI_HANDLER_BREAK; if (but && ui_but_pie_menu_supported_apply(but)) { - if (but->type == MENU) { + if (but->type == UI_BTYPE_MENU) { /* forcing the pie menu to close will not handle menus */ if (!force_close) { - uiBut *active_but = ui_but_find_activated(menu->region); + uiBut *active_but = ui_but_find_active_in_region(menu->region); if (active_but) { button_activate_exit(C, active_but, active_but->active, false, false); @@ -8563,7 +8563,7 @@ static int ui_but_pie_menu_apply(bContext *C, uiPopupBlockHandle *menu, uiBut *b } } else { - ui_apply_button(C, but->block, but, but->active, false); + ui_apply_but(C, but->block, but, but->active, false); button_activate_exit((bContext *)C, but, but->active, false, true); menu->menuretval = UI_RETURN_OK; @@ -8584,7 +8584,7 @@ static uiBut *ui_block_pie_dir_activate(uiBlock *block, const wmEvent *event, Ra if ((block->flag & UI_BLOCK_NUMSELECT) && event->val == KM_PRESS) { for (but = block->buttons.first; but; but = but->next) { - if (but->pie_dir == dir && !ELEM(but->type, SEPR, SEPRLINE)) { + if (but->pie_dir == dir && !ELEM(but->type, UI_BTYPE_SEPR, UI_BTYPE_SEPR_LINE)) { return but; } } @@ -8600,7 +8600,7 @@ static int ui_but_pie_button_activate(bContext *C, uiBut *but, uiPopupBlockHandl if (but == NULL) return WM_UI_HANDLER_BREAK; - active_but = ui_but_find_activated(menu->region); + active_but = ui_but_find_active_in_region(menu->region); if (active_but) button_activate_exit(C, active_but, active_but->active, false, false); @@ -8609,7 +8609,7 @@ static int ui_but_pie_button_activate(bContext *C, uiBut *but, uiPopupBlockHandl return ui_but_pie_menu_apply(C, menu, but, false); } -static int ui_handler_pie(bContext *C, const wmEvent *event, uiPopupBlockHandle *menu) +static int ui_pie_handler(bContext *C, const wmEvent *event, uiPopupBlockHandle *menu) { ARegion *ar; uiBlock *block; @@ -8646,7 +8646,7 @@ static int ui_handler_pie(bContext *C, const wmEvent *event, uiPopupBlockHandle ui_window_to_block_fl(ar, block, &event_xy[0], &event_xy[1]); - dist = ui_block_calculate_pie_segment(block, event_xy); + dist = ui_block_calc_pie_segment(block, event_xy); if (event->type == TIMER) { if (event->customdata == menu->scrolltimer) { @@ -8706,7 +8706,7 @@ static int ui_handler_pie(bContext *C, const wmEvent *event, uiPopupBlockHandle } if (len_sq < 1.0) { - uiBut *but = ui_but_find_activated(menu->region); + uiBut *but = ui_but_find_active_in_region(menu->region); if (but) { return ui_but_pie_menu_apply(C, menu, but, true); @@ -8732,7 +8732,7 @@ static int ui_handler_pie(bContext *C, const wmEvent *event, uiPopupBlockHandle block->pie_data.flags |= UI_PIE_CLICK_STYLE; } else { - uiBut *but = ui_but_find_activated(menu->region); + uiBut *but = ui_but_find_active_in_region(menu->region); if (but && (U.pie_menu_confirm > 0) && (dist >= U.pie_menu_threshold + U.pie_menu_confirm)) @@ -8871,7 +8871,7 @@ static int ui_handle_menus_recursive( bool do_towards_reinit = false; /* check if we have a submenu, and handle events for it first */ - but = ui_but_find_activated(menu->region); + but = ui_but_find_active_in_region(menu->region); data = (but) ? but->active : NULL; submenu = (data) ? data->menu : NULL; @@ -8898,7 +8898,7 @@ static int ui_handle_menus_recursive( /* now handle events for our own menu */ if (retval == WM_UI_HANDLER_CONTINUE || event->type == TIMER) { - const bool do_but_search = (but && ELEM(but->type, SEARCH_MENU, SEARCH_MENU_UNLINK)); + const bool do_but_search = (but && ELEM(but->type, UI_BTYPE_SEARCH_MENU, UI_BTYPE_SEARCH_MENU_UNLINK)); if (submenu && submenu->menuretval) { const bool do_ret_out_parent = (submenu->menuretval & UI_RETURN_OUT_PARENT) != 0; retval = ui_handle_menu_return_submenu(C, event, menu); @@ -8920,7 +8920,7 @@ static int ui_handle_menus_recursive( if (block->flag & UI_BLOCK_MOVEMOUSE_QUIT) { /* when there is a active search button and we close it, * we need to reinit the mouse coords [#35346] */ - if (ui_but_find_activated(menu->region) != but) { + if (ui_but_find_active_in_region(menu->region) != but) { do_towards_reinit = true; } } @@ -8929,7 +8929,7 @@ static int ui_handle_menus_recursive( uiBlock *block = menu->region->uiblocks.first; if (block->flag & UI_BLOCK_RADIAL) - retval = ui_handler_pie(C, event, menu); + retval = ui_pie_handler(C, event, menu); else if (event->type == LEFTMOUSE || event->val != KM_DBL_CLICK) retval = ui_handle_menu_event(C, event, menu, level, is_parent_inside, is_parent_menu, is_floating); } @@ -8944,7 +8944,7 @@ static int ui_handle_menus_recursive( /* *************** UI event handlers **************** */ -static int ui_handler_region(bContext *C, const wmEvent *event, void *UNUSED(userdata)) +static int ui_region_handler(bContext *C, const wmEvent *event, void *UNUSED(userdata)) { ARegion *ar; uiBut *but; @@ -8959,7 +8959,7 @@ static int ui_handler_region(bContext *C, const wmEvent *event, void *UNUSED(use } /* either handle events for already activated button or try to activate */ - but = ui_but_find_activated(ar); + but = ui_but_find_active_in_region(ar); retval = ui_handler_panel_region(C, event, ar); @@ -8983,7 +8983,7 @@ static int ui_handler_region(bContext *C, const wmEvent *event, void *UNUSED(use return retval; } -static void ui_handler_remove_region(bContext *C, void *UNUSED(userdata)) +static void ui_region_handler_remove(bContext *C, void *UNUSED(userdata)) { bScreen *sc; ARegion *ar; @@ -8991,14 +8991,14 @@ static void ui_handler_remove_region(bContext *C, void *UNUSED(userdata)) ar = CTX_wm_region(C); if (ar == NULL) return; - uiFreeBlocks(C, &ar->uiblocks); + UI_blocklist_free(C, &ar->uiblocks); sc = CTX_wm_screen(C); if (sc == NULL) return; /* delayed apply callbacks, but not for screen level regions, those * we rather do at the very end after closing them all, which will - * be done in ui_handler_region/window */ + * be done in ui_region_handler/window */ if (BLI_findindex(&sc->regionbase, ar) == -1) ui_apply_but_funcs_after(C); } @@ -9014,7 +9014,7 @@ static int ui_handler_region_menu(bContext *C, const wmEvent *event, void *UNUSE if (!ar) ar = CTX_wm_region(C); - but = ui_but_find_activated(ar); + but = ui_but_find_active_in_region(ar); if (but) { uiBut *but_other; @@ -9024,7 +9024,7 @@ static int ui_handler_region_menu(bContext *C, const wmEvent *event, void *UNUSE data = but->active; if ((data->state == BUTTON_STATE_MENU_OPEN) && - (but->type == PULLDOWN) && + (but->type == UI_BTYPE_PULLDOWN) && (but_other = ui_but_find_mouse_over(ar, event)) && (but != but_other) && (but->type == but_other->type)) @@ -9070,7 +9070,7 @@ static int ui_handler_region_menu(bContext *C, const wmEvent *event, void *UNUSE } /* two types of popups, one with operator + enum, other with regular callbacks */ -static int ui_handler_popup(bContext *C, const wmEvent *event, void *userdata) +static int ui_popup_handler(bContext *C, const wmEvent *event, void *userdata) { uiPopupBlockHandle *menu = userdata; struct ARegion *menu_region; @@ -9106,7 +9106,7 @@ static int ui_handler_popup(bContext *C, const wmEvent *event, void *userdata) } ui_popup_block_free(C, menu); - UI_remove_popup_handlers(&win->modalhandlers, menu); + UI_popup_handlers_remove(&win->modalhandlers, menu); #ifdef USE_DRAG_TOGGLE { @@ -9148,7 +9148,7 @@ static int ui_handler_popup(bContext *C, const wmEvent *event, void *userdata) return retval; } -static void ui_handler_remove_popup(bContext *C, void *userdata) +static void ui_popup_handler_remove(bContext *C, void *userdata) { uiPopupBlockHandle *menu = userdata; @@ -9159,25 +9159,25 @@ static void ui_handler_remove_popup(bContext *C, void *userdata) ui_apply_but_funcs_after(C); } -void UI_add_region_handlers(ListBase *handlers) +void UI_region_handlers_add(ListBase *handlers) { - WM_event_remove_ui_handler(handlers, ui_handler_region, ui_handler_remove_region, NULL, false); - WM_event_add_ui_handler(NULL, handlers, ui_handler_region, ui_handler_remove_region, NULL, false); + WM_event_remove_ui_handler(handlers, ui_region_handler, ui_region_handler_remove, NULL, false); + WM_event_add_ui_handler(NULL, handlers, ui_region_handler, ui_region_handler_remove, NULL, false); } -void UI_add_popup_handlers(bContext *C, ListBase *handlers, uiPopupBlockHandle *popup, const bool accept_dbl_click) +void UI_popup_handlers_add(bContext *C, ListBase *handlers, uiPopupBlockHandle *popup, const bool accept_dbl_click) { - WM_event_add_ui_handler(C, handlers, ui_handler_popup, ui_handler_remove_popup, popup, accept_dbl_click); + WM_event_add_ui_handler(C, handlers, ui_popup_handler, ui_popup_handler_remove, popup, accept_dbl_click); } -void UI_remove_popup_handlers(ListBase *handlers, uiPopupBlockHandle *popup) +void UI_popup_handlers_remove(ListBase *handlers, uiPopupBlockHandle *popup) { - WM_event_remove_ui_handler(handlers, ui_handler_popup, ui_handler_remove_popup, popup, false); + WM_event_remove_ui_handler(handlers, ui_popup_handler, ui_popup_handler_remove, popup, false); } -void UI_remove_popup_handlers_all(bContext *C, ListBase *handlers) +void UI_popup_handlers_remove_all(bContext *C, ListBase *handlers) { - WM_event_free_ui_handler_all(C, handlers, ui_handler_popup, ui_handler_remove_popup); + WM_event_free_ui_handler_all(C, handlers, ui_popup_handler, ui_popup_handler_remove); } bool UI_textbutton_activate_rna(const bContext *C, ARegion *ar, @@ -9188,7 +9188,7 @@ bool UI_textbutton_activate_rna(const bContext *C, ARegion *ar, for (block = ar->uiblocks.first; block; block = block->next) { for (but = block->buttons.first; but; but = but->next) { - if (but->type == TEX) { + if (but->type == UI_BTYPE_TEXT) { if (but->rnaprop && but->rnapoin.data == rna_poin_data) { if (STREQ(RNA_property_identifier(but->rnaprop), rna_prop_id)) { break; @@ -9201,7 +9201,7 @@ bool UI_textbutton_activate_rna(const bContext *C, ARegion *ar, } if (but) { - uiButActiveOnly(C, ar, block, but); + UI_but_active_only(C, ar, block, but); return true; } else { @@ -9217,7 +9217,7 @@ bool UI_textbutton_activate_but(const bContext *C, uiBut *actbut) for (block = ar->uiblocks.first; block; block = block->next) { for (but = block->buttons.first; but; but = but->next) - if (but == actbut && but->type == TEX) + if (but == actbut && but->type == UI_BTYPE_TEXT) break; if (but) @@ -9225,7 +9225,7 @@ bool UI_textbutton_activate_but(const bContext *C, uiBut *actbut) } if (but) { - uiButActiveOnly(C, ar, block, but); + UI_but_active_only(C, ar, block, but); return true; } else { @@ -9234,7 +9234,7 @@ bool UI_textbutton_activate_but(const bContext *C, uiBut *actbut) } -void ui_button_clipboard_free(void) +void ui_but_clipboard_free(void) { curvemapping_free_data(&but_copypaste_curve); } |