diff options
author | Campbell Barton <ideasman42@gmail.com> | 2021-08-19 05:49:10 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2021-08-19 05:50:50 +0300 |
commit | 594790d8a56777c4436b4da2165113d59d57283a (patch) | |
tree | 6f49400d14f2667d2702d708a8418e57f26a492f /source/blender/editors | |
parent | 7a4ef5256a383c2aba4585a2b80ff715b52bf73b (diff) |
UI: add function to access the buttons text without it's shortcut
Diffstat (limited to 'source/blender/editors')
-rw-r--r-- | source/blender/editors/interface/interface_context_menu.c | 8 | ||||
-rw-r--r-- | source/blender/editors/interface/interface_intern.h | 2 | ||||
-rw-r--r-- | source/blender/editors/interface/interface_query.c | 7 |
3 files changed, 10 insertions, 7 deletions
diff --git a/source/blender/editors/interface/interface_context_menu.c b/source/blender/editors/interface/interface_context_menu.c index 8ace057891d..b953d88c896 100644 --- a/source/blender/editors/interface/interface_context_menu.c +++ b/source/blender/editors/interface/interface_context_menu.c @@ -373,13 +373,7 @@ static void ui_but_user_menu_add(bContext *C, uiBut *but, bUserMenu *um) BLI_assert(ui_but_is_user_menu_compatible(C, but)); char drawstr[sizeof(but->drawstr)]; - STRNCPY(drawstr, but->drawstr); - if (but->flag & UI_BUT_HAS_SEP_CHAR) { - char *sep = strrchr(drawstr, UI_SEP_CHAR); - if (sep) { - *sep = '\0'; - } - } + ui_but_drawstr_without_sep_char(but, drawstr, sizeof(drawstr)); MenuType *mt = NULL; if (but->optype) { diff --git a/source/blender/editors/interface/interface_intern.h b/source/blender/editors/interface/interface_intern.h index 6b0b8e8df8f..d61104f094e 100644 --- a/source/blender/editors/interface/interface_intern.h +++ b/source/blender/editors/interface/interface_intern.h @@ -1177,6 +1177,8 @@ uiBut *ui_list_find_mouse_over_ex(const struct ARegion *region, bool ui_but_contains_password(const uiBut *but) ATTR_WARN_UNUSED_RESULT; +size_t ui_but_drawstr_without_sep_char(const uiBut *but, char *str, size_t str_maxlen) + ATTR_NONNULL(1, 2); size_t ui_but_drawstr_len_without_sep_char(const uiBut *but); size_t ui_but_tip_len_only_first_line(const uiBut *but); diff --git a/source/blender/editors/interface/interface_query.c b/source/blender/editors/interface/interface_query.c index 8534c95b6fd..09429bb6df5 100644 --- a/source/blender/editors/interface/interface_query.c +++ b/source/blender/editors/interface/interface_query.c @@ -23,6 +23,7 @@ #include "BLI_listbase.h" #include "BLI_math.h" #include "BLI_rect.h" +#include "BLI_string.h" #include "BLI_utildefines.h" #include "DNA_screen_types.h" @@ -553,6 +554,12 @@ size_t ui_but_drawstr_len_without_sep_char(const uiBut *but) return strlen(but->drawstr); } +size_t ui_but_drawstr_without_sep_char(const uiBut *but, char *str, size_t str_maxlen) +{ + size_t str_len_clip = ui_but_drawstr_len_without_sep_char(but); + return BLI_strncpy_rlen(str, but->drawstr, min_zz(str_len_clip + 1, str_maxlen)); +} + size_t ui_but_tip_len_only_first_line(const uiBut *but) { if (but->tip == NULL) { |