Fix undo UI text containing shortcuts & newlines
- Shortcuts were being shown in the undo history. - Multi-line tool-tips now only use the first line.
This commit is contained in:
@@ -171,7 +171,7 @@ static bool ui_mouse_motion_keynav_test(struct uiKeyNavLock *keynav, const wmEve
|
|||||||
/* pixels to move the cursor to get out of keyboard navigation */
|
/* pixels to move the cursor to get out of keyboard navigation */
|
||||||
#define BUTTON_KEYNAV_PX_LIMIT 8
|
#define BUTTON_KEYNAV_PX_LIMIT 8
|
||||||
|
|
||||||
#define MENU_TOWARDS_MARGIN 20 /* margin in pixels */
|
#define MENU_TOWARDS_MARGIN 20 /* margin in pixels */
|
||||||
#define MENU_TOWARDS_WIGGLE_ROOM 64 /* tolerance in pixels */
|
#define MENU_TOWARDS_WIGGLE_ROOM 64 /* tolerance in pixels */
|
||||||
/* drag-lock distance threshold in pixels */
|
/* drag-lock distance threshold in pixels */
|
||||||
#define BUTTON_DRAGLOCK_THRESH 3
|
#define BUTTON_DRAGLOCK_THRESH 3
|
||||||
@@ -822,21 +822,25 @@ static void ui_apply_but_undo(uiBut *but)
|
|||||||
{
|
{
|
||||||
if (but->flag & UI_BUT_UNDO) {
|
if (but->flag & UI_BUT_UNDO) {
|
||||||
const char *str = NULL;
|
const char *str = NULL;
|
||||||
|
size_t str_len_clip = SIZE_MAX - 1;
|
||||||
bool skip_undo = false;
|
bool skip_undo = false;
|
||||||
|
|
||||||
/* define which string to use for undo */
|
/* define which string to use for undo */
|
||||||
if (but->type == UI_BTYPE_MENU) {
|
if (but->type == UI_BTYPE_MENU) {
|
||||||
str = but->drawstr;
|
str = but->drawstr;
|
||||||
|
str_len_clip = ui_but_drawstr_len_without_sep_char(but);
|
||||||
}
|
}
|
||||||
else if (but->drawstr[0]) {
|
else if (but->drawstr[0]) {
|
||||||
str = but->drawstr;
|
str = but->drawstr;
|
||||||
|
str_len_clip = ui_but_drawstr_len_without_sep_char(but);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
str = but->tip;
|
str = but->tip;
|
||||||
|
str_len_clip = ui_but_tip_len_only_first_line(but);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* fallback, else we don't get an undo! */
|
/* fallback, else we don't get an undo! */
|
||||||
if (str == NULL || str[0] == '\0') {
|
if (str == NULL || str[0] == '\0' || str_len_clip == 0) {
|
||||||
str = "Unknown Action";
|
str = "Unknown Action";
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -873,7 +877,7 @@ static void ui_apply_but_undo(uiBut *but)
|
|||||||
|
|
||||||
/* delayed, after all other funcs run, popups are closed, etc */
|
/* delayed, after all other funcs run, popups are closed, etc */
|
||||||
uiAfterFunc *after = ui_afterfunc_new();
|
uiAfterFunc *after = ui_afterfunc_new();
|
||||||
BLI_strncpy(after->undostr, str, sizeof(after->undostr));
|
BLI_strncpy(after->undostr, str, min_zz(str_len_clip + 1, sizeof(after->undostr)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1088,6 +1088,9 @@ uiBut *ui_list_find_mouse_over_ex(struct ARegion *region, int x, int y) ATTR_WAR
|
|||||||
|
|
||||||
bool ui_but_contains_password(const uiBut *but) ATTR_WARN_UNUSED_RESULT;
|
bool ui_but_contains_password(const uiBut *but) ATTR_WARN_UNUSED_RESULT;
|
||||||
|
|
||||||
|
size_t ui_but_drawstr_len_without_sep_char(const uiBut *but);
|
||||||
|
size_t ui_but_tip_len_only_first_line(const uiBut *but);
|
||||||
|
|
||||||
uiBut *ui_but_prev(uiBut *but) ATTR_WARN_UNUSED_RESULT;
|
uiBut *ui_but_prev(uiBut *but) ATTR_WARN_UNUSED_RESULT;
|
||||||
uiBut *ui_but_next(uiBut *but) ATTR_WARN_UNUSED_RESULT;
|
uiBut *ui_but_next(uiBut *but) ATTR_WARN_UNUSED_RESULT;
|
||||||
uiBut *ui_but_first(uiBlock *block) ATTR_WARN_UNUSED_RESULT;
|
uiBut *ui_but_first(uiBlock *block) ATTR_WARN_UNUSED_RESULT;
|
||||||
|
|||||||
@@ -446,6 +446,32 @@ bool ui_but_contains_password(const uiBut *but)
|
|||||||
|
|
||||||
/** \} */
|
/** \} */
|
||||||
|
|
||||||
|
/* -------------------------------------------------------------------- */
|
||||||
|
/** \name Button (#uiBut) Text
|
||||||
|
* \{ */
|
||||||
|
|
||||||
|
size_t ui_but_drawstr_len_without_sep_char(const uiBut *but)
|
||||||
|
{
|
||||||
|
if (but->flag & UI_BUT_HAS_SEP_CHAR) {
|
||||||
|
const char *str_sep = strrchr(but->drawstr, UI_SEP_CHAR);
|
||||||
|
if (str_sep != NULL) {
|
||||||
|
return (str_sep - but->drawstr);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return strlen(but->drawstr);
|
||||||
|
}
|
||||||
|
|
||||||
|
size_t ui_but_tip_len_only_first_line(const uiBut *but)
|
||||||
|
{
|
||||||
|
const char *str_sep = strchr(but->tip, '\n');
|
||||||
|
if (str_sep != NULL) {
|
||||||
|
return (str_sep - but->tip);
|
||||||
|
}
|
||||||
|
return strlen(but->tip);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** \} */
|
||||||
|
|
||||||
/* -------------------------------------------------------------------- */
|
/* -------------------------------------------------------------------- */
|
||||||
/** \name Block (#uiBlock) State
|
/** \name Block (#uiBlock) State
|
||||||
* \{ */
|
* \{ */
|
||||||
|
|||||||
Reference in New Issue
Block a user