UI: uiBut Indeterminate State #108210

Merged
Julian Eisel merged 15 commits from Harley/blender:Indeterminate into main 2023-07-17 19:37:24 +02:00
1 changed files with 4 additions and 5 deletions
Showing only changes of commit 836f1eeb06 - Show all commits

View File

@ -1882,6 +1882,7 @@ static void widget_draw_text(const uiFontStyle *fstyle,
const char *drawstr = but->drawstr;
const char *drawstr_right = nullptr;
bool use_right_only = false;
const char *indeterminate_str = UI_VALUE_INDETERMINATE_CHAR;
#ifdef WITH_INPUT_IME
const wmIMEData *ime_data;
@ -1946,11 +1947,9 @@ static void widget_draw_text(const uiFontStyle *fstyle,
UI_BTYPE_TEXT,
UI_BTYPE_SEARCH_MENU))
{
Harley marked this conversation as resolved
Review

Do not modify but->drawstr here, the function shouldn't have such side effects. Modify the local drawstr instead.

Do not modify `but->drawstr` here, the function shouldn't have such side effects. Modify the local `drawstr` instead.
STRNCPY(but->drawstr, UI_VALUE_INDETERMINATE_CHAR);
drawstr = indeterminate_str;
drawstr_left_len = strlen(drawstr);
Harley marked this conversation as resolved Outdated

This doesn't have any impact, use_right_only is already false at this point, and may only be set to true later. Same for drawstr_right.

I think a bool drawstr_overridden makes sense. When true we don't draw right aligned text. This could also be set when but->editstr is true.

This doesn't have any impact, `use_right_only` is already false at this point, and may only be set to true later. Same for `drawstr_right`. I think a `bool drawstr_overridden` makes sense. When true we don't draw right aligned text. This could also be set when `but->editstr` is true.
align = UI_STYLE_TEXT_CENTER;
use_right_only = false;
drawstr_right = nullptr;
drawstr_left_len = strlen(but->drawstr);
}
/* text button selection, cursor, composite underline */
@ -5070,7 +5069,7 @@ void ui_draw_but(const bContext *C, ARegion *region, uiStyle *style, uiBut *but,
state.but_flag &= ~UI_BUT_OVERRIDDEN;
}
if ((state.but_drawflag & UI_BUT_INDETERMINATE) && (state.but_flag & UI_SELECT)) {
if (state.but_drawflag & UI_BUT_INDETERMINATE) {
state.but_flag &= ~UI_SELECT;
Harley marked this conversation as resolved
Review

I'd remove the && (state.but_flag & UI_SELECT) part, just makes the logic look unnecessarily complex.

I'd remove the ` && (state.but_flag & UI_SELECT)` part, just makes the logic look unnecessarily complex.
}