From 4a37269d0a13df639e7561851ea8cd11fb047769 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 11 Nov 2014 19:02:18 +0100 Subject: UI: Cleanup, replace enum with function --- .../blender/editors/interface/interface_handlers.c | 24 +++++++++++----------- .../blender/editors/interface/interface_intern.h | 1 + 2 files changed, 13 insertions(+), 12 deletions(-) diff --git a/source/blender/editors/interface/interface_handlers.c b/source/blender/editors/interface/interface_handlers.c index 362a4da8093..bfd702e9416 100644 --- a/source/blender/editors/interface/interface_handlers.c +++ b/source/blender/editors/interface/interface_handlers.c @@ -395,6 +395,14 @@ bool ui_but_is_editable(const uiBut *but) UI_BTYPE_ROUNDBOX, UI_BTYPE_LISTBOX, UI_BTYPE_PROGRESS_BAR); } +bool ui_but_is_editable_as_text(const uiBut *but) +{ + return ELEM(but->type, + UI_BTYPE_TEXT, UI_BTYPE_NUM, UI_BTYPE_NUM_SLIDER, + UI_BTYPE_SEARCH_MENU, UI_BTYPE_SEARCH_MENU_UNLINK); + +} + static uiBut *ui_but_prev(uiBut *but) { while (but->prev) { @@ -2522,9 +2530,7 @@ static void ui_textedit_next_but(uiBlock *block, uiBut *actbut, uiHandleButtonDa return; for (but = actbut->next; but; but = but->next) { - if (ELEM(but->type, UI_BTYPE_TEXT, UI_BTYPE_NUM, UI_BTYPE_NUM_SLIDER, - UI_BTYPE_SEARCH_MENU, UI_BTYPE_SEARCH_MENU_UNLINK)) - { + if (ui_but_is_editable_as_text(but)) { if (!(but->flag & UI_BUT_DISABLED)) { data->postbut = but; data->posttype = BUTTON_ACTIVATE_TEXT_EDITING; @@ -2533,9 +2539,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, UI_BTYPE_TEXT, UI_BTYPE_NUM, UI_BTYPE_NUM_SLIDER, - UI_BTYPE_SEARCH_MENU, UI_BTYPE_SEARCH_MENU_UNLINK)) - { + if (ui_but_is_editable_as_text(but)) { if (!(but->flag & UI_BUT_DISABLED)) { data->postbut = but; data->posttype = BUTTON_ACTIVATE_TEXT_EDITING; @@ -2554,9 +2558,7 @@ static void ui_textedit_prev_but(uiBlock *block, uiBut *actbut, uiHandleButtonDa return; for (but = actbut->prev; but; but = but->prev) { - if (ELEM(but->type, UI_BTYPE_TEXT, UI_BTYPE_NUM, UI_BTYPE_NUM_SLIDER, - UI_BTYPE_SEARCH_MENU, UI_BTYPE_SEARCH_MENU_UNLINK)) - { + if (ui_but_is_editable_as_text(but)) { if (!(but->flag & UI_BUT_DISABLED)) { data->postbut = but; data->posttype = BUTTON_ACTIVATE_TEXT_EDITING; @@ -2565,9 +2567,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, UI_BTYPE_TEXT, UI_BTYPE_NUM, UI_BTYPE_NUM_SLIDER, - UI_BTYPE_SEARCH_MENU, UI_BTYPE_SEARCH_MENU_UNLINK)) - { + if (ui_but_is_editable_as_text(but)) { if (!(but->flag & UI_BUT_DISABLED)) { data->postbut = but; data->posttype = BUTTON_ACTIVATE_TEXT_EDITING; diff --git a/source/blender/editors/interface/interface_intern.h b/source/blender/editors/interface/interface_intern.h index 6c80d3f1856..328822e47ef 100644 --- a/source/blender/editors/interface/interface_intern.h +++ b/source/blender/editors/interface/interface_intern.h @@ -617,6 +617,7 @@ extern int ui_but_menu_direction(uiBut *but); extern void ui_but_text_password_hide(char password_str[UI_MAX_DRAW_STR], uiBut *but, const bool restore); extern uiBut *ui_but_find_active_in_region(struct ARegion *ar); bool ui_but_is_editable(const uiBut *but); +bool ui_but_is_editable_as_text(const uiBut *but); void ui_but_pie_dir_visual(RadialDirection dir, float vec[2]); void ui_but_pie_dir(RadialDirection dir, float vec[2]); float ui_block_calc_pie_segment(struct uiBlock *block, const float event_xy[2]); -- cgit v1.2.3